@friggframework/devtools 2.0.0--canary.545.c459392.0 → 2.0.0--canary.547.67ebb53.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.
Files changed (128) hide show
  1. package/frigg-cli/README.md +1 -1
  2. package/frigg-cli/__tests__/unit/commands/build.test.js +1 -1
  3. package/frigg-cli/__tests__/unit/commands/doctor.test.js +2 -0
  4. package/frigg-cli/__tests__/unit/commands/install.test.js +19 -23
  5. package/frigg-cli/__tests__/unit/dependencies.test.js +2 -2
  6. package/frigg-cli/build-command/index.js +11 -123
  7. package/frigg-cli/deploy-command/index.js +1 -83
  8. package/frigg-cli/doctor-command/index.js +16 -37
  9. package/frigg-cli/generate-iam-command.js +1 -21
  10. package/frigg-cli/index.js +6 -21
  11. package/frigg-cli/index.test.js +2 -7
  12. package/frigg-cli/init-command/backend-first-handler.js +42 -124
  13. package/frigg-cli/init-command/index.js +1 -2
  14. package/frigg-cli/init-command/template-handler.js +3 -13
  15. package/frigg-cli/install-command/backend-js.js +3 -3
  16. package/frigg-cli/install-command/environment-variables.js +19 -16
  17. package/frigg-cli/install-command/environment-variables.test.js +13 -12
  18. package/frigg-cli/install-command/index.js +9 -14
  19. package/frigg-cli/install-command/integration-file.js +3 -3
  20. package/frigg-cli/install-command/logger.js +12 -0
  21. package/frigg-cli/install-command/validate-package.js +9 -5
  22. package/frigg-cli/jest.config.js +1 -4
  23. package/frigg-cli/repair-command/index.js +128 -121
  24. package/frigg-cli/start-command/index.js +2 -324
  25. package/frigg-cli/ui-command/index.js +36 -58
  26. package/frigg-cli/utils/repo-detection.js +37 -85
  27. package/infrastructure/create-frigg-infrastructure.js +0 -93
  28. package/infrastructure/docs/iam-policy-templates.md +1 -1
  29. package/infrastructure/domains/networking/vpc-builder.test.js +4 -2
  30. package/infrastructure/domains/networking/vpc-resolver.test.js +1 -1
  31. package/infrastructure/domains/shared/cloudformation-discovery.test.js +7 -4
  32. package/infrastructure/domains/shared/resource-discovery.js +5 -5
  33. package/infrastructure/domains/shared/types/app-definition.js +0 -21
  34. package/infrastructure/domains/shared/types/discovery-result.test.js +1 -1
  35. package/infrastructure/domains/shared/utilities/base-definition-factory.js +1 -10
  36. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +2 -2
  37. package/infrastructure/infrastructure-composer.js +0 -2
  38. package/infrastructure/infrastructure-composer.test.js +2 -2
  39. package/management-ui/README.md +109 -245
  40. package/package.json +7 -8
  41. package/frigg-cli/__tests__/application/use-cases/AddApiModuleToIntegrationUseCase.test.js +0 -326
  42. package/frigg-cli/__tests__/application/use-cases/CreateApiModuleUseCase.test.js +0 -337
  43. package/frigg-cli/__tests__/domain/entities/ApiModule.test.js +0 -373
  44. package/frigg-cli/__tests__/domain/entities/AppDefinition.test.js +0 -313
  45. package/frigg-cli/__tests__/domain/services/IntegrationValidator.test.js +0 -269
  46. package/frigg-cli/__tests__/domain/value-objects/IntegrationName.test.js +0 -82
  47. package/frigg-cli/__tests__/infrastructure/adapters/IntegrationJsUpdater.test.js +0 -408
  48. package/frigg-cli/__tests__/infrastructure/repositories/FileSystemApiModuleRepository.test.js +0 -583
  49. package/frigg-cli/__tests__/infrastructure/repositories/FileSystemAppDefinitionRepository.test.js +0 -314
  50. package/frigg-cli/__tests__/infrastructure/repositories/FileSystemIntegrationRepository.test.js +0 -383
  51. package/frigg-cli/__tests__/unit/commands/init.test.js +0 -406
  52. package/frigg-cli/__tests__/unit/commands/provider-dispatch.test.js +0 -383
  53. package/frigg-cli/__tests__/unit/commands/repair.test.js +0 -275
  54. package/frigg-cli/__tests__/unit/start-command/application/RunPreflightChecksUseCase.test.js +0 -411
  55. package/frigg-cli/__tests__/unit/start-command/infrastructure/DatabaseAdapter.test.js +0 -405
  56. package/frigg-cli/__tests__/unit/start-command/infrastructure/DockerAdapter.test.js +0 -496
  57. package/frigg-cli/__tests__/unit/start-command/presentation/InteractivePromptAdapter.test.js +0 -474
  58. package/frigg-cli/__tests__/unit/utils/output.test.js +0 -196
  59. package/frigg-cli/application/use-cases/AddApiModuleToIntegrationUseCase.js +0 -93
  60. package/frigg-cli/application/use-cases/CreateApiModuleUseCase.js +0 -93
  61. package/frigg-cli/application/use-cases/CreateIntegrationUseCase.js +0 -103
  62. package/frigg-cli/container.js +0 -172
  63. package/frigg-cli/docs/OUTPUT_MIGRATION_GUIDE.md +0 -286
  64. package/frigg-cli/domain/entities/ApiModule.js +0 -272
  65. package/frigg-cli/domain/entities/AppDefinition.js +0 -227
  66. package/frigg-cli/domain/entities/Integration.js +0 -198
  67. package/frigg-cli/domain/exceptions/DomainException.js +0 -24
  68. package/frigg-cli/domain/ports/IApiModuleRepository.js +0 -53
  69. package/frigg-cli/domain/ports/IAppDefinitionRepository.js +0 -43
  70. package/frigg-cli/domain/ports/IIntegrationRepository.js +0 -61
  71. package/frigg-cli/domain/services/IntegrationValidator.js +0 -185
  72. package/frigg-cli/domain/value-objects/IntegrationId.js +0 -42
  73. package/frigg-cli/domain/value-objects/IntegrationName.js +0 -60
  74. package/frigg-cli/domain/value-objects/SemanticVersion.js +0 -70
  75. package/frigg-cli/infrastructure/UnitOfWork.js +0 -46
  76. package/frigg-cli/infrastructure/adapters/BackendJsUpdater.js +0 -197
  77. package/frigg-cli/infrastructure/adapters/FileSystemAdapter.js +0 -224
  78. package/frigg-cli/infrastructure/adapters/IntegrationJsUpdater.js +0 -249
  79. package/frigg-cli/infrastructure/adapters/SchemaValidator.js +0 -92
  80. package/frigg-cli/infrastructure/repositories/FileSystemApiModuleRepository.js +0 -373
  81. package/frigg-cli/infrastructure/repositories/FileSystemAppDefinitionRepository.js +0 -116
  82. package/frigg-cli/infrastructure/repositories/FileSystemIntegrationRepository.js +0 -277
  83. package/frigg-cli/package-lock.json +0 -16226
  84. package/frigg-cli/start-command/application/RunPreflightChecksUseCase.js +0 -376
  85. package/frigg-cli/start-command/infrastructure/DatabaseAdapter.js +0 -591
  86. package/frigg-cli/start-command/infrastructure/DockerAdapter.js +0 -306
  87. package/frigg-cli/start-command/presentation/InteractivePromptAdapter.js +0 -329
  88. package/frigg-cli/templates/backend/.env.example +0 -62
  89. package/frigg-cli/templates/backend/.eslintrc.json +0 -12
  90. package/frigg-cli/templates/backend/.prettierrc +0 -6
  91. package/frigg-cli/templates/backend/docker-compose.yml +0 -22
  92. package/frigg-cli/templates/backend/index.js +0 -96
  93. package/frigg-cli/templates/backend/infrastructure.js +0 -12
  94. package/frigg-cli/templates/backend/jest.config.js +0 -17
  95. package/frigg-cli/templates/backend/package.json +0 -50
  96. package/frigg-cli/templates/backend/src/api-modules/.gitkeep +0 -10
  97. package/frigg-cli/templates/backend/src/base/.gitkeep +0 -7
  98. package/frigg-cli/templates/backend/src/integrations/.gitkeep +0 -10
  99. package/frigg-cli/templates/backend/src/integrations/ExampleIntegration.js +0 -65
  100. package/frigg-cli/templates/backend/src/utils/.gitkeep +0 -7
  101. package/frigg-cli/templates/backend/test/setup.js +0 -30
  102. package/frigg-cli/templates/backend/ui-extensions/.gitkeep +0 -0
  103. package/frigg-cli/templates/backend/ui-extensions/README.md +0 -77
  104. package/frigg-cli/utils/__tests__/provider-helper.test.js +0 -55
  105. package/frigg-cli/utils/__tests__/repo-detection.test.js +0 -436
  106. package/frigg-cli/utils/output.js +0 -382
  107. package/frigg-cli/utils/provider-helper.js +0 -75
  108. package/frigg-cli/validate-command/__tests__/adapters/validate-command.test.js +0 -205
  109. package/frigg-cli/validate-command/__tests__/application/validate-app-use-case.test.js +0 -104
  110. package/frigg-cli/validate-command/__tests__/domain/fix-suggestion.test.js +0 -153
  111. package/frigg-cli/validate-command/__tests__/domain/validation-error.test.js +0 -162
  112. package/frigg-cli/validate-command/__tests__/domain/validation-result.test.js +0 -152
  113. package/frigg-cli/validate-command/__tests__/infrastructure/api-module-validator.test.js +0 -332
  114. package/frigg-cli/validate-command/__tests__/infrastructure/app-definition-validator.test.js +0 -191
  115. package/frigg-cli/validate-command/__tests__/infrastructure/integration-class-validator.test.js +0 -146
  116. package/frigg-cli/validate-command/__tests__/infrastructure/template-validation.test.js +0 -155
  117. package/frigg-cli/validate-command/adapters/cli/validate-command.js +0 -199
  118. package/frigg-cli/validate-command/application/use-cases/validate-app-use-case.js +0 -35
  119. package/frigg-cli/validate-command/domain/entities/validation-result.js +0 -74
  120. package/frigg-cli/validate-command/domain/value-objects/fix-suggestion.js +0 -74
  121. package/frigg-cli/validate-command/domain/value-objects/validation-error.js +0 -68
  122. package/frigg-cli/validate-command/infrastructure/validators/api-module-validator.js +0 -181
  123. package/frigg-cli/validate-command/infrastructure/validators/app-definition-validator.js +0 -128
  124. package/frigg-cli/validate-command/infrastructure/validators/integration-class-validator.js +0 -113
  125. package/infrastructure/domains/admin-scripts/admin-script-builder.js +0 -200
  126. package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +0 -499
  127. package/infrastructure/domains/admin-scripts/index.js +0 -5
  128. package/infrastructure/jest.config.js +0 -16
