@friggframework/devtools 2.0.0--canary.461.41c835a.0 → 2.0.0--canary.461.4860820.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.
@@ -470,31 +470,20 @@ exports.handler = async (event, context) => {
470
470
 
471
471
  console.log(' ✅ Using discovered Secrets Manager credentials');
472
472
  } else {
473
- // No secret and no auto-create - construct DATABASE_URL using environment variables at runtime
473
+ // No secret and no auto-create - set individual DB connection components
474
+ // The application will construct DATABASE_URL at runtime from these components + DATABASE_USER + DATABASE_PASSWORD
474
475
  const dbName = dbConfig.database || 'frigg';
475
476
 
476
- // Set individual environment variables for flexible credential management
477
477
  result.environment.DATABASE_HOST = discoveredResources.auroraClusterEndpoint;
478
478
  result.environment.DATABASE_PORT = String(discoveredResources.auroraPort || 5432);
479
479
  result.environment.DATABASE_NAME = dbName;
480
480
 
481
- // Build DATABASE_URL using CloudFormation intrinsic functions to reference
482
- // the environment variables at runtime (not build time)
483
- result.environment.DATABASE_URL = {
484
- 'Fn::Sub': [
485
- 'postgresql://${DatabaseUser}:${DatabasePassword}@${DatabaseHost}:${DatabasePort}/${DatabaseName}',
486
- {
487
- DatabaseUser: '${env:DATABASE_USER, "postgres"}',
488
- DatabasePassword: '${env:DATABASE_PASSWORD}',
489
- DatabaseHost: discoveredResources.auroraClusterEndpoint,
490
- DatabasePort: String(discoveredResources.auroraPort || 5432),
491
- DatabaseName: dbName,
492
- },
493
- ],
494
- };
481
+ // Note: DATABASE_URL is NOT set here to avoid Serverless variable resolution errors
482
+ // The application (Frigg Core) should construct it at runtime from:
483
+ // DATABASE_HOST, DATABASE_PORT, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD
495
484
 
496
- console.log(' ℹ️ No Secrets Manager secret found - DATABASE_URL will use DATABASE_USER and DATABASE_PASSWORD from environment');
497
- console.log(' ℹ️ Set DATABASE_USER and DATABASE_PASSWORD in Lambda environment or via serverless deploy --param');
485
+ console.log(' ℹ️ No Secrets Manager secret found - set DATABASE_USER and DATABASE_PASSWORD in Lambda environment');
486
+ console.log(' ℹ️ Application will construct DATABASE_URL at runtime from DATABASE_HOST, DATABASE_PORT, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD');
498
487
  console.log(' ℹ️ Or enable autoCreateCredentials=true to automatically create and rotate credentials');
499
488
  }
500
489
 
@@ -422,11 +422,17 @@ describe('AuroraBuilder', () => {
422
422
  expect(result.resources.FriggAuroraPasswordRotator).toBeUndefined();
423
423
  expect(result.resources.PasswordRotatorRole).toBeUndefined();
424
424
 
425
- // DATABASE_URL should use env variables
426
- expect(result.environment.DATABASE_URL).toBeDefined();
427
- expect(result.environment.DATABASE_URL['Fn::Sub']).toBeDefined();
428
- expect(result.environment.DATABASE_URL['Fn::Sub'][1].DatabaseUser).toContain('env:DATABASE_USER');
429
- expect(result.environment.DATABASE_URL['Fn::Sub'][1].DatabasePassword).toContain('env:DATABASE_PASSWORD');
425
+ // Should set individual environment variables for flexible credential management
426
+ expect(result.environment.DATABASE_HOST).toBe('cluster.abc.us-east-1.rds.amazonaws.com');
427
+ expect(result.environment.DATABASE_PORT).toBe('5432');
428
+ expect(result.environment.DATABASE_NAME).toBe('frigg');
429
+
430
+ // DATABASE_URL should NOT be set (to avoid Serverless variable resolution errors)
431
+ // The application should construct it at runtime from DATABASE_HOST, DATABASE_PORT, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD
432
+ expect(result.environment.DATABASE_URL).toBeUndefined();
433
+
434
+ // DATABASE_USER and DATABASE_PASSWORD should come from appDefinition.environment
435
+ // and will be set by the environment-builder, not here
430
436
  });
