@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.
Files changed (229) hide show
  1. package/ABTest.cjs +291 -63
  2. package/Account.cjs +291 -63
  3. package/AccountLinkingRequest.cjs +291 -63
  4. package/Action.cjs +291 -63
  5. package/Alert.cjs +291 -63
  6. package/Allocation.cjs +291 -63
  7. package/AlpacaAccount.cjs +291 -63
  8. package/AnalyticsConfiguration.cjs +291 -63
  9. package/AnalyticsSnapshot.cjs +291 -63
  10. package/Asset.cjs +291 -63
  11. package/AuditLog.cjs +291 -63
  12. package/Authenticator.cjs +291 -63
  13. package/Configuration.cjs +291 -63
  14. package/ConflictEvent.cjs +291 -63
  15. package/ConnectionHealthSnapshot.cjs +291 -63
  16. package/Customer.cjs +291 -63
  17. package/DeadLetterMessage.cjs +291 -63
  18. package/EconomicEvent.cjs +291 -63
  19. package/Event.cjs +291 -63
  20. package/EventSnapshot.cjs +291 -63
  21. package/FeatureImportanceAnalysis.cjs +291 -63
  22. package/InstitutionalFlowSignal.cjs +291 -63
  23. package/InstitutionalHolding.cjs +291 -63
  24. package/InstitutionalSentimentAlerts.cjs +291 -63
  25. package/InstitutionalSentimentErrors.cjs +291 -63
  26. package/InstitutionalSentimentHistory.cjs +291 -63
  27. package/InstitutionalSentimentMetrics.cjs +291 -63
  28. package/InviteToken.cjs +291 -63
  29. package/LinkedProvider.cjs +291 -63
  30. package/MLTrainingData.cjs +291 -63
  31. package/MarketSentiment.cjs +291 -63
  32. package/ModelArtifact.cjs +291 -63
  33. package/ModelVersion.cjs +291 -63
  34. package/ModelVersionArtifact.cjs +291 -63
  35. package/NewsArticle.cjs +291 -63
  36. package/NewsArticleAssetSentiment.cjs +291 -63
  37. package/OptionsContract.cjs +291 -63
  38. package/OptionsGreeksHistory.cjs +291 -63
  39. package/OptionsPosition.cjs +291 -63
  40. package/OptionsTradeExecution.cjs +291 -63
  41. package/PortfolioGreeksHistory.cjs +291 -63
  42. package/ScheduledOptionOrder.cjs +291 -63
  43. package/Session.cjs +291 -63
  44. package/SignalGeneratorMetrics.cjs +291 -63
  45. package/SignalLineage.cjs +291 -63
  46. package/SignalOutcome.cjs +291 -63
  47. package/SignalPriorityQueue.cjs +291 -63
  48. package/SyncEvent.cjs +291 -63
  49. package/SystemAlert.cjs +291 -63
  50. package/Trade.cjs +291 -63
  51. package/TradeAuditEvent.cjs +291 -63
  52. package/TradeExecutionHistory.cjs +291 -63
  53. package/User.cjs +291 -63
  54. package/VerificationToken.cjs +291 -63
  55. package/WaitlistEntry.cjs +291 -63
  56. package/esm/ABTest.d.ts.map +1 -1
  57. package/esm/ABTest.js.map +1 -1
  58. package/esm/ABTest.mjs +255 -27
  59. package/esm/Account.d.ts.map +1 -1
  60. package/esm/Account.js.map +1 -1
  61. package/esm/Account.mjs +255 -27
  62. package/esm/AccountLinkingRequest.d.ts.map +1 -1
  63. package/esm/AccountLinkingRequest.js.map +1 -1
  64. package/esm/AccountLinkingRequest.mjs +255 -27
  65. package/esm/Action.d.ts.map +1 -1
  66. package/esm/Action.js.map +1 -1
  67. package/esm/Action.mjs +255 -27
  68. package/esm/Alert.d.ts.map +1 -1
  69. package/esm/Alert.js.map +1 -1
  70. package/esm/Alert.mjs +255 -27
  71. package/esm/Allocation.d.ts.map +1 -1
  72. package/esm/Allocation.js.map +1 -1
  73. package/esm/Allocation.mjs +255 -27
  74. package/esm/AlpacaAccount.d.ts.map +1 -1
  75. package/esm/AlpacaAccount.js.map +1 -1
  76. package/esm/AlpacaAccount.mjs +255 -27
  77. package/esm/AnalyticsConfiguration.d.ts.map +1 -1
  78. package/esm/AnalyticsConfiguration.js.map +1 -1
  79. package/esm/AnalyticsConfiguration.mjs +255 -27
  80. package/esm/AnalyticsSnapshot.d.ts.map +1 -1
  81. package/esm/AnalyticsSnapshot.js.map +1 -1
  82. package/esm/AnalyticsSnapshot.mjs +255 -27
  83. package/esm/Asset.d.ts.map +1 -1
  84. package/esm/Asset.js.map +1 -1
  85. package/esm/Asset.mjs +255 -27
  86. package/esm/AuditLog.d.ts.map +1 -1
  87. package/esm/AuditLog.js.map +1 -1
  88. package/esm/AuditLog.mjs +255 -27
  89. package/esm/Authenticator.d.ts.map +1 -1
  90. package/esm/Authenticator.js.map +1 -1
  91. package/esm/Authenticator.mjs +255 -27
  92. package/esm/Configuration.d.ts.map +1 -1
  93. package/esm/Configuration.js.map +1 -1
  94. package/esm/Configuration.mjs +255 -27
  95. package/esm/ConflictEvent.d.ts.map +1 -1
  96. package/esm/ConflictEvent.js.map +1 -1
  97. package/esm/ConflictEvent.mjs +255 -27
  98. package/esm/ConnectionHealthSnapshot.d.ts.map +1 -1
  99. package/esm/ConnectionHealthSnapshot.js.map +1 -1
  100. package/esm/ConnectionHealthSnapshot.mjs +255 -27
  101. package/esm/Customer.d.ts.map +1 -1
  102. package/esm/Customer.js.map +1 -1
  103. package/esm/Customer.mjs +255 -27
  104. package/esm/DeadLetterMessage.d.ts.map +1 -1
  105. package/esm/DeadLetterMessage.js.map +1 -1
  106. package/esm/DeadLetterMessage.mjs +255 -27
  107. package/esm/EconomicEvent.d.ts.map +1 -1
  108. package/esm/EconomicEvent.js.map +1 -1
  109. package/esm/EconomicEvent.mjs +255 -27
  110. package/esm/Event.d.ts.map +1 -1
  111. package/esm/Event.js.map +1 -1
  112. package/esm/Event.mjs +255 -27
  113. package/esm/EventSnapshot.d.ts.map +1 -1
  114. package/esm/EventSnapshot.js.map +1 -1
  115. package/esm/EventSnapshot.mjs +255 -27
  116. package/esm/FeatureImportanceAnalysis.d.ts.map +1 -1
  117. package/esm/FeatureImportanceAnalysis.js.map +1 -1
  118. package/esm/FeatureImportanceAnalysis.mjs +255 -27
  119. package/esm/InstitutionalFlowSignal.d.ts.map +1 -1
  120. package/esm/InstitutionalFlowSignal.js.map +1 -1
  121. package/esm/InstitutionalFlowSignal.mjs +255 -27
  122. package/esm/InstitutionalHolding.d.ts.map +1 -1
  123. package/esm/InstitutionalHolding.js.map +1 -1
  124. package/esm/InstitutionalHolding.mjs +255 -27
  125. package/esm/InstitutionalSentimentAlerts.d.ts.map +1 -1
  126. package/esm/InstitutionalSentimentAlerts.js.map +1 -1
  127. package/esm/InstitutionalSentimentAlerts.mjs +255 -27
  128. package/esm/InstitutionalSentimentErrors.d.ts.map +1 -1
  129. package/esm/InstitutionalSentimentErrors.js.map +1 -1
  130. package/esm/InstitutionalSentimentErrors.mjs +255 -27
  131. package/esm/InstitutionalSentimentHistory.d.ts.map +1 -1
  132. package/esm/InstitutionalSentimentHistory.js.map +1 -1
  133. package/esm/InstitutionalSentimentHistory.mjs +255 -27
  134. package/esm/InstitutionalSentimentMetrics.d.ts.map +1 -1
  135. package/esm/InstitutionalSentimentMetrics.js.map +1 -1
  136. package/esm/InstitutionalSentimentMetrics.mjs +255 -27
  137. package/esm/InviteToken.d.ts.map +1 -1
  138. package/esm/InviteToken.js.map +1 -1
  139. package/esm/InviteToken.mjs +255 -27
  140. package/esm/LinkedProvider.d.ts.map +1 -1
  141. package/esm/LinkedProvider.js.map +1 -1
  142. package/esm/LinkedProvider.mjs +255 -27
  143. package/esm/MLTrainingData.d.ts.map +1 -1
  144. package/esm/MLTrainingData.js.map +1 -1
  145. package/esm/MLTrainingData.mjs +255 -27
  146. package/esm/MarketSentiment.d.ts.map +1 -1
  147. package/esm/MarketSentiment.js.map +1 -1
  148. package/esm/MarketSentiment.mjs +255 -27
  149. package/esm/ModelArtifact.d.ts.map +1 -1
  150. package/esm/ModelArtifact.js.map +1 -1
  151. package/esm/ModelArtifact.mjs +255 -27
  152. package/esm/ModelVersion.d.ts.map +1 -1
  153. package/esm/ModelVersion.js.map +1 -1
  154. package/esm/ModelVersion.mjs +255 -27
  155. package/esm/ModelVersionArtifact.d.ts.map +1 -1
  156. package/esm/ModelVersionArtifact.js.map +1 -1
  157. package/esm/ModelVersionArtifact.mjs +255 -27
  158. package/esm/NewsArticle.d.ts.map +1 -1
  159. package/esm/NewsArticle.js.map +1 -1
  160. package/esm/NewsArticle.mjs +255 -27
  161. package/esm/NewsArticleAssetSentiment.d.ts.map +1 -1
  162. package/esm/NewsArticleAssetSentiment.js.map +1 -1
  163. package/esm/NewsArticleAssetSentiment.mjs +255 -27
  164. package/esm/OptionsContract.d.ts.map +1 -1
  165. package/esm/OptionsContract.js.map +1 -1
  166. package/esm/OptionsContract.mjs +255 -27
  167. package/esm/OptionsGreeksHistory.d.ts.map +1 -1
  168. package/esm/OptionsGreeksHistory.js.map +1 -1
  169. package/esm/OptionsGreeksHistory.mjs +255 -27
  170. package/esm/OptionsPosition.d.ts.map +1 -1
  171. package/esm/OptionsPosition.js.map +1 -1
  172. package/esm/OptionsPosition.mjs +255 -27
  173. package/esm/OptionsTradeExecution.d.ts.map +1 -1
  174. package/esm/OptionsTradeExecution.js.map +1 -1
  175. package/esm/OptionsTradeExecution.mjs +255 -27
  176. package/esm/PortfolioGreeksHistory.d.ts.map +1 -1
  177. package/esm/PortfolioGreeksHistory.js.map +1 -1
  178. package/esm/PortfolioGreeksHistory.mjs +255 -27
  179. package/esm/ScheduledOptionOrder.d.ts.map +1 -1
  180. package/esm/ScheduledOptionOrder.js.map +1 -1
  181. package/esm/ScheduledOptionOrder.mjs +255 -27
  182. package/esm/Session.d.ts.map +1 -1
  183. package/esm/Session.js.map +1 -1
  184. package/esm/Session.mjs +255 -27
  185. package/esm/SignalGeneratorMetrics.d.ts.map +1 -1
  186. package/esm/SignalGeneratorMetrics.js.map +1 -1
  187. package/esm/SignalGeneratorMetrics.mjs +255 -27
  188. package/esm/SignalLineage.d.ts.map +1 -1
  189. package/esm/SignalLineage.js.map +1 -1
  190. package/esm/SignalLineage.mjs +255 -27
  191. package/esm/SignalOutcome.d.ts.map +1 -1
  192. package/esm/SignalOutcome.js.map +1 -1
  193. package/esm/SignalOutcome.mjs +255 -27
  194. package/esm/SignalPriorityQueue.d.ts.map +1 -1
  195. package/esm/SignalPriorityQueue.js.map +1 -1
  196. package/esm/SignalPriorityQueue.mjs +255 -27
  197. package/esm/SyncEvent.d.ts.map +1 -1
  198. package/esm/SyncEvent.js.map +1 -1
  199. package/esm/SyncEvent.mjs +255 -27
  200. package/esm/SystemAlert.d.ts.map +1 -1
  201. package/esm/SystemAlert.js.map +1 -1
  202. package/esm/SystemAlert.mjs +255 -27
  203. package/esm/Trade.d.ts.map +1 -1
  204. package/esm/Trade.js.map +1 -1
  205. package/esm/Trade.mjs +255 -27
  206. package/esm/TradeAuditEvent.d.ts.map +1 -1
  207. package/esm/TradeAuditEvent.js.map +1 -1
  208. package/esm/TradeAuditEvent.mjs +255 -27
  209. package/esm/TradeExecutionHistory.d.ts.map +1 -1
  210. package/esm/TradeExecutionHistory.js.map +1 -1
  211. package/esm/TradeExecutionHistory.mjs +255 -27
  212. package/esm/User.d.ts.map +1 -1
  213. package/esm/User.js.map +1 -1
  214. package/esm/User.mjs +255 -27
  215. package/esm/VerificationToken.d.ts.map +1 -1
  216. package/esm/VerificationToken.js.map +1 -1
  217. package/esm/VerificationToken.mjs +255 -27
  218. package/esm/WaitlistEntry.d.ts.map +1 -1
  219. package/esm/WaitlistEntry.js.map +1 -1
  220. package/esm/WaitlistEntry.mjs +255 -27
  221. package/esm/middleware/audit-logger.d.ts +0 -7
  222. package/esm/middleware/audit-logger.d.ts.map +1 -1
  223. package/esm/middleware/audit-logger.js.map +1 -1
  224. package/esm/middleware/audit-logger.mjs +5 -3
  225. package/esm/prismaClient.d.ts.map +1 -1
  226. package/esm/prismaClient.js.map +1 -1
  227. package/esm/prismaClient.mjs +38 -9
  228. package/package.json +1 -1
  229. package/prismaClient.cjs +38 -9
