@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
@@ -232,7 +232,7 @@ exports.OptionsPosition = {
232
232
  * @returns The created OptionsPosition or null.
233
233
  */
234
234
  async create(props, globalClient) {
235
- var _a, _b, _c, _d, _e;
235
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
236
236
  // Maximum number of retries for database connection issues
237
237
  const MAX_RETRIES = 3;
238
238
  let retryCount = 0;
@@ -523,21 +523,52 @@ exports.OptionsPosition = {
523
523
  }
524
524
  catch (error) {
525
525
  lastError = error;
526
+ // Check for constraint violations FIRST - these are NEVER retryable
527
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
528
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
529
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
530
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
531
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
532
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
533
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
534
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
535
+ if (isConstraintViolation) {
536
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
537
+ logger_1.logger.error("Non-retryable constraint violation in createOneOptionsPosition", {
538
+ operation: 'createOneOptionsPosition',
539
+ model: 'OptionsPosition',
540
+ error: String(error),
541
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
542
+ errorCategory: 'CONSTRAINT_VIOLATION',
543
+ isRetryable: false,
544
+ });
545
+ throw error;
546
+ }
526
547
  // Check if this is a database connection error that we should retry
527
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
528
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
529
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
530
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
531
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
548
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
549
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
550
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
551
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
552
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
532
553
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
533
554
  retryCount++;
534
555
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
535
- logger_1.logger.warn("Database connection error, retrying...");
556
+ logger_1.logger.warn("Database connection error in createOneOptionsPosition, retrying...", {
557
+ operation: 'createOneOptionsPosition',
558
+ model: 'OptionsPosition',
559
+ attempt: retryCount,
560
+ maxRetries: MAX_RETRIES,
561
+ });
536
562
  await new Promise(resolve => setTimeout(resolve, delay));
537
563
  continue;
538
564
  }
539
- // Log the error and rethrow
540
- logger_1.logger.error("Database error occurred", { error: String(error) });
565
+ // Log structured error details and rethrow
566
+ logger_1.logger.error("Database create operation failed", {
567
+ operation: 'createOneOptionsPosition',
568
+ model: 'OptionsPosition',
569
+ error: String(error),
570
+ isRetryable: isConnectionError,
571
+ });
541
572
  throw error;
542
573
  }
543
574
  }
@@ -552,7 +583,7 @@ exports.OptionsPosition = {
552
583
  * @returns The count of created records or null.
553
584
  */
554
585
  async createMany(props, globalClient) {
555
- var _a, _b, _c, _d, _e;
586
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
556
587
  // Maximum number of retries for database connection issues
557
588
  const MAX_RETRIES = 3;
558
589
  let retryCount = 0;
@@ -607,21 +638,52 @@ exports.OptionsPosition = {
607
638
  }
608
639
  catch (error) {
609
640
  lastError = error;
641
+ // Check for constraint violations FIRST - these are NEVER retryable
642
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
643
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
644
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
645
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
646
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
647
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
648
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
649
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
650
+ if (isConstraintViolation) {
651
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
652
+ logger_1.logger.error("Non-retryable constraint violation in createManyOptionsPosition", {
653
+ operation: 'createManyOptionsPosition',
654
+ model: 'OptionsPosition',
655
+ error: String(error),
656
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
657
+ errorCategory: 'CONSTRAINT_VIOLATION',
658
+ isRetryable: false,
659
+ });
660
+ throw error;
661
+ }
610
662
  // Check if this is a database connection error that we should retry
611
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
612
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
613
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
614
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
615
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
663
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
664
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
665
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
666
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
667
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
616
668
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
617
669
  retryCount++;
618
670
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
619
- logger_1.logger.warn("Database connection error, retrying...");
671
+ logger_1.logger.warn("Database connection error in createManyOptionsPosition, retrying...", {
672
+ operation: 'createManyOptionsPosition',
673
+ model: 'OptionsPosition',
674
+ attempt: retryCount,
675
+ maxRetries: MAX_RETRIES,
676
+ });
620
677
  await new Promise(resolve => setTimeout(resolve, delay));
621
678
  continue;
622
679
  }
623
- // Log the error and rethrow
624
- logger_1.logger.error("Database error occurred", { error: String(error) });
680
+ // Log structured error details and rethrow
681
+ logger_1.logger.error("Database createMany operation failed", {
682
+ operation: 'createManyOptionsPosition',
683
+ model: 'OptionsPosition',
684
+ error: String(error),
685
+ isRetryable: isConnectionError,
686
+ });
625
687
  throw error;
626
688
  }
627
689
  }
