@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/Asset.cjs
CHANGED
|
@@ -110,7 +110,7 @@ exports.Asset = {
|
|
|
110
110
|
* @returns The created Asset or null.
|
|
111
111
|
*/
|
|
112
112
|
async create(props, globalClient) {
|
|
113
|
-
var _a, _b, _c, _d, _e;
|
|
113
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
114
114
|
// Maximum number of retries for database connection issues
|
|
115
115
|
const MAX_RETRIES = 3;
|
|
116
116
|
let retryCount = 0;
|
|
@@ -307,21 +307,52 @@ exports.Asset = {
|
|
|
307
307
|
}
|
|
308
308
|
catch (error) {
|
|
309
309
|
lastError = error;
|
|
310
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
311
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
312
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
313
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
314
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
315
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
316
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
317
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
318
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
319
|
+
if (isConstraintViolation) {
|
|
320
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
321
|
+
logger_1.logger.error("Non-retryable constraint violation in createOneAsset", {
|
|
322
|
+
operation: 'createOneAsset',
|
|
323
|
+
model: 'Asset',
|
|
324
|
+
error: String(error),
|
|
325
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
326
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
327
|
+
isRetryable: false,
|
|
328
|
+
});
|
|
329
|
+
throw error;
|
|
330
|
+
}
|
|
310
331
|
// Check if this is a database connection error that we should retry
|
|
311
|
-
const isConnectionError = ((
|
|
312
|
-
((
|
|
313
|
-
((
|
|
314
|
-
((
|
|
315
|
-
(error.networkError && ((
|
|
332
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
333
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
334
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
335
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
336
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
316
337
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
317
338
|
retryCount++;
|
|
318
339
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
319
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
340
|
+
logger_1.logger.warn("Database connection error in createOneAsset, retrying...", {
|
|
341
|
+
operation: 'createOneAsset',
|
|
342
|
+
model: 'Asset',
|
|
343
|
+
attempt: retryCount,
|
|
344
|
+
maxRetries: MAX_RETRIES,
|
|
345
|
+
});
|
|
320
346
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
321
347
|
continue;
|
|
322
348
|
}
|
|
323
|
-
// Log
|
|
324
|
-
logger_1.logger.error("Database
|
|
349
|
+
// Log structured error details and rethrow
|
|
350
|
+
logger_1.logger.error("Database create operation failed", {
|
|
351
|
+
operation: 'createOneAsset',
|
|
352
|
+
model: 'Asset',
|
|
353
|
+
error: String(error),
|
|
354
|
+
isRetryable: isConnectionError,
|
|
355
|
+
});
|
|
325
356
|
throw error;
|
|
326
357
|
}
|
|
327
358
|
}
|
|
@@ -336,7 +367,7 @@ exports.Asset = {
|
|
|
336
367
|
* @returns The count of created records or null.
|
|
337
368
|
*/
|
|
338
369
|
async createMany(props, globalClient) {
|
|
339
|
-
var _a, _b, _c, _d, _e;
|
|
370
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
340
371
|
// Maximum number of retries for database connection issues
|
|
341
372
|
const MAX_RETRIES = 3;
|
|
342
373
|
let retryCount = 0;
|
|
@@ -434,21 +465,52 @@ exports.Asset = {
|
|
|
434
465
|
}
|
|
435
466
|
catch (error) {
|
|
436
467
|
lastError = error;
|
|
468
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
469
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
470
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
471
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
472
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
473
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
474
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
475
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
476
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
477
|
+
if (isConstraintViolation) {
|
|
478
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
479
|
+
logger_1.logger.error("Non-retryable constraint violation in createManyAsset", {
|
|
480
|
+
operation: 'createManyAsset',
|
|
481
|
+
model: 'Asset',
|
|
482
|
+
error: String(error),
|
|
483
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
484
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
485
|
+
isRetryable: false,
|
|
486
|
+
});
|
|
487
|
+
throw error;
|
|
488
|
+
}
|
|
437
489
|
// Check if this is a database connection error that we should retry
|
|
438
|
-
const isConnectionError = ((
|
|
439
|
-
((
|
|
440
|
-
((
|
|
441
|
-
((
|
|
442
|
-
(error.networkError && ((
|
|
490
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
491
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
492
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
493
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
494
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
443
495
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
444
496
|
retryCount++;
|
|
445
497
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
446
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
498
|
+
logger_1.logger.warn("Database connection error in createManyAsset, retrying...", {
|
|
499
|
+
operation: 'createManyAsset',
|
|
500
|
+
model: 'Asset',
|
|
501
|
+
attempt: retryCount,
|
|
502
|
+
maxRetries: MAX_RETRIES,
|
|
503
|
+
});
|
|
447
504
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
448
505
|
continue;
|
|
449
506
|
}
|
|
450
|
-
// Log
|
|
451
|
-
logger_1.logger.error("Database
|
|
507
|
+
// Log structured error details and rethrow
|
|
508
|
+
logger_1.logger.error("Database createMany operation failed", {
|
|
509
|
+
operation: 'createManyAsset',
|
|
510
|
+
model: 'Asset',
|
|
511
|
+
error: String(error),
|
|
512
|
+
isRetryable: isConnectionError,
|
|
513
|
+
});
|
|
452
514
|
throw error;
|
|
453
515
|
}
|
|
454
516
|
}
|
|
@@ -463,7 +525,7 @@ exports.Asset = {
|
|
|
463
525
|
* @returns The updated Asset or null.
|
|
464
526
|
*/
|
|
465
527
|
async update(props, globalClient) {
|
|
466
|
-
var _a, _b, _c, _d, _e;
|
|
528
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
467
529
|
// Maximum number of retries for database connection issues
|
|
468
530
|
const MAX_RETRIES = 3;
|
|
469
531
|
let retryCount = 0;
|
|
@@ -938,21 +1000,55 @@ exports.Asset = {
|
|
|
938
1000
|
}
|
|
939
1001
|
catch (error) {
|
|
940
1002
|
lastError = error;
|
|
1003
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
1004
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
1005
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
1006
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
1007
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
1008
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
1009
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
1010
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
1011
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
1012
|
+
if (isConstraintViolation) {
|
|
1013
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
1014
|
+
logger_1.logger.error("Non-retryable constraint violation in updateOneAsset", {
|
|
1015
|
+
operation: 'updateOneAsset',
|
|
1016
|
+
model: 'Asset',
|
|
1017
|
+
error: String(error),
|
|
1018
|
+
recordId: props.id,
|
|
1019
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
1020
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
1021
|
+
isRetryable: false,
|
|
1022
|
+
});
|
|
1023
|
+
throw error;
|
|
1024
|
+
}
|
|
941
1025
|
// Check if this is a database connection error that we should retry
|
|
942
|
-
const isConnectionError = ((
|
|
943
|
-
((
|
|
944
|
-
((
|
|
945
|
-
((
|
|
946
|
-
(error.networkError && ((
|
|
1026
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
1027
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
1028
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
1029
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
1030
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
947
1031
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
948
1032
|
retryCount++;
|
|
949
1033
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
950
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
1034
|
+
logger_1.logger.warn("Database connection error in updateOneAsset, retrying...", {
|
|
1035
|
+
operation: 'updateOneAsset',
|
|
1036
|
+
model: 'Asset',
|
|
1037
|
+
attempt: retryCount,
|
|
1038
|
+
maxRetries: MAX_RETRIES,
|
|
1039
|
+
recordId: props.id,
|
|
1040
|
+
});
|
|
951
1041
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
952
1042
|
continue;
|
|
953
1043
|
}
|
|
954
|
-
// Log
|
|
955
|
-
logger_1.logger.error("Database
|
|
1044
|
+
// Log structured error details and rethrow
|
|
1045
|
+
logger_1.logger.error("Database update operation failed", {
|
|
1046
|
+
operation: 'updateOneAsset',
|
|
1047
|
+
model: 'Asset',
|
|
1048
|
+
error: String(error),
|
|
1049
|
+
recordId: props.id,
|
|
1050
|
+
isRetryable: isConnectionError,
|
|
1051
|
+
});
|
|
956
1052
|
throw error;
|
|
957
1053
|
}
|
|
958
1054
|
}
|
|
@@ -967,7 +1063,7 @@ exports.Asset = {
|
|
|
967
1063
|
* @returns The updated Asset or null.
|
|
968
1064
|
*/
|
|
969
1065
|
async upsert(props, globalClient) {
|
|
970
|
-
var _a, _b, _c, _d, _e;
|
|
1066
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
971
1067
|
// Maximum number of retries for database connection issues
|
|
972
1068
|
const MAX_RETRIES = 3;
|
|
973
1069
|
let retryCount = 0;
|
|
@@ -1588,21 +1684,55 @@ exports.Asset = {
|
|
|
1588
1684
|
}
|
|
1589
1685
|
catch (error) {
|
|
1590
1686
|
lastError = error;
|
|
1687
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
1688
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
1689
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
1690
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
1691
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
1692
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
1693
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
1694
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
1695
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
1696
|
+
if (isConstraintViolation) {
|
|
1697
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
1698
|
+
logger_1.logger.error("Non-retryable constraint violation in upsertOneAsset", {
|
|
1699
|
+
operation: 'upsertOneAsset',
|
|
1700
|
+
model: 'Asset',
|
|
1701
|
+
error: String(error),
|
|
1702
|
+
recordId: props.id,
|
|
1703
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
1704
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
1705
|
+
isRetryable: false,
|
|
1706
|
+
});
|
|
1707
|
+
throw error;
|
|
1708
|
+
}
|
|
1591
1709
|
// Check if this is a database connection error that we should retry
|
|
1592
|
-
const isConnectionError = ((
|
|
1593
|
-
((
|
|
1594
|
-
((
|
|
1595
|
-
((
|
|
1596
|
-
(error.networkError && ((
|
|
1710
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
1711
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
1712
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
1713
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
1714
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
1597
1715
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
1598
1716
|
retryCount++;
|
|
1599
1717
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
1600
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
1718
|
+
logger_1.logger.warn("Database connection error in upsertOneAsset, retrying...", {
|
|
1719
|
+
operation: 'upsertOneAsset',
|
|
1720
|
+
model: 'Asset',
|
|
1721
|
+
attempt: retryCount,
|
|
1722
|
+
maxRetries: MAX_RETRIES,
|
|
1723
|
+
recordId: props.id,
|
|
1724
|
+
});
|
|
1601
1725
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
1602
1726
|
continue;
|
|
1603
1727
|
}
|
|
1604
|
-
// Log
|
|
1605
|
-
logger_1.logger.error("Database
|
|
1728
|
+
// Log structured error details and rethrow
|
|
1729
|
+
logger_1.logger.error("Database upsert operation failed", {
|
|
1730
|
+
operation: 'upsertOneAsset',
|
|
1731
|
+
model: 'Asset',
|
|
1732
|
+
error: String(error),
|
|
1733
|
+
recordId: props.id,
|
|
1734
|
+
isRetryable: isConnectionError,
|
|
1735
|
+
});
|
|
1606
1736
|
throw error;
|
|
1607
1737
|
}
|
|
1608
1738
|
}
|
|
@@ -1617,7 +1747,7 @@ exports.Asset = {
|
|
|
1617
1747
|
* @returns The count of created records or null.
|
|
1618
1748
|
*/
|
|
1619
1749
|
async updateMany(props, globalClient) {
|
|
1620
|
-
var _a, _b, _c, _d, _e;
|
|
1750
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
1621
1751
|
// Maximum number of retries for database connection issues
|
|
1622
1752
|
const MAX_RETRIES = 3;
|
|
1623
1753
|
let retryCount = 0;
|
|
@@ -2092,21 +2222,52 @@ exports.Asset = {
|
|
|
2092
2222
|
}
|
|
2093
2223
|
catch (error) {
|
|
2094
2224
|
lastError = error;
|
|
2225
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
2226
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
2227
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
2228
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
2229
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
2230
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
2231
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
2232
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
2233
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
2234
|
+
if (isConstraintViolation) {
|
|
2235
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
2236
|
+
logger_1.logger.error("Non-retryable constraint violation in updateManyAsset", {
|
|
2237
|
+
operation: 'updateManyAsset',
|
|
2238
|
+
model: 'Asset',
|
|
2239
|
+
error: String(error),
|
|
2240
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
2241
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
2242
|
+
isRetryable: false,
|
|
2243
|
+
});
|
|
2244
|
+
throw error;
|
|
2245
|
+
}
|
|
2095
2246
|
// Check if this is a database connection error that we should retry
|
|
2096
|
-
const isConnectionError = ((
|
|
2097
|
-
((
|
|
2098
|
-
((
|
|
2099
|
-
((
|
|
2100
|
-
(error.networkError && ((
|
|
2247
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
2248
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
2249
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
2250
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
2251
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
2101
2252
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
2102
2253
|
retryCount++;
|
|
2103
2254
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
2104
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
2255
|
+
logger_1.logger.warn("Database connection error in updateManyAsset, retrying...", {
|
|
2256
|
+
operation: 'updateManyAsset',
|
|
2257
|
+
model: 'Asset',
|
|
2258
|
+
attempt: retryCount,
|
|
2259
|
+
maxRetries: MAX_RETRIES,
|
|
2260
|
+
});
|
|
2105
2261
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
2106
2262
|
continue;
|
|
2107
2263
|
}
|
|
2108
|
-
// Log
|
|
2109
|
-
logger_1.logger.error("Database
|
|
2264
|
+
// Log structured error details and rethrow
|
|
2265
|
+
logger_1.logger.error("Database updateMany operation failed", {
|
|
2266
|
+
operation: 'updateManyAsset',
|
|
2267
|
+
model: 'Asset',
|
|
2268
|
+
error: String(error),
|
|
2269
|
+
isRetryable: isConnectionError,
|
|
2270
|
+
});
|
|
2110
2271
|
throw error;
|
|
2111
2272
|
}
|
|
2112
2273
|
}
|
|
@@ -2121,7 +2282,7 @@ exports.Asset = {
|
|
|
2121
2282
|
* @returns The deleted Asset or null.
|
|
2122
2283
|
*/
|
|
2123
2284
|
async delete(props, globalClient) {
|
|
2124
|
-
var _a, _b, _c, _d, _e;
|
|
2285
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
2125
2286
|
// Maximum number of retries for database connection issues
|
|
2126
2287
|
const MAX_RETRIES = 3;
|
|
2127
2288
|
let retryCount = 0;
|
|
@@ -2165,21 +2326,58 @@ exports.Asset = {
|
|
|
2165
2326
|
}
|
|
2166
2327
|
catch (error) {
|
|
2167
2328
|
lastError = error;
|
|
2329
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
2330
|
+
// (e.g., foreign key constraints preventing deletion)
|
|
2331
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
2332
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
2333
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
2334
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
2335
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
2336
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
2337
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
|
|
2338
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
|
|
2339
|
+
((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
|
|
2340
|
+
((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
|
|
2341
|
+
if (isConstraintViolation) {
|
|
2342
|
+
const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
|
|
2343
|
+
logger_1.logger.error("Non-retryable constraint violation in deleteOneAsset", {
|
|
2344
|
+
operation: 'deleteOneAsset',
|
|
2345
|
+
model: 'Asset',
|
|
2346
|
+
error: String(error),
|
|
2347
|
+
recordId: props.id,
|
|
2348
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
2349
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
2350
|
+
isRetryable: false,
|
|
2351
|
+
});
|
|
2352
|
+
throw error;
|
|
2353
|
+
}
|
|
2168
2354
|
// Check if this is a database connection error that we should retry
|
|
2169
|
-
const isConnectionError = ((
|
|
2170
|
-
((
|
|
2171
|
-
((
|
|
2172
|
-
((
|
|
2173
|
-
(error.networkError && ((
|
|
2355
|
+
const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
|
|
2356
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
|
|
2357
|
+
((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
|
|
2358
|
+
((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
2359
|
+
(error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
|
|
2174
2360
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
2175
2361
|
retryCount++;
|
|
2176
2362
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
2177
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
2363
|
+
logger_1.logger.warn("Database connection error in deleteOneAsset, retrying...", {
|
|
2364
|
+
operation: 'deleteOneAsset',
|
|
2365
|
+
model: 'Asset',
|
|
2366
|
+
attempt: retryCount,
|
|
2367
|
+
maxRetries: MAX_RETRIES,
|
|
2368
|
+
recordId: props.id,
|
|
2369
|
+
});
|
|
2178
2370
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
2179
2371
|
continue;
|
|
2180
2372
|
}
|
|
2181
|
-
// Log
|
|
2182
|
-
logger_1.logger.error("Database
|
|
2373
|
+
// Log structured error details and rethrow
|
|
2374
|
+
logger_1.logger.error("Database delete operation failed", {
|
|
2375
|
+
operation: 'deleteOneAsset',
|
|
2376
|
+
model: 'Asset',
|
|
2377
|
+
error: String(error),
|
|
2378
|
+
recordId: props.id,
|
|
2379
|
+
isRetryable: isConnectionError,
|
|
2380
|
+
});
|
|
2183
2381
|
throw error;
|
|
2184
2382
|
}
|
|
2185
2383
|
}
|
|
@@ -2248,12 +2446,22 @@ exports.Asset = {
|
|
|
2248
2446
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
2249
2447
|
retryCount++;
|
|
2250
2448
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
2251
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
2449
|
+
logger_1.logger.warn("Database connection error in getAsset, retrying...", {
|
|
2450
|
+
operation: 'getAsset',
|
|
2451
|
+
model: 'Asset',
|
|
2452
|
+
attempt: retryCount,
|
|
2453
|
+
maxRetries: MAX_RETRIES,
|
|
2454
|
+
});
|
|
2252
2455
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
2253
2456
|
continue;
|
|
2254
2457
|
}
|
|
2255
|
-
// Log
|
|
2256
|
-
logger_1.logger.error("Database
|
|
2458
|
+
// Log structured error details and rethrow
|
|
2459
|
+
logger_1.logger.error("Database get operation failed", {
|
|
2460
|
+
operation: 'getAsset',
|
|
2461
|
+
model: 'Asset',
|
|
2462
|
+
error: String(error),
|
|
2463
|
+
isRetryable: isConnectionError,
|
|
2464
|
+
});
|
|
2257
2465
|
throw error;
|
|
2258
2466
|
}
|
|
2259
2467
|
}
|
|
@@ -2311,12 +2519,22 @@ exports.Asset = {
|
|
|
2311
2519
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
2312
2520
|
retryCount++;
|
|
2313
2521
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
2314
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
2522
|
+
logger_1.logger.warn("Database connection error in getAllAsset, retrying...", {
|
|
2523
|
+
operation: 'getAllAsset',
|
|
2524
|
+
model: 'Asset',
|
|
2525
|
+
attempt: retryCount,
|
|
2526
|
+
maxRetries: MAX_RETRIES,
|
|
2527
|
+
});
|
|
2315
2528
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
2316
2529
|
continue;
|
|
2317
2530
|
}
|
|
2318
|
-
// Log
|
|
2319
|
-
logger_1.logger.error("Database
|
|
2531
|
+
// Log structured error details and rethrow
|
|
2532
|
+
logger_1.logger.error("Database getAll operation failed", {
|
|
2533
|
+
operation: 'getAllAsset',
|
|
2534
|
+
model: 'Asset',
|
|
2535
|
+
error: String(error),
|
|
2536
|
+
isRetryable: isConnectionError,
|
|
2537
|
+
});
|
|
2320
2538
|
throw error;
|
|
2321
2539
|
}
|
|
2322
2540
|
}
|
|
@@ -2396,12 +2614,22 @@ exports.Asset = {
|
|
|
2396
2614
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
2397
2615
|
retryCount++;
|
|
2398
2616
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
2399
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
2617
|
+
logger_1.logger.warn("Database connection error in findManyAsset, retrying...", {
|
|
2618
|
+
operation: 'findManyAsset',
|
|
2619
|
+
model: 'Asset',
|
|
2620
|
+
attempt: retryCount,
|
|
2621
|
+
maxRetries: MAX_RETRIES,
|
|
2622
|
+
});
|
|
2400
2623
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
2401
2624
|
continue;
|
|
2402
2625
|
}
|
|
2403
|
-
// Log
|
|
2404
|
-
logger_1.logger.error("Database
|
|
2626
|
+
// Log structured error details and rethrow
|
|
2627
|
+
logger_1.logger.error("Database findMany operation failed", {
|
|
2628
|
+
operation: 'findManyAsset',
|
|
2629
|
+
model: 'Asset',
|
|
2630
|
+
error: String(error),
|
|
2631
|
+
isRetryable: isConnectionError,
|
|
2632
|
+
});
|
|
2405
2633
|
throw error;
|
|
2406
2634
|
}
|
|
2407
2635
|
}
|