@@ -212,7 +212,7 @@ exports.OptionsContract = {
212
212
  * @returns The created OptionsContract or null.
213
213
  */
214
214
  async create(props, globalClient) {
215
- var _a, _b, _c, _d, _e;
215
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
216
216
  // Maximum number of retries for database connection issues
217
217
  const MAX_RETRIES = 3;
218
218
  let retryCount = 0;
@@ -482,21 +482,52 @@ exports.OptionsContract = {
482
482
  }
483
483
  catch (error) {
484
484
  lastError = error;
485
+ // Check for constraint violations FIRST - these are NEVER retryable
486
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
487
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
488
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
489
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
490
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
491
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
492
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
493
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
494
+ if (isConstraintViolation) {
495
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
496
+ logger_1.logger.error("Non-retryable constraint violation in createOneOptionsContract", {
497
+ operation: 'createOneOptionsContract',
498
+ model: 'OptionsContract',
499
+ error: String(error),
500
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
501
+ errorCategory: 'CONSTRAINT_VIOLATION',
502
+ isRetryable: false,
503
+ });
504
+ throw error;
505
+ }
485
506
  // Check if this is a database connection error that we should retry
486
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
487
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
488
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
489
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
490
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
507
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
508
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
509
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
510
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
511
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
491
512
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
492
513
  retryCount++;
493
514
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
494
- logger_1.logger.warn("Database connection error, retrying...");
515
+ logger_1.logger.warn("Database connection error in createOneOptionsContract, retrying...", {
516
+ operation: 'createOneOptionsContract',
517
+ model: 'OptionsContract',
518
+ attempt: retryCount,
519
+ maxRetries: MAX_RETRIES,
520
+ });
495
521
  await new Promise(resolve => setTimeout(resolve, delay));
496
522
  continue;
497
523
  }
498
- // Log the error and rethrow
499
- logger_1.logger.error("Database error occurred", { error: String(error) });
524
+ // Log structured error details and rethrow
525
+ logger_1.logger.error("Database create operation failed", {
526
+ operation: 'createOneOptionsContract',
527
+ model: 'OptionsContract',
528
+ error: String(error),
529
+ isRetryable: isConnectionError,
530
+ });
500
531
  throw error;
501
532
  }
502
533
  }
