@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
@@ -236,7 +236,7 @@ exports.OptionsTradeExecution = {
236
236
  * @returns The created OptionsTradeExecution or null.
237
237
  */
238
238
  async create(props, globalClient) {
239
- var _a, _b, _c, _d, _e;
239
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
240
240
  // Maximum number of retries for database connection issues
241
241
  const MAX_RETRIES = 3;
242
242
  let retryCount = 0;
@@ -526,21 +526,52 @@ exports.OptionsTradeExecution = {
526
526
  }
527
527
  catch (error) {
528
528
  lastError = error;
529
+ // Check for constraint violations FIRST - these are NEVER retryable
530
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
531
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
532
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
533
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
534
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
535
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
536
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
537
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
538
+ if (isConstraintViolation) {
539
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
540
+ logger_1.logger.error("Non-retryable constraint violation in createOneOptionsTradeExecution", {
541
+ operation: 'createOneOptionsTradeExecution',
542
+ model: 'OptionsTradeExecution',
543
+ error: String(error),
544
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
545
+ errorCategory: 'CONSTRAINT_VIOLATION',
546
+ isRetryable: false,
547
+ });
548
+ throw error;
549
+ }
529
550
  // Check if this is a database connection error that we should retry
530
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
531
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
532
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
533
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
534
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
551
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
552
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
553
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
554
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
555
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
535
556
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
536
557
  retryCount++;
537
558
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
538
- logger_1.logger.warn("Database connection error, retrying...");
559
+ logger_1.logger.warn("Database connection error in createOneOptionsTradeExecution, retrying...", {
560
+ operation: 'createOneOptionsTradeExecution',
561
+ model: 'OptionsTradeExecution',
562
+ attempt: retryCount,
563
+ maxRetries: MAX_RETRIES,
564
+ });
539
565
  await new Promise(resolve => setTimeout(resolve, delay));
540
566
  continue;
541
567
  }
542
- // Log the error and rethrow
543
- logger_1.logger.error("Database error occurred", { error: String(error) });
568
+ // Log structured error details and rethrow
569
+ logger_1.logger.error("Database create operation failed", {
570
+ operation: 'createOneOptionsTradeExecution',
571
+ model: 'OptionsTradeExecution',
572
+ error: String(error),
573
+ isRetryable: isConnectionError,
574
+ });
544
575
  throw error;
545
576
  }
546
577
  }
@@ -555,7 +586,7 @@ exports.OptionsTradeExecution = {
555
586
  * @returns The count of created records or null.
556
587
  */
557
588
  async createMany(props, globalClient) {
558
- var _a, _b, _c, _d, _e;
589
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
559
590
  // Maximum number of retries for database connection issues
560
591
  const MAX_RETRIES = 3;
561
592
  let retryCount = 0;
@@ -610,21 +641,52 @@ exports.OptionsTradeExecution = {
610
641
  }
611
642
  catch (error) {
612
643
  lastError = error;
644
+ // Check for constraint violations FIRST - these are NEVER retryable
645
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
646
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
647
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
648
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
649
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
650
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
651
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
652
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
653
+ if (isConstraintViolation) {
654
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
655
+ logger_1.logger.error("Non-retryable constraint violation in createManyOptionsTradeExecution", {
656
+ operation: 'createManyOptionsTradeExecution',
657
+ model: 'OptionsTradeExecution',
658
+ error: String(error),
659
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
660
+ errorCategory: 'CONSTRAINT_VIOLATION',
661
+ isRetryable: false,
662
+ });
663
+ throw error;
664
+ }
613
665
  // Check if this is a database connection error that we should retry
614
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
615
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
616
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
617
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
618
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
666
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
667
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
668
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
669
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
670
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
619
671
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
620
672
  retryCount++;
621
673
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
622
- logger_1.logger.warn("Database connection error, retrying...");
674
+ logger_1.logger.warn("Database connection error in createManyOptionsTradeExecution, retrying...", {
675
+ operation: 'createManyOptionsTradeExecution',
676
+ model: 'OptionsTradeExecution',
677
+ attempt: retryCount,
678
+ maxRetries: MAX_RETRIES,
679
+ });
623
680
  await new Promise(resolve => setTimeout(resolve, delay));
624
681
  continue;
625
682
  }
626
- // Log the error and rethrow
627
- logger_1.logger.error("Database error occurred", { error: String(error) });
683
+ // Log structured error details and rethrow
684
+ logger_1.logger.error("Database createMany operation failed", {
685
+ operation: 'createManyOptionsTradeExecution',
686
+ model: 'OptionsTradeExecution',
687
+ error: String(error),
688
+ isRetryable: isConnectionError,
689
+ });
628
690
  throw error;
629
691
  }
630
692
  }
