@webiny/api-scheduler 0.0.0-unstable.e6f0dc8ca7 → 0.0.0-unstable.eb81deee7e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ScheduledActionLambdaHandler.d.ts +18 -0
- package/ScheduledActionLambdaHandler.js +41 -0
- package/ScheduledActionLambdaHandler.js.map +1 -0
- package/SchedulerFeature.d.ts +5 -0
- package/SchedulerFeature.js +21 -0
- package/SchedulerFeature.js.map +1 -0
- package/constants.js +11 -14
- package/constants.js.map +1 -1
- package/domain/SchedulePrivateModel.js +26 -22
- package/domain/SchedulePrivateModel.js.map +1 -1
- package/domain/ScheduledActionId.js +12 -4
- package/domain/ScheduledActionId.js.map +1 -1
- package/domain/ScheduledActionIdWithVersion.js +5 -6
- package/domain/ScheduledActionIdWithVersion.js.map +1 -1
- package/domain/ScheduledActionMapper.js +37 -32
- package/domain/ScheduledActionMapper.js.map +1 -1
- package/domain/errors.d.ts +1 -1
- package/domain/errors.js +52 -80
- package/domain/errors.js.map +1 -1
- package/domain/isValidDate.js +4 -9
- package/domain/isValidDate.js.map +1 -1
- package/exports/api/scheduler.d.ts +1 -1
- package/exports/api/scheduler.js +1 -3
- package/features/CancelScheduledAction/CancelScheduledActionUseCase.d.ts +7 -7
- package/features/CancelScheduledAction/CancelScheduledActionUseCase.js +45 -69
- package/features/CancelScheduledAction/CancelScheduledActionUseCase.js.map +1 -1
- package/features/CancelScheduledAction/abstractions.d.ts +2 -1
- package/features/CancelScheduledAction/abstractions.js +2 -11
- package/features/CancelScheduledAction/abstractions.js.map +1 -1
- package/features/CancelScheduledAction/feature.d.ts +1 -1
- package/features/CancelScheduledAction/feature.js +6 -12
- package/features/CancelScheduledAction/feature.js.map +1 -1
- package/features/CancelScheduledAction/index.js +0 -2
- package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.d.ts +3 -3
- package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.js +75 -93
- package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.js.map +1 -1
- package/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.js +21 -25
- package/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.js.map +1 -1
- package/features/ExecuteScheduledAction/abstractions.d.ts +2 -1
- package/features/ExecuteScheduledAction/abstractions.js +12 -37
- package/features/ExecuteScheduledAction/abstractions.js.map +1 -1
- package/features/ExecuteScheduledAction/feature.d.ts +1 -1
- package/features/ExecuteScheduledAction/feature.js +7 -13
- package/features/ExecuteScheduledAction/feature.js.map +1 -1
- package/features/ExecuteScheduledAction/index.js +0 -2
- package/features/GetScheduledAction/GetScheduledActionUseCase.d.ts +5 -5
- package/features/GetScheduledAction/GetScheduledActionUseCase.js +36 -53
- package/features/GetScheduledAction/GetScheduledActionUseCase.js.map +1 -1
- package/features/GetScheduledAction/abstractions.js +2 -12
- package/features/GetScheduledAction/abstractions.js.map +1 -1
- package/features/GetScheduledAction/feature.js +6 -12
- package/features/GetScheduledAction/feature.js.map +1 -1
- package/features/GetScheduledAction/index.js +0 -2
- package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.d.ts +5 -5
- package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js +49 -70
- package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js.map +1 -1
- package/features/GetTargetScheduledAction/abstractions.js +2 -1
- package/features/GetTargetScheduledAction/abstractions.js.map +1 -1
- package/features/GetTargetScheduledAction/feature.js +6 -12
- package/features/GetTargetScheduledAction/feature.js.map +1 -1
- package/features/GetTargetScheduledAction/index.js +0 -2
- package/features/ListScheduledActions/ListScheduledActionsUseCase.d.ts +5 -5
- package/features/ListScheduledActions/ListScheduledActionsUseCase.js +52 -65
- package/features/ListScheduledActions/ListScheduledActionsUseCase.js.map +1 -1
- package/features/ListScheduledActions/abstractions.js +2 -13
- package/features/ListScheduledActions/abstractions.js.map +1 -1
- package/features/ListScheduledActions/feature.js +6 -12
- package/features/ListScheduledActions/feature.js.map +1 -1
- package/features/ListScheduledActions/index.js +0 -2
- package/features/NamespaceHandler/NamespaceHandlerExecutioner.js +18 -17
- package/features/NamespaceHandler/NamespaceHandlerExecutioner.js.map +1 -1
- package/features/NamespaceHandler/abstractions.js +3 -13
- package/features/NamespaceHandler/abstractions.js.map +1 -1
- package/features/NamespaceHandler/feature.d.ts +4 -0
- package/features/NamespaceHandler/feature.js +11 -0
- package/features/NamespaceHandler/feature.js.map +1 -0
- package/features/NamespaceHandler/index.js +0 -2
- package/features/ScheduleAction/ScheduleActionUseCase.d.ts +6 -6
- package/features/ScheduleAction/ScheduleActionUseCase.js +153 -201
- package/features/ScheduleAction/ScheduleActionUseCase.js.map +1 -1
- package/features/ScheduleAction/abstractions.d.ts +1 -0
- package/features/ScheduleAction/abstractions.js +2 -11
- package/features/ScheduleAction/abstractions.js.map +1 -1
- package/features/ScheduleAction/feature.js +6 -12
- package/features/ScheduleAction/feature.js.map +1 -1
- package/features/ScheduleAction/index.js +0 -2
- package/features/ScheduledActionModelProvider.d.ts +26 -0
- package/features/ScheduledActionModelProvider.js +22 -0
- package/features/ScheduledActionModelProvider.js.map +1 -0
- package/features/SchedulerFeature.js +11 -19
- package/features/SchedulerFeature.js.map +1 -1
- package/features/SchedulerService/VoidSchedulerService.d.ts +9 -9
- package/features/SchedulerService/VoidSchedulerService.js +17 -24
- package/features/SchedulerService/VoidSchedulerService.js.map +1 -1
- package/features/permissions/SchedulerPermissionsResolver.d.ts +12 -0
- package/features/permissions/SchedulerPermissionsResolver.js +42 -0
- package/features/permissions/SchedulerPermissionsResolver.js.map +1 -0
- package/features/permissions/abstractions.d.ts +18 -12
- package/features/permissions/abstractions.js +4 -3
- package/features/permissions/abstractions.js.map +1 -1
- package/graphql/SchedulerGraphQLFactory.d.ts +4 -3
- package/graphql/SchedulerGraphQLFactory.js +90 -115
- package/graphql/SchedulerGraphQLFactory.js.map +1 -1
- package/{features/permissions → graphql}/feature.d.ts +1 -1
- package/graphql/feature.js +11 -0
- package/graphql/feature.js.map +1 -0
- package/graphql/index.js +0 -2
- package/index.d.ts +3 -2
- package/index.js +3 -4
- package/package.json +18 -25
- package/shared/abstractions.d.ts +30 -7
- package/shared/abstractions.js +4 -32
- package/shared/abstractions.js.map +1 -1
- package/context.d.ts +0 -7
- package/context.js +0 -47
- package/context.js.map +0 -1
- package/createEventHandler.d.ts +0 -14
- package/createEventHandler.js +0 -50
- package/createEventHandler.js.map +0 -1
- package/createScheduler.d.ts +0 -6
- package/createScheduler.js +0 -11
- package/createScheduler.js.map +0 -1
- package/domain/permissionsSchema.d.ts +0 -9
- package/domain/permissionsSchema.js +0 -12
- package/domain/permissionsSchema.js.map +0 -1
- package/exports/api/scheduler.js.map +0 -1
- package/features/CancelScheduledAction/index.js.map +0 -1
- package/features/ExecuteScheduledAction/index.js.map +0 -1
- package/features/GetScheduledAction/index.js.map +0 -1
- package/features/GetTargetScheduledAction/index.js.map +0 -1
- package/features/ListScheduledActions/index.js.map +0 -1
- package/features/NamespaceHandler/index.js.map +0 -1
- package/features/ScheduleAction/index.js.map +0 -1
- package/features/SchedulerService/EventBridgeSchedulerService.d.ts +0 -26
- package/features/SchedulerService/EventBridgeSchedulerService.js +0 -133
- package/features/SchedulerService/EventBridgeSchedulerService.js.map +0 -1
- package/features/permissions/feature.js +0 -6
- package/features/permissions/feature.js.map +0 -1
- package/graphql/index.js.map +0 -1
- package/index.js.map +0 -1
- package/manifest.d.ts +0 -17
- package/manifest.js +0 -39
- package/manifest.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CoreGraphQLSchemaFactory","GetScheduledActionUseCase","ErrorResponse","ListResponse","Response","ListScheduledActionsUseCase","ScheduleActionUseCase","CancelScheduledActionUseCase","ScheduledActionNotFoundError","ScheduledActionMapper","GetTargetScheduledActionUseCase","SchedulerGraphQL","execute","builder","addTypeDefs","addResolver","path","resolver","dependencies","useCase","args","result","isFail","error","toGraphQL","value","where","namespace","items","map","item","meta","SchedulerGraphQLFactory","createImplementation","implementation"],"sources":["SchedulerGraphQLFactory.ts"],"sourcesContent":["import { GraphQLSchemaBuilder } from \"@webiny/handler-graphql/features/GraphQLSchemaBuilder/abstractions\";\nimport { CoreGraphQLSchemaFactory } from \"@webiny/handler-graphql/graphql/abstractions.core.js\";\nimport { GetScheduledActionUseCase } from \"~/features/GetScheduledAction/index.js\";\nimport { ErrorResponse, ListResponse, Response } from \"@webiny/handler-graphql/responses.js\";\nimport { ListScheduledActionsUseCase } from \"~/features/ListScheduledActions/index.js\";\nimport { ScheduleActionUseCase } from \"~/features/ScheduleAction/index.js\";\nimport { CancelScheduledActionUseCase } from \"~/features/CancelScheduledAction/index.js\";\nimport { ScheduledActionNotFoundError } from \"~/domain/errors.js\";\nimport type { Identity, ScheduledActionType } from \"~/shared/abstractions.js\";\nimport { ScheduledActionMapper } from \"~/domain/ScheduledActionMapper.js\";\nimport { GetTargetScheduledActionUseCase } from \"~/features/GetTargetScheduledAction/index.js\";\n\ninterface IListScheduledActionsArgs extends ListScheduledActionsUseCase.Params {\n namespace: string;\n}\n\ninterface IScheduleRecordOutput {\n id: string;\n targetId: string;\n namespace: string;\n scheduledBy: Identity;\n publishOn: Date | null;\n unpublishOn: Date | null;\n actionType: ScheduledActionType;\n title: string;\n}\n\nexport class SchedulerGraphQL implements CoreGraphQLSchemaFactory.Interface {\n public async execute(\n builder: GraphQLSchemaBuilder.Interface\n ): Promise<GraphQLSchemaBuilder.Interface> {\n builder.addTypeDefs(`\n enum ScheduleRecordType {\n publish\n unpublish\n }\n \n type ScheduleError {\n message: String!\n code: String\n data: JSON\n stack: String\n }\n \n type ScheduleListMeta {\n hasMoreItems: Boolean!\n totalCount: Int!\n cursor: String\n }\n \n type ScheduleIdentity {\n id: String!\n displayName: String\n type: String\n }\n \n type ScheduleRecord {\n id: ID!\n targetId: String!\n namespace: String!\n scheduledBy: ScheduleIdentity!\n publishOn: DateTime\n unpublishOn: DateTime\n actionType: ScheduleRecordType!\n title: String!\n }\n\n type GetScheduledActionResponse {\n data: ScheduleRecord\n error: ScheduleError\n }\n\n type ListScheduledActionsResponse {\n data: [ScheduleRecord!]\n error: ScheduleError\n meta: ScheduleListMeta\n }\n\n type ScheduleActionResponse {\n data: ScheduleRecord\n error: ScheduleError\n }\n\n type CancelScheduledActionResponse {\n data: Boolean\n error: ScheduleError\n }\n\n input ListScheduledActionsWhereInput {\n targetId: String\n targetId_in: [String!]\n title: String\n title_contains: String\n title_not_contains: String\n actionType: ScheduleRecordType\n actionType_in: [ScheduleRecordType!]\n scheduledBy: String\n scheduledBy_in: [String!]\n scheduledFor: DateTime\n scheduledFor_gte: DateTime\n scheduledFor_lte: DateTime\n }\n\n enum ListScheduledActionsSorter {\n title_ASC\n title_DESC\n scheduledFor_ASC\n scheduledFor_DESC\n }\n \n type SchedulerQuery {\n _empty: String\n }\n \n type SchedulerMutation {\n _empty: String\n }\n\n extend type SchedulerQuery {\n # Fetch scheduled action by its own ID\n getScheduledAction(namespace: String!, id: ID!): GetScheduledActionResponse!\n \n # Fetch scheduled action by target ID\n getTargetScheduledAction(namespace: String!, id: ID!): GetScheduledActionResponse!\n \n listScheduledActions(\n namespace: String!\n where: ListScheduledActionsWhereInput\n sort: [ListScheduledActionsSorter!]\n limit: Int\n after: String\n ): ListScheduledActionsResponse!\n }\n\n extend type SchedulerMutation {\n scheduleAction(\n namespace: String!\n targetId: ID!\n immediately: Boolean\n scheduleFor: DateTime\n actionType: ScheduleRecordType!\n ): ScheduleActionResponse!\n \n cancelScheduledAction(namespace: String!, id: ID!): CancelScheduledActionResponse!\n }\n \n extend type Query {\n scheduler: SchedulerQuery\n }\n \n extend type Mutation {\n scheduler: SchedulerMutation\n }\n `);\n\n builder.addResolver({\n path: \"Query.scheduler\",\n resolver: () => {\n return async () => {\n return {};\n };\n }\n });\n builder.addResolver({\n path: \"Mutation.scheduler\",\n resolver: () => {\n return async () => {\n return {};\n };\n }\n });\n\n builder.addResolver<GetScheduledActionUseCase.Params>({\n path: \"SchedulerQuery.getScheduledAction\",\n dependencies: [GetScheduledActionUseCase],\n resolver: (useCase: GetScheduledActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n if (result.error instanceof ScheduledActionNotFoundError) {\n return new Response(null);\n }\n return new ErrorResponse(result.error);\n }\n\n return new Response<IScheduleRecordOutput>(\n ScheduledActionMapper.toGraphQL(result.value)\n );\n };\n }\n });\n\n builder.addResolver<GetTargetScheduledActionUseCase.Params>({\n path: \"SchedulerQuery.getTargetScheduledAction\",\n dependencies: [GetTargetScheduledActionUseCase],\n resolver: (useCase: GetTargetScheduledActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n if (result.error instanceof ScheduledActionNotFoundError) {\n return new Response(null);\n }\n return new ErrorResponse(result.error);\n }\n\n return new Response<IScheduleRecordOutput>(\n ScheduledActionMapper.toGraphQL(result.value)\n );\n };\n }\n });\n\n builder.addResolver<IListScheduledActionsArgs>({\n path: \"SchedulerQuery.listScheduledActions\",\n dependencies: [ListScheduledActionsUseCase],\n resolver: (useCase: ListScheduledActionsUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute({\n ...args,\n where: {\n ...args.where,\n namespace: args.namespace\n }\n });\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new ListResponse<IScheduleRecordOutput>(\n result.value.items.map(item => {\n return ScheduledActionMapper.toGraphQL(item);\n }),\n result.value.meta\n );\n };\n }\n });\n\n builder.addResolver<ScheduleActionUseCase.Params>({\n path: \"SchedulerMutation.scheduleAction\",\n dependencies: [ScheduleActionUseCase],\n resolver: (useCase: ScheduleActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response<IScheduleRecordOutput>(\n ScheduledActionMapper.toGraphQL(result.value)\n );\n };\n }\n });\n\n builder.addResolver<CancelScheduledActionUseCase.Params>({\n path: \"SchedulerMutation.cancelScheduledAction\",\n dependencies: [CancelScheduledActionUseCase],\n resolver: (useCase: CancelScheduledActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response<boolean>(result.value);\n };\n }\n });\n\n return builder;\n }\n}\n\nexport const SchedulerGraphQLFactory = CoreGraphQLSchemaFactory.createImplementation({\n dependencies: [],\n implementation: SchedulerGraphQL\n});\n"],"mappings":"AACA,SAASA,wBAAwB,QAAQ,sDAAsD;AAC/F,SAASC,yBAAyB;AAClC,SAASC,aAAa,EAAEC,YAAY,EAAEC,QAAQ,QAAQ,sCAAsC;AAC5F,SAASC,2BAA2B;AACpC,SAASC,qBAAqB;AAC9B,SAASC,4BAA4B;AACrC,SAASC,4BAA4B;AAErC,SAASC,qBAAqB;AAC9B,SAASC,+BAA+B;AAiBxC,OAAO,MAAMC,gBAAgB,CAA+C;EACxE,MAAaC,OAAOA,CAChBC,OAAuC,EACA;IACvCA,OAAO,CAACC,WAAW,CAAC;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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UACvB,MAAMC,MAAM,GAAG,MAAMF,OAAO,CAACP,OAAO,CAACQ,IAAI,CAAC;UAE1C,IAAIC,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;YACjB,OAAO,IAAIpB,aAAa,CAACmB,MAAM,CAACE,KAAK,CAAC;UAC1C;UAEA,OAAO,IAAInB,QAAQ,CACfK,qBAAqB,CAACe,SAAS,CAACH,MAAM,CAACI,KAAK,CAChD,CAAC;QACL,CAAC;MACL;IACJ,CAAC,CAAC;IAEFZ,OAAO,CAACE,WAAW,CAAsC;MACrDC,IAAI,EAAE,yCAAyC;MAC/CE,YAAY,EAAE,CAACX,4BAA4B,CAAC;MAC5CU,QAAQ,EAAGE,OAA+C,IAAK;QAC3D,OAAO,OAAO;UAAEC;QAAK,CAAC,KAAK;UACvB,MAAMC,MAAM,GAAG,MAAMF,OAAO,CAACP,OAAO,CAACQ,IAAI,CAAC;UAE1C,IAAIC,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;YACjB,OAAO,IAAIpB,aAAa,CAACmB,MAAM,CAACE,KAAK,CAAC;UAC1C;UAEA,OAAO,IAAInB,QAAQ,CAAUiB,MAAM,CAACI,KAAK,CAAC;QAC9C,CAAC;MACL;IACJ,CAAC,CAAC;IAEF,OAAOZ,OAAO;EAClB;AACJ;AAEA,OAAO,MAAMmB,uBAAuB,GAAGhC,wBAAwB,CAACiC,oBAAoB,CAAC;EACjFf,YAAY,EAAE,EAAE;EAChBgB,cAAc,EAAEvB;AACpB,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"graphql/SchedulerGraphQLFactory.js","sources":["../../src/graphql/SchedulerGraphQLFactory.ts"],"sourcesContent":["import { GraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions\";\nimport { staticSchemaKey } from \"@webiny/api-graphql/graphql/staticSchemaKey.js\";\nimport { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.core.js\";\nimport { GetScheduledActionUseCase } from \"~/features/GetScheduledAction/index.js\";\nimport { ErrorResponse, ListResponse, Response } from \"@webiny/api-graphql/responses.js\";\nimport { ListScheduledActionsUseCase } from \"~/features/ListScheduledActions/index.js\";\nimport { ScheduleActionUseCase } from \"~/features/ScheduleAction/index.js\";\nimport { CancelScheduledActionUseCase } from \"~/features/CancelScheduledAction/index.js\";\nimport { ScheduledActionNotFoundError } from \"~/domain/errors.js\";\nimport type { Identity, ScheduledActionType } from \"~/shared/abstractions.js\";\nimport { ScheduledActionMapper } from \"~/domain/ScheduledActionMapper.js\";\nimport { GetTargetScheduledActionUseCase } from \"~/features/GetTargetScheduledAction/index.js\";\n\ninterface IListScheduledActionsArgs extends ListScheduledActionsUseCase.Params {\n namespace: string;\n}\n\ninterface IScheduleRecordOutput {\n id: string;\n targetId: string;\n namespace: string;\n scheduledBy: Identity;\n publishOn: Date | null;\n unpublishOn: Date | null;\n actionType: ScheduledActionType;\n title: string;\n}\n\nexport class SchedulerGraphQL implements CoreGraphQLSchemaFactory.Interface {\n public getSchemaKey = staticSchemaKey(\"api-scheduler/SchedulerGraphQL\");\n\n public async execute(\n builder: GraphQLSchemaBuilder.Interface\n ): Promise<GraphQLSchemaBuilder.Interface> {\n builder.addTypeDefs(`\n enum ScheduleRecordType {\n publish\n unpublish\n }\n \n type ScheduleError {\n message: String!\n code: String\n data: JSON\n stack: String\n }\n \n type ScheduleListMeta {\n hasMoreItems: Boolean!\n totalCount: Int!\n cursor: String\n }\n \n type ScheduleIdentity {\n id: String!\n displayName: String\n type: String\n }\n \n type ScheduleRecord {\n id: ID!\n targetId: String!\n namespace: String!\n scheduledBy: ScheduleIdentity!\n publishOn: DateTime\n unpublishOn: DateTime\n actionType: ScheduleRecordType!\n title: String!\n }\n\n type GetScheduledActionResponse {\n data: ScheduleRecord\n error: ScheduleError\n }\n\n type ListScheduledActionsResponse {\n data: [ScheduleRecord!]\n error: ScheduleError\n meta: ScheduleListMeta\n }\n\n type ScheduleActionResponse {\n data: ScheduleRecord\n error: ScheduleError\n }\n\n type CancelScheduledActionResponse {\n data: Boolean\n error: ScheduleError\n }\n\n input ListScheduledActionsWhereInput {\n targetId: String\n targetId_in: [String!]\n title: String\n title_contains: String\n title_not_contains: String\n actionType: ScheduleRecordType\n actionType_in: [ScheduleRecordType!]\n scheduledBy: String\n scheduledBy_in: [String!]\n scheduledFor: DateTime\n scheduledFor_gte: DateTime\n scheduledFor_lte: DateTime\n }\n\n enum ListScheduledActionsSorter {\n title_ASC\n title_DESC\n scheduledFor_ASC\n scheduledFor_DESC\n }\n \n type SchedulerQuery {\n _empty: String\n }\n \n type SchedulerMutation {\n _empty: String\n }\n\n extend type SchedulerQuery {\n # Fetch scheduled action by its own ID\n getScheduledAction(namespace: String!, id: ID!): GetScheduledActionResponse!\n \n # Fetch scheduled action by target ID\n getTargetScheduledAction(namespace: String!, id: ID!): GetScheduledActionResponse!\n \n listScheduledActions(\n namespace: String!\n where: ListScheduledActionsWhereInput\n sort: [ListScheduledActionsSorter!]\n limit: Int\n after: String\n ): ListScheduledActionsResponse!\n }\n\n extend type SchedulerMutation {\n scheduleAction(\n namespace: String!\n targetId: ID!\n immediately: Boolean\n scheduleFor: DateTime\n actionType: ScheduleRecordType!\n ): ScheduleActionResponse!\n \n cancelScheduledAction(namespace: String!, id: ID!): CancelScheduledActionResponse!\n }\n \n extend type Query {\n scheduler: SchedulerQuery\n }\n \n extend type Mutation {\n scheduler: SchedulerMutation\n }\n `);\n\n builder.addResolver({\n path: \"Query.scheduler\",\n resolver: () => {\n return async () => {\n return {};\n };\n }\n });\n builder.addResolver({\n path: \"Mutation.scheduler\",\n resolver: () => {\n return async () => {\n return {};\n };\n }\n });\n\n builder.addResolver<GetScheduledActionUseCase.Params>({\n path: \"SchedulerQuery.getScheduledAction\",\n dependencies: [GetScheduledActionUseCase],\n resolver: (useCase: GetScheduledActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n if (result.error instanceof ScheduledActionNotFoundError) {\n return new Response(null);\n }\n return new ErrorResponse(result.error);\n }\n\n return new Response<IScheduleRecordOutput>(\n ScheduledActionMapper.toGraphQL(result.value)\n );\n };\n }\n });\n\n builder.addResolver<GetTargetScheduledActionUseCase.Params>({\n path: \"SchedulerQuery.getTargetScheduledAction\",\n dependencies: [GetTargetScheduledActionUseCase],\n resolver: (useCase: GetTargetScheduledActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n if (result.error instanceof ScheduledActionNotFoundError) {\n return new Response(null);\n }\n return new ErrorResponse(result.error);\n }\n\n return new Response<IScheduleRecordOutput>(\n ScheduledActionMapper.toGraphQL(result.value)\n );\n };\n }\n });\n\n builder.addResolver<IListScheduledActionsArgs>({\n path: \"SchedulerQuery.listScheduledActions\",\n dependencies: [ListScheduledActionsUseCase],\n resolver: (useCase: ListScheduledActionsUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute({\n ...args,\n where: {\n ...args.where,\n namespace: args.namespace\n }\n });\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new ListResponse<IScheduleRecordOutput>(\n result.value.items.map(item => {\n return ScheduledActionMapper.toGraphQL(item);\n }),\n result.value.meta\n );\n };\n }\n });\n\n builder.addResolver<ScheduleActionUseCase.Params>({\n path: \"SchedulerMutation.scheduleAction\",\n dependencies: [ScheduleActionUseCase],\n resolver: (useCase: ScheduleActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response<IScheduleRecordOutput>(\n ScheduledActionMapper.toGraphQL(result.value)\n );\n };\n }\n });\n\n builder.addResolver<CancelScheduledActionUseCase.Params>({\n path: \"SchedulerMutation.cancelScheduledAction\",\n dependencies: [CancelScheduledActionUseCase],\n resolver: (useCase: CancelScheduledActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response<boolean>(result.value);\n };\n }\n });\n\n return builder;\n }\n}\n\nexport const SchedulerGraphQLFactory = CoreGraphQLSchemaFactory.createImplementation({\n dependencies: [],\n implementation: SchedulerGraphQL\n});\n"],"names":["SchedulerGraphQL","builder","GetScheduledActionUseCase","useCase","args","result","ScheduledActionNotFoundError","Response","ErrorResponse","ScheduledActionMapper","GetTargetScheduledActionUseCase","ListScheduledActionsUseCase","ListResponse","item","ScheduleActionUseCase","CancelScheduledActionUseCase","staticSchemaKey","SchedulerGraphQLFactory","CoreGraphQLSchemaFactory"],"mappings":";;;;;;;;;;AA4BO,MAAMA;IAGT,MAAa,QACTC,OAAuC,EACA;QACvCA,QAAQ,WAAW,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA0HrB,CAAC;QAEDA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,UAAU,IACC,UACI,EAAC;QAGpB;QACAA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,UAAU,IACC,UACI,EAAC;QAGpB;QAEAA,QAAQ,WAAW,CAAmC;YAClD,MAAM;YACN,cAAc;gBAACC;aAA0B;YACzC,UAAU,CAACC,UACA,OAAO,EAAEC,IAAI,EAAE;oBAClB,MAAMC,SAAS,MAAMF,QAAQ,OAAO,CAACC;oBAErC,IAAIC,OAAO,MAAM,IAAI;wBACjB,IAAIA,OAAO,KAAK,YAAYC,8BACxB,OAAO,IAAIC,SAAS;wBAExB,OAAO,IAAIC,cAAcH,OAAO,KAAK;oBACzC;oBAEA,OAAO,IAAIE,SACPE,sBAAsB,SAAS,CAACJ,OAAO,KAAK;gBAEpD;QAER;QAEAJ,QAAQ,WAAW,CAAyC;YACxD,MAAM;YACN,cAAc;gBAACS;aAAgC;YAC/C,UAAU,CAAC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C;oBAErC,IAAIC,OAAO,MAAM,IACb,OAAO,IAAIG,cAAcH,OAAO,KAAK;oBAGzC,OAAO,IAAIE,SAAkBF,OAAO,KAAK;gBAC7C;QAER;QAEA,OAAOJ;IACX;;aA1PO,YAAY,GAAGe,gBAAgB;;AA2P1C;AAEO,MAAMC,0BAA0BC,yBAAyB,oBAAoB,CAAC;IACjF,cAAc,EAAE;IAChB,gBAAgBlB;AACpB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { SchedulerGraphQLFactory } from "./SchedulerGraphQLFactory.js";
|
|
3
|
+
const SchedulerGraphQLFactoryFeature = createFeature({
|
|
4
|
+
name: "SchedulerGraphQLFactory",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(SchedulerGraphQLFactory);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export { SchedulerGraphQLFactoryFeature };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql/feature.js","sources":["../../src/graphql/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { SchedulerGraphQLFactory } from \"./SchedulerGraphQLFactory.js\";\n\nexport const SchedulerGraphQLFactoryFeature = createFeature({\n name: \"SchedulerGraphQLFactory\",\n register(container) {\n container.register(SchedulerGraphQLFactory);\n }\n});\n"],"names":["SchedulerGraphQLFactoryFeature","createFeature","container","SchedulerGraphQLFactory"],"mappings":";;AAGO,MAAMA,iCAAiCC,cAAc;IACxD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|
package/graphql/index.js
CHANGED
package/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { SchedulerService,
|
|
1
|
+
export { SchedulerService, ScheduledActionHandler } from "./shared/abstractions.js";
|
|
2
2
|
export type { IScheduledAction } from "./shared/abstractions.js";
|
|
3
3
|
export { ScheduledActionId } from "./domain/ScheduledActionId.js";
|
|
4
|
-
export {
|
|
4
|
+
export { SchedulerFeature } from "./SchedulerFeature.js";
|
|
5
|
+
export { ScheduledActionLambdaHandler } from "./ScheduledActionLambdaHandler.js";
|
package/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { ScheduledActionHandler, SchedulerService } from "./shared/abstractions.js";
|
|
2
2
|
export { ScheduledActionId } from "./domain/ScheduledActionId.js";
|
|
3
|
-
export {
|
|
4
|
-
|
|
5
|
-
//# sourceMappingURL=index.js.map
|
|
3
|
+
export { SchedulerFeature } from "./SchedulerFeature.js";
|
|
4
|
+
export { ScheduledActionLambdaHandler } from "./ScheduledActionLambdaHandler.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-scheduler",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.eb81deee7e",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -18,34 +18,27 @@
|
|
|
18
18
|
"description": "A generic action scheduler.",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@webiny/api": "0.0.0-unstable.
|
|
22
|
-
"@webiny/api-core": "0.0.0-unstable.
|
|
23
|
-
"@webiny/api-
|
|
24
|
-
"@webiny/
|
|
25
|
-
"@webiny/
|
|
26
|
-
"@webiny/
|
|
27
|
-
"@webiny/
|
|
28
|
-
"@webiny/
|
|
29
|
-
"
|
|
30
|
-
"zod": "4.4.3"
|
|
21
|
+
"@webiny/api": "0.0.0-unstable.eb81deee7e",
|
|
22
|
+
"@webiny/api-core": "0.0.0-unstable.eb81deee7e",
|
|
23
|
+
"@webiny/api-graphql": "0.0.0-unstable.eb81deee7e",
|
|
24
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.eb81deee7e",
|
|
25
|
+
"@webiny/event-handler-aws": "0.0.0-unstable.eb81deee7e",
|
|
26
|
+
"@webiny/event-handler-core": "0.0.0-unstable.eb81deee7e",
|
|
27
|
+
"@webiny/feature": "0.0.0-unstable.eb81deee7e",
|
|
28
|
+
"@webiny/utils": "0.0.0-unstable.eb81deee7e",
|
|
29
|
+
"graphql": "16.14.2"
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
|
33
|
-
"@webiny/build-tools": "0.0.0-unstable.
|
|
34
|
-
"@webiny/db-dynamodb": "0.0.0-unstable.e6f0dc8ca7",
|
|
35
|
-
"@webiny/handler": "0.0.0-unstable.e6f0dc8ca7",
|
|
36
|
-
"@webiny/handler-aws": "0.0.0-unstable.e6f0dc8ca7",
|
|
37
|
-
"@webiny/project-utils": "0.0.0-unstable.e6f0dc8ca7",
|
|
38
|
-
"@webiny/testing": "0.0.0-unstable.e6f0dc8ca7",
|
|
39
|
-
"@webiny/wcp": "0.0.0-unstable.e6f0dc8ca7",
|
|
40
|
-
"aws-sdk-client-mock": "4.1.0",
|
|
41
|
-
"jest-dynalite": "3.6.1",
|
|
32
|
+
"@webiny/build-tools": "0.0.0-unstable.eb81deee7e",
|
|
42
33
|
"rimraf": "6.1.3",
|
|
43
|
-
"typescript": "
|
|
44
|
-
"vitest": "4.1.
|
|
34
|
+
"typescript": "7.0.2",
|
|
35
|
+
"vitest": "4.1.11"
|
|
45
36
|
},
|
|
46
37
|
"publishConfig": {
|
|
47
|
-
"access": "public"
|
|
48
|
-
"directory": "dist"
|
|
38
|
+
"access": "public"
|
|
49
39
|
},
|
|
50
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "8476da73b653c89cc1474d968baf55c1b0ae0e5f",
|
|
41
|
+
"webiny": {
|
|
42
|
+
"publishFrom": "dist"
|
|
43
|
+
}
|
|
51
44
|
}
|
package/shared/abstractions.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export interface IScheduledActionEntry<T extends GenericRecord = GenericRecord>
|
|
|
28
28
|
}
|
|
29
29
|
export interface IScheduledAction<T extends GenericRecord = GenericRecord> extends Omit<IScheduledActionEntryValues<T>, "scheduledFor"> {
|
|
30
30
|
id: string;
|
|
31
|
+
tenant: string;
|
|
31
32
|
scheduledFor: Date;
|
|
32
33
|
}
|
|
33
34
|
/**
|
|
@@ -61,30 +62,52 @@ export declare namespace ScheduledActionHandler {
|
|
|
61
62
|
*/
|
|
62
63
|
export interface ISchedulerServiceCreateParams {
|
|
63
64
|
id: string;
|
|
65
|
+
tenant: string;
|
|
64
66
|
namespace: string;
|
|
65
67
|
scheduleFor: Date;
|
|
66
68
|
}
|
|
67
69
|
export interface ISchedulerServiceUpdateParams {
|
|
68
70
|
id: string;
|
|
71
|
+
tenant: string;
|
|
69
72
|
namespace: string;
|
|
70
73
|
scheduleFor: Date;
|
|
71
74
|
}
|
|
75
|
+
export interface ISchedulerServiceDeleteParams {
|
|
76
|
+
id: string;
|
|
77
|
+
namespace: string;
|
|
78
|
+
tenant: string;
|
|
79
|
+
}
|
|
80
|
+
export interface ISchedulerServiceExistsParams {
|
|
81
|
+
id: string;
|
|
82
|
+
namespace: string;
|
|
83
|
+
tenant: string;
|
|
84
|
+
}
|
|
72
85
|
export interface ISchedulerService {
|
|
73
86
|
create(params: ISchedulerServiceCreateParams): Promise<void>;
|
|
74
87
|
update(params: ISchedulerServiceUpdateParams): Promise<void>;
|
|
75
|
-
delete(
|
|
76
|
-
exists(
|
|
88
|
+
delete(params: ISchedulerServiceDeleteParams): Promise<void>;
|
|
89
|
+
exists(params: ISchedulerServiceExistsParams): Promise<boolean>;
|
|
77
90
|
}
|
|
78
91
|
/** Core service for managing scheduled actions. */
|
|
79
92
|
export declare const SchedulerService: import("@webiny/di").Abstraction<ISchedulerService>;
|
|
80
93
|
export declare namespace SchedulerService {
|
|
81
94
|
type Interface = ISchedulerService;
|
|
95
|
+
type CreateParams = ISchedulerServiceCreateParams;
|
|
96
|
+
type UpdateParams = ISchedulerServiceUpdateParams;
|
|
97
|
+
type DeleteParams = ISchedulerServiceDeleteParams;
|
|
98
|
+
type ExistsParams = ISchedulerServiceExistsParams;
|
|
82
99
|
}
|
|
83
100
|
/**
|
|
84
|
-
*
|
|
101
|
+
* Provides the scheduler's CMS model for the current request's tenant.
|
|
102
|
+
*
|
|
103
|
+
* A provider rather than the model itself: fetching a model is asynchronous and tenant-dependent,
|
|
104
|
+
* and DI resolution is synchronous — so an already-resolved `CmsModel` could only be supplied by a
|
|
105
|
+
* per-request hook running before every consumer. Consumers `await get()` at the point of use.
|
|
85
106
|
*/
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
107
|
+
export interface IScheduledActionModelProvider {
|
|
108
|
+
get(): Promise<CmsModel>;
|
|
109
|
+
}
|
|
110
|
+
export declare const ScheduledActionModelProvider: import("@webiny/di").Abstraction<IScheduledActionModelProvider>;
|
|
111
|
+
export declare namespace ScheduledActionModelProvider {
|
|
112
|
+
type Interface = IScheduledActionModelProvider;
|
|
90
113
|
}
|
package/shared/abstractions.js
CHANGED
|
@@ -1,35 +1,7 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Scheduled Action Record - The data stored for a scheduled action
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* ScheduledActionHandler - Similar to EventHandler pattern
|
|
13
|
-
*
|
|
14
|
-
* Each application (CMS, Mailer, etc.) implements handlers for their actions.
|
|
15
|
-
* This is the ONLY action abstraction needed.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/** Handle execution of a scheduled action. */
|
|
19
|
-
export const ScheduledActionHandler = createAbstraction("ScheduledActionHandler");
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* SchedulerService - Cloud-agnostic scheduler service
|
|
23
|
-
*
|
|
24
|
-
* Abstracts the underlying scheduling infrastructure (AWS EventBridge, Azure Logic Apps, etc.)
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/** Core service for managing scheduled actions. */
|
|
28
|
-
export const SchedulerService = createAbstraction("SchedulerService");
|
|
29
|
-
/**
|
|
30
|
-
* ScheduledActionModel - A CMS model used by the scheduler for persistence.
|
|
31
|
-
*/
|
|
32
|
-
/** Content model definition for scheduled actions. */
|
|
33
|
-
export const ScheduledActionModel = createAbstraction("ScheduledActionModel");
|
|
2
|
+
const ScheduledActionHandler = createAbstraction("ScheduledActionHandler");
|
|
3
|
+
const SchedulerService = createAbstraction("SchedulerService");
|
|
4
|
+
const ScheduledActionModelProvider = createAbstraction("ScheduledActionModelProvider");
|
|
5
|
+
export { ScheduledActionHandler, ScheduledActionModelProvider, SchedulerService };
|
|
34
6
|
|
|
35
7
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"shared/abstractions.js","sources":["../../src/shared/abstractions.ts"],"sourcesContent":["import type { CmsModel } from \"@webiny/api-headless-cms/types/model.js\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { CmsEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { SCHEDULED_ACTION_PUBLISH, SCHEDULED_ACTION_UNPUBLISH } from \"~/constants.js\";\n\n/**\n * Identity type - represents who scheduled an action\n */\nexport interface Identity {\n id: string;\n type: string;\n displayName: string;\n}\n\nexport type ScheduledActionType =\n | typeof SCHEDULED_ACTION_PUBLISH\n | typeof SCHEDULED_ACTION_UNPUBLISH;\n/**\n * Scheduled Action Record - The data stored for a scheduled action\n */\n\nexport interface IScheduledActionEntryValues<T> {\n namespace: string; // Resource scope: \"Cms/Entry/Article\", \"Mailer/Email\"\n actionType: ScheduledActionType;\n targetId: string; // Resource identifier (entry ID, email ID, etc.)\n scheduledBy: Identity;\n scheduledFor: string;\n title: string;\n payload: T; // Action-specific data\n error: string | undefined; // Error if execution failed\n}\n\nexport interface IScheduledActionEntry<T extends GenericRecord = GenericRecord> extends CmsEntry<\n IScheduledActionEntryValues<T>\n> {}\n\nexport interface IScheduledAction<T extends GenericRecord = GenericRecord> extends Omit<\n IScheduledActionEntryValues<T>,\n \"scheduledFor\"\n> {\n id: string;\n tenant: string;\n scheduledFor: Date;\n}\n\n/**\n * ScheduledActionHandler - Similar to EventHandler pattern\n *\n * Each application (CMS, Mailer, etc.) implements handlers for their actions.\n * This is the ONLY action abstraction needed.\n */\nexport interface IScheduledActionHandler {\n /**\n * Determines if this handler can handle the given action\n *\n * @param namespace - Resource scope (e.g., \"Cms/Entry/Article\")\n * @param actionType - Operation type (e.g., \"Publish\")\n */\n canHandle(namespace: string, actionType: ScheduledActionType): boolean;\n\n /**\n * Executes the scheduled action\n */\n handle(action: IScheduledAction<any>): Promise<void>;\n}\n\n/** Handle execution of a scheduled action. */\nexport const ScheduledActionHandler =\n createAbstraction<IScheduledActionHandler>(\"ScheduledActionHandler\");\n\nexport namespace ScheduledActionHandler {\n export type Interface = IScheduledActionHandler;\n}\n\n/**\n * SchedulerService - Cloud-agnostic scheduler service\n *\n * Abstracts the underlying scheduling infrastructure (AWS EventBridge, Azure Logic Apps, etc.)\n */\n\nexport interface ISchedulerServiceCreateParams {\n id: string;\n tenant: string;\n namespace: string;\n scheduleFor: Date;\n}\nexport interface ISchedulerServiceUpdateParams {\n id: string;\n tenant: string;\n namespace: string;\n scheduleFor: Date;\n}\n\nexport interface ISchedulerServiceDeleteParams {\n id: string;\n namespace: string;\n tenant: string;\n}\n\nexport interface ISchedulerServiceExistsParams {\n id: string;\n namespace: string;\n tenant: string;\n}\n\nexport interface ISchedulerService {\n create(params: ISchedulerServiceCreateParams): Promise<void>;\n update(params: ISchedulerServiceUpdateParams): Promise<void>;\n delete(params: ISchedulerServiceDeleteParams): Promise<void>;\n exists(params: ISchedulerServiceExistsParams): Promise<boolean>;\n}\n\n/** Core service for managing scheduled actions. */\nexport const SchedulerService = createAbstraction<ISchedulerService>(\"SchedulerService\");\n\nexport namespace SchedulerService {\n export type Interface = ISchedulerService;\n export type CreateParams = ISchedulerServiceCreateParams;\n export type UpdateParams = ISchedulerServiceUpdateParams;\n export type DeleteParams = ISchedulerServiceDeleteParams;\n export type ExistsParams = ISchedulerServiceExistsParams;\n}\n\n/**\n * Provides the scheduler's CMS model for the current request's tenant.\n *\n * A provider rather than the model itself: fetching a model is asynchronous and tenant-dependent,\n * and DI resolution is synchronous — so an already-resolved `CmsModel` could only be supplied by a\n * per-request hook running before every consumer. Consumers `await get()` at the point of use.\n */\nexport interface IScheduledActionModelProvider {\n get(): Promise<CmsModel>;\n}\n\nexport const ScheduledActionModelProvider = createAbstraction<IScheduledActionModelProvider>(\n \"ScheduledActionModelProvider\"\n);\n\nexport namespace ScheduledActionModelProvider {\n export type Interface = IScheduledActionModelProvider;\n}\n"],"names":["ScheduledActionHandler","createAbstraction","SchedulerService","ScheduledActionModelProvider"],"mappings":";AAoEO,MAAMA,yBACTC,kBAA2C;AA6CxC,MAAMC,mBAAmBD,kBAAqC;AAqB9D,MAAME,+BAA+BF,kBACxC"}
|
package/context.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ContextPlugin } from "@webiny/api";
|
|
2
|
-
import type { SchedulerClient, SchedulerClientConfig } from "@webiny/aws-sdk/client-scheduler/index.js";
|
|
3
|
-
import type { CmsContext } from "@webiny/api-headless-cms/types/index.js";
|
|
4
|
-
export interface ICreateHeadlessCmsSchedulerContextParams {
|
|
5
|
-
getClient(config?: SchedulerClientConfig): Pick<SchedulerClient, "send">;
|
|
6
|
-
}
|
|
7
|
-
export declare const createSchedulerContext: (params: ICreateHeadlessCmsSchedulerContextParams) => ContextPlugin<CmsContext>;
|
package/context.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { ContextPlugin } from "@webiny/api";
|
|
2
|
-
import { getManifest } from "./manifest.js";
|
|
3
|
-
import { SCHEDULE_MODEL_ID } from "./constants.js";
|
|
4
|
-
import { ScheduledActionModel, SchedulerService } from "./shared/abstractions.js";
|
|
5
|
-
import { EventBridgeSchedulerService } from "./features/SchedulerService/EventBridgeSchedulerService.js";
|
|
6
|
-
import { VoidSchedulerService } from "./features/SchedulerService/VoidSchedulerService.js";
|
|
7
|
-
import { SchedulePrivateModel } from "./domain/SchedulePrivateModel.js";
|
|
8
|
-
import { SchedulerFeature } from "./features/SchedulerFeature.js";
|
|
9
|
-
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
10
|
-
import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
|
|
11
|
-
import { SchedulerGraphQLFactory } from "./graphql/index.js";
|
|
12
|
-
import { SchedulerPermissionsFeature } from "./features/permissions/feature.js";
|
|
13
|
-
import { NamespaceHandlerExecutioner } from "./features/NamespaceHandler/NamespaceHandlerExecutioner.js";
|
|
14
|
-
export const createSchedulerContext = params => {
|
|
15
|
-
return new ContextPlugin(async context => {
|
|
16
|
-
const tenantContext = context.container.resolve(TenantContext);
|
|
17
|
-
const getModel = context.container.resolve(GetModelUseCase);
|
|
18
|
-
if (!tenantContext.getTenant()) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const manifest = await getManifest({
|
|
22
|
-
client: context.db.driver.getClient()
|
|
23
|
-
});
|
|
24
|
-
if (manifest.error) {
|
|
25
|
-
context.container.registerInstance(SchedulerService, new VoidSchedulerService());
|
|
26
|
-
} else {
|
|
27
|
-
// TODO: in the future, extract AWS specific implementation into a separate package
|
|
28
|
-
context.container.registerInstance(SchedulerService, new EventBridgeSchedulerService(params.getClient, {
|
|
29
|
-
lambdaArn: manifest.data.lambdaArn,
|
|
30
|
-
roleArn: manifest.data.roleArn
|
|
31
|
-
}));
|
|
32
|
-
}
|
|
33
|
-
SchedulerPermissionsFeature.register(context.container);
|
|
34
|
-
context.container.register(SchedulePrivateModel);
|
|
35
|
-
context.container.register(SchedulerGraphQLFactory);
|
|
36
|
-
context.container.register(NamespaceHandlerExecutioner);
|
|
37
|
-
await context.security.withoutAuthorization(async () => {
|
|
38
|
-
const schedulerModel = await getModel.execute(SCHEDULE_MODEL_ID);
|
|
39
|
-
context.container.registerInstance(ScheduledActionModel, schedulerModel.value);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// Register all features
|
|
43
|
-
SchedulerFeature.register(context.container);
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
//# sourceMappingURL=context.js.map
|
package/context.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["ContextPlugin","getManifest","SCHEDULE_MODEL_ID","ScheduledActionModel","SchedulerService","EventBridgeSchedulerService","VoidSchedulerService","SchedulePrivateModel","SchedulerFeature","TenantContext","GetModelUseCase","SchedulerGraphQLFactory","SchedulerPermissionsFeature","NamespaceHandlerExecutioner","createSchedulerContext","params","context","tenantContext","container","resolve","getModel","getTenant","manifest","client","db","driver","getClient","error","registerInstance","lambdaArn","data","roleArn","register","security","withoutAuthorization","schedulerModel","execute","value"],"sources":["context.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport type {\n SchedulerClient,\n SchedulerClientConfig\n} from \"@webiny/aws-sdk/client-scheduler/index.js\";\nimport { getManifest } from \"~/manifest.js\";\nimport type { CmsContext } from \"@webiny/api-headless-cms/types/index.js\";\nimport { SCHEDULE_MODEL_ID } from \"./constants.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { ScheduledActionModel, SchedulerService } from \"~/shared/abstractions.js\";\nimport { EventBridgeSchedulerService } from \"~/features/SchedulerService/EventBridgeSchedulerService.js\";\nimport { VoidSchedulerService } from \"~/features/SchedulerService/VoidSchedulerService.js\";\nimport { SchedulePrivateModel } from \"~/domain/SchedulePrivateModel.js\";\nimport { SchedulerFeature } from \"./features/SchedulerFeature.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel/index.js\";\nimport { SchedulerGraphQLFactory } from \"~/graphql/index.js\";\nimport { SchedulerPermissionsFeature } from \"~/features/permissions/feature.js\";\nimport { NamespaceHandlerExecutioner } from \"~/features/NamespaceHandler/NamespaceHandlerExecutioner.js\";\n\nexport interface ICreateHeadlessCmsSchedulerContextParams {\n getClient(config?: SchedulerClientConfig): Pick<SchedulerClient, \"send\">;\n}\n\nexport const createSchedulerContext = (params: ICreateHeadlessCmsSchedulerContextParams) => {\n return new ContextPlugin<CmsContext>(async context => {\n const tenantContext = context.container.resolve(TenantContext);\n const getModel = context.container.resolve(GetModelUseCase);\n\n if (!tenantContext.getTenant()) {\n return;\n }\n\n const manifest = await getManifest({\n client: context.db.driver.getClient() as DynamoDBDocument\n });\n\n if (manifest.error) {\n context.container.registerInstance(SchedulerService, new VoidSchedulerService());\n } else {\n // TODO: in the future, extract AWS specific implementation into a separate package\n context.container.registerInstance(\n SchedulerService,\n new EventBridgeSchedulerService(params.getClient, {\n lambdaArn: manifest.data.lambdaArn,\n roleArn: manifest.data.roleArn\n })\n );\n }\n\n SchedulerPermissionsFeature.register(context.container);\n context.container.register(SchedulePrivateModel);\n context.container.register(SchedulerGraphQLFactory);\n context.container.register(NamespaceHandlerExecutioner);\n\n await context.security.withoutAuthorization(async () => {\n const schedulerModel = await getModel.execute(SCHEDULE_MODEL_ID);\n context.container.registerInstance(ScheduledActionModel, schedulerModel.value);\n });\n\n // Register all features\n SchedulerFeature.register(context.container);\n });\n};\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,aAAa;AAK3C,SAASC,WAAW;AAEpB,SAASC,iBAAiB;AAE1B,SAASC,oBAAoB,EAAEC,gBAAgB;AAC/C,SAASC,2BAA2B;AACpC,SAASC,oBAAoB;AAC7B,SAASC,oBAAoB;AAC7B,SAASC,gBAAgB;AAC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AAMG,OAAO,CAACiB,QAAQ,CAACC,oBAAoB,CAAC,YAAY;MACpD,MAAMC,cAAc,GAAG,MAAMf,QAAQ,CAACgB,OAAO,CAAClC,iBAAiB,CAAC;MAChEc,OAAO,CAACE,SAAS,CAACU,gBAAgB,CAACzB,oBAAoB,EAAEgC,cAAc,CAACE,KAAK,CAAC;IAClF,CAAC,CAAC;;IAEF;IACA7B,gBAAgB,CAACwB,QAAQ,CAAChB,OAAO,CAACE,SAAS,CAAC;EAChD,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
package/createEventHandler.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { HandlerFactoryParams } from "@webiny/handler-aws/types.js";
|
|
2
|
-
import { SCHEDULED_ACTION_EVENT_IDENTIFIER } from "./constants.js";
|
|
3
|
-
export interface IScheduledActionEventPayload {
|
|
4
|
-
namespace: string;
|
|
5
|
-
id: string;
|
|
6
|
-
scheduleFor: string;
|
|
7
|
-
}
|
|
8
|
-
export interface IScheduledActionEvent {
|
|
9
|
-
[SCHEDULED_ACTION_EVENT_IDENTIFIER]: IScheduledActionEventPayload;
|
|
10
|
-
}
|
|
11
|
-
export interface HandlerParams extends HandlerFactoryParams {
|
|
12
|
-
debug?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export declare const createScheduledActionEventHandler: () => import("@webiny/handler-aws/raw/index.js").RawEventHandler<IScheduledActionEvent, import("@webiny/handler/types").Context, any>;
|
package/createEventHandler.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { registry } from "@webiny/handler-aws/registry.js";
|
|
2
|
-
import { createSourceHandler } from "@webiny/handler-aws/sourceHandler.js";
|
|
3
|
-
import { createEventHandler, createHandler } from "@webiny/handler-aws/raw/index.js";
|
|
4
|
-
import { SCHEDULED_ACTION_EVENT_IDENTIFIER } from "./constants.js";
|
|
5
|
-
import { ExecuteScheduledActionUseCase } from "./features/ExecuteScheduledAction/index.js";
|
|
6
|
-
const canHandle = event => {
|
|
7
|
-
if (typeof event?.hasOwnProperty !== "function") {
|
|
8
|
-
return false;
|
|
9
|
-
} else if (!event.hasOwnProperty(SCHEDULED_ACTION_EVENT_IDENTIFIER)) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
const value = event[SCHEDULED_ACTION_EVENT_IDENTIFIER];
|
|
13
|
-
return !!(value?.id && value?.scheduleFor);
|
|
14
|
-
};
|
|
15
|
-
const handler = createSourceHandler({
|
|
16
|
-
name: "handler-aws-event-bridge-scheduled-cms-action-event",
|
|
17
|
-
canUse: canHandle,
|
|
18
|
-
handle: async ({
|
|
19
|
-
params,
|
|
20
|
-
event,
|
|
21
|
-
context
|
|
22
|
-
}) => {
|
|
23
|
-
return createHandler(params)(event, context);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
registry.register(handler);
|
|
27
|
-
export const createScheduledActionEventHandler = () => {
|
|
28
|
-
return createEventHandler({
|
|
29
|
-
canHandle,
|
|
30
|
-
handle: async params => {
|
|
31
|
-
const {
|
|
32
|
-
payload,
|
|
33
|
-
context
|
|
34
|
-
} = params;
|
|
35
|
-
const input = payload[SCHEDULED_ACTION_EVENT_IDENTIFIER];
|
|
36
|
-
const executeScheduledAction = context.container.resolve(ExecuteScheduledActionUseCase);
|
|
37
|
-
const result = await executeScheduledAction.execute(input);
|
|
38
|
-
if (result.isFail()) {
|
|
39
|
-
const error = result.error;
|
|
40
|
-
console.error(error.code, error.message);
|
|
41
|
-
throw error;
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
success: true
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
//# sourceMappingURL=createEventHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["registry","createSourceHandler","createEventHandler","createHandler","SCHEDULED_ACTION_EVENT_IDENTIFIER","ExecuteScheduledActionUseCase","canHandle","event","hasOwnProperty","value","id","scheduleFor","handler","name","canUse","handle","params","context","register","createScheduledActionEventHandler","payload","input","executeScheduledAction","container","resolve","result","execute","isFail","error","console","code","message","success"],"sources":["createEventHandler.ts"],"sourcesContent":["import { registry } from \"@webiny/handler-aws/registry.js\";\nimport type { HandlerFactoryParams } from \"@webiny/handler-aws/types.js\";\nimport { createSourceHandler } from \"@webiny/handler-aws/sourceHandler.js\";\nimport { createEventHandler, createHandler } from \"@webiny/handler-aws/raw/index.js\";\nimport { SCHEDULED_ACTION_EVENT_IDENTIFIER } from \"~/constants.js\";\nimport { ExecuteScheduledActionUseCase } from \"~/features/ExecuteScheduledAction/index.js\";\n\nexport interface IScheduledActionEventPayload {\n namespace: string;\n id: string;\n scheduleFor: string;\n}\n\nexport interface IScheduledActionEvent {\n [SCHEDULED_ACTION_EVENT_IDENTIFIER]: IScheduledActionEventPayload;\n}\n\nexport interface HandlerParams extends HandlerFactoryParams {\n debug?: boolean;\n}\n\nconst canHandle = (event: Partial<IScheduledActionEvent>): boolean => {\n if (typeof event?.hasOwnProperty !== \"function\") {\n return false;\n } else if (!event.hasOwnProperty(SCHEDULED_ACTION_EVENT_IDENTIFIER)) {\n return false;\n }\n\n const value = event[SCHEDULED_ACTION_EVENT_IDENTIFIER];\n return !!(value?.id && value?.scheduleFor);\n};\n\nconst handler = createSourceHandler<IScheduledActionEvent, HandlerParams>({\n name: \"handler-aws-event-bridge-scheduled-cms-action-event\",\n canUse: canHandle,\n handle: async ({ params, event, context }) => {\n return createHandler(params)(event, context);\n }\n});\n\nregistry.register(handler);\n\nexport const createScheduledActionEventHandler = () => {\n return createEventHandler<IScheduledActionEvent>({\n canHandle,\n handle: async params => {\n const { payload, context } = params;\n const input = payload[SCHEDULED_ACTION_EVENT_IDENTIFIER];\n\n const executeScheduledAction = context.container.resolve(ExecuteScheduledActionUseCase);\n const result = await executeScheduledAction.execute(input);\n\n if (result.isFail()) {\n const error = result.error;\n console.error(error.code, error.message);\n throw error;\n }\n return {\n success: true\n };\n }\n });\n};\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AO,CAACL,KAAK,CAAC;MAE1D,IAAII,MAAM,CAACE,MAAM,CAAC,CAAC,EAAE;QACjB,MAAMC,KAAK,GAAGH,MAAM,CAACG,KAAK;QAC1BC,OAAO,CAACD,KAAK,CAACA,KAAK,CAACE,IAAI,EAAEF,KAAK,CAACG,OAAO,CAAC;QACxC,MAAMH,KAAK;MACf;MACA,OAAO;QACHI,OAAO,EAAE;MACb,CAAC;IACL;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
package/createScheduler.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from "@webiny/plugins/types.js";
|
|
2
|
-
import { SchedulerClient, SchedulerClientConfig } from "@webiny/aws-sdk/client-scheduler/index.js";
|
|
3
|
-
export interface ICreateSchedulerParams {
|
|
4
|
-
getClient(config?: SchedulerClientConfig): Pick<SchedulerClient, "send">;
|
|
5
|
-
}
|
|
6
|
-
export declare const createScheduler: (params: ICreateSchedulerParams) => Plugin[];
|
package/createScheduler.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createSchedulerContext } from "./context.js";
|
|
2
|
-
import { createScheduledActionEventHandler } from "./createEventHandler.js";
|
|
3
|
-
export const createScheduler = params => {
|
|
4
|
-
return [
|
|
5
|
-
/**
|
|
6
|
-
* Handler for the Scheduled Action Event.
|
|
7
|
-
*/
|
|
8
|
-
createScheduledActionEventHandler(), createSchedulerContext(params)];
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=createScheduler.js.map
|
package/createScheduler.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createSchedulerContext","createScheduledActionEventHandler","createScheduler","params"],"sources":["createScheduler.ts"],"sourcesContent":["import type { Plugin } from \"@webiny/plugins/types.js\";\nimport { SchedulerClient, SchedulerClientConfig } from \"@webiny/aws-sdk/client-scheduler/index.js\";\nimport { createSchedulerContext } from \"~/context.js\";\nimport { createScheduledActionEventHandler } from \"~/createEventHandler.js\";\n\nexport interface ICreateSchedulerParams {\n getClient(config?: SchedulerClientConfig): Pick<SchedulerClient, \"send\">;\n}\nexport const createScheduler = (params: ICreateSchedulerParams): Plugin[] => {\n return [\n /**\n * Handler for the Scheduled Action Event.\n */\n createScheduledActionEventHandler(),\n createSchedulerContext(params)\n ];\n};\n"],"mappings":"AAEA,SAASA,sBAAsB;AAC/B,SAASC,iCAAiC;AAK1C,OAAO,MAAMC,eAAe,GAAIC,MAA8B,IAAe;EACzE,OAAO;EACH;AACR;AACA;EACQF,iCAAiC,CAAC,CAAC,EACnCD,sBAAsB,CAACG,MAAM,CAAC,CACjC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare const SCHEDULER_PERMISSIONS_SCHEMA: {
|
|
2
|
-
readonly prefix: "scheduler";
|
|
3
|
-
readonly fullAccess: true;
|
|
4
|
-
readonly entities: readonly [{
|
|
5
|
-
readonly id: "action";
|
|
6
|
-
readonly permission: "scheduler.action";
|
|
7
|
-
readonly scopes: readonly ["full", "own"];
|
|
8
|
-
}];
|
|
9
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { createPermissionSchema } from "@webiny/api-core/exports/api/security.js";
|
|
2
|
-
export const SCHEDULER_PERMISSIONS_SCHEMA = createPermissionSchema({
|
|
3
|
-
prefix: "scheduler",
|
|
4
|
-
fullAccess: true,
|
|
5
|
-
entities: [{
|
|
6
|
-
id: "action",
|
|
7
|
-
permission: "scheduler.action",
|
|
8
|
-
scopes: ["full", "own"]
|
|
9
|
-
}]
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=permissionsSchema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createPermissionSchema","SCHEDULER_PERMISSIONS_SCHEMA","prefix","fullAccess","entities","id","permission","scopes"],"sources":["permissionsSchema.ts"],"sourcesContent":["import { createPermissionSchema } from \"@webiny/api-core/exports/api/security.js\";\n\nexport const SCHEDULER_PERMISSIONS_SCHEMA = createPermissionSchema({\n prefix: \"scheduler\",\n fullAccess: true,\n entities: [\n {\n id: \"action\",\n permission: \"scheduler.action\",\n scopes: [\"full\", \"own\"]\n }\n ]\n});\n"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,0CAA0C;AAEjF,OAAO,MAAMC,4BAA4B,GAAGD,sBAAsB,CAAC;EAC/DE,MAAM,EAAE,WAAW;EACnBC,UAAU,EAAE,IAAI;EAChBC,QAAQ,EAAE,CACN;IACIC,EAAE,EAAE,QAAQ;IACZC,UAAU,EAAE,kBAAkB;IAC9BC,MAAM,EAAE,CAAC,MAAM,EAAE,KAAK;EAC1B,CAAC;AAET,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["ScheduleActionUseCase","GetScheduledActionUseCase","ListScheduledActionsUseCase","CancelScheduledActionUseCase","ExecuteScheduledActionUseCase","NamespaceHandler","SchedulerService","ScheduledActionModel","ScheduledActionHandler","SCHEDULED_ACTION_PUBLISH","ScheduledActionTypePublish","SCHEDULED_ACTION_UNPUBLISH","ScheduledActionTypeUnpublish"],"sources":["scheduler.ts"],"sourcesContent":["export { ScheduleActionUseCase } from \"~/features/ScheduleAction/index.js\";\nexport type { ScheduleActionError } from \"~/features/ScheduleAction/index.js\";\nexport { GetScheduledActionUseCase } from \"~/features/GetScheduledAction/index.js\";\nexport { ListScheduledActionsUseCase } from \"~/features/ListScheduledActions/index.js\";\nexport { CancelScheduledActionUseCase } from \"~/features/CancelScheduledAction/index.js\";\nexport { ExecuteScheduledActionUseCase } from \"~/features/ExecuteScheduledAction/index.js\";\nexport { NamespaceHandler } from \"~/features/NamespaceHandler/index.js\";\nexport type {\n IScheduledAction,\n IScheduledActionEntry,\n ScheduledActionType\n} from \"~/shared/abstractions.js\";\nexport {\n SchedulerService,\n ScheduledActionModel,\n ScheduledActionHandler\n} from \"~/shared/abstractions.js\";\n\nexport {\n SCHEDULED_ACTION_PUBLISH as ScheduledActionTypePublish,\n SCHEDULED_ACTION_UNPUBLISH as ScheduledActionTypeUnpublish\n} from \"~/constants.js\";\n"],"mappings":"AAAA,SAASA,qBAAqB;AAE9B,SAASC,yBAAyB;AAClC,SAASC,2BAA2B;AACpC,SAASC,4BAA4B;AACrC,SAASC,6BAA6B;AACtC,SAASC,gBAAgB;AAMzB,SACIC,gBAAgB,EAChBC,oBAAoB,EACpBC,sBAAsB;AAG1B,SACIC,wBAAwB,IAAIC,0BAA0B,EACtDC,0BAA0B,IAAIC,4BAA4B","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["NamespaceHandler"],"sources":["index.ts"],"sourcesContent":["export { NamespaceHandler } from \"./abstractions.js\";\n"],"mappings":"AAAA,SAASA,gBAAgB","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { type ISchedulerServiceCreateParams, type ISchedulerServiceUpdateParams, SchedulerService } from "../../shared/abstractions.js";
|
|
2
|
-
import { type SchedulerClient } from "@webiny/aws-sdk/client-scheduler/index.js";
|
|
3
|
-
export interface ISchedulerConfig {
|
|
4
|
-
lambdaArn: string;
|
|
5
|
-
roleArn: string;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* AWS EventBridge Scheduler implementation
|
|
9
|
-
*
|
|
10
|
-
* This is the AWS-specific implementation of the cloud-agnostic SchedulerService abstraction.
|
|
11
|
-
*
|
|
12
|
-
* Manages schedules in AWS EventBridge Scheduler for triggering Lambda functions
|
|
13
|
-
* at specified future times.
|
|
14
|
-
*/
|
|
15
|
-
export declare class EventBridgeSchedulerService implements SchedulerService.Interface {
|
|
16
|
-
private getClient;
|
|
17
|
-
private config;
|
|
18
|
-
constructor(getClient: (config?: any) => Pick<SchedulerClient, "send">, config: ISchedulerConfig);
|
|
19
|
-
create(params: ISchedulerServiceCreateParams): Promise<void>;
|
|
20
|
-
update(params: ISchedulerServiceUpdateParams): Promise<void>;
|
|
21
|
-
delete(id: string): Promise<void>;
|
|
22
|
-
exists(id: string): Promise<boolean>;
|
|
23
|
-
private createScheduleExpression;
|
|
24
|
-
private createScheduledActionEventInput;
|
|
25
|
-
private createScheduledActionEventPayload;
|
|
26
|
-
}
|