@friggframework/core 2.0.0--canary.531.bae174b.0 → 2.0.0--canary.531.5b60782.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.
- package/application/commands/scheduler-commands.js +2 -2
- package/infrastructure/scheduler/eventbridge-scheduler-adapter.js +10 -11
- package/infrastructure/scheduler/index.js +1 -2
- package/infrastructure/scheduler/mock-scheduler-adapter.js +8 -8
- package/infrastructure/scheduler/scheduler-service-interface.js +3 -3
- package/package.json +5 -5
|
@@ -157,7 +157,7 @@ function createSchedulerCommands({ integrationName, schedulerService }) {
|
|
|
157
157
|
const result = await service.scheduleOneTime({
|
|
158
158
|
scheduleName: jobId,
|
|
159
159
|
scheduleAt: scheduledAt,
|
|
160
|
-
|
|
160
|
+
queueResourceId: queueArn,
|
|
161
161
|
payload: sqsPayload,
|
|
162
162
|
});
|
|
163
163
|
|
|
@@ -167,7 +167,7 @@ function createSchedulerCommands({ integrationName, schedulerService }) {
|
|
|
167
167
|
|
|
168
168
|
return {
|
|
169
169
|
jobId,
|
|
170
|
-
jobArn: result.
|
|
170
|
+
jobArn: result.scheduledJobId,
|
|
171
171
|
scheduledAt: result.scheduledAt,
|
|
172
172
|
};
|
|
173
173
|
} catch (error) {
|
|
@@ -21,15 +21,14 @@ const {
|
|
|
21
21
|
|
|
22
22
|
const { SchedulerServiceInterface } = require('./scheduler-service-interface');
|
|
23
23
|
|
|
24
|
-
const SCHEDULE_GROUP_NAME = 'frigg-integration-schedules';
|
|
25
|
-
|
|
26
24
|
class EventBridgeSchedulerAdapter extends SchedulerServiceInterface {
|
|
27
25
|
constructor({ region } = {}) {
|
|
28
26
|
super();
|
|
29
27
|
this.client = new SchedulerClient({
|
|
30
28
|
region: region || process.env.AWS_REGION || 'us-east-1',
|
|
31
29
|
});
|
|
32
|
-
this.scheduleGroupName =
|
|
30
|
+
this.scheduleGroupName =
|
|
31
|
+
process.env.SCHEDULE_GROUP_NAME || 'frigg-integration-schedules';
|
|
33
32
|
this.roleArn = process.env.SCHEDULER_ROLE_ARN;
|
|
34
33
|
}
|
|
35
34
|
|
|
@@ -39,19 +38,19 @@ class EventBridgeSchedulerAdapter extends SchedulerServiceInterface {
|
|
|
39
38
|
* @param {Object} params
|
|
40
39
|
* @param {string} params.scheduleName - Unique name for the schedule
|
|
41
40
|
* @param {Date} params.scheduleAt - When to trigger the schedule
|
|
42
|
-
* @param {string} params.
|
|
41
|
+
* @param {string} params.queueResourceId - Queue resource identifier (ARN) to send message to
|
|
43
42
|
* @param {Object} params.payload - Message payload
|
|
44
|
-
* @returns {Promise<{
|
|
43
|
+
* @returns {Promise<{scheduledJobId: string, scheduledAt: string}>}
|
|
45
44
|
*/
|
|
46
|
-
async scheduleOneTime({ scheduleName, scheduleAt,
|
|
45
|
+
async scheduleOneTime({ scheduleName, scheduleAt, queueResourceId, payload }) {
|
|
47
46
|
if (!scheduleName) {
|
|
48
47
|
throw new Error('scheduleName is required');
|
|
49
48
|
}
|
|
50
49
|
if (!scheduleAt || !(scheduleAt instanceof Date)) {
|
|
51
50
|
throw new Error('scheduleAt must be a valid Date object');
|
|
52
51
|
}
|
|
53
|
-
if (!
|
|
54
|
-
throw new Error('
|
|
52
|
+
if (!queueResourceId) {
|
|
53
|
+
throw new Error('queueResourceId is required');
|
|
55
54
|
}
|
|
56
55
|
if (!this.roleArn) {
|
|
57
56
|
throw new Error(
|
|
@@ -71,7 +70,7 @@ class EventBridgeSchedulerAdapter extends SchedulerServiceInterface {
|
|
|
71
70
|
Mode: 'OFF',
|
|
72
71
|
},
|
|
73
72
|
Target: {
|
|
74
|
-
Arn:
|
|
73
|
+
Arn: queueResourceId,
|
|
75
74
|
RoleArn: this.roleArn,
|
|
76
75
|
Input: JSON.stringify(payload),
|
|
77
76
|
},
|
|
@@ -85,7 +84,7 @@ class EventBridgeSchedulerAdapter extends SchedulerServiceInterface {
|
|
|
85
84
|
);
|
|
86
85
|
|
|
87
86
|
return {
|
|
88
|
-
|
|
87
|
+
scheduledJobId: response.ScheduleArn,
|
|
89
88
|
scheduledAt: scheduleAt.toISOString(),
|
|
90
89
|
};
|
|
91
90
|
} catch (error) {
|
|
@@ -182,4 +181,4 @@ class EventBridgeSchedulerAdapter extends SchedulerServiceInterface {
|
|
|
182
181
|
}
|
|
183
182
|
}
|
|
184
183
|
|
|
185
|
-
module.exports = { EventBridgeSchedulerAdapter
|
|
184
|
+
module.exports = { EventBridgeSchedulerAdapter };
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
const { SchedulerServiceInterface } = require('./scheduler-service-interface');
|
|
13
|
-
const { EventBridgeSchedulerAdapter
|
|
13
|
+
const { EventBridgeSchedulerAdapter } = require('./eventbridge-scheduler-adapter');
|
|
14
14
|
const { MockSchedulerAdapter } = require('./mock-scheduler-adapter');
|
|
15
15
|
const {
|
|
16
16
|
createSchedulerService,
|
|
@@ -25,7 +25,6 @@ module.exports = {
|
|
|
25
25
|
// Adapters
|
|
26
26
|
EventBridgeSchedulerAdapter,
|
|
27
27
|
MockSchedulerAdapter,
|
|
28
|
-
SCHEDULE_GROUP_NAME,
|
|
29
28
|
|
|
30
29
|
// Factory
|
|
31
30
|
createSchedulerService,
|
|
@@ -22,25 +22,25 @@ class MockSchedulerAdapter extends SchedulerServiceInterface {
|
|
|
22
22
|
* @param {Object} params
|
|
23
23
|
* @param {string} params.scheduleName - Unique name for the schedule
|
|
24
24
|
* @param {Date} params.scheduleAt - When to trigger the schedule
|
|
25
|
-
* @param {string} params.
|
|
25
|
+
* @param {string} params.queueResourceId - Queue resource identifier to send message to
|
|
26
26
|
* @param {Object} params.payload - JSON payload to send
|
|
27
|
-
* @returns {Promise<{
|
|
27
|
+
* @returns {Promise<{scheduledJobId: string, scheduledAt: string}>}
|
|
28
28
|
*/
|
|
29
|
-
async scheduleOneTime({ scheduleName, scheduleAt,
|
|
29
|
+
async scheduleOneTime({ scheduleName, scheduleAt, queueResourceId, payload }) {
|
|
30
30
|
if (!scheduleName) {
|
|
31
31
|
throw new Error('scheduleName is required');
|
|
32
32
|
}
|
|
33
33
|
if (!scheduleAt || !(scheduleAt instanceof Date)) {
|
|
34
34
|
throw new Error('scheduleAt must be a valid Date object');
|
|
35
35
|
}
|
|
36
|
-
if (!
|
|
37
|
-
throw new Error('
|
|
36
|
+
if (!queueResourceId) {
|
|
37
|
+
throw new Error('queueResourceId is required');
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
const scheduleData = {
|
|
41
41
|
scheduleName,
|
|
42
42
|
scheduledAt: scheduleAt.toISOString(),
|
|
43
|
-
|
|
43
|
+
queueResourceId,
|
|
44
44
|
payload,
|
|
45
45
|
createdAt: new Date().toISOString(),
|
|
46
46
|
state: 'ENABLED',
|
|
@@ -50,13 +50,13 @@ class MockSchedulerAdapter extends SchedulerServiceInterface {
|
|
|
50
50
|
|
|
51
51
|
console.log(`[MockScheduler] Created schedule: ${scheduleName}`);
|
|
52
52
|
console.log(`[MockScheduler] Scheduled for: ${scheduleAt.toISOString()}`);
|
|
53
|
-
console.log(`[MockScheduler] Target: ${
|
|
53
|
+
console.log(`[MockScheduler] Target: ${queueResourceId}`);
|
|
54
54
|
if (this.verbose) {
|
|
55
55
|
console.log(`[MockScheduler] Payload:`, JSON.stringify(payload, null, 2));
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
return {
|
|
59
|
-
|
|
59
|
+
scheduledJobId: `mock-job-${scheduleName}`,
|
|
60
60
|
scheduledAt: scheduleAt.toISOString(),
|
|
61
61
|
};
|
|
62
62
|
}
|
|
@@ -15,11 +15,11 @@ class SchedulerServiceInterface {
|
|
|
15
15
|
* @param {Object} params
|
|
16
16
|
* @param {string} params.scheduleName - Unique name for the schedule
|
|
17
17
|
* @param {Date} params.scheduleAt - When to trigger the schedule
|
|
18
|
-
* @param {string} params.
|
|
18
|
+
* @param {string} params.queueResourceId - Queue resource identifier to send message to
|
|
19
19
|
* @param {Object} params.payload - JSON payload to send
|
|
20
|
-
* @returns {Promise<{
|
|
20
|
+
* @returns {Promise<{scheduledJobId: string, scheduledAt: string}>}
|
|
21
21
|
*/
|
|
22
|
-
async scheduleOneTime({ scheduleName, scheduleAt,
|
|
22
|
+
async scheduleOneTime({ scheduleName, scheduleAt, queueResourceId, payload }) {
|
|
23
23
|
throw new Error('Method scheduleOneTime must be implemented by subclass');
|
|
24
24
|
}
|
|
25
25
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/core",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0--canary.531.
|
|
4
|
+
"version": "2.0.0--canary.531.5b60782.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@aws-sdk/client-apigatewaymanagementapi": "^3.588.0",
|
|
7
7
|
"@aws-sdk/client-kms": "^3.588.0",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@friggframework/eslint-config": "2.0.0--canary.531.
|
|
42
|
-
"@friggframework/prettier-config": "2.0.0--canary.531.
|
|
43
|
-
"@friggframework/test": "2.0.0--canary.531.
|
|
41
|
+
"@friggframework/eslint-config": "2.0.0--canary.531.5b60782.0",
|
|
42
|
+
"@friggframework/prettier-config": "2.0.0--canary.531.5b60782.0",
|
|
43
|
+
"@friggframework/test": "2.0.0--canary.531.5b60782.0",
|
|
44
44
|
"@prisma/client": "^6.17.0",
|
|
45
45
|
"@types/lodash": "4.17.15",
|
|
46
46
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"publishConfig": {
|
|
81
81
|
"access": "public"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "5b607824c46df14b9597c489f4d2a9fbd5f0c8a7"
|
|
84
84
|
}
|