Skip to content

Commit 195d0eb

Browse files
authored
Merge pull request #61 from contentstack/feat/CS-39614-adds-nrp-auditLog-installation-users
refactor: adds and corrects types of ContentstackCollectin and marketplace functions
2 parents 38de96f + 72750a0 commit 195d0eb

File tree

10 files changed

+124
-98
lines changed

10 files changed

+124
-98
lines changed

types/contentstackCollection.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export interface Response {
33
}
44

55
export interface ContentstackCollection<T> extends Response {
6-
items: [T]
6+
items: T[]
77
count: number
88
}
99

types/marketplace/hosting.d.ts renamed to types/marketplace/app/hosting.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { AnyProperty, SystemFields } from '../utility/fields';
2-
import { ContentstackCollection } from '../contentstackCollection'
1+
import { AnyProperty, SystemFields } from '../../utility/fields';
2+
import { ContentstackCollection } from '../../contentstackCollection'
33
export interface Hosting {
44
isEnable(): Promise<AnyProperty>
55
enable(): Promise<AnyProperty>

types/marketplace/app/index.d.ts

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import { ContentstackCollection } from "../../contentstackCollection";
2+
import { AnyProperty, SystemFields } from "../../utility/fields";
3+
import { Creatable, SystemFunction } from "../../utility/operations";
4+
import { Authorization } from '../authorization';
5+
import { Hosting } from './hosting';
6+
import { Installation } from "../installation";
7+
import { Oauth } from "./oath";
8+
9+
export interface App extends SystemFields, SystemFunction<App> {
10+
11+
update(param?: AnyProperty): Promise<App>
12+
fetch(param?: AnyProperty): Promise<App>
13+
delete(param?: AnyProperty): Promise<App>
14+
oauth(): Oauth
15+
hosting(): Hosting
16+
install(data: {targetUid: string, targetType: AppTarget}): Promise<Installation>
17+
authorize(param: {
18+
responseType: string,
19+
clientId: string,
20+
redirectUri: string,
21+
scope: string,
22+
state: string }): Promise<AnyProperty>
23+
authorization(): Authorization
24+
listInstallations(): Promise<ContentstackCollection<App>>
25+
}
26+
27+
export interface Apps extends Creatable<App, AppData> {
28+
create(): Promise<App>
29+
}
30+
31+
export interface AppData extends AnyProperty {
32+
name: string
33+
description?: string
34+
icon?: string
35+
target_type: AppTarget
36+
ui_location?: UILocation
37+
webhook?: AppWebhook | AppWebhookChannel
38+
oauth?: AppOAuth
39+
}
40+
41+
export interface AppOAuth extends AnyProperty {
42+
redirect_uri?: string
43+
app_token_config?: TokenConfig
44+
user_token_config?: UserTokenConfig
45+
}
46+
47+
export interface TokenConfig extends AnyProperty {
48+
enabled: boolean
49+
scopes: string[]
50+
}
51+
52+
export interface UserTokenConfig extends TokenConfig {
53+
allow_pkce: boolean
54+
}
55+
56+
export interface AppWebhookChannel extends AppWebhook {
57+
target_url: string
58+
channels: string[]
59+
}
60+
61+
export interface AppWebhook extends AnyProperty {
62+
signed: boolean
63+
name: string
64+
enabled?: boolean
65+
app_lifecycle_enabled?: boolean
66+
retry_policy?: string
67+
}
68+
69+
export interface UILocation extends AnyProperty {
70+
signed: boolean
71+
base_url?: string
72+
locations: Location[]
73+
}
74+
75+
export interface Location extends AnyProperty {
76+
type: string
77+
meta: LocationMeta[]
78+
}
79+
80+
export interface LocationMeta extends AnyProperty {
81+
signed: boolean
82+
path: string
83+
name: string
84+
data_type?: string
85+
}
86+
87+
export type AppTarget =
88+
| 'stack'
89+
| 'organization'

types/marketplace/app/oath.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { AnyProperty } from '../../utility/fields';
2+
import { AppOAuth } from '.';
3+
4+
export interface Oauth {
5+
fetch(param?: AnyProperty): Promise<AppOAuth>
6+
update(data: { config: AppOAuth, param?: AnyProperty }): Promise<AppOAuth>
7+
getScopes(): Promise<AnyProperty>
8+
}
File renamed without changes.

types/marketplace/index.d.ts

Lines changed: 9 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,17 @@
11
import { ContentstackCollection } from "../contentstackCollection";
22
import { AnyProperty, SystemFields } from "../utility/fields";
3-
import { Creatable, SystemFunction } from "../utility/operations";
4-
import { Pagination } from '../utility/pagination';
5-
import { Authorization } from './authorization';
6-
import { Hosting } from './hosting';
3+
import { SystemFunction } from "../utility/operations";
74
import { Installation, Installations } from "./installation";
8-
import { Oauth } from "./oath";
5+
import { App, Apps } from "./app";
6+
import { AppRequest } from "./apprequest";
97

10-
export interface App extends SystemFields, SystemFunction<App> {
8+
export interface Marketplace extends SystemFields, SystemFunction<Marketplace> {
119

12-
install(data: {targetUid: string, targetType: AppTarget}): Promise<Installation>
10+
app(): Apps
11+
app(uid: string): App
1312
installation(): Installations
1413
installation(uid: string): Installation
15-
hosting(): Hosting
16-
authorize(param: {
17-
responseType: string,
18-
clientId: string,
19-
redirectUri: string,
20-
scope: string,
21-
state: string }): Promise<AnyProperty>
22-
listInstallations(): Promise<ContentstackCollection<App>>
23-
authorization(): Authorization
24-
oauth(): Oauth
14+
appRequests(): AppRequest
15+
findAllApps(param?: AnyProperty): Promise<ContentstackCollection<App>>
16+
findAllAuthorizedApps(param?: AnyProperty): Promise<AnyProperty>
2517
}
26-
27-
export interface Apps extends Creatable<App, AppData> {
28-
findAll(param?: AnyProperty): Promise<ContentstackCollection<App>>
29-
findAllAuthorized(param?: Pagination & AnyProperty): Promise<AnyProperty>
30-
}
31-
32-
export interface AppData extends AnyProperty {
33-
name: string
34-
description?: string
35-
icon?: string
36-
target_type: AppTarget
37-
ui_location?: UILocation
38-
webhook?: AppWebhook | AppWebhookChannel
39-
oauth?: AppOAuth
40-
}
41-
42-
export interface AppOAuth extends AnyProperty {
43-
redirect_uri?: string
44-
app_token_config?: TokenConfig
45-
user_token_config?: UserTokenConfig
46-
}
47-
48-
export interface TokenConfig extends AnyProperty {
49-
enabled: boolean
50-
scopes: string[]
51-
}
52-
export interface UserTokenConfig extends TokenConfig {
53-
allow_pkce: boolean
54-
}
55-
56-
export interface AppWebhookChannel extends AppWebhook {
57-
target_url: string
58-
channels: string[]
59-
}
60-
61-
export interface AppWebhook extends AnyProperty {
62-
signed: boolean
63-
name: string
64-
enabled?: boolean
65-
app_lifecycle_enabled?: boolean
66-
retry_policy?: string
67-
}
68-
69-
export interface UILocation extends AnyProperty {
70-
signed: boolean
71-
base_url?: string
72-
locations: Location[]
73-
}
74-
75-
export interface Location extends AnyProperty {
76-
type: string
77-
meta: LocationMeta[]
78-
}
79-
80-
export interface LocationMeta extends AnyProperty {
81-
signed: boolean
82-
path: string
83-
name: string
84-
data_type?: string
85-
}
86-
87-
export type AppTarget =
88-
| 'stack'
89-
| 'organization'

types/marketplace/installation.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@ export interface Installation extends SystemFields {
77
uninstall(param?: AnyProperty): Promise<AnyProperty>
88
configuration(param?: AnyProperty): Promise<AnyProperty>
99
setConfiguration(config: AnyProperty): Promise<AnyProperty>
10+
getConfigLocation(): Promise<AnyProperty>
1011
serverConfig(param?: AnyProperty): Promise<AnyProperty>
1112
setServerConfig(config: AnyProperty): Promise<AnyProperty>
1213
installationData(): Promise<AnyProperty>
14+
webhooks(webhookUid: string): WebHooks
1315
}
1416

1517
export interface Installations {
16-
findAll(param?: AnyProperty): Promise<ContentstackCollection<Installation>>
18+
fetchAll(param?: AnyProperty): Promise<ContentstackCollection<Installation>>
19+
getInstalledApps(): Promise<AnyProperty>
20+
getInstalledUsers(): Promise<AnyProperty>
21+
getInstalledStacks(): Promise<AnyProperty>
1722
}

types/marketplace/oath.d.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

types/marketplace/webhooks.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { AnyProperty } from "../utility/fields";
2+
3+
export interface WebHooks {
4+
listExecutionLogs(): Promise<AnyProperty>
5+
getExecutionLog(executionUid: string): Promise<AnyProperty>
6+
retryExecution(executionUid: string): Promise<AnyProperty>
7+
}

types/organization.d.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import { Sorting } from './utility/sorting'
55
import { Pagination } from './utility/pagination'
66
import { AnyProperty, SystemFields } from './utility/fields'
77
import { ContentstackCollection, Response } from './contentstackCollection'
8-
import { App, Apps } from './app'
9-
import { AppRequest } from './app/request'
8+
import { Marketplace } from '../lib/marketplace'
109

1110
export interface Organizations {
1211
fetchAll(params?: AnyProperty): Promise<ContentstackCollection<Organization>>
@@ -22,9 +21,7 @@ export interface Organization extends SystemFields {
2221
getInvitations(param?: Pagination & AnyProperty): Promise<ContentstackCollection<User>>
2322
resendInvitation(invitationUid: string): Promise<Response>
2423
roles(param?: Pagination & AnyProperty): Promise<ContentstackCollection<Role>>
25-
app(): Apps
26-
app(uid: string): App
27-
appRequest(): AppRequest
24+
marketplace(): Marketplace
2825
}
2926

3027
export interface OrganizationInvite {

0 commit comments

Comments
 (0)