@webiny/api-scheduler 0.0.0-unstable.ac6ebf63c6 → 0.0.0-unstable.c27f4d8a31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/context.js +6 -0
- package/context.js.map +1 -1
- package/createEventHandler.d.ts +1 -0
- package/createEventHandler.js +1 -1
- package/createEventHandler.js.map +1 -1
- package/domain/ScheduledActionMapper.d.ts +16 -0
- package/domain/ScheduledActionMapper.js +36 -0
- package/domain/ScheduledActionMapper.js.map +1 -0
- package/domain/errors.d.ts +19 -1
- package/domain/errors.js +27 -1
- package/domain/errors.js.map +1 -1
- package/domain/isValidDate.d.ts +1 -1
- package/domain/isValidDate.js +2 -2
- package/domain/isValidDate.js.map +1 -1
- package/domain/permissions.d.ts +45 -0
- package/domain/permissions.js +13 -0
- package/domain/permissions.js.map +1 -0
- package/exports/api/scheduler.d.ts +9 -0
- package/exports/api/scheduler.js +9 -0
- package/exports/api/scheduler.js.map +1 -0
- package/features/CancelScheduledAction/CancelScheduledActionUseCase.d.ts +4 -2
- package/features/CancelScheduledAction/CancelScheduledActionUseCase.js +14 -5
- package/features/CancelScheduledAction/CancelScheduledActionUseCase.js.map +1 -1
- package/features/CancelScheduledAction/abstractions.d.ts +8 -2
- package/features/CancelScheduledAction/abstractions.js +1 -1
- package/features/CancelScheduledAction/abstractions.js.map +1 -1
- package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.d.ts +1 -1
- package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.js +9 -6
- package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.js.map +1 -1
- package/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.d.ts +2 -2
- package/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.js.map +1 -1
- package/features/ExecuteScheduledAction/abstractions.d.ts +8 -2
- package/features/ExecuteScheduledAction/abstractions.js +1 -1
- package/features/ExecuteScheduledAction/abstractions.js.map +1 -1
- package/features/GetScheduledAction/GetScheduledActionUseCase.d.ts +6 -2
- package/features/GetScheduledAction/GetScheduledActionUseCase.js +32 -15
- package/features/GetScheduledAction/GetScheduledActionUseCase.js.map +1 -1
- package/features/GetScheduledAction/abstractions.d.ts +8 -2
- package/features/GetScheduledAction/abstractions.js +1 -1
- package/features/GetScheduledAction/abstractions.js.map +1 -1
- package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.d.ts +32 -0
- package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js +85 -0
- package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js.map +1 -0
- package/features/GetTargetScheduledAction/abstractions.d.ts +24 -0
- package/features/GetTargetScheduledAction/abstractions.js +4 -0
- package/features/GetTargetScheduledAction/abstractions.js.map +1 -0
- package/features/GetTargetScheduledAction/feature.d.ts +7 -0
- package/features/GetTargetScheduledAction/feature.js +17 -0
- package/features/GetTargetScheduledAction/feature.js.map +1 -0
- package/features/ListScheduledActions/ListScheduledActionsUseCase.d.ts +5 -1
- package/features/ListScheduledActions/ListScheduledActionsUseCase.js +25 -24
- package/features/ListScheduledActions/ListScheduledActionsUseCase.js.map +1 -1
- package/features/ListScheduledActions/abstractions.d.ts +10 -3
- package/features/ListScheduledActions/abstractions.js +1 -1
- package/features/ListScheduledActions/abstractions.js.map +1 -1
- package/features/NamespaceHandler/NamespaceHandlerExecutioner.d.ts +11 -0
- package/features/NamespaceHandler/NamespaceHandlerExecutioner.js +25 -0
- package/features/NamespaceHandler/NamespaceHandlerExecutioner.js.map +1 -0
- package/features/NamespaceHandler/abstractions.d.ts +49 -0
- package/features/NamespaceHandler/abstractions.js +15 -0
- package/features/NamespaceHandler/abstractions.js.map +1 -0
- package/features/NamespaceHandler/index.d.ts +1 -0
- package/features/NamespaceHandler/index.js +3 -0
- package/features/NamespaceHandler/index.js.map +1 -0
- package/features/ScheduleAction/ScheduleActionUseCase.d.ts +4 -4
- package/features/ScheduleAction/ScheduleActionUseCase.js +75 -16
- package/features/ScheduleAction/ScheduleActionUseCase.js.map +1 -1
- package/features/ScheduleAction/abstractions.d.ts +10 -11
- package/features/ScheduleAction/abstractions.js +1 -1
- package/features/ScheduleAction/abstractions.js.map +1 -1
- package/features/SchedulerFeature.js +2 -2
- package/features/SchedulerFeature.js.map +1 -1
- package/features/SchedulerService/EventBridgeSchedulerService.js +3 -1
- package/features/SchedulerService/EventBridgeSchedulerService.js.map +1 -1
- package/graphql/SchedulerGraphQLFactory.d.ts +8 -0
- package/graphql/SchedulerGraphQLFactory.js +248 -0
- package/graphql/SchedulerGraphQLFactory.js.map +1 -0
- package/graphql/index.d.ts +1 -0
- package/graphql/index.js +3 -0
- package/graphql/index.js.map +1 -0
- package/index.d.ts +0 -6
- package/index.js +0 -8
- package/index.js.map +1 -1
- package/package.json +20 -27
- package/shared/abstractions.d.ts +15 -6
- package/shared/abstractions.js.map +1 -1
- package/features/RunAction/RunActionUseCase.d.ts +0 -23
- package/features/RunAction/RunActionUseCase.js +0 -37
- package/features/RunAction/RunActionUseCase.js.map +0 -1
- package/features/RunAction/abstractions.d.ts +0 -35
- package/features/RunAction/abstractions.js +0 -15
- package/features/RunAction/abstractions.js.map +0 -1
- package/features/RunAction/feature.d.ts +0 -7
- package/features/RunAction/feature.js +0 -17
- package/features/RunAction/feature.js.map +0 -1
- /package/features/{RunAction → GetTargetScheduledAction}/index.d.ts +0 -0
- /package/features/{RunAction → GetTargetScheduledAction}/index.js +0 -0
- /package/features/{RunAction → GetTargetScheduledAction}/index.js.map +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
|
-
import type { IScheduledAction } from "../../shared/abstractions.js";
|
|
3
|
-
import { InvalidScheduleDateError, ScheduledActionPersistenceError, SchedulerServiceError } from "../../domain/errors.js";
|
|
2
|
+
import type { IScheduledAction, ScheduledActionType } from "../../shared/abstractions.js";
|
|
3
|
+
import { InvalidScheduleDateError, ScheduledActionPersistenceError, SchedulerServiceError, NamespaceHandlerNotFoundError } from "../../domain/errors.js";
|
|
4
4
|
import type { GenericRecord } from "@webiny/api/types.js";
|
|
5
5
|
/**
|
|
6
6
|
* ScheduleActionUseCase - Schedule an action for future execution
|
|
@@ -10,26 +10,25 @@ import type { GenericRecord } from "@webiny/api/types.js";
|
|
|
10
10
|
* - If schedule already exists: updates the existing schedule (reschedule)
|
|
11
11
|
*/
|
|
12
12
|
export interface IScheduleActionErrors {
|
|
13
|
+
namespaceHandlerNotFound: NamespaceHandlerNotFoundError;
|
|
13
14
|
persistence: ScheduledActionPersistenceError;
|
|
14
15
|
invalidDate: InvalidScheduleDateError;
|
|
15
16
|
schedulerService: SchedulerServiceError;
|
|
16
17
|
}
|
|
17
|
-
type ScheduleActionError = IScheduleActionErrors[keyof IScheduleActionErrors];
|
|
18
|
-
interface IScheduleActionParams
|
|
18
|
+
export type ScheduleActionError = IScheduleActionErrors[keyof IScheduleActionErrors];
|
|
19
|
+
export interface IScheduleActionParams {
|
|
19
20
|
namespace: string;
|
|
20
|
-
actionType: string;
|
|
21
21
|
targetId: string;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
actionType: ScheduledActionType;
|
|
23
|
+
scheduleFor: Date;
|
|
24
|
+
immediately?: boolean;
|
|
25
25
|
}
|
|
26
26
|
export interface IScheduleActionUseCase {
|
|
27
|
-
execute<T extends GenericRecord>(params: IScheduleActionParams
|
|
27
|
+
execute<T extends GenericRecord>(params: IScheduleActionParams): Promise<Result<IScheduledAction<T>, ScheduleActionError>>;
|
|
28
28
|
}
|
|
29
29
|
export declare const ScheduleActionUseCase: import("@webiny/di").Abstraction<IScheduleActionUseCase>;
|
|
30
30
|
export declare namespace ScheduleActionUseCase {
|
|
31
31
|
type Interface = IScheduleActionUseCase;
|
|
32
|
-
type Params
|
|
32
|
+
type Params = IScheduleActionParams;
|
|
33
33
|
type Error = ScheduleActionError;
|
|
34
34
|
}
|
|
35
|
-
export {};
|
|
@@ -8,6 +8,6 @@ import { createAbstraction } from "@webiny/feature/api";
|
|
|
8
8
|
* - If schedule already exists: updates the existing schedule (reschedule)
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
export const ScheduleActionUseCase = createAbstraction("ScheduleActionUseCase");
|
|
11
|
+
export const ScheduleActionUseCase = createAbstraction("Scheduler/ScheduleActionUseCase");
|
|
12
12
|
|
|
13
13
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createAbstraction","ScheduleActionUseCase"],"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 * ScheduleActionUseCase - Schedule an action for future execution\n *\n * Handles both new schedules and rescheduling (update) automatically:\n * - If no schedule exists for the namespace+actionType+targetId combination: creates new schedule\n * - If schedule already exists: updates the existing schedule (reschedule)\n */\n\nexport interface IScheduleActionErrors {\n persistence: ScheduledActionPersistenceError;\n invalidDate: InvalidScheduleDateError;\n schedulerService: SchedulerServiceError;\n}\n\
|
|
1
|
+
{"version":3,"names":["createAbstraction","ScheduleActionUseCase"],"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 NamespaceHandlerNotFoundError\n} from \"~/domain/errors.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\n/**\n * ScheduleActionUseCase - Schedule an action for future execution\n *\n * Handles both new schedules and rescheduling (update) automatically:\n * - If no schedule exists for the namespace+actionType+targetId combination: creates new schedule\n * - If schedule already exists: updates the existing schedule (reschedule)\n */\n\nexport interface IScheduleActionErrors {\n namespaceHandlerNotFound: NamespaceHandlerNotFoundError;\n persistence: ScheduledActionPersistenceError;\n invalidDate: InvalidScheduleDateError;\n schedulerService: SchedulerServiceError;\n}\n\nexport type ScheduleActionError = IScheduleActionErrors[keyof IScheduleActionErrors];\n\nexport interface IScheduleActionParams {\n namespace: string;\n targetId: string;\n actionType: ScheduledActionType;\n scheduleFor: Date;\n immediately?: boolean;\n}\n\nexport interface IScheduleActionUseCase {\n execute<T extends GenericRecord>(\n params: IScheduleActionParams\n ): Promise<Result<IScheduledAction<T>, ScheduleActionError>>;\n}\n\nexport const ScheduleActionUseCase = createAbstraction<IScheduleActionUseCase>(\n \"Scheduler/ScheduleActionUseCase\"\n);\n\nexport namespace ScheduleActionUseCase {\n export type Interface = IScheduleActionUseCase;\n export type Params = IScheduleActionParams;\n export type Error = ScheduleActionError;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAgB,qBAAqB;;AAU/D;AACA;AACA;AACA;AACA;AACA;AACA;;AAyBA,OAAO,MAAMC,qBAAqB,GAAGD,iBAAiB,CAClD,iCACJ,CAAC","ignoreList":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { ScheduleActionFeature } from "./ScheduleAction/feature.js";
|
|
3
3
|
import { GetScheduledActionFeature } from "./GetScheduledAction/feature.js";
|
|
4
|
+
import { GetTargetScheduledActionFeature } from "./GetTargetScheduledAction/feature.js";
|
|
4
5
|
import { ListScheduledActionsFeature } from "./ListScheduledActions/feature.js";
|
|
5
6
|
import { CancelScheduledActionFeature } from "./CancelScheduledAction/feature.js";
|
|
6
7
|
import { ExecuteScheduledActionFeature } from "./ExecuteScheduledAction/feature.js";
|
|
7
|
-
import { RunActionFeature } from "./RunAction/feature.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Main Scheduler Feature
|
|
@@ -19,10 +19,10 @@ export const SchedulerFeature = createFeature({
|
|
|
19
19
|
// Register all features
|
|
20
20
|
ScheduleActionFeature.register(container);
|
|
21
21
|
GetScheduledActionFeature.register(container);
|
|
22
|
+
GetTargetScheduledActionFeature.register(container);
|
|
22
23
|
ListScheduledActionsFeature.register(container);
|
|
23
24
|
CancelScheduledActionFeature.register(container);
|
|
24
25
|
ExecuteScheduledActionFeature.register(container);
|
|
25
|
-
RunActionFeature.register(container);
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
28
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createFeature","ScheduleActionFeature","GetScheduledActionFeature","ListScheduledActionsFeature","CancelScheduledActionFeature","ExecuteScheduledActionFeature","
|
|
1
|
+
{"version":3,"names":["createFeature","ScheduleActionFeature","GetScheduledActionFeature","GetTargetScheduledActionFeature","ListScheduledActionsFeature","CancelScheduledActionFeature","ExecuteScheduledActionFeature","SchedulerFeature","name","register","container"],"sources":["SchedulerFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ScheduleActionFeature } from \"./ScheduleAction/feature.js\";\nimport { GetScheduledActionFeature } from \"./GetScheduledAction/feature.js\";\nimport { GetTargetScheduledActionFeature } from \"./GetTargetScheduledAction/feature.js\";\nimport { ListScheduledActionsFeature } from \"./ListScheduledActions/feature.js\";\nimport { CancelScheduledActionFeature } from \"./CancelScheduledAction/feature.js\";\nimport { ExecuteScheduledActionFeature } from \"./ExecuteScheduledAction/feature.js\";\n\n/**\n * Main Scheduler Feature\n *\n * Registers all scheduler use cases and the composite handler.\n * Individual handler implementations are registered by consumer packages\n * (e.g., api-headless-cms-scheduler registers CMS-specific handlers).\n */\nexport const SchedulerFeature = createFeature({\n name: \"Scheduler\",\n register(container) {\n // Register all features\n ScheduleActionFeature.register(container);\n GetScheduledActionFeature.register(container);\n GetTargetScheduledActionFeature.register(container);\n ListScheduledActionsFeature.register(container);\n CancelScheduledActionFeature.register(container);\n ExecuteScheduledActionFeature.register(container);\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,qBAAqB;AAC9B,SAASC,yBAAyB;AAClC,SAASC,+BAA+B;AACxC,SAASC,2BAA2B;AACpC,SAASC,4BAA4B;AACrC,SAASC,6BAA6B;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAGP,aAAa,CAAC;EAC1CQ,IAAI,EAAE,WAAW;EACjBC,QAAQA,CAACC,SAAS,EAAE;IAChB;IACAT,qBAAqB,CAACQ,QAAQ,CAACC,SAAS,CAAC;IACzCR,yBAAyB,CAACO,QAAQ,CAACC,SAAS,CAAC;IAC7CP,+BAA+B,CAACM,QAAQ,CAACC,SAAS,CAAC;IACnDN,2BAA2B,CAACK,QAAQ,CAACC,SAAS,CAAC;IAC/CL,4BAA4B,CAACI,QAAQ,CAACC,SAAS,CAAC;IAChDJ,6BAA6B,CAACG,QAAQ,CAACC,SAAS,CAAC;EACrD;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -119,10 +119,12 @@ export class EventBridgeSchedulerService {
|
|
|
119
119
|
createScheduledActionEventPayload(params) {
|
|
120
120
|
const {
|
|
121
121
|
id,
|
|
122
|
-
scheduleFor
|
|
122
|
+
scheduleFor,
|
|
123
|
+
namespace
|
|
123
124
|
} = params;
|
|
124
125
|
return {
|
|
125
126
|
id,
|
|
127
|
+
namespace,
|
|
126
128
|
scheduleFor: scheduleFor.toISOString()
|
|
127
129
|
};
|
|
128
130
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WebinyError","CreateScheduleCommand","DeleteScheduleCommand","GetScheduleCommand","UpdateScheduleCommand","SCHEDULED_ACTION_EVENT_IDENTIFIER","EventBridgeSchedulerService","constructor","getClient","config","create","params","id","scheduleFor","Date","client","exists","update","send","Name","ScheduleExpression","createScheduleExpression","FlexibleTimeWindow","Mode","Target","Arn","lambdaArn","RoleArn","roleArn","Input","createScheduledActionEventInput","ActionAfterCompletion","delete","ex","name","from","toISOString","replace","JSON","stringify","createScheduledActionEventPayload"],"sources":["EventBridgeSchedulerService.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport {\n type ISchedulerServiceCreateParams,\n type ISchedulerServiceUpdateParams,\n SchedulerService\n} from \"~/shared/abstractions.js\";\nimport {\n CreateScheduleCommand,\n DeleteScheduleCommand,\n GetScheduleCommand,\n type SchedulerClient,\n UpdateScheduleCommand\n} from \"@webiny/aws-sdk/client-scheduler\";\nimport { SCHEDULED_ACTION_EVENT_IDENTIFIER } from \"~/constants.js\";\nimport type { IScheduledActionEventPayload } from \"~/createEventHandler.js\";\n\nexport interface ISchedulerConfig {\n lambdaArn: string;\n roleArn: string;\n}\n\n/**\n * AWS EventBridge Scheduler implementation\n *\n * This is the AWS-specific implementation of the cloud-agnostic SchedulerService abstraction.\n *\n * Manages schedules in AWS EventBridge Scheduler for triggering Lambda functions\n * at specified future times.\n */\nexport class EventBridgeSchedulerService implements SchedulerService.Interface {\n public constructor(\n private getClient: (config?: any) => Pick<SchedulerClient, \"send\">,\n private config: ISchedulerConfig\n ) {}\n\n public async create(params: ISchedulerServiceCreateParams): Promise<void> {\n const { id, scheduleFor } = params;\n\n // Validate date is in future\n if (scheduleFor <= new Date()) {\n throw new WebinyError(\n `Cannot create a schedule for \"${id}\" with date in the past`,\n \"INVALID_SCHEDULE_DATE\",\n {\n scheduleFor,\n id\n }\n );\n }\n\n const client = this.getClient();\n\n // Check if schedule already exists (for auto-update logic)\n const exists = await this.exists(id);\n if (exists) {\n return this.update(params);\n }\n\n await client.send(\n new CreateScheduleCommand({\n Name: id,\n ScheduleExpression: this.createScheduleExpression(scheduleFor),\n FlexibleTimeWindow: {\n Mode: \"OFF\"\n },\n Target: {\n Arn: this.config.lambdaArn,\n RoleArn: this.config.roleArn,\n Input: this.createScheduledActionEventInput(params)\n },\n ActionAfterCompletion: \"DELETE\" // Auto-cleanup after execution\n })\n );\n }\n\n public async update(params: ISchedulerServiceUpdateParams): Promise<void> {\n const { id, scheduleFor } = params;\n\n // Validate date is in future\n if (scheduleFor <= new Date()) {\n throw new WebinyError(\n `Cannot update an existing schedule for \"${id}\" with date in the past`,\n \"INVALID_SCHEDULE_DATE\",\n {\n scheduleFor,\n id\n }\n );\n }\n\n const client = this.getClient();\n\n await client.send(\n new UpdateScheduleCommand({\n Name: id,\n ScheduleExpression: this.createScheduleExpression(scheduleFor),\n FlexibleTimeWindow: {\n Mode: \"OFF\"\n },\n Target: {\n Arn: this.config.lambdaArn,\n RoleArn: this.config.roleArn,\n Input: this.createScheduledActionEventInput(params)\n },\n ActionAfterCompletion: \"DELETE\"\n })\n );\n }\n\n public async delete(id: string): Promise<void> {\n const client = this.getClient();\n\n const exists = await this.exists(id);\n if (!exists) {\n throw new WebinyError(`Cannot delete schedule \"${id}\" because it does not exist.`);\n }\n\n try {\n await client.send(new DeleteScheduleCommand({ Name: id }));\n } catch (ex) {\n if (ex.name === \"ResourceNotFoundException\") {\n return;\n }\n throw WebinyError.from(ex);\n }\n }\n\n public async exists(id: string): Promise<boolean> {\n const client = this.getClient();\n\n try {\n await client.send(new GetScheduleCommand({ Name: id }));\n return true;\n } catch (ex) {\n if (ex.name === \"ResourceNotFoundException\") {\n return false;\n }\n throw ex;\n }\n }\n\n private createScheduleExpression(scheduleFor: Date): string {\n // Format: at(YYYY-MM-DDTHH:mm:ss) - EventBridge expects this format\n return `at(${scheduleFor.toISOString().replace(/\\.\\d{3}Z$/, \"\")})`;\n }\n\n private createScheduledActionEventInput(\n params: ISchedulerServiceCreateParams | ISchedulerServiceUpdateParams\n ): string {\n return JSON.stringify({\n [SCHEDULED_ACTION_EVENT_IDENTIFIER]: this.createScheduledActionEventPayload(params)\n });\n }\n\n private createScheduledActionEventPayload(\n params: ISchedulerServiceCreateParams | ISchedulerServiceUpdateParams\n ): IScheduledActionEventPayload {\n const { id, scheduleFor } = params;\n\n return {\n id,\n scheduleFor: scheduleFor.toISOString()\n };\n }\n}\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,eAAe;AAM3C,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K,2BAA2B,EAAE;QACzC;MACJ;MACA,MAAMlC,WAAW,CAACmC,IAAI,CAACF,EAAE,CAAC;IAC9B;EACJ;EAEA,MAAajB,MAAMA,CAACJ,EAAU,EAAoB;IAC9C,MAAMG,MAAM,GAAG,IAAI,CAACP,SAAS,CAAC,CAAC;IAE/B,IAAI;MACA,MAAMO,MAAM,CAACG,IAAI,CAAC,IAAIf,kBAAkB,CAAC;QAAEgB,IAAI,EAAEP;MAAG,CAAC,CAAC,CAAC;MACvD,OAAO,IAAI;IACf,CAAC,CAAC,OAAOqB,EAAE,EAAE;MACT,IAAIA,EAAE,CAACC,IAAI,KAAK,2BAA2B,EAAE;QACzC,OAAO,KAAK;MAChB;MACA,MAAMD,EAAE;IACZ;EACJ;EAEQZ,wBAAwBA,CAACR,WAAiB,EAAU;IACxD;IACA,OAAO,MAAMA,WAAW,CAACuB,WAAW,CAAC,CAAC,CAACC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,GAAG;EACtE;EAEQP,+BAA+BA,CACnCnB,MAAqE,EAC/D;IACN,OAAO2B,IAAI,CAACC,SAAS,CAAC;MAClB,CAAClC,iCAAiC,GAAG,IAAI,CAACmC,iCAAiC,CAAC7B,MAAM;IACtF,CAAC,CAAC;EACN;EAEQ6B,iCAAiCA,CACrC7B,MAAqE,EACzC;IAC5B,MAAM;MAAEC,EAAE;MAAEC;
|
|
1
|
+
{"version":3,"names":["WebinyError","CreateScheduleCommand","DeleteScheduleCommand","GetScheduleCommand","UpdateScheduleCommand","SCHEDULED_ACTION_EVENT_IDENTIFIER","EventBridgeSchedulerService","constructor","getClient","config","create","params","id","scheduleFor","Date","client","exists","update","send","Name","ScheduleExpression","createScheduleExpression","FlexibleTimeWindow","Mode","Target","Arn","lambdaArn","RoleArn","roleArn","Input","createScheduledActionEventInput","ActionAfterCompletion","delete","ex","name","from","toISOString","replace","JSON","stringify","createScheduledActionEventPayload","namespace"],"sources":["EventBridgeSchedulerService.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport {\n type ISchedulerServiceCreateParams,\n type ISchedulerServiceUpdateParams,\n SchedulerService\n} from \"~/shared/abstractions.js\";\nimport {\n CreateScheduleCommand,\n DeleteScheduleCommand,\n GetScheduleCommand,\n type SchedulerClient,\n UpdateScheduleCommand\n} from \"@webiny/aws-sdk/client-scheduler\";\nimport { SCHEDULED_ACTION_EVENT_IDENTIFIER } from \"~/constants.js\";\nimport type { IScheduledActionEventPayload } from \"~/createEventHandler.js\";\n\nexport interface ISchedulerConfig {\n lambdaArn: string;\n roleArn: string;\n}\n\n/**\n * AWS EventBridge Scheduler implementation\n *\n * This is the AWS-specific implementation of the cloud-agnostic SchedulerService abstraction.\n *\n * Manages schedules in AWS EventBridge Scheduler for triggering Lambda functions\n * at specified future times.\n */\nexport class EventBridgeSchedulerService implements SchedulerService.Interface {\n public constructor(\n private getClient: (config?: any) => Pick<SchedulerClient, \"send\">,\n private config: ISchedulerConfig\n ) {}\n\n public async create(params: ISchedulerServiceCreateParams): Promise<void> {\n const { id, scheduleFor } = params;\n\n // Validate date is in future\n if (scheduleFor <= new Date()) {\n throw new WebinyError(\n `Cannot create a schedule for \"${id}\" with date in the past`,\n \"INVALID_SCHEDULE_DATE\",\n {\n scheduleFor,\n id\n }\n );\n }\n\n const client = this.getClient();\n\n // Check if schedule already exists (for auto-update logic)\n const exists = await this.exists(id);\n if (exists) {\n return this.update(params);\n }\n\n await client.send(\n new CreateScheduleCommand({\n Name: id,\n ScheduleExpression: this.createScheduleExpression(scheduleFor),\n FlexibleTimeWindow: {\n Mode: \"OFF\"\n },\n Target: {\n Arn: this.config.lambdaArn,\n RoleArn: this.config.roleArn,\n Input: this.createScheduledActionEventInput(params)\n },\n ActionAfterCompletion: \"DELETE\" // Auto-cleanup after execution\n })\n );\n }\n\n public async update(params: ISchedulerServiceUpdateParams): Promise<void> {\n const { id, scheduleFor } = params;\n\n // Validate date is in future\n if (scheduleFor <= new Date()) {\n throw new WebinyError(\n `Cannot update an existing schedule for \"${id}\" with date in the past`,\n \"INVALID_SCHEDULE_DATE\",\n {\n scheduleFor,\n id\n }\n );\n }\n\n const client = this.getClient();\n\n await client.send(\n new UpdateScheduleCommand({\n Name: id,\n ScheduleExpression: this.createScheduleExpression(scheduleFor),\n FlexibleTimeWindow: {\n Mode: \"OFF\"\n },\n Target: {\n Arn: this.config.lambdaArn,\n RoleArn: this.config.roleArn,\n Input: this.createScheduledActionEventInput(params)\n },\n ActionAfterCompletion: \"DELETE\"\n })\n );\n }\n\n public async delete(id: string): Promise<void> {\n const client = this.getClient();\n\n const exists = await this.exists(id);\n if (!exists) {\n throw new WebinyError(`Cannot delete schedule \"${id}\" because it does not exist.`);\n }\n\n try {\n await client.send(new DeleteScheduleCommand({ Name: id }));\n } catch (ex) {\n if (ex.name === \"ResourceNotFoundException\") {\n return;\n }\n throw WebinyError.from(ex);\n }\n }\n\n public async exists(id: string): Promise<boolean> {\n const client = this.getClient();\n\n try {\n await client.send(new GetScheduleCommand({ Name: id }));\n return true;\n } catch (ex) {\n if (ex.name === \"ResourceNotFoundException\") {\n return false;\n }\n throw ex;\n }\n }\n\n private createScheduleExpression(scheduleFor: Date): string {\n // Format: at(YYYY-MM-DDTHH:mm:ss) - EventBridge expects this format\n return `at(${scheduleFor.toISOString().replace(/\\.\\d{3}Z$/, \"\")})`;\n }\n\n private createScheduledActionEventInput(\n params: ISchedulerServiceCreateParams | ISchedulerServiceUpdateParams\n ): string {\n return JSON.stringify({\n [SCHEDULED_ACTION_EVENT_IDENTIFIER]: this.createScheduledActionEventPayload(params)\n });\n }\n\n private createScheduledActionEventPayload(\n params: ISchedulerServiceCreateParams | ISchedulerServiceUpdateParams\n ): IScheduledActionEventPayload {\n const { id, scheduleFor, namespace } = params;\n\n return {\n id,\n namespace,\n scheduleFor: scheduleFor.toISOString()\n };\n }\n}\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,eAAe;AAM3C,SACIC,qBAAqB,EACrBC,qBAAqB,EACrBC,kBAAkB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AW,CAACmC,IAAI,CAACF,EAAE,CAAC;IAC9B;EACJ;EAEA,MAAajB,MAAMA,CAACJ,EAAU,EAAoB;IAC9C,MAAMG,MAAM,GAAG,IAAI,CAACP,SAAS,CAAC,CAAC;IAE/B,IAAI;MACA,MAAMO,MAAM,CAACG,IAAI,CAAC,IAAIf,kBAAkB,CAAC;QAAEgB,IAAI,EAAEP;MAAG,CAAC,CAAC,CAAC;MACvD,OAAO,IAAI;IACf,CAAC,CAAC,OAAOqB,EAAE,EAAE;MACT,IAAIA,EAAE,CAACC,IAAI,KAAK,2BAA2B,EAAE;QACzC,OAAO,KAAK;MAChB;MACA,MAAMD,EAAE;IACZ;EACJ;EAEQZ,wBAAwBA,CAACR,WAAiB,EAAU;IACxD;IACA,OAAO,MAAMA,WAAW,CAACuB,WAAW,CAAC,CAAC,CAACC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,GAAG;EACtE;EAEQP,+BAA+BA,CACnCnB,MAAqE,EAC/D;IACN,OAAO2B,IAAI,CAACC,SAAS,CAAC;MAClB,CAAClC,iCAAiC,GAAG,IAAI,CAACmC,iCAAiC,CAAC7B,MAAM;IACtF,CAAC,CAAC;EACN;EAEQ6B,iCAAiCA,CACrC7B,MAAqE,EACzC;IAC5B,MAAM;MAAEC,EAAE;MAAEC,WAAW;MAAE4B;IAAU,CAAC,GAAG9B,MAAM;IAE7C,OAAO;MACHC,EAAE;MACF6B,SAAS;MACT5B,WAAW,EAAEA,WAAW,CAACuB,WAAW,CAAC;IACzC,CAAC;EACL;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GraphQLSchemaBuilder } from "@webiny/handler-graphql/features/GraphQLSchemaBuilder/abstractions";
|
|
2
|
+
import { CoreGraphQLSchemaFactory } from "@webiny/handler-graphql/graphql/abstractions.core.js";
|
|
3
|
+
export declare class SchedulerGraphQL implements CoreGraphQLSchemaFactory.Interface {
|
|
4
|
+
execute(builder: GraphQLSchemaBuilder.Interface): Promise<GraphQLSchemaBuilder.Interface>;
|
|
5
|
+
}
|
|
6
|
+
export declare const SchedulerGraphQLFactory: typeof SchedulerGraphQL & {
|
|
7
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/handler-graphql/graphql/abstractions.public").IGraphQLSchemaFactory>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { CoreGraphQLSchemaFactory } from "@webiny/handler-graphql/graphql/abstractions.core.js";
|
|
2
|
+
import { GetScheduledActionUseCase } from "../features/GetScheduledAction/index.js";
|
|
3
|
+
import { ErrorResponse, ListResponse, Response } from "@webiny/handler-graphql/responses.js";
|
|
4
|
+
import { ListScheduledActionsUseCase } from "../features/ListScheduledActions/index.js";
|
|
5
|
+
import { ScheduleActionUseCase } from "../features/ScheduleAction/index.js";
|
|
6
|
+
import { CancelScheduledActionUseCase } from "../features/CancelScheduledAction/index.js";
|
|
7
|
+
import { ScheduledActionNotFoundError } from "../domain/errors.js";
|
|
8
|
+
import { ScheduledActionMapper } from "../domain/ScheduledActionMapper.js";
|
|
9
|
+
import { GetTargetScheduledActionUseCase } from "../features/GetTargetScheduledAction/index.js";
|
|
10
|
+
export class SchedulerGraphQL {
|
|
11
|
+
async execute(builder) {
|
|
12
|
+
builder.addTypeDefs(`
|
|
13
|
+
enum ScheduleRecordType {
|
|
14
|
+
publish
|
|
15
|
+
unpublish
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type ScheduleError {
|
|
19
|
+
message: String!
|
|
20
|
+
code: String
|
|
21
|
+
data: JSON
|
|
22
|
+
stack: String
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
type ScheduleListMeta {
|
|
26
|
+
hasMoreItems: Boolean!
|
|
27
|
+
totalCount: Int!
|
|
28
|
+
cursor: String
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type ScheduleIdentity {
|
|
32
|
+
id: String!
|
|
33
|
+
displayName: String
|
|
34
|
+
type: String
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type ScheduleRecord {
|
|
38
|
+
id: ID!
|
|
39
|
+
targetId: String!
|
|
40
|
+
namespace: String!
|
|
41
|
+
scheduledBy: ScheduleIdentity!
|
|
42
|
+
publishOn: DateTime
|
|
43
|
+
unpublishOn: DateTime
|
|
44
|
+
actionType: ScheduleRecordType!
|
|
45
|
+
title: String!
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type GetScheduledActionResponse {
|
|
49
|
+
data: ScheduleRecord
|
|
50
|
+
error: ScheduleError
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
type ListScheduledActionsResponse {
|
|
54
|
+
data: [ScheduleRecord!]
|
|
55
|
+
error: ScheduleError
|
|
56
|
+
meta: ScheduleListMeta
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
type ScheduleActionResponse {
|
|
60
|
+
data: ScheduleRecord
|
|
61
|
+
error: ScheduleError
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
type CancelScheduledActionResponse {
|
|
65
|
+
data: Boolean
|
|
66
|
+
error: ScheduleError
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
input ListScheduledActionsWhereInput {
|
|
70
|
+
targetId: String
|
|
71
|
+
targetId_in: [String!]
|
|
72
|
+
title: String
|
|
73
|
+
title_contains: String
|
|
74
|
+
title_not_contains: String
|
|
75
|
+
actionType: ScheduleRecordType
|
|
76
|
+
actionType_in: [ScheduleRecordType!]
|
|
77
|
+
scheduledBy: String
|
|
78
|
+
scheduledBy_in: [String!]
|
|
79
|
+
scheduledFor: DateTime
|
|
80
|
+
scheduledFor_gte: DateTime
|
|
81
|
+
scheduledFor_lte: DateTime
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
enum ListScheduledActionsSorter {
|
|
85
|
+
title_ASC
|
|
86
|
+
title_DESC
|
|
87
|
+
scheduledFor_ASC
|
|
88
|
+
scheduledFor_DESC
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
type SchedulerQuery {
|
|
92
|
+
_empty: String
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
type SchedulerMutation {
|
|
96
|
+
_empty: String
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
extend type SchedulerQuery {
|
|
100
|
+
# Fetch scheduled action by its own ID
|
|
101
|
+
getScheduledAction(namespace: String!, id: ID!): GetScheduledActionResponse!
|
|
102
|
+
|
|
103
|
+
# Fetch scheduled action by target ID
|
|
104
|
+
getTargetScheduledAction(namespace: String!, id: ID!): GetScheduledActionResponse!
|
|
105
|
+
|
|
106
|
+
listScheduledActions(
|
|
107
|
+
namespace: String!
|
|
108
|
+
where: ListScheduledActionsWhereInput
|
|
109
|
+
sort: [ListScheduledActionsSorter!]
|
|
110
|
+
limit: Int
|
|
111
|
+
after: String
|
|
112
|
+
): ListScheduledActionsResponse!
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
extend type SchedulerMutation {
|
|
116
|
+
scheduleAction(
|
|
117
|
+
namespace: String!
|
|
118
|
+
targetId: ID!
|
|
119
|
+
immediately: Boolean
|
|
120
|
+
scheduleFor: DateTime
|
|
121
|
+
actionType: ScheduleRecordType!
|
|
122
|
+
): ScheduleActionResponse!
|
|
123
|
+
|
|
124
|
+
cancelScheduledAction(namespace: String!, id: ID!): CancelScheduledActionResponse!
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
extend type Query {
|
|
128
|
+
scheduler: SchedulerQuery
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
extend type Mutation {
|
|
132
|
+
scheduler: SchedulerMutation
|
|
133
|
+
}
|
|
134
|
+
`);
|
|
135
|
+
builder.addResolver({
|
|
136
|
+
path: "Query.scheduler",
|
|
137
|
+
resolver: () => {
|
|
138
|
+
return async () => {
|
|
139
|
+
return {};
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
builder.addResolver({
|
|
144
|
+
path: "Mutation.scheduler",
|
|
145
|
+
resolver: () => {
|
|
146
|
+
return async () => {
|
|
147
|
+
return {};
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
builder.addResolver({
|
|
152
|
+
path: "SchedulerQuery.getScheduledAction",
|
|
153
|
+
dependencies: [GetScheduledActionUseCase],
|
|
154
|
+
resolver: useCase => {
|
|
155
|
+
return async ({
|
|
156
|
+
args
|
|
157
|
+
}) => {
|
|
158
|
+
const result = await useCase.execute(args);
|
|
159
|
+
if (result.isFail()) {
|
|
160
|
+
if (result.error instanceof ScheduledActionNotFoundError) {
|
|
161
|
+
return new Response(null);
|
|
162
|
+
}
|
|
163
|
+
return new ErrorResponse(result.error);
|
|
164
|
+
}
|
|
165
|
+
return new Response(ScheduledActionMapper.toGraphQL(result.value));
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
builder.addResolver({
|
|
170
|
+
path: "SchedulerQuery.getTargetScheduledAction",
|
|
171
|
+
dependencies: [GetTargetScheduledActionUseCase],
|
|
172
|
+
resolver: useCase => {
|
|
173
|
+
return async ({
|
|
174
|
+
args
|
|
175
|
+
}) => {
|
|
176
|
+
const result = await useCase.execute(args);
|
|
177
|
+
if (result.isFail()) {
|
|
178
|
+
if (result.error instanceof ScheduledActionNotFoundError) {
|
|
179
|
+
return new Response(null);
|
|
180
|
+
}
|
|
181
|
+
return new ErrorResponse(result.error);
|
|
182
|
+
}
|
|
183
|
+
return new Response(ScheduledActionMapper.toGraphQL(result.value));
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
builder.addResolver({
|
|
188
|
+
path: "SchedulerQuery.listScheduledActions",
|
|
189
|
+
dependencies: [ListScheduledActionsUseCase],
|
|
190
|
+
resolver: useCase => {
|
|
191
|
+
return async ({
|
|
192
|
+
args
|
|
193
|
+
}) => {
|
|
194
|
+
const result = await useCase.execute({
|
|
195
|
+
...args,
|
|
196
|
+
where: {
|
|
197
|
+
...args.where,
|
|
198
|
+
namespace: args.namespace
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
if (result.isFail()) {
|
|
202
|
+
return new ErrorResponse(result.error);
|
|
203
|
+
}
|
|
204
|
+
return new ListResponse(result.value.items.map(item => {
|
|
205
|
+
return ScheduledActionMapper.toGraphQL(item);
|
|
206
|
+
}), result.value.meta);
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
builder.addResolver({
|
|
211
|
+
path: "SchedulerMutation.scheduleAction",
|
|
212
|
+
dependencies: [ScheduleActionUseCase],
|
|
213
|
+
resolver: useCase => {
|
|
214
|
+
return async ({
|
|
215
|
+
args
|
|
216
|
+
}) => {
|
|
217
|
+
const result = await useCase.execute(args);
|
|
218
|
+
if (result.isFail()) {
|
|
219
|
+
return new ErrorResponse(result.error);
|
|
220
|
+
}
|
|
221
|
+
return new Response(ScheduledActionMapper.toGraphQL(result.value));
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
builder.addResolver({
|
|
226
|
+
path: "SchedulerMutation.cancelScheduledAction",
|
|
227
|
+
dependencies: [CancelScheduledActionUseCase],
|
|
228
|
+
resolver: useCase => {
|
|
229
|
+
return async ({
|
|
230
|
+
args
|
|
231
|
+
}) => {
|
|
232
|
+
const result = await useCase.execute(args);
|
|
233
|
+
if (result.isFail()) {
|
|
234
|
+
return new ErrorResponse(result.error);
|
|
235
|
+
}
|
|
236
|
+
return new Response(result.value);
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
return builder;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
export const SchedulerGraphQLFactory = CoreGraphQLSchemaFactory.createImplementation({
|
|
244
|
+
dependencies: [],
|
|
245
|
+
implementation: SchedulerGraphQL
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
//# sourceMappingURL=SchedulerGraphQLFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CoreGraphQLSchemaFactory","GetScheduledActionUseCase","ErrorResponse","ListResponse","Response","ListScheduledActionsUseCase","ScheduleActionUseCase","CancelScheduledActionUseCase","ScheduledActionNotFoundError","ScheduledActionMapper","GetTargetScheduledActionUseCase","SchedulerGraphQL","execute","builder","addTypeDefs","addResolver","path","resolver","dependencies","useCase","args","result","isFail","error","toGraphQL","value","where","namespace","items","map","item","meta","SchedulerGraphQLFactory","createImplementation","implementation"],"sources":["SchedulerGraphQLFactory.ts"],"sourcesContent":["import { GraphQLSchemaBuilder } from \"@webiny/handler-graphql/features/GraphQLSchemaBuilder/abstractions\";\nimport { CoreGraphQLSchemaFactory } from \"@webiny/handler-graphql/graphql/abstractions.core.js\";\nimport { GetScheduledActionUseCase } from \"~/features/GetScheduledAction/index.js\";\nimport { ErrorResponse, ListResponse, Response } from \"@webiny/handler-graphql/responses.js\";\nimport { ListScheduledActionsUseCase } from \"~/features/ListScheduledActions/index.js\";\nimport { ScheduleActionUseCase } from \"~/features/ScheduleAction/index.js\";\nimport { CancelScheduledActionUseCase } from \"~/features/CancelScheduledAction/index.js\";\nimport { ScheduledActionNotFoundError } from \"~/domain/errors.js\";\nimport type { Identity, ScheduledActionType } from \"~/shared/abstractions.js\";\nimport { ScheduledActionMapper } from \"~/domain/ScheduledActionMapper.js\";\nimport { GetTargetScheduledActionUseCase } from \"~/features/GetTargetScheduledAction/index.js\";\n\ninterface IListScheduledActionsArgs extends ListScheduledActionsUseCase.Params {\n namespace: string;\n}\n\ninterface IScheduleRecordOutput {\n id: string;\n targetId: string;\n namespace: string;\n scheduledBy: Identity;\n publishOn: Date | null;\n unpublishOn: Date | null;\n actionType: ScheduledActionType;\n title: string;\n}\n\nexport class SchedulerGraphQL implements CoreGraphQLSchemaFactory.Interface {\n public async execute(\n builder: GraphQLSchemaBuilder.Interface\n ): Promise<GraphQLSchemaBuilder.Interface> {\n builder.addTypeDefs(`\n enum ScheduleRecordType {\n publish\n unpublish\n }\n \n type ScheduleError {\n message: String!\n code: String\n data: JSON\n stack: String\n }\n \n type ScheduleListMeta {\n hasMoreItems: Boolean!\n totalCount: Int!\n cursor: String\n }\n \n type ScheduleIdentity {\n id: String!\n displayName: String\n type: String\n }\n \n type ScheduleRecord {\n id: ID!\n targetId: String!\n namespace: String!\n scheduledBy: ScheduleIdentity!\n publishOn: DateTime\n unpublishOn: DateTime\n actionType: ScheduleRecordType!\n title: String!\n }\n\n type GetScheduledActionResponse {\n data: ScheduleRecord\n error: ScheduleError\n }\n\n type ListScheduledActionsResponse {\n data: [ScheduleRecord!]\n error: ScheduleError\n meta: ScheduleListMeta\n }\n\n type ScheduleActionResponse {\n data: ScheduleRecord\n error: ScheduleError\n }\n\n type CancelScheduledActionResponse {\n data: Boolean\n error: ScheduleError\n }\n\n input ListScheduledActionsWhereInput {\n targetId: String\n targetId_in: [String!]\n title: String\n title_contains: String\n title_not_contains: String\n actionType: ScheduleRecordType\n actionType_in: [ScheduleRecordType!]\n scheduledBy: String\n scheduledBy_in: [String!]\n scheduledFor: DateTime\n scheduledFor_gte: DateTime\n scheduledFor_lte: DateTime\n }\n\n enum ListScheduledActionsSorter {\n title_ASC\n title_DESC\n scheduledFor_ASC\n scheduledFor_DESC\n }\n \n type SchedulerQuery {\n _empty: String\n }\n \n type SchedulerMutation {\n _empty: String\n }\n\n extend type SchedulerQuery {\n # Fetch scheduled action by its own ID\n getScheduledAction(namespace: String!, id: ID!): GetScheduledActionResponse!\n \n # Fetch scheduled action by target ID\n getTargetScheduledAction(namespace: String!, id: ID!): GetScheduledActionResponse!\n \n listScheduledActions(\n namespace: String!\n where: ListScheduledActionsWhereInput\n sort: [ListScheduledActionsSorter!]\n limit: Int\n after: String\n ): ListScheduledActionsResponse!\n }\n\n extend type SchedulerMutation {\n scheduleAction(\n namespace: String!\n targetId: ID!\n immediately: Boolean\n scheduleFor: DateTime\n actionType: ScheduleRecordType!\n ): ScheduleActionResponse!\n \n cancelScheduledAction(namespace: String!, id: ID!): CancelScheduledActionResponse!\n }\n \n extend type Query {\n scheduler: SchedulerQuery\n }\n \n extend type Mutation {\n scheduler: SchedulerMutation\n }\n `);\n\n builder.addResolver({\n path: \"Query.scheduler\",\n resolver: () => {\n return async () => {\n return {};\n };\n }\n });\n builder.addResolver({\n path: \"Mutation.scheduler\",\n resolver: () => {\n return async () => {\n return {};\n };\n }\n });\n\n builder.addResolver<GetScheduledActionUseCase.Params>({\n path: \"SchedulerQuery.getScheduledAction\",\n dependencies: [GetScheduledActionUseCase],\n resolver: (useCase: GetScheduledActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n if (result.error instanceof ScheduledActionNotFoundError) {\n return new Response(null);\n }\n return new ErrorResponse(result.error);\n }\n\n return new Response<IScheduleRecordOutput>(\n ScheduledActionMapper.toGraphQL(result.value)\n );\n };\n }\n });\n\n builder.addResolver<GetTargetScheduledActionUseCase.Params>({\n path: \"SchedulerQuery.getTargetScheduledAction\",\n dependencies: [GetTargetScheduledActionUseCase],\n resolver: (useCase: GetTargetScheduledActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n if (result.error instanceof ScheduledActionNotFoundError) {\n return new Response(null);\n }\n return new ErrorResponse(result.error);\n }\n\n return new Response<IScheduleRecordOutput>(\n ScheduledActionMapper.toGraphQL(result.value)\n );\n };\n }\n });\n\n builder.addResolver<IListScheduledActionsArgs>({\n path: \"SchedulerQuery.listScheduledActions\",\n dependencies: [ListScheduledActionsUseCase],\n resolver: (useCase: ListScheduledActionsUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute({\n ...args,\n where: {\n ...args.where,\n namespace: args.namespace\n }\n });\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new ListResponse<IScheduleRecordOutput>(\n result.value.items.map(item => {\n return ScheduledActionMapper.toGraphQL(item);\n }),\n result.value.meta\n );\n };\n }\n });\n\n builder.addResolver<ScheduleActionUseCase.Params>({\n path: \"SchedulerMutation.scheduleAction\",\n dependencies: [ScheduleActionUseCase],\n resolver: (useCase: ScheduleActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response<IScheduleRecordOutput>(\n ScheduledActionMapper.toGraphQL(result.value)\n );\n };\n }\n });\n\n builder.addResolver<CancelScheduledActionUseCase.Params>({\n path: \"SchedulerMutation.cancelScheduledAction\",\n dependencies: [CancelScheduledActionUseCase],\n resolver: (useCase: CancelScheduledActionUseCase.Interface) => {\n return async ({ args }) => {\n const result = await useCase.execute(args);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return new Response<void>(result.value);\n };\n }\n });\n\n return builder;\n }\n}\n\nexport const SchedulerGraphQLFactory = CoreGraphQLSchemaFactory.createImplementation({\n dependencies: [],\n implementation: SchedulerGraphQL\n});\n"],"mappings":"AACA,SAASA,wBAAwB,QAAQ,sDAAsD;AAC/F,SAASC,yBAAyB;AAClC,SAASC,aAAa,EAAEC,YAAY,EAAEC,QAAQ,QAAQ,sCAAsC;AAC5F,SAASC,2BAA2B;AACpC,SAASC,qBAAqB;AAC9B,SAASC,4BAA4B;AACrC,SAASC,4BAA4B;AAErC,SAASC,qBAAqB;AAC9B,SAASC,+BAA+B;AAiBxC,OAAO,MAAMC,gBAAgB,CAA+C;EACxE,MAAaC,OAAOA,CAChBC,OAAuC,EACA;IACvCA,OAAO,CAACC,WAAW,CAAC;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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from "./SchedulerGraphQLFactory.js";
|
package/graphql/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SchedulerGraphQLFactory"],"sources":["index.ts"],"sourcesContent":["export { SchedulerGraphQLFactory } from \"./SchedulerGraphQLFactory.js\";\n"],"mappings":"AAAA,SAASA,uBAAuB","ignoreList":[]}
|
package/index.d.ts
CHANGED
|
@@ -2,9 +2,3 @@ export { SchedulerService, ScheduledActionModel, ScheduledActionHandler } from "
|
|
|
2
2
|
export type { IScheduledAction } from "./shared/abstractions.js";
|
|
3
3
|
export { ScheduledActionId } from "./domain/ScheduledActionId.js";
|
|
4
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";
|
package/index.js
CHANGED
|
@@ -2,12 +2,4 @@ export { SchedulerService, ScheduledActionModel, ScheduledActionHandler } from "
|
|
|
2
2
|
export { ScheduledActionId } from "./domain/ScheduledActionId.js";
|
|
3
3
|
export { createScheduler } from "./createScheduler.js";
|
|
4
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
5
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SchedulerService","ScheduledActionModel","ScheduledActionHandler","ScheduledActionId","createScheduler"],"sources":["index.ts"],"sourcesContent":["export {\n SchedulerService,\n ScheduledActionModel,\n ScheduledActionHandler\n} from \"./shared/abstractions.js\";\n\nexport type { IScheduledAction } from \"./shared/abstractions.js\";\n\nexport { ScheduledActionId } from \"./domain/ScheduledActionId.js\";\nexport { createScheduler } from \"./createScheduler.js\";\n
|
|
1
|
+
{"version":3,"names":["SchedulerService","ScheduledActionModel","ScheduledActionHandler","ScheduledActionId","createScheduler"],"sources":["index.ts"],"sourcesContent":["export {\n SchedulerService,\n ScheduledActionModel,\n ScheduledActionHandler\n} from \"./shared/abstractions.js\";\n\nexport type { IScheduledAction } from \"./shared/abstractions.js\";\n\nexport { ScheduledActionId } from \"./domain/ScheduledActionId.js\";\nexport { createScheduler } from \"./createScheduler.js\";\n"],"mappings":"AAAA,SACIA,gBAAgB,EAChBC,oBAAoB,EACpBC,sBAAsB;AAK1B,SAASC,iBAAiB;AAC1B,SAASC,eAAe","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-scheduler",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.c27f4d8a31",
|
|
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": "0.0.0-unstable.
|
|
27
|
-
"@webiny/api-core": "0.0.0-unstable.
|
|
28
|
-
"@webiny/api-headless-cms": "0.0.0-unstable.
|
|
29
|
-
"@webiny/aws-sdk": "0.0.0-unstable.
|
|
30
|
-
"@webiny/error": "0.0.0-unstable.
|
|
31
|
-
"@webiny/feature": "0.0.0-unstable.
|
|
32
|
-
"@webiny/handler-graphql": "0.0.0-unstable.
|
|
33
|
-
"@webiny/plugins": "0.0.0-unstable.
|
|
34
|
-
"@webiny/utils": "0.0.0-unstable.
|
|
35
|
-
"zod": "3.
|
|
18
|
+
"@webiny/api": "0.0.0-unstable.c27f4d8a31",
|
|
19
|
+
"@webiny/api-core": "0.0.0-unstable.c27f4d8a31",
|
|
20
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.c27f4d8a31",
|
|
21
|
+
"@webiny/aws-sdk": "0.0.0-unstable.c27f4d8a31",
|
|
22
|
+
"@webiny/error": "0.0.0-unstable.c27f4d8a31",
|
|
23
|
+
"@webiny/feature": "0.0.0-unstable.c27f4d8a31",
|
|
24
|
+
"@webiny/handler-graphql": "0.0.0-unstable.c27f4d8a31",
|
|
25
|
+
"@webiny/plugins": "0.0.0-unstable.c27f4d8a31",
|
|
26
|
+
"@webiny/utils": "0.0.0-unstable.c27f4d8a31",
|
|
27
|
+
"zod": "4.3.6"
|
|
36
28
|
},
|
|
37
29
|
"devDependencies": {
|
|
38
|
-
"@webiny/build-tools": "0.0.0-unstable.
|
|
39
|
-
"@webiny/db-dynamodb": "0.0.0-unstable.
|
|
40
|
-
"@webiny/handler": "0.0.0-unstable.
|
|
41
|
-
"@webiny/handler-aws": "0.0.0-unstable.
|
|
42
|
-
"@webiny/project-utils": "0.0.0-unstable.
|
|
43
|
-
"@webiny/
|
|
30
|
+
"@webiny/build-tools": "0.0.0-unstable.c27f4d8a31",
|
|
31
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.c27f4d8a31",
|
|
32
|
+
"@webiny/handler": "0.0.0-unstable.c27f4d8a31",
|
|
33
|
+
"@webiny/handler-aws": "0.0.0-unstable.c27f4d8a31",
|
|
34
|
+
"@webiny/project-utils": "0.0.0-unstable.c27f4d8a31",
|
|
35
|
+
"@webiny/testing": "0.0.0-unstable.c27f4d8a31",
|
|
36
|
+
"@webiny/wcp": "0.0.0-unstable.c27f4d8a31",
|
|
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": "
|
|
41
|
+
"vitest": "4.0.18"
|
|
49
42
|
},
|
|
50
43
|
"publishConfig": {
|
|
51
44
|
"access": "public",
|
|
52
45
|
"directory": "dist"
|
|
53
46
|
},
|
|
54
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "c27f4d8a31c3af1570817797441855292b6c1f20"
|
|
55
48
|
}
|
package/shared/abstractions.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
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";
|
|
3
4
|
/**
|
|
4
5
|
* Identity type - represents who scheduled an action
|
|
5
6
|
*/
|
|
@@ -8,19 +9,25 @@ export interface Identity {
|
|
|
8
9
|
type: string;
|
|
9
10
|
displayName: string;
|
|
10
11
|
}
|
|
12
|
+
export type ScheduledActionType = "publish" | "unpublish";
|
|
11
13
|
/**
|
|
12
14
|
* Scheduled Action Record - The data stored for a scheduled action
|
|
13
15
|
*/
|
|
14
|
-
export interface
|
|
15
|
-
id: string;
|
|
16
|
+
export interface IScheduledActionEntryValues<T> {
|
|
16
17
|
namespace: string;
|
|
17
|
-
actionType:
|
|
18
|
+
actionType: ScheduledActionType;
|
|
18
19
|
targetId: string;
|
|
19
20
|
scheduledBy: Identity;
|
|
20
21
|
scheduledFor: string;
|
|
21
|
-
title
|
|
22
|
+
title: string;
|
|
22
23
|
payload: T;
|
|
23
|
-
error
|
|
24
|
+
error: string | undefined;
|
|
25
|
+
}
|
|
26
|
+
export interface IScheduledActionEntry<T extends GenericRecord = GenericRecord> extends CmsEntry<IScheduledActionEntryValues<T>> {
|
|
27
|
+
}
|
|
28
|
+
export interface IScheduledAction<T extends GenericRecord = GenericRecord> extends Omit<IScheduledActionEntryValues<T>, "scheduledFor"> {
|
|
29
|
+
id: string;
|
|
30
|
+
scheduledFor: Date;
|
|
24
31
|
}
|
|
25
32
|
/**
|
|
26
33
|
* ScheduledActionHandler - Similar to EventHandler pattern
|
|
@@ -35,7 +42,7 @@ export interface IScheduledActionHandler {
|
|
|
35
42
|
* @param namespace - Resource scope (e.g., "Cms/Entry/Article")
|
|
36
43
|
* @param actionType - Operation type (e.g., "Publish")
|
|
37
44
|
*/
|
|
38
|
-
canHandle(namespace: string, actionType:
|
|
45
|
+
canHandle(namespace: string, actionType: ScheduledActionType): boolean;
|
|
39
46
|
/**
|
|
40
47
|
* Executes the scheduled action
|
|
41
48
|
*/
|
|
@@ -52,10 +59,12 @@ export declare namespace ScheduledActionHandler {
|
|
|
52
59
|
*/
|
|
53
60
|
export interface ISchedulerServiceCreateParams {
|
|
54
61
|
id: string;
|
|
62
|
+
namespace: string;
|
|
55
63
|
scheduleFor: Date;
|
|
56
64
|
}
|
|
57
65
|
export interface ISchedulerServiceUpdateParams {
|
|
58
66
|
id: string;
|
|
67
|
+
namespace: string;
|
|
59
68
|
scheduleFor: Date;
|
|
60
69
|
}
|
|
61
70
|
export interface ISchedulerService {
|