@friggframework/core 2.0.0--canary.461.40be5d4.0 → 2.0.0--canary.461.d9e6ed3.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.
@@ -47,20 +47,15 @@ const {
47
47
  ValidationError,
48
48
  } = require('../../database/use-cases/run-database-migration-use-case');
49
49
  const {
50
- UpdateProcessState,
51
- } = require('../../integrations/use-cases/update-process-state');
52
- const {
53
- ProcessRepositoryPostgres,
54
- } = require('../../integrations/repositories/process-repository-postgres');
50
+ MigrationStatusRepositoryS3,
51
+ } = require('../../database/repositories/migration-status-repository-s3');
55
52
 
56
53
  // Inject prisma-runner as dependency
57
54
  const prismaRunner = require('../../database/utils/prisma-runner');
58
55
 
59
- // Create process repository and use case for tracking migration progress
60
- // Note: Migrations are PostgreSQL-only, so we directly use ProcessRepositoryPostgres
61
- // This avoids loading app definition (which requires integration classes)
62
- const processRepository = new ProcessRepositoryPostgres();
63
- const updateProcessState = new UpdateProcessState({ processRepository });
56
+ // Use S3 repository for migration status tracking (no User table dependency)
57
+ const bucketName = process.env.S3_BUCKET_NAME || process.env.MIGRATION_STATUS_BUCKET;
58
+ const migrationStatusRepository = new MigrationStatusRepositoryS3(bucketName);
64
59
 
65
60
  /**
66
61
  * Sanitizes error messages to prevent credential leaks
@@ -100,12 +95,12 @@ function sanitizeDatabaseUrl(url) {
100
95
  /**
101
96
  * Extract migration parameters from SQS event or direct invocation
102
97
  * @param {Object} event - Lambda event (SQS or direct)
103
- * @returns {Object} Extracted parameters { processId, dbType, stage }
98
+ * @returns {Object} Extracted parameters { migrationId, dbType, stage }
104
99
  */