@@ -636,7 +698,7 @@ exports.OptionsPosition = {
636
698
  * @returns The updated OptionsPosition or null.
637
699
  */
638
700
  async update(props, globalClient) {
639
- var _a, _b, _c, _d, _e;
701
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
640
702
  // Maximum number of retries for database connection issues
641
703
  const MAX_RETRIES = 3;
642
704
  let retryCount = 0;
@@ -1889,21 +1951,55 @@ exports.OptionsPosition = {
1889
1951
  }
1890
1952
  catch (error) {
1891
1953
  lastError = error;
1954
+ // Check for constraint violations FIRST - these are NEVER retryable
1955
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
1956
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
1957
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
1958
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
1959
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
1960
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
1961
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
1962
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
1963
+ if (isConstraintViolation) {
1964
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
1965
+ logger_1.logger.error("Non-retryable constraint violation in updateOneOptionsPosition", {
1966
+ operation: 'updateOneOptionsPosition',
1967
+ model: 'OptionsPosition',
1968
+ error: String(error),
1969
+ recordId: props.id,
1970
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1971
+ errorCategory: 'CONSTRAINT_VIOLATION',
1972
+ isRetryable: false,
1973
+ });
1974
+ throw error;
1975
+ }
1892
1976
  // Check if this is a database connection error that we should retry
1893
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
1894
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
1895
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
1896
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
1897
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
1977
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
1978
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
1979
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
1980
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
1981
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
1898
1982
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1899
1983
  retryCount++;
1900
1984
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1901
- logger_1.logger.warn("Database connection error, retrying...");
1985
+ logger_1.logger.warn("Database connection error in updateOneOptionsPosition, retrying...", {
1986
+ operation: 'updateOneOptionsPosition',
1987
+ model: 'OptionsPosition',
1988
+ attempt: retryCount,
1989
+ maxRetries: MAX_RETRIES,
1990
+ recordId: props.id,
1991
+ });
1902
1992
  await new Promise(resolve => setTimeout(resolve, delay));
1903
1993
  continue;
1904
1994
  }
1905
- // Log the error and rethrow
1906
- logger_1.logger.error("Database error occurred", { error: String(error) });
1995
+ // Log structured error details and rethrow
1996
+ logger_1.logger.error("Database update operation failed", {
1997
+ operation: 'updateOneOptionsPosition',
1998
+ model: 'OptionsPosition',
1999
+ error: String(error),
2000
+ recordId: props.id,
2001
+ isRetryable: isConnectionError,
2002
+ });
1907
2003
  throw error;
1908
2004
  }
1909
2005
  }
@@ -1918,7 +2014,7 @@ exports.OptionsPosition = {
1918
2014
  * @returns The updated OptionsPosition or null.
1919
2015
  */
1920
2016
  async upsert(props, globalClient) {
1921
- var _a, _b, _c, _d, _e;
2017
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1922
2018
  // Maximum number of retries for database connection issues
1923
2019
  const MAX_RETRIES = 3;
1924
2020
  let retryCount = 0;
@@ -3411,21 +3507,55 @@ exports.OptionsPosition = {
3411
3507
  }
3412
3508
  catch (error) {
3413
3509
  lastError = error;
3510
+ // Check for constraint violations FIRST - these are NEVER retryable
3511
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
3512
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
3513
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
3514
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
3515
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
3516
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
3517
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
3518
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
3519
+ if (isConstraintViolation) {
3520
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
3521
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneOptionsPosition", {
3522
+ operation: 'upsertOneOptionsPosition',
3523
+ model: 'OptionsPosition',
3524
+ error: String(error),
3525
+ recordId: props.id,
3526
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
3527
+ errorCategory: 'CONSTRAINT_VIOLATION',
3528
+ isRetryable: false,
3529
+ });
3530
+ throw error;
3531
+ }
3414
3532
  // Check if this is a database connection error that we should retry
3415
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
3416
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
3417
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
3418
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
3419
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
3533
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
3534
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
3535
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
3536
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
3537
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
3420
3538
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
3421
3539
  retryCount++;
3422
3540
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
3423
- logger_1.logger.warn("Database connection error, retrying...");
3541
+ logger_1.logger.warn("Database connection error in upsertOneOptionsPosition, retrying...", {
3542
+ operation: 'upsertOneOptionsPosition',
3543
+ model: 'OptionsPosition',
3544
+ attempt: retryCount,
3545
+ maxRetries: MAX_RETRIES,
3546
+ recordId: props.id,
3547
+ });
3424
3548
  await new Promise(resolve => setTimeout(resolve, delay));
3425
3549
  continue;
3426
3550
  }