@@ -639,7 +701,7 @@ exports.OptionsTradeExecution = {
639
701
  * @returns The updated OptionsTradeExecution or null.
640
702
  */
641
703
  async update(props, globalClient) {
642
- var _a, _b, _c, _d, _e;
704
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
643
705
  // Maximum number of retries for database connection issues
644
706
  const MAX_RETRIES = 3;
645
707
  let retryCount = 0;
@@ -1898,21 +1960,55 @@ exports.OptionsTradeExecution = {
1898
1960
  }
1899
1961
  catch (error) {
1900
1962
  lastError = error;
1963
+ // Check for constraint violations FIRST - these are NEVER retryable
1964
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
1965
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
1966
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
1967
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
1968
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
1969
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
1970
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
1971
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
1972
+ if (isConstraintViolation) {
1973
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
1974
+ logger_1.logger.error("Non-retryable constraint violation in updateOneOptionsTradeExecution", {
1975
+ operation: 'updateOneOptionsTradeExecution',
1976
+ model: 'OptionsTradeExecution',
1977
+ error: String(error),
1978
+ recordId: props.id,
1979
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1980
+ errorCategory: 'CONSTRAINT_VIOLATION',
1981
+ isRetryable: false,
1982
+ });
1983
+ throw error;
1984
+ }
1901
1985
  // Check if this is a database connection error that we should retry
1902
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
1903
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
1904
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
1905
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
1906
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
1986
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
1987
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
1988
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
1989
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
1990
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
1907
1991
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1908
1992
  retryCount++;
1909
1993
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1910
- logger_1.logger.warn("Database connection error, retrying...");
1994
+ logger_1.logger.warn("Database connection error in updateOneOptionsTradeExecution, retrying...", {
1995
+ operation: 'updateOneOptionsTradeExecution',
1996
+ model: 'OptionsTradeExecution',
1997
+ attempt: retryCount,
1998
+ maxRetries: MAX_RETRIES,
1999
+ recordId: props.id,
2000
+ });
1911
2001
  await new Promise(resolve => setTimeout(resolve, delay));
1912
2002
  continue;
1913
2003
  }
1914
- // Log the error and rethrow
1915
- logger_1.logger.error("Database error occurred", { error: String(error) });
2004
+ // Log structured error details and rethrow
2005
+ logger_1.logger.error("Database update operation failed", {
2006
+ operation: 'updateOneOptionsTradeExecution',
2007
+ model: 'OptionsTradeExecution',
2008
+ error: String(error),
2009
+ recordId: props.id,
2010
+ isRetryable: isConnectionError,
2011
+ });
1916
2012
  throw error;
1917
2013
  }
1918
2014
  }
@@ -1927,7 +2023,7 @@ exports.OptionsTradeExecution = {
1927
2023
  * @returns The updated OptionsTradeExecution or null.
1928
2024
  */
1929
2025
  async upsert(props, globalClient) {
1930
- var _a, _b, _c, _d, _e;
2026
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1931
2027
  // Maximum number of retries for database connection issues
1932
2028
  const MAX_RETRIES = 3;
1933
2029
  let retryCount = 0;
@@ -3425,21 +3521,55 @@ exports.OptionsTradeExecution = {
3425
3521
  }
3426
3522
  catch (error) {
3427
3523
  lastError = error;
3524
+ // Check for constraint violations FIRST - these are NEVER retryable
3525
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
3526
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
3527
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
3528
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
3529
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
3530
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
3531
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
3532
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
3533
+ if (isConstraintViolation) {
3534
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
3535
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneOptionsTradeExecution", {
3536
+ operation: 'upsertOneOptionsTradeExecution',
3537
+ model: 'OptionsTradeExecution',
3538
+ error: String(error),
3539
+ recordId: props.id,
3540
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
3541
+ errorCategory: 'CONSTRAINT_VIOLATION',
3542
+ isRetryable: false,
3543
+ });
3544
+ throw error;
3545
+ }
3428
3546
  // Check if this is a database connection error that we should retry
3429
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
3430
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
3431
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
3432
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
3433
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
3547
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
3548
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
3549
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
3550
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
3551
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
3434
3552
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
3435
3553
  retryCount++;
3436
3554
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
3437
- logger_1.logger.warn("Database connection error, retrying...");
3555
+ logger_1.logger.warn("Database connection error in upsertOneOptionsTradeExecution, retrying...", {
3556
+ operation: 'upsertOneOptionsTradeExecution',
3557
+ model: 'OptionsTradeExecution',
3558
+ attempt: retryCount,
3559
+ maxRetries: MAX_RETRIES,
3560
+ recordId: props.id,
3561
+ });
3438
3562
  await new Promise(resolve => setTimeout(resolve, delay));
3439
3563
  continue;
3440
3564
  }
