@webiny/api-scheduler 6.0.0 → 6.1.0-beta.0

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.
Files changed (102) hide show
  1. package/constants.d.ts +5 -0
  2. package/constants.js +6 -0
  3. package/constants.js.map +1 -1
  4. package/context.js +6 -0
  5. package/context.js.map +1 -1
  6. package/createEventHandler.d.ts +1 -0
  7. package/createEventHandler.js +1 -1
  8. package/createEventHandler.js.map +1 -1
  9. package/domain/ScheduledActionMapper.d.ts +16 -0
  10. package/domain/ScheduledActionMapper.js +37 -0
  11. package/domain/ScheduledActionMapper.js.map +1 -0
  12. package/domain/errors.d.ts +19 -1
  13. package/domain/errors.js +27 -1
  14. package/domain/errors.js.map +1 -1
  15. package/domain/isValidDate.d.ts +1 -1
  16. package/domain/isValidDate.js +2 -2
  17. package/domain/isValidDate.js.map +1 -1
  18. package/domain/permissions.d.ts +45 -0
  19. package/domain/permissions.js +13 -0
  20. package/domain/permissions.js.map +1 -0
  21. package/exports/api/scheduler.d.ts +10 -0
  22. package/exports/api/scheduler.js +10 -0
  23. package/exports/api/scheduler.js.map +1 -0
  24. package/features/CancelScheduledAction/CancelScheduledActionUseCase.d.ts +4 -2
  25. package/features/CancelScheduledAction/CancelScheduledActionUseCase.js +17 -8
  26. package/features/CancelScheduledAction/CancelScheduledActionUseCase.js.map +1 -1
  27. package/features/CancelScheduledAction/abstractions.d.ts +9 -2
  28. package/features/CancelScheduledAction/abstractions.js +2 -1
  29. package/features/CancelScheduledAction/abstractions.js.map +1 -1
  30. package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.d.ts +1 -1
  31. package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.js +9 -6
  32. package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.js.map +1 -1
  33. package/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.d.ts +2 -2
  34. package/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.js.map +1 -1
  35. package/features/ExecuteScheduledAction/abstractions.d.ts +9 -2
  36. package/features/ExecuteScheduledAction/abstractions.js +2 -1
  37. package/features/ExecuteScheduledAction/abstractions.js.map +1 -1
  38. package/features/GetScheduledAction/GetScheduledActionUseCase.d.ts +6 -2
  39. package/features/GetScheduledAction/GetScheduledActionUseCase.js +32 -15
  40. package/features/GetScheduledAction/GetScheduledActionUseCase.js.map +1 -1
  41. package/features/GetScheduledAction/abstractions.d.ts +9 -2
  42. package/features/GetScheduledAction/abstractions.js +2 -1
  43. package/features/GetScheduledAction/abstractions.js.map +1 -1
  44. package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.d.ts +32 -0
  45. package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js +86 -0
  46. package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js.map +1 -0
  47. package/features/GetTargetScheduledAction/abstractions.d.ts +24 -0
  48. package/features/GetTargetScheduledAction/abstractions.js +4 -0
  49. package/features/GetTargetScheduledAction/abstractions.js.map +1 -0
  50. package/features/GetTargetScheduledAction/feature.d.ts +7 -0
  51. package/features/GetTargetScheduledAction/feature.js +17 -0
  52. package/features/GetTargetScheduledAction/feature.js.map +1 -0
  53. package/features/ListScheduledActions/ListScheduledActionsUseCase.d.ts +5 -1
  54. package/features/ListScheduledActions/ListScheduledActionsUseCase.js +25 -24
  55. package/features/ListScheduledActions/ListScheduledActionsUseCase.js.map +1 -1
  56. package/features/ListScheduledActions/abstractions.d.ts +11 -3
  57. package/features/ListScheduledActions/abstractions.js +2 -1
  58. package/features/ListScheduledActions/abstractions.js.map +1 -1
  59. package/features/NamespaceHandler/NamespaceHandlerExecutioner.d.ts +11 -0
  60. package/features/NamespaceHandler/NamespaceHandlerExecutioner.js +25 -0
  61. package/features/NamespaceHandler/NamespaceHandlerExecutioner.js.map +1 -0
  62. package/features/NamespaceHandler/abstractions.d.ts +50 -0
  63. package/features/NamespaceHandler/abstractions.js +16 -0
  64. package/features/NamespaceHandler/abstractions.js.map +1 -0
  65. package/features/NamespaceHandler/index.d.ts +1 -0
  66. package/features/NamespaceHandler/index.js +3 -0
  67. package/features/NamespaceHandler/index.js.map +1 -0
  68. package/features/ScheduleAction/ScheduleActionUseCase.d.ts +4 -4
  69. package/features/ScheduleAction/ScheduleActionUseCase.js +75 -16
  70. package/features/ScheduleAction/ScheduleActionUseCase.js.map +1 -1
  71. package/features/ScheduleAction/abstractions.d.ts +10 -10
  72. package/features/ScheduleAction/abstractions.js +2 -1
  73. package/features/ScheduleAction/abstractions.js.map +1 -1
  74. package/features/SchedulerFeature.js +2 -2
  75. package/features/SchedulerFeature.js.map +1 -1
  76. package/features/SchedulerService/EventBridgeSchedulerService.js +3 -1
  77. package/features/SchedulerService/EventBridgeSchedulerService.js.map +1 -1
  78. package/graphql/SchedulerGraphQLFactory.d.ts +8 -0
  79. package/graphql/SchedulerGraphQLFactory.js +248 -0
  80. package/graphql/SchedulerGraphQLFactory.js.map +1 -0
  81. package/graphql/index.d.ts +1 -0
  82. package/graphql/index.js +3 -0
  83. package/graphql/index.js.map +1 -0
  84. package/index.d.ts +0 -6
  85. package/index.js +0 -8
  86. package/index.js.map +1 -1
  87. package/package.json +20 -27
  88. package/shared/abstractions.d.ts +18 -6
  89. package/shared/abstractions.js +3 -0
  90. package/shared/abstractions.js.map +1 -1
  91. package/features/RunAction/RunActionUseCase.d.ts +0 -23
  92. package/features/RunAction/RunActionUseCase.js +0 -37
  93. package/features/RunAction/RunActionUseCase.js.map +0 -1
  94. package/features/RunAction/abstractions.d.ts +0 -35
  95. package/features/RunAction/abstractions.js +0 -15
  96. package/features/RunAction/abstractions.js.map +0 -1
  97. package/features/RunAction/feature.d.ts +0 -7
  98. package/features/RunAction/feature.js +0 -17
  99. package/features/RunAction/feature.js.map +0 -1
  100. /package/features/{RunAction → GetTargetScheduledAction}/index.d.ts +0 -0
  101. /package/features/{RunAction → GetTargetScheduledAction}/index.js +0 -0
  102. /package/features/{RunAction → GetTargetScheduledAction}/index.js.map +0 -0
package/constants.d.ts CHANGED
@@ -6,3 +6,8 @@ export declare const SCHEDULE_ID_PREFIX = "wby-schedule-";
6
6
  */
7
7
  export declare const SCHEDULE_MIN_FUTURE_SECONDS = 65;
8
8
  export declare const SCHEDULED_ACTION_EVENT_IDENTIFIER = "WebinyScheduledAction";
9
+ /** Constant identifier for the publish scheduled action type. */
10
+ export declare const SCHEDULED_ACTION_PUBLISH: "publish";
11
+ /** Constant identifier for the unpublish scheduled action type. */
12
+ export declare const SCHEDULED_ACTION_UNPUBLISH: "unpublish";
13
+ export declare const SCHEDULED_ACTIONS: readonly ["publish", "unpublish"];
package/constants.js CHANGED
@@ -7,4 +7,10 @@ export const SCHEDULE_ID_PREFIX = "wby-schedule-";
7
7
  export const SCHEDULE_MIN_FUTURE_SECONDS = 65;
8
8
  export const SCHEDULED_ACTION_EVENT_IDENTIFIER = "WebinyScheduledAction";
9
9
 
10
+ /** Constant identifier for the publish scheduled action type. */
11
+ export const SCHEDULED_ACTION_PUBLISH = "publish";
12
+ /** Constant identifier for the unpublish scheduled action type. */
13
+ export const SCHEDULED_ACTION_UNPUBLISH = "unpublish";
14
+ export const SCHEDULED_ACTIONS = [SCHEDULED_ACTION_PUBLISH, SCHEDULED_ACTION_UNPUBLISH];
15
+
10
16
  //# sourceMappingURL=constants.js.map