105
100
  function extractMigrationParams(event) {
106
- let processId = null;
101
+ let migrationId = null;
107
102
  let stage = null;
108
-
103
+
109
104
  // Migration infrastructure is PostgreSQL-only, so hardcode dbType
110
105
  const dbType = 'postgresql';
111
106
 
@@ -113,27 +108,27 @@ function extractMigrationParams(event) {
113
108
  if (event.Records && event.Records.length > 0) {
114
109
  // SQS event - extract from message body
115
110
  const message = JSON.parse(event.Records[0].body);
116
- processId = message.processId;
111
+ migrationId = message.migrationId;
117
112
  stage = message.stage;
118
113
 
119
114
  console.log('SQS event detected');
120
- console.log(` Process ID: ${processId}`);
115
+ console.log(` Migration ID: ${migrationId}`);
121
116
  console.log(` DB Type: ${dbType} (hardcoded - PostgreSQL-only)`);
122
117
  console.log(` Stage: ${stage}`);
123
118
  } else {
124
119
  // Direct invocation - use event properties or environment variables
125
- processId = event.processId || null;
120
+ migrationId = event.migrationId || null;
126
121
  stage = event.stage || process.env.STAGE || 'production';
127
122
 
128
123
  console.log('Direct invocation detected');
129
- if (processId) {
130
- console.log(` Process ID: ${processId}`);
124
+ if (migrationId) {
125
+ console.log(` Migration ID: ${migrationId}`);
131
126
  }
132
127
  console.log(` DB Type: ${dbType} (hardcoded - PostgreSQL-only)`);
133
128
  console.log(` Stage: ${stage}`);
134
129
  }
135
130
 
136
- return { processId, dbType, stage };
131
+ return { migrationId, dbType, stage };
137
132
  }
138
133
 
139
134
  /**
@@ -154,7 +149,7 @@ exports.handler = async (event, context) => {
154
149
  }, null, 2));
155
150
 
156
151
  // Extract migration parameters from event
157
- const { processId, dbType, stage } = extractMigrationParams(event);
152
+ const { migrationId, dbType, stage } = extractMigrationParams(event);
158
153
 
159
154
  // Get environment variables
160
155
  const databaseUrl = process.env.DATABASE_URL;
@@ -178,10 +173,14 @@ exports.handler = async (event, context) => {
178
173
  console.log(` Stage: ${stage}`);
179
174
  console.log(` Database URL: ${sanitizeDatabaseUrl(databaseUrl)}`);
180
175
 
181
- // Update process state to RUNNING (if processId provided)
182
- if (processId) {
183
- console.log(`\n✓ Updating process state to RUNNING: ${processId}`);
184
- await updateProcessState.execute(processId, 'RUNNING', {
176
+ // Update migration status to RUNNING (if migrationId provided)
177
+ if (migrationId) {
178
+ console.log(`\n✓ Updating migration status to RUNNING: ${migrationId}`);
179
+ await migrationStatusRepository.update({
180
+ migrationId,
181
+ stage,
182
+ state: 'RUNNING',
183
+ progress: 10,
185
184
  startedAt: new Date().toISOString(),
186
185
  });
187
186
  }
@@ -212,10 +211,14 @@ exports.handler = async (event, context) => {
212
211
  console.log(` Command: ${result.command}`);
213
212
  console.log('========================================');
214
213
 
215
- // Update process state to COMPLETED (if processId provided)
216
- if (processId) {
217
- console.log(`\n✓ Updating process state to COMPLETED: ${processId}`);
218
- await updateProcessState.execute(processId, 'COMPLETED', {
214
+ // Update migration status to COMPLETED (if migrationId provided)
215
+ if (migrationId) {
216
+ console.log(`\n✓ Updating migration status to COMPLETED: ${migrationId}`);
217
+ await migrationStatusRepository.update({
218
+ migrationId,
219
+ stage,
220
+ state: 'COMPLETED',
221
+ progress: 100,
219
222
  completedAt: new Date().toISOString(),
220
223
  migrationCommand: result.command,
221
224
  });
@@ -231,8 +234,8 @@ exports.handler = async (event, context) => {
231
234
  timestamp: new Date().toISOString(),
232
235
  };
233
236
 
234
- if (processId) {
235
- responseBody.processId = processId;
237
+ if (migrationId) {
238
+ responseBody.migrationId = migrationId;
236
239
  }
237
240
 
238
241
  return {
@@ -269,18 +272,21 @@ exports.handler = async (event, context) => {
269
272
  // Sanitize error message before returning
270
273
  const sanitizedError = sanitizeError(errorMessage);
271
274
 
272
- // Update process state to FAILED (if processId provided)
273
- if (processId) {
275
+ // Update migration status to FAILED (if migrationId provided)
276
+ if (migrationId) {
274
277
  try {
275
- console.log(`\n✓ Updating process state to FAILED: ${processId}`);
276
- await updateProcessState.execute(processId, 'FAILED', {
277
- failedAt: new Date().toISOString(),
278
+ console.log(`\n✓ Updating migration status to FAILED: ${migrationId}`);
279
+ await migrationStatusRepository.update({
280
+ migrationId,
281
+ stage,
282
+ state: 'FAILED',
283
+ progress: 0,
278
284
  error: sanitizedError,
279
- errorType: error.name || 'Error',
285
+ failedAt: new Date().toISOString(),
280
286
  });
281
287
  } catch (updateError) {
282
- console.error('Failed to update process state:', updateError);
283
- // Don't fail the entire handler if state update fails
288
+ console.error('Failed to update migration status:', updateError.message);
289
+ // Continue - don't let status update failure block error response
284
290
  }
285
291
  }
286
292
 
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.40be5d4.0",
4
+ "version": "2.0.0--canary.461.d9e6ed3.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.40be5d4.0",
41
- "@friggframework/prettier-config": "2.0.0--canary.461.40be5d4.0",
42
- "@friggframework/test": "2.0.0--canary.461.40be5d4.0",
40
+ "@friggframework/eslint-config": "2.0.0--canary.461.d9e6ed3.0",
41
+ "@friggframework/prettier-config": "2.0.0--canary.461.d9e6ed3.0",
42
+ "@friggframework/test": "2.0.0--canary.461.d9e6ed3.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": "40be5d49a7b1b9492aedfd669b1ab4ce56c82c11"
82
+ "gitHead": "d9e6ed3383bf057b4114c45c96e99a461f73bd17"
83
83
  }