3427
- // Log the error and rethrow
3428
- logger_1.logger.error("Database error occurred", { error: String(error) });
3551
+ // Log structured error details and rethrow
3552
+ logger_1.logger.error("Database upsert operation failed", {
3553
+ operation: 'upsertOneOptionsPosition',
3554
+ model: 'OptionsPosition',
3555
+ error: String(error),
3556
+ recordId: props.id,
3557
+ isRetryable: isConnectionError,
3558
+ });
3429
3559
  throw error;
3430
3560
  }
3431
3561
  }
@@ -3440,7 +3570,7 @@ exports.OptionsPosition = {
3440
3570
  * @returns The count of created records or null.
3441
3571
  */
3442
3572
  async updateMany(props, globalClient) {
3443
- var _a, _b, _c, _d, _e;
3573
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
3444
3574
  // Maximum number of retries for database connection issues
3445
3575
  const MAX_RETRIES = 3;
3446
3576
  let retryCount = 0;
@@ -4693,21 +4823,52 @@ exports.OptionsPosition = {
4693
4823
  }
4694
4824
  catch (error) {
4695
4825
  lastError = error;
4826
+ // Check for constraint violations FIRST - these are NEVER retryable
4827
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
4828
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
4829
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
4830
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
4831
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
4832
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
4833
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
4834
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
4835
+ if (isConstraintViolation) {
4836
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
4837
+ logger_1.logger.error("Non-retryable constraint violation in updateManyOptionsPosition", {
4838
+ operation: 'updateManyOptionsPosition',
4839
+ model: 'OptionsPosition',
4840
+ error: String(error),
4841
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
4842
+ errorCategory: 'CONSTRAINT_VIOLATION',
4843
+ isRetryable: false,
4844
+ });
4845
+ throw error;
4846
+ }
4696
4847
  // Check if this is a database connection error that we should retry
4697
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
4698
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
4699
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
4700
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
4701
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
4848
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
4849
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
4850
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
4851
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
4852
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
4702
4853
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4703
4854
  retryCount++;
4704
4855
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4705
- logger_1.logger.warn("Database connection error, retrying...");
4856
+ logger_1.logger.warn("Database connection error in updateManyOptionsPosition, retrying...", {
4857
+ operation: 'updateManyOptionsPosition',
4858
+ model: 'OptionsPosition',
4859
+ attempt: retryCount,
4860
+ maxRetries: MAX_RETRIES,
4861
+ });
4706
4862
  await new Promise(resolve => setTimeout(resolve, delay));
4707
4863
  continue;
4708
4864
  }
4709
- // Log the error and rethrow
4710
- logger_1.logger.error("Database error occurred", { error: String(error) });
4865
+ // Log structured error details and rethrow
4866
+ logger_1.logger.error("Database updateMany operation failed", {
4867
+ operation: 'updateManyOptionsPosition',
4868
+ model: 'OptionsPosition',
4869
+ error: String(error),
4870
+ isRetryable: isConnectionError,
4871
+ });
4711
4872
  throw error;
4712
4873
  }
4713
4874
  }
@@ -4722,7 +4883,7 @@ exports.OptionsPosition = {
4722
4883
  * @returns The deleted OptionsPosition or null.
4723
4884
  */
4724
4885
  async delete(props, globalClient) {
4725
- var _a, _b, _c, _d, _e;
4886
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
4726
4887
  // Maximum number of retries for database connection issues
4727
4888
  const MAX_RETRIES = 3;
4728
4889
  let retryCount = 0;
@@ -4766,21 +4927,58 @@ exports.OptionsPosition = {
4766
4927
  }
4767
4928
  catch (error) {
4768
4929
  lastError = error;
4930
+ // Check for constraint violations FIRST - these are NEVER retryable
4931
+ // (e.g., foreign key constraints preventing deletion)
4932
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
4933
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
4934
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
4935
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
4936
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
4937
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
4938
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
4939
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
4940
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
4941
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
4942
+ if (isConstraintViolation) {
4943
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
4944
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneOptionsPosition", {
4945
+ operation: 'deleteOneOptionsPosition',
4946
+ model: 'OptionsPosition',
4947
+ error: String(error),
4948
+ recordId: props.id,
4949
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
4950
+ errorCategory: 'CONSTRAINT_VIOLATION',
4951
+ isRetryable: false,
4952
+ });
4953
+ throw error;
4954
+ }
4769
4955
  // Check if this is a database connection error that we should retry
4770
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
4771
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
4772
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
4773
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
4774
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
4956
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
4957
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
4958
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
4959
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
4960
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
4775
4961
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4776
4962
  retryCount++;
4777
4963
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4778
- logger_1.logger.warn("Database connection error, retrying...");
4964
+ logger_1.logger.warn("Database connection error in deleteOneOptionsPosition, retrying...", {
4965
+ operation: 'deleteOneOptionsPosition',
4966
+ model: 'OptionsPosition',
4967
+ attempt: retryCount,
4968
+ maxRetries: MAX_RETRIES,
4969
+ recordId: props.id,
4970
+ });
4779
4971
  await new Promise(resolve => setTimeout(resolve, delay));
4780
4972
  continue;
4781
4973
  }
