@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
package/index.d.ts CHANGED
@@ -1,10 +1,5 @@
1
- export { SchedulerService, ScheduledActionModel, ScheduledActionHandler } from "./shared/abstractions.js";
1
+ export { SchedulerService, ScheduledActionHandler } from "./shared/abstractions.js";
2
2
  export type { IScheduledAction } from "./shared/abstractions.js";
3
3
  export { ScheduledActionId } from "./domain/ScheduledActionId.js";
4
- export { createScheduler } from "./createScheduler.js";
5
- export * from "./features/ScheduleAction/index.js";
6
- export * from "./features/GetScheduledAction/index.js";
7
- export * from "./features/ListScheduledActions/index.js";
8
- export * from "./features/CancelScheduledAction/index.js";
9
- export * from "./features/ExecuteScheduledAction/index.js";
10
- export * from "./features/RunAction/index.js";
4
+ export { SchedulerFeature } from "./SchedulerFeature.js";
5
+ export { ScheduledActionLambdaHandler } from "./ScheduledActionLambdaHandler.js";
package/index.js CHANGED
@@ -1,13 +1,4 @@
1
- export { SchedulerService, ScheduledActionModel, ScheduledActionHandler } from "./shared/abstractions.js";
1
+ export { ScheduledActionHandler, SchedulerService } from "./shared/abstractions.js";
2
2
  export { ScheduledActionId } from "./domain/ScheduledActionId.js";
3
- export { createScheduler } from "./createScheduler.js";
4
-
5
- // Feature abstractions (for use case dependencies)
6
- export * from "./features/ScheduleAction/index.js";
7
- export * from "./features/GetScheduledAction/index.js";
8
- export * from "./features/ListScheduledActions/index.js";
9
- export * from "./features/CancelScheduledAction/index.js";
10
- export * from "./features/ExecuteScheduledAction/index.js";
11
- export * from "./features/RunAction/index.js";
12
-
13
- //# sourceMappingURL=index.js.map
3
+ export { SchedulerFeature } from "./SchedulerFeature.js";
4
+ export { ScheduledActionLambdaHandler } from "./ScheduledActionLambdaHandler.js";
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@webiny/api-scheduler",
3
- "version": "0.0.0-unstable.df7a8bb475",
3
+ "version": "0.0.0-unstable.e1999482d0",
4
4
  "type": "module",
5
- "main": "index.js",
5
+ "exports": {
6
+ ".": "./index.js",
7
+ "./*": "./*"
8
+ },
6
9
  "repository": {
7
10
  "type": "git",
8
11
  "url": "https://github.com/webiny/webiny-js.git",
@@ -14,42 +17,27 @@
14
17
  "author": "Webiny Ltd",
15
18
  "description": "A generic action scheduler.",
16
19
  "license": "MIT",
17
- "exports": {
18
- "./features/ScheduleAction": "./features/ScheduleAction/index.js",
19
- "./features/GetScheduledAction": "./features/GetScheduledAction/index.js",
20
- "./features/ListScheduledActions": "./features/ListScheduledActions/index.js",
21
- "./features/CancelScheduledAction": "./features/CancelScheduledAction/index.js",
22
- "./features/ExecuteScheduledAction": "./features/ExecuteScheduledAction/index.js",
23
- ".": "./index.js"
24
- },
25
20
  "dependencies": {
26
- "@webiny/api": "0.0.0-unstable.df7a8bb475",
27
- "@webiny/api-core": "0.0.0-unstable.df7a8bb475",
28
- "@webiny/api-headless-cms": "0.0.0-unstable.df7a8bb475",
29
- "@webiny/aws-sdk": "0.0.0-unstable.df7a8bb475",
30
- "@webiny/error": "0.0.0-unstable.df7a8bb475",
31
- "@webiny/feature": "0.0.0-unstable.df7a8bb475",
32
- "@webiny/handler-graphql": "0.0.0-unstable.df7a8bb475",
33
- "@webiny/plugins": "0.0.0-unstable.df7a8bb475",
34
- "@webiny/utils": "0.0.0-unstable.df7a8bb475",
35
- "zod": "3.25.76"
21
+ "@webiny/api": "0.0.0-unstable.e1999482d0",
22
+ "@webiny/api-core": "0.0.0-unstable.e1999482d0",
23
+ "@webiny/api-graphql": "0.0.0-unstable.e1999482d0",
24
+ "@webiny/api-headless-cms": "0.0.0-unstable.e1999482d0",
25
+ "@webiny/api-kernel-core": "0.0.0-unstable.e1999482d0",
26
+ "@webiny/feature": "0.0.0-unstable.e1999482d0",
27
+ "@webiny/utils": "0.0.0-unstable.e1999482d0",
28
+ "graphql": "16.15.0"
36
29
  },
37
30
  "devDependencies": {
38
- "@webiny/build-tools": "0.0.0-unstable.df7a8bb475",
39
- "@webiny/db-dynamodb": "0.0.0-unstable.df7a8bb475",
40
- "@webiny/handler": "0.0.0-unstable.df7a8bb475",
41
- "@webiny/handler-aws": "0.0.0-unstable.df7a8bb475",
42
- "@webiny/project-utils": "0.0.0-unstable.df7a8bb475",
43
- "@webiny/wcp": "0.0.0-unstable.df7a8bb475",
44
- "aws-sdk-client-mock": "4.1.0",
45
- "jest-dynalite": "3.6.1",
46
- "rimraf": "6.1.3",
47
- "typescript": "5.9.3",
48
- "vitest": "3.2.4"
31
+ "@webiny/build-tools": "0.0.0-unstable.e1999482d0",
32
+ "rimraf": "6.1.4",
33
+ "typescript": "7.0.2",
34
+ "vitest": "5.1.1"
49
35
  },
50
36
  "publishConfig": {
51
- "access": "public",
52
- "directory": "dist"
37
+ "access": "public"
53
38
  },
54
- "gitHead": "df7a8bb4755a1da047f0af8c56bdb649cc81bf7d"
39
+ "gitHead": "8476da73b653c89cc1474d968baf55c1b0ae0e5f",
40
+ "webiny": {
41
+ "publishFrom": "dist"
42
+ }
55
43
  }
