@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/User.cjs
CHANGED
|
@@ -208,7 +208,7 @@ exports.User = {
|
|
|
208
208
|
* @returns The created User or null.
|
|
209
209
|
*/
|
|
210
210
|
async create(props, globalClient) {
|
|
211
|
-
var _a, _b, _c, _d, _e;
|
|
211
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
212
212
|
// Maximum number of retries for database connection issues
|
|
213
213
|
const MAX_RETRIES = 3;
|
|
214
214
|
let retryCount = 0;
|
|
@@ -572,21 +572,52 @@ exports.User = {
|
|
|
572
572
|
}
|
|
573
573
|
catch (error) {
|
|
574
574
|
lastError = error;
|
|
575
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
576
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
577
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
578
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
579
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
580
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
581
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
582
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
583
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
584
|
+
if (isConstraintViolation) {
|
|
585
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
586
|
+
logger_1.logger.error("Non-retryable constraint violation in createOneUser", {
|
|
587
|
+
operation: 'createOneUser',
|
|
588
|
+
model: 'User',
|
|
589
|
+
error: String(error),
|
|
590
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
591
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
592
|
+
isRetryable: false,
|
|
593
|
+
});
|
|
594
|
+
throw error;
|
|
595
|
+
}
|
|
575
596
|
// Check if this is a database connection error that we should retry
|
|
576
|
-
const isConnectionError = ((
|
|
577
|
-
((
|
|
578
|
-
((
|
|
579
|
-
((
|
|
580
|
-
(error.networkError && ((
|
|
597
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
598
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
599
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
600
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
601
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
581
602
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
582
603
|
retryCount++;
|
|
583
604
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
584
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
605
|
+
logger_1.logger.warn("Database connection error in createOneUser, retrying...", {
|
|
606
|
+
operation: 'createOneUser',
|
|
607
|
+
model: 'User',
|
|
608
|
+
attempt: retryCount,
|
|
609
|
+
maxRetries: MAX_RETRIES,
|
|
610
|
+
});
|
|
585
611
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
586
612
|
continue;
|
|
587
613
|
}
|
|
588
|
-
// Log
|
|
589
|
-
logger_1.logger.error("Database
|
|
614
|
+
// Log structured error details and rethrow
|
|
615
|
+
logger_1.logger.error("Database create operation failed", {
|
|
616
|
+
operation: 'createOneUser',
|
|
617
|
+
model: 'User',
|
|
618
|
+
error: String(error),
|
|
619
|
+
isRetryable: isConnectionError,
|
|
620
|
+
});
|
|
590
621
|
throw error;
|
|
591
622
|
}
|
|
592
623
|
}
|
|
@@ -601,7 +632,7 @@ exports.User = {
|
|
|
601
632
|
* @returns The count of created records or null.
|
|
602
633
|
*/
|
|
603
634
|
async createMany(props, globalClient) {
|
|
604
|
-
var _a, _b, _c, _d, _e;
|
|
635
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
605
636
|
// Maximum number of retries for database connection issues
|
|
606
637
|
const MAX_RETRIES = 3;
|
|
607
638
|
let retryCount = 0;
|
|
@@ -657,21 +688,52 @@ exports.User = {
|
|
|
657
688
|
}
|
|
658
689
|
catch (error) {
|
|
659
690
|
lastError = error;
|
|
691
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
692
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
693
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
694
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
695
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
696
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
697
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
698
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
699
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
700
|
+
if (isConstraintViolation) {
|
|
701
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
702
|
+
logger_1.logger.error("Non-retryable constraint violation in createManyUser", {
|
|
703
|
+
operation: 'createManyUser',
|
|
704
|
+
model: 'User',
|
|
705
|
+
error: String(error),
|
|
706
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
707
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
708
|
+
isRetryable: false,
|
|
709
|
+
});
|
|
710
|
+
throw error;
|
|
711
|
+
}
|
|
660
712
|
// Check if this is a database connection error that we should retry
|
|
661
|
-
const isConnectionError = ((
|
|
662
|
-
((
|
|
663
|
-
((
|
|
664
|
-
((
|
|
665
|
-
(error.networkError && ((
|
|
713
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
714
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
715
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
716
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
717
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
666
718
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
667
719
|
retryCount++;
|
|
668
720
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
669
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
721
|
+
logger_1.logger.warn("Database connection error in createManyUser, retrying...", {
|
|
722
|
+
operation: 'createManyUser',
|
|
723
|
+
model: 'User',
|
|
724
|
+
attempt: retryCount,
|
|
725
|
+
maxRetries: MAX_RETRIES,
|
|
726
|
+
});
|
|
670
727
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
671
728
|
continue;
|
|
672
729
|
}
|
|
673
|
-
// Log
|
|
674
|
-
logger_1.logger.error("Database
|
|
730
|
+
// Log structured error details and rethrow
|
|
731
|
+
logger_1.logger.error("Database createMany operation failed", {
|
|
732
|
+
operation: 'createManyUser',
|
|
733
|
+
model: 'User',
|
|
734
|
+
error: String(error),
|
|
735
|
+
isRetryable: isConnectionError,
|
|
736
|
+
});
|
|
675
737
|
throw error;
|
|
676
738
|
}
|
|
677
739
|
}
|
|
@@ -686,7 +748,7 @@ exports.User = {
|
|
|
686
748
|
* @returns The updated User or null.
|
|
687
749
|
*/
|
|
688
750
|
async update(props, globalClient) {
|
|
689
|
-
var _a, _b, _c, _d, _e;
|
|
751
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
690
752
|
// Maximum number of retries for database connection issues
|
|
691
753
|
const MAX_RETRIES = 3;
|
|
692
754
|
let retryCount = 0;
|
|
@@ -1522,21 +1584,55 @@ exports.User = {
|
|
|
1522
1584
|
}
|
|
1523
1585
|
catch (error) {
|
|
1524
1586
|
lastError = error;
|
|
1587
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
1588
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
1589
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
1590
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
1591
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
1592
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
1593
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
1594
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
1595
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
1596
|
+
if (isConstraintViolation) {
|
|
1597
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
1598
|
+
logger_1.logger.error("Non-retryable constraint violation in updateOneUser", {
|
|
1599
|
+
operation: 'updateOneUser',
|
|
1600
|
+
model: 'User',
|
|
1601
|
+
error: String(error),
|
|
1602
|
+
recordId: props.id,
|
|
1603
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
1604
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
1605
|
+
isRetryable: false,
|
|
1606
|
+
});
|
|
1607
|
+
throw error;
|
|
1608
|
+
}
|
|
1525
1609
|
// Check if this is a database connection error that we should retry
|
|
1526
|
-
const isConnectionError = ((
|
|
1527
|
-
((
|
|
1528
|
-
((
|
|
1529
|
-
((
|
|
1530
|
-
(error.networkError && ((
|
|
1610
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
1611
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
1612
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
1613
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
1614
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
1531
1615
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
1532
1616
|
retryCount++;
|
|
1533
1617
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
1534
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
1618
|
+
logger_1.logger.warn("Database connection error in updateOneUser, retrying...", {
|
|
1619
|
+
operation: 'updateOneUser',
|
|
1620
|
+
model: 'User',
|
|
1621
|
+
attempt: retryCount,
|
|
1622
|
+
maxRetries: MAX_RETRIES,
|
|
1623
|
+
recordId: props.id,
|
|
1624
|
+
});
|
|
1535
1625
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
1536
1626
|
continue;
|
|
1537
1627
|
}
|
|
1538
|
-
// Log
|
|
1539
|
-
logger_1.logger.error("Database
|
|
1628
|
+
// Log structured error details and rethrow
|
|
1629
|
+
logger_1.logger.error("Database update operation failed", {
|
|
1630
|
+
operation: 'updateOneUser',
|
|
1631
|
+
model: 'User',
|
|
1632
|
+
error: String(error),
|
|
1633
|
+
recordId: props.id,
|
|
1634
|
+
isRetryable: isConnectionError,
|
|
1635
|
+
});
|
|
1540
1636
|
throw error;
|
|
1541
1637
|
}
|
|
1542
1638
|
}
|
|
@@ -1551,7 +1647,7 @@ exports.User = {
|
|
|
1551
1647
|
* @returns The updated User or null.
|
|
1552
1648
|
*/
|
|
1553
1649
|
async upsert(props, globalClient) {
|
|
1554
|
-
var _a, _b, _c, _d, _e;
|
|
1650
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
1555
1651
|
// Maximum number of retries for database connection issues
|
|
1556
1652
|
const MAX_RETRIES = 3;
|
|
1557
1653
|
let retryCount = 0;
|
|
@@ -2700,21 +2796,55 @@ exports.User = {
|
|
|
2700
2796
|
}
|
|
2701
2797
|
catch (error) {
|
|
2702
2798
|
lastError = error;
|
|
2799
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
2800
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
2801
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
2802
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
2803
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
2804
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
2805
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
2806
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
2807
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
2808
|
+
if (isConstraintViolation) {
|
|
2809
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
2810
|
+
logger_1.logger.error("Non-retryable constraint violation in upsertOneUser", {
|
|
2811
|
+
operation: 'upsertOneUser',
|
|
2812
|
+
model: 'User',
|
|
2813
|
+
error: String(error),
|
|
2814
|
+
recordId: props.id,
|
|
2815
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
2816
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
2817
|
+
isRetryable: false,
|
|
2818
|
+
});
|
|
2819
|
+
throw error;
|
|
2820
|
+
}
|
|
2703
2821
|
// Check if this is a database connection error that we should retry
|
|
2704
|
-
const isConnectionError = ((
|
|
2705
|
-
((
|
|
2706
|
-
((
|
|
2707
|
-
((
|
|
2708
|
-
(error.networkError && ((
|
|
2822
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
2823
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
2824
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
2825
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
2826
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
2709
2827
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
2710
2828
|
retryCount++;
|
|
2711
2829
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
2712
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
2830
|
+
logger_1.logger.warn("Database connection error in upsertOneUser, retrying...", {
|
|
2831
|
+
operation: 'upsertOneUser',
|
|
2832
|
+
model: 'User',
|
|
2833
|
+
attempt: retryCount,
|
|
2834
|
+
maxRetries: MAX_RETRIES,
|
|
2835
|
+
recordId: props.id,
|
|
2836
|
+
});
|
|
2713
2837
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
2714
2838
|
continue;
|
|
2715
2839
|
}
|
|
2716
|
-
// Log
|
|
2717
|
-
logger_1.logger.error("Database
|
|
2840
|
+
// Log structured error details and rethrow
|
|
2841
|
+
logger_1.logger.error("Database upsert operation failed", {
|
|
2842
|
+
operation: 'upsertOneUser',
|
|
2843
|
+
model: 'User',
|
|
2844
|
+
error: String(error),
|
|
2845
|
+
recordId: props.id,
|
|
2846
|
+
isRetryable: isConnectionError,
|
|
2847
|
+
});
|
|
2718
2848
|
throw error;
|
|
2719
2849
|
}
|
|
2720
2850
|
}
|
|
@@ -2729,7 +2859,7 @@ exports.User = {
|
|
|
2729
2859
|
* @returns The count of created records or null.
|
|
2730
2860
|
*/
|
|
2731
2861
|
async updateMany(props, globalClient) {
|
|
2732
|
-
var _a, _b, _c, _d, _e;
|
|
2862
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
2733
2863
|
// Maximum number of retries for database connection issues
|
|
2734
2864
|
const MAX_RETRIES = 3;
|
|
2735
2865
|
let retryCount = 0;
|
|
@@ -3565,21 +3695,52 @@ exports.User = {
|
|
|
3565
3695
|
}
|
|
3566
3696
|
catch (error) {
|
|
3567
3697
|
lastError = error;
|
|
3698
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
3699
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
3700
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
3701
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
3702
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
3703
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
3704
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
3705
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
3706
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
3707
|
+
if (isConstraintViolation) {
|
|
3708
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
3709
|
+
logger_1.logger.error("Non-retryable constraint violation in updateManyUser", {
|
|
3710
|
+
operation: 'updateManyUser',
|
|
3711
|
+
model: 'User',
|
|
3712
|
+
error: String(error),
|
|
3713
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
3714
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
3715
|
+
isRetryable: false,
|
|
3716
|
+
});
|
|
3717
|
+
throw error;
|
|
3718
|
+
}
|
|
3568
3719
|
// Check if this is a database connection error that we should retry
|
|
3569
|
-
const isConnectionError = ((
|
|
3570
|
-
((
|
|
3571
|
-
((
|
|
3572
|
-
((
|
|
3573
|
-
(error.networkError && ((
|
|
3720
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
3721
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
3722
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
3723
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
3724
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
3574
3725
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
3575
3726
|
retryCount++;
|
|
3576
3727
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
3577
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
3728
|
+
logger_1.logger.warn("Database connection error in updateManyUser, retrying...", {
|
|
3729
|
+
operation: 'updateManyUser',
|
|
3730
|
+
model: 'User',
|
|
3731
|
+
attempt: retryCount,
|
|
3732
|
+
maxRetries: MAX_RETRIES,
|
|
3733
|
+
});
|
|
3578
3734
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
3579
3735
|
continue;
|
|
3580
3736
|
}
|
|
3581
|
-
// Log
|
|
3582
|
-
logger_1.logger.error("Database
|
|
3737
|
+
// Log structured error details and rethrow
|
|
3738
|
+
logger_1.logger.error("Database updateMany operation failed", {
|
|
3739
|
+
operation: 'updateManyUser',
|
|
3740
|
+
model: 'User',
|
|
3741
|
+
error: String(error),
|
|
3742
|
+
isRetryable: isConnectionError,
|
|
3743
|
+
});
|
|
3583
3744
|
throw error;
|
|
3584
3745
|
}
|
|
3585
3746
|
}
|
|
@@ -3594,7 +3755,7 @@ exports.User = {
|
|
|
3594
3755
|
* @returns The deleted User or null.
|
|
3595
3756
|
*/
|
|
3596
3757
|
async delete(props, globalClient) {
|
|
3597
|
-
var _a, _b, _c, _d, _e;
|
|
3758
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
3598
3759
|
// Maximum number of retries for database connection issues
|
|
3599
3760
|
const MAX_RETRIES = 3;
|
|
3600
3761
|
let retryCount = 0;
|
|
@@ -3638,21 +3799,58 @@ exports.User = {
|
|
|
3638
3799
|
}
|
|
3639
3800
|
catch (error) {
|
|
3640
3801
|
lastError = error;
|
|
3802
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
3803
|
+
// (e.g., foreign key constraints preventing deletion)
|
|
3804
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
3805
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
3806
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
3807
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
3808
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
3809
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
3810
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
|
|
3811
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
|
|
3812
|
+
((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
|
|
3813
|
+
((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
|
|
3814
|
+
if (isConstraintViolation) {
|
|
3815
|
+
const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
|
|
3816
|
+
logger_1.logger.error("Non-retryable constraint violation in deleteOneUser", {
|
|
3817
|
+
operation: 'deleteOneUser',
|
|
3818
|
+
model: 'User',
|
|
3819
|
+
error: String(error),
|
|
3820
|
+
recordId: props.id,
|
|
3821
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
3822
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
3823
|
+
isRetryable: false,
|
|
3824
|
+
});
|
|
3825
|
+
throw error;
|
|
3826
|
+
}
|
|
3641
3827
|
// Check if this is a database connection error that we should retry
|
|
3642
|
-
const isConnectionError = ((
|
|
3643
|
-
((
|
|
3644
|
-
((
|
|
3645
|
-
((
|
|
3646
|
-
(error.networkError && ((
|
|
3828
|
+
const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
|
|
3829
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
|
|
3830
|
+
((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
|
|
3831
|
+
((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
3832
|
+
(error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
|
|
3647
3833
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
3648
3834
|
retryCount++;
|
|
3649
3835
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
3650
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
3836
|
+
logger_1.logger.warn("Database connection error in deleteOneUser, retrying...", {
|
|
3837
|
+
operation: 'deleteOneUser',
|
|
3838
|
+
model: 'User',
|
|
3839
|
+
attempt: retryCount,
|
|
3840
|
+
maxRetries: MAX_RETRIES,
|
|
3841
|
+
recordId: props.id,
|
|
3842
|
+
});
|
|
3651
3843
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
3652
3844
|
continue;
|
|
3653
3845
|
}
|
|
3654
|
-
// Log
|
|
3655
|
-
logger_1.logger.error("Database
|
|
3846
|
+
// Log structured error details and rethrow
|
|
3847
|
+
logger_1.logger.error("Database delete operation failed", {
|
|
3848
|
+
operation: 'deleteOneUser',
|
|
3849
|
+
model: 'User',
|
|
3850
|
+
error: String(error),
|
|
3851
|
+
recordId: props.id,
|
|
3852
|
+
isRetryable: isConnectionError,
|
|
3853
|
+
});
|
|
3656
3854
|
throw error;
|
|
3657
3855
|
}
|
|
3658
3856
|
}
|
|
@@ -3723,12 +3921,22 @@ exports.User = {
|
|
|
3723
3921
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
3724
3922
|
retryCount++;
|
|
3725
3923
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
3726
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
3924
|
+
logger_1.logger.warn("Database connection error in getUser, retrying...", {
|
|
3925
|
+
operation: 'getUser',
|
|
3926
|
+
model: 'User',
|
|
3927
|
+
attempt: retryCount,
|
|
3928
|
+
maxRetries: MAX_RETRIES,
|
|
3929
|
+
});
|
|
3727
3930
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
3728
3931
|
continue;
|
|
3729
3932
|
}
|
|
3730
|
-
// Log
|
|
3731
|
-
logger_1.logger.error("Database
|
|
3933
|
+
// Log structured error details and rethrow
|
|
3934
|
+
logger_1.logger.error("Database get operation failed", {
|
|
3935
|
+
operation: 'getUser',
|
|
3936
|
+
model: 'User',
|
|
3937
|
+
error: String(error),
|
|
3938
|
+
isRetryable: isConnectionError,
|
|
3939
|
+
});
|
|
3732
3940
|
throw error;
|
|
3733
3941
|
}
|
|
3734
3942
|
}
|
|
@@ -3786,12 +3994,22 @@ exports.User = {
|
|
|
3786
3994
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
3787
3995
|
retryCount++;
|
|
3788
3996
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
3789
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
3997
|
+
logger_1.logger.warn("Database connection error in getAllUser, retrying...", {
|
|
3998
|
+
operation: 'getAllUser',
|
|
3999
|
+
model: 'User',
|
|
4000
|
+
attempt: retryCount,
|
|
4001
|
+
maxRetries: MAX_RETRIES,
|
|
4002
|
+
});
|
|
3790
4003
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
3791
4004
|
continue;
|
|
3792
4005
|
}
|
|
3793
|
-
// Log
|
|
3794
|
-
logger_1.logger.error("Database
|
|
4006
|
+
// Log structured error details and rethrow
|
|
4007
|
+
logger_1.logger.error("Database getAll operation failed", {
|
|
4008
|
+
operation: 'getAllUser',
|
|
4009
|
+
model: 'User',
|
|
4010
|
+
error: String(error),
|
|
4011
|
+
isRetryable: isConnectionError,
|
|
4012
|
+
});
|
|
3795
4013
|
throw error;
|
|
3796
4014
|
}
|
|
3797
4015
|
}
|
|
@@ -3871,12 +4089,22 @@ exports.User = {
|
|
|
3871
4089
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
3872
4090
|
retryCount++;
|
|
3873
4091
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
3874
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
4092
|
+
logger_1.logger.warn("Database connection error in findManyUser, retrying...", {
|
|
4093
|
+
operation: 'findManyUser',
|
|
4094
|
+
model: 'User',
|
|
4095
|
+
attempt: retryCount,
|
|
4096
|
+
maxRetries: MAX_RETRIES,
|
|
4097
|
+
});
|
|
3875
4098
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
3876
4099
|
continue;
|
|
3877
4100
|
}
|
|
3878
|
-
// Log
|
|
3879
|
-
logger_1.logger.error("Database
|
|
4101
|
+
// Log structured error details and rethrow
|
|
4102
|
+
logger_1.logger.error("Database findMany operation failed", {
|
|
4103
|
+
operation: 'findManyUser',
|
|
4104
|
+
model: 'User',
|
|
4105
|
+
error: String(error),
|
|
4106
|
+
isRetryable: isConnectionError,
|
|
4107
|
+
});
|
|
3880
4108
|
throw error;
|
|
3881
4109
|
}
|
|
3882
4110
|
}
|