@friggframework/core 2.0.0--canary.461.af4cde8.0 → 2.0.0--canary.461.74b99c9.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/database/config.js
CHANGED
|
@@ -4,13 +4,28 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Determines database type from app definition
|
|
8
|
-
*
|
|
7
|
+
* Determines database type from DATABASE_URL or app definition
|
|
8
|
+
*
|
|
9
|
+
* Detection order:
|
|
10
|
+
* 1. DATABASE_URL protocol (for migration handlers - avoids loading app definition)
|
|
11
|
+
* 2. App definition (backend/index.js Definition.database configuration)
|
|
9
12
|
*
|
|
10
13
|
* @returns {'mongodb'|'postgresql'} Database type
|
|
11
14
|
* @throws {Error} If database type cannot be determined or app definition missing
|
|
12
15
|
*/
|
|
13
16
|
function getDatabaseType() {
|
|
17
|
+
// First, try to detect from DATABASE_URL (migration handlers don't need app definition)
|
|
18
|
+
const databaseUrl = process.env.DATABASE_URL;
|
|
19
|
+
if (databaseUrl) {
|
|
20
|
+
if (databaseUrl.startsWith('postgresql://') || databaseUrl.startsWith('postgres://')) {
|
|
21
|
+
return 'postgresql';
|
|
22
|
+
}
|
|
23
|
+
if (databaseUrl.startsWith('mongodb://') || databaseUrl.startsWith('mongodb+srv://')) {
|
|
24
|
+
return 'mongodb';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Fallback: Load app definition
|
|
14
29
|
try {
|
|
15
30
|
const path = require('node:path');
|
|
16
31
|
const fs = require('node:fs');
|
|
@@ -85,11 +85,13 @@ router.use(validateApiKey);
|
|
|
85
85
|
router.post(
|
|
86
86
|
'/db-migrate',
|
|
87
87
|
catchAsyncError(async (req, res) => {
|
|
88
|
-
|
|
88
|
+
// Migration infrastructure is PostgreSQL-only, so hardcode dbType
|
|
89
|
+
const dbType = 'postgresql';
|
|
90
|
+
const { stage } = req.body;
|
|
89
91
|
// TODO: Extract userId from JWT token when auth is implemented
|
|
90
92
|
const userId = req.body.userId || 'admin';
|
|
91
93
|
|
|
92
|
-
console.log(`Migration trigger request: dbType=${dbType}, stage=${stage}, userId=${userId}`);
|
|
94
|
+
console.log(`Migration trigger request: dbType=${dbType}, stage=${stage || 'auto-detect'}, userId=${userId}`);
|
|
93
95
|
|
|
94
96
|
try {
|
|
95
97
|
const result = await triggerMigrationUseCase.execute({
|
|
@@ -28,7 +28,7 @@ describe('Database Migration Router - Adapter Layer', () => {
|
|
|
28
28
|
it('should load without requiring app definition (critical bug fix)', () => {
|
|
29
29
|
// Before fix: createProcessRepository() → getDatabaseType() → loads app definition → requires integrations → CRASH
|
|
30
30
|
// After fix: ProcessRepositoryPostgres instantiated directly → no app definition → SUCCESS
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
expect(() => {
|
|
33
33
|
require('./db-migration');
|
|
34
34
|
}).not.toThrow();
|
|
@@ -40,4 +40,12 @@ describe('Database Migration Router - Adapter Layer', () => {
|
|
|
40
40
|
expect(typeof router).toBe('function');
|
|
41
41
|
expect(router.stack).toBeDefined();
|
|
42
42
|
});
|
|
43
|
+
|
|
44
|
+
it('should hardcode dbType as postgresql (migrations are PostgreSQL-only)', () => {
|
|
45
|
+
// Migration infrastructure is only created for PostgreSQL deployments
|
|
46
|
+
// So we can safely hardcode dbType instead of requiring it from request
|
|
47
|
+
const router = require('./db-migration').router;
|
|
48
|
+
expect(router).toBeDefined();
|
|
49
|
+
// Test will pass if handler doesn't crash when dbType is omitted from request
|
|
50
|
+
});
|
|
43
51
|
});
|
|
@@ -104,32 +104,32 @@ function sanitizeDatabaseUrl(url) {
|
|
|
104
104
|
*/
|
|
105
105
|
function extractMigrationParams(event) {
|
|
106
106
|
let processId = null;
|
|
107
|
-
let dbType = null;
|
|
108
107
|
let stage = null;
|
|
108
|
+
|
|
109
|
+
// Migration infrastructure is PostgreSQL-only, so hardcode dbType
|
|
110
|
+
const dbType = 'postgresql';
|
|
109
111
|
|
|
110
112
|
// Check if this is an SQS event
|
|
111
113
|
if (event.Records && event.Records.length > 0) {
|
|
112
114
|
// SQS event - extract from message body
|
|
113
115
|
const message = JSON.parse(event.Records[0].body);
|
|
114
116
|
processId = message.processId;
|
|
115
|
-
dbType = message.dbType;
|
|
116
117
|
stage = message.stage;
|
|
117
118
|
|
|
118
119
|
console.log('SQS event detected');
|
|
119
120
|
console.log(` Process ID: ${processId}`);
|
|
120
|
-
console.log(` DB Type: ${dbType}`);
|
|
121
|
+
console.log(` DB Type: ${dbType} (hardcoded - PostgreSQL-only)`);
|
|
121
122
|
console.log(` Stage: ${stage}`);
|
|
122
123
|
} else {
|
|
123
124
|
// Direct invocation - use event properties or environment variables
|
|
124
125
|
processId = event.processId || null;
|
|
125
|
-
dbType = event.dbType || process.env.DB_TYPE || 'postgresql';
|
|
126
126
|
stage = event.stage || process.env.STAGE || 'production';
|
|
127
127
|
|
|
128
128
|
console.log('Direct invocation detected');
|
|
129
129
|
if (processId) {
|
|
130
130
|
console.log(` Process ID: ${processId}`);
|
|
131
131
|
}
|
|
132
|
-
console.log(` DB Type: ${dbType}`);
|
|
132
|
+
console.log(` DB Type: ${dbType} (hardcoded - PostgreSQL-only)`);
|
|
133
133
|
console.log(` Stage: ${stage}`);
|
|
134
134
|
}
|
|
135
135
|
|
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.461.
|
|
4
|
+
"version": "2.0.0--canary.461.74b99c9.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@aws-sdk/client-apigatewaymanagementapi": "^3.588.0",
|
|
7
7
|
"@aws-sdk/client-kms": "^3.588.0",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@friggframework/eslint-config": "2.0.0--canary.461.
|
|
41
|
-
"@friggframework/prettier-config": "2.0.0--canary.461.
|
|
42
|
-
"@friggframework/test": "2.0.0--canary.461.
|
|
40
|
+
"@friggframework/eslint-config": "2.0.0--canary.461.74b99c9.0",
|
|
41
|
+
"@friggframework/prettier-config": "2.0.0--canary.461.74b99c9.0",
|
|
42
|
+
"@friggframework/test": "2.0.0--canary.461.74b99c9.0",
|
|
43
43
|
"@prisma/client": "^6.17.0",
|
|
44
44
|
"@types/lodash": "4.17.15",
|
|
45
45
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"publishConfig": {
|
|
80
80
|
"access": "public"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "74b99c9d56dce5e4ea9f74f2db3a6087132578d3"
|
|
83
83
|
}
|