@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/SystemAlert.mjs
CHANGED
|
@@ -109,6 +109,27 @@ export const SystemAlert = {
|
|
|
109
109
|
}
|
|
110
110
|
catch (error) {
|
|
111
111
|
lastError = error;
|
|
112
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
113
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
114
|
+
error.message?.includes('violates unique constraint') ||
|
|
115
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
116
|
+
error.message?.includes('unique constraint') ||
|
|
117
|
+
error.message?.includes('23514') ||
|
|
118
|
+
error.message?.includes('23505') ||
|
|
119
|
+
error.message?.includes('P2002') ||
|
|
120
|
+
error.message?.includes('P2003');
|
|
121
|
+
if (isConstraintViolation) {
|
|
122
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
123
|
+
logger.error("Non-retryable constraint violation in createOneSystemAlert", {
|
|
124
|
+
operation: 'createOneSystemAlert',
|
|
125
|
+
model: 'SystemAlert',
|
|
126
|
+
error: String(error),
|
|
127
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
128
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
129
|
+
isRetryable: false,
|
|
130
|
+
});
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
112
133
|
// Check if this is a database connection error that we should retry
|
|
113
134
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
114
135
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -118,12 +139,22 @@ export const SystemAlert = {
|
|
|
118
139
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
119
140
|
retryCount++;
|
|
120
141
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
121
|
-
logger.warn("Database connection error, retrying..."
|
|
142
|
+
logger.warn("Database connection error in createOneSystemAlert, retrying...", {
|
|
143
|
+
operation: 'createOneSystemAlert',
|
|
144
|
+
model: 'SystemAlert',
|
|
145
|
+
attempt: retryCount,
|
|
146
|
+
maxRetries: MAX_RETRIES,
|
|
147
|
+
});
|
|
122
148
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
123
149
|
continue;
|
|
124
150
|
}
|
|
125
|
-
// Log
|
|
126
|
-
logger.error("Database
|
|
151
|
+
// Log structured error details and rethrow
|
|
152
|
+
logger.error("Database create operation failed", {
|
|
153
|
+
operation: 'createOneSystemAlert',
|
|
154
|
+
model: 'SystemAlert',
|
|
155
|
+
error: String(error),
|
|
156
|
+
isRetryable: isConnectionError,
|
|
157
|
+
});
|
|
127
158
|
throw error;
|
|
128
159
|
}
|
|
129
160
|
}
|
|
@@ -200,6 +231,27 @@ export const SystemAlert = {
|
|
|
200
231
|
}
|
|
201
232
|
catch (error) {
|
|
202
233
|
lastError = error;
|
|
234
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
235
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
236
|
+
error.message?.includes('violates unique constraint') ||
|
|
237
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
238
|
+
error.message?.includes('unique constraint') ||
|
|
239
|
+
error.message?.includes('23514') ||
|
|
240
|
+
error.message?.includes('23505') ||
|
|
241
|
+
error.message?.includes('P2002') ||
|
|
242
|
+
error.message?.includes('P2003');
|
|
243
|
+
if (isConstraintViolation) {
|
|
244
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
245
|
+
logger.error("Non-retryable constraint violation in createManySystemAlert", {
|
|
246
|
+
operation: 'createManySystemAlert',
|
|
247
|
+
model: 'SystemAlert',
|
|
248
|
+
error: String(error),
|
|
249
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
250
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
251
|
+
isRetryable: false,
|
|
252
|
+
});
|
|
253
|
+
throw error;
|
|
254
|
+
}
|
|
203
255
|
// Check if this is a database connection error that we should retry
|
|
204
256
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
205
257
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -209,12 +261,22 @@ export const SystemAlert = {
|
|
|
209
261
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
210
262
|
retryCount++;
|
|
211
263
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
212
|
-
logger.warn("Database connection error, retrying..."
|
|
264
|
+
logger.warn("Database connection error in createManySystemAlert, retrying...", {
|
|
265
|
+
operation: 'createManySystemAlert',
|
|
266
|
+
model: 'SystemAlert',
|
|
267
|
+
attempt: retryCount,
|
|
268
|
+
maxRetries: MAX_RETRIES,
|
|
269
|
+
});
|
|
213
270
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
214
271
|
continue;
|
|
215
272
|
}
|
|
216
|
-
// Log
|
|
217
|
-
logger.error("Database
|
|
273
|
+
// Log structured error details and rethrow
|
|
274
|
+
logger.error("Database createMany operation failed", {
|
|
275
|
+
operation: 'createManySystemAlert',
|
|
276
|
+
model: 'SystemAlert',
|
|
277
|
+
error: String(error),
|
|
278
|
+
isRetryable: isConnectionError,
|
|
279
|
+
});
|
|
218
280
|
throw error;
|
|
219
281
|
}
|
|
220
282
|
}
|
|
@@ -349,6 +411,28 @@ export const SystemAlert = {
|
|
|
349
411
|
}
|
|
350
412
|
catch (error) {
|
|
351
413
|
lastError = error;
|
|
414
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
415
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
416
|
+
error.message?.includes('violates unique constraint') ||
|
|
417
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
418
|
+
error.message?.includes('unique constraint') ||
|
|
419
|
+
error.message?.includes('23514') ||
|
|
420
|
+
error.message?.includes('23505') ||
|
|
421
|
+
error.message?.includes('P2002') ||
|
|
422
|
+
error.message?.includes('P2003');
|
|
423
|
+
if (isConstraintViolation) {
|
|
424
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
425
|
+
logger.error("Non-retryable constraint violation in updateOneSystemAlert", {
|
|
426
|
+
operation: 'updateOneSystemAlert',
|
|
427
|
+
model: 'SystemAlert',
|
|
428
|
+
error: String(error),
|
|
429
|
+
recordId: props.id,
|
|
430
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
431
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
432
|
+
isRetryable: false,
|
|
433
|
+
});
|
|
434
|
+
throw error;
|
|
435
|
+
}
|
|
352
436
|
// Check if this is a database connection error that we should retry
|
|
353
437
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
354
438
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -358,12 +442,24 @@ export const SystemAlert = {
|
|
|
358
442
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
359
443
|
retryCount++;
|
|
360
444
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
361
|
-
logger.warn("Database connection error, retrying..."
|
|
445
|
+
logger.warn("Database connection error in updateOneSystemAlert, retrying...", {
|
|
446
|
+
operation: 'updateOneSystemAlert',
|
|
447
|
+
model: 'SystemAlert',
|
|
448
|
+
attempt: retryCount,
|
|
449
|
+
maxRetries: MAX_RETRIES,
|
|
450
|
+
recordId: props.id,
|
|
451
|
+
});
|
|
362
452
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
363
453
|
continue;
|
|
364
454
|
}
|
|
365
|
-
// Log
|
|
366
|
-
logger.error("Database
|
|
455
|
+
// Log structured error details and rethrow
|
|
456
|
+
logger.error("Database update operation failed", {
|
|
457
|
+
operation: 'updateOneSystemAlert',
|
|
458
|
+
model: 'SystemAlert',
|
|
459
|
+
error: String(error),
|
|
460
|
+
recordId: props.id,
|
|
461
|
+
isRetryable: isConnectionError,
|
|
462
|
+
});
|
|
367
463
|
throw error;
|
|
368
464
|
}
|
|
369
465
|
}
|
|
@@ -511,6 +607,28 @@ export const SystemAlert = {
|
|
|
511
607
|
}
|
|
512
608
|
catch (error) {
|
|
513
609
|
lastError = error;
|
|
610
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
611
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
612
|
+
error.message?.includes('violates unique constraint') ||
|
|
613
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
614
|
+
error.message?.includes('unique constraint') ||
|
|
615
|
+
error.message?.includes('23514') ||
|
|
616
|
+
error.message?.includes('23505') ||
|
|
617
|
+
error.message?.includes('P2002') ||
|
|
618
|
+
error.message?.includes('P2003');
|
|
619
|
+
if (isConstraintViolation) {
|
|
620
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
621
|
+
logger.error("Non-retryable constraint violation in upsertOneSystemAlert", {
|
|
622
|
+
operation: 'upsertOneSystemAlert',
|
|
623
|
+
model: 'SystemAlert',
|
|
624
|
+
error: String(error),
|
|
625
|
+
recordId: props.id,
|
|
626
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
627
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
628
|
+
isRetryable: false,
|
|
629
|
+
});
|
|
630
|
+
throw error;
|
|
631
|
+
}
|
|
514
632
|
// Check if this is a database connection error that we should retry
|
|
515
633
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
516
634
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -520,12 +638,24 @@ export const SystemAlert = {
|
|
|
520
638
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
521
639
|
retryCount++;
|
|
522
640
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
523
|
-
logger.warn("Database connection error, retrying..."
|
|
641
|
+
logger.warn("Database connection error in upsertOneSystemAlert, retrying...", {
|
|
642
|
+
operation: 'upsertOneSystemAlert',
|
|
643
|
+
model: 'SystemAlert',
|
|
644
|
+
attempt: retryCount,
|
|
645
|
+
maxRetries: MAX_RETRIES,
|
|
646
|
+
recordId: props.id,
|
|
647
|
+
});
|
|
524
648
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
525
649
|
continue;
|
|
526
650
|
}
|
|
527
|
-
// Log
|
|
528
|
-
logger.error("Database
|
|
651
|
+
// Log structured error details and rethrow
|
|
652
|
+
logger.error("Database upsert operation failed", {
|
|
653
|
+
operation: 'upsertOneSystemAlert',
|
|
654
|
+
model: 'SystemAlert',
|
|
655
|
+
error: String(error),
|
|
656
|
+
recordId: props.id,
|
|
657
|
+
isRetryable: isConnectionError,
|
|
658
|
+
});
|
|
529
659
|
throw error;
|
|
530
660
|
}
|
|
531
661
|
}
|
|
@@ -660,6 +790,27 @@ export const SystemAlert = {
|
|
|
660
790
|
}
|
|
661
791
|
catch (error) {
|
|
662
792
|
lastError = error;
|
|
793
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
794
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
795
|
+
error.message?.includes('violates unique constraint') ||
|
|
796
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
797
|
+
error.message?.includes('unique constraint') ||
|
|
798
|
+
error.message?.includes('23514') ||
|
|
799
|
+
error.message?.includes('23505') ||
|
|
800
|
+
error.message?.includes('P2002') ||
|
|
801
|
+
error.message?.includes('P2003');
|
|
802
|
+
if (isConstraintViolation) {
|
|
803
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
804
|
+
logger.error("Non-retryable constraint violation in updateManySystemAlert", {
|
|
805
|
+
operation: 'updateManySystemAlert',
|
|
806
|
+
model: 'SystemAlert',
|
|
807
|
+
error: String(error),
|
|
808
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
809
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
810
|
+
isRetryable: false,
|
|
811
|
+
});
|
|
812
|
+
throw error;
|
|
813
|
+
}
|
|
663
814
|
// Check if this is a database connection error that we should retry
|
|
664
815
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
665
816
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -669,12 +820,22 @@ export const SystemAlert = {
|
|
|
669
820
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
670
821
|
retryCount++;
|
|
671
822
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
672
|
-
logger.warn("Database connection error, retrying..."
|
|
823
|
+
logger.warn("Database connection error in updateManySystemAlert, retrying...", {
|
|
824
|
+
operation: 'updateManySystemAlert',
|
|
825
|
+
model: 'SystemAlert',
|
|
826
|
+
attempt: retryCount,
|
|
827
|
+
maxRetries: MAX_RETRIES,
|
|
828
|
+
});
|
|
673
829
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
674
830
|
continue;
|
|
675
831
|
}
|
|
676
|
-
// Log
|
|
677
|
-
logger.error("Database
|
|
832
|
+
// Log structured error details and rethrow
|
|
833
|
+
logger.error("Database updateMany operation failed", {
|
|
834
|
+
operation: 'updateManySystemAlert',
|
|
835
|
+
model: 'SystemAlert',
|
|
836
|
+
error: String(error),
|
|
837
|
+
isRetryable: isConnectionError,
|
|
838
|
+
});
|
|
678
839
|
throw error;
|
|
679
840
|
}
|
|
680
841
|
}
|
|
@@ -732,6 +893,31 @@ export const SystemAlert = {
|
|
|
732
893
|
}
|
|
733
894
|
catch (error) {
|
|
734
895
|
lastError = error;
|
|
896
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
897
|
+
// (e.g., foreign key constraints preventing deletion)
|
|
898
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
899
|
+
error.message?.includes('violates unique constraint') ||
|
|
900
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
901
|
+
error.message?.includes('unique constraint') ||
|
|
902
|
+
error.message?.includes('23514') ||
|
|
903
|
+
error.message?.includes('23505') ||
|
|
904
|
+
error.message?.includes('23503') ||
|
|
905
|
+
error.message?.includes('P2002') ||
|
|
906
|
+
error.message?.includes('P2003') ||
|
|
907
|
+
error.message?.includes('P2014');
|
|
908
|
+
if (isConstraintViolation) {
|
|
909
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
910
|
+
logger.error("Non-retryable constraint violation in deleteOneSystemAlert", {
|
|
911
|
+
operation: 'deleteOneSystemAlert',
|
|
912
|
+
model: 'SystemAlert',
|
|
913
|
+
error: String(error),
|
|
914
|
+
recordId: props.id,
|
|
915
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
916
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
917
|
+
isRetryable: false,
|
|
918
|
+
});
|
|
919
|
+
throw error;
|
|
920
|
+
}
|
|
735
921
|
// Check if this is a database connection error that we should retry
|
|
736
922
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
737
923
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -741,12 +927,24 @@ export const SystemAlert = {
|
|
|
741
927
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
742
928
|
retryCount++;
|
|
743
929
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
744
|
-
logger.warn("Database connection error, retrying..."
|
|
930
|
+
logger.warn("Database connection error in deleteOneSystemAlert, retrying...", {
|
|
931
|
+
operation: 'deleteOneSystemAlert',
|
|
932
|
+
model: 'SystemAlert',
|
|
933
|
+
attempt: retryCount,
|
|
934
|
+
maxRetries: MAX_RETRIES,
|
|
935
|
+
recordId: props.id,
|
|
936
|
+
});
|
|
745
937
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
746
938
|
continue;
|
|
747
939
|
}
|
|
748
|
-
// Log
|
|
749
|
-
logger.error("Database
|
|
940
|
+
// Log structured error details and rethrow
|
|
941
|
+
logger.error("Database delete operation failed", {
|
|
942
|
+
operation: 'deleteOneSystemAlert',
|
|
943
|
+
model: 'SystemAlert',
|
|
944
|
+
error: String(error),
|
|
945
|
+
recordId: props.id,
|
|
946
|
+
isRetryable: isConnectionError,
|
|
947
|
+
});
|
|
750
948
|
throw error;
|
|
751
949
|
}
|
|
752
950
|
}
|
|
@@ -818,12 +1016,22 @@ export const SystemAlert = {
|
|
|
818
1016
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
819
1017
|
retryCount++;
|
|
820
1018
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
821
|
-
logger.warn("Database connection error, retrying..."
|
|
1019
|
+
logger.warn("Database connection error in getSystemAlert, retrying...", {
|
|
1020
|
+
operation: 'getSystemAlert',
|
|
1021
|
+
model: 'SystemAlert',
|
|
1022
|
+
attempt: retryCount,
|
|
1023
|
+
maxRetries: MAX_RETRIES,
|
|
1024
|
+
});
|
|
822
1025
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
823
1026
|
continue;
|
|
824
1027
|
}
|
|
825
|
-
// Log
|
|
826
|
-
logger.error("Database
|
|
1028
|
+
// Log structured error details and rethrow
|
|
1029
|
+
logger.error("Database get operation failed", {
|
|
1030
|
+
operation: 'getSystemAlert',
|
|
1031
|
+
model: 'SystemAlert',
|
|
1032
|
+
error: String(error),
|
|
1033
|
+
isRetryable: isConnectionError,
|
|
1034
|
+
});
|
|
827
1035
|
throw error;
|
|
828
1036
|
}
|
|
829
1037
|
}
|
|
@@ -880,12 +1088,22 @@ export const SystemAlert = {
|
|
|
880
1088
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
881
1089
|
retryCount++;
|
|
882
1090
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
883
|
-
logger.warn("Database connection error, retrying..."
|
|
1091
|
+
logger.warn("Database connection error in getAllSystemAlert, retrying...", {
|
|
1092
|
+
operation: 'getAllSystemAlert',
|
|
1093
|
+
model: 'SystemAlert',
|
|
1094
|
+
attempt: retryCount,
|
|
1095
|
+
maxRetries: MAX_RETRIES,
|
|
1096
|
+
});
|
|
884
1097
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
885
1098
|
continue;
|
|
886
1099
|
}
|
|
887
|
-
// Log
|
|
888
|
-
logger.error("Database
|
|
1100
|
+
// Log structured error details and rethrow
|
|
1101
|
+
logger.error("Database getAll operation failed", {
|
|
1102
|
+
operation: 'getAllSystemAlert',
|
|
1103
|
+
model: 'SystemAlert',
|
|
1104
|
+
error: String(error),
|
|
1105
|
+
isRetryable: isConnectionError,
|
|
1106
|
+
});
|
|
889
1107
|
throw error;
|
|
890
1108
|
}
|
|
891
1109
|
}
|
|
@@ -964,12 +1182,22 @@ export const SystemAlert = {
|
|
|
964
1182
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
965
1183
|
retryCount++;
|
|
966
1184
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
967
|
-
logger.warn("Database connection error, retrying..."
|
|
1185
|
+
logger.warn("Database connection error in findManySystemAlert, retrying...", {
|
|
1186
|
+
operation: 'findManySystemAlert',
|
|
1187
|
+
model: 'SystemAlert',
|
|
1188
|
+
attempt: retryCount,
|
|
1189
|
+
maxRetries: MAX_RETRIES,
|
|
1190
|
+
});
|
|
968
1191
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
969
1192
|
continue;
|
|
970
1193
|
}
|
|
971
|
-
// Log
|
|
972
|
-
logger.error("Database
|
|
1194
|
+
// Log structured error details and rethrow
|
|
1195
|
+
logger.error("Database findMany operation failed", {
|
|
1196
|
+
operation: 'findManySystemAlert',
|
|
1197
|
+
model: 'SystemAlert',
|
|
1198
|
+
error: String(error),
|
|
1199
|
+
isRetryable: isConnectionError,
|
|
1200
|
+
});
|
|
973
1201
|
throw error;
|
|
974
1202
|
}
|
|
975
1203
|
}
|
package/esm/Trade.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Trade.d.ts","sourceRoot":"","sources":["../../src/Trade.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AAsD7G,eAAO,MAAM,KAAK;IAEhB;;;;;OAKG;IAEH;;;;;;OAMG;kBACiB,SAAS,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Trade.d.ts","sourceRoot":"","sources":["../../src/Trade.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AAsD7G,eAAO,MAAM,KAAK;IAEhB;;;;;OAKG;IAEH;;;;;;OAMG;kBACiB,SAAS,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;IAgK5G;;;;;;OAMG;sBACqB,SAAS,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAqI/H;;;;;;OAMG;kBACiB,SAAS,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;IA8P1G;;;;;;OAMG;kBACiB,SAAS,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;IAyS1G;;;;;;OAMG;sBACqB,SAAS,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IA6P/H;;;;;;OAMG;kBACiB,SAAS,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;IAmH1G;;;;;;;OAOG;eACc,SAAS,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IA0FhI;;;;;OAKG;0BACyB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC;IA4EjG;;;;;;;OAOG;oBACmB,SAAS,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC;CAgGxI,CAAC"}
|