@friggframework/devtools 2.0.0-next.121 → 2.0.0-next.123

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 (27) hide show
  1. package/frigg-cli/__tests__/unit/commands/deploy.test.js +30 -24
  2. package/frigg-cli/__tests__/unit/commands/doctor.test.js +10 -6
  3. package/frigg-cli/__tests__/unit/commands/install.test.js +7 -0
  4. package/frigg-cli/__tests__/unit/commands/ui.test.js +31 -30
  5. package/frigg-cli/__tests__/unit/dependencies.test.js +6 -2
  6. package/infrastructure/__tests__/management-api-gateway-routes.test.js +281 -0
  7. package/infrastructure/__tests__/postgres-config.test.js +241 -835
  8. package/infrastructure/__tests__/template-generation.test.js +36 -8
  9. package/infrastructure/domains/health/application/use-cases/__tests__/mismatch-analyzer-method-name.test.js +12 -8
  10. package/infrastructure/domains/health/application/use-cases/__tests__/repair-via-import-use-case.test.js +19 -7
  11. package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.test.js +12 -8
  12. package/infrastructure/domains/health/domain/services/__tests__/import-progress-monitor.test.js +17 -18
  13. package/infrastructure/domains/health/domain/services/__tests__/update-progress-monitor.test.js +12 -2
  14. package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-relationship-analysis.test.js +8 -1
  15. package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.test.js +4 -2
  16. package/infrastructure/domains/health/infrastructure/adapters/aws-resource-detector.test.js +10 -0
  17. package/infrastructure/domains/networking/vpc-builder.js +18 -8
  18. package/infrastructure/domains/networking/vpc-builder.test.js +26 -12
  19. package/infrastructure/domains/shared/cloudformation-discovery.test.js +36 -6
  20. package/infrastructure/domains/shared/utilities/base-definition-factory.js +19 -0
  21. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +13 -1
  22. package/infrastructure/infrastructure-composer.test.js +268 -794
  23. package/infrastructure/scripts/build-prisma-layer.test.js +28 -7
  24. package/infrastructure/scripts/build-time-discovery.test.js +18 -3
  25. package/package.json +7 -7
  26. package/frigg-cli/index.test.js +0 -158
  27. package/infrastructure/integration.test.js +0 -381
@@ -164,7 +164,7 @@ describe('CloudFormationDiscovery', () => {
164
164
  expect(result.routeTableId).toBe('rtb-123');
165
165
  expect(result.vpcEndpointSecurityGroupId).toBe('sg-vpce-123');
166
166
  expect(result.s3VpcEndpointId).toBe('vpce-s3-123');
167
- expect(result.dynamoDbVpcEndpointId).toBe('vpce-ddb-123');
167
+ expect(result.dynamodbVpcEndpointId).toBe('vpce-ddb-123');
168
168
  expect(result.kmsVpcEndpointId).toBe('vpce-kms-123');
169
169
  expect(result.secretsManagerVpcEndpointId).toBe('vpce-sm-123');
170
170
  });
