@adaptic/backend-legacy 0.0.903 → 0.0.905
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/ABTest.cjs +291 -63
- package/Account.cjs +291 -63
- package/AccountLinkingRequest.cjs +291 -63
- package/Action.cjs +291 -63
- package/Alert.cjs +291 -63
- package/Allocation.cjs +291 -63
- package/AlpacaAccount.cjs +291 -63
- package/AnalyticsConfiguration.cjs +291 -63
- package/AnalyticsSnapshot.cjs +291 -63
- package/Asset.cjs +291 -63
- package/AuditLog.cjs +291 -63
- package/Authenticator.cjs +291 -63
- package/Configuration.cjs +291 -63
- package/ConflictEvent.cjs +291 -63
- package/ConnectionHealthSnapshot.cjs +291 -63
- package/Customer.cjs +291 -63
- package/DeadLetterMessage.cjs +291 -63
- package/EconomicEvent.cjs +291 -63
- package/Event.cjs +291 -63
- package/EventSnapshot.cjs +291 -63
- package/FeatureImportanceAnalysis.cjs +291 -63
- package/InstitutionalFlowSignal.cjs +291 -63
- package/InstitutionalHolding.cjs +291 -63
- package/InstitutionalSentimentAlerts.cjs +291 -63
- package/InstitutionalSentimentErrors.cjs +291 -63
- package/InstitutionalSentimentHistory.cjs +291 -63
- package/InstitutionalSentimentMetrics.cjs +291 -63
- package/InviteToken.cjs +291 -63
- package/LinkedProvider.cjs +291 -63
- package/MLTrainingData.cjs +291 -63
- package/MarketSentiment.cjs +291 -63
- package/ModelArtifact.cjs +291 -63
- package/ModelVersion.cjs +291 -63
- package/ModelVersionArtifact.cjs +291 -63
- package/NewsArticle.cjs +291 -63
- package/NewsArticleAssetSentiment.cjs +291 -63
- package/OptionsContract.cjs +291 -63
- package/OptionsGreeksHistory.cjs +291 -63
- package/OptionsPosition.cjs +291 -63
- package/OptionsTradeExecution.cjs +291 -63
- package/PortfolioGreeksHistory.cjs +291 -63
- package/ScheduledOptionOrder.cjs +291 -63
- package/Session.cjs +291 -63
- package/SignalGeneratorMetrics.cjs +291 -63
- package/SignalLineage.cjs +291 -63
- package/SignalOutcome.cjs +291 -63
- package/SignalPriorityQueue.cjs +291 -63
- package/SyncEvent.cjs +291 -63
- package/SystemAlert.cjs +291 -63
- package/Trade.cjs +291 -63
- package/TradeAuditEvent.cjs +291 -63
- package/TradeExecutionHistory.cjs +291 -63
- package/User.cjs +291 -63
- package/VerificationToken.cjs +291 -63
- package/WaitlistEntry.cjs +291 -63
- package/esm/ABTest.d.ts.map +1 -1
- package/esm/ABTest.js.map +1 -1
- package/esm/ABTest.mjs +255 -27
- package/esm/Account.d.ts.map +1 -1
- package/esm/Account.js.map +1 -1
- package/esm/Account.mjs +255 -27
- package/esm/AccountLinkingRequest.d.ts.map +1 -1
- package/esm/AccountLinkingRequest.js.map +1 -1
- package/esm/AccountLinkingRequest.mjs +255 -27
- package/esm/Action.d.ts.map +1 -1
- package/esm/Action.js.map +1 -1
- package/esm/Action.mjs +255 -27
- package/esm/Alert.d.ts.map +1 -1
- package/esm/Alert.js.map +1 -1
- package/esm/Alert.mjs +255 -27
- package/esm/Allocation.d.ts.map +1 -1
- package/esm/Allocation.js.map +1 -1
- package/esm/Allocation.mjs +255 -27
- package/esm/AlpacaAccount.d.ts.map +1 -1
- package/esm/AlpacaAccount.js.map +1 -1
- package/esm/AlpacaAccount.mjs +255 -27
- package/esm/AnalyticsConfiguration.d.ts.map +1 -1
- package/esm/AnalyticsConfiguration.js.map +1 -1
- package/esm/AnalyticsConfiguration.mjs +255 -27
- package/esm/AnalyticsSnapshot.d.ts.map +1 -1
- package/esm/AnalyticsSnapshot.js.map +1 -1
- package/esm/AnalyticsSnapshot.mjs +255 -27
- package/esm/Asset.d.ts.map +1 -1
- package/esm/Asset.js.map +1 -1
- package/esm/Asset.mjs +255 -27
- package/esm/AuditLog.d.ts.map +1 -1
- package/esm/AuditLog.js.map +1 -1
- package/esm/AuditLog.mjs +255 -27
- package/esm/Authenticator.d.ts.map +1 -1
- package/esm/Authenticator.js.map +1 -1
- package/esm/Authenticator.mjs +255 -27
- package/esm/Configuration.d.ts.map +1 -1
- package/esm/Configuration.js.map +1 -1
- package/esm/Configuration.mjs +255 -27
- package/esm/ConflictEvent.d.ts.map +1 -1
- package/esm/ConflictEvent.js.map +1 -1
- package/esm/ConflictEvent.mjs +255 -27
- package/esm/ConnectionHealthSnapshot.d.ts.map +1 -1
- package/esm/ConnectionHealthSnapshot.js.map +1 -1
- package/esm/ConnectionHealthSnapshot.mjs +255 -27
- package/esm/Customer.d.ts.map +1 -1
- package/esm/Customer.js.map +1 -1
- package/esm/Customer.mjs +255 -27
- package/esm/DeadLetterMessage.d.ts.map +1 -1
- package/esm/DeadLetterMessage.js.map +1 -1
- package/esm/DeadLetterMessage.mjs +255 -27
- package/esm/EconomicEvent.d.ts.map +1 -1
- package/esm/EconomicEvent.js.map +1 -1
- package/esm/EconomicEvent.mjs +255 -27
- package/esm/Event.d.ts.map +1 -1
- package/esm/Event.js.map +1 -1
- package/esm/Event.mjs +255 -27
- package/esm/EventSnapshot.d.ts.map +1 -1
- package/esm/EventSnapshot.js.map +1 -1
- package/esm/EventSnapshot.mjs +255 -27
- package/esm/FeatureImportanceAnalysis.d.ts.map +1 -1
- package/esm/FeatureImportanceAnalysis.js.map +1 -1
- package/esm/FeatureImportanceAnalysis.mjs +255 -27
- package/esm/InstitutionalFlowSignal.d.ts.map +1 -1
- package/esm/InstitutionalFlowSignal.js.map +1 -1
- package/esm/InstitutionalFlowSignal.mjs +255 -27
- package/esm/InstitutionalHolding.d.ts.map +1 -1
- package/esm/InstitutionalHolding.js.map +1 -1
- package/esm/InstitutionalHolding.mjs +255 -27
- package/esm/InstitutionalSentimentAlerts.d.ts.map +1 -1
- package/esm/InstitutionalSentimentAlerts.js.map +1 -1
- package/esm/InstitutionalSentimentAlerts.mjs +255 -27
- package/esm/InstitutionalSentimentErrors.d.ts.map +1 -1
- package/esm/InstitutionalSentimentErrors.js.map +1 -1
- package/esm/InstitutionalSentimentErrors.mjs +255 -27
- package/esm/InstitutionalSentimentHistory.d.ts.map +1 -1
- package/esm/InstitutionalSentimentHistory.js.map +1 -1
- package/esm/InstitutionalSentimentHistory.mjs +255 -27
- package/esm/InstitutionalSentimentMetrics.d.ts.map +1 -1
- package/esm/InstitutionalSentimentMetrics.js.map +1 -1
- package/esm/InstitutionalSentimentMetrics.mjs +255 -27
- package/esm/InviteToken.d.ts.map +1 -1
- package/esm/InviteToken.js.map +1 -1
- package/esm/InviteToken.mjs +255 -27
- package/esm/LinkedProvider.d.ts.map +1 -1
- package/esm/LinkedProvider.js.map +1 -1
- package/esm/LinkedProvider.mjs +255 -27
- package/esm/MLTrainingData.d.ts.map +1 -1
- package/esm/MLTrainingData.js.map +1 -1
- package/esm/MLTrainingData.mjs +255 -27
- package/esm/MarketSentiment.d.ts.map +1 -1
- package/esm/MarketSentiment.js.map +1 -1
- package/esm/MarketSentiment.mjs +255 -27
- package/esm/ModelArtifact.d.ts.map +1 -1
- package/esm/ModelArtifact.js.map +1 -1
- package/esm/ModelArtifact.mjs +255 -27
- package/esm/ModelVersion.d.ts.map +1 -1
- package/esm/ModelVersion.js.map +1 -1
- package/esm/ModelVersion.mjs +255 -27
- package/esm/ModelVersionArtifact.d.ts.map +1 -1
- package/esm/ModelVersionArtifact.js.map +1 -1
- package/esm/ModelVersionArtifact.mjs +255 -27
- package/esm/NewsArticle.d.ts.map +1 -1
- package/esm/NewsArticle.js.map +1 -1
- package/esm/NewsArticle.mjs +255 -27
- package/esm/NewsArticleAssetSentiment.d.ts.map +1 -1
- package/esm/NewsArticleAssetSentiment.js.map +1 -1
- package/esm/NewsArticleAssetSentiment.mjs +255 -27
- package/esm/OptionsContract.d.ts.map +1 -1
- package/esm/OptionsContract.js.map +1 -1
- package/esm/OptionsContract.mjs +255 -27
- package/esm/OptionsGreeksHistory.d.ts.map +1 -1
- package/esm/OptionsGreeksHistory.js.map +1 -1
- package/esm/OptionsGreeksHistory.mjs +255 -27
- package/esm/OptionsPosition.d.ts.map +1 -1
- package/esm/OptionsPosition.js.map +1 -1
- package/esm/OptionsPosition.mjs +255 -27
- package/esm/OptionsTradeExecution.d.ts.map +1 -1
- package/esm/OptionsTradeExecution.js.map +1 -1
- package/esm/OptionsTradeExecution.mjs +255 -27
- package/esm/PortfolioGreeksHistory.d.ts.map +1 -1
- package/esm/PortfolioGreeksHistory.js.map +1 -1
- package/esm/PortfolioGreeksHistory.mjs +255 -27
- package/esm/ScheduledOptionOrder.d.ts.map +1 -1
- package/esm/ScheduledOptionOrder.js.map +1 -1
- package/esm/ScheduledOptionOrder.mjs +255 -27
- package/esm/Session.d.ts.map +1 -1
- package/esm/Session.js.map +1 -1
- package/esm/Session.mjs +255 -27
- package/esm/SignalGeneratorMetrics.d.ts.map +1 -1
- package/esm/SignalGeneratorMetrics.js.map +1 -1
- package/esm/SignalGeneratorMetrics.mjs +255 -27
- package/esm/SignalLineage.d.ts.map +1 -1
- package/esm/SignalLineage.js.map +1 -1
- package/esm/SignalLineage.mjs +255 -27
- package/esm/SignalOutcome.d.ts.map +1 -1
- package/esm/SignalOutcome.js.map +1 -1
- package/esm/SignalOutcome.mjs +255 -27
- package/esm/SignalPriorityQueue.d.ts.map +1 -1
- package/esm/SignalPriorityQueue.js.map +1 -1
- package/esm/SignalPriorityQueue.mjs +255 -27
- package/esm/SyncEvent.d.ts.map +1 -1
- package/esm/SyncEvent.js.map +1 -1
- package/esm/SyncEvent.mjs +255 -27
- package/esm/SystemAlert.d.ts.map +1 -1
- package/esm/SystemAlert.js.map +1 -1
- package/esm/SystemAlert.mjs +255 -27
- package/esm/Trade.d.ts.map +1 -1
- package/esm/Trade.js.map +1 -1
- package/esm/Trade.mjs +255 -27
- package/esm/TradeAuditEvent.d.ts.map +1 -1
- package/esm/TradeAuditEvent.js.map +1 -1
- package/esm/TradeAuditEvent.mjs +255 -27
- package/esm/TradeExecutionHistory.d.ts.map +1 -1
- package/esm/TradeExecutionHistory.js.map +1 -1
- package/esm/TradeExecutionHistory.mjs +255 -27
- package/esm/User.d.ts.map +1 -1
- package/esm/User.js.map +1 -1
- package/esm/User.mjs +255 -27
- package/esm/VerificationToken.d.ts.map +1 -1
- package/esm/VerificationToken.js.map +1 -1
- package/esm/VerificationToken.mjs +255 -27
- package/esm/WaitlistEntry.d.ts.map +1 -1
- package/esm/WaitlistEntry.js.map +1 -1
- package/esm/WaitlistEntry.mjs +255 -27
- package/esm/middleware/audit-logger.d.ts +0 -7
- package/esm/middleware/audit-logger.d.ts.map +1 -1
- package/esm/middleware/audit-logger.js.map +1 -1
- package/esm/middleware/audit-logger.mjs +5 -3
- package/esm/prismaClient.d.ts.map +1 -1
- package/esm/prismaClient.js.map +1 -1
- package/esm/prismaClient.mjs +38 -9
- package/package.json +1 -1
- package/prismaClient.cjs +38 -9
package/esm/AuditLog.mjs
CHANGED
|
@@ -85,6 +85,27 @@ export const AuditLog = {
|
|
|
85
85
|
}
|
|
86
86
|
catch (error) {
|
|
87
87
|
lastError = error;
|
|
88
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
89
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
90
|
+
error.message?.includes('violates unique constraint') ||
|
|
91
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
92
|
+
error.message?.includes('unique constraint') ||
|
|
93
|
+
error.message?.includes('23514') ||
|
|
94
|
+
error.message?.includes('23505') ||
|
|
95
|
+
error.message?.includes('P2002') ||
|
|
96
|
+
error.message?.includes('P2003');
|
|
97
|
+
if (isConstraintViolation) {
|
|
98
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
99
|
+
logger.error("Non-retryable constraint violation in createOneAuditLog", {
|
|
100
|
+
operation: 'createOneAuditLog',
|
|
101
|
+
model: 'AuditLog',
|
|
102
|
+
error: String(error),
|
|
103
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
104
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
105
|
+
isRetryable: false,
|
|
106
|
+
});
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
88
109
|
// Check if this is a database connection error that we should retry
|
|
89
110
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
90
111
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -94,12 +115,22 @@ export const AuditLog = {
|
|
|
94
115
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
95
116
|
retryCount++;
|
|
96
117
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
97
|
-
logger.warn("Database connection error, retrying..."
|
|
118
|
+
logger.warn("Database connection error in createOneAuditLog, retrying...", {
|
|
119
|
+
operation: 'createOneAuditLog',
|
|
120
|
+
model: 'AuditLog',
|
|
121
|
+
attempt: retryCount,
|
|
122
|
+
maxRetries: MAX_RETRIES,
|
|
123
|
+
});
|
|
98
124
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
99
125
|
continue;
|
|
100
126
|
}
|
|
101
|
-
// Log
|
|
102
|
-
logger.error("Database
|
|
127
|
+
// Log structured error details and rethrow
|
|
128
|
+
logger.error("Database create operation failed", {
|
|
129
|
+
operation: 'createOneAuditLog',
|
|
130
|
+
model: 'AuditLog',
|
|
131
|
+
error: String(error),
|
|
132
|
+
isRetryable: isConnectionError,
|
|
133
|
+
});
|
|
103
134
|
throw error;
|
|
104
135
|
}
|
|
105
136
|
}
|
|
@@ -165,6 +196,27 @@ export const AuditLog = {
|
|
|
165
196
|
}
|
|
166
197
|
catch (error) {
|
|
167
198
|
lastError = error;
|
|
199
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
200
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
201
|
+
error.message?.includes('violates unique constraint') ||
|
|
202
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
203
|
+
error.message?.includes('unique constraint') ||
|
|
204
|
+
error.message?.includes('23514') ||
|
|
205
|
+
error.message?.includes('23505') ||
|
|
206
|
+
error.message?.includes('P2002') ||
|
|
207
|
+
error.message?.includes('P2003');
|
|
208
|
+
if (isConstraintViolation) {
|
|
209
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
210
|
+
logger.error("Non-retryable constraint violation in createManyAuditLog", {
|
|
211
|
+
operation: 'createManyAuditLog',
|
|
212
|
+
model: 'AuditLog',
|
|
213
|
+
error: String(error),
|
|
214
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
215
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
216
|
+
isRetryable: false,
|
|
217
|
+
});
|
|
218
|
+
throw error;
|
|
219
|
+
}
|
|
168
220
|
// Check if this is a database connection error that we should retry
|
|
169
221
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
170
222
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -174,12 +226,22 @@ export const AuditLog = {
|
|
|
174
226
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
175
227
|
retryCount++;
|
|
176
228
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
177
|
-
logger.warn("Database connection error, retrying..."
|
|
229
|
+
logger.warn("Database connection error in createManyAuditLog, retrying...", {
|
|
230
|
+
operation: 'createManyAuditLog',
|
|
231
|
+
model: 'AuditLog',
|
|
232
|
+
attempt: retryCount,
|
|
233
|
+
maxRetries: MAX_RETRIES,
|
|
234
|
+
});
|
|
178
235
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
179
236
|
continue;
|
|
180
237
|
}
|
|
181
|
-
// Log
|
|
182
|
-
logger.error("Database
|
|
238
|
+
// Log structured error details and rethrow
|
|
239
|
+
logger.error("Database createMany operation failed", {
|
|
240
|
+
operation: 'createManyAuditLog',
|
|
241
|
+
model: 'AuditLog',
|
|
242
|
+
error: String(error),
|
|
243
|
+
isRetryable: isConnectionError,
|
|
244
|
+
});
|
|
183
245
|
throw error;
|
|
184
246
|
}
|
|
185
247
|
}
|
|
@@ -272,6 +334,28 @@ export const AuditLog = {
|
|
|
272
334
|
}
|
|
273
335
|
catch (error) {
|
|
274
336
|
lastError = error;
|
|
337
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
338
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
339
|
+
error.message?.includes('violates unique constraint') ||
|
|
340
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
341
|
+
error.message?.includes('unique constraint') ||
|
|
342
|
+
error.message?.includes('23514') ||
|
|
343
|
+
error.message?.includes('23505') ||
|
|
344
|
+
error.message?.includes('P2002') ||
|
|
345
|
+
error.message?.includes('P2003');
|
|
346
|
+
if (isConstraintViolation) {
|
|
347
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
348
|
+
logger.error("Non-retryable constraint violation in updateOneAuditLog", {
|
|
349
|
+
operation: 'updateOneAuditLog',
|
|
350
|
+
model: 'AuditLog',
|
|
351
|
+
error: String(error),
|
|
352
|
+
recordId: props.id,
|
|
353
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
354
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
355
|
+
isRetryable: false,
|
|
356
|
+
});
|
|
357
|
+
throw error;
|
|
358
|
+
}
|
|
275
359
|
// Check if this is a database connection error that we should retry
|
|
276
360
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
277
361
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -281,12 +365,24 @@ export const AuditLog = {
|
|
|
281
365
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
282
366
|
retryCount++;
|
|
283
367
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
284
|
-
logger.warn("Database connection error, retrying..."
|
|
368
|
+
logger.warn("Database connection error in updateOneAuditLog, retrying...", {
|
|
369
|
+
operation: 'updateOneAuditLog',
|
|
370
|
+
model: 'AuditLog',
|
|
371
|
+
attempt: retryCount,
|
|
372
|
+
maxRetries: MAX_RETRIES,
|
|
373
|
+
recordId: props.id,
|
|
374
|
+
});
|
|
285
375
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
286
376
|
continue;
|
|
287
377
|
}
|
|
288
|
-
// Log
|
|
289
|
-
logger.error("Database
|
|
378
|
+
// Log structured error details and rethrow
|
|
379
|
+
logger.error("Database update operation failed", {
|
|
380
|
+
operation: 'updateOneAuditLog',
|
|
381
|
+
model: 'AuditLog',
|
|
382
|
+
error: String(error),
|
|
383
|
+
recordId: props.id,
|
|
384
|
+
isRetryable: isConnectionError,
|
|
385
|
+
});
|
|
290
386
|
throw error;
|
|
291
387
|
}
|
|
292
388
|
}
|
|
@@ -387,6 +483,28 @@ export const AuditLog = {
|
|
|
387
483
|
}
|
|
388
484
|
catch (error) {
|
|
389
485
|
lastError = error;
|
|
486
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
487
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
488
|
+
error.message?.includes('violates unique constraint') ||
|
|
489
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
490
|
+
error.message?.includes('unique constraint') ||
|
|
491
|
+
error.message?.includes('23514') ||
|
|
492
|
+
error.message?.includes('23505') ||
|
|
493
|
+
error.message?.includes('P2002') ||
|
|
494
|
+
error.message?.includes('P2003');
|
|
495
|
+
if (isConstraintViolation) {
|
|
496
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
497
|
+
logger.error("Non-retryable constraint violation in upsertOneAuditLog", {
|
|
498
|
+
operation: 'upsertOneAuditLog',
|
|
499
|
+
model: 'AuditLog',
|
|
500
|
+
error: String(error),
|
|
501
|
+
recordId: props.id,
|
|
502
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
503
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
504
|
+
isRetryable: false,
|
|
505
|
+
});
|
|
506
|
+
throw error;
|
|
507
|
+
}
|
|
390
508
|
// Check if this is a database connection error that we should retry
|
|
391
509
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
392
510
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -396,12 +514,24 @@ export const AuditLog = {
|
|
|
396
514
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
397
515
|
retryCount++;
|
|
398
516
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
399
|
-
logger.warn("Database connection error, retrying..."
|
|
517
|
+
logger.warn("Database connection error in upsertOneAuditLog, retrying...", {
|
|
518
|
+
operation: 'upsertOneAuditLog',
|
|
519
|
+
model: 'AuditLog',
|
|
520
|
+
attempt: retryCount,
|
|
521
|
+
maxRetries: MAX_RETRIES,
|
|
522
|
+
recordId: props.id,
|
|
523
|
+
});
|
|
400
524
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
401
525
|
continue;
|
|
402
526
|
}
|
|
403
|
-
// Log
|
|
404
|
-
logger.error("Database
|
|
527
|
+
// Log structured error details and rethrow
|
|
528
|
+
logger.error("Database upsert operation failed", {
|
|
529
|
+
operation: 'upsertOneAuditLog',
|
|
530
|
+
model: 'AuditLog',
|
|
531
|
+
error: String(error),
|
|
532
|
+
recordId: props.id,
|
|
533
|
+
isRetryable: isConnectionError,
|
|
534
|
+
});
|
|
405
535
|
throw error;
|
|
406
536
|
}
|
|
407
537
|
}
|
|
@@ -494,6 +624,27 @@ export const AuditLog = {
|
|
|
494
624
|
}
|
|
495
625
|
catch (error) {
|
|
496
626
|
lastError = error;
|
|
627
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
628
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
629
|
+
error.message?.includes('violates unique constraint') ||
|
|
630
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
631
|
+
error.message?.includes('unique constraint') ||
|
|
632
|
+
error.message?.includes('23514') ||
|
|
633
|
+
error.message?.includes('23505') ||
|
|
634
|
+
error.message?.includes('P2002') ||
|
|
635
|
+
error.message?.includes('P2003');
|
|
636
|
+
if (isConstraintViolation) {
|
|
637
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
638
|
+
logger.error("Non-retryable constraint violation in updateManyAuditLog", {
|
|
639
|
+
operation: 'updateManyAuditLog',
|
|
640
|
+
model: 'AuditLog',
|
|
641
|
+
error: String(error),
|
|
642
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
643
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
644
|
+
isRetryable: false,
|
|
645
|
+
});
|
|
646
|
+
throw error;
|
|
647
|
+
}
|
|
497
648
|
// Check if this is a database connection error that we should retry
|
|
498
649
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
499
650
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -503,12 +654,22 @@ export const AuditLog = {
|
|
|
503
654
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
504
655
|
retryCount++;
|
|
505
656
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
506
|
-
logger.warn("Database connection error, retrying..."
|
|
657
|
+
logger.warn("Database connection error in updateManyAuditLog, retrying...", {
|
|
658
|
+
operation: 'updateManyAuditLog',
|
|
659
|
+
model: 'AuditLog',
|
|
660
|
+
attempt: retryCount,
|
|
661
|
+
maxRetries: MAX_RETRIES,
|
|
662
|
+
});
|
|
507
663
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
508
664
|
continue;
|
|
509
665
|
}
|
|
510
|
-
// Log
|
|
511
|
-
logger.error("Database
|
|
666
|
+
// Log structured error details and rethrow
|
|
667
|
+
logger.error("Database updateMany operation failed", {
|
|
668
|
+
operation: 'updateManyAuditLog',
|
|
669
|
+
model: 'AuditLog',
|
|
670
|
+
error: String(error),
|
|
671
|
+
isRetryable: isConnectionError,
|
|
672
|
+
});
|
|
512
673
|
throw error;
|
|
513
674
|
}
|
|
514
675
|
}
|
|
@@ -566,6 +727,31 @@ export const AuditLog = {
|
|
|
566
727
|
}
|
|
567
728
|
catch (error) {
|
|
568
729
|
lastError = error;
|
|
730
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
731
|
+
// (e.g., foreign key constraints preventing deletion)
|
|
732
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
733
|
+
error.message?.includes('violates unique constraint') ||
|
|
734
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
735
|
+
error.message?.includes('unique constraint') ||
|
|
736
|
+
error.message?.includes('23514') ||
|
|
737
|
+
error.message?.includes('23505') ||
|
|
738
|
+
error.message?.includes('23503') ||
|
|
739
|
+
error.message?.includes('P2002') ||
|
|
740
|
+
error.message?.includes('P2003') ||
|
|
741
|
+
error.message?.includes('P2014');
|
|
742
|
+
if (isConstraintViolation) {
|
|
743
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
744
|
+
logger.error("Non-retryable constraint violation in deleteOneAuditLog", {
|
|
745
|
+
operation: 'deleteOneAuditLog',
|
|
746
|
+
model: 'AuditLog',
|
|
747
|
+
error: String(error),
|
|
748
|
+
recordId: props.id,
|
|
749
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
750
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
751
|
+
isRetryable: false,
|
|
752
|
+
});
|
|
753
|
+
throw error;
|
|
754
|
+
}
|
|
569
755
|
// Check if this is a database connection error that we should retry
|
|
570
756
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
571
757
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -575,12 +761,24 @@ export const AuditLog = {
|
|
|
575
761
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
576
762
|
retryCount++;
|
|
577
763
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
578
|
-
logger.warn("Database connection error, retrying..."
|
|
764
|
+
logger.warn("Database connection error in deleteOneAuditLog, retrying...", {
|
|
765
|
+
operation: 'deleteOneAuditLog',
|
|
766
|
+
model: 'AuditLog',
|
|
767
|
+
attempt: retryCount,
|
|
768
|
+
maxRetries: MAX_RETRIES,
|
|
769
|
+
recordId: props.id,
|
|
770
|
+
});
|
|
579
771
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
580
772
|
continue;
|
|
581
773
|
}
|
|
582
|
-
// Log
|
|
583
|
-
logger.error("Database
|
|
774
|
+
// Log structured error details and rethrow
|
|
775
|
+
logger.error("Database delete operation failed", {
|
|
776
|
+
operation: 'deleteOneAuditLog',
|
|
777
|
+
model: 'AuditLog',
|
|
778
|
+
error: String(error),
|
|
779
|
+
recordId: props.id,
|
|
780
|
+
isRetryable: isConnectionError,
|
|
781
|
+
});
|
|
584
782
|
throw error;
|
|
585
783
|
}
|
|
586
784
|
}
|
|
@@ -649,12 +847,22 @@ export const AuditLog = {
|
|
|
649
847
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
650
848
|
retryCount++;
|
|
651
849
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
652
|
-
logger.warn("Database connection error, retrying..."
|
|
850
|
+
logger.warn("Database connection error in getAuditLog, retrying...", {
|
|
851
|
+
operation: 'getAuditLog',
|
|
852
|
+
model: 'AuditLog',
|
|
853
|
+
attempt: retryCount,
|
|
854
|
+
maxRetries: MAX_RETRIES,
|
|
855
|
+
});
|
|
653
856
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
654
857
|
continue;
|
|
655
858
|
}
|
|
656
|
-
// Log
|
|
657
|
-
logger.error("Database
|
|
859
|
+
// Log structured error details and rethrow
|
|
860
|
+
logger.error("Database get operation failed", {
|
|
861
|
+
operation: 'getAuditLog',
|
|
862
|
+
model: 'AuditLog',
|
|
863
|
+
error: String(error),
|
|
864
|
+
isRetryable: isConnectionError,
|
|
865
|
+
});
|
|
658
866
|
throw error;
|
|
659
867
|
}
|
|
660
868
|
}
|
|
@@ -711,12 +919,22 @@ export const AuditLog = {
|
|
|
711
919
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
712
920
|
retryCount++;
|
|
713
921
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
714
|
-
logger.warn("Database connection error, retrying..."
|
|
922
|
+
logger.warn("Database connection error in getAllAuditLog, retrying...", {
|
|
923
|
+
operation: 'getAllAuditLog',
|
|
924
|
+
model: 'AuditLog',
|
|
925
|
+
attempt: retryCount,
|
|
926
|
+
maxRetries: MAX_RETRIES,
|
|
927
|
+
});
|
|
715
928
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
716
929
|
continue;
|
|
717
930
|
}
|
|
718
|
-
// Log
|
|
719
|
-
logger.error("Database
|
|
931
|
+
// Log structured error details and rethrow
|
|
932
|
+
logger.error("Database getAll operation failed", {
|
|
933
|
+
operation: 'getAllAuditLog',
|
|
934
|
+
model: 'AuditLog',
|
|
935
|
+
error: String(error),
|
|
936
|
+
isRetryable: isConnectionError,
|
|
937
|
+
});
|
|
720
938
|
throw error;
|
|
721
939
|
}
|
|
722
940
|
}
|
|
@@ -792,12 +1010,22 @@ export const AuditLog = {
|
|
|
792
1010
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
793
1011
|
retryCount++;
|
|
794
1012
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
795
|
-
logger.warn("Database connection error, retrying..."
|
|
1013
|
+
logger.warn("Database connection error in findManyAuditLog, retrying...", {
|
|
1014
|
+
operation: 'findManyAuditLog',
|
|
1015
|
+
model: 'AuditLog',
|
|
1016
|
+
attempt: retryCount,
|
|
1017
|
+
maxRetries: MAX_RETRIES,
|
|
1018
|
+
});
|
|
796
1019
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
797
1020
|
continue;
|
|
798
1021
|
}
|
|
799
|
-
// Log
|
|
800
|
-
logger.error("Database
|
|
1022
|
+
// Log structured error details and rethrow
|
|
1023
|
+
logger.error("Database findMany operation failed", {
|
|
1024
|
+
operation: 'findManyAuditLog',
|
|
1025
|
+
model: 'AuditLog',
|
|
1026
|
+
error: String(error),
|
|
1027
|
+
isRetryable: isConnectionError,
|
|
1028
|
+
});
|
|
801
1029
|
throw error;
|
|
802
1030
|
}
|
|
803
1031
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Authenticator.d.ts","sourceRoot":"","sources":["../../src/Authenticator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AACzG,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AAmM7G,eAAO,MAAM,aAAa;IAExB;;;;;OAKG;IAEH;;;;;;OAMG;kBACiB,iBAAiB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"Authenticator.d.ts","sourceRoot":"","sources":["../../src/Authenticator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AACzG,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AAmM7G,eAAO,MAAM,aAAa;IAExB;;;;;OAKG;IAEH;;;;;;OAMG;kBACiB,iBAAiB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA+a5H;;;;;;OAMG;sBACqB,iBAAiB,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAgHvI;;;;;;OAMG;kBACiB,iBAAiB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAyrC1H;;;;;;OAMG;kBACiB,iBAAiB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAm/C1H;;;;;;OAMG;sBACqB,iBAAiB,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAwrCvI;;;;;;OAMG;kBACiB,iBAAiB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAmH1H;;;;;;;OAOG;eACc,iBAAiB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAuFhJ;;;;;OAKG;0BACyB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,iBAAiB,EAAE,GAAG,IAAI,CAAC;IA4EzG;;;;;;;OAOG;oBACmB,iBAAiB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,iBAAiB,EAAE,GAAG,IAAI,CAAC;CA6FxJ,CAAC"}
|