431
437
 
432
438
  it('should not create credentials when secret is already discovered', async () => {
@@ -525,6 +531,39 @@ describe('AuroraBuilder', () => {
525
531
  // Should use string concatenation instead
526
532
  expect(zipFileCode).toContain("'Successfully rotated password for cluster: ' + ClusterIdentifier");
527
533
  });
534
+
535
+ it('should properly escape ExcludeCharacters for valid JSON in CloudFormation template', async () => {
536
+ const appDefinition = {
537
+ database: {
538
+ postgres: {
539
+ enable: true,
540
+ management: 'discover',
541
+ autoCreateCredentials: true,
542
+ },
543
+ },
544
+ };
545
+
546
+ const discoveredResources = {
547
+ auroraClusterEndpoint: 'cluster.abc.us-east-1.rds.amazonaws.com',
548
+ auroraPort: 5432,
549
+ };
550
+
551
+ const result = await auroraBuilder.build(appDefinition, discoveredResources);
552
+
553
+ const excludeChars = result.resources.FriggDBSecret.Properties.GenerateSecretString.ExcludeCharacters;
554
+
555
+ // Should properly escape the backslash so it's valid JSON
556
+ // In JavaScript string: '"@/\\' represents the string: "@/\
557
+ // When serialized to JSON, backslash must be doubled: '"@/\\'
558
+ expect(excludeChars).toBe('"@/\\\\');
559
+
560
+ // Verify it can be JSON-stringified without errors
561
+ expect(() => JSON.stringify(result.resources.FriggDBSecret)).not.toThrow();
562
+
563
+ // Verify the JSON output has the correct escape sequence
564
+ const jsonOutput = JSON.stringify(result.resources.FriggDBSecret);
565
+ expect(jsonOutput).toContain('\\"@/\\\\\\\\'); // In JSON string: "\"@/\\\\"
566
+ });
528
567
  });
529
568
  });
530
569
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@friggframework/devtools",
3
3
  "prettier": "@friggframework/prettier-config",
4
- "version": "2.0.0--canary.461.41c835a.0",
4
+ "version": "2.0.0--canary.461.4860820.0",
5
5
  "dependencies": {
6
6
  "@aws-sdk/client-ec2": "^3.835.0",
7
7
  "@aws-sdk/client-kms": "^3.835.0",
@@ -11,8 +11,8 @@
11
11
  "@babel/eslint-parser": "^7.18.9",
12
12
  "@babel/parser": "^7.25.3",
13
13
  "@babel/traverse": "^7.25.3",
14
- "@friggframework/schemas": "2.0.0--canary.461.41c835a.0",
15
- "@friggframework/test": "2.0.0--canary.461.41c835a.0",
14
+ "@friggframework/schemas": "2.0.0--canary.461.4860820.0",
15
+ "@friggframework/test": "2.0.0--canary.461.4860820.0",
16
16
  "@hapi/boom": "^10.0.1",
17
17
  "@inquirer/prompts": "^5.3.8",
18
18
  "axios": "^1.7.2",
@@ -34,8 +34,8 @@
34
34
  "serverless-http": "^2.7.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@friggframework/eslint-config": "2.0.0--canary.461.41c835a.0",
38
- "@friggframework/prettier-config": "2.0.0--canary.461.41c835a.0",
37
+ "@friggframework/eslint-config": "2.0.0--canary.461.4860820.0",
38
+ "@friggframework/prettier-config": "2.0.0--canary.461.4860820.0",
39
39
  "aws-sdk-client-mock": "^4.1.0",
40
40
  "aws-sdk-client-mock-jest": "^4.1.0",
41
41
  "jest": "^30.1.3",
@@ -70,5 +70,5 @@
70
70
  "publishConfig": {
71
71
  "access": "public"
72
72
  },
73
- "gitHead": "41c835ab632e6cb39b585b16663981525975ae6a"
73
+ "gitHead": "486082018ba9bc219bf266048eb4c846bd9a45fb"
74
74
  }