@webiny/api-scheduler 0.0.0-unstable.df7a8bb475 → 0.0.0-unstable.e1999482d0

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 (161) hide show
  1. package/ScheduledActionLambdaHandler.d.ts +18 -0
  2. package/ScheduledActionLambdaHandler.js +41 -0
  3. package/ScheduledActionLambdaHandler.js.map +1 -0
  4. package/SchedulerFeature.d.ts +5 -0
  5. package/SchedulerFeature.js +21 -0
  6. package/SchedulerFeature.js.map +1 -0
  7. package/constants.d.ts +5 -0
  8. package/constants.js +11 -8
  9. package/constants.js.map +1 -1
  10. package/domain/SchedulePrivateModel.js +26 -22
  11. package/domain/SchedulePrivateModel.js.map +1 -1
  12. package/domain/ScheduledActionId.js +12 -4
  13. package/domain/ScheduledActionId.js.map +1 -1
  14. package/domain/ScheduledActionIdWithVersion.js +5 -6
  15. package/domain/ScheduledActionIdWithVersion.js.map +1 -1
  16. package/domain/ScheduledActionMapper.d.ts +16 -0
  17. package/domain/ScheduledActionMapper.js +42 -0
  18. package/domain/ScheduledActionMapper.js.map +1 -0
  19. package/domain/errors.d.ts +22 -4
  20. package/domain/errors.js +55 -56
  21. package/domain/errors.js.map +1 -1
  22. package/domain/isValidDate.d.ts +1 -1
  23. package/domain/isValidDate.js +5 -9
  24. package/domain/isValidDate.js.map +1 -1
  25. package/exports/api/scheduler.d.ts +11 -0
  26. package/exports/api/scheduler.js +9 -0
  27. package/features/CancelScheduledAction/CancelScheduledActionUseCase.d.ts +12 -6
  28. package/features/CancelScheduledAction/CancelScheduledActionUseCase.js +67 -62
  29. package/features/CancelScheduledAction/CancelScheduledActionUseCase.js.map +1 -1
  30. package/features/CancelScheduledAction/abstractions.d.ts +11 -3
  31. package/features/CancelScheduledAction/abstractions.js +2 -10
  32. package/features/CancelScheduledAction/abstractions.js.map +1 -1
  33. package/features/CancelScheduledAction/feature.d.ts +5 -2
  34. package/features/CancelScheduledAction/feature.js +6 -12
  35. package/features/CancelScheduledAction/feature.js.map +1 -1
  36. package/features/CancelScheduledAction/index.js +0 -2
  37. package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.d.ts +4 -4
  38. package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.js +75 -90
  39. package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.js.map +1 -1
  40. package/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.d.ts +2 -2
  41. package/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.js +21 -25
  42. package/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.js.map +1 -1
  43. package/features/ExecuteScheduledAction/abstractions.d.ts +11 -3
  44. package/features/ExecuteScheduledAction/abstractions.js +12 -36
  45. package/features/ExecuteScheduledAction/abstractions.js.map +1 -1
  46. package/features/ExecuteScheduledAction/feature.d.ts +5 -2
  47. package/features/ExecuteScheduledAction/feature.js +7 -13
  48. package/features/ExecuteScheduledAction/feature.js.map +1 -1
  49. package/features/ExecuteScheduledAction/index.js +0 -2
  50. package/features/GetScheduledAction/GetScheduledActionUseCase.d.ts +8 -12
  51. package/features/GetScheduledAction/GetScheduledActionUseCase.js +44 -40
  52. package/features/GetScheduledAction/GetScheduledActionUseCase.js.map +1 -1
  53. package/features/GetScheduledAction/abstractions.d.ts +9 -2
  54. package/features/GetScheduledAction/abstractions.js +2 -11
  55. package/features/GetScheduledAction/abstractions.js.map +1 -1
  56. package/features/GetScheduledAction/feature.d.ts +4 -1
  57. package/features/GetScheduledAction/feature.js +6 -12
  58. package/features/GetScheduledAction/feature.js.map +1 -1
  59. package/features/GetScheduledAction/index.js +0 -2
  60. package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.d.ts +21 -0
  61. package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js +69 -0
  62. package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js.map +1 -0
  63. package/features/GetTargetScheduledAction/abstractions.d.ts +24 -0
  64. package/features/GetTargetScheduledAction/abstractions.js +5 -0
  65. package/features/GetTargetScheduledAction/abstractions.js.map +1 -0
  66. package/features/GetTargetScheduledAction/feature.d.ts +10 -0
  67. package/features/GetTargetScheduledAction/feature.js +11 -0
  68. package/features/GetTargetScheduledAction/feature.js.map +1 -0
  69. package/features/{RunAction → GetTargetScheduledAction}/index.js +0 -2
  70. package/features/ListScheduledActions/ListScheduledActionsUseCase.d.ts +7 -12
  71. package/features/ListScheduledActions/ListScheduledActionsUseCase.js +61 -68
  72. package/features/ListScheduledActions/ListScheduledActionsUseCase.js.map +1 -1
  73. package/features/ListScheduledActions/abstractions.d.ts +11 -3
  74. package/features/ListScheduledActions/abstractions.js +2 -12
  75. package/features/ListScheduledActions/abstractions.js.map +1 -1
  76. package/features/ListScheduledActions/feature.d.ts +4 -1
  77. package/features/ListScheduledActions/feature.js +6 -12
  78. package/features/ListScheduledActions/feature.js.map +1 -1
  79. package/features/ListScheduledActions/index.js +0 -2
  80. package/features/NamespaceHandler/NamespaceHandlerExecutioner.d.ts +11 -0
  81. package/features/NamespaceHandler/NamespaceHandlerExecutioner.js +26 -0
  82. package/features/NamespaceHandler/NamespaceHandlerExecutioner.js.map +1 -0
  83. package/features/NamespaceHandler/abstractions.d.ts +51 -0
  84. package/features/NamespaceHandler/abstractions.js +6 -0
  85. package/features/NamespaceHandler/abstractions.js.map +1 -0
  86. package/features/NamespaceHandler/feature.d.ts +4 -0
  87. package/features/NamespaceHandler/feature.js +11 -0
  88. package/features/NamespaceHandler/feature.js.map +1 -0
  89. package/features/NamespaceHandler/index.d.ts +1 -0
  90. package/features/NamespaceHandler/index.js +1 -0
  91. package/features/ScheduleAction/ScheduleActionUseCase.d.ts +9 -9
  92. package/features/ScheduleAction/ScheduleActionUseCase.js +158 -144
  93. package/features/ScheduleAction/ScheduleActionUseCase.js.map +1 -1
  94. package/features/ScheduleAction/abstractions.d.ts +16 -11
  95. package/features/ScheduleAction/abstractions.js +2 -10
  96. package/features/ScheduleAction/abstractions.js.map +1 -1
  97. package/features/ScheduleAction/feature.d.ts +4 -1
  98. package/features/ScheduleAction/feature.js +6 -12
  99. package/features/ScheduleAction/feature.js.map +1 -1
  100. package/features/ScheduleAction/index.js +0 -2
  101. package/features/ScheduledActionModelProvider.d.ts +26 -0
  102. package/features/ScheduledActionModelProvider.js +22 -0
  103. package/features/ScheduledActionModelProvider.js.map +1 -0
  104. package/features/SchedulerFeature.d.ts +4 -1
  105. package/features/SchedulerFeature.js +12 -20
  106. package/features/SchedulerFeature.js.map +1 -1
  107. package/features/SchedulerService/VoidSchedulerService.d.ts +9 -9
  108. package/features/SchedulerService/VoidSchedulerService.js +17 -24
  109. package/features/SchedulerService/VoidSchedulerService.js.map +1 -1
  110. package/features/permissions/SchedulerPermissionsResolver.d.ts +12 -0
  111. package/features/permissions/SchedulerPermissionsResolver.js +42 -0
  112. package/features/permissions/SchedulerPermissionsResolver.js.map +1 -0
  113. package/features/permissions/abstractions.d.ts +32 -0
  114. package/features/permissions/abstractions.js +6 -0
  115. package/features/permissions/abstractions.js.map +1 -0
  116. package/graphql/SchedulerGraphQLFactory.d.ts +9 -0
  117. package/graphql/SchedulerGraphQLFactory.js +223 -0
  118. package/graphql/SchedulerGraphQLFactory.js.map +1 -0
  119. package/graphql/feature.d.ts +4 -0
  120. package/graphql/feature.js +11 -0
  121. package/graphql/feature.js.map +1 -0
  122. package/graphql/index.d.ts +1 -0
  123. package/graphql/index.js +1 -0
  124. package/index.d.ts +3 -8
  125. package/index.js +3 -12
  126. package/package.json +22 -34
  127. package/shared/abstractions.d.ts +49 -13
  128. package/shared/abstractions.js +4 -29
  129. package/shared/abstractions.js.map +1 -1
  130. package/context.d.ts +0 -7
  131. package/context.js +0 -41
  132. package/context.js.map +0 -1
  133. package/createEventHandler.d.ts +0 -13
  134. package/createEventHandler.js +0 -50
  135. package/createEventHandler.js.map +0 -1
  136. package/createScheduler.d.ts +0 -6
  137. package/createScheduler.js +0 -11
  138. package/createScheduler.js.map +0 -1
  139. package/features/CancelScheduledAction/index.js.map +0 -1
  140. package/features/ExecuteScheduledAction/index.js.map +0 -1
  141. package/features/GetScheduledAction/index.js.map +0 -1
  142. package/features/ListScheduledActions/index.js.map +0 -1
  143. package/features/RunAction/RunActionUseCase.d.ts +0 -23
  144. package/features/RunAction/RunActionUseCase.js +0 -37
  145. package/features/RunAction/RunActionUseCase.js.map +0 -1
  146. package/features/RunAction/abstractions.d.ts +0 -35
  147. package/features/RunAction/abstractions.js +0 -15
  148. package/features/RunAction/abstractions.js.map +0 -1
  149. package/features/RunAction/feature.d.ts +0 -7
  150. package/features/RunAction/feature.js +0 -17
  151. package/features/RunAction/feature.js.map +0 -1
  152. package/features/RunAction/index.js.map +0 -1
  153. package/features/ScheduleAction/index.js.map +0 -1
  154. package/features/SchedulerService/EventBridgeSchedulerService.d.ts +0 -26
  155. package/features/SchedulerService/EventBridgeSchedulerService.js +0 -131
  156. package/features/SchedulerService/EventBridgeSchedulerService.js.map +0 -1
  157. package/index.js.map +0 -1
  158. package/manifest.d.ts +0 -17
  159. package/manifest.js +0 -39
  160. package/manifest.js.map +0 -1
  161. /package/features/{RunAction → GetTargetScheduledAction}/index.d.ts +0 -0
