@friggframework/core 2.0.0--canary.639.cf7e091.0 → 2.0.0--canary.705.9cfd819.0
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.
|
@@ -11,65 +11,19 @@
|
|
|
11
11
|
* This adapter implements SchedulerServiceInterface for AWS EventBridge Scheduler.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
const {
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const {
|
|
15
|
+
SchedulerClient,
|
|
16
|
+
CreateScheduleCommand,
|
|
17
|
+
DeleteScheduleCommand,
|
|
18
|
+
GetScheduleCommand,
|
|
19
|
+
ResourceNotFoundException,
|
|
20
|
+
} = require('@aws-sdk/client-scheduler');
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
* Lazily load the AWS EventBridge Scheduler SDK.
|
|
20
|
-
*
|
|
21
|
-
* Requiring `@aws-sdk/client-scheduler` at module top level would put the AWS
|
|
22
|
-
* SDK on the load path of every consumer of `@friggframework/core`, including
|
|
23
|
-
* those using the mock scheduler or no scheduler at all. Loading it here, on
|
|
24
|
-
* construction of the EventBridge adapter, keeps it out of the module-load
|
|
25
|
-
* path. The adapter calls it exactly once, in its constructor, and keeps the
|
|
26
|
-
* classes its methods need on the instance.
|
|
27
|
-
*
|
|
28
|
-
* Only a MODULE_NOT_FOUND for the scheduler SDK itself is rewritten into an
|
|
29
|
-
* actionable message; any other failure (including a missing transitive
|
|
30
|
-
* dependency) is rethrown unchanged so the real cause is not masked.
|
|
31
|
-
*
|
|
32
|
-
* @returns {object} The relevant exports from `@aws-sdk/client-scheduler`.
|
|
33
|
-
*/
|
|
34
|
-
function loadSchedulerSdk() {
|
|
35
|
-
try {
|
|
36
|
-
// Keep the literal specifier so bundlers (esbuild) can resolve it.
|
|
37
|
-
return require('@aws-sdk/client-scheduler');
|
|
38
|
-
} catch (error) {
|
|
39
|
-
const isSchedulerSdkMissing =
|
|
40
|
-
error &&
|
|
41
|
-
error.code === 'MODULE_NOT_FOUND' &&
|
|
42
|
-
typeof error.message === 'string' &&
|
|
43
|
-
error.message.includes(SCHEDULER_SDK);
|
|
44
|
-
if (isSchedulerSdkMissing) {
|
|
45
|
-
throw new Error(
|
|
46
|
-
`The EventBridge scheduler requires the "${SCHEDULER_SDK}" package, ` +
|
|
47
|
-
`which is not installed. Install it (\`npm install ${SCHEDULER_SDK}\`) ` +
|
|
48
|
-
'to use the EventBridge scheduler provider, or use the mock scheduler provider ' +
|
|
49
|
-
'(SCHEDULER_PROVIDER=mock) for local development.',
|
|
50
|
-
{ cause: error }
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
throw error;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
22
|
+
const { SchedulerServiceInterface } = require('./scheduler-service-interface');
|
|
56
23
|
|
|
57
24
|
class EventBridgeSchedulerAdapter extends SchedulerServiceInterface {
|
|
58
25
|
constructor({ region } = {}) {
|
|
59
26
|
super();
|
|
60
|
-
const {
|
|
61
|
-
SchedulerClient,
|
|
62
|
-
CreateScheduleCommand,
|
|
63
|
-
DeleteScheduleCommand,
|
|
64
|
-
GetScheduleCommand,
|
|
65
|
-
ResourceNotFoundException,
|
|
66
|
-
} = loadSchedulerSdk();
|
|
67
|
-
this.sdk = {
|
|
68
|
-
CreateScheduleCommand,
|
|
69
|
-
DeleteScheduleCommand,
|
|
70
|
-
GetScheduleCommand,
|
|
71
|
-
ResourceNotFoundException,
|
|
72
|
-
};
|
|
73
27
|
this.client = new SchedulerClient({
|
|
74
28
|
region: region || process.env.AWS_REGION || 'us-east-1',
|
|
75
29
|
});
|
|
@@ -88,12 +42,7 @@ class EventBridgeSchedulerAdapter extends SchedulerServiceInterface {
|
|
|
88
42
|
* @param {Object} params.payload - Message payload
|
|
89
43
|
* @returns {Promise<{scheduledJobId: string, scheduledAt: string}>}
|
|
90
44
|
*/
|
|
91
|
-
async scheduleOneTime({
|
|
92
|
-
scheduleName,
|
|
93
|
-
scheduleAt,
|
|
94
|
-
queueResourceId,
|
|
95
|
-
payload,
|
|
96
|
-
}) {
|
|
45
|
+
async scheduleOneTime({ scheduleName, scheduleAt, queueResourceId, payload }) {
|
|
97
46
|
if (!scheduleName) {
|
|
98
47
|
throw new Error('scheduleName is required');
|
|
99
48
|
}
|
|
@@ -110,11 +59,8 @@ class EventBridgeSchedulerAdapter extends SchedulerServiceInterface {
|
|
|
110
59
|
}
|
|
111
60
|
|
|
112
61
|
// Format date to AWS schedule expression (at(yyyy-mm-ddThh:mm:ss))
|
|
113
|
-
const scheduleExpression = `at(${scheduleAt
|
|
114
|
-
.toISOString()
|
|
115
|
-
.replace(/\.\d{3}Z$/, '')})`;
|
|
62
|
+
const scheduleExpression = `at(${scheduleAt.toISOString().replace(/\.\d{3}Z$/, '')})`;
|
|
116
63
|
|
|
117
|
-
const { CreateScheduleCommand } = this.sdk;
|
|
118
64
|
const command = new CreateScheduleCommand({
|
|
119
65
|
Name: scheduleName,
|
|
120
66
|
GroupName: this.scheduleGroupName,
|
|
@@ -161,7 +107,6 @@ class EventBridgeSchedulerAdapter extends SchedulerServiceInterface {
|
|
|
161
107
|
throw new Error('scheduleName is required');
|
|
162
108
|
}
|
|
163
109
|
|
|
164
|
-
const { DeleteScheduleCommand, ResourceNotFoundException } = this.sdk;
|
|
165
110
|
const command = new DeleteScheduleCommand({
|
|
166
111
|
Name: scheduleName,
|
|
167
112
|
GroupName: this.scheduleGroupName,
|
|
@@ -196,7 +141,6 @@ class EventBridgeSchedulerAdapter extends SchedulerServiceInterface {
|
|
|
196
141
|
throw new Error('scheduleName is required');
|
|
197
142
|
}
|
|
198
143
|
|
|
199
|
-
const { GetScheduleCommand, ResourceNotFoundException } = this.sdk;
|
|
200
144
|
const command = new GetScheduleCommand({
|
|
201
145
|
Name: scheduleName,
|
|
202
146
|
GroupName: this.scheduleGroupName,
|
|
@@ -209,7 +153,9 @@ class EventBridgeSchedulerAdapter extends SchedulerServiceInterface {
|
|
|
209
153
|
// Format: at(yyyy-mm-ddThh:mm:ss)
|
|
210
154
|
let scheduledAt = null;
|
|
211
155
|
if (response.ScheduleExpression) {
|
|
212
|
-
const match = response.ScheduleExpression.match(
|
|
156
|
+
const match = response.ScheduleExpression.match(
|
|
157
|
+
/^at\((.+)\)$/
|
|
158
|
+
);
|
|
213
159
|
if (match) {
|
|
214
160
|
scheduledAt = new Date(match[1] + 'Z').toISOString();
|
|
215
161
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/core",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0--canary.
|
|
4
|
+
"version": "2.0.0--canary.705.9cfd819.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@aws-sdk/client-apigatewaymanagementapi": "^3.588.0",
|
|
7
7
|
"@aws-sdk/client-kms": "^3.588.0",
|
|
8
8
|
"@aws-sdk/client-lambda": "^3.714.0",
|
|
9
9
|
"@aws-sdk/client-s3": "^3.588.0",
|
|
10
|
-
"@aws-sdk/client-scheduler": "^3.588.0",
|
|
11
10
|
"@aws-sdk/client-sqs": "^3.588.0",
|
|
12
11
|
"@aws-sdk/client-ssm": "^3.588.0",
|
|
13
12
|
"@aws-sdk/s3-request-presigner": "^3.588.0",
|
|
@@ -48,9 +47,9 @@
|
|
|
48
47
|
}
|
|
49
48
|
},
|
|
50
49
|
"devDependencies": {
|
|
51
|
-
"@friggframework/eslint-config": "2.0.0--canary.
|
|
52
|
-
"@friggframework/prettier-config": "2.0.0--canary.
|
|
53
|
-
"@friggframework/test": "2.0.0--canary.
|
|
50
|
+
"@friggframework/eslint-config": "2.0.0--canary.705.9cfd819.0",
|
|
51
|
+
"@friggframework/prettier-config": "2.0.0--canary.705.9cfd819.0",
|
|
52
|
+
"@friggframework/test": "2.0.0--canary.705.9cfd819.0",
|
|
54
53
|
"@prisma/client": "^6.19.3",
|
|
55
54
|
"@types/lodash": "4.17.15",
|
|
56
55
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
@@ -90,5 +89,5 @@
|
|
|
90
89
|
"publishConfig": {
|
|
91
90
|
"access": "public"
|
|
92
91
|
},
|
|
93
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "9cfd819cc94f0c7dc1fd2710775cfb93aba3a424"
|
|
94
93
|
}
|