@@ -511,7 +542,7 @@ exports.OptionsContract = {
511
542
  * @returns The count of created records or null.
512
543
  */
513
544
  async createMany(props, globalClient) {
514
- var _a, _b, _c, _d, _e;
545
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
515
546
  // Maximum number of retries for database connection issues
516
547
  const MAX_RETRIES = 3;
517
548
  let retryCount = 0;
@@ -566,21 +597,52 @@ exports.OptionsContract = {
566
597
  }
567
598
  catch (error) {
568
599
  lastError = error;
600
+ // Check for constraint violations FIRST - these are NEVER retryable
601
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
602
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
603
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
604
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
605
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
606
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
607
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
608
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
609
+ if (isConstraintViolation) {
610
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
611
+ logger_1.logger.error("Non-retryable constraint violation in createManyOptionsContract", {
612
+ operation: 'createManyOptionsContract',
613
+ model: 'OptionsContract',
614
+ error: String(error),
615
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
616
+ errorCategory: 'CONSTRAINT_VIOLATION',
617
+ isRetryable: false,
618
+ });
619
+ throw error;
620
+ }
569
621
  // Check if this is a database connection error that we should retry
570
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
571
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
572
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
573
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
574
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
622
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
623
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
624
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
625
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
626
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
575
627
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
576
628
  retryCount++;
577
629
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
578
- logger_1.logger.warn("Database connection error, retrying...");
630
+ logger_1.logger.warn("Database connection error in createManyOptionsContract, retrying...", {
631
+ operation: 'createManyOptionsContract',
632
+ model: 'OptionsContract',
633
+ attempt: retryCount,
634
+ maxRetries: MAX_RETRIES,
635
+ });
579
636
  await new Promise(resolve => setTimeout(resolve, delay));
580
637
  continue;
581
638
  }
582
- // Log the error and rethrow
583
- logger_1.logger.error("Database error occurred", { error: String(error) });
639
+ // Log structured error details and rethrow
640
+ logger_1.logger.error("Database createMany operation failed", {
641
+ operation: 'createManyOptionsContract',
642
+ model: 'OptionsContract',
643
+ error: String(error),
644
+ isRetryable: isConnectionError,
645
+ });
584
646
  throw error;
585
647
  }
586
648
  }
