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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/constants.d.ts +5 -0
  2. package/constants.js +6 -0
  3. package/constants.js.map +1 -1
  4. package/context.js +6 -0
  5. package/context.js.map +1 -1
  6. package/createEventHandler.d.ts +1 -0
  7. package/createEventHandler.js +1 -1
  8. package/createEventHandler.js.map +1 -1
  9. package/domain/ScheduledActionMapper.d.ts +16 -0
  10. package/domain/ScheduledActionMapper.js +37 -0
  11. package/domain/ScheduledActionMapper.js.map +1 -0
  12. package/domain/errors.d.ts +19 -1
  13. package/domain/errors.js +27 -1
  14. package/domain/errors.js.map +1 -1
  15. package/domain/isValidDate.d.ts +1 -1
  16. package/domain/isValidDate.js +2 -2
  17. package/domain/isValidDate.js.map +1 -1
  18. package/domain/permissions.d.ts +45 -0
  19. package/domain/permissions.js +13 -0
  20. package/domain/permissions.js.map +1 -0
  21. package/exports/api/scheduler.d.ts +10 -0
  22. package/exports/api/scheduler.js +10 -0
  23. package/exports/api/scheduler.js.map +1 -0
  24. package/features/CancelScheduledAction/CancelScheduledActionUseCase.d.ts +4 -2
  25. package/features/CancelScheduledAction/CancelScheduledActionUseCase.js +17 -8
  26. package/features/CancelScheduledAction/CancelScheduledActionUseCase.js.map +1 -1
  27. package/features/CancelScheduledAction/abstractions.d.ts +9 -2
  28. package/features/CancelScheduledAction/abstractions.js +2 -1
  29. package/features/CancelScheduledAction/abstractions.js.map +1 -1
  30. package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.d.ts +1 -1
  31. package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.js +9 -6
  32. package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.js.map +1 -1
  33. package/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.d.ts +2 -2
  34. package/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.js.map +1 -1
  35. package/features/ExecuteScheduledAction/abstractions.d.ts +9 -2
  36. package/features/ExecuteScheduledAction/abstractions.js +2 -1
  37. package/features/ExecuteScheduledAction/abstractions.js.map +1 -1
  38. package/features/GetScheduledAction/GetScheduledActionUseCase.d.ts +6 -2
  39. package/features/GetScheduledAction/GetScheduledActionUseCase.js +32 -15
  40. package/features/GetScheduledAction/GetScheduledActionUseCase.js.map +1 -1
  41. package/features/GetScheduledAction/abstractions.d.ts +9 -2
  42. package/features/GetScheduledAction/abstractions.js +2 -1
  43. package/features/GetScheduledAction/abstractions.js.map +1 -1
  44. package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.d.ts +32 -0
  45. package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js +86 -0
  46. package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js.map +1 -0
  47. package/features/GetTargetScheduledAction/abstractions.d.ts +24 -0
  48. package/features/GetTargetScheduledAction/abstractions.js +4 -0
  49. package/features/GetTargetScheduledAction/abstractions.js.map +1 -0
  50. package/features/GetTargetScheduledAction/feature.d.ts +7 -0
  51. package/features/GetTargetScheduledAction/feature.js +17 -0
  52. package/features/GetTargetScheduledAction/feature.js.map +1 -0
  53. package/features/ListScheduledActions/ListScheduledActionsUseCase.d.ts +5 -1
  54. package/features/ListScheduledActions/ListScheduledActionsUseCase.js +25 -24
  55. package/features/ListScheduledActions/ListScheduledActionsUseCase.js.map +1 -1
  56. package/features/ListScheduledActions/abstractions.d.ts +11 -3
  57. package/features/ListScheduledActions/abstractions.js +2 -1
  58. package/features/ListScheduledActions/abstractions.js.map +1 -1
  59. package/features/NamespaceHandler/NamespaceHandlerExecutioner.d.ts +11 -0
  60. package/features/NamespaceHandler/NamespaceHandlerExecutioner.js +25 -0
  61. package/features/NamespaceHandler/NamespaceHandlerExecutioner.js.map +1 -0
  62. package/features/NamespaceHandler/abstractions.d.ts +50 -0
  63. package/features/NamespaceHandler/abstractions.js +16 -0
  64. package/features/NamespaceHandler/abstractions.js.map +1 -0
  65. package/features/NamespaceHandler/index.d.ts +1 -0
  66. package/features/NamespaceHandler/index.js +3 -0
  67. package/features/NamespaceHandler/index.js.map +1 -0
  68. package/features/ScheduleAction/ScheduleActionUseCase.d.ts +4 -4
  69. package/features/ScheduleAction/ScheduleActionUseCase.js +75 -16
  70. package/features/ScheduleAction/ScheduleActionUseCase.js.map +1 -1
  71. package/features/ScheduleAction/abstractions.d.ts +10 -10
  72. package/features/ScheduleAction/abstractions.js +2 -1
  73. package/features/ScheduleAction/abstractions.js.map +1 -1
  74. package/features/SchedulerFeature.js +2 -2
  75. package/features/SchedulerFeature.js.map +1 -1
  76. package/features/SchedulerService/EventBridgeSchedulerService.js +3 -1
  77. package/features/SchedulerService/EventBridgeSchedulerService.js.map +1 -1
  78. package/graphql/SchedulerGraphQLFactory.d.ts +8 -0
  79. package/graphql/SchedulerGraphQLFactory.js +248 -0
  80. package/graphql/SchedulerGraphQLFactory.js.map +1 -0
  81. package/graphql/index.d.ts +1 -0
  82. package/graphql/index.js +3 -0
  83. package/graphql/index.js.map +1 -0
  84. package/index.d.ts +0 -6
  85. package/index.js +0 -8
  86. package/index.js.map +1 -1
  87. package/package.json +20 -27
  88. package/shared/abstractions.d.ts +18 -6
  89. package/shared/abstractions.js +3 -0
  90. package/shared/abstractions.js.map +1 -1
  91. package/features/RunAction/RunActionUseCase.d.ts +0 -23
  92. package/features/RunAction/RunActionUseCase.js +0 -37
  93. package/features/RunAction/RunActionUseCase.js.map +0 -1
  94. package/features/RunAction/abstractions.d.ts +0 -35
  95. package/features/RunAction/abstractions.js +0 -15
  96. package/features/RunAction/abstractions.js.map +0 -1
  97. package/features/RunAction/feature.d.ts +0 -7
  98. package/features/RunAction/feature.js +0 -17
  99. package/features/RunAction/feature.js.map +0 -1
  100. /package/features/{RunAction → GetTargetScheduledAction}/index.d.ts +0 -0
  101. /package/features/{RunAction → GetTargetScheduledAction}/index.js +0 -0
  102. /package/features/{RunAction → GetTargetScheduledAction}/index.js.map +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-scheduler",
