@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/Alert.mjs
CHANGED
|
@@ -377,6 +377,27 @@ export const Alert = {
|
|
|
377
377
|
}
|
|
378
378
|
catch (error) {
|
|
379
379
|
lastError = error;
|
|
380
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
381
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
382
|
+
error.message?.includes('violates unique constraint') ||
|
|
383
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
384
|
+
error.message?.includes('unique constraint') ||
|
|
385
|
+
error.message?.includes('23514') ||
|
|
386
|
+
error.message?.includes('23505') ||
|
|
387
|
+
error.message?.includes('P2002') ||
|
|
388
|
+
error.message?.includes('P2003');
|
|
389
|
+
if (isConstraintViolation) {
|
|
390
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
391
|
+
logger.error("Non-retryable constraint violation in createOneAlert", {
|
|
392
|
+
operation: 'createOneAlert',
|
|
393
|
+
model: 'Alert',
|
|
394
|
+
error: String(error),
|
|
395
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
396
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
397
|
+
isRetryable: false,
|
|
398
|
+
});
|
|
399
|
+
throw error;
|
|
400
|
+
}
|
|
380
401
|
// Check if this is a database connection error that we should retry
|
|
381
402
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
382
403
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -386,12 +407,22 @@ export const Alert = {
|
|
|
386
407
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
387
408
|
retryCount++;
|
|
388
409
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
389
|
-
logger.warn("Database connection error, retrying..."
|
|
410
|
+
logger.warn("Database connection error in createOneAlert, retrying...", {
|
|
411
|
+
operation: 'createOneAlert',
|
|
412
|
+
model: 'Alert',
|
|
413
|
+
attempt: retryCount,
|
|
414
|
+
maxRetries: MAX_RETRIES,
|
|
415
|
+
});
|
|
390
416
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
391
417
|
continue;
|
|
392
418
|
}
|
|
393
|
-
// Log
|
|
394
|
-
logger.error("Database
|
|
419
|
+
// Log structured error details and rethrow
|
|
420
|
+
logger.error("Database create operation failed", {
|
|
421
|
+
operation: 'createOneAlert',
|
|
422
|
+
model: 'Alert',
|
|
423
|
+
error: String(error),
|
|
424
|
+
isRetryable: isConnectionError,
|
|
425
|
+
});
|
|
395
426
|
throw error;
|
|
396
427
|
}
|
|
397
428
|
}
|
|
@@ -461,6 +492,27 @@ export const Alert = {
|
|
|
461
492
|
}
|
|
462
493
|
catch (error) {
|
|
463
494
|
lastError = error;
|
|
495
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
496
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
497
|
+
error.message?.includes('violates unique constraint') ||
|
|
498
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
499
|
+
error.message?.includes('unique constraint') ||
|
|
500
|
+
error.message?.includes('23514') ||
|
|
501
|
+
error.message?.includes('23505') ||
|
|
502
|
+
error.message?.includes('P2002') ||
|
|
503
|
+
error.message?.includes('P2003');
|
|
504
|
+
if (isConstraintViolation) {
|
|
505
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
506
|
+
logger.error("Non-retryable constraint violation in createManyAlert", {
|
|
507
|
+
operation: 'createManyAlert',
|
|
508
|
+
model: 'Alert',
|
|
509
|
+
error: String(error),
|
|
510
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
511
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
512
|
+
isRetryable: false,
|
|
513
|
+
});
|
|
514
|
+
throw error;
|
|
515
|
+
}
|
|
464
516
|
// Check if this is a database connection error that we should retry
|
|
465
517
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
466
518
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -470,12 +522,22 @@ export const Alert = {
|
|
|
470
522
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
471
523
|
retryCount++;
|
|
472
524
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
473
|
-
logger.warn("Database connection error, retrying..."
|
|
525
|
+
logger.warn("Database connection error in createManyAlert, retrying...", {
|
|
526
|
+
operation: 'createManyAlert',
|
|
527
|
+
model: 'Alert',
|
|
528
|
+
attempt: retryCount,
|
|
529
|
+
maxRetries: MAX_RETRIES,
|
|
530
|
+
});
|
|
474
531
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
475
532
|
continue;
|
|
476
533
|
}
|
|
477
|
-
// Log
|
|
478
|
-
logger.error("Database
|
|
534
|
+
// Log structured error details and rethrow
|
|
535
|
+
logger.error("Database createMany operation failed", {
|
|
536
|
+
operation: 'createManyAlert',
|
|
537
|
+
model: 'Alert',
|
|
538
|
+
error: String(error),
|
|
539
|
+
isRetryable: isConnectionError,
|
|
540
|
+
});
|
|
479
541
|
throw error;
|
|
480
542
|
}
|
|
481
543
|
}
|
|
@@ -1638,6 +1700,28 @@ export const Alert = {
|
|
|
1638
1700
|
}
|
|
1639
1701
|
catch (error) {
|
|
1640
1702
|
lastError = error;
|
|
1703
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
1704
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
1705
|
+
error.message?.includes('violates unique constraint') ||
|
|
1706
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
1707
|
+
error.message?.includes('unique constraint') ||
|
|
1708
|
+
error.message?.includes('23514') ||
|
|
1709
|
+
error.message?.includes('23505') ||
|
|
1710
|
+
error.message?.includes('P2002') ||
|
|
1711
|
+
error.message?.includes('P2003');
|
|
1712
|
+
if (isConstraintViolation) {
|
|
1713
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
1714
|
+
logger.error("Non-retryable constraint violation in updateOneAlert", {
|
|
1715
|
+
operation: 'updateOneAlert',
|
|
1716
|
+
model: 'Alert',
|
|
1717
|
+
error: String(error),
|
|
1718
|
+
recordId: props.id,
|
|
1719
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
1720
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
1721
|
+
isRetryable: false,
|
|
1722
|
+
});
|
|
1723
|
+
throw error;
|
|
1724
|
+
}
|
|
1641
1725
|
// Check if this is a database connection error that we should retry
|
|
1642
1726
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
1643
1727
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -1647,12 +1731,24 @@ export const Alert = {
|
|
|
1647
1731
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
1648
1732
|
retryCount++;
|
|
1649
1733
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
1650
|
-
logger.warn("Database connection error, retrying..."
|
|
1734
|
+
logger.warn("Database connection error in updateOneAlert, retrying...", {
|
|
1735
|
+
operation: 'updateOneAlert',
|
|
1736
|
+
model: 'Alert',
|
|
1737
|
+
attempt: retryCount,
|
|
1738
|
+
maxRetries: MAX_RETRIES,
|
|
1739
|
+
recordId: props.id,
|
|
1740
|
+
});
|
|
1651
1741
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
1652
1742
|
continue;
|
|
1653
1743
|
}
|
|
1654
|
-
// Log
|
|
1655
|
-
logger.error("Database
|
|
1744
|
+
// Log structured error details and rethrow
|
|
1745
|
+
logger.error("Database update operation failed", {
|
|
1746
|
+
operation: 'updateOneAlert',
|
|
1747
|
+
model: 'Alert',
|
|
1748
|
+
error: String(error),
|
|
1749
|
+
recordId: props.id,
|
|
1750
|
+
isRetryable: isConnectionError,
|
|
1751
|
+
});
|
|
1656
1752
|
throw error;
|
|
1657
1753
|
}
|
|
1658
1754
|
}
|
|
@@ -3103,6 +3199,28 @@ export const Alert = {
|
|
|
3103
3199
|
}
|
|
3104
3200
|
catch (error) {
|
|
3105
3201
|
lastError = error;
|
|
3202
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
3203
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
3204
|
+
error.message?.includes('violates unique constraint') ||
|
|
3205
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
3206
|
+
error.message?.includes('unique constraint') ||
|
|
3207
|
+
error.message?.includes('23514') ||
|
|
3208
|
+
error.message?.includes('23505') ||
|
|
3209
|
+
error.message?.includes('P2002') ||
|
|
3210
|
+
error.message?.includes('P2003');
|
|
3211
|
+
if (isConstraintViolation) {
|
|
3212
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
3213
|
+
logger.error("Non-retryable constraint violation in upsertOneAlert", {
|
|
3214
|
+
operation: 'upsertOneAlert',
|
|
3215
|
+
model: 'Alert',
|
|
3216
|
+
error: String(error),
|
|
3217
|
+
recordId: props.id,
|
|
3218
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
3219
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
3220
|
+
isRetryable: false,
|
|
3221
|
+
});
|
|
3222
|
+
throw error;
|
|
3223
|
+
}
|
|
3106
3224
|
// Check if this is a database connection error that we should retry
|
|
3107
3225
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
3108
3226
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -3112,12 +3230,24 @@ export const Alert = {
|
|
|
3112
3230
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
3113
3231
|
retryCount++;
|
|
3114
3232
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
3115
|
-
logger.warn("Database connection error, retrying..."
|
|
3233
|
+
logger.warn("Database connection error in upsertOneAlert, retrying...", {
|
|
3234
|
+
operation: 'upsertOneAlert',
|
|
3235
|
+
model: 'Alert',
|
|
3236
|
+
attempt: retryCount,
|
|
3237
|
+
maxRetries: MAX_RETRIES,
|
|
3238
|
+
recordId: props.id,
|
|
3239
|
+
});
|
|
3116
3240
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
3117
3241
|
continue;
|
|
3118
3242
|
}
|
|
3119
|
-
// Log
|
|
3120
|
-
logger.error("Database
|
|
3243
|
+
// Log structured error details and rethrow
|
|
3244
|
+
logger.error("Database upsert operation failed", {
|
|
3245
|
+
operation: 'upsertOneAlert',
|
|
3246
|
+
model: 'Alert',
|
|
3247
|
+
error: String(error),
|
|
3248
|
+
recordId: props.id,
|
|
3249
|
+
isRetryable: isConnectionError,
|
|
3250
|
+
});
|
|
3121
3251
|
throw error;
|
|
3122
3252
|
}
|
|
3123
3253
|
}
|
|
@@ -4280,6 +4410,27 @@ export const Alert = {
|
|
|
4280
4410
|
}
|
|
4281
4411
|
catch (error) {
|
|
4282
4412
|
lastError = error;
|
|
4413
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
4414
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
4415
|
+
error.message?.includes('violates unique constraint') ||
|
|
4416
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
4417
|
+
error.message?.includes('unique constraint') ||
|
|
4418
|
+
error.message?.includes('23514') ||
|
|
4419
|
+
error.message?.includes('23505') ||
|
|
4420
|
+
error.message?.includes('P2002') ||
|
|
4421
|
+
error.message?.includes('P2003');
|
|
4422
|
+
if (isConstraintViolation) {
|
|
4423
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
4424
|
+
logger.error("Non-retryable constraint violation in updateManyAlert", {
|
|
4425
|
+
operation: 'updateManyAlert',
|
|
4426
|
+
model: 'Alert',
|
|
4427
|
+
error: String(error),
|
|
4428
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
4429
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
4430
|
+
isRetryable: false,
|
|
4431
|
+
});
|
|
4432
|
+
throw error;
|
|
4433
|
+
}
|
|
4283
4434
|
// Check if this is a database connection error that we should retry
|
|
4284
4435
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
4285
4436
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -4289,12 +4440,22 @@ export const Alert = {
|
|
|
4289
4440
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
4290
4441
|
retryCount++;
|
|
4291
4442
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
4292
|
-
logger.warn("Database connection error, retrying..."
|
|
4443
|
+
logger.warn("Database connection error in updateManyAlert, retrying...", {
|
|
4444
|
+
operation: 'updateManyAlert',
|
|
4445
|
+
model: 'Alert',
|
|
4446
|
+
attempt: retryCount,
|
|
4447
|
+
maxRetries: MAX_RETRIES,
|
|
4448
|
+
});
|
|
4293
4449
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
4294
4450
|
continue;
|
|
4295
4451
|
}
|
|
4296
|
-
// Log
|
|
4297
|
-
logger.error("Database
|
|
4452
|
+
// Log structured error details and rethrow
|
|
4453
|
+
logger.error("Database updateMany operation failed", {
|
|
4454
|
+
operation: 'updateManyAlert',
|
|
4455
|
+
model: 'Alert',
|
|
4456
|
+
error: String(error),
|
|
4457
|
+
isRetryable: isConnectionError,
|
|
4458
|
+
});
|
|
4298
4459
|
throw error;
|
|
4299
4460
|
}
|
|
4300
4461
|
}
|
|
@@ -4352,6 +4513,31 @@ export const Alert = {
|
|
|
4352
4513
|
}
|
|
4353
4514
|
catch (error) {
|
|
4354
4515
|
lastError = error;
|
|
4516
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
4517
|
+
// (e.g., foreign key constraints preventing deletion)
|
|
4518
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
4519
|
+
error.message?.includes('violates unique constraint') ||
|
|
4520
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
4521
|
+
error.message?.includes('unique constraint') ||
|
|
4522
|
+
error.message?.includes('23514') ||
|
|
4523
|
+
error.message?.includes('23505') ||
|
|
4524
|
+
error.message?.includes('23503') ||
|
|
4525
|
+
error.message?.includes('P2002') ||
|
|
4526
|
+
error.message?.includes('P2003') ||
|
|
4527
|
+
error.message?.includes('P2014');
|
|
4528
|
+
if (isConstraintViolation) {
|
|
4529
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
4530
|
+
logger.error("Non-retryable constraint violation in deleteOneAlert", {
|
|
4531
|
+
operation: 'deleteOneAlert',
|
|
4532
|
+
model: 'Alert',
|
|
4533
|
+
error: String(error),
|
|
4534
|
+
recordId: props.id,
|
|
4535
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
4536
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
4537
|
+
isRetryable: false,
|
|
4538
|
+
});
|
|
4539
|
+
throw error;
|
|
4540
|
+
}
|
|
4355
4541
|
// Check if this is a database connection error that we should retry
|
|
4356
4542
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
4357
4543
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -4361,12 +4547,24 @@ export const Alert = {
|
|
|
4361
4547
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
4362
4548
|
retryCount++;
|
|
4363
4549
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
4364
|
-
logger.warn("Database connection error, retrying..."
|
|
4550
|
+
logger.warn("Database connection error in deleteOneAlert, retrying...", {
|
|
4551
|
+
operation: 'deleteOneAlert',
|
|
4552
|
+
model: 'Alert',
|
|
4553
|
+
attempt: retryCount,
|
|
4554
|
+
maxRetries: MAX_RETRIES,
|
|
4555
|
+
recordId: props.id,
|
|
4556
|
+
});
|
|
4365
4557
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
4366
4558
|
continue;
|
|
4367
4559
|
}
|
|
4368
|
-
// Log
|
|
4369
|
-
logger.error("Database
|
|
4560
|
+
// Log structured error details and rethrow
|
|
4561
|
+
logger.error("Database delete operation failed", {
|
|
4562
|
+
operation: 'deleteOneAlert',
|
|
4563
|
+
model: 'Alert',
|
|
4564
|
+
error: String(error),
|
|
4565
|
+
recordId: props.id,
|
|
4566
|
+
isRetryable: isConnectionError,
|
|
4567
|
+
});
|
|
4370
4568
|
throw error;
|
|
4371
4569
|
}
|
|
4372
4570
|
}
|
|
@@ -4438,12 +4636,22 @@ export const Alert = {
|
|
|
4438
4636
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
4439
4637
|
retryCount++;
|
|
4440
4638
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
4441
|
-
logger.warn("Database connection error, retrying..."
|
|
4639
|
+
logger.warn("Database connection error in getAlert, retrying...", {
|
|
4640
|
+
operation: 'getAlert',
|
|
4641
|
+
model: 'Alert',
|
|
4642
|
+
attempt: retryCount,
|
|
4643
|
+
maxRetries: MAX_RETRIES,
|
|
4644
|
+
});
|
|
4442
4645
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
4443
4646
|
continue;
|
|
4444
4647
|
}
|
|
4445
|
-
// Log
|
|
4446
|
-
logger.error("Database
|
|
4648
|
+
// Log structured error details and rethrow
|
|
4649
|
+
logger.error("Database get operation failed", {
|
|
4650
|
+
operation: 'getAlert',
|
|
4651
|
+
model: 'Alert',
|
|
4652
|
+
error: String(error),
|
|
4653
|
+
isRetryable: isConnectionError,
|
|
4654
|
+
});
|
|
4447
4655
|
throw error;
|
|
4448
4656
|
}
|
|
4449
4657
|
}
|
|
@@ -4500,12 +4708,22 @@ export const Alert = {
|
|
|
4500
4708
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
4501
4709
|
retryCount++;
|
|
4502
4710
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
4503
|
-
logger.warn("Database connection error, retrying..."
|
|
4711
|
+
logger.warn("Database connection error in getAllAlert, retrying...", {
|
|
4712
|
+
operation: 'getAllAlert',
|
|
4713
|
+
model: 'Alert',
|
|
4714
|
+
attempt: retryCount,
|
|
4715
|
+
maxRetries: MAX_RETRIES,
|
|
4716
|
+
});
|
|
4504
4717
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
4505
4718
|
continue;
|
|
4506
4719
|
}
|
|
4507
|
-
// Log
|
|
4508
|
-
logger.error("Database
|
|
4720
|
+
// Log structured error details and rethrow
|
|
4721
|
+
logger.error("Database getAll operation failed", {
|
|
4722
|
+
operation: 'getAllAlert',
|
|
4723
|
+
model: 'Alert',
|
|
4724
|
+
error: String(error),
|
|
4725
|
+
isRetryable: isConnectionError,
|
|
4726
|
+
});
|
|
4509
4727
|
throw error;
|
|
4510
4728
|
}
|
|
4511
4729
|
}
|
|
@@ -4584,12 +4802,22 @@ export const Alert = {
|
|
|
4584
4802
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
4585
4803
|
retryCount++;
|
|
4586
4804
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
4587
|
-
logger.warn("Database connection error, retrying..."
|
|
4805
|
+
logger.warn("Database connection error in findManyAlert, retrying...", {
|
|
4806
|
+
operation: 'findManyAlert',
|
|
4807
|
+
model: 'Alert',
|
|
4808
|
+
attempt: retryCount,
|
|
4809
|
+
maxRetries: MAX_RETRIES,
|
|
4810
|
+
});
|
|
4588
4811
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
4589
4812
|
continue;
|
|
4590
4813
|
}
|
|
4591
|
-
// Log
|
|
4592
|
-
logger.error("Database
|
|
4814
|
+
// Log structured error details and rethrow
|
|
4815
|
+
logger.error("Database findMany operation failed", {
|
|
4816
|
+
operation: 'findManyAlert',
|
|
4817
|
+
model: 'Alert',
|
|
4818
|
+
error: String(error),
|
|
4819
|
+
isRetryable: isConnectionError,
|
|
4820
|
+
});
|
|
4593
4821
|
throw error;
|
|
4594
4822
|
}
|
|
4595
4823
|
}
|
package/esm/Allocation.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Allocation.d.ts","sourceRoot":"","sources":["../../src/Allocation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,kDAAkD,CAAC;AAChG,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AA0I7G,eAAO,MAAM,UAAU;IAErB;;;;;OAKG;IAEH;;;;;;OAMG;kBACiB,cAAc,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"Allocation.d.ts","sourceRoot":"","sources":["../../src/Allocation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,kDAAkD,CAAC;AAChG,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AA0I7G,eAAO,MAAM,UAAU;IAErB;;;;;OAKG;IAEH;;;;;;OAMG;kBACiB,cAAc,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;IAoatH;;;;;;OAMG;sBACqB,cAAc,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAqHpI;;;;;;OAMG;kBACiB,cAAc,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;IAmtCpH;;;;;;OAMG;kBACiB,cAAc,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;IA8+CpH;;;;;;OAMG;sBACqB,cAAc,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAwsCpI;;;;;;OAMG;kBACiB,cAAc,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;IAmHpH;;;;;;;OAOG;eACc,cAAc,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAqF1I;;;;;OAKG;0BACyB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,cAAc,EAAE,GAAG,IAAI,CAAC;IA4EtG;;;;;;;OAOG;oBACmB,cAAc,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,cAAc,EAAE,GAAG,IAAI,CAAC;CA6FlJ,CAAC"}
|