@@ -1,5 +1,7 @@
1
1
  import type { CmsModel } from "@webiny/api-headless-cms/types/model.js";
2
2
  import type { GenericRecord } from "@webiny/api/types.js";
3
+ import type { CmsEntry } from "@webiny/api-headless-cms/types/index.js";
4
+ import type { SCHEDULED_ACTION_PUBLISH, SCHEDULED_ACTION_UNPUBLISH } from "../constants.js";
3
5
  /**
4
6
  * Identity type - represents who scheduled an action
5
7
  */
@@ -8,22 +10,29 @@ export interface Identity {
8
10
  type: string;
9
11
  displayName: string;
10
12
  }
13
+ export type ScheduledActionType = typeof SCHEDULED_ACTION_PUBLISH | typeof SCHEDULED_ACTION_UNPUBLISH;
11
14
  /**
12
15
  * Scheduled Action Record - The data stored for a scheduled action
13
16
  */
14
- export interface IScheduledAction<T extends GenericRecord> {
15
- id: string;
17
+ export interface IScheduledActionEntryValues<T> {
16
18
  namespace: string;
17
- actionType: string;
19
+ actionType: ScheduledActionType;
18
20
  targetId: string;
19
21
  scheduledBy: Identity;
20
22
  scheduledFor: string;
21
- title?: string;
23
+ title: string;
22
24
  payload: T;
23
- error?: string;
25
+ error: string | undefined;
26
+ }
27
+ export interface IScheduledActionEntry<T extends GenericRecord = GenericRecord> extends CmsEntry<IScheduledActionEntryValues<T>> {
28
+ }
29
+ export interface IScheduledAction<T extends GenericRecord = GenericRecord> extends Omit<IScheduledActionEntryValues<T>, "scheduledFor"> {
30
+ id: string;
31
+ tenant: string;
32
+ scheduledFor: Date;
24
33
  }
25
34
  /**
26
- * ScheduledActionHandler - Similar to EventHandler pattern
35
+ * ScheduledActionHandler - Similar to InputHandler pattern
27
36
  *
28
37
  * Each application (CMS, Mailer, etc.) implements handlers for their actions.
29
38
  * This is the ONLY action abstraction needed.
@@ -35,12 +44,13 @@ export interface IScheduledActionHandler {
35
44
  * @param namespace - Resource scope (e.g., "Cms/Entry/Article")
36
45
  * @param actionType - Operation type (e.g., "Publish")
37
46
  */
38
- canHandle(namespace: string, actionType: string): boolean;
47
+ canHandle(namespace: string, actionType: ScheduledActionType): boolean;
39
48
  /**
40
49
  * Executes the scheduled action
41
50
  */
42
51
  handle(action: IScheduledAction<any>): Promise<void>;
43
52
  }
53
+ /** Handle execution of a scheduled action. */
44
54
  export declare const ScheduledActionHandler: import("@webiny/di").Abstraction<IScheduledActionHandler>;