@@ -595,7 +657,7 @@ exports.OptionsContract = {
595
657
  * @returns The updated OptionsContract or null.
596
658
  */
597
659
  async update(props, globalClient) {
598
- var _a, _b, _c, _d, _e;
660
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
599
661
  // Maximum number of retries for database connection issues
600
662
  const MAX_RETRIES = 3;
601
663
  let retryCount = 0;
@@ -1693,21 +1755,55 @@ exports.OptionsContract = {
1693
1755
  }
1694
1756
  catch (error) {
1695
1757
  lastError = error;
1758
+ // Check for constraint violations FIRST - these are NEVER retryable
1759
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
1760
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
1761
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
1762
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
1763
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
1764
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
1765
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
1766
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
1767
+ if (isConstraintViolation) {
1768
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
1769
+ logger_1.logger.error("Non-retryable constraint violation in updateOneOptionsContract", {
1770
+ operation: 'updateOneOptionsContract',
1771
+ model: 'OptionsContract',
1772
+ error: String(error),
1773
+ recordId: props.id,
1774
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1775
+ errorCategory: 'CONSTRAINT_VIOLATION',
1776
+ isRetryable: false,
1777
+ });
1778
+ throw error;
1779
+ }
1696
1780
  // Check if this is a database connection error that we should retry
1697
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
1698
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
1699
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
1700
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
1701
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
1781
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
1782
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
1783
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
1784
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
1785
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
1702
1786
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1703
1787
  retryCount++;
1704
1788
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1705
- logger_1.logger.warn("Database connection error, retrying...");
1789
+ logger_1.logger.warn("Database connection error in updateOneOptionsContract, retrying...", {
1790
+ operation: 'updateOneOptionsContract',
1791
+ model: 'OptionsContract',
1792
+ attempt: retryCount,
1793
+ maxRetries: MAX_RETRIES,
1794
+ recordId: props.id,
1795
+ });
1706
1796
  await new Promise(resolve => setTimeout(resolve, delay));
1707
1797
  continue;
1708
1798
  }
1709
- // Log the error and rethrow
1710
- logger_1.logger.error("Database error occurred", { error: String(error) });
1799
+ // Log structured error details and rethrow
1800
+ logger_1.logger.error("Database update operation failed", {
1801
+ operation: 'updateOneOptionsContract',
1802
+ model: 'OptionsContract',
1803
+ error: String(error),
1804
+ recordId: props.id,
1805
+ isRetryable: isConnectionError,
1806
+ });
1711
1807
  throw error;
1712
1808
  }
1713
1809
  }