3
- "version": "6.0.0",
3
+ "version": "6.1.0-beta.1",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -14,42 +14,35 @@
14
14
  "author": "Webiny Ltd",
15
15
  "description": "A generic action scheduler.",
16
16
  "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
17
  "dependencies": {
26
- "@webiny/api": "6.0.0",
27
- "@webiny/api-core": "6.0.0",
28
- "@webiny/api-headless-cms": "6.0.0",
29
- "@webiny/aws-sdk": "6.0.0",
30
- "@webiny/error": "6.0.0",
31
- "@webiny/feature": "6.0.0",
32
- "@webiny/handler-graphql": "6.0.0",
33
- "@webiny/plugins": "6.0.0",
34
- "@webiny/utils": "6.0.0",
35
- "zod": "3.25.76"
18
+ "@webiny/api": "6.1.0-beta.1",
19
+ "@webiny/api-core": "6.1.0-beta.1",
20
+ "@webiny/api-headless-cms": "6.1.0-beta.1",
21
+ "@webiny/aws-sdk": "6.1.0-beta.1",
22
+ "@webiny/error": "6.1.0-beta.1",
23
+ "@webiny/feature": "6.1.0-beta.1",
24
+ "@webiny/handler-graphql": "6.1.0-beta.1",
25
+ "@webiny/plugins": "6.1.0-beta.1",
26
+ "@webiny/utils": "6.1.0-beta.1",
27
+ "zod": "4.3.6"
36
28
  },
37
29
  "devDependencies": {
38
- "@webiny/build-tools": "6.0.0",
39
- "@webiny/db-dynamodb": "6.0.0",
40
- "@webiny/handler": "6.0.0",
41
- "@webiny/handler-aws": "6.0.0",
42
- "@webiny/project-utils": "6.0.0",
43
- "@webiny/wcp": "6.0.0",
30
+ "@webiny/build-tools": "6.1.0-beta.1",
31
+ "@webiny/db-dynamodb": "6.1.0-beta.1",
32
+ "@webiny/handler": "6.1.0-beta.1",
33
+ "@webiny/handler-aws": "6.1.0-beta.1",
34
+ "@webiny/project-utils": "6.1.0-beta.1",
35
+ "@webiny/testing": "6.1.0-beta.1",
36
+ "@webiny/wcp": "6.1.0-beta.1",
44
37
  "aws-sdk-client-mock": "4.1.0",
45
38
  "jest-dynalite": "3.6.1",
46
39
  "rimraf": "6.1.3",
47
40
  "typescript": "5.9.3",
48
- "vitest": "4.0.18"
41
+ "vitest": "4.1.2"
49
42
  },