45
55
  export declare namespace ScheduledActionHandler {
46
56
  type Interface = IScheduledActionHandler;
@@ -52,26 +62,52 @@ export declare namespace ScheduledActionHandler {
52
62
  */
53
63
  export interface ISchedulerServiceCreateParams {
54
64
  id: string;
65
+ tenant: string;
66
+ namespace: string;
55
67
  scheduleFor: Date;
56
68
  }
57
69
  export interface ISchedulerServiceUpdateParams {
58
70
  id: string;
71
+ tenant: string;
72
+ namespace: string;
59
73
  scheduleFor: Date;
60
74
  }
75
+ export interface ISchedulerServiceDeleteParams {
76
+ id: string;
77
+ namespace: string;
78
+ tenant: string;
79
+ }
80
+ export interface ISchedulerServiceExistsParams {
81
+ id: string;
82
+ namespace: string;
83
+ tenant: string;
84
+ }
61
85
  export interface ISchedulerService {
62
86
  create(params: ISchedulerServiceCreateParams): Promise<void>;
63
87
  update(params: ISchedulerServiceUpdateParams): Promise<void>;
64
- delete(id: string): Promise<void>;
65
- exists(id: string): Promise<boolean>;
88
+ delete(params: ISchedulerServiceDeleteParams): Promise<void>;
89
+ exists(params: ISchedulerServiceExistsParams): Promise<boolean>;
66
90
  }
91
+ /** Core service for managing scheduled actions. */
67
92
  export declare const SchedulerService: import("@webiny/di").Abstraction<ISchedulerService>;
68
93
  export declare namespace SchedulerService {
69
94
  type Interface = ISchedulerService;
95
+ type CreateParams = ISchedulerServiceCreateParams;
96
+ type UpdateParams = ISchedulerServiceUpdateParams;
97
+ type DeleteParams = ISchedulerServiceDeleteParams;
98
+ type ExistsParams = ISchedulerServiceExistsParams;
70
99
  }
71
100
  /**
72
- * ScheduledActionModel - A CMS model used by the scheduler for persistence.
101
+ * Provides the scheduler's CMS model for the current request's tenant.
102
+ *
103
+ * A provider rather than the model itself: fetching a model is asynchronous and tenant-dependent,
104
+ * and DI resolution is synchronous — so an already-resolved `CmsModel` could only be supplied by a
105
+ * per-request hook running before every consumer. Consumers `await get()` at the point of use.
73
106
  */
74
- export declare const ScheduledActionModel: import("@webiny/di").Abstraction<CmsModel>;
75
- export declare namespace ScheduledActionModel {
76
- type Interface = CmsModel;
107
+ export interface IScheduledActionModelProvider {
108
+ get(): Promise<CmsModel>;
109
+ }
110
+ export declare const ScheduledActionModelProvider: import("@webiny/di").Abstraction<IScheduledActionModelProvider>;
111
+ export declare namespace ScheduledActionModelProvider {
112
+ type Interface = IScheduledActionModelProvider;
77
113
  }
@@ -1,32 +1,7 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
-
3
- /**
4
- * Identity type - represents who scheduled an action
5
- */
6
-
7
- /**
8
- * Scheduled Action Record - The data stored for a scheduled action
9
- */
10
-
11
- /**
12
- * ScheduledActionHandler - Similar to EventHandler pattern
13
- *
14
- * Each application (CMS, Mailer, etc.) implements handlers for their actions.
15
- * This is the ONLY action abstraction needed.
16
- */
17
-
18
- export const ScheduledActionHandler = createAbstraction("ScheduledActionHandler");
19
-
20
- /**
21
- * SchedulerService - Cloud-agnostic scheduler service
22
- *
23
- * Abstracts the underlying scheduling infrastructure (AWS EventBridge, Azure Logic Apps, etc.)
24
- */
25
-
26
- export const SchedulerService = createAbstraction("SchedulerService");
27
- /**
28
- * ScheduledActionModel - A CMS model used by the scheduler for persistence.
29
- */
30
- export const ScheduledActionModel = createAbstraction("ScheduledActionModel");
2
+ const ScheduledActionHandler = createAbstraction("ScheduledActionHandler");
3
+ const SchedulerService = createAbstraction("SchedulerService");
4
+ const ScheduledActionModelProvider = createAbstraction("ScheduledActionModelProvider");
5
+ export { ScheduledActionHandler, ScheduledActionModelProvider, SchedulerService };
31
6
 
32
7
  //# sourceMappingURL=abstractions.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","ScheduledActionHandler","SchedulerService","ScheduledActionModel"],"sources":["abstractions.ts"],"sourcesContent":["import type { CmsModel } from \"@webiny/api-headless-cms/types/model.js\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\n/**\n * Identity type - represents who scheduled an action\n */\nexport interface Identity {\n id: string;\n type: string;\n displayName: string;\n}\n\n/**\n * Scheduled Action Record - The data stored for a scheduled action\n */\nexport interface IScheduledAction<T extends GenericRecord> {\n id: string;\n namespace: string; // Resource scope: \"Cms/Entry/Article\", \"Mailer/Email\"\n actionType: string; // Operation: \"Publish\", \"Unpublish\", \"Send\", \"Delete\"\n targetId: string; // Resource identifier (entry ID, email ID, etc.)\n scheduledBy: Identity;\n scheduledFor: string;\n title?: string;\n payload: T; // Action-specific data\n error?: string; // Error if execution failed\n}\n\n/**\n * ScheduledActionHandler - Similar to EventHandler pattern\n *\n * Each application (CMS, Mailer, etc.) implements handlers for their actions.\n * This is the ONLY action abstraction needed.\n */\nexport interface IScheduledActionHandler {\n /**\n * Determines if this handler can handle the given action\n *\n * @param namespace - Resource scope (e.g., \"Cms/Entry/Article\")\n * @param actionType - Operation type (e.g., \"Publish\")\n */\n canHandle(namespace: string, actionType: string): boolean;\n\n /**\n * Executes the scheduled action\n */\n handle(action: IScheduledAction<any>): Promise<void>;\n}\n\nexport const ScheduledActionHandler =\n createAbstraction<IScheduledActionHandler>(\"ScheduledActionHandler\");\n\nexport namespace ScheduledActionHandler {\n export type Interface = IScheduledActionHandler;\n}\n\n/**\n * SchedulerService - Cloud-agnostic scheduler service\n *\n * Abstracts the underlying scheduling infrastructure (AWS EventBridge, Azure Logic Apps, etc.)\n */\n\nexport interface ISchedulerServiceCreateParams {\n id: string;\n scheduleFor: Date;\n}\nexport interface ISchedulerServiceUpdateParams {\n id: string;\n scheduleFor: Date;\n}\n\nexport interface ISchedulerService {\n create(params: ISchedulerServiceCreateParams): Promise<void>;\n update(params: ISchedulerServiceUpdateParams): Promise<void>;\n delete(id: string): Promise<void>;\n exists(id: string): Promise<boolean>;\n}\n\nexport const SchedulerService = createAbstraction<ISchedulerService>(\"SchedulerService\");\n\nexport namespace SchedulerService {\n export type Interface = ISchedulerService;\n}\n\n/**\n * ScheduledActionModel - A CMS model used by the scheduler for persistence.\n */\nexport const ScheduledActionModel = createAbstraction<CmsModel>(\"ScheduledActionModel\");\n\nexport namespace ScheduledActionModel {\n export type Interface = CmsModel;\n}\n"],"mappings":"AACA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAGvD;AACA;AACA;;AAOA;AACA;AACA;;AAaA;AACA;AACA;AACA;AACA;AACA;;AAgBA,OAAO,MAAMC,sBAAsB,GAC/BD,iBAAiB,CAA0B,wBAAwB,CAAC;;AAMxE;AACA;AACA;AACA;AACA;;AAkBA,OAAO,MAAME,gBAAgB,GAAGF,iBAAiB,CAAoB,kBAAkB,CAAC;AAMxF;AACA;AACA;AACA,OAAO,MAAMG,oBAAoB,GAAGH,iBAAiB,CAAW,sBAAsB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"shared/abstractions.js","sources":["../../src/shared/abstractions.ts"],"sourcesContent":["import type { CmsModel } from \"@webiny/api-headless-cms/types/model.js\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { CmsEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { SCHEDULED_ACTION_PUBLISH, SCHEDULED_ACTION_UNPUBLISH } from \"~/constants.js\";\n\n/**\n * Identity type - represents who scheduled an action\n */\nexport interface Identity {\n id: string;\n type: string;\n displayName: string;\n}\n\nexport type ScheduledActionType =\n | typeof SCHEDULED_ACTION_PUBLISH\n | typeof SCHEDULED_ACTION_UNPUBLISH;\n/**\n * Scheduled Action Record - The data stored for a scheduled action\n */\n\nexport interface IScheduledActionEntryValues<T> {\n namespace: string; // Resource scope: \"Cms/Entry/Article\", \"Mailer/Email\"\n actionType: ScheduledActionType;\n targetId: string; // Resource identifier (entry ID, email ID, etc.)\n scheduledBy: Identity;\n scheduledFor: string;\n title: string;\n payload: T; // Action-specific data\n error: string | undefined; // Error if execution failed\n}\n\nexport interface IScheduledActionEntry<T extends GenericRecord = GenericRecord> extends CmsEntry<\n IScheduledActionEntryValues<T>\n> {}\n\nexport interface IScheduledAction<T extends GenericRecord = GenericRecord> extends Omit<\n IScheduledActionEntryValues<T>,\n \"scheduledFor\"\n> {\n id: string;\n tenant: string;\n scheduledFor: Date;\n}\n\n/**\n * ScheduledActionHandler - Similar to InputHandler pattern\n *\n * Each application (CMS, Mailer, etc.) implements handlers for their actions.\n * This is the ONLY action abstraction needed.\n */\nexport interface IScheduledActionHandler {\n /**\n * Determines if this handler can handle the given action\n *\n * @param namespace - Resource scope (e.g., \"Cms/Entry/Article\")\n * @param actionType - Operation type (e.g., \"Publish\")\n */\n canHandle(namespace: string, actionType: ScheduledActionType): boolean;\n\n /**\n * Executes the scheduled action\n */\n handle(action: IScheduledAction<any>): Promise<void>;\n}\n\n/** Handle execution of a scheduled action. */\nexport const ScheduledActionHandler =\n createAbstraction<IScheduledActionHandler>(\"ScheduledActionHandler\");\n\nexport namespace ScheduledActionHandler {\n export type Interface = IScheduledActionHandler;\n}\n\n/**\n * SchedulerService - Cloud-agnostic scheduler service\n *\n * Abstracts the underlying scheduling infrastructure (AWS EventBridge, Azure Logic Apps, etc.)\n */\n\nexport interface ISchedulerServiceCreateParams {\n id: string;\n tenant: string;\n namespace: string;\n scheduleFor: Date;\n}\nexport interface ISchedulerServiceUpdateParams {\n id: string;\n tenant: string;\n namespace: string;\n scheduleFor: Date;\n}\n\nexport interface ISchedulerServiceDeleteParams {\n id: string;\n namespace: string;\n tenant: string;\n}\n\nexport interface ISchedulerServiceExistsParams {\n id: string;\n namespace: string;\n tenant: string;\n}\n\nexport interface ISchedulerService {\n create(params: ISchedulerServiceCreateParams): Promise<void>;\n update(params: ISchedulerServiceUpdateParams): Promise<void>;\n delete(params: ISchedulerServiceDeleteParams): Promise<void>;\n exists(params: ISchedulerServiceExistsParams): Promise<boolean>;\n}\n\n/** Core service for managing scheduled actions. */\nexport const SchedulerService = createAbstraction<ISchedulerService>(\"SchedulerService\");\n\nexport namespace SchedulerService {\n export type Interface = ISchedulerService;\n export type CreateParams = ISchedulerServiceCreateParams;\n export type UpdateParams = ISchedulerServiceUpdateParams;\n export type DeleteParams = ISchedulerServiceDeleteParams;\n export type ExistsParams = ISchedulerServiceExistsParams;\n}\n\n/**\n * Provides the scheduler's CMS model for the current request's tenant.\n *\n * A provider rather than the model itself: fetching a model is asynchronous and tenant-dependent,\n * and DI resolution is synchronous — so an already-resolved `CmsModel` could only be supplied by a\n * per-request hook running before every consumer. Consumers `await get()` at the point of use.\n */\nexport interface IScheduledActionModelProvider {\n get(): Promise<CmsModel>;\n}\n\nexport const ScheduledActionModelProvider = createAbstraction<IScheduledActionModelProvider>(\n \"ScheduledActionModelProvider\"\n);\n\nexport namespace ScheduledActionModelProvider {\n export type Interface = IScheduledActionModelProvider;\n}\n"],"names":["ScheduledActionHandler","createAbstraction","SchedulerService","ScheduledActionModelProvider"],"mappings":";AAoEO,MAAMA,yBACTC,kBAA2C;AA6CxC,MAAMC,mBAAmBD,kBAAqC;AAqB9D,MAAME,+BAA+BF,kBACxC"}
package/context.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import { ContextPlugin } from "@webiny/api";
2
- import type { SchedulerClient, SchedulerClientConfig } from "@webiny/aws-sdk/client-scheduler/index.js";
3
- import type { CmsContext } from "@webiny/api-headless-cms/types/index.js";
4
- export interface ICreateHeadlessCmsSchedulerContextParams {
5
- getClient(config?: SchedulerClientConfig): Pick<SchedulerClient, "send">;
6
- }
7
- export declare const createSchedulerContext: (params: ICreateHeadlessCmsSchedulerContextParams) => ContextPlugin<CmsContext>;
package/context.js DELETED
@@ -1,41 +0,0 @@
1
- import { ContextPlugin } from "@webiny/api";
2
- import { getManifest } from "./manifest.js";
3
- import { SCHEDULE_MODEL_ID } from "./constants.js";
4
- import { ScheduledActionModel, SchedulerService } from "./shared/abstractions.js";
5
- import { EventBridgeSchedulerService } from "./features/SchedulerService/EventBridgeSchedulerService.js";
6
- import { VoidSchedulerService } from "./features/SchedulerService/VoidSchedulerService.js";
7
- import { SchedulePrivateModel } from "./domain/SchedulePrivateModel.js";
8
- import { SchedulerFeature } from "./features/SchedulerFeature.js";
9
- import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
10
- import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel/index.js";
11
- export const createSchedulerContext = params => {
12
- return new ContextPlugin(async context => {
13
- const tenantContext = context.container.resolve(TenantContext);
14
- const getModel = context.container.resolve(GetModelUseCase);
15
- if (!tenantContext.getTenant()) {
16
- return;
17
- }
18
- const manifest = await getManifest({
19
- client: context.db.driver.getClient()
20
- });
21
- if (manifest.error) {
22
- context.container.registerInstance(SchedulerService, new VoidSchedulerService());
23
- } else {
24
- // TODO: in the future, extract AWS specific implementation into a separate package
25
- context.container.registerInstance(SchedulerService, new EventBridgeSchedulerService(params.getClient, {
26
- lambdaArn: manifest.data.lambdaArn,
27
- roleArn: manifest.data.roleArn
28
- }));
29
- }
30
- context.container.register(SchedulePrivateModel);
31
- await context.security.withoutAuthorization(async () => {
32
- const schedulerModel = await getModel.execute(SCHEDULE_MODEL_ID);
33
- context.container.registerInstance(ScheduledActionModel, schedulerModel.value);
34
- });
35
-
36
- // Register all features
37
- SchedulerFeature.register(context.container);
38
- });
39
- };
40
-
41
- //# sourceMappingURL=context.js.map
package/context.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"names":["ContextPlugin","getManifest","SCHEDULE_MODEL_ID","ScheduledActionModel","SchedulerService","EventBridgeSchedulerService","VoidSchedulerService","SchedulePrivateModel","SchedulerFeature","TenantContext","GetModelUseCase","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;AAC/C,SAASC,2BAA2B;AACpC,SAASC,oBAAoB;AAC7B,SAASC,oBAAoB;AAC7B,SAASC,gBAAgB;AACzB,SAASC,aAAa,QAAQ,0DAA0D;AACxF,SAASC,eAAe,QAAQ,kEAAkE;AAMlG,OAAO,MAAMC,sBAAsB,GAAIC,MAAgD,IAAK;EACxF,OAAO,IAAIZ,aAAa,CAAa,MAAMa,OAAO,IAAI;IAClD,MAAMC,aAAa,GAAGD,OAAO,CAACE,SAAS,CAACC,OAAO,CAACP,aAAa,CAAC;IAC9D,MAAMQ,QAAQ,GAAGJ,OAAO,CAACE,SAAS,CAACC,OAAO,CAACN,eAAe,CAAC;IAE3D,IAAI,CAACI,aAAa,CAACI,SAAS,CAAC,CAAC,EAAE;MAC5B;IACJ;IAEA,MAAMC,QAAQ,GAAG,MAAMlB,WAAW,CAAC;MAC/BmB,MAAM,EAAEP,OAAO,CAACQ,EAAE,CAACC,MAAM,CAACC,SAAS,CAAC;IACxC,CAAC,CAAC;IAEF,IAAIJ,QAAQ,CAACK,KAAK,EAAE;MAChBX,OAAO,CAACE,SAAS,CAACU,gBAAgB,CAACrB,gBAAgB,EAAE,IAAIE,oBAAoB,CAAC,CAAC,CAAC;IACpF,CAAC,MAAM;MACH;MACAO,OAAO,CAACE,SAAS,CAACU,gBAAgB,CAC9BrB,gBAAgB,EAChB,IAAIC,2BAA2B,CAACO,MAAM,CAACW,SAAS,EAAE;QAC9CG,SAAS,EAAEP,QAAQ,CAACQ,IAAI,CAACD,SAAS;QAClCE,OAAO,EAAET,QAAQ,CAACQ,IAAI,CAACC;MAC3B,CAAC,CACL,CAAC;IACL;IAEAf,OAAO,CAACE,SAAS,CAACc,QAAQ,CAACtB,oBAAoB,CAAC;IAEhD,MAAMM,OAAO,CAACiB,QAAQ,CAACC,oBAAoB,CAAC,YAAY;MACpD,MAAMC,cAAc,GAAG,MAAMf,QAAQ,CAACgB,OAAO,CAAC/B,iBAAiB,CAAC;MAChEW,OAAO,CAACE,SAAS,CAACU,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,13 +0,0 @@
1
- import type { HandlerFactoryParams } from "@webiny/handler-aws/types.js";
2
- import { SCHEDULED_ACTION_EVENT_IDENTIFIER } from "./constants.js";
3
- export interface IScheduledActionEventPayload {
4
- id: string;
5
- scheduleFor: string;
6
- }
7
- export interface IScheduledActionEvent {
8
- [SCHEDULED_ACTION_EVENT_IDENTIFIER]: IScheduledActionEventPayload;
9
- }
10
- export interface HandlerParams extends HandlerFactoryParams {
11
- debug?: boolean;
12
- }
13
- export declare const createScheduledActionEventHandler: () => import("@webiny/handler-aws/raw/index.js").RawEventHandler<IScheduledActionEvent, import("@webiny/handler/types").Context, any>;
@@ -1,50 +0,0 @@
1
- import { registry } from "@webiny/handler-aws/registry.js";
2
- import { createSourceHandler } from "@webiny/handler-aws/sourceHandler.js";
3
- import { createEventHandler, createHandler } from "@webiny/handler-aws/raw/index.js";
4
- import { SCHEDULED_ACTION_EVENT_IDENTIFIER } from "./constants.js";
5
- import { ExecuteScheduledActionUseCase } from "./features/ExecuteScheduledAction/index.js";
6
- const canHandle = event => {
7
- if (typeof event?.hasOwnProperty !== "function") {
8
- return false;
9
- } else if (!event.hasOwnProperty(SCHEDULED_ACTION_EVENT_IDENTIFIER)) {
10
- return false;
11
- }
12
- const value = event[SCHEDULED_ACTION_EVENT_IDENTIFIER];
13
- return !!(value?.id && value?.scheduleFor);
14
- };
15
- const handler = createSourceHandler({
16
- name: "handler-aws-event-bridge-scheduled-cms-action-event",
17
- canUse: canHandle,
18
- handle: async ({
19
- params,
20
- event,
21
- context
22
- }) => {
23
- return createHandler(params)(event, context);
24
- }
25
- });
26
- registry.register(handler);
27
- export const createScheduledActionEventHandler = () => {
28
- return createEventHandler({
29
- canHandle,
30
- handle: async params => {
31
- const {
32
- payload,
33
- context
34
- } = params;
35
- const input = payload[SCHEDULED_ACTION_EVENT_IDENTIFIER];
36
- const executeScheduledAction = context.container.resolve(ExecuteScheduledActionUseCase);
37
- const result = await executeScheduledAction.execute(input.id);
38
- if (result.isFail()) {
39
- const error = result.error;
40
- console.error(error.code, error.message);
41
- throw error;
42
- }
43
- return {
44
- success: true
45
- };
46
- }
47
- });
48
- };
49
-
50
- //# sourceMappingURL=createEventHandler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["registry","createSourceHandler","createEventHandler","createHandler","SCHEDULED_ACTION_EVENT_IDENTIFIER","ExecuteScheduledActionUseCase","canHandle","event","hasOwnProperty","value","id","scheduleFor","handler","name","canUse","handle","params","context","register","createScheduledActionEventHandler","payload","input","executeScheduledAction","container","resolve","result","execute","isFail","error","console","code","message","success"],"sources":["createEventHandler.ts"],"sourcesContent":["import { registry } from \"@webiny/handler-aws/registry.js\";\nimport type { HandlerFactoryParams } from \"@webiny/handler-aws/types.js\";\nimport { createSourceHandler } from \"@webiny/handler-aws/sourceHandler.js\";\nimport { createEventHandler, createHandler } from \"@webiny/handler-aws/raw/index.js\";\nimport { SCHEDULED_ACTION_EVENT_IDENTIFIER } from \"~/constants.js\";\nimport { ExecuteScheduledActionUseCase } from \"~/features/ExecuteScheduledAction/index.js\";\n\nexport interface IScheduledActionEventPayload {\n 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,6 +0,0 @@
1
- import type { Plugin } from "@webiny/plugins/types.js";
2
- import { SchedulerClient, SchedulerClientConfig } from "@webiny/aws-sdk/client-scheduler";
3
- export interface ICreateSchedulerParams {
4
- getClient(config?: SchedulerClientConfig): Pick<SchedulerClient, "send">;
5
- }
6
- export declare const createScheduler: (params: ICreateSchedulerParams) => Plugin[];
@@ -1,11 +0,0 @@
1
- import { createSchedulerContext } from "./context.js";
2
- import { createScheduledActionEventHandler } from "./createEventHandler.js";
3
- export const createScheduler = params => {
4
- return [
5
- /**
6
- * Handler for the Scheduled Action Event.
7
- */
8
- createScheduledActionEventHandler(), createSchedulerContext(params)];
9
- };
10
-
11
- //# sourceMappingURL=createScheduler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["createSchedulerContext","createScheduledActionEventHandler","createScheduler","params"],"sources":["createScheduler.ts"],"sourcesContent":["import type { Plugin } from \"@webiny/plugins/types.js\";\nimport { SchedulerClient, SchedulerClientConfig } from \"@webiny/aws-sdk/client-scheduler\";\nimport { createSchedulerContext } from \"~/context.js\";\nimport { createScheduledActionEventHandler } from \"~/createEventHandler.js\";\n\nexport interface ICreateSchedulerParams {\n getClient(config?: SchedulerClientConfig): Pick<SchedulerClient, \"send\">;\n}\nexport const createScheduler = (params: ICreateSchedulerParams): Plugin[] => {\n return [\n /**\n * Handler for the Scheduled Action Event.\n */\n createScheduledActionEventHandler(),\n createSchedulerContext(params)\n ];\n};\n"],"mappings":"AAEA,SAASA,sBAAsB;AAC/B,SAASC,iCAAiC;AAK1C,OAAO,MAAMC,eAAe,GAAIC,MAA8B,IAAe;EACzE,OAAO;EACH;AACR;AACA;EACQF,iCAAiC,CAAC,CAAC,EACnCD,sBAAsB,CAACG,MAAM,CAAC,CACjC;AACL,CAAC","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
@@ -1,23 +0,0 @@
1
- import { Result } from "@webiny/feature/api";
2
- import { RunActionUseCase as UseCaseAbstraction } from "./abstractions.js";
3
- import { ScheduleActionUseCase } from "../../features/ScheduleAction/abstractions.js";
4
- import type { IScheduledAction } from "../../shared/abstractions.js";
5
- import type { GenericRecord } from "@webiny/api/types.js";
6
- /**
7
- * Schedules an action for immediate execution
8
- *
9
- * Flow:
10
- * 1. Calculate the closest possible execution time
11
- * 2. Delegate to ScheduleAction use case with calculated time
12
- *
13
- * Note: We add a small buffer to ensure EventBridge has time to process the schedule
14
- */
15
- declare class RunActionUseCaseImpl implements UseCaseAbstraction.Interface {
16
- private scheduleActionUseCase;
17
- constructor(scheduleActionUseCase: ScheduleActionUseCase.Interface);
18
- execute<T extends GenericRecord>(params: UseCaseAbstraction.Params<T>): Promise<Result<IScheduledAction<T>, UseCaseAbstraction.Error>>;
19
- }
20
- export declare const RunActionUseCase: typeof RunActionUseCaseImpl & {
21
- __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IRunActionUseCase>;
22
- };
23
- export {};
@@ -1,37 +0,0 @@
1
- import { Result } from "@webiny/feature/api";
2
- import { RunActionUseCase as UseCaseAbstraction } from "./abstractions.js";
3
- import { ScheduleActionUseCase } from "../ScheduleAction/abstractions.js";
4
- /**
5
- * Schedules an action for immediate execution
6
- *
7
- * Flow:
8
- * 1. Calculate the closest possible execution time
9
- * 2. Delegate to ScheduleAction use case with calculated time
10
- *
11
- * Note: We add a small buffer to ensure EventBridge has time to process the schedule
12
- */
13
- class RunActionUseCaseImpl {
14
- constructor(scheduleActionUseCase) {
15
- this.scheduleActionUseCase = scheduleActionUseCase;
16
- }
17
- async execute(params) {
18
- // Delegate to ScheduleAction
19
- const result = await this.scheduleActionUseCase.execute({
20
- ...params,
21
- title: "Unknown title",
22
- // Calculate the soonest possible execution time.
23
- // Add at least 90 seconds of buffer to ensure EventBridge can process the schedule.
24
- scheduleFor: new Date(Date.now() + 90000).toISOString()
25
- });
26
- if (result.isFail()) {
27
- return Result.fail(result.error);
28
- }
29
- return Result.ok(result.value);
30
- }
31
- }
32
- export const RunActionUseCase = UseCaseAbstraction.createImplementation({
33
- implementation: RunActionUseCaseImpl,
34
- dependencies: [ScheduleActionUseCase]
35
- });
36
-
37
- //# sourceMappingURL=RunActionUseCase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["Result","RunActionUseCase","UseCaseAbstraction","ScheduleActionUseCase","RunActionUseCaseImpl","constructor","scheduleActionUseCase","execute","params","result","title","scheduleFor","Date","now","toISOString","isFail","fail","error","ok","value","createImplementation","implementation","dependencies"],"sources":["RunActionUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { RunActionUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { ScheduleActionUseCase } from \"~/features/ScheduleAction/abstractions.js\";\nimport type { IScheduledAction } from \"~/shared/abstractions.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\n/**\n * Schedules an action for immediate execution\n *\n * Flow:\n * 1. Calculate the closest possible execution time\n * 2. Delegate to ScheduleAction use case with calculated time\n *\n * Note: We add a small buffer to ensure EventBridge has time to process the schedule\n */\nclass RunActionUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(private scheduleActionUseCase: ScheduleActionUseCase.Interface) {}\n\n async execute<T extends GenericRecord>(\n params: UseCaseAbstraction.Params<T>\n ): Promise<Result<IScheduledAction<T>, UseCaseAbstraction.Error>> {\n // Delegate to ScheduleAction\n const result = await this.scheduleActionUseCase.execute({\n ...params,\n title: \"Unknown title\",\n // Calculate the soonest possible execution time.\n // Add at least 90 seconds of buffer to ensure EventBridge can process the schedule.\n scheduleFor: new Date(Date.now() + 90000).toISOString()\n });\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n return Result.ok(result.value);\n }\n}\n\nexport const RunActionUseCase = UseCaseAbstraction.createImplementation({\n implementation: RunActionUseCaseImpl,\n dependencies: [ScheduleActionUseCase]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,gBAAgB,IAAIC,kBAAkB;AAC/C,SAASC,qBAAqB;AAI9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,oBAAoB,CAAyC;EAC/DC,WAAWA,CAASC,qBAAsD,EAAE;IAAA,KAAxDA,qBAAsD,GAAtDA,qBAAsD;EAAG;EAE7E,MAAMC,OAAOA,CACTC,MAAoC,EAC0B;IAC9D;IACA,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACH,qBAAqB,CAACC,OAAO,CAAC;MACpD,GAAGC,MAAM;MACTE,KAAK,EAAE,eAAe;MACtB;MACA;MACAC,WAAW,EAAE,IAAIC,IAAI,CAACA,IAAI,CAACC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAACC,WAAW,CAAC;IAC1D,CAAC,CAAC;IAEF,IAAIL,MAAM,CAACM,MAAM,CAAC,CAAC,EAAE;MACjB,OAAOf,MAAM,CAACgB,IAAI,CAACP,MAAM,CAACQ,KAAK,CAAC;IACpC;IAEA,OAAOjB,MAAM,CAACkB,EAAE,CAACT,MAAM,CAACU,KAAK,CAAC;EAClC;AACJ;AAEA,OAAO,MAAMlB,gBAAgB,GAAGC,kBAAkB,CAACkB,oBAAoB,CAAC;EACpEC,cAAc,EAAEjB,oBAAoB;EACpCkB,YAAY,EAAE,CAACnB,qBAAqB;AACxC,CAAC,CAAC","ignoreList":[]}
@@ -1,35 +0,0 @@
1
- import { Result } from "@webiny/feature/api";
2
- import type { IScheduledAction } from "../../shared/abstractions.js";
3
- import { InvalidScheduleDateError, ScheduledActionPersistenceError, SchedulerServiceError } from "../../domain/errors.js";
4
- import type { GenericRecord } from "@webiny/api/types.js";
5
- /**
6
- * RunActionUseCase - Schedule an action for immediate execution
7
- *
8
- * This is a convenience use case that wraps ScheduleAction and automatically
9
- * calculates the closest possible execution time (current time + small buffer).
10
- *
11
- * Use this when you want to execute an action "immediately" without having to manually
12
- * calculate the schedule date.
13
- */
14
- export interface IRunActionErrors {
15
- persistence: ScheduledActionPersistenceError;
16
- invalidDate: InvalidScheduleDateError;
17
- schedulerService: SchedulerServiceError;
18
- }
19
- type RunActionError = IRunActionErrors[keyof IRunActionErrors];
20
- interface IRunActionParams<T extends GenericRecord> {
21
- namespace: string;
22
- actionType: string;
23
- targetId: string;
24
- payload: T;
25
- }
26
- export interface IRunActionUseCase {
27
- execute<T extends GenericRecord>(params: IRunActionParams<T>): Promise<Result<IScheduledAction<T>, RunActionError>>;
28
- }
29
- export declare const RunActionUseCase: import("@webiny/di").Abstraction<IRunActionUseCase>;
30
- export declare namespace RunActionUseCase {
31
- type Interface = IRunActionUseCase;
32
- type Params<T extends GenericRecord> = IRunActionParams<T>;
33
- type Error = RunActionError;
34
- }
35
- export {};
@@ -1,15 +0,0 @@
1
- import { createAbstraction } from "@webiny/feature/api";
2
-
3
- /**
4
- * RunActionUseCase - Schedule an action for immediate execution
5
- *
6
- * This is a convenience use case that wraps ScheduleAction and automatically
7
- * calculates the closest possible execution time (current time + small buffer).
8
- *
9
- * Use this when you want to execute an action "immediately" without having to manually
10
- * calculate the schedule date.
11
- */
12
-
13
- export const RunActionUseCase = createAbstraction("RunActionUseCase");
14
-
15
- //# sourceMappingURL=abstractions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["createAbstraction","RunActionUseCase"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction, Result } from \"@webiny/feature/api\";\nimport type { IScheduledAction } from \"~/shared/abstractions.js\";\nimport {\n InvalidScheduleDateError,\n ScheduledActionPersistenceError,\n SchedulerServiceError\n} from \"~/domain/errors.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\n/**\n * RunActionUseCase - Schedule an action for immediate execution\n *\n * This is a convenience use case that wraps ScheduleAction and automatically\n * calculates the closest possible execution time (current time + small buffer).\n *\n * Use this when you want to execute an action \"immediately\" without having to manually\n * calculate the schedule date.\n */\n\nexport interface IRunActionErrors {\n persistence: ScheduledActionPersistenceError;\n invalidDate: InvalidScheduleDateError;\n schedulerService: SchedulerServiceError;\n}\n\ntype RunActionError = IRunActionErrors[keyof IRunActionErrors];\n\ninterface IRunActionParams<T extends GenericRecord> {\n namespace: string;\n actionType: string;\n targetId: string;\n payload: T;\n}\n\nexport interface IRunActionUseCase {\n execute<T extends GenericRecord>(\n params: IRunActionParams<T>\n ): Promise<Result<IScheduledAction<T>, RunActionError>>;\n}\n\nexport const RunActionUseCase = createAbstraction<IRunActionUseCase>(\"RunActionUseCase\");\n\nexport namespace RunActionUseCase {\n export type Interface = IRunActionUseCase;\n export type Params<T extends GenericRecord> = IRunActionParams<T>;\n export type Error = RunActionError;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAgB,qBAAqB;;AAS/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuBA,OAAO,MAAMC,gBAAgB,GAAGD,iBAAiB,CAAoB,kBAAkB,CAAC","ignoreList":[]}
@@ -1,7 +0,0 @@
1
- /**
2
- * RunAction Feature
3
- *
4
- * Provides the ability to schedule an action for immediate execution
5
- * without having to manually calculate the schedule date.
6
- */
7
- export declare const RunActionFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
@@ -1,17 +0,0 @@
1
- import { createFeature } from "@webiny/feature/api";
2
- import { RunActionUseCase } from "./RunActionUseCase.js";
3
-
4
- /**
5
- * RunAction Feature
6
- *
7
- * Provides the ability to schedule an action for immediate execution
8
- * without having to manually calculate the schedule date.
9
- */
10
- export const RunActionFeature = createFeature({
11
- name: "RunAction",
12
- register(container) {
13
- container.register(RunActionUseCase);
14
- }
15
- });
16
-
17
- //# sourceMappingURL=feature.js.map