@@ -1722,7 +1818,7 @@ exports.OptionsContract = {
1722
1818
  * @returns The updated OptionsContract or null.
1723
1819
  */
1724
1820
  async upsert(props, globalClient) {
1725
- var _a, _b, _c, _d, _e;
1821
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1726
1822
  // Maximum number of retries for database connection issues
1727
1823
  const MAX_RETRIES = 3;
1728
1824
  let retryCount = 0;
@@ -3039,21 +3135,55 @@ exports.OptionsContract = {
3039
3135
  }
3040
3136
  catch (error) {
3041
3137
  lastError = error;
3138
+ // Check for constraint violations FIRST - these are NEVER retryable
3139
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
3140
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
3141
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
3142
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
3143
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
3144
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
3145
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
3146
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
3147
+ if (isConstraintViolation) {
3148
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
3149
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneOptionsContract", {
3150
+ operation: 'upsertOneOptionsContract',
3151
+ model: 'OptionsContract',
3152
+ error: String(error),
3153
+ recordId: props.id,
3154
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
3155
+ errorCategory: 'CONSTRAINT_VIOLATION',
3156
+ isRetryable: false,
3157
+ });
3158
+ throw error;
3159
+ }
3042
3160
  // Check if this is a database connection error that we should retry
3043
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
3044
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
3045
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
3046
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
3047
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
3161
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
3162
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
3163
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
3164
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
3165
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
3048
3166
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
3049
3167
  retryCount++;
3050
3168
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
3051
- logger_1.logger.warn("Database connection error, retrying...");
3169
+ logger_1.logger.warn("Database connection error in upsertOneOptionsContract, retrying...", {
3170
+ operation: 'upsertOneOptionsContract',
3171
+ model: 'OptionsContract',
3172
+ attempt: retryCount,
3173
+ maxRetries: MAX_RETRIES,
3174
+ recordId: props.id,
3175
+ });
3052
3176
  await new Promise(resolve => setTimeout(resolve, delay));
3053
3177
  continue;
3054
3178
  }