50
43
  "publishConfig": {
51
44
  "access": "public",
52
45
  "directory": "dist"
53
46
  },
54
- "gitHead": "9c6892640a45679ff521e25cd6587dff57393a2e"
47
+ "gitHead": "3c1293ba17a14f239fb1cbf5d80cd66846849309"
55
48
  }
@@ -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,20 +10,25 @@ export interface Identity {
8
10
  type: string;
9
11
  displayName: string;
10
12
  }
11
- export type ScheduledActionType = "Publish" | "Unpublish" | "Send" | "Delete";
13
+ export type ScheduledActionType = typeof SCHEDULED_ACTION_PUBLISH | typeof SCHEDULED_ACTION_UNPUBLISH;
12
14
  /**
13
15
  * Scheduled Action Record - The data stored for a scheduled action
14
16
  */
15
- export interface IScheduledAction<T extends GenericRecord> {
16
- id: string;
17
+ export interface IScheduledActionEntryValues<T> {
17
18
  namespace: string;
18
19
  actionType: ScheduledActionType;
19
20
  targetId: string;
20
21
  scheduledBy: Identity;
21
22
  scheduledFor: string;
22
- title?: string;
23
+ title: string;
23
24
  payload: T;
24
- 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
+ scheduledFor: Date;
25
32
  }
26
33
  /**
27
34
  * ScheduledActionHandler - Similar to EventHandler pattern
@@ -36,12 +43,13 @@ export interface IScheduledActionHandler {
36
43
  * @param namespace - Resource scope (e.g., "Cms/Entry/Article")
37
44
  * @param actionType - Operation type (e.g., "Publish")
38
45
  */
39
- canHandle(namespace: string, actionType: string): boolean;
46
+ canHandle(namespace: string, actionType: ScheduledActionType): boolean;
40
47
  /**
41
48
  * Executes the scheduled action
42
49
  */
43
50
  handle(action: IScheduledAction<any>): Promise<void>;
44
51
  }
52
+ /** Handle execution of a scheduled action. */
45
53
  export declare const ScheduledActionHandler: import("@webiny/di").Abstraction<IScheduledActionHandler>;
