@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/Account.mjs
CHANGED
|
@@ -568,6 +568,27 @@ export const Account = {
|
|
|
568
568
|
}
|
|
569
569
|
catch (error) {
|
|
570
570
|
lastError = error;
|
|
571
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
572
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
573
|
+
error.message?.includes('violates unique constraint') ||
|
|
574
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
575
|
+
error.message?.includes('unique constraint') ||
|
|
576
|
+
error.message?.includes('23514') ||
|
|
577
|
+
error.message?.includes('23505') ||
|
|
578
|
+
error.message?.includes('P2002') ||
|
|
579
|
+
error.message?.includes('P2003');
|
|
580
|
+
if (isConstraintViolation) {
|
|
581
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
582
|
+
logger.error("Non-retryable constraint violation in createOneAccount", {
|
|
583
|
+
operation: 'createOneAccount',
|
|
584
|
+
model: 'Account',
|
|
585
|
+
error: String(error),
|
|
586
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
587
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
588
|
+
isRetryable: false,
|
|
589
|
+
});
|
|
590
|
+
throw error;
|
|
591
|
+
}
|
|
571
592
|
// Check if this is a database connection error that we should retry
|
|
572
593
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
573
594
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -577,12 +598,22 @@ export const Account = {
|
|
|
577
598
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
578
599
|
retryCount++;
|
|
579
600
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
580
|
-
logger.warn("Database connection error, retrying..."
|
|
601
|
+
logger.warn("Database connection error in createOneAccount, retrying...", {
|
|
602
|
+
operation: 'createOneAccount',
|
|
603
|
+
model: 'Account',
|
|
604
|
+
attempt: retryCount,
|
|
605
|
+
maxRetries: MAX_RETRIES,
|
|
606
|
+
});
|
|
581
607
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
582
608
|
continue;
|
|
583
609
|
}
|
|
584
|
-
// Log
|
|
585
|
-
logger.error("Database
|
|
610
|
+
// Log structured error details and rethrow
|
|
611
|
+
logger.error("Database create operation failed", {
|
|
612
|
+
operation: 'createOneAccount',
|
|
613
|
+
model: 'Account',
|
|
614
|
+
error: String(error),
|
|
615
|
+
isRetryable: isConnectionError,
|
|
616
|
+
});
|
|
586
617
|
throw error;
|
|
587
618
|
}
|
|
588
619
|
}
|
|
@@ -650,6 +681,27 @@ export const Account = {
|
|
|
650
681
|
}
|
|
651
682
|
catch (error) {
|
|
652
683
|
lastError = error;
|
|
684
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
685
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
686
|
+
error.message?.includes('violates unique constraint') ||
|
|
687
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
688
|
+
error.message?.includes('unique constraint') ||
|
|
689
|
+
error.message?.includes('23514') ||
|
|
690
|
+
error.message?.includes('23505') ||
|
|
691
|
+
error.message?.includes('P2002') ||
|
|
692
|
+
error.message?.includes('P2003');
|
|
693
|
+
if (isConstraintViolation) {
|
|
694
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
695
|
+
logger.error("Non-retryable constraint violation in createManyAccount", {
|
|
696
|
+
operation: 'createManyAccount',
|
|
697
|
+
model: 'Account',
|
|
698
|
+
error: String(error),
|
|
699
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
700
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
701
|
+
isRetryable: false,
|
|
702
|
+
});
|
|
703
|
+
throw error;
|
|
704
|
+
}
|
|
653
705
|
// Check if this is a database connection error that we should retry
|
|
654
706
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
655
707
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -659,12 +711,22 @@ export const Account = {
|
|
|
659
711
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
660
712
|
retryCount++;
|
|
661
713
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
662
|
-
logger.warn("Database connection error, retrying..."
|
|
714
|
+
logger.warn("Database connection error in createManyAccount, retrying...", {
|
|
715
|
+
operation: 'createManyAccount',
|
|
716
|
+
model: 'Account',
|
|
717
|
+
attempt: retryCount,
|
|
718
|
+
maxRetries: MAX_RETRIES,
|
|
719
|
+
});
|
|
663
720
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
664
721
|
continue;
|
|
665
722
|
}
|
|
666
|
-
// Log
|
|
667
|
-
logger.error("Database
|
|
723
|
+
// Log structured error details and rethrow
|
|
724
|
+
logger.error("Database createMany operation failed", {
|
|
725
|
+
operation: 'createManyAccount',
|
|
726
|
+
model: 'Account',
|
|
727
|
+
error: String(error),
|
|
728
|
+
isRetryable: isConnectionError,
|
|
729
|
+
});
|
|
668
730
|
throw error;
|
|
669
731
|
}
|
|
670
732
|
}
|
|
@@ -1804,6 +1866,28 @@ export const Account = {
|
|
|
1804
1866
|
}
|
|
1805
1867
|
catch (error) {
|
|
1806
1868
|
lastError = error;
|
|
1869
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
1870
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
1871
|
+
error.message?.includes('violates unique constraint') ||
|
|
1872
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
1873
|
+
error.message?.includes('unique constraint') ||
|
|
1874
|
+
error.message?.includes('23514') ||
|
|
1875
|
+
error.message?.includes('23505') ||
|
|
1876
|
+
error.message?.includes('P2002') ||
|
|
1877
|
+
error.message?.includes('P2003');
|
|
1878
|
+
if (isConstraintViolation) {
|
|
1879
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
1880
|
+
logger.error("Non-retryable constraint violation in updateOneAccount", {
|
|
1881
|
+
operation: 'updateOneAccount',
|
|
1882
|
+
model: 'Account',
|
|
1883
|
+
error: String(error),
|
|
1884
|
+
recordId: props.id,
|
|
1885
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
1886
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
1887
|
+
isRetryable: false,
|
|
1888
|
+
});
|
|
1889
|
+
throw error;
|
|
1890
|
+
}
|
|
1807
1891
|
// Check if this is a database connection error that we should retry
|
|
1808
1892
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
1809
1893
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -1813,12 +1897,24 @@ export const Account = {
|
|
|
1813
1897
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
1814
1898
|
retryCount++;
|
|
1815
1899
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
1816
|
-
logger.warn("Database connection error, retrying..."
|
|
1900
|
+
logger.warn("Database connection error in updateOneAccount, retrying...", {
|
|
1901
|
+
operation: 'updateOneAccount',
|
|
1902
|
+
model: 'Account',
|
|
1903
|
+
attempt: retryCount,
|
|
1904
|
+
maxRetries: MAX_RETRIES,
|
|
1905
|
+
recordId: props.id,
|
|
1906
|
+
});
|
|
1817
1907
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
1818
1908
|
continue;
|
|
1819
1909
|
}
|
|
1820
|
-
// Log
|
|
1821
|
-
logger.error("Database
|
|
1910
|
+
// Log structured error details and rethrow
|
|
1911
|
+
logger.error("Database update operation failed", {
|
|
1912
|
+
operation: 'updateOneAccount',
|
|
1913
|
+
model: 'Account',
|
|
1914
|
+
error: String(error),
|
|
1915
|
+
recordId: props.id,
|
|
1916
|
+
isRetryable: isConnectionError,
|
|
1917
|
+
});
|
|
1822
1918
|
throw error;
|
|
1823
1919
|
}
|
|
1824
1920
|
}
|
|
@@ -3271,6 +3367,28 @@ export const Account = {
|
|
|
3271
3367
|
}
|
|
3272
3368
|
catch (error) {
|
|
3273
3369
|
lastError = error;
|
|
3370
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
3371
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
3372
|
+
error.message?.includes('violates unique constraint') ||
|
|
3373
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
3374
|
+
error.message?.includes('unique constraint') ||
|
|
3375
|
+
error.message?.includes('23514') ||
|
|
3376
|
+
error.message?.includes('23505') ||
|
|
3377
|
+
error.message?.includes('P2002') ||
|
|
3378
|
+
error.message?.includes('P2003');
|
|
3379
|
+
if (isConstraintViolation) {
|
|
3380
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
3381
|
+
logger.error("Non-retryable constraint violation in upsertOneAccount", {
|
|
3382
|
+
operation: 'upsertOneAccount',
|
|
3383
|
+
model: 'Account',
|
|
3384
|
+
error: String(error),
|
|
3385
|
+
recordId: props.id,
|
|
3386
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
3387
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
3388
|
+
isRetryable: false,
|
|
3389
|
+
});
|
|
3390
|
+
throw error;
|
|
3391
|
+
}
|
|
3274
3392
|
// Check if this is a database connection error that we should retry
|
|
3275
3393
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
3276
3394
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -3280,12 +3398,24 @@ export const Account = {
|
|
|
3280
3398
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
3281
3399
|
retryCount++;
|
|
3282
3400
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
3283
|
-
logger.warn("Database connection error, retrying..."
|
|
3401
|
+
logger.warn("Database connection error in upsertOneAccount, retrying...", {
|
|
3402
|
+
operation: 'upsertOneAccount',
|
|
3403
|
+
model: 'Account',
|
|
3404
|
+
attempt: retryCount,
|
|
3405
|
+
maxRetries: MAX_RETRIES,
|
|
3406
|
+
recordId: props.id,
|
|
3407
|
+
});
|
|
3284
3408
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
3285
3409
|
continue;
|
|
3286
3410
|
}
|
|
3287
|
-
// Log
|
|
3288
|
-
logger.error("Database
|
|
3411
|
+
// Log structured error details and rethrow
|
|
3412
|
+
logger.error("Database upsert operation failed", {
|
|
3413
|
+
operation: 'upsertOneAccount',
|
|
3414
|
+
model: 'Account',
|
|
3415
|
+
error: String(error),
|
|
3416
|
+
recordId: props.id,
|
|
3417
|
+
isRetryable: isConnectionError,
|
|
3418
|
+
});
|
|
3289
3419
|
throw error;
|
|
3290
3420
|
}
|
|
3291
3421
|
}
|
|
@@ -4425,6 +4555,27 @@ export const Account = {
|
|
|
4425
4555
|
}
|
|
4426
4556
|
catch (error) {
|
|
4427
4557
|
lastError = error;
|
|
4558
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
4559
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
4560
|
+
error.message?.includes('violates unique constraint') ||
|
|
4561
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
4562
|
+
error.message?.includes('unique constraint') ||
|
|
4563
|
+
error.message?.includes('23514') ||
|
|
4564
|
+
error.message?.includes('23505') ||
|
|
4565
|
+
error.message?.includes('P2002') ||
|
|
4566
|
+
error.message?.includes('P2003');
|
|
4567
|
+
if (isConstraintViolation) {
|
|
4568
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
4569
|
+
logger.error("Non-retryable constraint violation in updateManyAccount", {
|
|
4570
|
+
operation: 'updateManyAccount',
|
|
4571
|
+
model: 'Account',
|
|
4572
|
+
error: String(error),
|
|
4573
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
4574
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
4575
|
+
isRetryable: false,
|
|
4576
|
+
});
|
|
4577
|
+
throw error;
|
|
4578
|
+
}
|
|
4428
4579
|
// Check if this is a database connection error that we should retry
|
|
4429
4580
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
4430
4581
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -4434,12 +4585,22 @@ export const Account = {
|
|
|
4434
4585
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
4435
4586
|
retryCount++;
|
|
4436
4587
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
4437
|
-
logger.warn("Database connection error, retrying..."
|
|
4588
|
+
logger.warn("Database connection error in updateManyAccount, retrying...", {
|
|
4589
|
+
operation: 'updateManyAccount',
|
|
4590
|
+
model: 'Account',
|
|
4591
|
+
attempt: retryCount,
|
|
4592
|
+
maxRetries: MAX_RETRIES,
|
|
4593
|
+
});
|
|
4438
4594
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
4439
4595
|
continue;
|
|
4440
4596
|
}
|
|
4441
|
-
// Log
|
|
4442
|
-
logger.error("Database
|
|
4597
|
+
// Log structured error details and rethrow
|
|
4598
|
+
logger.error("Database updateMany operation failed", {
|
|
4599
|
+
operation: 'updateManyAccount',
|
|
4600
|
+
model: 'Account',
|
|
4601
|
+
error: String(error),
|
|
4602
|
+
isRetryable: isConnectionError,
|
|
4603
|
+
});
|
|
4443
4604
|
throw error;
|
|
4444
4605
|
}
|
|
4445
4606
|
}
|
|
@@ -4497,6 +4658,31 @@ export const Account = {
|
|
|
4497
4658
|
}
|
|
4498
4659
|
catch (error) {
|
|
4499
4660
|
lastError = error;
|
|
4661
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
4662
|
+
// (e.g., foreign key constraints preventing deletion)
|
|
4663
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
4664
|
+
error.message?.includes('violates unique constraint') ||
|
|
4665
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
4666
|
+
error.message?.includes('unique constraint') ||
|
|
4667
|
+
error.message?.includes('23514') ||
|
|
4668
|
+
error.message?.includes('23505') ||
|
|
4669
|
+
error.message?.includes('23503') ||
|
|
4670
|
+
error.message?.includes('P2002') ||
|
|
4671
|
+
error.message?.includes('P2003') ||
|
|
4672
|
+
error.message?.includes('P2014');
|
|
4673
|
+
if (isConstraintViolation) {
|
|
4674
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
4675
|
+
logger.error("Non-retryable constraint violation in deleteOneAccount", {
|
|
4676
|
+
operation: 'deleteOneAccount',
|
|
4677
|
+
model: 'Account',
|
|
4678
|
+
error: String(error),
|
|
4679
|
+
recordId: props.id,
|
|
4680
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
4681
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
4682
|
+
isRetryable: false,
|
|
4683
|
+
});
|
|
4684
|
+
throw error;
|
|
4685
|
+
}
|
|
4500
4686
|
// Check if this is a database connection error that we should retry
|
|
4501
4687
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
4502
4688
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -4506,12 +4692,24 @@ export const Account = {
|
|
|
4506
4692
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
4507
4693
|
retryCount++;
|
|
4508
4694
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
4509
|
-
logger.warn("Database connection error, retrying..."
|
|
4695
|
+
logger.warn("Database connection error in deleteOneAccount, retrying...", {
|
|
4696
|
+
operation: 'deleteOneAccount',
|
|
4697
|
+
model: 'Account',
|
|
4698
|
+
attempt: retryCount,
|
|
4699
|
+
maxRetries: MAX_RETRIES,
|
|
4700
|
+
recordId: props.id,
|
|
4701
|
+
});
|
|
4510
4702
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
4511
4703
|
continue;
|
|
4512
4704
|
}
|
|
4513
|
-
// Log
|
|
4514
|
-
logger.error("Database
|
|
4705
|
+
// Log structured error details and rethrow
|
|
4706
|
+
logger.error("Database delete operation failed", {
|
|
4707
|
+
operation: 'deleteOneAccount',
|
|
4708
|
+
model: 'Account',
|
|
4709
|
+
error: String(error),
|
|
4710
|
+
recordId: props.id,
|
|
4711
|
+
isRetryable: isConnectionError,
|
|
4712
|
+
});
|
|
4515
4713
|
throw error;
|
|
4516
4714
|
}
|
|
4517
4715
|
}
|
|
@@ -4581,12 +4779,22 @@ export const Account = {
|
|
|
4581
4779
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
4582
4780
|
retryCount++;
|
|
4583
4781
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
4584
|
-
logger.warn("Database connection error, retrying..."
|
|
4782
|
+
logger.warn("Database connection error in getAccount, retrying...", {
|
|
4783
|
+
operation: 'getAccount',
|
|
4784
|
+
model: 'Account',
|
|
4785
|
+
attempt: retryCount,
|
|
4786
|
+
maxRetries: MAX_RETRIES,
|
|
4787
|
+
});
|
|
4585
4788
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
4586
4789
|
continue;
|
|
4587
4790
|
}
|
|
4588
|
-
// Log
|
|
4589
|
-
logger.error("Database
|
|
4791
|
+
// Log structured error details and rethrow
|
|
4792
|
+
logger.error("Database get operation failed", {
|
|
4793
|
+
operation: 'getAccount',
|
|
4794
|
+
model: 'Account',
|
|
4795
|
+
error: String(error),
|
|
4796
|
+
isRetryable: isConnectionError,
|
|
4797
|
+
});
|
|
4590
4798
|
throw error;
|
|
4591
4799
|
}
|
|
4592
4800
|
}
|
|
@@ -4643,12 +4851,22 @@ export const Account = {
|
|
|
4643
4851
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
4644
4852
|
retryCount++;
|
|
4645
4853
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
4646
|
-
logger.warn("Database connection error, retrying..."
|
|
4854
|
+
logger.warn("Database connection error in getAllAccount, retrying...", {
|
|
4855
|
+
operation: 'getAllAccount',
|
|
4856
|
+
model: 'Account',
|
|
4857
|
+
attempt: retryCount,
|
|
4858
|
+
maxRetries: MAX_RETRIES,
|
|
4859
|
+
});
|
|
4647
4860
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
4648
4861
|
continue;
|
|
4649
4862
|
}
|
|
4650
|
-
// Log
|
|
4651
|
-
logger.error("Database
|
|
4863
|
+
// Log structured error details and rethrow
|
|
4864
|
+
logger.error("Database getAll operation failed", {
|
|
4865
|
+
operation: 'getAllAccount',
|
|
4866
|
+
model: 'Account',
|
|
4867
|
+
error: String(error),
|
|
4868
|
+
isRetryable: isConnectionError,
|
|
4869
|
+
});
|
|
4652
4870
|
throw error;
|
|
4653
4871
|
}
|
|
4654
4872
|
}
|
|
@@ -4727,12 +4945,22 @@ export const Account = {
|
|
|
4727
4945
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
4728
4946
|
retryCount++;
|
|
4729
4947
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
4730
|
-
logger.warn("Database connection error, retrying..."
|
|
4948
|
+
logger.warn("Database connection error in findManyAccount, retrying...", {
|
|
4949
|
+
operation: 'findManyAccount',
|
|
4950
|
+
model: 'Account',
|
|
4951
|
+
attempt: retryCount,
|
|
4952
|
+
maxRetries: MAX_RETRIES,
|
|
4953
|
+
});
|
|
4731
4954
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
4732
4955
|
continue;
|
|
4733
4956
|
}
|
|
4734
|
-
// Log
|
|
4735
|
-
logger.error("Database
|
|
4957
|
+
// Log structured error details and rethrow
|
|
4958
|
+
logger.error("Database findMany operation failed", {
|
|
4959
|
+
operation: 'findManyAccount',
|
|
4960
|
+
model: 'Account',
|
|
4961
|
+
error: String(error),
|
|
4962
|
+
isRetryable: isConnectionError,
|
|
4963
|
+
});
|
|
4736
4964
|
throw error;
|
|
4737
4965
|
}
|
|
4738
4966
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountLinkingRequest.d.ts","sourceRoot":"","sources":["../../src/AccountLinkingRequest.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,IAAI,yBAAyB,EAAE,MAAM,6DAA6D,CAAC;AACjI,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AAmM7G,eAAO,MAAM,qBAAqB;IAEhC;;;;;OAKG;IAEH;;;;;;OAMG;kBACiB,yBAAyB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"AccountLinkingRequest.d.ts","sourceRoot":"","sources":["../../src/AccountLinkingRequest.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,IAAI,yBAAyB,EAAE,MAAM,6DAA6D,CAAC;AACjI,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AAmM7G,eAAO,MAAM,qBAAqB;IAEhC;;;;;OAKG;IAEH;;;;;;OAMG;kBACiB,yBAAyB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAya5I;;;;;;OAMG;sBACqB,yBAAyB,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAwH/I;;;;;;OAMG;kBACiB,yBAAyB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAgqC1I;;;;;;OAMG;kBACiB,yBAAyB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAu9C1I;;;;;;OAMG;sBACqB,yBAAyB,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IA+pC/I;;;;;;OAMG;kBACiB,yBAAyB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAmH1I;;;;;;;OAOG;eACc,yBAAyB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC;IA6FhK;;;;;OAKG;0BACyB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,yBAAyB,EAAE,GAAG,IAAI,CAAC;IA4EjH;;;;;;;OAOG;oBACmB,yBAAyB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,yBAAyB,EAAE,GAAG,IAAI,CAAC;CAmGxK,CAAC"}
|