3055
- // Log the error and rethrow
3056
- logger_1.logger.error("Database error occurred", { error: String(error) });
3179
+ // Log structured error details and rethrow
3180
+ logger_1.logger.error("Database upsert operation failed", {
3181
+ operation: 'upsertOneOptionsContract',
3182
+ model: 'OptionsContract',
3183
+ error: String(error),
3184
+ recordId: props.id,
3185
+ isRetryable: isConnectionError,
3186
+ });
3057
3187
  throw error;
3058
3188
  }
3059
3189
  }
@@ -3068,7 +3198,7 @@ exports.OptionsContract = {
3068
3198
  * @returns The count of created records or null.
3069
3199
  */
3070
3200
  async updateMany(props, globalClient) {
3071
- var _a, _b, _c, _d, _e;
3201
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
3072
3202
  // Maximum number of retries for database connection issues
3073
3203
  const MAX_RETRIES = 3;
3074
3204
  let retryCount = 0;
@@ -4166,21 +4296,52 @@ exports.OptionsContract = {
4166
4296
  }
4167
4297
  catch (error) {
4168
4298
  lastError = error;
4299
+ // Check for constraint violations FIRST - these are NEVER retryable
4300
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
4301
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
4302
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
4303
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
4304
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
4305
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
4306
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
4307
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
4308
+ if (isConstraintViolation) {
4309
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
4310
+ logger_1.logger.error("Non-retryable constraint violation in updateManyOptionsContract", {
4311
+ operation: 'updateManyOptionsContract',
4312
+ model: 'OptionsContract',
4313
+ error: String(error),
4314
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
4315
+ errorCategory: 'CONSTRAINT_VIOLATION',
4316
+ isRetryable: false,
4317
+ });
4318
+ throw error;
4319
+ }
4169
4320
  // Check if this is a database connection error that we should retry
4170
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
4171
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
4172
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
4173
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
4174
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
4321
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
4322
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
4323
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
4324
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
4325
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
4175
4326
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4176
4327
  retryCount++;
4177
4328
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4178
- logger_1.logger.warn("Database connection error, retrying...");
4329
+ logger_1.logger.warn("Database connection error in updateManyOptionsContract, retrying...", {
4330
+ operation: 'updateManyOptionsContract',
4331
+ model: 'OptionsContract',
4332
+ attempt: retryCount,
4333
+ maxRetries: MAX_RETRIES,
4334
+ });
4179
4335
  await new Promise(resolve => setTimeout(resolve, delay));
4180
4336
  continue;
4181
4337
  }
4182
- // Log the error and rethrow
4183
- logger_1.logger.error("Database error occurred", { error: String(error) });
4338
+ // Log structured error details and rethrow
4339
+ logger_1.logger.error("Database updateMany operation failed", {
4340
+ operation: 'updateManyOptionsContract',
4341
+ model: 'OptionsContract',
4342
+ error: String(error),
4343
+ isRetryable: isConnectionError,
4344
+ });
4184
4345
  throw error;
4185
4346
  }
4186
4347
  }
