Skip to content

Commit

Permalink
fix: use new shape of app actions (#1285)
Browse files Browse the repository at this point in the history
  • Loading branch information
shikaan authored Apr 12, 2022
1 parent 62074cb commit 0a794e8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
4 changes: 1 addition & 3 deletions lib/entities/app-action-call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ export type AppActionCallProps = {

export type CreateAppActionCallProps = {
/** The body for the call */
body: { [key: string]: any }
/** The headers for the call*/
headers: { [key: string]: any }
parameters: { [key: string]: any }
}

export interface AppActionCall extends AppActionCallProps, DefaultElements<AppActionCallProps> {}
Expand Down
25 changes: 11 additions & 14 deletions lib/entities/app-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ type AppActionSys = Except<BasicMetaSysProps, 'version'> & {
organization: SysLink
}

export type BodyDefinition = Omit<ParameterDefinition, 'labels'>
export type AppActionParameterDefinition = Omit<ParameterDefinition, 'labels'>

export enum ActionTypes {
Endpoint = 'endpoint',
export enum AppActionCategory {
EntryListV1Beta = 'EntryList.v1.0-beta',
NotificationV1Beta = 'Notification.v1.0-beta',
Custom = 'Custom',
}

export type CreateAppActionProps = {
type: ActionTypes.Endpoint
url: string
body?: BodyDefinition[]
headers?: string[]
category: AppActionCategory
parameters?: AppActionParameterDefinition[]
name: string
}

Expand All @@ -31,21 +32,17 @@ export type AppActionProps = {
*/
sys: AppActionSys
/**
* Type of the action
* Category identifying the shape of the action. Choose "Custom" for custom schema
*/
type: ActionTypes
category: AppActionCategory
/**
* Url that will be called when the action is invoked
*/
url: string
/**
* An optional schema for which body parameters need to be provided when calling the action
*/
body?: BodyDefinition[]
/**
* An optional schema for which headers need to be provided hen calling the action
*/
headers?: string[]
parameters?: AppActionParameterDefinition[]
/**
* Human readable name for the action
*/
Expand All @@ -65,7 +62,7 @@ export interface AppAction extends AppActionProps, DefaultElements<AppActionProp
*
* client.getOrganization('<org_id>')
* .then((org) => org.getAppDefinition('<app_def_id>'))
* .then((appDefinition) => appDefinition.getAppAction('<app-bundle-id>'))
* .then((appDefinition) => appDefinition.getAppAction('<app-action-id>'))
* .then((appAction) => appAction.delete())
* .catch(console.error)
* ```
Expand Down
4 changes: 2 additions & 2 deletions lib/export-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export type {
AppAction,
AppActionProps,
CreateAppActionProps,
BodyDefinition,
ActionTypes,
AppActionParameterDefinition,
AppActionCategory,
} from './entities/app-action'
export type {
AppActionCall,
Expand Down

0 comments on commit 0a794e8

Please sign in to comment.