package/constants.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["SCHEDULE_MODEL_ID","SCHEDULE_ID_PREFIX","SCHEDULE_MIN_FUTURE_SECONDS","SCHEDULED_ACTION_EVENT_IDENTIFIER"],"sources":["constants.ts"],"sourcesContent":["export const SCHEDULE_MODEL_ID = \"wbySchedule\";\nexport const SCHEDULE_ID_PREFIX = \"wby-schedule-\";\n/**\n * Minimum number of seconds in the future that a schedule can be set.\n * Everything else will result in immediately running the action.\n */\nexport const SCHEDULE_MIN_FUTURE_SECONDS = 65;\n\nexport const SCHEDULED_ACTION_EVENT_IDENTIFIER = \"WebinyScheduledAction\";\n"],"mappings":"AAAA,OAAO,MAAMA,iBAAiB,GAAG,aAAa;AAC9C,OAAO,MAAMC,kBAAkB,GAAG,eAAe;AACjD;AACA;AACA;AACA;AACA,OAAO,MAAMC,2BAA2B,GAAG,EAAE;AAE7C,OAAO,MAAMC,iCAAiC,GAAG,uBAAuB","ignoreList":[]}
1
+ {"version":3,"names":["SCHEDULE_MODEL_ID","SCHEDULE_ID_PREFIX","SCHEDULE_MIN_FUTURE_SECONDS","SCHEDULED_ACTION_EVENT_IDENTIFIER","SCHEDULED_ACTION_PUBLISH","SCHEDULED_ACTION_UNPUBLISH","SCHEDULED_ACTIONS"],"sources":["constants.ts"],"sourcesContent":["export const SCHEDULE_MODEL_ID = \"wbySchedule\";\nexport const SCHEDULE_ID_PREFIX = \"wby-schedule-\";\n/**\n * Minimum number of seconds in the future that a schedule can be set.\n * Everything else will result in immediately running the action.\n */\nexport const SCHEDULE_MIN_FUTURE_SECONDS = 65;\n\nexport const SCHEDULED_ACTION_EVENT_IDENTIFIER = \"WebinyScheduledAction\";\n\n/** Constant identifier for the publish scheduled action type. */\nexport const SCHEDULED_ACTION_PUBLISH = \"publish\" as const;\n/** Constant identifier for the unpublish scheduled action type. */\nexport const SCHEDULED_ACTION_UNPUBLISH = \"unpublish\" as const;\n\nexport const SCHEDULED_ACTIONS = [SCHEDULED_ACTION_PUBLISH, SCHEDULED_ACTION_UNPUBLISH] as const;\n"],"mappings":"AAAA,OAAO,MAAMA,iBAAiB,GAAG,aAAa;AAC9C,OAAO,MAAMC,kBAAkB,GAAG,eAAe;AACjD;AACA;AACA;AACA;AACA,OAAO,MAAMC,2BAA2B,GAAG,EAAE;AAE7C,OAAO,MAAMC,iCAAiC,GAAG,uBAAuB;;AAExE;AACA,OAAO,MAAMC,wBAAwB,GAAG,SAAkB;AAC1D;AACA,OAAO,MAAMC,0BAA0B,GAAG,WAAoB;AAE9D,OAAO,MAAMC,iBAAiB,GAAG,CAACF,wBAAwB,EAAEC,0BAA0B,CAAU","ignoreList":[]}
package/context.js CHANGED
@@ -8,6 +8,9 @@ import { SchedulePrivateModel } from "./domain/SchedulePrivateModel.js";
8
8
  import { SchedulerFeature } from "./features/SchedulerFeature.js";
9
9
  import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
10
10
  import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
11
+ import { SchedulerGraphQLFactory } from "./graphql/index.js";
12
+ import { SchedulerPermissions } from "./domain/permissions.js";
13
+ import { NamespaceHandlerExecutioner } from "./features/NamespaceHandler/NamespaceHandlerExecutioner.js";
11
14
  export const createSchedulerContext = params => {
12
15
  return new ContextPlugin(async context => {
13
16
  const tenantContext = context.container.resolve(TenantContext);
@@ -27,7 +30,10 @@ export const createSchedulerContext = params => {
27
30
  roleArn: manifest.data.roleArn
28
31
  }));
29
32
  }
33
+ context.container.register(SchedulerPermissions.Implementation);
30
34
  context.container.register(SchedulePrivateModel);
