@webiny/api-scheduler 6.3.0 → 6.4.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.
- package/constants.js +11 -14
- package/constants.js.map +1 -1
- package/context.d.ts +1 -1
- package/context.js +29 -29
- package/context.js.map +1 -1
- package/createEventHandler.js +26 -39
- package/createEventHandler.js.map +1 -1
- package/createScheduler.js +5 -7
- package/createScheduler.js.map +1 -1
- package/domain/SchedulePrivateModel.js +25 -22
- package/domain/SchedulePrivateModel.js.map +1 -1
- package/domain/ScheduledActionId.js +12 -4
- package/domain/ScheduledActionId.js.map +1 -1
- package/domain/ScheduledActionIdWithVersion.js +5 -6
- package/domain/ScheduledActionIdWithVersion.js.map +1 -1
- package/domain/ScheduledActionMapper.js +31 -32
- package/domain/ScheduledActionMapper.js.map +1 -1
- package/domain/errors.js +52 -80
- package/domain/errors.js.map +1 -1
- package/domain/isValidDate.js +4 -9
- package/domain/isValidDate.js.map +1 -1
- package/domain/permissionsSchema.js +14 -8
- package/domain/permissionsSchema.js.map +1 -1
- package/exports/api/scheduler.js +1 -3
- package/features/CancelScheduledAction/CancelScheduledActionUseCase.js +42 -67
- package/features/CancelScheduledAction/CancelScheduledActionUseCase.js.map +1 -1
- package/features/CancelScheduledAction/abstractions.js +2 -11
- package/features/CancelScheduledAction/abstractions.js.map +1 -1
- package/features/CancelScheduledAction/feature.js +6 -12
- package/features/CancelScheduledAction/feature.js.map +1 -1
- package/features/CancelScheduledAction/index.js +0 -2
- package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.js +65 -92
- package/features/ExecuteScheduledAction/ExecuteScheduledActionUseCase.js.map +1 -1
- package/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.js +21 -25
- package/features/ExecuteScheduledAction/ScheduledActionHandlerComposite.js.map +1 -1
- package/features/ExecuteScheduledAction/abstractions.js +12 -37
- package/features/ExecuteScheduledAction/abstractions.js.map +1 -1
- package/features/ExecuteScheduledAction/feature.js +7 -13
- package/features/ExecuteScheduledAction/feature.js.map +1 -1
- package/features/ExecuteScheduledAction/index.js +0 -2
- package/features/GetScheduledAction/GetScheduledActionUseCase.js +33 -51
- package/features/GetScheduledAction/GetScheduledActionUseCase.js.map +1 -1
- package/features/GetScheduledAction/abstractions.js +2 -12
- package/features/GetScheduledAction/abstractions.js.map +1 -1
- package/features/GetScheduledAction/feature.js +6 -12
- package/features/GetScheduledAction/feature.js.map +1 -1
- package/features/GetScheduledAction/index.js +0 -2
- package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js +46 -68
- package/features/GetTargetScheduledAction/GetTargetScheduledActionUseCase.js.map +1 -1
- package/features/GetTargetScheduledAction/abstractions.js +2 -1
- package/features/GetTargetScheduledAction/abstractions.js.map +1 -1
- package/features/GetTargetScheduledAction/feature.js +6 -12
- package/features/GetTargetScheduledAction/feature.js.map +1 -1
- package/features/GetTargetScheduledAction/index.js +0 -2
- package/features/ListScheduledActions/ListScheduledActionsUseCase.js +48 -63
- package/features/ListScheduledActions/ListScheduledActionsUseCase.js.map +1 -1
- package/features/ListScheduledActions/abstractions.js +2 -13
- package/features/ListScheduledActions/abstractions.js.map +1 -1
- package/features/ListScheduledActions/feature.js +6 -12
- package/features/ListScheduledActions/feature.js.map +1 -1
- package/features/ListScheduledActions/index.js +0 -2
- package/features/NamespaceHandler/NamespaceHandlerExecutioner.js +18 -17
- package/features/NamespaceHandler/NamespaceHandlerExecutioner.js.map +1 -1
- package/features/NamespaceHandler/abstractions.js +3 -13
- package/features/NamespaceHandler/abstractions.js.map +1 -1
- package/features/NamespaceHandler/index.js +0 -2
- package/features/ScheduleAction/ScheduleActionUseCase.js +144 -200
- package/features/ScheduleAction/ScheduleActionUseCase.js.map +1 -1
- package/features/ScheduleAction/abstractions.js +2 -11
- package/features/ScheduleAction/abstractions.js.map +1 -1
- package/features/ScheduleAction/feature.js +6 -12
- package/features/ScheduleAction/feature.js.map +1 -1
- package/features/ScheduleAction/index.js +0 -2
- package/features/SchedulerFeature.js +11 -19
- package/features/SchedulerFeature.js.map +1 -1
- package/features/SchedulerService/EventBridgeSchedulerService.js +85 -121
- package/features/SchedulerService/EventBridgeSchedulerService.js.map +1 -1
- package/features/SchedulerService/VoidSchedulerService.js +17 -24
- package/features/SchedulerService/VoidSchedulerService.js.map +1 -1
- package/features/permissions/abstractions.js +2 -1
- package/features/permissions/abstractions.js.map +1 -1
- package/features/permissions/feature.js +2 -1
- package/features/permissions/feature.js.map +1 -1
- package/graphql/SchedulerGraphQLFactory.js +84 -113
- package/graphql/SchedulerGraphQLFactory.js.map +1 -1
- package/graphql/index.js +0 -2
- package/index.js +1 -3
- package/manifest.js +26 -30
- package/manifest.js.map +1 -1
- package/package.json +20 -20
- package/shared/abstractions.js +4 -32
- package/shared/abstractions.js.map +1 -1
- package/exports/api/scheduler.js.map +0 -1
- package/features/CancelScheduledAction/index.js.map +0 -1
- package/features/ExecuteScheduledAction/index.js.map +0 -1
- package/features/GetScheduledAction/index.js.map +0 -1
- package/features/GetTargetScheduledAction/index.js.map +0 -1
- package/features/ListScheduledActions/index.js.map +0 -1
- package/features/NamespaceHandler/index.js.map +0 -1
- package/features/ScheduleAction/index.js.map +0 -1
- package/graphql/index.js.map +0 -1
- package/index.js.map +0 -1
|
@@ -1,133 +1,97 @@
|
|
|
1
1
|
import { WebinyError } from "@webiny/error";
|
|
2
2
|
import { CreateScheduleCommand, DeleteScheduleCommand, GetScheduleCommand, UpdateScheduleCommand } from "@webiny/aws-sdk/client-scheduler/index.js";
|
|
3
3
|
import { SCHEDULED_ACTION_EVENT_IDENTIFIER } from "../../constants.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
* Manages schedules in AWS EventBridge Scheduler for triggering Lambda functions
|
|
10
|
-
* at specified future times.
|
|
11
|
-
*/
|
|
12
|
-
export class EventBridgeSchedulerService {
|
|
13
|
-
constructor(getClient, config) {
|
|
14
|
-
this.getClient = getClient;
|
|
15
|
-
this.config = config;
|
|
16
|
-
}
|
|
17
|
-
async create(params) {
|
|
18
|
-
const {
|
|
19
|
-
id,
|
|
20
|
-
scheduleFor
|
|
21
|
-
} = params;
|
|
22
|
-
|
|
23
|
-
// Validate date is in future
|
|
24
|
-
if (scheduleFor <= new Date()) {
|
|
25
|
-
throw new WebinyError(`Cannot create a schedule for "${id}" with date in the past`, "INVALID_SCHEDULE_DATE", {
|
|
26
|
-
scheduleFor,
|
|
27
|
-
id
|
|
28
|
-
});
|
|
4
|
+
class EventBridgeSchedulerService {
|
|
5
|
+
constructor(getClient, config){
|
|
6
|
+
this.getClient = getClient;
|
|
7
|
+
this.config = config;
|
|
29
8
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
9
|
+
async create(params) {
|
|
10
|
+
const { id, scheduleFor } = params;
|
|
11
|
+
if (scheduleFor <= new Date()) throw new WebinyError(`Cannot create a schedule for "${id}" with date in the past`, "INVALID_SCHEDULE_DATE", {
|
|
12
|
+
scheduleFor,
|
|
13
|
+
id
|
|
14
|
+
});
|
|
15
|
+
const client = this.getClient();
|
|
16
|
+
const exists = await this.exists(id);
|
|
17
|
+
if (exists) return this.update(params);
|
|
18
|
+
await client.send(new CreateScheduleCommand({
|
|
19
|
+
Name: id,
|
|
20
|
+
ScheduleExpression: this.createScheduleExpression(scheduleFor),
|
|
21
|
+
FlexibleTimeWindow: {
|
|
22
|
+
Mode: "OFF"
|
|
23
|
+
},
|
|
24
|
+
Target: {
|
|
25
|
+
Arn: this.config.lambdaArn,
|
|
26
|
+
RoleArn: this.config.roleArn,
|
|
27
|
+
Input: this.createScheduledActionEventInput(params)
|
|
28
|
+
},
|
|
29
|
+
ActionAfterCompletion: "DELETE"
|
|
30
|
+
}));
|
|
36
31
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
id
|
|
62
|
-
|
|
32
|
+
async update(params) {
|
|
33
|
+
const { id, scheduleFor } = params;
|
|
34
|
+
if (scheduleFor <= new Date()) throw new WebinyError(`Cannot update an existing schedule for "${id}" with date in the past`, "INVALID_SCHEDULE_DATE", {
|
|
35
|
+
scheduleFor,
|
|
36
|
+
id
|
|
37
|
+
});
|
|
38
|
+
const client = this.getClient();
|
|
39
|
+
await client.send(new UpdateScheduleCommand({
|
|
40
|
+
Name: id,
|
|
41
|
+
ScheduleExpression: this.createScheduleExpression(scheduleFor),
|
|
42
|
+
FlexibleTimeWindow: {
|
|
43
|
+
Mode: "OFF"
|
|
44
|
+
},
|
|
45
|
+
Target: {
|
|
46
|
+
Arn: this.config.lambdaArn,
|
|
47
|
+
RoleArn: this.config.roleArn,
|
|
48
|
+
Input: this.createScheduledActionEventInput(params)
|
|
49
|
+
},
|
|
50
|
+
ActionAfterCompletion: "DELETE"
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
async delete(id) {
|
|
54
|
+
const client = this.getClient();
|
|
55
|
+
const exists = await this.exists(id);
|
|
56
|
+
if (!exists) throw new WebinyError(`Cannot delete schedule "${id}" because it does not exist.`);
|
|
57
|
+
try {
|
|
58
|
+
await client.send(new DeleteScheduleCommand({
|
|
59
|
+
Name: id
|
|
60
|
+
}));
|
|
61
|
+
} catch (ex) {
|
|
62
|
+
if ("ResourceNotFoundException" === ex.name) return;
|
|
63
|
+
throw WebinyError.from(ex);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async exists(id) {
|
|
67
|
+
const client = this.getClient();
|
|
68
|
+
try {
|
|
69
|
+
await client.send(new GetScheduleCommand({
|
|
70
|
+
Name: id
|
|
71
|
+
}));
|
|
72
|
+
return true;
|
|
73
|
+
} catch (ex) {
|
|
74
|
+
if ("ResourceNotFoundException" === ex.name) return false;
|
|
75
|
+
throw ex;
|
|
76
|
+
}
|
|
63
77
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
Name: id,
|
|
67
|
-
ScheduleExpression: this.createScheduleExpression(scheduleFor),
|
|
68
|
-
FlexibleTimeWindow: {
|
|
69
|
-
Mode: "OFF"
|
|
70
|
-
},
|
|
71
|
-
Target: {
|
|
72
|
-
Arn: this.config.lambdaArn,
|
|
73
|
-
RoleArn: this.config.roleArn,
|
|
74
|
-
Input: this.createScheduledActionEventInput(params)
|
|
75
|
-
},
|
|
76
|
-
ActionAfterCompletion: "DELETE"
|
|
77
|
-
}));
|
|
78
|
-
}
|
|
79
|
-
async delete(id) {
|
|
80
|
-
const client = this.getClient();
|
|
81
|
-
const exists = await this.exists(id);
|
|
82
|
-
if (!exists) {
|
|
83
|
-
throw new WebinyError(`Cannot delete schedule "${id}" because it does not exist.`);
|
|
78
|
+
createScheduleExpression(scheduleFor) {
|
|
79
|
+
return `at(${scheduleFor.toISOString().replace(/\.\d{3}Z$/, "")})`;
|
|
84
80
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
} catch (ex) {
|
|
90
|
-
if (ex.name === "ResourceNotFoundException") {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
throw WebinyError.from(ex);
|
|
81
|
+
createScheduledActionEventInput(params) {
|
|
82
|
+
return JSON.stringify({
|
|
83
|
+
[SCHEDULED_ACTION_EVENT_IDENTIFIER]: this.createScheduledActionEventPayload(params)
|
|
84
|
+
});
|
|
94
85
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return true;
|
|
103
|
-
} catch (ex) {
|
|
104
|
-
if (ex.name === "ResourceNotFoundException") {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
throw ex;
|
|
86
|
+
createScheduledActionEventPayload(params) {
|
|
87
|
+
const { id, scheduleFor, namespace } = params;
|
|
88
|
+
return {
|
|
89
|
+
id,
|
|
90
|
+
namespace,
|
|
91
|
+
scheduleFor: scheduleFor.toISOString()
|
|
92
|
+
};
|
|
108
93
|
}
|
|
109
|
-
}
|
|
110
|
-
createScheduleExpression(scheduleFor) {
|
|
111
|
-
// Format: at(YYYY-MM-DDTHH:mm:ss) - EventBridge expects this format
|
|
112
|
-
return `at(${scheduleFor.toISOString().replace(/\.\d{3}Z$/, "")})`;
|
|
113
|
-
}
|
|
114
|
-
createScheduledActionEventInput(params) {
|
|
115
|
-
return JSON.stringify({
|
|
116
|
-
[SCHEDULED_ACTION_EVENT_IDENTIFIER]: this.createScheduledActionEventPayload(params)
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
createScheduledActionEventPayload(params) {
|
|
120
|
-
const {
|
|
121
|
-
id,
|
|
122
|
-
scheduleFor,
|
|
123
|
-
namespace
|
|
124
|
-
} = params;
|
|
125
|
-
return {
|
|
126
|
-
id,
|
|
127
|
-
namespace,
|
|
128
|
-
scheduleFor: scheduleFor.toISOString()
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
94
|
}
|
|
95
|
+
export { EventBridgeSchedulerService };
|
|
132
96
|
|
|
133
97
|
//# sourceMappingURL=EventBridgeSchedulerService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/SchedulerService/EventBridgeSchedulerService.js","sources":["../../../src/features/SchedulerService/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/index.js\";\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"],"names":["EventBridgeSchedulerService","getClient","config","params","id","scheduleFor","Date","WebinyError","client","exists","CreateScheduleCommand","UpdateScheduleCommand","DeleteScheduleCommand","ex","GetScheduleCommand","JSON","SCHEDULED_ACTION_EVENT_IDENTIFIER","namespace"],"mappings":";;;AA6BO,MAAMA;IACT,YACYC,SAA0D,EAC1DC,MAAwB,CAClC;aAFUD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VoidSchedulerService {
|
|
2
|
+
constructor(callbacks){
|
|
3
|
+
this.callbacks = callbacks;
|
|
8
4
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (!this.callbacks?.update) {
|
|
13
|
-
return;
|
|
5
|
+
async create(params) {
|
|
6
|
+
if (!this.callbacks?.create) return;
|
|
7
|
+
return this.callbacks?.create(params);
|
|
14
8
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (!this.callbacks?.delete) {
|
|
19
|
-
return;
|
|
9
|
+
async update(params) {
|
|
10
|
+
if (!this.callbacks?.update) return;
|
|
11
|
+
return this.callbacks?.update(params);
|
|
20
12
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
async delete(id) {
|
|
14
|
+
if (!this.callbacks?.delete) return;
|
|
15
|
+
return this.callbacks?.delete(id);
|
|
16
|
+
}
|
|
17
|
+
async exists(id) {
|
|
18
|
+
if (!this.callbacks?.exists) return false;
|
|
19
|
+
return this.callbacks?.exists(id);
|
|
26
20
|
}
|
|
27
|
-
return this.callbacks?.exists(id);
|
|
28
|
-
}
|
|
29
21
|
}
|
|
22
|
+
export { VoidSchedulerService };
|
|
30
23
|
|
|
31
24
|
//# sourceMappingURL=VoidSchedulerService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/SchedulerService/VoidSchedulerService.js","sources":["../../../src/features/SchedulerService/VoidSchedulerService.ts"],"sourcesContent":["import {\n type ISchedulerServiceCreateParams,\n type ISchedulerServiceUpdateParams,\n SchedulerService\n} from \"~/shared/abstractions.js\";\n\nexport interface IVoidSchedulerServiceParams {\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 class VoidSchedulerService implements SchedulerService.Interface {\n private readonly callbacks: IVoidSchedulerServiceParams | undefined;\n\n public constructor(callbacks?: IVoidSchedulerServiceParams) {\n this.callbacks = callbacks;\n }\n\n public async create(params: ISchedulerServiceCreateParams): Promise<void> {\n if (!this.callbacks?.create) {\n return;\n }\n return this.callbacks?.create(params);\n }\n\n public async update(params: ISchedulerServiceUpdateParams): Promise<void> {\n if (!this.callbacks?.update) {\n return;\n }\n return this.callbacks?.update(params);\n }\n\n public async delete(id: string): Promise<void> {\n if (!this.callbacks?.delete) {\n return;\n }\n return this.callbacks?.delete(id);\n }\n\n public async exists(id: string): Promise<boolean> {\n if (!this.callbacks?.exists) {\n return false;\n }\n return this.callbacks?.exists(id);\n }\n}\n"],"names":["VoidSchedulerService","callbacks","params","id"],"mappings":"AAaO,MAAMA;IAGT,YAAmBC,SAAuC,CAAE;QACxD,IAAI,CAAC,SAAS,GAAGA;IACrB;IAEA,MAAa,OAAOC,MAAqC,EAAiB;QACtE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QACjB;QAEJ,OAAO,IAAI,CAAC,SAAS,EAAE,OAAOA;IAClC;IAEA,MAAa,OAAOA,MAAqC,EAAiB;QACtE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QACjB;QAEJ,OAAO,IAAI,CAAC,SAAS,EAAE,OAAOA;IAClC;IAEA,MAAa,OAAOC,EAAU,EAAiB;QAC3C,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QACjB;QAEJ,OAAO,IAAI,CAAC,SAAS,EAAE,OAAOA;IAClC;IAEA,MAAa,OAAOA,EAAU,EAAoB;QAC9C,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QACjB,OAAO;QAEX,OAAO,IAAI,CAAC,SAAS,EAAE,OAAOA;IAClC;AACJ"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createPermissionsAbstraction } from "@webiny/api-core/exports/api/security.js";
|
|
2
2
|
import { SCHEDULER_PERMISSIONS_SCHEMA } from "../../domain/permissionsSchema.js";
|
|
3
|
-
|
|
3
|
+
const SchedulerPermissions = createPermissionsAbstraction(SCHEDULER_PERMISSIONS_SCHEMA);
|
|
4
|
+
export { SchedulerPermissions };
|
|
4
5
|
|
|
5
6
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/permissions/abstractions.js","sources":["../../../src/features/permissions/abstractions.ts"],"sourcesContent":["import { createPermissionsAbstraction } from \"@webiny/api-core/exports/api/security.js\";\nimport type { Permissions } from \"@webiny/api-core/exports/api/security.js\";\nimport { SCHEDULER_PERMISSIONS_SCHEMA } from \"~/domain/permissionsSchema.js\";\n\nexport const SchedulerPermissions = createPermissionsAbstraction(SCHEDULER_PERMISSIONS_SCHEMA);\n\nexport namespace SchedulerPermissions {\n export type Interface = Permissions<typeof SCHEDULER_PERMISSIONS_SCHEMA>;\n}\n"],"names":["SchedulerPermissions","createPermissionsAbstraction","SCHEDULER_PERMISSIONS_SCHEMA"],"mappings":";;AAIO,MAAMA,uBAAuBC,6BAA6BC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createPermissionsFeature } from "@webiny/api-core/exports/api/security.js";
|
|
2
2
|
import { SCHEDULER_PERMISSIONS_SCHEMA } from "../../domain/permissionsSchema.js";
|
|
3
3
|
import { SchedulerPermissions } from "./abstractions.js";
|
|
4
|
-
|
|
4
|
+
const SchedulerPermissionsFeature = createPermissionsFeature(SCHEDULER_PERMISSIONS_SCHEMA, SchedulerPermissions);
|
|
5
|
+
export { SchedulerPermissionsFeature };
|
|
5
6
|
|
|
6
7
|
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/permissions/feature.js","sources":["../../../src/features/permissions/feature.ts"],"sourcesContent":["import { createPermissionsFeature } from \"@webiny/api-core/exports/api/security.js\";\nimport { SCHEDULER_PERMISSIONS_SCHEMA } from \"~/domain/permissionsSchema.js\";\nimport { SchedulerPermissions } from \"./abstractions.js\";\n\nexport const SchedulerPermissionsFeature = createPermissionsFeature(\n SCHEDULER_PERMISSIONS_SCHEMA,\n SchedulerPermissions\n);\n"],"names":["SchedulerPermissionsFeature","createPermissionsFeature","SCHEDULER_PERMISSIONS_SCHEMA","SchedulerPermissions"],"mappings":";;;AAIO,MAAMA,8BAA8BC,yBACvCC,8BACAC"}
|
|
@@ -7,9 +7,9 @@ import { CancelScheduledActionUseCase } from "../features/CancelScheduledAction/
|
|
|
7
7
|
import { ScheduledActionNotFoundError } from "../domain/errors.js";
|
|
8
8
|
import { ScheduledActionMapper } from "../domain/ScheduledActionMapper.js";
|
|
9
9
|
import { GetTargetScheduledActionUseCase } from "../features/GetTargetScheduledAction/index.js";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
class SchedulerGraphQL {
|
|
11
|
+
async execute(builder) {
|
|
12
|
+
builder.addTypeDefs(`
|
|
13
13
|
enum ScheduleRecordType {
|
|
14
14
|
publish
|
|
15
15
|
unpublish
|
|
@@ -132,117 +132,88 @@ export class SchedulerGraphQL {
|
|
|
132
132
|
scheduler: SchedulerMutation
|
|
133
133
|
}
|
|
134
134
|
`);
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
-
}
|
|
135
|
+
builder.addResolver({
|
|
136
|
+
path: "Query.scheduler",
|
|
137
|
+
resolver: ()=>async ()=>({})
|
|
138
|
+
});
|
|
139
|
+
builder.addResolver({
|
|
140
|
+
path: "Mutation.scheduler",
|
|
141
|
+
resolver: ()=>async ()=>({})
|
|
142
|
+
});
|
|
143
|
+
builder.addResolver({
|
|
144
|
+
path: "SchedulerQuery.getScheduledAction",
|
|
145
|
+
dependencies: [
|
|
146
|
+
GetScheduledActionUseCase
|
|
147
|
+
],
|
|
148
|
+
resolver: (useCase)=>async ({ args })=>{
|
|
149
|
+
const result = await useCase.execute(args);
|
|
150
|
+
if (result.isFail()) {
|
|
151
|
+
if (result.error instanceof ScheduledActionNotFoundError) return new Response(null);
|
|
152
|
+
return new ErrorResponse(result.error);
|
|
153
|
+
}
|
|
154
|
+
return new Response(ScheduledActionMapper.toGraphQL(result.value));
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
builder.addResolver({
|
|
158
|
+
path: "SchedulerQuery.getTargetScheduledAction",
|
|
159
|
+
dependencies: [
|
|
160
|
+
GetTargetScheduledActionUseCase
|
|
161
|
+
],
|
|
162
|
+
resolver: (useCase)=>async ({ args })=>{
|
|
163
|
+
const result = await useCase.execute(args);
|
|
164
|
+
if (result.isFail()) {
|
|
165
|
+
if (result.error instanceof ScheduledActionNotFoundError) return new Response(null);
|
|
166
|
+
return new ErrorResponse(result.error);
|
|
167
|
+
}
|
|
168
|
+
return new Response(ScheduledActionMapper.toGraphQL(result.value));
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
builder.addResolver({
|
|
172
|
+
path: "SchedulerQuery.listScheduledActions",
|
|
173
|
+
dependencies: [
|
|
174
|
+
ListScheduledActionsUseCase
|
|
175
|
+
],
|
|
176
|
+
resolver: (useCase)=>async ({ args })=>{
|
|
177
|
+
const result = await useCase.execute({
|
|
178
|
+
...args,
|
|
179
|
+
where: {
|
|
180
|
+
...args.where,
|
|
181
|
+
namespace: args.namespace
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
if (result.isFail()) return new ErrorResponse(result.error);
|
|
185
|
+
return new ListResponse(result.value.items.map((item)=>ScheduledActionMapper.toGraphQL(item)), result.value.meta);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
builder.addResolver({
|
|
189
|
+
path: "SchedulerMutation.scheduleAction",
|
|
190
|
+
dependencies: [
|
|
191
|
+
ScheduleActionUseCase
|
|
192
|
+
],
|
|
193
|
+
resolver: (useCase)=>async ({ args })=>{
|
|
194
|
+
const result = await useCase.execute(args);
|
|
195
|
+
if (result.isFail()) return new ErrorResponse(result.error);
|
|
196
|
+
return new Response(ScheduledActionMapper.toGraphQL(result.value));
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
builder.addResolver({
|
|
200
|
+
path: "SchedulerMutation.cancelScheduledAction",
|
|
201
|
+
dependencies: [
|
|
202
|
+
CancelScheduledActionUseCase
|
|
203
|
+
],
|
|
204
|
+
resolver: (useCase)=>async ({ args })=>{
|
|
205
|
+
const result = await useCase.execute(args);
|
|
206
|
+
if (result.isFail()) return new ErrorResponse(result.error);
|
|
207
|
+
return new Response(result.value);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
return builder;
|
|
211
|
+
}
|
|
242
212
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
213
|
+
const SchedulerGraphQLFactory = CoreGraphQLSchemaFactory.createImplementation({
|
|
214
|
+
dependencies: [],
|
|
215
|
+
implementation: SchedulerGraphQL
|
|
246
216
|
});
|
|
217
|
+
export { SchedulerGraphQL, SchedulerGraphQLFactory };
|
|
247
218
|
|
|
248
219
|
//# sourceMappingURL=SchedulerGraphQLFactory.js.map
|