@friggframework/admin-scripts 2.0.0--canary.517.2239974.0 → 2.0.0--canary.517.179491e.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/package.json
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/admin-scripts",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0--canary.517.
|
|
4
|
+
"version": "2.0.0--canary.517.179491e.0",
|
|
5
5
|
"description": "Admin Script Runner for Frigg - Execute maintenance and operational scripts in hosted environments",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@aws-sdk/client-scheduler": "^3.588.0",
|
|
8
|
-
"@friggframework/core": "2.0.0--canary.517.
|
|
9
|
-
"bcryptjs": "^2.4.3",
|
|
8
|
+
"@friggframework/core": "2.0.0--canary.517.179491e.0",
|
|
10
9
|
"express": "^4.18.2",
|
|
11
|
-
"
|
|
12
|
-
"serverless-http": "^3.2.0",
|
|
13
|
-
"uuid": "^9.0.1"
|
|
10
|
+
"serverless-http": "^3.2.0"
|
|
14
11
|
},
|
|
15
12
|
"devDependencies": {
|
|
16
|
-
"@friggframework/eslint-config": "2.0.0--canary.517.
|
|
17
|
-
"@friggframework/prettier-config": "2.0.0--canary.517.
|
|
18
|
-
"@friggframework/test": "2.0.0--canary.517.
|
|
13
|
+
"@friggframework/eslint-config": "2.0.0--canary.517.179491e.0",
|
|
14
|
+
"@friggframework/prettier-config": "2.0.0--canary.517.179491e.0",
|
|
15
|
+
"@friggframework/test": "2.0.0--canary.517.179491e.0",
|
|
19
16
|
"eslint": "^8.22.0",
|
|
20
17
|
"jest": "^29.7.0",
|
|
21
18
|
"prettier": "^2.7.1",
|
|
@@ -46,5 +43,5 @@
|
|
|
46
43
|
"maintenance",
|
|
47
44
|
"operations"
|
|
48
45
|
],
|
|
49
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "179491ee820576004873fdfdbe0e8e10a807098d"
|
|
50
47
|
}
|
|
@@ -169,6 +169,7 @@ describe('Admin Script Router', () => {
|
|
|
169
169
|
});
|
|
170
170
|
|
|
171
171
|
it('should queue script for async execution', async () => {
|
|
172
|
+
process.env.ADMIN_SCRIPT_QUEUE_URL = 'https://sqs.us-east-1.amazonaws.com/123/test-queue';
|
|
172
173
|
mockCommands.createAdminProcess.mockResolvedValue({
|
|
173
174
|
id: 'exec-456',
|
|
174
175
|
});
|
|
@@ -188,11 +189,13 @@ describe('Admin Script Router', () => {
|
|
|
188
189
|
scriptName: 'test-script',
|
|
189
190
|
executionId: 'exec-456',
|
|
190
191
|
}),
|
|
191
|
-
|
|
192
|
+
'https://sqs.us-east-1.amazonaws.com/123/test-queue'
|
|
192
193
|
);
|
|
194
|
+
delete process.env.ADMIN_SCRIPT_QUEUE_URL;
|
|
193
195
|
});
|
|
194
196
|
|
|
195
197
|
it('should default to async mode', async () => {
|
|
198
|
+
process.env.ADMIN_SCRIPT_QUEUE_URL = 'https://sqs.us-east-1.amazonaws.com/123/test-queue';
|
|
196
199
|
mockCommands.createAdminProcess.mockResolvedValue({
|
|
197
200
|
id: 'exec-789',
|
|
198
201
|
});
|
|
@@ -205,6 +208,21 @@ describe('Admin Script Router', () => {
|
|
|
205
208
|
|
|
206
209
|
expect(response.status).toBe(202);
|
|
207
210
|
expect(response.body.status).toBe('QUEUED');
|
|
211
|
+
delete process.env.ADMIN_SCRIPT_QUEUE_URL;
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it('should return 503 when ADMIN_SCRIPT_QUEUE_URL is not set', async () => {
|
|
215
|
+
delete process.env.ADMIN_SCRIPT_QUEUE_URL;
|
|
216
|
+
|
|
217
|
+
const response = await request(app)
|
|
218
|
+
.post('/admin/scripts/test-script')
|
|
219
|
+
.send({
|
|
220
|
+
params: { foo: 'bar' },
|
|
221
|
+
mode: 'async',
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
expect(response.status).toBe(503);
|
|
225
|
+
expect(response.body.code).toBe('QUEUE_NOT_CONFIGURED');
|
|
208
226
|
});
|
|
209
227
|
|
|
210
228
|
it('should return 404 for non-existent script', async () => {
|
|
@@ -24,7 +24,12 @@ router.use(validateAdminApiKey);
|
|
|
24
24
|
*/
|
|
25
25
|
function createScheduleUseCases() {
|
|
26
26
|
const commands = createAdminScriptCommands();
|
|
27
|
-
const schedulerAdapter = createSchedulerAdapter(
|
|
27
|
+
const schedulerAdapter = createSchedulerAdapter({
|
|
28
|
+
type: process.env.SCHEDULER_PROVIDER || 'local',
|
|
29
|
+
targetLambdaArn: process.env.ADMIN_SCRIPT_EXECUTOR_LAMBDA_ARN,
|
|
30
|
+
scheduleGroupName: process.env.ADMIN_SCRIPT_SCHEDULE_GROUP,
|
|
31
|
+
roleArn: process.env.SCHEDULER_ROLE_ARN,
|
|
32
|
+
});
|
|
28
33
|
const scriptFactory = getScriptFactory();
|
|
29
34
|
|
|
30
35
|
return {
|
|
@@ -147,6 +152,14 @@ router.post('/scripts/:scriptName', async (req, res) => {
|
|
|
147
152
|
}
|
|
148
153
|
|
|
149
154
|
// Async execution - queue and return immediately
|
|
155
|
+
const queueUrl = process.env.ADMIN_SCRIPT_QUEUE_URL;
|
|
156
|
+
if (!queueUrl) {
|
|
157
|
+
return res.status(503).json({
|
|
158
|
+
error: 'Async execution is not configured (ADMIN_SCRIPT_QUEUE_URL not set)',
|
|
159
|
+
code: 'QUEUE_NOT_CONFIGURED',
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
150
163
|
const commands = createAdminScriptCommands();
|
|
151
164
|
const execution = await commands.createAdminProcess({
|
|
152
165
|
scriptName,
|
|
@@ -164,7 +177,7 @@ router.post('/scripts/:scriptName', async (req, res) => {
|
|
|
164
177
|
trigger: 'MANUAL',
|
|
165
178
|
params,
|
|
166
179
|
},
|
|
167
|
-
|
|
180
|
+
queueUrl
|
|
168
181
|
);
|
|
169
182
|
|
|
170
183
|
res.status(202).json({
|