35
+ context.container.register(SchedulerGraphQLFactory);
36
+ context.container.register(NamespaceHandlerExecutioner);
31
37
  await context.security.withoutAuthorization(async () => {
32
38
  const schedulerModel = await getModel.execute(SCHEDULE_MODEL_ID);
33
39
  context.container.registerInstance(ScheduledActionModel, schedulerModel.value);
package/context.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["ContextPlugin","getManifest","SCHEDULE_MODEL_ID","ScheduledActionModel","SchedulerService","EventBridgeSchedulerService","VoidSchedulerService","SchedulePrivateModel","SchedulerFeature","TenantContext","GetModelUseCase","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\";\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 context.container.register(SchedulePrivateModel);\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;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AACU,gBAAgB,CAACtB,oBAAoB,EAAE6B,cAAc,CAACE,KAAK,CAAC;IAClF,CAAC,CAAC;;IAEF;IACA1B,gBAAgB,CAACqB,QAAQ,CAAChB,OAAO,CAACE,SAAS,CAAC;EAChD,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["ContextPlugin","getManifest","SCHEDULE_MODEL_ID","ScheduledActionModel","SchedulerService","EventBridgeSchedulerService","VoidSchedulerService","SchedulePrivateModel","SchedulerFeature","TenantContext","GetModelUseCase","SchedulerGraphQLFactory","SchedulerPermissions","NamespaceHandlerExecutioner","createSchedulerContext","params","context","tenantContext","container","resolve","getModel","getTenant","manifest","client","db","driver","getClient","error","registerInstance","lambdaArn","data","roleArn","register","Implementation","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 { SchedulerPermissions } from \"~/domain/permissions.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 context.container.register(SchedulerPermissions.Implementation);\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;AACzB,SAASC,aAAa,QAAQ,0DAA0D;AACxF,SAASC,eAAe,QAAQ,kEAAkE;AAClG,SAASC,uBAAuB;AAChC,SAASC,oBAAoB;AAC7B,SAASC,2BAA2B;AAMpC,OAAO,MAAMC,sBAAsB,GAAIC,MAAgD,IAAK;EACxF,OAAO,IAAIf,aAAa,CAAa,MAAMgB,OAAO,IAAI;IACl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AClF,CAAC,CAAC;;IAEF;IACA9B,gBAAgB,CAACwB,QAAQ,CAAChB,OAAO,CAACE,SAAS,CAAC;EAChD,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
@@ -1,6 +1,7 @@
1
1
  import type { HandlerFactoryParams } from "@webiny/handler-aws/types.js";
2
2
  import { SCHEDULED_ACTION_EVENT_IDENTIFIER } from "./constants.js";
3
3
  export interface IScheduledActionEventPayload {
4
+ namespace: string;
4
5
  id: string;
5
6
  scheduleFor: string;
6
7
  }
@@ -34,7 +34,7 @@ export const createScheduledActionEventHandler = () => {
34
34
  } = params;
35
35
  const input = payload[SCHEDULED_ACTION_EVENT_IDENTIFIER];
36
36
  const executeScheduledAction = context.container.resolve(ExecuteScheduledActionUseCase);
37
- const result = await executeScheduledAction.execute(input.id);
37
+ const result = await executeScheduledAction.execute(input);
38
38
  if (result.isFail()) {
39
39
  const error = result.error;
40
40
  console.error(error.code, error.message);
@@ -1 +1 @@
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 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.id);\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};\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,iCAAiC;AAE1D,SAASC,mBAAmB,QAAQ,sCAAsC;AAC1E,SAASC,kBAAkB,EAAEC,aAAa,QAAQ,kCAAkC;AACpF,SAASC,iCAAiC;AAC1C,SAASC,6BAA6B;AAetC,MAAMC,SAAS,GAAIC,KAAqC,IAAc;EAClE,IAAI,OAAOA,KAAK,EAAEC,cAAc,KAAK,UAAU,EAAE;IAC7C,OAAO,KAAK;EAChB,CAAC,MAAM,IAAI,CAACD,KAAK,CAACC,cAAc,CAACJ,iCAAiC,CAAC,EAAE;IACjE,OAAO,KAAK;EAChB;EAEA,MAAMK,KAAK,GAAGF,KAAK,CAACH,iCAAiC,CAAC;EACtD,OAAO,CAAC,EAAEK,KAAK,EAAEC,EAAE,IAAID,KAAK,EAAEE,WAAW,CAAC;AAC9C,CAAC;AAED,MAAMC,OAAO,GAAGX,mBAAmB,CAAuC;EACtEY,IAAI,EAAE,qDAAqD;EAC3DC,MAAM,EAAER,SAAS;EACjBS,MAAM,EAAE,MAAAA,CAAO;IAAEC,MAAM;IAAET,KAAK;IAAEU;EAAQ,CAAC,KAAK;IAC1C,OAAOd,aAAa,CAACa,MAAM,CAAC,CAACT,KAAK,EAAEU,OAAO,CAAC;EAChD;AACJ,CAAC,CAAC;AAEFjB,QAAQ,CAACkB,QAAQ,CAACN,OAAO,CAAC;AAE1B,OAAO,MAAMO,iCAAiC,GAAGA,CAAA,KAAM;EACnD,OAAOjB,kBAAkB,CAAwB;IAC7CI,SAAS;IACTS,MAAM,EAAE,MAAMC,MAAM,IAAI;MACpB,MAAM;QAAEI,OAAO;QAAEH;MAAQ,CAAC,GAAGD,MAAM;MACnC,MAAMK,KAAK,GAAGD,OAAO,CAAChB,iCAAiC,CAAC;MAExD,MAAMkB,sBAAsB,GAAGL,OAAO,CAACM,SAAS,CAACC,OAAO,CAACnB,6BAA6B,CAAC;MACvF,MAAMoB,MAAM,GAAG,MAAMH,sBAAsB,CAACI,OAAO,CAACL,KAAK,CAACX,EAAE,CAAC;MAE7D,IAAIe,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":[]}
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};\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,iCAAiC;AAE1D,SAASC,mBAAmB,QAAQ,s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,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":[]}
@@ -0,0 +1,16 @@
1
+ import type { IScheduledAction, IScheduledActionEntry } from "../shared/abstractions.js";
2
+ import type { GenericRecord } from "@webiny/api/types.js";
3
+ export declare class ScheduledActionMapper {
4
+ static toAction<T extends GenericRecord = GenericRecord>(action: IScheduledActionEntry<T>): IScheduledAction<T>;
5
+ static toActions<T extends GenericRecord = GenericRecord>(actions: IScheduledActionEntry<T>[]): IScheduledAction<T>[];
6
+ static toGraphQL<T extends GenericRecord = GenericRecord>(action: IScheduledAction<T>): {
7
+ id: string;
8
+ targetId: string;
9
+ namespace: string;
10
+ scheduledBy: import("~/shared/abstractions.js").Identity;
11
+ publishOn: Date | null;
12
+ unpublishOn: Date | null;
13
+ actionType: import("~/shared/abstractions.js").ScheduledActionType;
14
+ title: string;
15
+ };
16
+ }
@@ -0,0 +1,37 @@
1
+ import { parseIdentifier } from "@webiny/utils";
2
+ import { SCHEDULED_ACTION_PUBLISH, SCHEDULED_ACTION_UNPUBLISH } from "../constants.js";
3
+ export class ScheduledActionMapper {
4
+ static toAction(action) {
5
+ const {
6
+ id: scheduleId
7
+ } = parseIdentifier(action.id);
8
+ return {
9
+ id: scheduleId,
10
+ targetId: action.values.targetId,
11
+ namespace: action.values.namespace,
12
+ scheduledBy: action.values.scheduledBy,
13
+ scheduledFor: new Date(action.values.scheduledFor),
14
+ actionType: action.values.actionType,
15
+ title: action.values.title,
16
+ payload: action.values.payload,
17
+ error: action.values.error
18
+ };
19
+ }
20
+ static toActions(actions) {
21
+ return actions.map(ScheduledActionMapper.toAction);
22
+ }
23
+ static toGraphQL(action) {
24
+ return {
25
+ id: action.id,
26
+ targetId: action.targetId,
27
+ namespace: action.namespace,
28
+ scheduledBy: action.scheduledBy,
29
+ publishOn: action.actionType === SCHEDULED_ACTION_PUBLISH ? action.scheduledFor : null,
30
+ unpublishOn: action.actionType === SCHEDULED_ACTION_UNPUBLISH ? action.scheduledFor : null,
31
+ actionType: action.actionType,
32
+ title: action.title
33
+ };
34
+ }
35
+ }
36
+
37
+ //# sourceMappingURL=ScheduledActionMapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["parseIdentifier","SCHEDULED_ACTION_PUBLISH","SCHEDULED_ACTION_UNPUBLISH","ScheduledActionMapper","toAction","action","id","scheduleId","targetId","values","namespace","scheduledBy","scheduledFor","Date","actionType","title","payload","error","toActions","actions","map","toGraphQL","publishOn","unpublishOn"],"sources":["ScheduledActionMapper.ts"],"sourcesContent":["import type { IScheduledAction, IScheduledActionEntry } from \"~/shared/abstractions.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { SCHEDULED_ACTION_PUBLISH, SCHEDULED_ACTION_UNPUBLISH } from \"~/constants.js\";\n\nexport class ScheduledActionMapper {\n static toAction<T extends GenericRecord = GenericRecord>(\n action: IScheduledActionEntry<T>\n ): IScheduledAction<T> {\n const { id: scheduleId } = parseIdentifier(action.id);\n return {\n id: scheduleId,\n targetId: action.values.targetId,\n namespace: action.values.namespace,\n scheduledBy: action.values.scheduledBy,\n scheduledFor: new Date(action.values.scheduledFor),\n actionType: action.values.actionType,\n title: action.values.title,\n payload: action.values.payload,\n error: action.values.error\n };\n }\n\n static toActions<T extends GenericRecord = GenericRecord>(\n actions: IScheduledActionEntry<T>[]\n ): IScheduledAction<T>[] {\n return actions.map(ScheduledActionMapper.toAction);\n }\n\n static toGraphQL<T extends GenericRecord = GenericRecord>(action: IScheduledAction<T>) {\n return {\n id: action.id,\n targetId: action.targetId,\n namespace: action.namespace,\n scheduledBy: action.scheduledBy,\n publishOn: action.actionType === SCHEDULED_ACTION_PUBLISH ? action.scheduledFor : null,\n unpublishOn:\n action.actionType === SCHEDULED_ACTION_UNPUBLISH ? action.scheduledFor : null,\n actionType: action.actionType,\n title: action.title\n };\n }\n}\n"],"mappings":"AAEA,SAASA,eAAe,QAAQ,eAAe;AAC/C,SAASC,wBAAwB,EAAEC,0BAA0B;AAE7D,OAAO,MAAMC,qBAAqB,CAAC;EAC/B,OAAOC,QAAQA,CACXC,MAAgC,EACb;IACnB,MAAM;MAAEC,EAAE,EAAEC;IAAW,CAAC,GAAGP,eAAe,CAACK,MAAM,CAACC,EAAE,CAAC;IACrD,OAAO;MACHA,EAAE,EAAEC,UAAU;MACdC,QAAQ,EAAEH,MAAM,CAACI,MAAM,CAACD,QAAQ;MAChCE,SAAS,EAAEL,MAAM,CAACI,MAAM,CAACC,SAAS;MAClCC,WAAW,EAAEN,MAAM,CAACI,MAAM,CAACE,WAAW;MACtCC,YAAY,EAAE,IAAIC,IAAI,CAACR,MAAM,CAACI,MAAM,CAACG,YAAY,CAAC;MAClDE,UAAU,EAAET,MAAM,CAACI,MAAM,CAACK,UAAU;MACpCC,KAAK,EAAEV,MAAM,CAACI,MAAM,CAACM,KAAK;MAC1BC,OAAO,EAAEX,MAAM,CAACI,MAAM,CAACO,OAAO;MAC9BC,KAAK,EAAEZ,MAAM,CAACI,MAAM,CAACQ;IACzB,CAAC;EACL;EAEA,OAAOC,SAASA,CACZC,OAAmC,EACd;IACrB,OAAOA,OAAO,CAACC,GAAG,CAACjB,qBAAqB,CAACC,QAAQ,CAAC;EACtD;EAEA,OAAOiB,SAASA,CAA0ChB,MAA2B,EAAE;IACnF,OAAO;MACHC,EAAE,EAAED,MAAM,CAACC,EAAE;MACbE,QAAQ,EAAEH,MAAM,CAACG,QAAQ;MACzBE,SAAS,EAAEL,MAAM,CAACK,SAAS;MAC3BC,WAAW,EAAEN,MAAM,CAACM,WAAW;MAC/BW,SAAS,EAAEjB,MAAM,CAACS,UAAU,KAAKb,wBAAwB,GAAGI,MAAM,CAACO,YAAY,GAAG,IAAI;MACtFW,WAAW,EACPlB,MAAM,CAACS,UAAU,KAAKZ,0BAA0B,GAAGG,MAAM,CAACO,YAAY,GAAG,IAAI;MACjFE,UAAU,EAAET,MAAM,CAACS,UAAU;MAC7BC,KAAK,EAAEV,MAAM,CAACU;IAClB,CAAC;EACL;AACJ","ignoreList":[]}
@@ -1,4 +1,11 @@
1
1
  import { BaseError } from "@webiny/feature/api";
2
+ /**
3
+ * Not authorized error when user lacks permissions to manage scheduled actions.
4
+ */
5
+ export declare class NotAuthorizedError extends BaseError {
6
+ readonly code: "Scheduler/NotAuthorized";
7
+ constructor();
8
+ }
2
9
  /**
3
10
  * Scheduled action not found error
4
11
  */
@@ -24,7 +31,7 @@ export declare class InvalidScheduleDateError extends BaseError<{
24
31
  scheduleFor: string;
25
32
  }> {
26
33
  readonly code: "Scheduler/ScheduledAction/InvalidDate";
27
- constructor(scheduleFor: string);
34
+ constructor(scheduleFor: Date);
28
35
  }
29
36
  /**
30
37
  * Scheduler service error (EventBridge/cloud provider errors)
@@ -35,3 +42,14 @@ export declare class SchedulerServiceError extends BaseError<{
35
42
  readonly code: "Scheduler/Service/Error";
36
43
  constructor(error: Error);
37
44
  }
45
+ interface INamespaceHandlerNotFoundErrorData {
46
+ namespace: string;
47
+ }
48
+ /**
49
+ * Namespace handler not found error.
50
+ */
51
+ export declare class NamespaceHandlerNotFoundError extends BaseError<INamespaceHandlerNotFoundErrorData> {
52
+ readonly code: "Scheduler/NamespaceHandler/NotFound";
53
+ constructor(namespace: string);
54
+ }
55
+ export {};
package/domain/errors.js CHANGED
@@ -1,5 +1,17 @@
1
1
  import { BaseError } from "@webiny/feature/api";
2
2
 
3
+ /**
4
+ * Not authorized error when user lacks permissions to manage scheduled actions.
5
+ */
6
+ export class NotAuthorizedError extends BaseError {
7
+ code = "Scheduler/NotAuthorized";
8
+ constructor() {
9
+ super({
10
+ message: "Not authorized!"
11
+ });
12
+ }
13
+ }
14
+
3
15
  /**
4
16
  * Scheduled action not found error
5
17
  */
@@ -39,7 +51,7 @@ export class InvalidScheduleDateError extends BaseError {
39
51
  super({
40
52
  message: "Cannot schedule in the past",
41
53
  data: {
42
- scheduleFor
54
+ scheduleFor: scheduleFor.toISOString()
43
55
  }
44
56
  });
45
57
  }
@@ -59,5 +71,19 @@ export class SchedulerServiceError extends BaseError {
59
71
  });