3441
- // Log the error and rethrow
3442
- logger_1.logger.error("Database error occurred", { error: String(error) });
3565
+ // Log structured error details and rethrow
3566
+ logger_1.logger.error("Database upsert operation failed", {
3567
+ operation: 'upsertOneOptionsTradeExecution',
3568
+ model: 'OptionsTradeExecution',
3569
+ error: String(error),
3570
+ recordId: props.id,
3571
+ isRetryable: isConnectionError,
3572
+ });
3443
3573
  throw error;
3444
3574
  }
3445
3575
  }
@@ -3454,7 +3584,7 @@ exports.OptionsTradeExecution = {
3454
3584
  * @returns The count of created records or null.
3455
3585
  */
3456
3586
  async updateMany(props, globalClient) {
3457
- var _a, _b, _c, _d, _e;
3587
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
3458
3588
  // Maximum number of retries for database connection issues
3459
3589
  const MAX_RETRIES = 3;
3460
3590
  let retryCount = 0;
@@ -4713,21 +4843,52 @@ exports.OptionsTradeExecution = {
4713
4843
  }
4714
4844
  catch (error) {
4715
4845
  lastError = error;
4846
+ // Check for constraint violations FIRST - these are NEVER retryable
4847
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
4848
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
4849
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
4850
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
4851
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
4852
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
4853
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
4854
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
4855
+ if (isConstraintViolation) {
4856
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
4857
+ logger_1.logger.error("Non-retryable constraint violation in updateManyOptionsTradeExecution", {
4858
+ operation: 'updateManyOptionsTradeExecution',
4859
+ model: 'OptionsTradeExecution',
4860
+ error: String(error),
4861
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
4862
+ errorCategory: 'CONSTRAINT_VIOLATION',
4863
+ isRetryable: false,
4864
+ });
4865
+ throw error;
4866
+ }
4716
4867
  // Check if this is a database connection error that we should retry
4717
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
4718
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
4719
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
4720
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
4721
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
4868
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
4869
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
4870
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
4871
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
4872
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
4722
4873
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4723
4874
  retryCount++;
4724
4875
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4725
- logger_1.logger.warn("Database connection error, retrying...");
4876
+ logger_1.logger.warn("Database connection error in updateManyOptionsTradeExecution, retrying...", {
4877
+ operation: 'updateManyOptionsTradeExecution',
4878
+ model: 'OptionsTradeExecution',
4879
+ attempt: retryCount,
4880
+ maxRetries: MAX_RETRIES,
4881
+ });
4726
4882
  await new Promise(resolve => setTimeout(resolve, delay));
4727
4883
  continue;
4728
4884
  }
4729
- // Log the error and rethrow
4730
- logger_1.logger.error("Database error occurred", { error: String(error) });
4885
+ // Log structured error details and rethrow
4886
+ logger_1.logger.error("Database updateMany operation failed", {
4887
+ operation: 'updateManyOptionsTradeExecution',
4888
+ model: 'OptionsTradeExecution',
4889
+ error: String(error),
4890
+ isRetryable: isConnectionError,
4891
+ });
4731
4892
  throw error;
4732
4893
  }
4733
4894
  }
@@ -4742,7 +4903,7 @@ exports.OptionsTradeExecution = {
4742
4903
  * @returns The deleted OptionsTradeExecution or null.
4743
4904
  */
4744
4905
  async delete(props, globalClient) {
4745
- var _a, _b, _c, _d, _e;
4906
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
4746
4907
  // Maximum number of retries for database connection issues
4747
4908
  const MAX_RETRIES = 3;
4748
4909
  let retryCount = 0;
@@ -4786,21 +4947,58 @@ exports.OptionsTradeExecution = {
4786
4947
  }
4787
4948
  catch (error) {
4788
4949
  lastError = error;
4950
+ // Check for constraint violations FIRST - these are NEVER retryable
4951
+ // (e.g., foreign key constraints preventing deletion)
4952
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
4953
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
4954
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
4955
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
4956
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
4957
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
4958
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
4959
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
4960
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
4961
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
4962
+ if (isConstraintViolation) {
4963
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
4964
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneOptionsTradeExecution", {
4965
+ operation: 'deleteOneOptionsTradeExecution',
4966
+ model: 'OptionsTradeExecution',
4967
+ error: String(error),
4968
+ recordId: props.id,
4969
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
4970
+ errorCategory: 'CONSTRAINT_VIOLATION',
4971
+ isRetryable: false,
4972
+ });
4973
+ throw error;
4974
+ }
4789
4975
  // Check if this is a database connection error that we should retry
4790
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
4791
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
4792
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
4793
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
4794
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
4976
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
4977
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
4978
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
4979
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
4980
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
4795
4981
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4796
4982
  retryCount++;
4797
4983
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4798
- logger_1.logger.warn("Database connection error, retrying...");
4984
+ logger_1.logger.warn("Database connection error in deleteOneOptionsTradeExecution, retrying...", {
4985
+ operation: 'deleteOneOptionsTradeExecution',
4986
+ model: 'OptionsTradeExecution',
4987
+ attempt: retryCount,
4988
+ maxRetries: MAX_RETRIES,
4989
+ recordId: props.id,
4990
+ });
4799
4991
  await new Promise(resolve => setTimeout(resolve, delay));
4800
4992
  continue;
4801
4993
  }