@@ -4195,7 +4356,7 @@ exports.OptionsContract = {
4195
4356
  * @returns The deleted OptionsContract or null.
4196
4357
  */
4197
4358
  async delete(props, globalClient) {
4198
- var _a, _b, _c, _d, _e;
4359
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
4199
4360
  // Maximum number of retries for database connection issues
4200
4361
  const MAX_RETRIES = 3;
4201
4362
  let retryCount = 0;
@@ -4239,21 +4400,58 @@ exports.OptionsContract = {
4239
4400
  }
4240
4401
  catch (error) {
4241
4402
  lastError = error;
4403
+ // Check for constraint violations FIRST - these are NEVER retryable
4404
+ // (e.g., foreign key constraints preventing deletion)
4405
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
4406
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
4407
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
4408
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
4409
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
4410
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
4411
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
4412
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
4413
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
4414
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
4415
+ if (isConstraintViolation) {
4416
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
4417
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneOptionsContract", {
4418
+ operation: 'deleteOneOptionsContract',
4419
+ model: 'OptionsContract',
4420
+ error: String(error),
4421
+ recordId: props.id,
4422
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
4423
+ errorCategory: 'CONSTRAINT_VIOLATION',
4424
+ isRetryable: false,
4425
+ });
4426
+ throw error;
4427
+ }
4242
4428
  // Check if this is a database connection error that we should retry
4243
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
4244
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
4245
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
4246
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
4247
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
4429
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
4430
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
4431
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
4432
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
4433
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
4248
4434
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4249
4435
  retryCount++;
4250
4436
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4251
- logger_1.logger.warn("Database connection error, retrying...");
4437
+ logger_1.logger.warn("Database connection error in deleteOneOptionsContract, retrying...", {
4438
+ operation: 'deleteOneOptionsContract',
4439
+ model: 'OptionsContract',
4440
+ attempt: retryCount,
4441
+ maxRetries: MAX_RETRIES,
4442
+ recordId: props.id,
4443
+ });
4252
4444
  await new Promise(resolve => setTimeout(resolve, delay));
4253
4445
  continue;
4254
4446
  }