60
72
  }
61
73
  }
74
+ /**
75
+ * Namespace handler not found error.
76
+ */
77
+ export class NamespaceHandlerNotFoundError extends BaseError {
78
+ code = "Scheduler/NamespaceHandler/NotFound";
79
+ constructor(namespace) {
80
+ super({
81
+ message: `Namespace handler for "${namespace}" was not found.`,
82
+ data: {
83
+ namespace
84
+ }
85
+ });
86
+ }
87
+ }
62
88
 
63
89
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["BaseError","ScheduledActionNotFoundError","code","constructor","scheduleId","message","data","ScheduledActionPersistenceError","error","originalError","InvalidScheduleDateError","scheduleFor","SchedulerServiceError"],"sources":["errors.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\n\n/**\n * Scheduled action not found error\n */\nexport class ScheduledActionNotFoundError extends BaseError<{ scheduleId: string }> {\n override readonly code = \"Scheduler/ScheduledAction/NotFound\" as const;\n\n constructor(scheduleId: string) {\n super({\n message: `Scheduled action \"${scheduleId}\" was not found.`,\n data: {\n scheduleId\n }\n });\n }\n}\n\n/**\n * Storage/persistence error when working with scheduled actions\n */\nexport class ScheduledActionPersistenceError extends BaseError<{ originalError: Error }> {\n override readonly code = \"Scheduler/ScheduledAction/PersistenceError\" as const;\n\n constructor(error: Error) {\n super({\n message: error.message,\n data: { originalError: error }\n });\n }\n}\n\n/**\n * Invalid schedule date error (e.g., scheduling in the past)\n */\nexport class InvalidScheduleDateError extends BaseError<{ scheduleFor: string }> {\n override readonly code = \"Scheduler/ScheduledAction/InvalidDate\" as const;\n\n constructor(scheduleFor: string) {\n super({\n message: \"Cannot schedule in the past\",\n data: { scheduleFor }\n });\n }\n}\n\n/**\n * Scheduler service error (EventBridge/cloud provider errors)\n */\nexport class SchedulerServiceError extends BaseError<{ originalError: Error }> {\n override readonly code = \"Scheduler/Service/Error\" as const;\n\n constructor(error: Error) {\n super({\n message: `Scheduler service error: ${error.message}`,\n data: { originalError: error }\n });\n }\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,qBAAqB;;AAE/C;AACA;AACA;AACA,OAAO,MAAMC,4BAA4B,SAASD,SAAS,CAAyB;EAC9DE,IAAI,GAAG,oCAAoC;EAE7DC,WAAWA,CAACC,UAAkB,EAAE;IAC5B,KAAK,CAAC;MACFC,OAAO,EAAE,qBAAqBD,UAAU,kBAAkB;MAC1DE,IAAI,EAAE;QACFF;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;;AAEA;AACA;AACA;AACA,OAAO,MAAMG,+BAA+B,SAASP,SAAS,CAA2B;EACnEE,IAAI,GAAG,4CAA4C;EAErEC,WAAWA,CAACK,KAAY,EAAE;IACtB,KAAK,CAAC;MACFH,OAAO,EAAEG,KAAK,CAACH,OAAO;MACtBC,IAAI,EAAE;QAAEG,aAAa,EAAED;MAAM;IACjC,CAAC,CAAC;EACN;AACJ;;AAEA;AACA;AACA;AACA,OAAO,MAAME,wBAAwB,SAASV,SAAS,CAA0B;EAC3DE,IAAI,GAAG,uCAAuC;EAEhEC,WAAWA,CAACQ,WAAmB,EAAE;IAC7B,KAAK,CAAC;MACFN,OAAO,EAAE,6BAA6B;MACtCC,IAAI,EAAE;QAAEK;MAAY;IACxB,CAAC,CAAC;EACN;AACJ;;AAEA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,SAASZ,SAAS,CAA2B;EACzDE,IAAI,GAAG,yBAAyB;EAElDC,WAAWA,CAACK,KAAY,EAAE;IACtB,KAAK,CAAC;MACFH,OAAO,EAAE,4BAA4BG,KAAK,CAACH,OAAO,EAAE;MACpDC,IAAI,EAAE;QAAEG,aAAa,EAAED;MAAM;IACjC,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["BaseError","NotAuthorizedError","code","constructor","message","ScheduledActionNotFoundError","scheduleId","data","ScheduledActionPersistenceError","error","originalError","InvalidScheduleDateError","scheduleFor","toISOString","SchedulerServiceError","NamespaceHandlerNotFoundError","namespace"],"sources":["errors.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\n\n/**\n * Not authorized error when user lacks permissions to manage scheduled actions.\n */\nexport class NotAuthorizedError extends BaseError {\n override readonly code = \"Scheduler/NotAuthorized\" as const;\n\n constructor() {\n super({ message: \"Not authorized!\" });\n }\n}\n\n/**\n * Scheduled action not found error\n */\nexport class ScheduledActionNotFoundError extends BaseError<{ scheduleId: string }> {\n override readonly code = \"Scheduler/ScheduledAction/NotFound\" as const;\n\n constructor(scheduleId: string) {\n super({\n message: `Scheduled action \"${scheduleId}\" was not found.`,\n data: {\n scheduleId\n }\n });\n }\n}\n\n/**\n * Storage/persistence error when working with scheduled actions\n */\nexport class ScheduledActionPersistenceError extends BaseError<{ originalError: Error }> {\n override readonly code = \"Scheduler/ScheduledAction/PersistenceError\" as const;\n\n constructor(error: Error) {\n super({\n message: error.message,\n data: { originalError: error }\n });\n }\n}\n\n/**\n * Invalid schedule date error (e.g., scheduling in the past)\n */\nexport class InvalidScheduleDateError extends BaseError<{ scheduleFor: string }> {\n override readonly code = \"Scheduler/ScheduledAction/InvalidDate\" as const;\n\n constructor(scheduleFor: Date) {\n super({\n message: \"Cannot schedule in the past\",\n data: {\n scheduleFor: scheduleFor.toISOString()\n }\n });\n }\n}\n\n/**\n * Scheduler service error (EventBridge/cloud provider errors)\n */\nexport class SchedulerServiceError extends BaseError<{ originalError: Error }> {\n override readonly code = \"Scheduler/Service/Error\" as const;\n\n constructor(error: Error) {\n super({\n message: `Scheduler service error: ${error.message}`,\n data: { originalError: error }\n });\n }\n}\n\ninterface INamespaceHandlerNotFoundErrorData {\n namespace: string;\n}\n/**\n * Namespace handler not found error.\n */\nexport class NamespaceHandlerNotFoundError extends BaseError<INamespaceHandlerNotFoundErrorData> {\n override readonly code = \"Scheduler/NamespaceHandler/NotFound\" as const;\n\n constructor(namespace: string) {\n super({\n message: `Namespace handler for \"${namespace}\" was not found.`,\n data: {\n namespace\n }\n });\n }\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,qBAAqB;;AAE/C;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,SAASD,SAAS,CAAC;EAC5BE,IAAI,GAAG,yBAAyB;EAElDC,WAAWA,CAAA,EAAG;IACV,KAAK,CAAC;MAAEC,OAAO,EAAE;IAAkB,CAAC,CAAC;EACzC;AACJ;;AAEA;AACA;AACA;AACA,OAAO,MAAMC,4BAA4B,SAASL,SAAS,CAAyB;EAC9DE,IAAI,GAAG,oCAAoC;EAE7DC,WAAWA,CAACG,UAAkB,EAAE;IAC5B,KAAK,CAAC;MACFF,OAAO,EAAE,qBAAqBE,UAAU,kBAAkB;MAC1DC,IAAI,EAAE;QACFD;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;;AAEA;AACA;AACA;AACA,OAAO,MAAME,+BAA+B,SAASR,SAAS,CAA2B;EACnEE,IAAI,GAAG,4CAA4C;EAErEC,WAAWA,CAACM,KAAY,EAAE;IACtB,KAAK,CAAC;MACFL,OAAO,EAAEK,KAAK,CAACL,OAAO;MACtBG,IAAI,EAAE;QAAEG,aAAa,EAAED;MAAM;IACjC,CAAC,CAAC;EACN;AACJ;;AAEA;AACA;AACA;AACA,OAAO,MAAME,wBAAwB,SAASX,SAAS,CAA0B;EAC3DE,IAAI,GAAG,uCAAuC;EAEhEC,WAAWA,CAACS,WAAiB,EAAE;IAC3B,KAAK,CAAC;MACFR,OAAO,EAAE,6BAA6B;MACtCG,IAAI,EAAE;QACFK,WAAW,EAAEA,WAAW,CAACC,WAAW,CAAC;MACzC;IACJ,CAAC,CAAC;EACN;AACJ;;AAEA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,SAASd,SAAS,CAA2B;EACzDE,IAAI,GAAG,yBAAyB;EAElDC,WAAWA,CAACM,KAAY,EAAE;IACtB,KAAK,CAAC;MACFL,OAAO,EAAE,4BAA4BK,KAAK,CAACL,OAAO,EAAE;MACpDG,IAAI,EAAE;QAAEG,aAAa,EAAED;MAAM;IACjC,CAAC,CAAC;EACN;AACJ;AAKA;AACA;AACA;AACA,OAAO,MAAMM,6BAA6B,SAASf,SAAS,CAAqC;EAC3EE,IAAI,GAAG,qCAAqC;EAE9DC,WAAWA,CAACa,SAAiB,EAAE;IAC3B,KAAK,CAAC;MACFZ,OAAO,EAAE,0BAA0BY,SAAS,kBAAkB;MAC9DT,IAAI,EAAE;QACFS;MACJ;IACJ,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
@@ -3,4 +3,4 @@
3
3
  * We need to ensure that the date is at least a SCHEDULE_MIN_FUTURE_MINUTES minutes in the future.
4
4
  * Otherwise, we consider it as "immediate" and run the action right away.
5
5
  */
6
- export declare const isValidDate: (date: string) => boolean;
6
+ export declare const isValidDate: (input: Date) => boolean;
@@ -5,9 +5,9 @@ import { SCHEDULE_MIN_FUTURE_SECONDS } from "../constants.js";
5
5
  * We need to ensure that the date is at least a SCHEDULE_MIN_FUTURE_MINUTES minutes in the future.
6
6
  * Otherwise, we consider it as "immediate" and run the action right away.
7
7
  */
8
- export const isValidDate = date => {
8
+ export const isValidDate = input => {
9
9
  const minDate = new Date(Date.now() + SCHEDULE_MIN_FUTURE_SECONDS * 1000);
10
- return new Date(date).getTime() >= minDate.getTime();
10
+ return input.getTime() >= minDate.getTime();
11
11
  };
12
12
 
13
13
  //# sourceMappingURL=isValidDate.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["SCHEDULE_MIN_FUTURE_SECONDS","isValidDate","date","minDate","Date","now","getTime"],"sources":["isValidDate.ts"],"sourcesContent":["import { SCHEDULE_MIN_FUTURE_SECONDS } from \"~/constants.js\";\n\n/**\n * Check if the provided date is in the future.\n * We need to ensure that the date is at least a SCHEDULE_MIN_FUTURE_MINUTES minutes in the future.\n * Otherwise, we consider it as \"immediate\" and run the action right away.\n */\nexport const isValidDate = (date: string): boolean => {\n const minDate = new Date(Date.now() + SCHEDULE_MIN_FUTURE_SECONDS * 1000);\n\n return new Date(date).getTime() >= minDate.getTime();\n};\n"],"mappings":"AAAA,SAASA,2BAA2B;;AAEpC;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,WAAW,GAAIC,IAAY,IAAc;EAClD,MAAMC,OAAO,GAAG,IAAIC,IAAI,CAACA,IAAI,CAACC,GAAG,CAAC,CAAC,GAAGL,2BAA2B,GAAG,IAAI,CAAC;EAEzE,OAAO,IAAII,IAAI,CAACF,IAAI,CAAC,CAACI,OAAO,CAAC,CAAC,IAAIH,OAAO,CAACG,OAAO,CAAC,CAAC;AACxD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["SCHEDULE_MIN_FUTURE_SECONDS","isValidDate","input","minDate","Date","now","getTime"],"sources":["isValidDate.ts"],"sourcesContent":["import { SCHEDULE_MIN_FUTURE_SECONDS } from \"~/constants.js\";\n\n/**\n * Check if the provided date is in the future.\n * We need to ensure that the date is at least a SCHEDULE_MIN_FUTURE_MINUTES minutes in the future.\n * Otherwise, we consider it as \"immediate\" and run the action right away.\n */\nexport const isValidDate = (input: Date): boolean => {\n const minDate = new Date(Date.now() + SCHEDULE_MIN_FUTURE_SECONDS * 1000);\n\n return input.getTime() >= minDate.getTime();\n};\n"],"mappings":"AAAA,SAASA,2BAA2B;;AAEpC;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,WAAW,GAAIC,KAAW,IAAc;EACjD,MAAMC,OAAO,GAAG,IAAIC,IAAI,CAACA,IAAI,CAACC,GAAG,CAAC,CAAC,GAAGL,2BAA2B,GAAG,IAAI,CAAC;EAEzE,OAAOE,KAAK,CAACI,OAAO,CAAC,CAAC,IAAIH,OAAO,CAACG,OAAO,CAAC,CAAC;AAC/C,CAAC","ignoreList":[]}
@@ -0,0 +1,45 @@
1
+ import type { Permissions } from "@webiny/api-core/features/security/permissions/index.js";
2
+ declare const schema: {
3
+ readonly prefix: "scheduler";
4
+ readonly fullAccess: true;
5
+ readonly entities: readonly [{
6
+ readonly id: "action";
7
+ readonly permission: "scheduler.action";
8
+ readonly scopes: readonly ["full", "own"];
9
+ }];
10
+ };
11
+ type SchedulerSchema = typeof schema;
12
+ export declare const SchedulerPermissions: {
13
+ Abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/security/permissions/types").PermissionsTyped<{
14
+ readonly prefix: "scheduler";
15
+ readonly fullAccess: true;
16
+ readonly entities: readonly [{
17
+ readonly id: "action";
18
+ readonly permission: "scheduler.action";
19
+ readonly scopes: readonly ["full", "own"];
20
+ }];
21
+ }>>;
22
+ Implementation: import("@webiny/di").Constructor<import("@webiny/api-core/features/security/permissions/types").PermissionsTyped<{
23
+ readonly prefix: "scheduler";
24
+ readonly fullAccess: true;
25
+ readonly entities: readonly [{
26
+ readonly id: "action";
27
+ readonly permission: "scheduler.action";
28
+ readonly scopes: readonly ["full", "own"];
29
+ }];
30
+ }>> & {
31
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/security/permissions/types").PermissionsTyped<{
32
+ readonly prefix: "scheduler";
33
+ readonly fullAccess: true;
34
+ readonly entities: readonly [{
35
+ readonly id: "action";
36
+ readonly permission: "scheduler.action";
37
+ readonly scopes: readonly ["full", "own"];
38
+ }];
39
+ }>>;
40
+ };
41
+ };
42
+ export declare namespace SchedulerPermissions {
43
+ type Interface = Permissions<SchedulerSchema>;
44
+ }
45
+ export {};
@@ -0,0 +1,13 @@
1
+ import { createPermissions } from "@webiny/api-core/features/security/permissions/index.js";
2
+ const schema = {
3
+ prefix: "scheduler",
4
+ fullAccess: true,
5
+ entities: [{
6
+ id: "action",
7
+ permission: "scheduler.action",
8
+ scopes: ["full", "own"]
9
+ }]
10
+ };
11
+ export const SchedulerPermissions = createPermissions(schema);
12
+
13
+ //# sourceMappingURL=permissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createPermissions","schema","prefix","fullAccess","entities","id","permission","scopes","SchedulerPermissions"],"sources":["permissions.ts"],"sourcesContent":["import { createPermissions } from \"@webiny/api-core/features/security/permissions/index.js\";\nimport type { Permissions } from \"@webiny/api-core/features/security/permissions/index.js\";\n\nconst schema = {\n prefix: \"scheduler\",\n fullAccess: true,\n entities: [\n {\n id: \"action\",\n permission: \"scheduler.action\",\n scopes: [\"full\", \"own\"]\n }\n ]\n} as const;\n\ntype SchedulerSchema = typeof schema;\n\nexport const SchedulerPermissions = createPermissions(schema);\n\nexport namespace SchedulerPermissions {\n export type Interface = Permissions<SchedulerSchema>;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,yDAAyD;AAG3F,MAAMC,MAAM,GAAG;EACXC,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,CAAU;AAIV,OAAO,MAAMC,oBAAoB,GAAGR,iBAAiB,CAACC,MAAM,CAAC","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ export { ScheduleActionUseCase } from "../../features/ScheduleAction/index.js";
2
+ export type { ScheduleActionError } from "../../features/ScheduleAction/index.js";
3
+ export { GetScheduledActionUseCase } from "../../features/GetScheduledAction/index.js";
4
+ export { ListScheduledActionsUseCase } from "../../features/ListScheduledActions/index.js";
5
+ export { CancelScheduledActionUseCase } from "../../features/CancelScheduledAction/index.js";
6
+ export { ExecuteScheduledActionUseCase } from "../../features/ExecuteScheduledAction/index.js";
7
+ export { NamespaceHandler } from "../../features/NamespaceHandler/index.js";
8
+ export type { IScheduledAction, IScheduledActionEntry, ScheduledActionType } from "../../shared/abstractions.js";
9
+ export { SchedulerService, ScheduledActionModel, ScheduledActionHandler } from "../../shared/abstractions.js";
10
+ export { SCHEDULED_ACTION_PUBLISH as ScheduledActionTypePublish, SCHEDULED_ACTION_UNPUBLISH as ScheduledActionTypeUnpublish } from "../../constants.js";
@@ -0,0 +1,10 @@
1
+ export { ScheduleActionUseCase } from "../../features/ScheduleAction/index.js";
2
+ export { GetScheduledActionUseCase } from "../../features/GetScheduledAction/index.js";
3
+ export { ListScheduledActionsUseCase } from "../../features/ListScheduledActions/index.js";
4
+ export { CancelScheduledActionUseCase } from "../../features/CancelScheduledAction/index.js";
5
+ export { ExecuteScheduledActionUseCase } from "../../features/ExecuteScheduledAction/index.js";
6
+ export { NamespaceHandler } from "../../features/NamespaceHandler/index.js";
7
+ export { SchedulerService, ScheduledActionModel, ScheduledActionHandler } from "../../shared/abstractions.js";
8
+ export { SCHEDULED_ACTION_PUBLISH as ScheduledActionTypePublish, SCHEDULED_ACTION_UNPUBLISH as ScheduledActionTypeUnpublish } from "../../constants.js";
9
+
10
+ //# sourceMappingURL=scheduler.js.map
@@ -0,0 +1 @@
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":[]}
@@ -3,6 +3,7 @@ import { CancelScheduledActionUseCase as UseCaseAbstraction } from "./abstractio
3
3
  import { GetScheduledActionUseCase } from "../../features/GetScheduledAction/abstractions.js";
4
4
  import { ScheduledActionModel, SchedulerService } from "../../shared/abstractions.js";
5
5
  import { DeleteEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/DeleteEntry/index.js";
6
+ import { SchedulerPermissions } from "../../domain/permissions.js";
6
7
  /**
7
8
  * Cancels a scheduled action
8
9
  *
@@ -17,8 +18,9 @@ declare class CancelScheduledActionUseCaseImpl implements UseCaseAbstraction.Int
17
18
  private schedulerService;
18
19
  private deleteEntryUseCase;
19
20
  private model;
20
- constructor(getScheduledActionUseCase: GetScheduledActionUseCase.Interface, schedulerService: SchedulerService.Interface, deleteEntryUseCase: DeleteEntryUseCase.Interface, model: ScheduledActionModel.Interface);
21
- execute(id: string): Promise<Result<void, UseCaseAbstraction.Error>>;
21
+ private permissions;
22
+ constructor(getScheduledActionUseCase: GetScheduledActionUseCase.Interface, schedulerService: SchedulerService.Interface, deleteEntryUseCase: DeleteEntryUseCase.Interface, model: ScheduledActionModel.Interface, permissions: SchedulerPermissions.Interface);
23
+ execute(params: UseCaseAbstraction.Params): Promise<Result<boolean, UseCaseAbstraction.Error>>;
22
24
  }
23
25
  export declare const CancelScheduledActionUseCase: typeof CancelScheduledActionUseCaseImpl & {
24
26
  __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ICancelScheduledActionUseCase>;
@@ -2,10 +2,11 @@ import { Result } from "@webiny/feature/api";
2
2
  import { CancelScheduledActionUseCase as UseCaseAbstraction } from "./abstractions.js";
3
3
  import { GetScheduledActionUseCase } from "../GetScheduledAction/abstractions.js";
4
4
  import { ScheduledActionModel, SchedulerService } from "../../shared/abstractions.js";
5
- import { ScheduledActionNotFoundError, ScheduledActionPersistenceError } from "../../domain/errors.js";
5
+ import { NotAuthorizedError, ScheduledActionNotFoundError, ScheduledActionPersistenceError } from "../../domain/errors.js";
6
6
  import { DeleteEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/DeleteEntry/index.js";
7
7
  import { ScheduledActionIdWithVersion } from "../../domain/ScheduledActionIdWithVersion.js";
8
8
  import { EntryNotFoundError } from "@webiny/api-headless-cms/domain/contentEntry/errors.js";
9
+ import { SchedulerPermissions } from "../../domain/permissions.js";
9
10
 
10
11
  /**
11
12
  * Cancels a scheduled action
@@ -17,15 +18,23 @@ import { EntryNotFoundError } from "@webiny/api-headless-cms/domain/contentEntry
17
18
  * 4. If EventBridge delete fails, continue anyway (schedule might already be executed/deleted)
18
19
  */
19
20
  class CancelScheduledActionUseCaseImpl {
20
- constructor(getScheduledActionUseCase, schedulerService, deleteEntryUseCase, model) {
21
+ constructor(getScheduledActionUseCase, schedulerService, deleteEntryUseCase, model, permissions) {
21
22
  this.getScheduledActionUseCase = getScheduledActionUseCase;
22
23
  this.schedulerService = schedulerService;
23
24
  this.deleteEntryUseCase = deleteEntryUseCase;
24
25
  this.model = model;
26
+ this.permissions = permissions;
25
27
  }
26
- async execute(id) {
28
+ async execute(params) {
29
+ const hasPermission = await this.permissions.canRead("action");
30
+ if (!hasPermission) {
31
+ return Result.fail(new NotAuthorizedError());
32
+ }
33
+ const {
34
+ id
35
+ } = params;
27
36
  // Check if scheduled action exists
28
- const getResult = await this.getScheduledActionUseCase.execute(id);
37
+ const getResult = await this.getScheduledActionUseCase.execute(params);
29
38
  if (getResult.isFail()) {
30
39
  const error = getResult.error;
31
40
  if (error.code === "Scheduler/ScheduledAction/NotFound") {
@@ -50,7 +59,7 @@ class CancelScheduledActionUseCaseImpl {
50
59
  }
51
60
 
52
61
  // Delete CMS entry
53
- const deleteResult = await this.deleteEntryUseCase.execute(this.model, scheduleId, {
62
+ const deleteResult = await this.deleteEntryUseCase.execute(this.model, getResult.value.id, {
54
63
  force: true,
55
64
  permanently: true
56
65
  });
@@ -59,16 +68,16 @@ class CancelScheduledActionUseCaseImpl {
59
68
  * Some process could have already deleted the entry, in which case we can safely ignore this error.
60
69
  */
61
70
  if (deleteResult.error instanceof EntryNotFoundError) {
62
- return Result.ok();
71
+ return Result.ok(true);
63
72
  }
64
73
  return Result.fail(new ScheduledActionPersistenceError(new Error(deleteResult.error.message)));
65
74
  }
66
- return Result.ok();
75
+ return Result.ok(true);
67
76
  }
68
77
  }
69
78
  export const CancelScheduledActionUseCase = UseCaseAbstraction.createImplementation({
70
79
  implementation: CancelScheduledActionUseCaseImpl,
71
- dependencies: [GetScheduledActionUseCase, SchedulerService, DeleteEntryUseCase, ScheduledActionModel]
80
+ dependencies: [GetScheduledActionUseCase, SchedulerService, DeleteEntryUseCase, ScheduledActionModel, SchedulerPermissions.Abstraction]
72
81
  });
73
82
 
74
83
  //# sourceMappingURL=CancelScheduledActionUseCase.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Result","CancelScheduledActionUseCase","UseCaseAbstraction","GetScheduledActionUseCase","ScheduledActionModel","SchedulerService","ScheduledActionNotFoundError","ScheduledActionPersistenceError","DeleteEntryUseCase","ScheduledActionIdWithVersion","EntryNotFoundError","CancelScheduledActionUseCaseImpl","constructor","getScheduledActionUseCase","schedulerService","deleteEntryUseCase","model","execute","id","getResult","isFail","error","code","fail","scheduleId","from","eventBridgeSchedule","exists","delete","console","warn","deleteResult","force","permanently","ok","Error","message","createImplementation","implementation","dependencies"],"sources":["CancelScheduledActionUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { CancelScheduledActionUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { GetScheduledActionUseCase } from \"~/features/GetScheduledAction/abstractions.js\";\nimport { ScheduledActionModel, SchedulerService } from \"~/shared/abstractions.js\";\nimport { ScheduledActionNotFoundError, ScheduledActionPersistenceError } from \"~/domain/errors.js\";\nimport { DeleteEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/DeleteEntry/index.js\";\nimport { ScheduledActionIdWithVersion } from \"~/domain/ScheduledActionIdWithVersion.js\";\nimport { EntryNotFoundError } from \"@webiny/api-headless-cms/domain/contentEntry/errors.js\";\n\n/**\n * Cancels a scheduled action\n *\n * Flow:\n * 1. Check if schedule exists\n * 2. Delete EventBridge schedule\n * 3. Delete CMS entry\n * 4. If EventBridge delete fails, continue anyway (schedule might already be executed/deleted)\n */\nclass CancelScheduledActionUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getScheduledActionUseCase: GetScheduledActionUseCase.Interface,\n private schedulerService: SchedulerService.Interface,\n private deleteEntryUseCase: DeleteEntryUseCase.Interface,\n private model: ScheduledActionModel.Interface\n ) {}\n\n async execute(id: string): Promise<Result<void, UseCaseAbstraction.Error>> {\n // Check if scheduled action exists\n const getResult = await this.getScheduledActionUseCase.execute(id);\n\n if (getResult.isFail()) {\n const error = getResult.error;\n\n if (error.code === \"Scheduler/ScheduledAction/NotFound\") {\n return Result.fail(new ScheduledActionNotFoundError(id));\n }\n\n return Result.fail(error);\n }\n\n const scheduleId = ScheduledActionIdWithVersion.from(id);\n\n // Delete EventBridge schedule\n // Note: We continue even if this fails, as the schedule might already be executed/deleted\n try {\n const eventBridgeSchedule = await this.schedulerService.exists(id);\n /**\n * No point to even try deleting if it doesn't exist.\n */\n if (eventBridgeSchedule) {\n await this.schedulerService.delete(id);\n }\n } catch (error) {\n console.warn(\n `Failed to delete EventBridge schedule: ${scheduleId}. Continuing with CMS entry deletion.`,\n error\n );\n }\n\n // Delete CMS entry\n const deleteResult = await this.deleteEntryUseCase.execute(this.model, scheduleId, {\n force: true,\n permanently: true\n });\n\n if (deleteResult.isFail()) {\n /**\n * Some process could have already deleted the entry, in which case we can safely ignore this error.\n */\n if (deleteResult.error instanceof EntryNotFoundError) {\n return Result.ok();\n }\n return Result.fail(\n new ScheduledActionPersistenceError(new Error(deleteResult.error.message))\n );\n }\n\n return Result.ok();\n }\n}\n\nexport const CancelScheduledActionUseCase = UseCaseAbstraction.createImplementation({\n implementation: CancelScheduledActionUseCaseImpl,\n dependencies: [\n GetScheduledActionUseCase,\n SchedulerService,\n DeleteEntryUseCase,\n ScheduledActionModel\n ]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,4BAA4B,IAAIC,kBAAkB;AAC3D,SAASC,yBAAyB;AAClC,SAASC,oBAAoB,EAAEC,gBAAgB;AAC/C,SAASC,4BAA4B,EAAEC,+BAA+B;AACtE,SAASC,kBAAkB,QAAQ,qEAAqE;AACxG,SAASC,4BAA4B;AACrC,SAASC,kBAAkB,QAAQ,wDAAwD;;AAE3F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,gCAAgC,CAAyC;EAC3EC,WAAWA,CACCC,yBAA8D,EAC9DC,gBAA4C,EAC5CC,kBAAgD,EAChDC,KAAqC,EAC/C;IAAA,KAJUH,yBAA8D,GAA9DA,yBAA8D;IAAA,KAC9DC,gBAA4C,GAA5CA,gBAA4C;IAAA,KAC5CC,kBAAgD,GAAhDA,kBAAgD;IAAA,KAChDC,KAAqC,GAArCA,KAAqC;EAC9C;EAEH,MAAMC,OAAOA,CAACC,EAAU,EAAmD;IACvE;IACA,MAAMC,SAAS,GAAG,MAAM,IAAI,CAACN,yBAAyB,CAACI,OAAO,CAACC,EAAE,CAAC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ACtB;AACJ;AAEA,OAAO,MAAMjC,4BAA4B,GAAGC,kBAAkB,CAACmC,oBAAoB,CAAC;EAChFC,cAAc,EAAE3B,gCAAgC;EAChD4B,YAAY,EAAE,CACVpC,yBAAyB,EACzBE,gBAAgB,EAChBG,kBAAkB,EAClBJ,oBAAoB;AAE5B,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["Result","CancelScheduledActionUseCase","UseCaseAbstraction","GetScheduledActionUseCase","ScheduledActionModel","SchedulerService","NotAuthorizedError","ScheduledActionNotFoundError","ScheduledActionPersistenceError","DeleteEntryUseCase","ScheduledActionIdWithVersion","EntryNotFoundError","SchedulerPermissions","CancelScheduledActionUseCaseImpl","constructor","getScheduledActionUseCase","schedulerService","deleteEntryUseCase","model","permissions","execute","params","hasPermission","canRead","fail","id","getResult","isFail","error","code","scheduleId","from","eventBridgeSchedule","exists","delete","console","warn","deleteResult","value","force","permanently","ok","Error","message","createImplementation","implementation","dependencies","Abstraction"],"sources":["CancelScheduledActionUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { CancelScheduledActionUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { GetScheduledActionUseCase } from \"~/features/GetScheduledAction/abstractions.js\";\nimport { ScheduledActionModel, SchedulerService } from \"~/shared/abstractions.js\";\nimport {\n NotAuthorizedError,\n ScheduledActionNotFoundError,\n ScheduledActionPersistenceError\n} from \"~/domain/errors.js\";\nimport { DeleteEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/DeleteEntry/index.js\";\nimport { ScheduledActionIdWithVersion } from \"~/domain/ScheduledActionIdWithVersion.js\";\nimport { EntryNotFoundError } from \"@webiny/api-headless-cms/domain/contentEntry/errors.js\";\nimport { SchedulerPermissions } from \"~/domain/permissions.js\";\n\n/**\n * Cancels a scheduled action\n *\n * Flow:\n * 1. Check if schedule exists\n * 2. Delete EventBridge schedule\n * 3. Delete CMS entry\n * 4. If EventBridge delete fails, continue anyway (schedule might already be executed/deleted)\n */\nclass CancelScheduledActionUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getScheduledActionUseCase: GetScheduledActionUseCase.Interface,\n private schedulerService: SchedulerService.Interface,\n private deleteEntryUseCase: DeleteEntryUseCase.Interface,\n private model: ScheduledActionModel.Interface,\n private permissions: SchedulerPermissions.Interface\n ) {}\n\n async execute(\n params: UseCaseAbstraction.Params\n ): Promise<Result<boolean, UseCaseAbstraction.Error>> {\n const hasPermission = await this.permissions.canRead(\"action\");\n if (!hasPermission) {\n return Result.fail(new NotAuthorizedError());\n }\n const { id } = params;\n // Check if scheduled action exists\n const getResult = await this.getScheduledActionUseCase.execute(params);\n\n if (getResult.isFail()) {\n const error = getResult.error;\n\n if (error.code === \"Scheduler/ScheduledAction/NotFound\") {\n return Result.fail(new ScheduledActionNotFoundError(id));\n }\n\n return Result.fail(error);\n }\n\n const scheduleId = ScheduledActionIdWithVersion.from(id);\n\n // Delete EventBridge schedule\n // Note: We continue even if this fails, as the schedule might already be executed/deleted\n try {\n const eventBridgeSchedule = await this.schedulerService.exists(id);\n /**\n * No point to even try deleting if it doesn't exist.\n */\n if (eventBridgeSchedule) {\n await this.schedulerService.delete(id);\n }\n } catch (error) {\n console.warn(\n `Failed to delete EventBridge schedule: ${scheduleId}. Continuing with CMS entry deletion.`,\n error\n );\n }\n\n // Delete CMS entry\n const deleteResult = await this.deleteEntryUseCase.execute(this.model, getResult.value.id, {\n force: true,\n permanently: true\n });\n\n if (deleteResult.isFail()) {\n /**\n * Some process could have already deleted the entry, in which case we can safely ignore this error.\n */\n if (deleteResult.error instanceof EntryNotFoundError) {\n return Result.ok(true);\n }\n return Result.fail(\n new ScheduledActionPersistenceError(new Error(deleteResult.error.message))\n );\n }\n\n return Result.ok(true);\n }\n}\n\nexport const CancelScheduledActionUseCase = UseCaseAbstraction.createImplementation({\n implementation: CancelScheduledActionUseCaseImpl,\n dependencies: [\n GetScheduledActionUseCase,\n SchedulerService,\n DeleteEntryUseCase,\n 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iC,YAAY,EAAE,CACV3C,yBAAyB,EACzBE,gBAAgB,EAChBI,kBAAkB,EAClBL,oBAAoB,EACpBQ,oBAAoB,CAACmC,WAAW;AAExC,CAAC,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import { Result } from "@webiny/feature/api";
2
- import { ScheduledActionNotFoundError, ScheduledActionPersistenceError, SchedulerServiceError } from "../../domain/errors.js";
2
+ import { NotAuthorizedError, ScheduledActionNotFoundError, ScheduledActionPersistenceError, SchedulerServiceError } from "../../domain/errors.js";
3
3
  /**
4
4
  * CancelScheduledActionUseCase - Cancel a scheduled action
5
5
  *
@@ -11,14 +11,21 @@ export interface ICancelScheduledActionErrors {
11
11
  notFound: ScheduledActionNotFoundError;
12
12
  persistence: ScheduledActionPersistenceError;
13
13
  schedulerService: SchedulerServiceError;
14
+ unauthorized: NotAuthorizedError;
14
15
  }
15
16
  type CancelScheduledActionError = ICancelScheduledActionErrors[keyof ICancelScheduledActionErrors];
17
+ export interface ICancelScheduledActionUseCaseParams {
18
+ namespace: string;
19
+ id: string;
20
+ }
16
21
  export interface ICancelScheduledActionUseCase {
17
- execute(scheduleId: string): Promise<Result<void, CancelScheduledActionError>>;
22
+ execute(params: ICancelScheduledActionUseCaseParams): Promise<Result<boolean, CancelScheduledActionError>>;
18
23
  }
24
+ /** Cancel a scheduled action. */
19
25
  export declare const CancelScheduledActionUseCase: import("@webiny/di").Abstraction<ICancelScheduledActionUseCase>;
20
26
  export declare namespace CancelScheduledActionUseCase {
21
27
  type Interface = ICancelScheduledActionUseCase;
22
28
  type Error = CancelScheduledActionError;
29
+ type Params = ICancelScheduledActionUseCaseParams;
23
30
  }
24
31
  export {};
@@ -8,6 +8,7 @@ import { createAbstraction } from "@webiny/feature/api";
8
8
  * determines the action should no longer execute.
9
9
  */
10
10
 
11
- export const CancelScheduledActionUseCase = createAbstraction("CancelScheduledActionUseCase");
11
+ /** Cancel a scheduled action. */
12
+ export const CancelScheduledActionUseCase = createAbstraction("Scheduler/CancelScheduledActionUseCase");
12
13
 
13
14
  //# sourceMappingURL=abstractions.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","CancelScheduledActionUseCase"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport {\n ScheduledActionNotFoundError,\n ScheduledActionPersistenceError,\n SchedulerServiceError\n} from \"~/domain/errors.js\";\n\n/**\n * CancelScheduledActionUseCase - Cancel a scheduled action\n *\n * Cancels both the CMS entry and the EventBridge schedule.\n * Used when a user manually cancels a scheduled action or when business logic\n * determines the action should no longer execute.\n */\n\nexport interface ICancelScheduledActionErrors {\n notFound: ScheduledActionNotFoundError;\n persistence: ScheduledActionPersistenceError;\n schedulerService: SchedulerServiceError;\n}\n\ntype CancelScheduledActionError = ICancelScheduledActionErrors[keyof ICancelScheduledActionErrors];\n\nexport interface ICancelScheduledActionUseCase {\n execute(scheduleId: string): Promise<Result<void, CancelScheduledActionError>>;\n}\n\nexport const CancelScheduledActionUseCase = createAbstraction<ICancelScheduledActionUseCase>(\n \"CancelScheduledActionUseCase\"\n);\n\nexport namespace CancelScheduledActionUseCase {\n export type Interface = ICancelScheduledActionUseCase;\n export type Error = CancelScheduledActionError;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAQvD;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA,OAAO,MAAMC,4BAA4B,GAAGD,iBAAiB,CACzD,8BACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["createAbstraction","CancelScheduledActionUseCase"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction, Result } from \"@webiny/feature/api\";\nimport {\n NotAuthorizedError,\n ScheduledActionNotFoundError,\n ScheduledActionPersistenceError,\n SchedulerServiceError\n} from \"~/domain/errors.js\";\n\n/**\n * CancelScheduledActionUseCase - Cancel a scheduled action\n *\n * Cancels both the CMS entry and the EventBridge schedule.\n * Used when a user manually cancels a scheduled action or when business logic\n * determines the action should no longer execute.\n */\n\nexport interface ICancelScheduledActionErrors {\n notFound: ScheduledActionNotFoundError;\n persistence: ScheduledActionPersistenceError;\n schedulerService: SchedulerServiceError;\n unauthorized: NotAuthorizedError;\n}\n\ntype CancelScheduledActionError = ICancelScheduledActionErrors[keyof ICancelScheduledActionErrors];\nexport interface ICancelScheduledActionUseCaseParams {\n namespace: string;\n id: string;\n}\nexport interface ICancelScheduledActionUseCase {\n execute(\n params: ICancelScheduledActionUseCaseParams\n ): Promise<Result<boolean, CancelScheduledActionError>>;\n}\n\n/** Cancel a scheduled action. */\nexport const CancelScheduledActionUseCase = createAbstraction<ICancelScheduledActionUseCase>(\n \"Scheduler/CancelScheduledActionUseCase\"\n);\n\nexport namespace CancelScheduledActionUseCase {\n export type Interface = ICancelScheduledActionUseCase;\n export type Error = CancelScheduledActionError;\n export type Params = ICancelScheduledActionUseCaseParams;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAgB,qBAAqB;;AAQ/D;AACA;AACA;AACA;AACA;AACA;AACA;;AAoBA;AACA,OAAO,MAAMC,4BAA4B,GAAGD,iBAAiB,CACzD,wCACJ,CAAC","ignoreList":[]}