46
54
  export declare namespace ScheduledActionHandler {
47
55
  type Interface = IScheduledActionHandler;
@@ -53,10 +61,12 @@ export declare namespace ScheduledActionHandler {
53
61
  */
54
62
  export interface ISchedulerServiceCreateParams {
55
63
  id: string;
64
+ namespace: string;
56
65
  scheduleFor: Date;
57
66
  }
58
67
  export interface ISchedulerServiceUpdateParams {
59
68
  id: string;
69
+ namespace: string;
60
70
  scheduleFor: Date;
61
71
  }
62
72
  export interface ISchedulerService {
@@ -65,6 +75,7 @@ export interface ISchedulerService {
65
75
  delete(id: string): Promise<void>;
66
76
  exists(id: string): Promise<boolean>;
67
77
  }
78
+ /** Core service for managing scheduled actions. */
68
79
  export declare const SchedulerService: import("@webiny/di").Abstraction<ISchedulerService>;
69
80
  export declare namespace SchedulerService {
70
81
  type Interface = ISchedulerService;
@@ -72,6 +83,7 @@ export declare namespace SchedulerService {
72
83
  /**
73
84
  * ScheduledActionModel - A CMS model used by the scheduler for persistence.
74
85
  */
86
+ /** Content model definition for scheduled actions. */
75
87
  export declare const ScheduledActionModel: import("@webiny/di").Abstraction<CmsModel>;
76
88
  export declare namespace ScheduledActionModel {
77
89
  type Interface = CmsModel;
@@ -15,6 +15,7 @@ import { createAbstraction } from "@webiny/feature/api";
15
15
  * This is the ONLY action abstraction needed.
16
16
  */
17
17
 
18
+ /** Handle execution of a scheduled action. */
18
19
  export const ScheduledActionHandler = createAbstraction("ScheduledActionHandler");
19
20
 
20
21
  /**
@@ -23,10 +24,12 @@ export const ScheduledActionHandler = createAbstraction("ScheduledActionHandler"
23
24
  * Abstracts the underlying scheduling infrastructure (AWS EventBridge, Azure Logic Apps, etc.)
24
25
  */
25
26
 
27
+ /** Core service for managing scheduled actions. */
26
28
  export const SchedulerService = createAbstraction("SchedulerService");
27
29
  /**
28
30
  * ScheduledActionModel - A CMS model used by the scheduler for persistence.
29
31
  */
32
+ /** Content model definition for scheduled actions. */
30
33
  export const ScheduledActionModel = createAbstraction("ScheduledActionModel");
31
34
 
32
35
  //# 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\nexport type ScheduledActionType = \"Publish\" | \"Unpublish\" | \"Send\" | \"Delete\";\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: 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; // 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;;AAQA;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,"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\";\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>\n extends CmsEntry<IScheduledActionEntryValues<T>> {}\n\nexport interface IScheduledAction<T extends GenericRecord = GenericRecord>\n extends Omit<IScheduledActionEntryValues<T>, \"scheduledFor\"> {\n id: string;\n scheduledFor: Date;\n}\n\n/**\n * ScheduledActionHandler - Similar to EventHandler pattern\n *\n * Each application (CMS, Mailer, etc.) implements handlers for their actions.\n * This is the ONLY action abstraction needed.\n */\nexport interface IScheduledActionHandler {\n /**\n * Determines if this handler can handle the given action\n *\n * @param namespace - Resource scope (e.g., \"Cms/Entry/Article\")\n * @param actionType - Operation type (e.g., \"Publish\")\n */\n canHandle(namespace: string, actionType: ScheduledActionType): boolean;\n\n /**\n * Executes the scheduled action\n */\n handle(action: IScheduledAction<any>): Promise<void>;\n}\n\n/** Handle execution of a scheduled action. */\nexport const ScheduledActionHandler =\n createAbstraction<IScheduledActionHandler>(\"ScheduledActionHandler\");\n\nexport namespace ScheduledActionHandler {\n export type Interface = IScheduledActionHandler;\n}\n\n/**\n * SchedulerService - Cloud-agnostic scheduler service\n *\n * Abstracts the underlying scheduling infrastructure (AWS EventBridge, Azure Logic Apps, etc.)\n */\n\nexport interface ISchedulerServiceCreateParams {\n id: string;\n namespace: string;\n scheduleFor: Date;\n}\nexport interface ISchedulerServiceUpdateParams {\n id: string;\n namespace: 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\n/** Core service for managing scheduled actions. */\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 */\n/** Content model definition for scheduled actions. */\nexport const ScheduledActionModel = createAbstraction<CmsModel>(\"ScheduledActionModel\");\n\nexport namespace ScheduledActionModel {\n export type Interface = CmsModel;\n}\n"],"mappings":"AACA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAKvD;AACA;AACA;;AAUA;AACA;AACA;;AAsBA;AACA;AACA;AACA;AACA;AACA;;AAgBA;AACA,OAAO,MAAMC,sBAAsB,GAC/BD,iBAAiB,CAA0B,wBAAwB,CAAC;;AAMxE;AACA;AACA;AACA;AACA;;AAoBA;AACA,OAAO,MAAME,gBAAgB,GAAGF,iBAAiB,CAAoB,kBAAkB,CAAC;AAMxF;AACA;AACA;AACA;AACA,OAAO,MAAMG,oBAAoB,GAAGH,iBAAiB,CAAW,sBAAsB,CAAC","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, ScheduledActionType } 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: ScheduledActionType;
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, ScheduledActionType } 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: ScheduledActionType;\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
@@ -1 +0,0 @@
1
- {"version":3,"names":["createFeature","RunActionUseCase","RunActionFeature","name","register","container"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { RunActionUseCase } from \"./RunActionUseCase.js\";\n\n/**\n * RunAction Feature\n *\n * Provides the ability to schedule an action for immediate execution\n * without having to manually calculate the schedule date.\n */\nexport const RunActionFeature = createFeature({\n name: \"RunAction\",\n register(container) {\n container.register(RunActionUseCase);\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,gBAAgB;;AAEzB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAGF,aAAa,CAAC;EAC1CG,IAAI,EAAE,WAAW;EACjBC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,gBAAgB,CAAC;EACxC;AACJ,CAAC,CAAC","ignoreList":[]}