4255
- // Log the error and rethrow
4256
- logger_1.logger.error("Database error occurred", { error: String(error) });
4447
+ // Log structured error details and rethrow
4448
+ logger_1.logger.error("Database delete operation failed", {
4449
+ operation: 'deleteOneOptionsContract',
4450
+ model: 'OptionsContract',
4451
+ error: String(error),
4452
+ recordId: props.id,
4453
+ isRetryable: isConnectionError,
4454
+ });
4257
4455
  throw error;
4258
4456
  }
4259
4457
  }
@@ -4323,12 +4521,22 @@ exports.OptionsContract = {
4323
4521
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4324
4522
  retryCount++;
4325
4523
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4326
- logger_1.logger.warn("Database connection error, retrying...");
4524
+ logger_1.logger.warn("Database connection error in getOptionsContract, retrying...", {
4525
+ operation: 'getOptionsContract',
4526
+ model: 'OptionsContract',
4527
+ attempt: retryCount,
4528
+ maxRetries: MAX_RETRIES,
4529
+ });
4327
4530
  await new Promise(resolve => setTimeout(resolve, delay));
4328
4531
  continue;
4329
4532
  }
4330
- // Log the error and rethrow
4331
- logger_1.logger.error("Database error occurred", { error: String(error) });
4533
+ // Log structured error details and rethrow
4534
+ logger_1.logger.error("Database get operation failed", {
4535
+ operation: 'getOptionsContract',
4536
+ model: 'OptionsContract',
4537
+ error: String(error),
4538
+ isRetryable: isConnectionError,
4539
+ });
4332
4540
  throw error;
4333
4541
  }
4334
4542
  }
@@ -4386,12 +4594,22 @@ exports.OptionsContract = {
4386
4594
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4387
4595
  retryCount++;
4388
4596
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4389
- logger_1.logger.warn("Database connection error, retrying...");
4597
+ logger_1.logger.warn("Database connection error in getAllOptionsContract, retrying...", {
4598
+ operation: 'getAllOptionsContract',
4599
+ model: 'OptionsContract',
4600
+ attempt: retryCount,
4601
+ maxRetries: MAX_RETRIES,
4602
+ });
4390
4603
  await new Promise(resolve => setTimeout(resolve, delay));
4391
4604
  continue;
4392
4605
  }
4393
- // Log the error and rethrow
4394
- logger_1.logger.error("Database error occurred", { error: String(error) });
4606
+ // Log structured error details and rethrow
4607
+ logger_1.logger.error("Database getAll operation failed", {
4608
+ operation: 'getAllOptionsContract',
4609
+ model: 'OptionsContract',
4610
+ error: String(error),
4611
+ isRetryable: isConnectionError,
4612
+ });
4395
4613
  throw error;
4396
4614
  }
4397
4615
  }
@@ -4468,12 +4686,22 @@ exports.OptionsContract = {
4468
4686
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4469
4687
  retryCount++;
4470
4688
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4471
- logger_1.logger.warn("Database connection error, retrying...");
4689
+ logger_1.logger.warn("Database connection error in findManyOptionsContract, retrying...", {
4690
+ operation: 'findManyOptionsContract',
4691
+ model: 'OptionsContract',
4692
+ attempt: retryCount,
4693
+ maxRetries: MAX_RETRIES,
4694
+ });
4472
4695
  await new Promise(resolve => setTimeout(resolve, delay));
4473
4696
  continue;
4474
4697
  }
4475
- // Log the error and rethrow
4476
- logger_1.logger.error("Database error occurred", { error: String(error) });
4698
+ // Log structured error details and rethrow
4699
+ logger_1.logger.error("Database findMany operation failed", {
4700
+ operation: 'findManyOptionsContract',
4701
+ model: 'OptionsContract',
4702
+ error: String(error),
4703
+ isRetryable: isConnectionError,
4704
+ });
4477
4705
  throw error;
4478
4706
  }
4479
4707
  }