@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/Alert.cjs
CHANGED
|
@@ -42,7 +42,7 @@ exports.Alert = {
|
|
|
42
42
|
* @returns The created Alert or null.
|
|
43
43
|
*/
|
|
44
44
|
async create(props, globalClient) {
|
|
45
|
-
var _a, _b, _c, _d, _e;
|
|
45
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
46
46
|
// Maximum number of retries for database connection issues
|
|
47
47
|
const MAX_RETRIES = 3;
|
|
48
48
|
let retryCount = 0;
|
|
@@ -381,21 +381,52 @@ exports.Alert = {
|
|
|
381
381
|
}
|
|
382
382
|
catch (error) {
|
|
383
383
|
lastError = error;
|
|
384
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
385
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
386
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
387
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
388
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
389
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
390
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
391
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
392
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
393
|
+
if (isConstraintViolation) {
|
|
394
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
395
|
+
logger_1.logger.error("Non-retryable constraint violation in createOneAlert", {
|
|
396
|
+
operation: 'createOneAlert',
|
|
397
|
+
model: 'Alert',
|
|
398
|
+
error: String(error),
|
|
399
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
400
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
401
|
+
isRetryable: false,
|
|
402
|
+
});
|
|
403
|
+
throw error;
|
|
404
|
+
}
|
|
384
405
|
// Check if this is a database connection error that we should retry
|
|
385
|
-
const isConnectionError = ((
|
|
386
|
-
((
|
|
387
|
-
((
|
|
388
|
-
((
|
|
389
|
-
(error.networkError && ((
|
|
406
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
407
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
408
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
409
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
410
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
390
411
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
391
412
|
retryCount++;
|
|
392
413
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
393
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
414
|
+
logger_1.logger.warn("Database connection error in createOneAlert, retrying...", {
|
|
415
|
+
operation: 'createOneAlert',
|
|
416
|
+
model: 'Alert',
|
|
417
|
+
attempt: retryCount,
|
|
418
|
+
maxRetries: MAX_RETRIES,
|
|
419
|
+
});
|
|
394
420
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
395
421
|
continue;
|
|
396
422
|
}
|
|
397
|
-
// Log
|
|
398
|
-
logger_1.logger.error("Database
|
|
423
|
+
// Log structured error details and rethrow
|
|
424
|
+
logger_1.logger.error("Database create operation failed", {
|
|
425
|
+
operation: 'createOneAlert',
|
|
426
|
+
model: 'Alert',
|
|
427
|
+
error: String(error),
|
|
428
|
+
isRetryable: isConnectionError,
|
|
429
|
+
});
|
|
399
430
|
throw error;
|
|
400
431
|
}
|
|
401
432
|
}
|
|
@@ -410,7 +441,7 @@ exports.Alert = {
|
|
|
410
441
|
* @returns The count of created records or null.
|
|
411
442
|
*/
|
|
412
443
|
async createMany(props, globalClient) {
|
|
413
|
-
var _a, _b, _c, _d, _e;
|
|
444
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
414
445
|
// Maximum number of retries for database connection issues
|
|
415
446
|
const MAX_RETRIES = 3;
|
|
416
447
|
let retryCount = 0;
|
|
@@ -466,21 +497,52 @@ exports.Alert = {
|
|
|
466
497
|
}
|
|
467
498
|
catch (error) {
|
|
468
499
|
lastError = error;
|
|
500
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
501
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
502
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
503
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
504
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
505
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
506
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
507
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
508
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
509
|
+
if (isConstraintViolation) {
|
|
510
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
511
|
+
logger_1.logger.error("Non-retryable constraint violation in createManyAlert", {
|
|
512
|
+
operation: 'createManyAlert',
|
|
513
|
+
model: 'Alert',
|
|
514
|
+
error: String(error),
|
|
515
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
516
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
517
|
+
isRetryable: false,
|
|
518
|
+
});
|
|
519
|
+
throw error;
|
|
520
|
+
}
|
|
469
521
|
// Check if this is a database connection error that we should retry
|
|
470
|
-
const isConnectionError = ((
|
|
471
|
-
((
|
|
472
|
-
((
|
|
473
|
-
((
|
|
474
|
-
(error.networkError && ((
|
|
522
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
523
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
524
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
525
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
526
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
475
527
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
476
528
|
retryCount++;
|
|
477
529
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
478
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
530
|
+
logger_1.logger.warn("Database connection error in createManyAlert, retrying...", {
|
|
531
|
+
operation: 'createManyAlert',
|
|
532
|
+
model: 'Alert',
|
|
533
|
+
attempt: retryCount,
|
|
534
|
+
maxRetries: MAX_RETRIES,
|
|
535
|
+
});
|
|
479
536
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
480
537
|
continue;
|
|
481
538
|
}
|
|
482
|
-
// Log
|
|
483
|
-
logger_1.logger.error("Database
|
|
539
|
+
// Log structured error details and rethrow
|
|
540
|
+
logger_1.logger.error("Database createMany operation failed", {
|
|
541
|
+
operation: 'createManyAlert',
|
|
542
|
+
model: 'Alert',
|
|
543
|
+
error: String(error),
|
|
544
|
+
isRetryable: isConnectionError,
|
|
545
|
+
});
|
|
484
546
|
throw error;
|
|
485
547
|
}
|
|
486
548
|
}
|
|
@@ -495,7 +557,7 @@ exports.Alert = {
|
|
|
495
557
|
* @returns The updated Alert or null.
|
|
496
558
|
*/
|
|
497
559
|
async update(props, globalClient) {
|
|
498
|
-
var _a, _b, _c, _d, _e;
|
|
560
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
499
561
|
// Maximum number of retries for database connection issues
|
|
500
562
|
const MAX_RETRIES = 3;
|
|
501
563
|
let retryCount = 0;
|
|
@@ -1644,21 +1706,55 @@ exports.Alert = {
|
|
|
1644
1706
|
}
|
|
1645
1707
|
catch (error) {
|
|
1646
1708
|
lastError = error;
|
|
1709
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
1710
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
1711
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
1712
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
1713
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
1714
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
1715
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
1716
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
1717
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
1718
|
+
if (isConstraintViolation) {
|
|
1719
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
1720
|
+
logger_1.logger.error("Non-retryable constraint violation in updateOneAlert", {
|
|
1721
|
+
operation: 'updateOneAlert',
|
|
1722
|
+
model: 'Alert',
|
|
1723
|
+
error: String(error),
|
|
1724
|
+
recordId: props.id,
|
|
1725
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
1726
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
1727
|
+
isRetryable: false,
|
|
1728
|
+
});
|
|
1729
|
+
throw error;
|
|
1730
|
+
}
|
|
1647
1731
|
// Check if this is a database connection error that we should retry
|
|
1648
|
-
const isConnectionError = ((
|
|
1649
|
-
((
|
|
1650
|
-
((
|
|
1651
|
-
((
|
|
1652
|
-
(error.networkError && ((
|
|
1732
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
1733
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
1734
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
1735
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
1736
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
1653
1737
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
1654
1738
|
retryCount++;
|
|
1655
1739
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
1656
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
1740
|
+
logger_1.logger.warn("Database connection error in updateOneAlert, retrying...", {
|
|
1741
|
+
operation: 'updateOneAlert',
|
|
1742
|
+
model: 'Alert',
|
|
1743
|
+
attempt: retryCount,
|
|
1744
|
+
maxRetries: MAX_RETRIES,
|
|
1745
|
+
recordId: props.id,
|
|
1746
|
+
});
|
|
1657
1747
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
1658
1748
|
continue;
|
|
1659
1749
|
}
|
|
1660
|
-
// Log
|
|
1661
|
-
logger_1.logger.error("Database
|
|
1750
|
+
// Log structured error details and rethrow
|
|
1751
|
+
logger_1.logger.error("Database update operation failed", {
|
|
1752
|
+
operation: 'updateOneAlert',
|
|
1753
|
+
model: 'Alert',
|
|
1754
|
+
error: String(error),
|
|
1755
|
+
recordId: props.id,
|
|
1756
|
+
isRetryable: isConnectionError,
|
|
1757
|
+
});
|
|
1662
1758
|
throw error;
|
|
1663
1759
|
}
|
|
1664
1760
|
}
|
|
@@ -1673,7 +1769,7 @@ exports.Alert = {
|
|
|
1673
1769
|
* @returns The updated Alert or null.
|
|
1674
1770
|
*/
|
|
1675
1771
|
async upsert(props, globalClient) {
|
|
1676
|
-
var _a, _b, _c, _d, _e;
|
|
1772
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
1677
1773
|
// Maximum number of retries for database connection issues
|
|
1678
1774
|
const MAX_RETRIES = 3;
|
|
1679
1775
|
let retryCount = 0;
|
|
@@ -3110,21 +3206,55 @@ exports.Alert = {
|
|
|
3110
3206
|
}
|
|
3111
3207
|
catch (error) {
|
|
3112
3208
|
lastError = error;
|
|
3209
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
3210
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
3211
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
3212
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
3213
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
3214
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
3215
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
3216
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
3217
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
3218
|
+
if (isConstraintViolation) {
|
|
3219
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
3220
|
+
logger_1.logger.error("Non-retryable constraint violation in upsertOneAlert", {
|
|
3221
|
+
operation: 'upsertOneAlert',
|
|
3222
|
+
model: 'Alert',
|
|
3223
|
+
error: String(error),
|
|
3224
|
+
recordId: props.id,
|
|
3225
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
3226
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
3227
|
+
isRetryable: false,
|
|
3228
|
+
});
|
|
3229
|
+
throw error;
|
|
3230
|
+
}
|
|
3113
3231
|
// Check if this is a database connection error that we should retry
|
|
3114
|
-
const isConnectionError = ((
|
|
3115
|
-
((
|
|
3116
|
-
((
|
|
3117
|
-
((
|
|
3118
|
-
(error.networkError && ((
|
|
3232
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
3233
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
3234
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
3235
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
3236
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
3119
3237
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
3120
3238
|
retryCount++;
|
|
3121
3239
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
3122
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
3240
|
+
logger_1.logger.warn("Database connection error in upsertOneAlert, retrying...", {
|
|
3241
|
+
operation: 'upsertOneAlert',
|
|
3242
|
+
model: 'Alert',
|
|
3243
|
+
attempt: retryCount,
|
|
3244
|
+
maxRetries: MAX_RETRIES,
|
|
3245
|
+
recordId: props.id,
|
|
3246
|
+
});
|
|
3123
3247
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
3124
3248
|
continue;
|
|
3125
3249
|
}
|
|
3126
|
-
// Log
|
|
3127
|
-
logger_1.logger.error("Database
|
|
3250
|
+
// Log structured error details and rethrow
|
|
3251
|
+
logger_1.logger.error("Database upsert operation failed", {
|
|
3252
|
+
operation: 'upsertOneAlert',
|
|
3253
|
+
model: 'Alert',
|
|
3254
|
+
error: String(error),
|
|
3255
|
+
recordId: props.id,
|
|
3256
|
+
isRetryable: isConnectionError,
|
|
3257
|
+
});
|
|
3128
3258
|
throw error;
|
|
3129
3259
|
}
|
|
3130
3260
|
}
|
|
@@ -3139,7 +3269,7 @@ exports.Alert = {
|
|
|
3139
3269
|
* @returns The count of created records or null.
|
|
3140
3270
|
*/
|
|
3141
3271
|
async updateMany(props, globalClient) {
|
|
3142
|
-
var _a, _b, _c, _d, _e;
|
|
3272
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
3143
3273
|
// Maximum number of retries for database connection issues
|
|
3144
3274
|
const MAX_RETRIES = 3;
|
|
3145
3275
|
let retryCount = 0;
|
|
@@ -4288,21 +4418,52 @@ exports.Alert = {
|
|
|
4288
4418
|
}
|
|
4289
4419
|
catch (error) {
|
|
4290
4420
|
lastError = error;
|
|
4421
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
4422
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
4423
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
4424
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
4425
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
4426
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
4427
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
4428
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
4429
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
4430
|
+
if (isConstraintViolation) {
|
|
4431
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
4432
|
+
logger_1.logger.error("Non-retryable constraint violation in updateManyAlert", {
|
|
4433
|
+
operation: 'updateManyAlert',
|
|
4434
|
+
model: 'Alert',
|
|
4435
|
+
error: String(error),
|
|
4436
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
4437
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
4438
|
+
isRetryable: false,
|
|
4439
|
+
});
|
|
4440
|
+
throw error;
|
|
4441
|
+
}
|
|
4291
4442
|
// Check if this is a database connection error that we should retry
|
|
4292
|
-
const isConnectionError = ((
|
|
4293
|
-
((
|
|
4294
|
-
((
|
|
4295
|
-
((
|
|
4296
|
-
(error.networkError && ((
|
|
4443
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
4444
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
4445
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
4446
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
4447
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
4297
4448
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
4298
4449
|
retryCount++;
|
|
4299
4450
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
4300
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
4451
|
+
logger_1.logger.warn("Database connection error in updateManyAlert, retrying...", {
|
|
4452
|
+
operation: 'updateManyAlert',
|
|
4453
|
+
model: 'Alert',
|
|
4454
|
+
attempt: retryCount,
|
|
4455
|
+
maxRetries: MAX_RETRIES,
|
|
4456
|
+
});
|
|
4301
4457
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
4302
4458
|
continue;
|
|
4303
4459
|
}
|
|
4304
|
-
// Log
|
|
4305
|
-
logger_1.logger.error("Database
|
|
4460
|
+
// Log structured error details and rethrow
|
|
4461
|
+
logger_1.logger.error("Database updateMany operation failed", {
|
|
4462
|
+
operation: 'updateManyAlert',
|
|
4463
|
+
model: 'Alert',
|
|
4464
|
+
error: String(error),
|
|
4465
|
+
isRetryable: isConnectionError,
|
|
4466
|
+
});
|
|
4306
4467
|
throw error;
|
|
4307
4468
|
}
|
|
4308
4469
|
}
|
|
@@ -4317,7 +4478,7 @@ exports.Alert = {
|
|
|
4317
4478
|
* @returns The deleted Alert or null.
|
|
4318
4479
|
*/
|
|
4319
4480
|
async delete(props, globalClient) {
|
|
4320
|
-
var _a, _b, _c, _d, _e;
|
|
4481
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
4321
4482
|
// Maximum number of retries for database connection issues
|
|
4322
4483
|
const MAX_RETRIES = 3;
|
|
4323
4484
|
let retryCount = 0;
|
|
@@ -4361,21 +4522,58 @@ exports.Alert = {
|
|
|
4361
4522
|
}
|
|
4362
4523
|
catch (error) {
|
|
4363
4524
|
lastError = error;
|
|
4525
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
4526
|
+
// (e.g., foreign key constraints preventing deletion)
|
|
4527
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
4528
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
4529
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
4530
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
4531
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
4532
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
4533
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
|
|
4534
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
|
|
4535
|
+
((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
|
|
4536
|
+
((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
|
|
4537
|
+
if (isConstraintViolation) {
|
|
4538
|
+
const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
|
|
4539
|
+
logger_1.logger.error("Non-retryable constraint violation in deleteOneAlert", {
|
|
4540
|
+
operation: 'deleteOneAlert',
|
|
4541
|
+
model: 'Alert',
|
|
4542
|
+
error: String(error),
|
|
4543
|
+
recordId: props.id,
|
|
4544
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
4545
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
4546
|
+
isRetryable: false,
|
|
4547
|
+
});
|
|
4548
|
+
throw error;
|
|
4549
|
+
}
|
|
4364
4550
|
// Check if this is a database connection error that we should retry
|
|
4365
|
-
const isConnectionError = ((
|
|
4366
|
-
((
|
|
4367
|
-
((
|
|
4368
|
-
((
|
|
4369
|
-
(error.networkError && ((
|
|
4551
|
+
const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
|
|
4552
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
|
|
4553
|
+
((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
|
|
4554
|
+
((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
4555
|
+
(error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
|
|
4370
4556
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
4371
4557
|
retryCount++;
|
|
4372
4558
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
4373
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
4559
|
+
logger_1.logger.warn("Database connection error in deleteOneAlert, retrying...", {
|
|
4560
|
+
operation: 'deleteOneAlert',
|
|
4561
|
+
model: 'Alert',
|
|
4562
|
+
attempt: retryCount,
|
|
4563
|
+
maxRetries: MAX_RETRIES,
|
|
4564
|
+
recordId: props.id,
|
|
4565
|
+
});
|
|
4374
4566
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
4375
4567
|
continue;
|
|
4376
4568
|
}
|
|
4377
|
-
// Log
|
|
4378
|
-
logger_1.logger.error("Database
|
|
4569
|
+
// Log structured error details and rethrow
|
|
4570
|
+
logger_1.logger.error("Database delete operation failed", {
|
|
4571
|
+
operation: 'deleteOneAlert',
|
|
4572
|
+
model: 'Alert',
|
|
4573
|
+
error: String(error),
|
|
4574
|
+
recordId: props.id,
|
|
4575
|
+
isRetryable: isConnectionError,
|
|
4576
|
+
});
|
|
4379
4577
|
throw error;
|
|
4380
4578
|
}
|
|
4381
4579
|
}
|
|
@@ -4448,12 +4646,22 @@ exports.Alert = {
|
|
|
4448
4646
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
4449
4647
|
retryCount++;
|
|
4450
4648
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
4451
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
4649
|
+
logger_1.logger.warn("Database connection error in getAlert, retrying...", {
|
|
4650
|
+
operation: 'getAlert',
|
|
4651
|
+
model: 'Alert',
|
|
4652
|
+
attempt: retryCount,
|
|
4653
|
+
maxRetries: MAX_RETRIES,
|
|
4654
|
+
});
|
|
4452
4655
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
4453
4656
|
continue;
|
|
4454
4657
|
}
|
|
4455
|
-
// Log
|
|
4456
|
-
logger_1.logger.error("Database
|
|
4658
|
+
// Log structured error details and rethrow
|
|
4659
|
+
logger_1.logger.error("Database get operation failed", {
|
|
4660
|
+
operation: 'getAlert',
|
|
4661
|
+
model: 'Alert',
|
|
4662
|
+
error: String(error),
|
|
4663
|
+
isRetryable: isConnectionError,
|
|
4664
|
+
});
|
|
4457
4665
|
throw error;
|
|
4458
4666
|
}
|
|
4459
4667
|
}
|
|
@@ -4511,12 +4719,22 @@ exports.Alert = {
|
|
|
4511
4719
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
4512
4720
|
retryCount++;
|
|
4513
4721
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
4514
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
4722
|
+
logger_1.logger.warn("Database connection error in getAllAlert, retrying...", {
|
|
4723
|
+
operation: 'getAllAlert',
|
|
4724
|
+
model: 'Alert',
|
|
4725
|
+
attempt: retryCount,
|
|
4726
|
+
maxRetries: MAX_RETRIES,
|
|
4727
|
+
});
|
|
4515
4728
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
4516
4729
|
continue;
|
|
4517
4730
|
}
|
|
4518
|
-
// Log
|
|
4519
|
-
logger_1.logger.error("Database
|
|
4731
|
+
// Log structured error details and rethrow
|
|
4732
|
+
logger_1.logger.error("Database getAll operation failed", {
|
|
4733
|
+
operation: 'getAllAlert',
|
|
4734
|
+
model: 'Alert',
|
|
4735
|
+
error: String(error),
|
|
4736
|
+
isRetryable: isConnectionError,
|
|
4737
|
+
});
|
|
4520
4738
|
throw error;
|
|
4521
4739
|
}
|
|
4522
4740
|
}
|
|
@@ -4596,12 +4814,22 @@ exports.Alert = {
|
|
|
4596
4814
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
4597
4815
|
retryCount++;
|
|
4598
4816
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
4599
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
4817
|
+
logger_1.logger.warn("Database connection error in findManyAlert, retrying...", {
|
|
4818
|
+
operation: 'findManyAlert',
|
|
4819
|
+
model: 'Alert',
|
|
4820
|
+
attempt: retryCount,
|
|
4821
|
+
maxRetries: MAX_RETRIES,
|
|
4822
|
+
});
|
|
4600
4823
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
4601
4824
|
continue;
|
|
4602
4825
|
}
|
|
4603
|
-
// Log
|
|
4604
|
-
logger_1.logger.error("Database
|
|
4826
|
+
// Log structured error details and rethrow
|
|
4827
|
+
logger_1.logger.error("Database findMany operation failed", {
|
|
4828
|
+
operation: 'findManyAlert',
|
|
4829
|
+
model: 'Alert',
|
|
4830
|
+
error: String(error),
|
|
4831
|
+
isRetryable: isConnectionError,
|
|
4832
|
+
});
|
|
4605
4833
|
throw error;
|
|
4606
4834
|
}
|
|
4607
4835
|
}
|