4802
- // Log the error and rethrow
4803
- logger_1.logger.error("Database error occurred", { error: String(error) });
4994
+ // Log structured error details and rethrow
4995
+ logger_1.logger.error("Database delete operation failed", {
4996
+ operation: 'deleteOneOptionsTradeExecution',
4997
+ model: 'OptionsTradeExecution',
4998
+ error: String(error),
4999
+ recordId: props.id,
5000
+ isRetryable: isConnectionError,
5001
+ });
4804
5002
  throw error;
4805
5003
  }
4806
5004
  }
@@ -4879,12 +5077,22 @@ exports.OptionsTradeExecution = {
4879
5077
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4880
5078
  retryCount++;
4881
5079
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4882
- logger_1.logger.warn("Database connection error, retrying...");
5080
+ logger_1.logger.warn("Database connection error in getOptionsTradeExecution, retrying...", {
5081
+ operation: 'getOptionsTradeExecution',
5082
+ model: 'OptionsTradeExecution',
5083
+ attempt: retryCount,
5084
+ maxRetries: MAX_RETRIES,
5085
+ });
4883
5086
  await new Promise(resolve => setTimeout(resolve, delay));
4884
5087
  continue;
4885
5088
  }
4886
- // Log the error and rethrow
4887
- logger_1.logger.error("Database error occurred", { error: String(error) });
5089
+ // Log structured error details and rethrow
5090
+ logger_1.logger.error("Database get operation failed", {
5091
+ operation: 'getOptionsTradeExecution',
5092
+ model: 'OptionsTradeExecution',
5093
+ error: String(error),
5094
+ isRetryable: isConnectionError,
5095
+ });
4888
5096
  throw error;
4889
5097
  }
4890
5098
  }
@@ -4942,12 +5150,22 @@ exports.OptionsTradeExecution = {
4942
5150
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4943
5151
  retryCount++;
4944
5152
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4945
- logger_1.logger.warn("Database connection error, retrying...");
5153
+ logger_1.logger.warn("Database connection error in getAllOptionsTradeExecution, retrying...", {
5154
+ operation: 'getAllOptionsTradeExecution',
5155
+ model: 'OptionsTradeExecution',
5156
+ attempt: retryCount,
5157
+ maxRetries: MAX_RETRIES,
5158
+ });
4946
5159
  await new Promise(resolve => setTimeout(resolve, delay));
4947
5160
  continue;
4948
5161
  }
4949
- // Log the error and rethrow
4950
- logger_1.logger.error("Database error occurred", { error: String(error) });
5162
+ // Log structured error details and rethrow
5163
+ logger_1.logger.error("Database getAll operation failed", {
5164
+ operation: 'getAllOptionsTradeExecution',
5165
+ model: 'OptionsTradeExecution',
5166
+ error: String(error),
5167
+ isRetryable: isConnectionError,
5168
+ });
4951
5169
  throw error;
4952
5170
  }
4953
5171
  }
@@ -5033,12 +5251,22 @@ exports.OptionsTradeExecution = {
5033
5251
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
5034
5252
  retryCount++;
5035
5253
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
5036
- logger_1.logger.warn("Database connection error, retrying...");
5254
+ logger_1.logger.warn("Database connection error in findManyOptionsTradeExecution, retrying...", {
5255
+ operation: 'findManyOptionsTradeExecution',
5256
+ model: 'OptionsTradeExecution',
5257
+ attempt: retryCount,
5258
+ maxRetries: MAX_RETRIES,
5259
+ });
5037
5260
  await new Promise(resolve => setTimeout(resolve, delay));
5038
5261
  continue;
5039
5262
  }
5040
- // Log the error and rethrow
5041
- logger_1.logger.error("Database error occurred", { error: String(error) });
5263
+ // Log structured error details and rethrow
5264
+ logger_1.logger.error("Database findMany operation failed", {
5265
+ operation: 'findManyOptionsTradeExecution',
5266
+ model: 'OptionsTradeExecution',
5267
+ error: String(error),
5268
+ isRetryable: isConnectionError,
5269
+ });
5042
5270
  throw error;
5043
5271
  }
5044
5272
  }