Skip to content

refactor: adds and corrects types of ContentstackCollectin and marketplace functions #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion types/contentstackCollection.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export interface Response {
}

export interface ContentstackCollection<T> extends Response {
items: [T]
items: T[]
count: number
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AnyProperty, SystemFields } from '../utility/fields';
import { ContentstackCollection } from '../contentstackCollection'
import { AnyProperty, SystemFields } from '../../utility/fields';
import { ContentstackCollection } from '../../contentstackCollection'
export interface Hosting {
isEnable(): Promise<AnyProperty>
enable(): Promise<AnyProperty>
Expand Down
89 changes: 89 additions & 0 deletions types/marketplace/app/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { ContentstackCollection } from "../../contentstackCollection";
import { AnyProperty, SystemFields } from "../../utility/fields";
import { Creatable, SystemFunction } from "../../utility/operations";
import { Authorization } from '../authorization';
import { Hosting } from './hosting';
import { Installation } from "../installation";
import { Oauth } from "./oath";

export interface App extends SystemFields, SystemFunction<App> {

update(param?: AnyProperty): Promise<App>
fetch(param?: AnyProperty): Promise<App>
delete(param?: AnyProperty): Promise<App>
oauth(): Oauth
hosting(): Hosting
install(data: {targetUid: string, targetType: AppTarget}): Promise<Installation>
authorize(param: {
responseType: string,
clientId: string,
redirectUri: string,
scope: string,
state: string }): Promise<AnyProperty>
authorization(): Authorization
listInstallations(): Promise<ContentstackCollection<App>>
}

export interface Apps extends Creatable<App, AppData> {
create(): Promise<App>
}

export interface AppData extends AnyProperty {
name: string
description?: string
icon?: string
target_type: AppTarget
ui_location?: UILocation
webhook?: AppWebhook | AppWebhookChannel
oauth?: AppOAuth
}

export interface AppOAuth extends AnyProperty {
redirect_uri?: string
app_token_config?: TokenConfig
user_token_config?: UserTokenConfig
}

export interface TokenConfig extends AnyProperty {
enabled: boolean
scopes: string[]
}

export interface UserTokenConfig extends TokenConfig {
allow_pkce: boolean
}

export interface AppWebhookChannel extends AppWebhook {
target_url: string
channels: string[]
}

export interface AppWebhook extends AnyProperty {
signed: boolean
name: string
enabled?: boolean
app_lifecycle_enabled?: boolean
retry_policy?: string
}

export interface UILocation extends AnyProperty {
signed: boolean
base_url?: string
locations: Location[]
}

export interface Location extends AnyProperty {
type: string
meta: LocationMeta[]
}

export interface LocationMeta extends AnyProperty {
signed: boolean
path: string
name: string
data_type?: string
}

export type AppTarget =
| 'stack'
| 'organization'
8 changes: 8 additions & 0 deletions types/marketplace/app/oath.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { AnyProperty } from '../../utility/fields';
import { AppOAuth } from '.';

export interface Oauth {
fetch(param?: AnyProperty): Promise<AppOAuth>
update(data: { config: AppOAuth, param?: AnyProperty }): Promise<AppOAuth>
getScopes(): Promise<AnyProperty>
}
File renamed without changes.
90 changes: 9 additions & 81 deletions types/marketplace/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,89 +1,17 @@
import { ContentstackCollection } from "../contentstackCollection";
import { AnyProperty, SystemFields } from "../utility/fields";
import { Creatable, SystemFunction } from "../utility/operations";
import { Pagination } from '../utility/pagination';
import { Authorization } from './authorization';
import { Hosting } from './hosting';
import { SystemFunction } from "../utility/operations";
import { Installation, Installations } from "./installation";
import { Oauth } from "./oath";
import { App, Apps } from "./app";
import { AppRequest } from "./apprequest";

export interface App extends SystemFields, SystemFunction<App> {
export interface Marketplace extends SystemFields, SystemFunction<Marketplace> {

install(data: {targetUid: string, targetType: AppTarget}): Promise<Installation>
app(): Apps
app(uid: string): App
installation(): Installations
installation(uid: string): Installation
hosting(): Hosting
authorize(param: {
responseType: string,
clientId: string,
redirectUri: string,
scope: string,
state: string }): Promise<AnyProperty>
listInstallations(): Promise<ContentstackCollection<App>>
authorization(): Authorization
oauth(): Oauth
appRequests(): AppRequest
findAllApps(param?: AnyProperty): Promise<ContentstackCollection<App>>
findAllAuthorizedApps(param?: AnyProperty): Promise<AnyProperty>
}

export interface Apps extends Creatable<App, AppData> {
findAll(param?: AnyProperty): Promise<ContentstackCollection<App>>
findAllAuthorized(param?: Pagination & AnyProperty): Promise<AnyProperty>
}

export interface AppData extends AnyProperty {
name: string
description?: string
icon?: string
target_type: AppTarget
ui_location?: UILocation
webhook?: AppWebhook | AppWebhookChannel
oauth?: AppOAuth
}

export interface AppOAuth extends AnyProperty {
redirect_uri?: string
app_token_config?: TokenConfig
user_token_config?: UserTokenConfig
}

export interface TokenConfig extends AnyProperty {
enabled: boolean
scopes: string[]
}
export interface UserTokenConfig extends TokenConfig {
allow_pkce: boolean
}

export interface AppWebhookChannel extends AppWebhook {
target_url: string
channels: string[]
}

export interface AppWebhook extends AnyProperty {
signed: boolean
name: string
enabled?: boolean
app_lifecycle_enabled?: boolean
retry_policy?: string
}

export interface UILocation extends AnyProperty {
signed: boolean
base_url?: string
locations: Location[]
}

export interface Location extends AnyProperty {
type: string
meta: LocationMeta[]
}

export interface LocationMeta extends AnyProperty {
signed: boolean
path: string
name: string
data_type?: string
}

export type AppTarget =
| 'stack'
| 'organization'
7 changes: 6 additions & 1 deletion types/marketplace/installation.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ export interface Installation extends SystemFields {
uninstall(param?: AnyProperty): Promise<AnyProperty>
configuration(param?: AnyProperty): Promise<AnyProperty>
setConfiguration(config: AnyProperty): Promise<AnyProperty>
getConfigLocation(): Promise<AnyProperty>
serverConfig(param?: AnyProperty): Promise<AnyProperty>
setServerConfig(config: AnyProperty): Promise<AnyProperty>
installationData(): Promise<AnyProperty>
webhooks(webhookUid: string): WebHooks
}

export interface Installations {
findAll(param?: AnyProperty): Promise<ContentstackCollection<Installation>>
fetchAll(param?: AnyProperty): Promise<ContentstackCollection<Installation>>
getInstalledApps(): Promise<AnyProperty>
getInstalledUsers(): Promise<AnyProperty>
getInstalledStacks(): Promise<AnyProperty>
}
8 changes: 0 additions & 8 deletions types/marketplace/oath.d.ts

This file was deleted.

7 changes: 7 additions & 0 deletions types/marketplace/webhooks.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { AnyProperty } from "../utility/fields";

export interface WebHooks {
listExecutionLogs(): Promise<AnyProperty>
getExecutionLog(executionUid: string): Promise<AnyProperty>
retryExecution(executionUid: string): Promise<AnyProperty>
}
7 changes: 2 additions & 5 deletions types/organization.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { Sorting } from './utility/sorting'
import { Pagination } from './utility/pagination'
import { AnyProperty, SystemFields } from './utility/fields'
import { ContentstackCollection, Response } from './contentstackCollection'
import { App, Apps } from './app'
import { AppRequest } from './app/request'
import { Marketplace } from '../lib/marketplace'

export interface Organizations {
fetchAll(params?: AnyProperty): Promise<ContentstackCollection<Organization>>
Expand All @@ -22,9 +21,7 @@ export interface Organization extends SystemFields {
getInvitations(param?: Pagination & AnyProperty): Promise<ContentstackCollection<User>>
resendInvitation(invitationUid: string): Promise<Response>
roles(param?: Pagination & AnyProperty): Promise<ContentstackCollection<Role>>
app(): Apps
app(uid: string): App
appRequest(): AppRequest
marketplace(): Marketplace
}

export interface OrganizationInvite {
Expand Down