@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/Allocation.mjs
CHANGED
|
@@ -500,6 +500,27 @@ export const Allocation = {
|
|
|
500
500
|
}
|
|
501
501
|
catch (error) {
|
|
502
502
|
lastError = error;
|
|
503
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
504
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
505
|
+
error.message?.includes('violates unique constraint') ||
|
|
506
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
507
|
+
error.message?.includes('unique constraint') ||
|
|
508
|
+
error.message?.includes('23514') ||
|
|
509
|
+
error.message?.includes('23505') ||
|
|
510
|
+
error.message?.includes('P2002') ||
|
|
511
|
+
error.message?.includes('P2003');
|
|
512
|
+
if (isConstraintViolation) {
|
|
513
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
514
|
+
logger.error("Non-retryable constraint violation in createOneAllocation", {
|
|
515
|
+
operation: 'createOneAllocation',
|
|
516
|
+
model: 'Allocation',
|
|
517
|
+
error: String(error),
|
|
518
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
519
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
520
|
+
isRetryable: false,
|
|
521
|
+
});
|
|
522
|
+
throw error;
|
|
523
|
+
}
|
|
503
524
|
// Check if this is a database connection error that we should retry
|
|
504
525
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
505
526
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -509,12 +530,22 @@ export const Allocation = {
|
|
|
509
530
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
510
531
|
retryCount++;
|
|
511
532
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
512
|
-
logger.warn("Database connection error, retrying..."
|
|
533
|
+
logger.warn("Database connection error in createOneAllocation, retrying...", {
|
|
534
|
+
operation: 'createOneAllocation',
|
|
535
|
+
model: 'Allocation',
|
|
536
|
+
attempt: retryCount,
|
|
537
|
+
maxRetries: MAX_RETRIES,
|
|
538
|
+
});
|
|
513
539
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
514
540
|
continue;
|
|
515
541
|
}
|
|
516
|
-
// Log
|
|
517
|
-
logger.error("Database
|
|
542
|
+
// Log structured error details and rethrow
|
|
543
|
+
logger.error("Database create operation failed", {
|
|
544
|
+
operation: 'createOneAllocation',
|
|
545
|
+
model: 'Allocation',
|
|
546
|
+
error: String(error),
|
|
547
|
+
isRetryable: isConnectionError,
|
|
548
|
+
});
|
|
518
549
|
throw error;
|
|
519
550
|
}
|
|
520
551
|
}
|
|
@@ -580,6 +611,27 @@ export const Allocation = {
|
|
|
580
611
|
}
|
|
581
612
|
catch (error) {
|
|
582
613
|
lastError = error;
|
|
614
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
615
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
616
|
+
error.message?.includes('violates unique constraint') ||
|
|
617
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
618
|
+
error.message?.includes('unique constraint') ||
|
|
619
|
+
error.message?.includes('23514') ||
|
|
620
|
+
error.message?.includes('23505') ||
|
|
621
|
+
error.message?.includes('P2002') ||
|
|
622
|
+
error.message?.includes('P2003');
|
|
623
|
+
if (isConstraintViolation) {
|
|
624
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
625
|
+
logger.error("Non-retryable constraint violation in createManyAllocation", {
|
|
626
|
+
operation: 'createManyAllocation',
|
|
627
|
+
model: 'Allocation',
|
|
628
|
+
error: String(error),
|
|
629
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
630
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
631
|
+
isRetryable: false,
|
|
632
|
+
});
|
|
633
|
+
throw error;
|
|
634
|
+
}
|
|
583
635
|
// Check if this is a database connection error that we should retry
|
|
584
636
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
585
637
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -589,12 +641,22 @@ export const Allocation = {
|
|
|
589
641
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
590
642
|
retryCount++;
|
|
591
643
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
592
|
-
logger.warn("Database connection error, retrying..."
|
|
644
|
+
logger.warn("Database connection error in createManyAllocation, retrying...", {
|
|
645
|
+
operation: 'createManyAllocation',
|
|
646
|
+
model: 'Allocation',
|
|
647
|
+
attempt: retryCount,
|
|
648
|
+
maxRetries: MAX_RETRIES,
|
|
649
|
+
});
|
|
593
650
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
594
651
|
continue;
|
|
595
652
|
}
|
|
596
|
-
// Log
|
|
597
|
-
logger.error("Database
|
|
653
|
+
// Log structured error details and rethrow
|
|
654
|
+
logger.error("Database createMany operation failed", {
|
|
655
|
+
operation: 'createManyAllocation',
|
|
656
|
+
model: 'Allocation',
|
|
657
|
+
error: String(error),
|
|
658
|
+
isRetryable: isConnectionError,
|
|
659
|
+
});
|
|
598
660
|
throw error;
|
|
599
661
|
}
|
|
600
662
|
}
|
|
@@ -1774,6 +1836,28 @@ export const Allocation = {
|
|
|
1774
1836
|
}
|
|
1775
1837
|
catch (error) {
|
|
1776
1838
|
lastError = error;
|
|
1839
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
1840
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
1841
|
+
error.message?.includes('violates unique constraint') ||
|
|
1842
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
1843
|
+
error.message?.includes('unique constraint') ||
|
|
1844
|
+
error.message?.includes('23514') ||
|
|
1845
|
+
error.message?.includes('23505') ||
|
|
1846
|
+
error.message?.includes('P2002') ||
|
|
1847
|
+
error.message?.includes('P2003');
|
|
1848
|
+
if (isConstraintViolation) {
|
|
1849
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
1850
|
+
logger.error("Non-retryable constraint violation in updateOneAllocation", {
|
|
1851
|
+
operation: 'updateOneAllocation',
|
|
1852
|
+
model: 'Allocation',
|
|
1853
|
+
error: String(error),
|
|
1854
|
+
recordId: props.id,
|
|
1855
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
1856
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
1857
|
+
isRetryable: false,
|
|
1858
|
+
});
|
|
1859
|
+
throw error;
|
|
1860
|
+
}
|
|
1777
1861
|
// Check if this is a database connection error that we should retry
|
|
1778
1862
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
1779
1863
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -1783,12 +1867,24 @@ export const Allocation = {
|
|
|
1783
1867
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
1784
1868
|
retryCount++;
|
|
1785
1869
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
1786
|
-
logger.warn("Database connection error, retrying..."
|
|
1870
|
+
logger.warn("Database connection error in updateOneAllocation, retrying...", {
|
|
1871
|
+
operation: 'updateOneAllocation',
|
|
1872
|
+
model: 'Allocation',
|
|
1873
|
+
attempt: retryCount,
|
|
1874
|
+
maxRetries: MAX_RETRIES,
|
|
1875
|
+
recordId: props.id,
|
|
1876
|
+
});
|
|
1787
1877
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
1788
1878
|
continue;
|
|
1789
1879
|
}
|
|
1790
|
-
// Log
|
|
1791
|
-
logger.error("Database
|
|
1880
|
+
// Log structured error details and rethrow
|
|
1881
|
+
logger.error("Database update operation failed", {
|
|
1882
|
+
operation: 'updateOneAllocation',
|
|
1883
|
+
model: 'Allocation',
|
|
1884
|
+
error: String(error),
|
|
1885
|
+
recordId: props.id,
|
|
1886
|
+
isRetryable: isConnectionError,
|
|
1887
|
+
});
|
|
1792
1888
|
throw error;
|
|
1793
1889
|
}
|
|
1794
1890
|
}
|
|
@@ -3252,6 +3348,28 @@ export const Allocation = {
|
|
|
3252
3348
|
}
|
|
3253
3349
|
catch (error) {
|
|
3254
3350
|
lastError = error;
|
|
3351
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
3352
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
3353
|
+
error.message?.includes('violates unique constraint') ||
|
|
3354
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
3355
|
+
error.message?.includes('unique constraint') ||
|
|
3356
|
+
error.message?.includes('23514') ||
|
|
3357
|
+
error.message?.includes('23505') ||
|
|
3358
|
+
error.message?.includes('P2002') ||
|
|
3359
|
+
error.message?.includes('P2003');
|
|
3360
|
+
if (isConstraintViolation) {
|
|
3361
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
3362
|
+
logger.error("Non-retryable constraint violation in upsertOneAllocation", {
|
|
3363
|
+
operation: 'upsertOneAllocation',
|
|
3364
|
+
model: 'Allocation',
|
|
3365
|
+
error: String(error),
|
|
3366
|
+
recordId: props.id,
|
|
3367
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
3368
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
3369
|
+
isRetryable: false,
|
|
3370
|
+
});
|
|
3371
|
+
throw error;
|
|
3372
|
+
}
|
|
3255
3373
|
// Check if this is a database connection error that we should retry
|
|
3256
3374
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
3257
3375
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -3261,12 +3379,24 @@ export const Allocation = {
|
|
|
3261
3379
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
3262
3380
|
retryCount++;
|
|
3263
3381
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
3264
|
-
logger.warn("Database connection error, retrying..."
|
|
3382
|
+
logger.warn("Database connection error in upsertOneAllocation, retrying...", {
|
|
3383
|
+
operation: 'upsertOneAllocation',
|
|
3384
|
+
model: 'Allocation',
|
|
3385
|
+
attempt: retryCount,
|
|
3386
|
+
maxRetries: MAX_RETRIES,
|
|
3387
|
+
recordId: props.id,
|
|
3388
|
+
});
|
|
3265
3389
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
3266
3390
|
continue;
|
|
3267
3391
|
}
|
|
3268
|
-
// Log
|
|
3269
|
-
logger.error("Database
|
|
3392
|
+
// Log structured error details and rethrow
|
|
3393
|
+
logger.error("Database upsert operation failed", {
|
|
3394
|
+
operation: 'upsertOneAllocation',
|
|
3395
|
+
model: 'Allocation',
|
|
3396
|
+
error: String(error),
|
|
3397
|
+
recordId: props.id,
|
|
3398
|
+
isRetryable: isConnectionError,
|
|
3399
|
+
});
|
|
3270
3400
|
throw error;
|
|
3271
3401
|
}
|
|
3272
3402
|
}
|
|
@@ -4437,6 +4567,27 @@ export const Allocation = {
|
|
|
4437
4567
|
}
|
|
4438
4568
|
catch (error) {
|
|
4439
4569
|
lastError = error;
|
|
4570
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
4571
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
4572
|
+
error.message?.includes('violates unique constraint') ||
|
|
4573
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
4574
|
+
error.message?.includes('unique constraint') ||
|
|
4575
|
+
error.message?.includes('23514') ||
|
|
4576
|
+
error.message?.includes('23505') ||
|
|
4577
|
+
error.message?.includes('P2002') ||
|
|
4578
|
+
error.message?.includes('P2003');
|
|
4579
|
+
if (isConstraintViolation) {
|
|
4580
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
4581
|
+
logger.error("Non-retryable constraint violation in updateManyAllocation", {
|
|
4582
|
+
operation: 'updateManyAllocation',
|
|
4583
|
+
model: 'Allocation',
|
|
4584
|
+
error: String(error),
|
|
4585
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
4586
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
4587
|
+
isRetryable: false,
|
|
4588
|
+
});
|
|
4589
|
+
throw error;
|
|
4590
|
+
}
|
|
4440
4591
|
// Check if this is a database connection error that we should retry
|
|
4441
4592
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
4442
4593
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -4446,12 +4597,22 @@ export const Allocation = {
|
|
|
4446
4597
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
4447
4598
|
retryCount++;
|
|
4448
4599
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
4449
|
-
logger.warn("Database connection error, retrying..."
|
|
4600
|
+
logger.warn("Database connection error in updateManyAllocation, retrying...", {
|
|
4601
|
+
operation: 'updateManyAllocation',
|
|
4602
|
+
model: 'Allocation',
|
|
4603
|
+
attempt: retryCount,
|
|
4604
|
+
maxRetries: MAX_RETRIES,
|
|
4605
|
+
});
|
|
4450
4606
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
4451
4607
|
continue;
|
|
4452
4608
|
}
|
|
4453
|
-
// Log
|
|
4454
|
-
logger.error("Database
|
|
4609
|
+
// Log structured error details and rethrow
|
|
4610
|
+
logger.error("Database updateMany operation failed", {
|
|
4611
|
+
operation: 'updateManyAllocation',
|
|
4612
|
+
model: 'Allocation',
|
|
4613
|
+
error: String(error),
|
|
4614
|
+
isRetryable: isConnectionError,
|
|
4615
|
+
});
|
|
4455
4616
|
throw error;
|
|
4456
4617
|
}
|
|
4457
4618
|
}
|
|
@@ -4509,6 +4670,31 @@ export const Allocation = {
|
|
|
4509
4670
|
}
|
|
4510
4671
|
catch (error) {
|
|
4511
4672
|
lastError = error;
|
|
4673
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
4674
|
+
// (e.g., foreign key constraints preventing deletion)
|
|
4675
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
4676
|
+
error.message?.includes('violates unique constraint') ||
|
|
4677
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
4678
|
+
error.message?.includes('unique constraint') ||
|
|
4679
|
+
error.message?.includes('23514') ||
|
|
4680
|
+
error.message?.includes('23505') ||
|
|
4681
|
+
error.message?.includes('23503') ||
|
|
4682
|
+
error.message?.includes('P2002') ||
|
|
4683
|
+
error.message?.includes('P2003') ||
|
|
4684
|
+
error.message?.includes('P2014');
|
|
4685
|
+
if (isConstraintViolation) {
|
|
4686
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
4687
|
+
logger.error("Non-retryable constraint violation in deleteOneAllocation", {
|
|
4688
|
+
operation: 'deleteOneAllocation',
|
|
4689
|
+
model: 'Allocation',
|
|
4690
|
+
error: String(error),
|
|
4691
|
+
recordId: props.id,
|
|
4692
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
4693
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
4694
|
+
isRetryable: false,
|
|
4695
|
+
});
|
|
4696
|
+
throw error;
|
|
4697
|
+
}
|
|
4512
4698
|
// Check if this is a database connection error that we should retry
|
|
4513
4699
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
4514
4700
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -4518,12 +4704,24 @@ export const Allocation = {
|
|
|
4518
4704
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
4519
4705
|
retryCount++;
|
|
4520
4706
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
4521
|
-
logger.warn("Database connection error, retrying..."
|
|
4707
|
+
logger.warn("Database connection error in deleteOneAllocation, retrying...", {
|
|
4708
|
+
operation: 'deleteOneAllocation',
|
|
4709
|
+
model: 'Allocation',
|
|
4710
|
+
attempt: retryCount,
|
|
4711
|
+
maxRetries: MAX_RETRIES,
|
|
4712
|
+
recordId: props.id,
|
|
4713
|
+
});
|
|
4522
4714
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
4523
4715
|
continue;
|
|
4524
4716
|
}
|
|
4525
|
-
// Log
|
|
4526
|
-
logger.error("Database
|
|
4717
|
+
// Log structured error details and rethrow
|
|
4718
|
+
logger.error("Database delete operation failed", {
|
|
4719
|
+
operation: 'deleteOneAllocation',
|
|
4720
|
+
model: 'Allocation',
|
|
4721
|
+
error: String(error),
|
|
4722
|
+
recordId: props.id,
|
|
4723
|
+
isRetryable: isConnectionError,
|
|
4724
|
+
});
|
|
4527
4725
|
throw error;
|
|
4528
4726
|
}
|
|
4529
4727
|
}
|
|
@@ -4590,12 +4788,22 @@ export const Allocation = {
|
|
|
4590
4788
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
4591
4789
|
retryCount++;
|
|
4592
4790
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
4593
|
-
logger.warn("Database connection error, retrying..."
|
|
4791
|
+
logger.warn("Database connection error in getAllocation, retrying...", {
|
|
4792
|
+
operation: 'getAllocation',
|
|
4793
|
+
model: 'Allocation',
|
|
4794
|
+
attempt: retryCount,
|
|
4795
|
+
maxRetries: MAX_RETRIES,
|
|
4796
|
+
});
|
|
4594
4797
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
4595
4798
|
continue;
|
|
4596
4799
|
}
|
|
4597
|
-
// Log
|
|
4598
|
-
logger.error("Database
|
|
4800
|
+
// Log structured error details and rethrow
|
|
4801
|
+
logger.error("Database get operation failed", {
|
|
4802
|
+
operation: 'getAllocation',
|
|
4803
|
+
model: 'Allocation',
|
|
4804
|
+
error: String(error),
|
|
4805
|
+
isRetryable: isConnectionError,
|
|
4806
|
+
});
|
|
4599
4807
|
throw error;
|
|
4600
4808
|
}
|
|
4601
4809
|
}
|
|
@@ -4652,12 +4860,22 @@ export const Allocation = {
|
|
|
4652
4860
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
4653
4861
|
retryCount++;
|
|
4654
4862
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
4655
|
-
logger.warn("Database connection error, retrying..."
|
|
4863
|
+
logger.warn("Database connection error in getAllAllocation, retrying...", {
|
|
4864
|
+
operation: 'getAllAllocation',
|
|
4865
|
+
model: 'Allocation',
|
|
4866
|
+
attempt: retryCount,
|
|
4867
|
+
maxRetries: MAX_RETRIES,
|
|
4868
|
+
});
|
|
4656
4869
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
4657
4870
|
continue;
|
|
4658
4871
|
}
|
|
4659
|
-
// Log
|
|
4660
|
-
logger.error("Database
|
|
4872
|
+
// Log structured error details and rethrow
|
|
4873
|
+
logger.error("Database getAll operation failed", {
|
|
4874
|
+
operation: 'getAllAllocation',
|
|
4875
|
+
model: 'Allocation',
|
|
4876
|
+
error: String(error),
|
|
4877
|
+
isRetryable: isConnectionError,
|
|
4878
|
+
});
|
|
4661
4879
|
throw error;
|
|
4662
4880
|
}
|
|
4663
4881
|
}
|
|
@@ -4733,12 +4951,22 @@ export const Allocation = {
|
|
|
4733
4951
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
4734
4952
|
retryCount++;
|
|
4735
4953
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
4736
|
-
logger.warn("Database connection error, retrying..."
|
|
4954
|
+
logger.warn("Database connection error in findManyAllocation, retrying...", {
|
|
4955
|
+
operation: 'findManyAllocation',
|
|
4956
|
+
model: 'Allocation',
|
|
4957
|
+
attempt: retryCount,
|
|
4958
|
+
maxRetries: MAX_RETRIES,
|
|
4959
|
+
});
|
|
4737
4960
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
4738
4961
|
continue;
|
|
4739
4962
|
}
|
|
4740
|
-
// Log
|
|
4741
|
-
logger.error("Database
|
|
4963
|
+
// Log structured error details and rethrow
|
|
4964
|
+
logger.error("Database findMany operation failed", {
|
|
4965
|
+
operation: 'findManyAllocation',
|
|
4966
|
+
model: 'Allocation',
|
|
4967
|
+
error: String(error),
|
|
4968
|
+
isRetryable: isConnectionError,
|
|
4969
|
+
});
|
|
4742
4970
|
throw error;
|
|
4743
4971
|
}
|
|
4744
4972
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlpacaAccount.d.ts","sourceRoot":"","sources":["../../src/AlpacaAccount.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AACzG,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AAsJ7G,eAAO,MAAM,aAAa;IAExB;;;;;OAKG;IAEH;;;;;;OAMG;kBACiB,iBAAiB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"AlpacaAccount.d.ts","sourceRoot":"","sources":["../../src/AlpacaAccount.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AACzG,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AAsJ7G,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;IAuIvI;;;;;;OAMG;kBACiB,iBAAiB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA6hC1H;;;;;;OAMG;kBACiB,iBAAiB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAu1C1H;;;;;;OAMG;sBACqB,iBAAiB,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IA4hCvI;;;;;;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"}
|