4782
- // Log the error and rethrow
4783
- logger_1.logger.error("Database error occurred", { error: String(error) });
4974
+ // Log structured error details and rethrow
4975
+ logger_1.logger.error("Database delete operation failed", {
4976
+ operation: 'deleteOneOptionsPosition',
4977
+ model: 'OptionsPosition',
4978
+ error: String(error),
4979
+ recordId: props.id,
4980
+ isRetryable: isConnectionError,
4981
+ });
4784
4982
  throw error;
4785
4983
  }
4786
4984
  }
@@ -4853,12 +5051,22 @@ exports.OptionsPosition = {
4853
5051
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4854
5052
  retryCount++;
4855
5053
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4856
- logger_1.logger.warn("Database connection error, retrying...");
5054
+ logger_1.logger.warn("Database connection error in getOptionsPosition, retrying...", {
5055
+ operation: 'getOptionsPosition',
5056
+ model: 'OptionsPosition',
5057
+ attempt: retryCount,
5058
+ maxRetries: MAX_RETRIES,
5059
+ });
4857
5060
  await new Promise(resolve => setTimeout(resolve, delay));
4858
5061
  continue;
4859
5062
  }
4860
- // Log the error and rethrow
4861
- logger_1.logger.error("Database error occurred", { error: String(error) });
5063
+ // Log structured error details and rethrow
5064
+ logger_1.logger.error("Database get operation failed", {
5065
+ operation: 'getOptionsPosition',
5066
+ model: 'OptionsPosition',
5067
+ error: String(error),
5068
+ isRetryable: isConnectionError,
5069
+ });
4862
5070
  throw error;
4863
5071
  }
4864
5072
  }
@@ -4916,12 +5124,22 @@ exports.OptionsPosition = {
4916
5124
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4917
5125
  retryCount++;
4918
5126
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4919
- logger_1.logger.warn("Database connection error, retrying...");
5127
+ logger_1.logger.warn("Database connection error in getAllOptionsPosition, retrying...", {
5128
+ operation: 'getAllOptionsPosition',
5129
+ model: 'OptionsPosition',
5130
+ attempt: retryCount,
5131
+ maxRetries: MAX_RETRIES,
5132
+ });
4920
5133
  await new Promise(resolve => setTimeout(resolve, delay));
4921
5134
  continue;
4922
5135
  }
4923
- // Log the error and rethrow
4924
- logger_1.logger.error("Database error occurred", { error: String(error) });
5136
+ // Log structured error details and rethrow
5137
+ logger_1.logger.error("Database getAll operation failed", {
5138
+ operation: 'getAllOptionsPosition',
5139
+ model: 'OptionsPosition',
5140
+ error: String(error),
5141
+ isRetryable: isConnectionError,
5142
+ });
4925
5143
  throw error;
4926
5144
  }
4927
5145
  }
@@ -5001,12 +5219,22 @@ exports.OptionsPosition = {
5001
5219
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
5002
5220
  retryCount++;
5003
5221
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
5004
- logger_1.logger.warn("Database connection error, retrying...");
5222
+ logger_1.logger.warn("Database connection error in findManyOptionsPosition, retrying...", {
5223
+ operation: 'findManyOptionsPosition',
5224
+ model: 'OptionsPosition',
5225
+ attempt: retryCount,
5226
+ maxRetries: MAX_RETRIES,
5227
+ });
5005
5228
  await new Promise(resolve => setTimeout(resolve, delay));
5006
5229
  continue;
5007
5230
  }
5008
- // Log the error and rethrow
5009
- logger_1.logger.error("Database error occurred", { error: String(error) });
5231
+ // Log structured error details and rethrow
5232
+ logger_1.logger.error("Database findMany operation failed", {
5233
+ operation: 'findManyOptionsPosition',
5234
+ model: 'OptionsPosition',
5235
+ error: String(error),
5236
+ isRetryable: isConnectionError,
5237
+ });
5010
5238
  throw error;
5011
5239
  }
5012
5240
  }