diff --git a/src/requests/typings/function.ts b/src/requests/typings/function.ts index e68a4b84..8afbb20e 100644 --- a/src/requests/typings/function.ts +++ b/src/requests/typings/function.ts @@ -19,6 +19,8 @@ import { const GRAPHQL_FIELD_MAPPING_EVENT = 'graphql.field.mapping' const GRAPHQL_QUERY_EVENT = 'graphql.query' const APP_EVENT_FILTER = 'appevent.filter' +const APP_EVENT_HANDLER = 'appevent.handler' +const APP_EVENT_TRANSFORMATION = 'appevent.transformation' type GraphQLFieldTypeMappingRequest = { type: typeof GRAPHQL_FIELD_MAPPING_EVENT @@ -88,61 +90,64 @@ type ScheduledActionActions = 'create' | 'save' | 'delete' | 'execute' type BulkActionActions = 'create' | 'execute' type TemplateInstallationActions = 'complete' -type AppEventFilter = { - type: typeof APP_EVENT_FILTER +type AppEventBase = { entityProps: EntityProps - entityAction: EntityActions // 'create' | 'publish' etc etc. + entityAction: EntityActions + type: typeof APP_EVENT_HANDLER | typeof APP_EVENT_TRANSFORMATION | typeof APP_EVENT_FILTER } -export type AppEventContentTypeFilter = { +export type AppEventContentType = { entityType: 'ContentType' -} & AppEventFilter -export type AppEventEntryFilter = { +} & AppEventBase +export type AppEventEntry = { entityType: 'Entry' -} & AppEventFilter -export type AppEventAssetFilter = { +} & AppEventBase +export type AppEventAsset = { entityType: 'Asset' -} & AppEventFilter -export type AppEventAppInstallationFilter = { +} & AppEventBase +export type AppEventAppInstallation = { entityType: 'AppInstallation' -} & AppEventFilter -export type AppEventTaskFilter = { +} & AppEventBase +export type AppEventTask = { entityType: 'Task' -} & AppEventFilter -export type AppEventCommentFilter = { +} & AppEventBase +export type AppEventComment = { entityType: 'Comment' -} & AppEventFilter -export type AppEventReleaseFilter = { +} & AppEventBase +export type AppEventRelease = { entityType: 'Release' -} & AppEventFilter -export type AppEventReleaseActionFilter = { +} & AppEventBase +export type AppEventReleaseAction = { entityType: 'ReleaseAction' -} & AppEventFilter -export type AppEventScheduledActionFilter = { +} & AppEventBase +export type AppEventScheduledAction = { entityType: 'ScheduledAction' -} & AppEventFilter -export type AppEventBulkActionFilter = { +} & AppEventBase +export type AppEventBulkAction = { entityType: 'BulkAction' -} & AppEventFilter -export type AppEventTemplateInstallationFilter = { +} & AppEventBase +export type AppEventTemplateInstallation = { entityType: 'TemplateInstallation' -} & AppEventFilter -export type AppEventFilterRequest = - | AppEventEntryFilter - | AppEventAssetFilter - | AppEventContentTypeFilter - | AppEventAppInstallationFilter - | AppEventTaskFilter - | AppEventCommentFilter - | AppEventReleaseFilter - | AppEventReleaseActionFilter - | AppEventScheduledActionFilter - | AppEventBulkActionFilter - | AppEventTemplateInstallationFilter +} & AppEventBase +export type AppEventRequest = + | AppEventEntry + | AppEventAsset + | AppEventContentType + | AppEventAppInstallation + | AppEventTask + | AppEventComment + | AppEventRelease + | AppEventReleaseAction + | AppEventScheduledAction + | AppEventBulkAction + | AppEventTemplateInstallation export type AppEventFilterResponse = { result: boolean } +export type AppEventHandlerResponse = any +export type AppEventTransformationResponse = any + /** * P: Possibility to type app installation parameters */ @@ -162,15 +167,20 @@ type FunctionEventHandlers = { response: GraphQLQueryResponse } [APP_EVENT_FILTER]: { - event: AppEventFilterRequest + event: AppEventRequest response: AppEventFilterResponse } + [APP_EVENT_HANDLER]: { + event: AppEventRequest + response: AppEventHandlerResponse + } + [APP_EVENT_TRANSFORMATION]: { + event: AppEventRequest + response: AppEventTransformationResponse + } } -export type FunctionEvent = - | GraphQLFieldTypeMappingRequest - | GraphQLQueryRequest - | AppEventFilterRequest +export type FunctionEvent = GraphQLFieldTypeMappingRequest | GraphQLQueryRequest | AppEventRequest export type FunctionEventType = keyof FunctionEventHandlers /**