@@ -1,499 +0,0 @@
1
- /**
2
- * Tests for Admin Script Builder
3
- *
4
- * Tests admin script infrastructure generation including:
5
- * - SQS queue for script execution
6
- * - Lambda executor function
7
- * - Lambda router function with HTTP routes
8
- * - EventBridge Scheduler resources (optional)
9
- */
10
-
11
- const { AdminScriptBuilder } = require('./admin-script-builder');
12
- const { ValidationResult } = require('../shared/base-builder');
13
-
14
- describe('AdminScriptBuilder', () => {
15
- let adminScriptBuilder;
16
-
17
- beforeEach(() => {
18
- adminScriptBuilder = new AdminScriptBuilder();
19
- });
20
-
21
- describe('shouldExecute()', () => {
22
- it('should return false when no adminScripts', () => {
23
- const appDefinition = {};
24
-
25
- expect(adminScriptBuilder.shouldExecute(appDefinition)).toBe(false);
26
- });
27
-
28
- it('should return false when adminScripts is empty array', () => {
29
- const appDefinition = {
30
- adminScripts: [],
31
- };
32
-
33
- expect(adminScriptBuilder.shouldExecute(appDefinition)).toBe(false);
34
- });
35
-
36
- it('should return true when adminScripts has items', () => {
37
- const appDefinition = {
38
- adminScripts: [
39
- { Definition: { name: 'test-script' } },
40
- ],
41
- };
42
-
43
- expect(adminScriptBuilder.shouldExecute(appDefinition)).toBe(true);
44
- });
45
-
46
- it('should return false when adminScripts is not an array', () => {
47
- const appDefinition = {
48
- adminScripts: { name: 'test' },
49
- };
50
-
51
- expect(adminScriptBuilder.shouldExecute(appDefinition)).toBe(false);
52
- });
53
- });
54
-
55
- describe('getDependencies()', () => {
56
- it('should have no dependencies', () => {
57
- const deps = adminScriptBuilder.getDependencies();
58
-
59
- expect(deps).toEqual([]);
60
- });
61
- });
62
-
63
- describe('validate()', () => {
64
- it('should pass validation with valid adminScripts', () => {
65
- const appDefinition = {
66
- adminScripts: [
67
- { Definition: { name: 'oauth-refresh' } },
68
- { Definition: { name: 'health-check' } },
69
- ],
70
- };
71
-
72
- const result = adminScriptBuilder.validate(appDefinition);
73
-
74
- expect(result).toBeInstanceOf(ValidationResult);
75
- expect(result.valid).toBe(true);
76
- expect(result.errors).toEqual([]);
77
- });
78
-
79
- it('should pass when adminScripts is undefined', () => {
80
- const appDefinition = {};
81
-
82
- const result = adminScriptBuilder.validate(appDefinition);
83
-
84
- expect(result.valid).toBe(true);
85
- });
86
-
87
- it('should fail when adminScripts is not an array', () => {
88
- const appDefinition = {
89
- adminScripts: 'invalid',
90
- };
91
-
92
- const result = adminScriptBuilder.validate(appDefinition);
93
-
94
- expect(result.valid).toBe(false);
95
- expect(result.errors).toContain('adminScripts must be an array');
96
- });
97
-
98
- it('should fail when script missing Definition.name', () => {
99
- const appDefinition = {
100
- adminScripts: [
101
- { Definition: {} },
102
- ],
103
- };
104
-
105
- const result = adminScriptBuilder.validate(appDefinition);
106
-
107
- expect(result.valid).toBe(false);
108
- expect(result.errors).toContain(
109
- 'Admin script at index 0 is missing Definition or name'
110
- );
111
- });
112
-
113
- it('should fail when script missing Definition', () => {
114
- const appDefinition = {
115
- adminScripts: [
116
- { someOtherField: 'value' },
117
- ],
118
- };
119
-
120
- const result = adminScriptBuilder.validate(appDefinition);
121
-
122
- expect(result.valid).toBe(false);
123
- expect(result.errors).toContain(
124
- 'Admin script at index 0 is missing Definition or name'
125
- );
126
- });
127
-
128
- it('should validate all scripts', () => {
129
- const appDefinition = {
130
- adminScripts: [
131
- { Definition: { name: 'valid' } },
132
- { Definition: {} }, // Invalid - no name
133
- { someField: 'value' }, // Invalid - no Definition
134
- ],
135
- };
136
-
137
- const result = adminScriptBuilder.validate(appDefinition);
138
-
139
- expect(result.valid).toBe(false);
140
- expect(result.errors).toHaveLength(2);
141
- });
142
- });
143
-
144
- describe('build()', () => {
145
- it('should create AdminScriptQueue resource', async () => {
146
- const appDefinition = {
147
- adminScripts: [
148
- { Definition: { name: 'test-script' } },
149
- ],
150
- };
151
-
152
- const result = await adminScriptBuilder.build(appDefinition, {});
153
-
154
- expect(result.resources.AdminScriptQueue).toBeDefined();
155
- expect(result.resources.AdminScriptQueue.Type).toBe('AWS::SQS::Queue');
156
- });
157
-
158
- it('should configure AdminScriptQueue with correct retention and timeout', async () => {
159
- const appDefinition = {
160
- adminScripts: [
161
- { Definition: { name: 'test-script' } },
162
- ],
163
- };
164
-
165
- const result = await adminScriptBuilder.build(appDefinition, {});
166
-
167
- expect(result.resources.AdminScriptQueue.Properties.MessageRetentionPeriod).toBe(86400); // 1 day
168
- expect(result.resources.AdminScriptQueue.Properties.VisibilityTimeout).toBe(900); // 15 minutes
169
- });
170
-
171
- it('should configure AdminScriptQueue redrive policy to InternalErrorQueue', async () => {
172
- const appDefinition = {
173
- adminScripts: [
174
- { Definition: { name: 'test-script' } },
175
- ],
176
- };
177
-
178
- const result = await adminScriptBuilder.build(appDefinition, {});
179
-
180
- expect(result.resources.AdminScriptQueue.Properties.RedrivePolicy).toEqual({
181
- maxReceiveCount: 3,
182
- deadLetterTargetArn: {
183
- 'Fn::GetAtt': ['InternalErrorQueue', 'Arn'],
184
- },
185
- });
186
- });
187
-
188
- it('should add ADMIN_SCRIPT_QUEUE_URL to environment variables', async () => {
189
- const appDefinition = {
190
- adminScripts: [
191
- { Definition: { name: 'test-script' } },
192
- ],
193
- };
194
-
195
- const result = await adminScriptBuilder.build(appDefinition, {});
196
-
197
- expect(result.environment.ADMIN_SCRIPT_QUEUE_URL).toEqual({
198
- Ref: 'AdminScriptQueue',
199
- });
200
- });
201
-
202
- it('should create adminScriptExecutor function', async () => {
203
- const appDefinition = {
204
- adminScripts: [
205
- { Definition: { name: 'test-script' } },
206
- ],
207
- };
208
-
209
- const result = await adminScriptBuilder.build(appDefinition, {});
210
-
211
- expect(result.functions.adminScriptExecutor).toBeDefined();
212
- expect(result.functions.adminScriptExecutor.handler).toBe(
213
- 'node_modules/@friggframework/admin-scripts/src/infrastructure/script-executor-handler.handler'
214
- );
215
- });
216
-
217
- it('should configure adminScriptExecutor with SQS event', async () => {
218
- const appDefinition = {
219
- adminScripts: [
220
- { Definition: { name: 'test-script' } },
221
- ],
222
- };
223
-
224
- const result = await adminScriptBuilder.build(appDefinition, {});
225
-
226
- expect(result.functions.adminScriptExecutor.events).toEqual([
227
- {
228
- sqs: {
229
- arn: { 'Fn::GetAtt': ['AdminScriptQueue', 'Arn'] },
230
- batchSize: 1,
231
- },
232
- },
233
- ]);
234
- });
235
-
236
- it('should set adminScriptExecutor timeout to 900 seconds', async () => {
237
- const appDefinition = {
238
- adminScripts: [
239
- { Definition: { name: 'test-script' } },
240
- ],
241
- };
242
-
243
- const result = await adminScriptBuilder.build(appDefinition, {});
244
-
245
- expect(result.functions.adminScriptExecutor.timeout).toBe(900); // 15 minutes (Lambda max)
246
- });
247
-
248
- it('should set adminScriptExecutor memory size', async () => {
249
- const appDefinition = {
250
- adminScripts: [
251
- { Definition: { name: 'test-script' } },
252
- ],
253
- };
254
-
255
- const result = await adminScriptBuilder.build(appDefinition, {});
256
-
257
- expect(result.functions.adminScriptExecutor.memorySize).toBe(1024);
258
- });
259
-
260
- it('should attach Prisma layer to adminScriptExecutor', async () => {
261
- const appDefinition = {
262
- adminScripts: [
263
- { Definition: { name: 'test-script' } },
264
- ],
265
- };
266
-
267
- const result = await adminScriptBuilder.build(appDefinition, {});
268
-
269
- expect(result.functions.adminScriptExecutor.layers).toEqual([
270
- { Ref: 'PrismaLambdaLayer' }
271
- ]);
272
- });
273
-
274
- it('should create adminScriptRouter function', async () => {
275
- const appDefinition = {
276
- adminScripts: [
277
- { Definition: { name: 'test-script' } },
278
- ],
279
- };
280
-
281
- const result = await adminScriptBuilder.build(appDefinition, {});
282
-
283
- expect(result.functions.adminScriptRouter).toBeDefined();
284
- expect(result.functions.adminScriptRouter.handler).toBe(
285
- 'node_modules/@friggframework/admin-scripts/src/infrastructure/admin-script-router.handler'
286
- );
287
- });
288
-
289
- it('should configure adminScriptRouter with correct HTTP routes', async () => {
290
- const appDefinition = {
291
- adminScripts: [
292
- { Definition: { name: 'test-script' } },
293
- ],
294
- };
295
-
296
- const result = await adminScriptBuilder.build(appDefinition, {});
297
-
298
- expect(result.functions.adminScriptRouter.events).toEqual([
299
- // List scripts
300
- { httpApi: { path: '/admin/scripts', method: 'GET' } },
301
- // Get script details
302
- { httpApi: { path: '/admin/scripts/{scriptName}', method: 'GET' } },
303
- // Execute script (sync or async)
304
- { httpApi: { path: '/admin/scripts/{scriptName}/execute', method: 'POST' } },
305
- // Get execution status
306
- { httpApi: { path: '/admin/executions/{executionId}', method: 'GET' } },
307
- // List executions
308
- { httpApi: { path: '/admin/executions', method: 'GET' } },
309
- // Schedule management (Phase 2)
310
- { httpApi: { path: '/admin/scripts/{scriptName}/schedule', method: 'GET' } },
311
- { httpApi: { path: '/admin/scripts/{scriptName}/schedule', method: 'PUT' } },
312
- { httpApi: { path: '/admin/scripts/{scriptName}/schedule', method: 'DELETE' } },
313
- ]);
314
- });
315
-
316
- it('should set adminScriptRouter timeout to 30 seconds', async () => {
317
- const appDefinition = {
318
- adminScripts: [
319
- { Definition: { name: 'test-script' } },
320
- ],
321
- };
322
-
323
- const result = await adminScriptBuilder.build(appDefinition, {});
324
-
325
- expect(result.functions.adminScriptRouter.timeout).toBe(30);
326
- });
327
-
328
- it('should attach Prisma layer to adminScriptRouter', async () => {
329
- const appDefinition = {
330
- adminScripts: [
331
- { Definition: { name: 'test-script' } },
332
- ],
333
- };
334
-
335
- const result = await adminScriptBuilder.build(appDefinition, {});
336
-
337
- expect(result.functions.adminScriptRouter.layers).toEqual([
338
- { Ref: 'PrismaLambdaLayer' }
339
- ]);
340
- });
341
-
342
- it('should create scheduler resources when admin.enableScheduling is true', async () => {
343
- const appDefinition = {
344
- adminScripts: [
345
- { Definition: { name: 'test-script' } },
346
- ],
347
- admin: {
348
- enableScheduling: true,
349
- },
350
- };
351
-
352
- const result = await adminScriptBuilder.build(appDefinition, {});
353
-
354
- // Check for scheduler IAM role
355
- expect(result.resources.AdminScriptSchedulerRole).toBeDefined();
356
- expect(result.resources.AdminScriptSchedulerRole.Type).toBe('AWS::IAM::Role');
357
-
358
- // Check for schedule group
359
- expect(result.resources.AdminScriptScheduleGroup).toBeDefined();
360
- expect(result.resources.AdminScriptScheduleGroup.Type).toBe('AWS::Scheduler::ScheduleGroup');
361
-
362
- // Check for environment variables
363
- expect(result.environment.SCHEDULER_ROLE_ARN).toEqual({
364
- 'Fn::GetAtt': ['AdminScriptSchedulerRole', 'Arn'],
365
- });
366
- expect(result.environment.SCHEDULE_GROUP_NAME).toEqual({
367
- Ref: 'AdminScriptScheduleGroup',
368
- });
369
- });
370
-
371
- it('should not create scheduler resources when enableScheduling is false', async () => {
372
- const appDefinition = {
373
- adminScripts: [
374
- { Definition: { name: 'test-script' } },
375
- ],
376
- admin: {
377
- enableScheduling: false,
378
- },
379
- };
380
-
381
- const result = await adminScriptBuilder.build(appDefinition, {});
382
-
383
- expect(result.resources.AdminScriptSchedulerRole).toBeUndefined();
384
- expect(result.resources.AdminScriptScheduleGroup).toBeUndefined();
385
- expect(result.environment.SCHEDULER_ROLE_ARN).toBeUndefined();
386
- expect(result.environment.SCHEDULE_GROUP_NAME).toBeUndefined();
387
- });
388
-
389
- it('should not create scheduler resources when admin config is not provided', async () => {
390
- const appDefinition = {
391
- adminScripts: [
392
- { Definition: { name: 'test-script' } },
393
- ],
394
- };
395
-
396
- const result = await adminScriptBuilder.build(appDefinition, {});
397
-
398
- expect(result.resources.AdminScriptSchedulerRole).toBeUndefined();
399
- expect(result.resources.AdminScriptScheduleGroup).toBeUndefined();
400
- });
401
-
402
- it('should use skipEsbuild for all functions', async () => {
403
- const appDefinition = {
404
- adminScripts: [
405
- { Definition: { name: 'test-script' } },
406
- ],
407
- };
408
-
409
- const result = await adminScriptBuilder.build(appDefinition, {});
410
-
411
- expect(result.functions.adminScriptExecutor.skipEsbuild).toBe(true);
412
- expect(result.functions.adminScriptRouter.skipEsbuild).toBe(true);
413
- });
414
-
415
- it('should not attach Prisma layer when usePrismaLambdaLayer=false', async () => {
416
- const appDefinition = {
417
- usePrismaLambdaLayer: false,
418
- adminScripts: [
419
- { Definition: { name: 'test-script' } },
420
- ],
421
- };
422
-
423
- const result = await adminScriptBuilder.build(appDefinition, {});
424
-
425
- expect(result.functions.adminScriptExecutor.layers).toBeUndefined();
426
- expect(result.functions.adminScriptRouter.layers).toBeUndefined();
427
- });
428
-
429
- it('should handle multiple admin scripts', async () => {
430
- const appDefinition = {
431
- adminScripts: [
432
- { Definition: { name: 'oauth-refresh' } },
433
- { Definition: { name: 'health-check' } },
434
- { Definition: { name: 'attio-healing' } },
435
- ],
436
- };
437
-
438
- const result = await adminScriptBuilder.build(appDefinition, {});
439
-
440
- // Should still only create one queue and two functions
441
- expect(result.resources.AdminScriptQueue).toBeDefined();
442
- expect(result.functions.adminScriptExecutor).toBeDefined();
443
- expect(result.functions.adminScriptRouter).toBeDefined();
444
-
445
- // Should not create separate resources per script
446
- expect(Object.keys(result.resources)).toHaveLength(1); // Only AdminScriptQueue
447
- expect(Object.keys(result.functions)).toHaveLength(2); // Only executor and router
448
- });
449
-
450
- it('should configure scheduler role with correct trust policy', async () => {
451
- const appDefinition = {
452
- adminScripts: [
453
- { Definition: { name: 'test-script' } },
454
- ],
455
- admin: {
456
- enableScheduling: true,
457
- },
458
- };
459
-
460
- const result = await adminScriptBuilder.build(appDefinition, {});
461
-
462
- const trustPolicy = result.resources.AdminScriptSchedulerRole.Properties.AssumeRolePolicyDocument;
463
-
464
- expect(trustPolicy.Statement[0]).toEqual({
465
- Effect: 'Allow',
466
- Principal: { Service: 'scheduler.amazonaws.com' },
467
- Action: 'sts:AssumeRole',
468
- });
469
- });
470
-
471
- it('should configure scheduler role with Lambda invoke permission', async () => {
472
- const appDefinition = {
473
- adminScripts: [
474
- { Definition: { name: 'test-script' } },
475
- ],
476
- admin: {
477
- enableScheduling: true,
478
- },
479
- };
480
-
481
- const result = await adminScriptBuilder.build(appDefinition, {});
482
-
483
- const policies = result.resources.AdminScriptSchedulerRole.Properties.Policies;
484
-
485
- expect(policies[0].PolicyName).toBe('InvokeLambda');
486
- expect(policies[0].PolicyDocument.Statement[0]).toEqual({
487
- Effect: 'Allow',
488
- Action: 'lambda:InvokeFunction',
489
- Resource: { 'Fn::GetAtt': ['AdminScriptExecutorLambdaFunction', 'Arn'] },
490
- });
491
- });
492
- });
493
-
494
- describe('getName()', () => {
495
- it('should return AdminScriptBuilder', () => {
496
- expect(adminScriptBuilder.getName()).toBe('AdminScriptBuilder');
497
- });
498
- });
499
- });
@@ -1,5 +0,0 @@
1
- const { AdminScriptBuilder } = require('./admin-script-builder');
2
-
3
- module.exports = {
4
- AdminScriptBuilder
5
- };
@@ -1,16 +0,0 @@
1
- module.exports = {
2
- displayName: 'Infrastructure',
3
- rootDir: __dirname,
4
- testMatch: [
5
- '<rootDir>/**/*.test.js',
6
- '<rootDir>/**/*.spec.js',
7
- ],
8
- testPathIgnorePatterns: [
9
- '/node_modules/',
10
- '/__tests__/fixtures/',
11
- '/__tests__/helpers/',
12
- ],
13
- testEnvironment: 'node',
14
- testTimeout: 10000,
15
- transform: {},
16
- };