@@ -190,6 +190,9 @@ describe('CloudFormationDiscovery', () => {
190
190
 
191
191
  expect(result).toEqual({
192
192
  fromCloudFormationStack: true,
193
+ // _extractFromResources() initialises the structured endpoint map whenever
194
+ // the stack has resources (37a354e8)
195
+ vpcEndpoints: {},
193
196
  stackName: 'test-stack',
194
197
  auroraClusterId: 'test-cluster',
195
198
  existingLogicalIds: ['FriggAuroraCluster'],
@@ -257,6 +260,9 @@ describe('CloudFormationDiscovery', () => {
257
260
 
258
261
  expect(result).toEqual({
259
262
  fromCloudFormationStack: true,
263
+ // _extractFromResources() initialises the structured endpoint map whenever
264
+ // the stack has resources (37a354e8)
265
+ vpcEndpoints: {},
260
266
  stackName: 'test-stack',
261
267
  migrationStatusBucket: 'test-migration-bucket',
262
268
  existingLogicalIds: ['FriggMigrationStatusBucket'],
@@ -285,6 +291,9 @@ describe('CloudFormationDiscovery', () => {
285
291
 
286
292
  expect(result).toEqual({
287
293
  fromCloudFormationStack: true,
294
+ // _extractFromResources() initialises the structured endpoint map whenever
295
+ // the stack has resources (37a354e8)
296
+ vpcEndpoints: {},
288
297
  stackName: 'test-stack',
289
298
  migrationQueueUrl:
290
299
  'https://sqs.us-east-1.amazonaws.com/123456789/test-queue',
@@ -313,6 +322,9 @@ describe('CloudFormationDiscovery', () => {
313
322
 
314
323
  expect(result).toEqual({
315
324
  fromCloudFormationStack: true,
325
+ // _extractFromResources() initialises the structured endpoint map whenever
326
+ // the stack has resources (37a354e8)
327
+ vpcEndpoints: {},
316
328
  stackName: 'test-stack',
317
329
  natGatewayId: 'nat-0123456789',
318
330
  existingLogicalIds: ['FriggNatGateway'],
@@ -340,6 +352,9 @@ describe('CloudFormationDiscovery', () => {
340
352
 
341
353
  expect(result).toEqual({
342
354
  fromCloudFormationStack: true,
355
+ // _extractFromResources() initialises the structured endpoint map whenever
356
+ // the stack has resources (37a354e8)
357
+ vpcEndpoints: {},
343
358
  stackName: 'test-stack',
344
359
  defaultVpcId: 'vpc-037ec55fe87aec1e7',
345
360
  existingLogicalIds: ['FriggVPC'],
@@ -378,6 +393,9 @@ describe('CloudFormationDiscovery', () => {
378
393
 
379
394
  expect(result).toEqual({
380
395
  fromCloudFormationStack: true,
396
+ // _extractFromResources() initialises the structured endpoint map whenever
397
+ // the stack has resources (37a354e8)
398
+ vpcEndpoints: {},
381
399
  stackName: 'test-stack',
382
400
  defaultVpcId: 'vpc-123', // VpcBuilder expects 'defaultVpcId'
383
401
  defaultKmsKeyId: 'arn:aws:kms:us-east-1:123456789:key/abc',
@@ -406,6 +424,9 @@ describe('CloudFormationDiscovery', () => {
406
424
 
407
425
  expect(result).toEqual({
408
426
  fromCloudFormationStack: true,
427
+ // _extractFromResources() initialises the structured endpoint map whenever
428
+ // the stack has resources (37a354e8)
429
+ vpcEndpoints: {},
409
430
  stackName: 'test-stack',
410
431
  });
411
432
  });
@@ -439,6 +460,11 @@ describe('CloudFormationDiscovery', () => {
439
460
  SecurityGroups: [{ VpcId: 'vpc-123' }],
440
461
  });
441
462
 
463
+ // Mock the VPC's default security group lookup (added in 37a354e8)
464
+ mockEC2Client.send.mockResolvedValueOnce({
465
+ SecurityGroups: [{ GroupId: 'sg-default-123' }],
466
+ });
467
+
442
468
  // Mock subnet query
443
469
  mockEC2Client.send.mockResolvedValueOnce({
444
470
  Subnets: [
@@ -469,9 +495,11 @@ describe('CloudFormationDiscovery', () => {
469
495
 
470
496
  const result = await cfDiscovery.discoverFromStack('test-stack');
471
497
 
498
+ expect(result.defaultVpcId).toBe('vpc-123');
499
+ expect(result.defaultSecurityGroupId).toBe('sg-default-123');
472
500
  expect(result.privateSubnetId1).toBe('subnet-private-1');
473
501
  expect(result.privateSubnetId2).toBe('subnet-private-2');
474
- expect(mockEC2Client.send).toHaveBeenCalledTimes(2);
502
+ expect(mockEC2Client.send).toHaveBeenCalledTimes(3);
475
503
  });
476
504
 
477
505
  it('should handle EC2 subnet query errors gracefully', async () => {
@@ -739,7 +767,7 @@ describe('CloudFormationDiscovery', () => {
739
767
  expect(result.vpcEndpoints.s3).toBe('vpce-0352ceac2124c14be');
740
768
  expect(result.vpcEndpoints.dynamodb).toBe('vpce-0b06c4f631199ea68');
741
769
  expect(result.s3VpcEndpointId).toBe('vpce-0352ceac2124c14be');
742
- expect(result.dynamoDbVpcEndpointId).toBe('vpce-0b06c4f631199ea68');
770
+ expect(result.dynamodbVpcEndpointId).toBe('vpce-0b06c4f631199ea68');
743
771
 
744
772
  // Verify NO VPC/KMS resources (they're external)
745
773
  expect(result.defaultVpcId).toBeUndefined();
@@ -776,7 +804,7 @@ describe('CloudFormationDiscovery', () => {
776
804
  expect(result.vpcEndpoints.s3).toBe('vpce-legacy-s3');
777
805
  expect(result.vpcEndpoints.dynamodb).toBe('vpce-legacy-ddb');
778
806
  expect(result.s3VpcEndpointId).toBe('vpce-legacy-s3');
779
- expect(result.dynamoDbVpcEndpointId).toBe('vpce-legacy-ddb');
807
+ expect(result.dynamodbVpcEndpointId).toBe('vpce-legacy-ddb');
780
808
  });
781
809
 
782
810
  it('should extract FriggLambdaSecurityGroup from stack', async () => {
@@ -807,7 +835,9 @@ describe('CloudFormationDiscovery', () => {
807
835
 
808
836
  // Lambda security group should be extracted
809
837
  expect(result.lambdaSecurityGroupId).toBe('sg-01002240c6a446202');
810
- expect(result.defaultSecurityGroupId).toBe('sg-01002240c6a446202');
838
+ // The Lambda SG must not masquerade as the VPC's default SG
839
+ // (defaultSecurityGroupId is only ever the VPC default; see 37a354e8).
840
+ expect(result.defaultSecurityGroupId).toBeUndefined();
811
841
  expect(result.existingLogicalIds).toContain(
812
842
  'FriggLambdaSecurityGroup'
813
843
  );
@@ -899,7 +929,7 @@ describe('CloudFormationDiscovery', () => {
899
929
 
900
930
  describe('existingLogicalIds tracking', () => {
901
931
  it('should track OLD VPC endpoint logical IDs (VPCEndpointS3 pattern) for backwards compatibility', async () => {
902
- // CRITICAL: Frontify production uses OLD naming convention
932
+ // CRITICAL: Older production stacks use the OLD naming convention
903
933
  const mockStack = {
904
934
  StackName: 'create-frigg-app-production',
905
935
  Outputs: [],
@@ -286,6 +286,11 @@ function createBaseDefinition(
286
286
  ...(usePrismaLayer && { layers: [{ Ref: 'PrismaLambdaLayer' }] }),
287
287
  skipEsbuild: true, // Handlers in node_modules don't need bundling
288
288
  package: skipEsbuildPackageConfig,
289
+ // Every path prefix the core integration router
290
+ // (createIntegrationRouter) registers must be routed here;
291
+ // HTTP API has no implicit catch-all, so an unlisted prefix
292
+ // 404s at the gateway before Express sees it. Guarded by
293
+ // __tests__/management-api-gateway-routes.test.js.
289
294
  events: [
290
295
  { httpApi: { path: '/api/integrations', method: 'ANY' } },
291
296
  {
@@ -295,6 +300,20 @@ function createBaseDefinition(
295
300
  },
296
301
  },
297
302
  { httpApi: { path: '/api/authorize', method: 'ANY' } },
303
+ { httpApi: { path: '/api/entity', method: 'ANY' } },
304
+ {
305
+ httpApi: {
306
+ path: '/api/entity/{proxy+}',
307
+ method: 'ANY',
308
+ },
309
+ },
310
+ { httpApi: { path: '/api/entities', method: 'ANY' } },
311
+ {
312
+ httpApi: {
313
+ path: '/api/entities/{proxy+}',
314
+ method: 'ANY',
315
+ },
316
+ },
298
317
  ],
299
318
  },
300
319
  user: {
@@ -94,7 +94,19 @@ describe('Base Definition Factory', () => {
94
94
 
95
95
  expect(result.functions.auth.handler).toBe('node_modules/@friggframework/core/handlers/routers/auth.handler');
96
96
  expect(result.functions.auth.layers).toEqual([{ Ref: 'PrismaLambdaLayer' }]);
97
- expect(result.functions.auth.events).toHaveLength(3);
97
+ expect(
98
+ result.functions.auth.events.map(
99
+ (e) => `${e.httpApi.method} ${e.httpApi.path}`
100
+ )
101
+ ).toEqual([
102
+ 'ANY /api/integrations',
103
+ 'ANY /api/integrations/{proxy+}',
104
+ 'ANY /api/authorize',
105
+ 'ANY /api/entity',
106
+ 'ANY /api/entity/{proxy+}',
107
+ 'ANY /api/entities',
108
+ 'ANY /api/entities/{proxy+}',
109
+ ]);
98
110
  });
99
111
 
100
112
  it('should NOT include legacy dbMigrate function', () => {