@@ -1,4 +1,4 @@
1
- import { IScheduledAction, ScheduledActionHandler } from "../../shared/abstractions.js";
1
+ import { IScheduledAction, ScheduledActionHandler, type ScheduledActionType } from "../../shared/abstractions.js";
2
2
  import type { GenericRecord } from "@webiny/api/types.js";
3
3
  /**
4
4
  * Composite handler that iterates through all registered handlers
@@ -10,7 +10,7 @@ import type { GenericRecord } from "@webiny/api/types.js";
10
10
  declare class ScheduledActionHandlerCompositeImpl implements ScheduledActionHandler.Interface {
11
11
  private handlers;
12
12
  constructor(handlers: ScheduledActionHandler.Interface[]);
13
- canHandle(namespace: string, actionType: string): boolean;
13
+ canHandle(namespace: string, actionType: ScheduledActionType): boolean;
14
14
  handle<T extends GenericRecord>(action: IScheduledAction<T>): Promise<void>;
15
15
  }
16
16
  export declare const ScheduledActionHandlerComposite: typeof ScheduledActionHandlerCompositeImpl & {
@@ -1,32 +1,28 @@
1
1
  import { ScheduledActionHandler } from "../../shared/abstractions.js";
2
- /**
3
- * Composite handler that iterates through all registered handlers
4
- * to find one that can handle the given namespace + actionType combination.
5
- *
6
- * This is registered as a composite via container.registerComposite(),
7
- * and the DI container will automatically inject all registered handlers.
8
- */
9
2
  class ScheduledActionHandlerCompositeImpl {
10
- constructor(handlers) {
11
- this.handlers = handlers;
12
- }
13
- canHandle(namespace, actionType) {
14
- return this.handlers.some(handler => handler.canHandle(namespace, actionType));
15
- }
16
- async handle(action) {
17
- const handler = this.handlers.find(h => h.canHandle(action.namespace, action.actionType));
18
- if (!handler) {
19
- console.log(`No handler found for namespace "${action.namespace}" and actionType "${action.actionType}"`);
20
- return;
3
+ constructor(handlers){
4
+ this.handlers = handlers;
5
+ }
6
+ canHandle(namespace, actionType) {
7
+ return this.handlers.some((handler)=>handler.canHandle(namespace, actionType));
8
+ }
9
+ async handle(action) {
10
+ const handler = this.handlers.find((h)=>h.canHandle(action.namespace, action.actionType));
11
+ if (!handler) return void console.log(`No handler found for namespace "${action.namespace}" and actionType "${action.actionType}"`);
12
+ await handler.handle(action);
21
13
  }
22
- await handler.handle(action);
23
- }
24
14
  }
25
- export const ScheduledActionHandlerComposite = ScheduledActionHandler.createComposite({
26
- implementation: ScheduledActionHandlerCompositeImpl,
27
- dependencies: [[ScheduledActionHandler, {
28
- multiple: true
29
- }]]
15
+ const ScheduledActionHandlerComposite = ScheduledActionHandler.createComposite({
16
+ implementation: ScheduledActionHandlerCompositeImpl,
17
+ dependencies: [
18
+ [
19
+ ScheduledActionHandler,
20
+ {
21
+ multiple: true
22
+ }
23
+ ]
24
+ ]
30
25
  });
26
+ export { ScheduledActionHandlerComposite };
31
27
 
32
28
  //# sourceMappingURL=ScheduledActionHandlerComposite.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ScheduledActionHandler","ScheduledActionHandlerCompositeImpl","constructor","handlers","canHandle","namespace","actionType","some","handler","handle","action","find","h","console","log","ScheduledActionHandlerComposite","createComposite","implementation","dependencies","multiple"],"sources":["ScheduledActionHandlerComposite.ts"],"sourcesContent":["import { IScheduledAction, ScheduledActionHandler } from \"~/shared/abstractions.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\n/**\n * Composite handler that iterates through all registered handlers\n * to find one that can handle the given namespace + actionType combination.\n *\n * This is registered as a composite via container.registerComposite(),\n * and the DI container will automatically inject all registered handlers.\n */\nclass ScheduledActionHandlerCompositeImpl implements ScheduledActionHandler.Interface {\n public constructor(private handlers: ScheduledActionHandler.Interface[]) {}\n\n public canHandle(namespace: string, actionType: string): boolean {\n return this.handlers.some(handler => handler.canHandle(namespace, actionType));\n }\n\n public async handle<T extends GenericRecord>(action: IScheduledAction<T>): Promise<void> {\n const handler = this.handlers.find(h => h.canHandle(action.namespace, action.actionType));\n\n if (!handler) {\n console.log(\n `No handler found for namespace \"${action.namespace}\" and actionType \"${action.actionType}\"`\n );\n return;\n }\n\n await handler.handle(action);\n }\n}\n\nexport const ScheduledActionHandlerComposite = ScheduledActionHandler.createComposite({\n implementation: ScheduledActionHandlerCompositeImpl,\n dependencies: [[ScheduledActionHandler, { multiple: true }]]\n});\n"],"mappings":"AAAA,SAA2BA,sBAAsB;AAGjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,mCAAmC,CAA6C;EAC3EC,WAAWA,CAASC,QAA4C,EAAE;IAAA,KAA9CA,QAA4C,GAA5CA,QAA4C;EAAG;EAEnEC,SAASA,CAACC,SAAiB,EAAEC,UAAkB,EAAW;IAC7D,OAAO,IAAI,CAACH,QAAQ,CAACI,IAAI,CAACC,OAAO,IAAIA,OAAO,CAACJ,SAAS,CAACC,SAAS,EAAEC,UAAU,CAAC,CAAC;EAClF;EAEA,MAAaG,MAAMA,CAA0BC,MAA2B,EAAiB;IACrF,MAAMF,OAAO,GAAG,IAAI,CAACL,QAAQ,CAACQ,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACR,SAAS,CAACM,MAAM,CAACL,SAAS,EAAEK,MAAM,CAACJ,UAAU,CAAC,CAAC;IAEzF,IAAI,CAACE,OAAO,EAAE;MACVK,OAAO,CAACC,GAAG,CACP,mCAAmCJ,MAAM,CAACL,SAAS,qBAAqBK,MAAM,CAACJ,UAAU,GAC7F,CAAC;MACD;IACJ;IAEA,MAAME,OAAO,CAACC,MAAM,CAACC,MAAM,CAAC;EAChC;AACJ;AAEA,OAAO,MAAMK,+BAA+B,GAAGf,sBAAsB,CAACgB,eAAe,CAAC;EAClFC,cAAc,EAAEhB,mCAAmC;EACnDiB,YAAY,EAAE,CAAC,CAAClB,sBAAsB,EAAE;IAAEmB,QAAQ,EAAE;EAAK,CAAC,CAAC;AAC/D,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/ExecuteScheduledAction/ScheduledActionHandlerComposite.js","sources":["../../../src/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.ts"],"sourcesContent":["import {\n IScheduledAction,\n ScheduledActionHandler,\n type ScheduledActionType\n} from \"~/shared/abstractions.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\n/**\n * Composite handler that iterates through all registered handlers\n * to find one that can handle the given namespace + actionType combination.\n *\n * This is registered as a composite via container.registerComposite(),\n * and the DI container will automatically inject all registered handlers.\n */\nclass ScheduledActionHandlerCompositeImpl implements ScheduledActionHandler.Interface {\n public constructor(private handlers: ScheduledActionHandler.Interface[]) {}\n\n public canHandle(namespace: string, actionType: ScheduledActionType): boolean {\n return this.handlers.some(handler => handler.canHandle(namespace, actionType));\n }\n\n public async handle<T extends GenericRecord>(action: IScheduledAction<T>): Promise<void> {\n const handler = this.handlers.find(h => h.canHandle(action.namespace, action.actionType));\n\n if (!handler) {\n console.log(\n `No handler found for namespace \"${action.namespace}\" and actionType \"${action.actionType}\"`\n );\n return;\n }\n\n await handler.handle(action);\n }\n}\n\nexport const ScheduledActionHandlerComposite = ScheduledActionHandler.createComposite({\n implementation: ScheduledActionHandlerCompositeImpl,\n dependencies: [[ScheduledActionHandler, { multiple: true }]]\n});\n"],"names":["ScheduledActionHandlerCompositeImpl","handlers","namespace","actionType","handler","action","h","console","ScheduledActionHandlerComposite","ScheduledActionHandler"],"mappings":";AAcA,MAAMA;IACF,YAA2BC,QAA4C,CAAE;aAA9CA,QAAQ,GAARA;IAA+C;IAEnE,UAAUC,SAAiB,EAAEC,UAA+B,EAAW;QAC1E,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAACC,CAAAA,UAAWA,QAAQ,SAAS,CAACF,WAAWC;IACtE;IAEA,MAAa,OAAgCE,MAA2B,EAAiB;QACrF,MAAMD,UAAU,IAAI,CAAC,QAAQ,CAAC,IAAI,CAACE,CAAAA,IAAKA,EAAE,SAAS,CAACD,OAAO,SAAS,EAAEA,OAAO,UAAU;QAEvF,IAAI,CAACD,SAAS,YACVG,QAAQ,GAAG,CACP,CAAC,gCAAgC,EAAEF,OAAO,SAAS,CAAC,kBAAkB,EAAEA,OAAO,UAAU,CAAC,CAAC,CAAC;QAKpG,MAAMD,QAAQ,MAAM,CAACC;IACzB;AACJ;AAEO,MAAMG,kCAAkCC,uBAAuB,eAAe,CAAC;IAClF,gBAAgBT;IAChB,cAAc;QAAC;YAACS;YAAwB;gBAAE,UAAU;YAAK;SAAE;KAAC;AAChE"}
@@ -1,9 +1,9 @@
1
1
  import { Result } from "@webiny/feature/api";
2
- import { ScheduledActionNotFoundError, ScheduledActionPersistenceError } from "../../domain/errors.js";
2
+ import { NotAuthorizedError, ScheduledActionNotFoundError, ScheduledActionPersistenceError } from "../../domain/errors.js";
3
3
  /**
4
4
  * ExecuteScheduledActionUseCase - Execute a scheduled action
5
5
  *
6
- * This is triggered by EventBridge when a schedule fires.
6
+ * This is triggered by the scheduler when a schedule fires.
7
7
  * Finds the appropriate handler based on namespace + actionType and executes it.
8
8
  *
9
9
  * Flow:
@@ -18,15 +18,23 @@ export interface IExecuteScheduledActionErrors {
18
18
  persistence: ScheduledActionPersistenceError;
19
19
  handlerNotFound: HandlerNotFoundError;
20
20
  executionFailed: ExecutionFailedError;
21
+ unauthorized: NotAuthorizedError;
21
22
  }
22
23
  type ExecuteScheduledActionError = IExecuteScheduledActionErrors[keyof IExecuteScheduledActionErrors];
24
+ export interface IExecuteScheduledActionUseCaseParams {
25
+ namespace: string;
26
+ tenant: string;
27
+ id: string;
28
+ }
23
29
  export interface IExecuteScheduledActionUseCase {
24
- execute(scheduleId: string): Promise<Result<void, ExecuteScheduledActionError>>;
30
+ execute(params: IExecuteScheduledActionUseCaseParams): Promise<Result<void, ExecuteScheduledActionError>>;
25
31
  }
32
+ /** Execute a scheduled action immediately. */
26
33
  export declare const ExecuteScheduledActionUseCase: import("@webiny/di").Abstraction<IExecuteScheduledActionUseCase>;
27
34
  export declare namespace ExecuteScheduledActionUseCase {
28
35
  type Interface = IExecuteScheduledActionUseCase;
29
36
  type Error = ExecuteScheduledActionError;
37
+ type Params = IExecuteScheduledActionUseCaseParams;
30
38
  }
31
39
  /**
32
40
  * Handler not found error
@@ -1,41 +1,17 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
-
3
- /**
4
- * ExecuteScheduledActionUseCase - Execute a scheduled action
5
- *
6
- * This is triggered by EventBridge when a schedule fires.
7
- * Finds the appropriate handler based on namespace + actionType and executes it.
8
- *
9
- * Flow:
10
- * 1. Load scheduled action from CMS
11
- * 2. Find registered handler for namespace + actionType
12
- * 3. Execute handler
13
- * 4. Delete schedule entry on success
14
- * 5. Update entry with error on failure
15
- */
16
-
17
- export const ExecuteScheduledActionUseCase = createAbstraction("ExecuteScheduledActionUseCase");
18
- /**
19
- * Handler not found error
20
- */
21
- export class HandlerNotFoundError extends Error {
22
- code = "Scheduler/Handler/NotFound";
23
- constructor(namespace, actionType) {
24
- super(`No handler registered for namespace "${namespace}" and actionType "${actionType}"`);
25
- this.name = "HandlerNotFoundError";
26
- }
2
+ const ExecuteScheduledActionUseCase = createAbstraction("Scheduler/ExecuteScheduledActionUseCase");
3
+ class HandlerNotFoundError extends Error {
4
+ constructor(namespace, actionType){
5
+ super(`No handler registered for namespace "${namespace}" and actionType "${actionType}"`), this.code = "Scheduler/Handler/NotFound";
6
+ this.name = "HandlerNotFoundError";
7
+ }
27
8
  }
28
-
29
- /**
30
- * Execution failed error
31
- */
32
- export class ExecutionFailedError extends Error {
33
- code = "Scheduler/Execution/Failed";
34
- constructor(message, originalError) {
35
- super(message);
36
- this.originalError = originalError;
37
- this.name = "ExecutionFailedError";
38
- }
9
+ class ExecutionFailedError extends Error {
10
+ constructor(message, originalError){
11
+ super(message), this.originalError = originalError, this.code = "Scheduler/Execution/Failed";
12
+ this.name = "ExecutionFailedError";
13
+ }
39
14
  }
15
+ export { ExecuteScheduledActionUseCase, ExecutionFailedError, HandlerNotFoundError };
40
16
 
41
17
  //# sourceMappingURL=abstractions.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","ExecuteScheduledActionUseCase","HandlerNotFoundError","Error","code","constructor","namespace","actionType","name","ExecutionFailedError","message","originalError"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { ScheduledActionNotFoundError, ScheduledActionPersistenceError } from \"~/domain/errors.js\";\n\n/**\n * ExecuteScheduledActionUseCase - Execute a scheduled action\n *\n * This is triggered by EventBridge when a schedule fires.\n * Finds the appropriate handler based on namespace + actionType and executes it.\n *\n * Flow:\n * 1. Load scheduled action from CMS\n * 2. Find registered handler for namespace + actionType\n * 3. Execute handler\n * 4. Delete schedule entry on success\n * 5. Update entry with error on failure\n */\n\nexport interface IExecuteScheduledActionErrors {\n notFound: ScheduledActionNotFoundError;\n persistence: ScheduledActionPersistenceError;\n handlerNotFound: HandlerNotFoundError;\n executionFailed: ExecutionFailedError;\n}\n\ntype ExecuteScheduledActionError =\n IExecuteScheduledActionErrors[keyof IExecuteScheduledActionErrors];\n\nexport interface IExecuteScheduledActionUseCase {\n execute(scheduleId: string): Promise<Result<void, ExecuteScheduledActionError>>;\n}\n\nexport const ExecuteScheduledActionUseCase = createAbstraction<IExecuteScheduledActionUseCase>(\n \"ExecuteScheduledActionUseCase\"\n);\n\nexport namespace ExecuteScheduledActionUseCase {\n export type Interface = IExecuteScheduledActionUseCase;\n export type Error = ExecuteScheduledActionError;\n}\n\n/**\n * Handler not found error\n */\nexport class HandlerNotFoundError extends Error {\n readonly code = \"Scheduler/Handler/NotFound\" as const;\n\n constructor(namespace: string, actionType: string) {\n super(`No handler registered for namespace \"${namespace}\" and actionType \"${actionType}\"`);\n this.name = \"HandlerNotFoundError\";\n }\n}\n\n/**\n * Execution failed error\n */\nexport class ExecutionFailedError extends Error {\n readonly code = \"Scheduler/Execution/Failed\" as const;\n\n constructor(\n message: string,\n public readonly originalError?: Error\n ) {\n super(message);\n this.name = \"ExecutionFailedError\";\n }\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAIvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA,OAAO,MAAMC,6BAA6B,GAAGD,iBAAiB,CAC1D,+BACJ,CAAC;AAOD;AACA;AACA;AACA,OAAO,MAAME,oBAAoB,SAASC,KAAK,CAAC;EACnCC,IAAI,GAAG,4BAA4B;EAE5CC,WAAWA,CAACC,SAAiB,EAAEC,UAAkB,EAAE;IAC/C,KAAK,CAAC,wCAAwCD,SAAS,qBAAqBC,UAAU,GAAG,CAAC;IAC1F,IAAI,CAACC,IAAI,GAAG,sBAAsB;EACtC;AACJ;;AAEA;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,SAASN,KAAK,CAAC;EACnCC,IAAI,GAAG,4BAA4B;EAE5CC,WAAWA,CACPK,OAAe,EACCC,aAAqB,EACvC;IACE,KAAK,CAACD,OAAO,CAAC;IAAC,KAFCC,aAAqB,GAArBA,aAAqB;IAGrC,IAAI,CAACH,IAAI,GAAG,sBAAsB;EACtC;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"features/ExecuteScheduledAction/abstractions.js","sources":["../../../src/features/ExecuteScheduledAction/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport {\n NotAuthorizedError,\n ScheduledActionNotFoundError,\n ScheduledActionPersistenceError\n} from \"~/domain/errors.js\";\n\n/**\n * ExecuteScheduledActionUseCase - Execute a scheduled action\n *\n * This is triggered by the scheduler when a schedule fires.\n * Finds the appropriate handler based on namespace + actionType and executes it.\n *\n * Flow:\n * 1. Load scheduled action from CMS\n * 2. Find registered handler for namespace + actionType\n * 3. Execute handler\n * 4. Delete schedule entry on success\n * 5. Update entry with error on failure\n */\n\nexport interface IExecuteScheduledActionErrors {\n notFound: ScheduledActionNotFoundError;\n persistence: ScheduledActionPersistenceError;\n handlerNotFound: HandlerNotFoundError;\n executionFailed: ExecutionFailedError;\n unauthorized: NotAuthorizedError;\n}\n\ntype ExecuteScheduledActionError =\n IExecuteScheduledActionErrors[keyof IExecuteScheduledActionErrors];\n\nexport interface IExecuteScheduledActionUseCaseParams {\n namespace: string;\n tenant: string;\n id: string;\n}\n\nexport interface IExecuteScheduledActionUseCase {\n execute(\n params: IExecuteScheduledActionUseCaseParams\n ): Promise<Result<void, ExecuteScheduledActionError>>;\n}\n\n/** Execute a scheduled action immediately. */\nexport const ExecuteScheduledActionUseCase = createAbstraction<IExecuteScheduledActionUseCase>(\n \"Scheduler/ExecuteScheduledActionUseCase\"\n);\n\nexport namespace ExecuteScheduledActionUseCase {\n export type Interface = IExecuteScheduledActionUseCase;\n export type Error = ExecuteScheduledActionError;\n export type Params = IExecuteScheduledActionUseCaseParams;\n}\n\n/**\n * Handler not found error\n */\nexport class HandlerNotFoundError extends Error {\n readonly code = \"Scheduler/Handler/NotFound\" as const;\n\n constructor(namespace: string, actionType: string) {\n super(`No handler registered for namespace \"${namespace}\" and actionType \"${actionType}\"`);\n this.name = \"HandlerNotFoundError\";\n }\n}\n\n/**\n * Execution failed error\n */\nexport class ExecutionFailedError extends Error {\n readonly code = \"Scheduler/Execution/Failed\" as const;\n\n constructor(\n message: string,\n public readonly originalError?: Error\n ) {\n super(message);\n this.name = \"ExecutionFailedError\";\n }\n}\n"],"names":["ExecuteScheduledActionUseCase","createAbstraction","HandlerNotFoundError","Error","namespace","actionType","ExecutionFailedError","message","originalError"],"mappings":";AA8CO,MAAMA,gCAAgCC,kBACzC;AAYG,MAAMC,6BAA6BC;IAGtC,YAAYC,SAAiB,EAAEC,UAAkB,CAAE;QAC/C,KAAK,CAAC,CAAC,qCAAqC,EAAED,UAAU,kBAAkB,EAAEC,WAAW,CAAC,CAAC,QAHpF,IAAI,GAAG;QAIZ,IAAI,CAAC,IAAI,GAAG;IAChB;AACJ;AAKO,MAAMC,6BAA6BH;IAGtC,YACII,OAAe,EACCC,aAAqB,CACvC;QACE,KAAK,CAACD,UAAAA,IAAAA,CAFUC,aAAa,GAAbA,eAAAA,IAAAA,CAJX,IAAI,GAAG;QAOZ,IAAI,CAAC,IAAI,GAAG;IAChB;AACJ"}
@@ -1,7 +1,10 @@
1
1
  /**
2
2
  * ExecuteScheduledAction Feature
3
3
  *
4
- * Provides the ability to execute a scheduled action when triggered by EventBridge.
4
+ * Provides the ability to execute a scheduled action when the scheduler fires.
5
5
  * Finds the appropriate handler and executes it, then cleans up the schedule entry.
6
6
  */
7
- export declare const ExecuteScheduledActionFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
7
+ export declare const ExecuteScheduledActionFeature: {
8
+ name: string;
9
+ register(container: import("@webiny/di").Container): void;
10
+ };
@@ -1,19 +1,13 @@
1
1
  import { createFeature } from "@webiny/feature/api";
2
2
  import { ExecuteScheduledActionUseCase } from "./ExecuteScheduledActionUseCase.js";
3
3
  import { ScheduledActionHandlerComposite } from "./ScheduledActionHandlerComposite.js";
4
-
5
- /**
6
- * ExecuteScheduledAction Feature
7
- *
8
- * Provides the ability to execute a scheduled action when triggered by EventBridge.
9
- * Finds the appropriate handler and executes it, then cleans up the schedule entry.
10
- */
11
- export const ExecuteScheduledActionFeature = createFeature({
12
- name: "ExecuteScheduledAction",
13
- register(container) {
14
- container.register(ExecuteScheduledActionUseCase);
15
- container.registerComposite(ScheduledActionHandlerComposite);
16
- }
4
+ const ExecuteScheduledActionFeature = createFeature({
5
+ name: "ExecuteScheduledAction",
6
+ register (container) {
7
+ container.register(ExecuteScheduledActionUseCase);
8
+ container.registerComposite(ScheduledActionHandlerComposite);
9
+ }
17
10
  });
11
+ export { ExecuteScheduledActionFeature };
18
12
 
19
13
  //# sourceMappingURL=feature.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createFeature","ExecuteScheduledActionUseCase","ScheduledActionHandlerComposite","ExecuteScheduledActionFeature","name","register","container","registerComposite"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ExecuteScheduledActionUseCase } from \"./ExecuteScheduledActionUseCase.js\";\nimport { ScheduledActionHandlerComposite } from \"~/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.js\";\n\n/**\n * ExecuteScheduledAction Feature\n *\n * Provides the ability to execute a scheduled action when triggered by EventBridge.\n * Finds the appropriate handler and executes it, then cleans up the schedule entry.\n */\nexport const ExecuteScheduledActionFeature = createFeature({\n name: \"ExecuteScheduledAction\",\n register(container) {\n container.register(ExecuteScheduledActionUseCase);\n container.registerComposite(ScheduledActionHandlerComposite);\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,6BAA6B;AACtC,SAASC,+BAA+B;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,6BAA6B,GAAGH,aAAa,CAAC;EACvDI,IAAI,EAAE,wBAAwB;EAC9BC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACJ,6BAA6B,CAAC;IACjDK,SAAS,CAACC,iBAAiB,CAACL,+BAA+B,CAAC;EAChE;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/ExecuteScheduledAction/feature.js","sources":["../../../src/features/ExecuteScheduledAction/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ExecuteScheduledActionUseCase } from \"./ExecuteScheduledActionUseCase.js\";\nimport { ScheduledActionHandlerComposite } from \"~/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.js\";\n\n/**\n * ExecuteScheduledAction Feature\n *\n * Provides the ability to execute a scheduled action when the scheduler fires.\n * Finds the appropriate handler and executes it, then cleans up the schedule entry.\n */\nexport const ExecuteScheduledActionFeature = createFeature({\n name: \"ExecuteScheduledAction\",\n register(container) {\n container.register(ExecuteScheduledActionUseCase);\n container.registerComposite(ScheduledActionHandlerComposite);\n }\n});\n"],"names":["ExecuteScheduledActionFeature","createFeature","container","ExecuteScheduledActionUseCase","ScheduledActionHandlerComposite"],"mappings":";;;AAUO,MAAMA,gCAAgCC,cAAc;IACvD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,iBAAiB,CAACE;IAChC;AACJ"}
@@ -1,3 +1 @@
1
1
  export * from "./abstractions.js";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -1,22 +1,18 @@
1
1
  import { Result } from "@webiny/feature/api";
2
2
  import { GetScheduledActionUseCase as UseCaseAbstraction } from "./abstractions.js";
3
3
  import type { IScheduledAction } from "../../shared/abstractions.js";
4
- import { ScheduledActionModel } from "../../shared/abstractions.js";
4
+ import { ScheduledActionModelProvider } from "../../shared/abstractions.js";
5
5
  import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById/index.js";
6
6
  import type { GenericRecord } from "@webiny/api/types.js";
7
- /**
8
- * Retrieves a scheduled action by its ID
9
- *
10
- * Flow:
11
- * 1. Fetch schedule entry from CMS storage by ID
12
- * 2. Return null if not found
13
- * 3. Transform CMS entry to IScheduledAction format
14
- */
7
+ import { SchedulerPermissionsResolver } from "../../features/permissions/abstractions.js";
8
+ import { IdentityContext } from "@webiny/api-core/exports/api/security.js";
15
9
  declare class GetScheduledActionUseCaseImpl implements UseCaseAbstraction.Interface {
16
10
  private getEntryByIdUseCase;
17
- private model;
18
- constructor(getEntryByIdUseCase: GetEntryByIdUseCase.Interface, model: ScheduledActionModel.Interface);
19
- execute<T extends GenericRecord>(id: string): Promise<Result<IScheduledAction<T>, UseCaseAbstraction.Error>>;
11
+ private modelProvider;
12
+ private permissionsResolver;
13
+ private identityContext;
14
+ constructor(getEntryByIdUseCase: GetEntryByIdUseCase.Interface, modelProvider: ScheduledActionModelProvider.Interface, permissionsResolver: SchedulerPermissionsResolver.Interface, identityContext: IdentityContext.Interface);
15
+ execute<T extends GenericRecord>(params: UseCaseAbstraction.Params): Promise<Result<IScheduledAction<T>, UseCaseAbstraction.Error>>;
20
16
  }
21
17
  export declare const GetScheduledActionUseCase: typeof GetScheduledActionUseCaseImpl & {
22
18
  __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetScheduledActionUseCase>;
@@ -1,49 +1,53 @@
1
1
  import { Result } from "@webiny/feature/api";
2
- import { GetScheduledActionUseCase as UseCaseAbstraction } from "./abstractions.js";
3
- import { ScheduledActionModel } from "../../shared/abstractions.js";
4
- import { ScheduledActionNotFoundError, ScheduledActionPersistenceError } from "../../domain/errors.js";
2
+ import { GetScheduledActionUseCase } from "./abstractions.js";
3
+ import { ScheduledActionModelProvider } from "../../shared/abstractions.js";
4
+ import { NotAuthorizedError, ScheduledActionNotFoundError, ScheduledActionPersistenceError } from "../../domain/errors.js";
5
5
  import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById/index.js";
6
6
  import { ScheduledActionIdWithVersion } from "../../domain/ScheduledActionIdWithVersion.js";
7
- /**
8
- * Retrieves a scheduled action by its ID
9
- *
10
- * Flow:
11
- * 1. Fetch schedule entry from CMS storage by ID
12
- * 2. Return null if not found
13
- * 3. Transform CMS entry to IScheduledAction format
14
- */
7
+ import { SchedulerPermissionsResolver } from "../permissions/abstractions.js";
8
+ import { IdentityContext } from "@webiny/api-core/exports/api/security.js";
9
+ import { ScheduledActionMapper } from "../../domain/ScheduledActionMapper.js";
15
10
  class GetScheduledActionUseCaseImpl {
16
- constructor(getEntryByIdUseCase, model) {
17
- this.getEntryByIdUseCase = getEntryByIdUseCase;
18
- this.model = model;
19
- }
20
- async execute(id) {
21
- // Get entry from CMS
22
- const scheduleId = ScheduledActionIdWithVersion.from(id);
23
- const entryResult = await this.getEntryByIdUseCase.execute(this.model, scheduleId);
24
- if (entryResult.isFail()) {
25
- if (entryResult.error.code === "Cms/Entry/NotFound") {
26
- return Result.fail(new ScheduledActionNotFoundError(scheduleId));
27
- }
28
- return Result.fail(new ScheduledActionPersistenceError(entryResult.error));
11
+ constructor(getEntryByIdUseCase, modelProvider, permissionsResolver, identityContext){
12
+ this.getEntryByIdUseCase = getEntryByIdUseCase;
13
+ this.modelProvider = modelProvider;
14
+ this.permissionsResolver = permissionsResolver;
15
+ this.identityContext = identityContext;
16
+ }
17
+ async execute(params) {
18
+ const { id, namespace } = params;
19
+ const permissions = this.permissionsResolver.forNamespace(namespace);
20
+ if (!await permissions.canRead({
21
+ namespace
22
+ })) return Result.fail(new NotAuthorizedError());
23
+ const model = await this.modelProvider.get();
24
+ const scheduleId = ScheduledActionIdWithVersion.from(id);
25
+ const entryResult = await this.getEntryByIdUseCase.execute(model, scheduleId);
26
+ if (entryResult.isFail()) {
27
+ if ("Cms/Entry/NotFound" === entryResult.error.code) return Result.fail(new ScheduledActionNotFoundError(scheduleId));
28
+ return Result.fail(new ScheduledActionPersistenceError(entryResult.error));
29
+ }
30
+ const ownRecordsOnly = await permissions.onlyOwnRecords({
31
+ namespace
32
+ });
33
+ if (ownRecordsOnly) {
34
+ if (entryResult.value.createdBy.id !== this.identityContext.getIdentity().id) return Result.fail(new NotAuthorizedError());
35
+ }
36
+ const entry = entryResult.value;
37
+ if (entry.values.namespace !== namespace) return Result.fail(new ScheduledActionNotFoundError(scheduleId));
38
+ const action = ScheduledActionMapper.toAction(entry);
39
+ return Result.ok(action);
29
40
  }
30
- const entry = entryResult.value;
31
- return Result.ok({
32
- id: entry.entryId,
33
- namespace: entry.values.namespace,
34
- actionType: entry.values.actionType,
35
- targetId: entry.values.targetId,
36
- scheduledBy: entry.values.scheduledBy,
37
- scheduledFor: entry.values.scheduledFor,
38
- payload: entry.values.payload,
39
- title: entry.values.title,
40
- error: entry.values.error
41
- });
42
- }
43
41
  }
44
- export const GetScheduledActionUseCase = UseCaseAbstraction.createImplementation({
45
- implementation: GetScheduledActionUseCaseImpl,
46
- dependencies: [GetEntryByIdUseCase, ScheduledActionModel]
42
+ const GetScheduledActionUseCase_GetScheduledActionUseCase = GetScheduledActionUseCase.createImplementation({
43
+ implementation: GetScheduledActionUseCaseImpl,
44
+ dependencies: [
45
+ GetEntryByIdUseCase,
46
+ ScheduledActionModelProvider,
47
+ SchedulerPermissionsResolver,
48
+ IdentityContext
49
+ ]
47
50
  });
51
+ export { GetScheduledActionUseCase_GetScheduledActionUseCase as GetScheduledActionUseCase };
48
52
 
49
53
  //# sourceMappingURL=GetScheduledActionUseCase.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Result","GetScheduledActionUseCase","UseCaseAbstraction","ScheduledActionModel","ScheduledActionNotFoundError","ScheduledActionPersistenceError","GetEntryByIdUseCase","ScheduledActionIdWithVersion","GetScheduledActionUseCaseImpl","constructor","getEntryByIdUseCase","model","execute","id","scheduleId","from","entryResult","isFail","error","code","fail","entry","value","ok","entryId","namespace","values","actionType","targetId","scheduledBy","scheduledFor","payload","title","createImplementation","implementation","dependencies"],"sources":["GetScheduledActionUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetScheduledActionUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport type { IScheduledAction } from \"~/shared/abstractions.js\";\nimport { ScheduledActionModel } from \"~/shared/abstractions.js\";\nimport { ScheduledActionNotFoundError, ScheduledActionPersistenceError } from \"~/domain/errors.js\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById/index.js\";\nimport { ScheduledActionIdWithVersion } from \"~/domain/ScheduledActionIdWithVersion.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\n/**\n * Retrieves a scheduled action by its ID\n *\n * Flow:\n * 1. Fetch schedule entry from CMS storage by ID\n * 2. Return null if not found\n * 3. Transform CMS entry to IScheduledAction format\n */\nclass GetScheduledActionUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getEntryByIdUseCase: GetEntryByIdUseCase.Interface,\n private model: ScheduledActionModel.Interface\n ) {}\n\n async execute<T extends GenericRecord>(\n id: string\n ): Promise<Result<IScheduledAction<T>, UseCaseAbstraction.Error>> {\n // Get entry from CMS\n const scheduleId = ScheduledActionIdWithVersion.from(id);\n const entryResult = await this.getEntryByIdUseCase.execute<IScheduledAction<T>>(\n this.model,\n scheduleId\n );\n\n if (entryResult.isFail()) {\n if (entryResult.error.code === \"Cms/Entry/NotFound\") {\n return Result.fail(new ScheduledActionNotFoundError(scheduleId));\n }\n\n return Result.fail(new ScheduledActionPersistenceError(entryResult.error));\n }\n\n const entry = entryResult.value;\n\n return Result.ok({\n id: entry.entryId,\n namespace: entry.values.namespace,\n actionType: entry.values.actionType,\n targetId: entry.values.targetId,\n scheduledBy: entry.values.scheduledBy,\n scheduledFor: entry.values.scheduledFor,\n payload: entry.values.payload,\n title: entry.values.title,\n error: entry.values.error\n });\n }\n}\n\nexport const GetScheduledActionUseCase = UseCaseAbstraction.createImplementation({\n implementation: GetScheduledActionUseCaseImpl,\n dependencies: [GetEntryByIdUseCase, ScheduledActionModel]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,yBAAyB,IAAIC,kBAAkB;AAExD,SAASC,oBAAoB;AAC7B,SAASC,4BAA4B,EAAEC,+BAA+B;AACtE,SAASC,mBAAmB,QAAQ,sEAAsE;AAC1G,SAASC,4BAA4B;AAGrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,6BAA6B,CAAyC;EACxEC,WAAWA,CACCC,mBAAkD,EAClDC,KAAqC,EAC/C;IAAA,KAFUD,mBAAkD,GAAlDA,mBAAkD;IAAA,KAClDC,KAAqC,GAArCA,KAAqC;EAC9C;EAEH,MAAMC,OAAOA,CACTC,EAAU,EACoD;IAC9D;IACA,MAAMC,UAAU,GAAGP,4BAA4B,CAACQ,IAAI,CAACF,EAAE,CAAC;IACxD,MAAMG,WAAW,GAAG,MAAM,IAAI,CAACN,mBAAmB,CAACE,OAAO,CACtD,IAAI,CAACD,KAAK,EACVG,UACJ,CAAC;IAED,IAAIE,WAAW,CAACC,MAAM,CAAC,CAAC,EAAE;MACtB,IAAID,WAAW,CAACE,KAAK,CAACC,IAAI,KAAK,oBAAoB,EAAE;QACjD,OAAOnB,MAAM,CAACoB,IAAI,CAAC,IAAIhB,4BAA4B,CAACU,UAAU,CAAC,CAAC;MACpE;MAEA,OAAOd,MAAM,CAACoB,IAAI,CAAC,IAAIf,+BAA+B,CAACW,WAAW,CAACE,KAAK,CAAC,CAAC;IAC9E;IAEA,MAAMG,KAAK,GAAGL,WAAW,CAACM,KAAK;IAE/B,OAAOtB,MAAM,CAACuB,EAAE,CAAC;MACbV,EAAE,EAAEQ,KAAK,CAACG,OAAO;MACjBC,SAAS,EAAEJ,KAAK,CAACK,MAAM,CAACD,SAAS;MACjCE,UAAU,EAAEN,KAAK,CAACK,MAAM,CAACC,UAAU;MACnCC,QAAQ,EAAEP,KAAK,CAACK,MAAM,CAACE,QAAQ;MAC/BC,WAAW,EAAER,KAAK,CAACK,MAAM,CAACG,WAAW;MACrCC,YAAY,EAAET,KAAK,CAACK,MAAM,CAACI,YAAY;MACvCC,OAAO,EAAEV,KAAK,CAACK,MAAM,CAACK,OAAO;MAC7BC,KAAK,EAAEX,KAAK,CAACK,MAAM,CAACM,KAAK;MACzBd,KAAK,EAAEG,KAAK,CAACK,MAAM,CAACR;IACxB,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMjB,yBAAyB,GAAGC,kBAAkB,CAAC+B,oBAAoB,CAAC;EAC7EC,cAAc,EAAE1B,6BAA6B;EAC7C2B,YAAY,EAAE,CAAC7B,mBAAmB,EAAEH,oBAAoB;AAC5D,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/GetScheduledAction/GetScheduledActionUseCase.js","sources":["../../../src/features/GetScheduledAction/GetScheduledActionUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetScheduledActionUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport type { IScheduledAction, IScheduledActionEntryValues } from \"~/shared/abstractions.js\";\nimport { ScheduledActionModelProvider } from \"~/shared/abstractions.js\";\nimport {\n NotAuthorizedError,\n ScheduledActionNotFoundError,\n ScheduledActionPersistenceError\n} from \"~/domain/errors.js\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById/index.js\";\nimport { ScheduledActionIdWithVersion } from \"~/domain/ScheduledActionIdWithVersion.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { SchedulerPermissionsResolver } from \"~/features/permissions/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/exports/api/security.js\";\nimport { ScheduledActionMapper } from \"~/domain/ScheduledActionMapper.js\";\n\nclass GetScheduledActionUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getEntryByIdUseCase: GetEntryByIdUseCase.Interface,\n private modelProvider: ScheduledActionModelProvider.Interface,\n private permissionsResolver: SchedulerPermissionsResolver.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute<T extends GenericRecord>(\n params: UseCaseAbstraction.Params\n ): Promise<Result<IScheduledAction<T>, UseCaseAbstraction.Error>> {\n const { id, namespace } = params;\n const permissions = this.permissionsResolver.forNamespace(namespace);\n if (!(await permissions.canRead({ namespace }))) {\n return Result.fail(new NotAuthorizedError());\n }\n const model = await this.modelProvider.get();\n // Get entry from CMS\n const scheduleId = ScheduledActionIdWithVersion.from(id);\n const entryResult = await this.getEntryByIdUseCase.execute<IScheduledActionEntryValues<T>>(\n model,\n scheduleId\n );\n\n if (entryResult.isFail()) {\n if (entryResult.error.code === \"Cms/Entry/NotFound\") {\n return Result.fail(new ScheduledActionNotFoundError(scheduleId));\n }\n\n return Result.fail(new ScheduledActionPersistenceError(entryResult.error));\n }\n\n const ownRecordsOnly = await permissions.onlyOwnRecords({ namespace });\n if (ownRecordsOnly) {\n if (entryResult.value.createdBy.id !== this.identityContext.getIdentity().id) {\n return Result.fail(new NotAuthorizedError());\n }\n }\n\n const entry = entryResult.value;\n if (entry.values.namespace !== namespace) {\n return Result.fail(new ScheduledActionNotFoundError(scheduleId));\n }\n const action = ScheduledActionMapper.toAction<T>(entry);\n\n return Result.ok(action);\n }\n}\n\nexport const GetScheduledActionUseCase = UseCaseAbstraction.createImplementation({\n implementation: GetScheduledActionUseCaseImpl,\n dependencies: [\n GetEntryByIdUseCase,\n ScheduledActionModelProvider,\n SchedulerPermissionsResolver,\n IdentityContext\n ]\n});\n"],"names":["GetScheduledActionUseCaseImpl","getEntryByIdUseCase","modelProvider","permissionsResolver","identityContext","params","id","namespace","permissions","Result","NotAuthorizedError","model","scheduleId","ScheduledActionIdWithVersion","entryResult","ScheduledActionNotFoundError","ScheduledActionPersistenceError","ownRecordsOnly","entry","action","ScheduledActionMapper","GetScheduledActionUseCase","UseCaseAbstraction","GetEntryByIdUseCase","ScheduledActionModelProvider","SchedulerPermissionsResolver","IdentityContext"],"mappings":";;;;;;;;;AAgBA,MAAMA;IACF,YACYC,mBAAkD,EAClDC,aAAqD,EACrDC,mBAA2D,EAC3DC,eAA0C,CACpD;aAJUH,mBAAmB,GAAnBA;aACAC,aAAa,GAAbA;aACAC,mBAAmB,GAAnBA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAM,QACFC,MAAiC,EAC6B;QAC9D,MAAM,EAAEC,EAAE,EAAEC,SAAS,EAAE,GAAGF;QAC1B,MAAMG,cAAc,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAACD;QAC1D,IAAI,CAAE,MAAMC,YAAY,OAAO,CAAC;YAAED;QAAU,IACxC,OAAOE,OAAO,IAAI,CAAC,IAAIC;QAE3B,MAAMC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG;QAE1C,MAAMC,aAAaC,6BAA6B,IAAI,CAACP;QACrD,MAAMQ,cAAc,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CACtDH,OACAC;QAGJ,IAAIE,YAAY,MAAM,IAAI;YACtB,IAAIA,AAA2B,yBAA3BA,YAAY,KAAK,CAAC,IAAI,EACtB,OAAOL,OAAO,IAAI,CAAC,IAAIM,6BAA6BH;YAGxD,OAAOH,OAAO,IAAI,CAAC,IAAIO,gCAAgCF,YAAY,KAAK;QAC5E;QAEA,MAAMG,iBAAiB,MAAMT,YAAY,cAAc,CAAC;YAAED;QAAU;QACpE,IAAIU,gBACA;YAAA,IAAIH,YAAY,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,IAAI,CAAC,eAAe,CAAC,WAAW,GAAG,EAAE,EACxE,OAAOL,OAAO,IAAI,CAAC,IAAIC;QAC3B;QAGJ,MAAMQ,QAAQJ,YAAY,KAAK;QAC/B,IAAII,MAAM,MAAM,CAAC,SAAS,KAAKX,WAC3B,OAAOE,OAAO,IAAI,CAAC,IAAIM,6BAA6BH;QAExD,MAAMO,SAASC,sBAAsB,QAAQ,CAAIF;QAEjD,OAAOT,OAAO,EAAE,CAACU;IACrB;AACJ;AAEO,MAAME,sDAA4BC,0BAAAA,oBAAuC,CAAC;IAC7E,gBAAgBtB;IAChB,cAAc;QACVuB;QACAC;QACAC;QACAC;KACH;AACL"}
@@ -1,6 +1,6 @@
1
1
  import { Result } from "@webiny/feature/api";
2
2
  import type { IScheduledAction } from "../../shared/abstractions.js";
3
- import { ScheduledActionNotFoundError, ScheduledActionPersistenceError } from "../../domain/errors.js";
3
+ import { ScheduledActionNotFoundError, ScheduledActionPersistenceError, NotAuthorizedError } from "../../domain/errors.js";
4
4
  import type { GenericRecord } from "@webiny/api/types.js";
5
5
  /**
6
6
  * GetScheduledActionUseCase - Retrieve a scheduled action by ID
@@ -13,14 +13,21 @@ import type { GenericRecord } from "@webiny/api/types.js";
13
13
  export interface IGetScheduledActionErrors {
14
14
  persistence: ScheduledActionPersistenceError;
15
15
  notFound: ScheduledActionNotFoundError;
16
+ unauthorized: NotAuthorizedError;
16
17
  }
17
18
  type GetScheduledActionError = IGetScheduledActionErrors[keyof IGetScheduledActionErrors];
19
+ export interface IGetScheduledActionUseCaseParams {
20
+ namespace: string;
21
+ id: string;
22
+ }
18
23
  export interface IGetScheduledActionUseCase {
19
- execute<T extends GenericRecord>(scheduleId: string): Promise<Result<IScheduledAction<T>, GetScheduledActionError>>;
24
+ execute<T extends GenericRecord>(params: IGetScheduledActionUseCaseParams): Promise<Result<IScheduledAction<T>, GetScheduledActionError>>;
20
25
  }
26
+ /** Retrieve a scheduled action. */
21
27
  export declare const GetScheduledActionUseCase: import("@webiny/di").Abstraction<IGetScheduledActionUseCase>;
22
28
  export declare namespace GetScheduledActionUseCase {
23
29
  type Interface = IGetScheduledActionUseCase;
24
30
  type Error = GetScheduledActionError;
31
+ type Params = IGetScheduledActionUseCaseParams;
25
32
  }
26
33
  export {};
@@ -1,14 +1,5 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
-
3
- /**
4
- * GetScheduledActionUseCase - Retrieve a scheduled action by ID
5
- *
6
- * Used to check if a schedule exists (for reschedule logic) and to retrieve
7
- * schedule details for display/management purposes.
8
- *
9
- * Returns null value (Result.ok(null)) if schedule not found.
10
- */
11
-
12
- export const GetScheduledActionUseCase = createAbstraction("GetScheduledActionUseCase");
2
+ const GetScheduledActionUseCase = createAbstraction("Scheduler/GetScheduledActionUseCase");
3
+ export { GetScheduledActionUseCase };
13
4
 
14
5
  //# sourceMappingURL=abstractions.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","GetScheduledActionUseCase"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { IScheduledAction } from \"~/shared/abstractions.js\";\nimport { ScheduledActionNotFoundError, ScheduledActionPersistenceError } from \"~/domain/errors.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\n/**\n * GetScheduledActionUseCase - Retrieve a scheduled action by ID\n *\n * Used to check if a schedule exists (for reschedule logic) and to retrieve\n * schedule details for display/management purposes.\n *\n * Returns null value (Result.ok(null)) if schedule not found.\n */\n\nexport interface IGetScheduledActionErrors {\n persistence: ScheduledActionPersistenceError;\n notFound: ScheduledActionNotFoundError;\n}\n\ntype GetScheduledActionError = IGetScheduledActionErrors[keyof IGetScheduledActionErrors];\n\nexport interface IGetScheduledActionUseCase {\n execute<T extends GenericRecord>(\n scheduleId: string\n ): Promise<Result<IScheduledAction<T>, GetScheduledActionError>>;\n}\n\nexport const GetScheduledActionUseCase = createAbstraction<IGetScheduledActionUseCase>(\n \"GetScheduledActionUseCase\"\n);\n\nexport namespace GetScheduledActionUseCase {\n export type Interface = IGetScheduledActionUseCase;\n export type Error = GetScheduledActionError;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAMvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA,OAAO,MAAMC,yBAAyB,GAAGD,iBAAiB,CACtD,2BACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/GetScheduledAction/abstractions.js","sources":["../../../src/features/GetScheduledAction/abstractions.ts"],"sourcesContent":["import { createAbstraction, Result } from \"@webiny/feature/api\";\nimport type { IScheduledAction } from \"~/shared/abstractions.js\";\nimport {\n ScheduledActionNotFoundError,\n ScheduledActionPersistenceError,\n NotAuthorizedError\n} from \"~/domain/errors.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\n/**\n * GetScheduledActionUseCase - Retrieve a scheduled action by ID\n *\n * Used to check if a schedule exists (for reschedule logic) and to retrieve\n * schedule details for display/management purposes.\n *\n * Returns null value (Result.ok(null)) if schedule not found.\n */\n\nexport interface IGetScheduledActionErrors {\n persistence: ScheduledActionPersistenceError;\n notFound: ScheduledActionNotFoundError;\n unauthorized: NotAuthorizedError;\n}\n\ntype GetScheduledActionError = IGetScheduledActionErrors[keyof IGetScheduledActionErrors];\n\nexport interface IGetScheduledActionUseCaseParams {\n namespace: string;\n id: string;\n}\n\nexport interface IGetScheduledActionUseCase {\n execute<T extends GenericRecord>(\n params: IGetScheduledActionUseCaseParams\n ): Promise<Result<IScheduledAction<T>, GetScheduledActionError>>;\n}\n\n/** Retrieve a scheduled action. */\nexport const GetScheduledActionUseCase = createAbstraction<IGetScheduledActionUseCase>(\n \"Scheduler/GetScheduledActionUseCase\"\n);\n\nexport namespace GetScheduledActionUseCase {\n export type Interface = IGetScheduledActionUseCase;\n export type Error = GetScheduledActionError;\n export type Params = IGetScheduledActionUseCaseParams;\n}\n"],"names":["GetScheduledActionUseCase","createAbstraction"],"mappings":";AAsCO,MAAMA,4BAA4BC,kBACrC"}
@@ -4,4 +4,7 @@
4
4
  * Provides the ability to retrieve a scheduled action by ID.
5
5
  * Used for checking if schedules exist and displaying schedule details.
6
6
  */
7
- export declare const GetScheduledActionFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
7
+ export declare const GetScheduledActionFeature: {
8
+ name: string;
9
+ register(container: import("@webiny/di").Container): void;
10
+ };
@@ -1,17 +1,11 @@
1
1
  import { createFeature } from "@webiny/feature/api";
2
2
  import { GetScheduledActionUseCase } from "./GetScheduledActionUseCase.js";
3
-
4
- /**
5
- * GetScheduledAction Feature
6
- *
7
- * Provides the ability to retrieve a scheduled action by ID.
8
- * Used for checking if schedules exist and displaying schedule details.
9
- */
10
- export const GetScheduledActionFeature = createFeature({
11
- name: "GetScheduledAction",
12
- register(container) {
13
- container.register(GetScheduledActionUseCase);
14
- }
3
+ const GetScheduledActionFeature = createFeature({
4
+ name: "GetScheduledAction",
5
+ register (container) {
6
+ container.register(GetScheduledActionUseCase);
7
+ }
15
8
  });
9
+ export { GetScheduledActionFeature };
16
10
 
17
11
  //# sourceMappingURL=feature.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createFeature","GetScheduledActionUseCase","GetScheduledActionFeature","name","register","container"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { GetScheduledActionUseCase } from \"./GetScheduledActionUseCase.js\";\n\n/**\n * GetScheduledAction Feature\n *\n * Provides the ability to retrieve a scheduled action by ID.\n * Used for checking if schedules exist and displaying schedule details.\n */\nexport const GetScheduledActionFeature = createFeature({\n name: \"GetScheduledAction\",\n register(container) {\n container.register(GetScheduledActionUseCase);\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,yBAAyB;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,yBAAyB,GAAGF,aAAa,CAAC;EACnDG,IAAI,EAAE,oBAAoB;EAC1BC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,yBAAyB,CAAC;EACjD;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/GetScheduledAction/feature.js","sources":["../../../src/features/GetScheduledAction/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { GetScheduledActionUseCase } from \"./GetScheduledActionUseCase.js\";\n\n/**\n * GetScheduledAction Feature\n *\n * Provides the ability to retrieve a scheduled action by ID.\n * Used for checking if schedules exist and displaying schedule details.\n */\nexport const GetScheduledActionFeature = createFeature({\n name: \"GetScheduledAction\",\n register(container) {\n container.register(GetScheduledActionUseCase);\n }\n});\n"],"names":["GetScheduledActionFeature","createFeature","container","GetScheduledActionUseCase"],"mappings":";;AASO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
@@ -1,3 +1 @@
1
1
  export * from "./abstractions.js";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,21 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { GetTargetScheduledActionUseCase as UseCaseAbstraction } from "./abstractions.js";
3
+ import type { IScheduledAction } from "../../shared/abstractions.js";
4
+ import { ScheduledActionModelProvider } from "../../shared/abstractions.js";
5
+ import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById/index.js";
6
+ import type { GenericRecord } from "@webiny/api/types.js";
7
+ import { SchedulerPermissionsResolver } from "../../features/permissions/abstractions.js";
8
+ import { IdentityContext } from "@webiny/api-core/exports/api/security.js";
9
+ declare class GetTargetScheduledActionUseCaseImpl implements UseCaseAbstraction.Interface {
10
+ private getEntryByIdUseCase;
11
+ private modelProvider;
12
+ private permissionsResolver;
13
+ private identityContext;
14
+ constructor(getEntryByIdUseCase: GetEntryByIdUseCase.Interface, modelProvider: ScheduledActionModelProvider.Interface, permissionsResolver: SchedulerPermissionsResolver.Interface, identityContext: IdentityContext.Interface);
15
+ execute<T extends GenericRecord>(params: UseCaseAbstraction.Params): Promise<Result<IScheduledAction<T>, UseCaseAbstraction.Error>>;
16
+ private getRecord;
17
+ }
18
+ export declare const GetTargetScheduledActionUseCase: typeof GetTargetScheduledActionUseCaseImpl & {
19
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetTargetScheduledActionUseCase>;
20
+ };
21
+ export {};