@friggframework/core 2.0.0--canary.627.33970be.0 → 2.0.0--canary.627.ce32cdc.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.
@@ -405,14 +405,25 @@ async function runPrismaMigrateResolve(migrationName, action = 'applied', verbos
405
405
  const [executable, ...executableArgs] = prismaBin.split(' ');
406
406
  const fullArgs = [...executableArgs, ...args];
407
407
 
408
+ let stdout = '';
409
+ let stderr = '';
408
410
  const proc = spawn(executable, fullArgs, {
409
- stdio: 'inherit',
411
+ stdio: ['inherit', 'pipe', 'pipe'],
410
412
  env: {
411
413
  ...process.env,
412
414
  PRISMA_HIDE_UPDATE_MESSAGE: '1'
413
415
  }
414
416
  });
415
417
 
418
+ proc.stdout.on('data', (data) => {
419
+ stdout += data.toString();
420
+ if (verbose) process.stdout.write(data);
421
+ });
422
+ proc.stderr.on('data', (data) => {
423
+ stderr += data.toString();
424
+ if (verbose) process.stderr.write(data);
425
+ });
426
+
416
427
  proc.on('error', (error) => {
417
428
  resolve({
418
429
  success: false,
@@ -427,9 +438,12 @@ async function runPrismaMigrateResolve(migrationName, action = 'applied', verbos
427
438
  output: `Migration ${migrationName} marked as ${action}`
428
439
  });
429
440
  } else {
441
+ const detail = (stderr || stdout).trim();
430
442
  resolve({
431
443
  success: false,
432
- error: `Resolve process exited with code ${code}`
444
+ error: detail
445
+ ? `Prisma migrate resolve failed (exit ${code}): ${detail}`
446
+ : `Resolve process exited with code ${code}`
433
447
  });
434
448
  }
435
449
  });
@@ -31,7 +31,10 @@ const {
31
31
  ValidationError: GetValidationError,
32
32
  NotFoundError,
33
33
  } = require('../../database/use-cases/get-migration-status-use-case');
34
- const { LambdaInvoker } = require('../../database/adapters/lambda-invoker');
34
+ const {
35
+ LambdaInvoker,
36
+ LambdaInvocationError,
37
+ } = require('../../database/adapters/lambda-invoker');
35
38
  const {
36
39
  GetDatabaseStateViaWorkerUseCase,
37
40
  } = require('../../database/use-cases/get-database-state-via-worker-use-case');
@@ -262,6 +265,13 @@ router.post(
262
265
  });
263
266
  }
264
267
 
268
+ if (!/^\d{14}_[a-z0-9_]+$/i.test(migrationName)) {
269
+ return res.status(400).json({
270
+ success: false,
271
+ error: 'migrationName is not a valid migration identifier'
272
+ });
273
+ }
274
+
265
275
  if (!['applied', 'rolled-back'].includes(action)) {
266
276
  return res.status(400).json({
267
277
  success: false,
@@ -272,8 +282,6 @@ router.post(
272
282
  const stage = req.body.stage || process.env.STAGE || 'production';
273
283
 
274
284
  try {
275
- // Delegate to the worker Lambda (which has the Prisma CLI); the
276
- // router Lambda is packaged without Prisma.
277
285
  const result = await resolveMigrationUseCase.execute({
278
286
  migrationName,
279
287
  action,
@@ -283,6 +291,15 @@ router.post(
283
291
  res.status(200).json(result);
284
292
  } catch (error) {
285
293
  console.error('Migration resolve failed:', error);
294
+ if (
295
+ error instanceof LambdaInvocationError &&
296
+ error.statusCode === 400
297
+ ) {
298
+ return res.status(400).json({
299
+ success: false,
300
+ error: error.message,
301
+ });
302
+ }
286
303
  return res.status(500).json({
287
304
  success: false,
288
305
  error: 'Failed to resolve migration',
@@ -188,8 +188,6 @@ exports.handler = async (event, context) => {
188
188
  }
189
189
  }
190
190
 
191
- // Handle resolve action (P3009 recovery — router delegates here because the
192
- // worker has the Prisma CLI; the router does not).
193
191
  if (action === 'resolve') {
194
192
  const { migrationName, resolveAction = 'applied' } = event;
195
193
  console.log(`\n========================================`);
@@ -204,6 +202,15 @@ exports.handler = async (event, context) => {
204
202
  body: { success: false, error: 'migrationName is required' },
205
203
  };
206
204
  }
205
+ if (!/^\d{14}_[a-z0-9_]+$/i.test(migrationName)) {
206
+ return {
207
+ statusCode: 400,
208
+ body: {
209
+ success: false,
210
+ error: 'migrationName is not a valid migration identifier',
211
+ },
212
+ };
213
+ }
207
214
  if (!['applied', 'rolled-back'].includes(resolveAction)) {
208
215
  return {
209
216
  statusCode: 400,
@@ -213,6 +220,15 @@ exports.handler = async (event, context) => {
213
220
  },
214
221
  };
215
222
  }
223
+ if (dbType !== 'postgresql') {
224
+ return {
225
+ statusCode: 400,
226
+ body: {
227
+ success: false,
228
+ error: `Migration resolve is only supported for postgresql, not "${dbType}"`,
229
+ },
230
+ };
231
+ }
216
232
 
217
233
  try {
218
234
  const result = await prismaRunner.runPrismaMigrateResolve(
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.627.33970be.0",
4
+ "version": "2.0.0--canary.627.ce32cdc.0",
5
5
  "dependencies": {
6
6
  "@aws-sdk/client-apigatewaymanagementapi": "^3.588.0",
7
7
  "@aws-sdk/client-kms": "^3.588.0",
@@ -46,9 +46,9 @@
46
46
  }
47
47
  },
48
48
  "devDependencies": {
49
- "@friggframework/eslint-config": "2.0.0--canary.627.33970be.0",
50
- "@friggframework/prettier-config": "2.0.0--canary.627.33970be.0",
51
- "@friggframework/test": "2.0.0--canary.627.33970be.0",
49
+ "@friggframework/eslint-config": "2.0.0--canary.627.ce32cdc.0",
50
+ "@friggframework/prettier-config": "2.0.0--canary.627.ce32cdc.0",
51
+ "@friggframework/test": "2.0.0--canary.627.ce32cdc.0",
52
52
  "@prisma/client": "^6.19.3",
53
53
  "@types/lodash": "4.17.15",
54
54
  "@typescript-eslint/eslint-plugin": "^8.0.0",
@@ -88,5 +88,5 @@
88
88
  "publishConfig": {
89
89
  "access": "public"
90
90
  },
91
- "gitHead": "33970be6bc4ffa8e60d4c2799d6c24da4409bf5e"
91
+ "gitHead": "ce32cdc11aca0fa8087180474bb19d6e07fa47b6"
92
92
  }