From bcc656adf652383e21776d35f72173127ee71cae Mon Sep 17 00:00:00 2001 From: david shibley Date: Tue, 9 Apr 2024 11:04:30 -0600 Subject: [PATCH 1/2] feat: app event handler and transformations [EXT-5142] --- src/requests/typings/function.ts | 94 ++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 42 deletions(-) diff --git a/src/requests/typings/function.ts b/src/requests/typings/function.ts index e68a4b84..b57b8833 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 = void +export type AppEventTransformationResponse = void + /** * 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 /** From b4590dbb66e7cf4f5e2bde44b4b32d580c79751b Mon Sep 17 00:00:00 2001 From: david shibley Date: Tue, 9 Apr 2024 11:39:27 -0600 Subject: [PATCH 2/2] switching to use any --- src/requests/typings/function.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/requests/typings/function.ts b/src/requests/typings/function.ts index b57b8833..8afbb20e 100644 --- a/src/requests/typings/function.ts +++ b/src/requests/typings/function.ts @@ -145,8 +145,8 @@ export type AppEventFilterResponse = { result: boolean } -export type AppEventHandlerResponse = void -export type AppEventTransformationResponse = void +export type AppEventHandlerResponse = any +export type AppEventTransformationResponse = any /** * P: Possibility to type app installation parameters