@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
package/Customer.cjs CHANGED
@@ -208,7 +208,7 @@ exports.Customer = {
208
208
  * @returns The created Customer or null.
209
209
  */
210
210
  async create(props, globalClient) {
211
- var _a, _b, _c, _d, _e;
211
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
212
212
  // Maximum number of retries for database connection issues
213
213
  const MAX_RETRIES = 3;
214
214
  let retryCount = 0;
@@ -565,21 +565,52 @@ exports.Customer = {
565
565
  }
566
566
  catch (error) {
567
567
  lastError = error;
568
+ // Check for constraint violations FIRST - these are NEVER retryable
569
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
570
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
571
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
572
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
573
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
574
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
575
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
576
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
577
+ if (isConstraintViolation) {
578
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
579
+ logger_1.logger.error("Non-retryable constraint violation in createOneCustomer", {
580
+ operation: 'createOneCustomer',
581
+ model: 'Customer',
582
+ error: String(error),
583
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
584
+ errorCategory: 'CONSTRAINT_VIOLATION',
585
+ isRetryable: false,
586
+ });
587
+ throw error;
588
+ }
568
589
  // Check if this is a database connection error that we should retry
569
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
570
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
571
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
572
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
573
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
590
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
591
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
592
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
593
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
594
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
574
595
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
575
596
  retryCount++;
576
597
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
577
- logger_1.logger.warn("Database connection error, retrying...");
598
+ logger_1.logger.warn("Database connection error in createOneCustomer, retrying...", {
599
+ operation: 'createOneCustomer',
600
+ model: 'Customer',
601
+ attempt: retryCount,
602
+ maxRetries: MAX_RETRIES,
603
+ });
578
604
  await new Promise(resolve => setTimeout(resolve, delay));
579
605
  continue;
580
606
  }
581
- // Log the error and rethrow
582
- logger_1.logger.error("Database error occurred", { error: String(error) });
607
+ // Log structured error details and rethrow
608
+ logger_1.logger.error("Database create operation failed", {
609
+ operation: 'createOneCustomer',
610
+ model: 'Customer',
611
+ error: String(error),
612
+ isRetryable: isConnectionError,
613
+ });
583
614
  throw error;
584
615
  }
585
616
  }
@@ -594,7 +625,7 @@ exports.Customer = {
594
625
  * @returns The count of created records or null.
595
626
  */
596
627
  async createMany(props, globalClient) {
597
- var _a, _b, _c, _d, _e;
628
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
598
629
  // Maximum number of retries for database connection issues
599
630
  const MAX_RETRIES = 3;
600
631
  let retryCount = 0;
@@ -644,21 +675,52 @@ exports.Customer = {
644
675
  }
645
676
  catch (error) {
646
677
  lastError = error;
678
+ // Check for constraint violations FIRST - these are NEVER retryable
679
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
680
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
681
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
682
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
683
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
684
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
685
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
686
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
687
+ if (isConstraintViolation) {
688
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
689
+ logger_1.logger.error("Non-retryable constraint violation in createManyCustomer", {
690
+ operation: 'createManyCustomer',
691
+ model: 'Customer',
692
+ error: String(error),
693
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
694
+ errorCategory: 'CONSTRAINT_VIOLATION',
695
+ isRetryable: false,
696
+ });
697
+ throw error;
698
+ }
647
699
  // Check if this is a database connection error that we should retry
648
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
649
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
650
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
651
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
652
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
700
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
701
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
702
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
703
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
704
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
653
705
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
654
706
  retryCount++;
655
707
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
656
- logger_1.logger.warn("Database connection error, retrying...");
708
+ logger_1.logger.warn("Database connection error in createManyCustomer, retrying...", {
709
+ operation: 'createManyCustomer',
710
+ model: 'Customer',
711
+ attempt: retryCount,
712
+ maxRetries: MAX_RETRIES,
713
+ });
657
714
  await new Promise(resolve => setTimeout(resolve, delay));
658
715
  continue;
659
716
  }
660
- // Log the error and rethrow
661
- logger_1.logger.error("Database error occurred", { error: String(error) });
717
+ // Log structured error details and rethrow
718
+ logger_1.logger.error("Database createMany operation failed", {
719
+ operation: 'createManyCustomer',
720
+ model: 'Customer',
721
+ error: String(error),
722
+ isRetryable: isConnectionError,
723
+ });
662
724
  throw error;
663
725
  }
664
726
  }
@@ -673,7 +735,7 @@ exports.Customer = {
673
735
  * @returns The updated Customer or null.
674
736
  */
675
737
  async update(props, globalClient) {
676
- var _a, _b, _c, _d, _e;
738
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
677
739
  // Maximum number of retries for database connection issues
678
740
  const MAX_RETRIES = 3;
679
741
  let retryCount = 0;
@@ -1786,21 +1848,55 @@ exports.Customer = {
1786
1848
  }
1787
1849
  catch (error) {
1788
1850
  lastError = error;
1851
+ // Check for constraint violations FIRST - these are NEVER retryable
1852
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
1853
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
1854
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
1855
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
1856
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
1857
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
1858
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
1859
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
1860
+ if (isConstraintViolation) {
1861
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
1862
+ logger_1.logger.error("Non-retryable constraint violation in updateOneCustomer", {
1863
+ operation: 'updateOneCustomer',
1864
+ model: 'Customer',
1865
+ error: String(error),
1866
+ recordId: props.id,
1867
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1868
+ errorCategory: 'CONSTRAINT_VIOLATION',
1869
+ isRetryable: false,
1870
+ });
1871
+ throw error;
1872
+ }
1789
1873
  // Check if this is a database connection error that we should retry
1790
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
1791
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
1792
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
1793
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
1794
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
1874
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
1875
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
1876
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
1877
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
1878
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
1795
1879
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1796
1880
  retryCount++;
1797
1881
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1798
- logger_1.logger.warn("Database connection error, retrying...");
1882
+ logger_1.logger.warn("Database connection error in updateOneCustomer, retrying...", {
1883
+ operation: 'updateOneCustomer',
1884
+ model: 'Customer',
1885
+ attempt: retryCount,
1886
+ maxRetries: MAX_RETRIES,
1887
+ recordId: props.id,
1888
+ });
1799
1889
  await new Promise(resolve => setTimeout(resolve, delay));
1800
1890
  continue;
1801
1891
  }
1802
- // Log the error and rethrow
1803
- logger_1.logger.error("Database error occurred", { error: String(error) });
1892
+ // Log structured error details and rethrow
1893
+ logger_1.logger.error("Database update operation failed", {
1894
+ operation: 'updateOneCustomer',
1895
+ model: 'Customer',
1896
+ error: String(error),
1897
+ recordId: props.id,
1898
+ isRetryable: isConnectionError,
1899
+ });
1804
1900
  throw error;
1805
1901
  }
1806
1902
  }
@@ -1815,7 +1911,7 @@ exports.Customer = {
1815
1911
  * @returns The updated Customer or null.
1816
1912
  */
1817
1913
  async upsert(props, globalClient) {
1818
- var _a, _b, _c, _d, _e;
1914
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1819
1915
  // Maximum number of retries for database connection issues
1820
1916
  const MAX_RETRIES = 3;
1821
1917
  let retryCount = 0;
@@ -3237,21 +3333,55 @@ exports.Customer = {
3237
3333
  }
3238
3334
  catch (error) {
3239
3335
  lastError = error;
3336
+ // Check for constraint violations FIRST - these are NEVER retryable
3337
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
3338
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
3339
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
3340
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
3341
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
3342
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
3343
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
3344
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
3345
+ if (isConstraintViolation) {
3346
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
3347
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneCustomer", {
3348
+ operation: 'upsertOneCustomer',
3349
+ model: 'Customer',
3350
+ error: String(error),
3351
+ recordId: props.id,
3352
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
3353
+ errorCategory: 'CONSTRAINT_VIOLATION',
3354
+ isRetryable: false,
3355
+ });
3356
+ throw error;
3357
+ }
3240
3358
  // Check if this is a database connection error that we should retry
3241
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
3242
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
3243
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
3244
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
3245
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
3359
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
3360
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
3361
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
3362
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
3363
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
3246
3364
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
3247
3365
  retryCount++;
3248
3366
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
3249
- logger_1.logger.warn("Database connection error, retrying...");
3367
+ logger_1.logger.warn("Database connection error in upsertOneCustomer, retrying...", {
3368
+ operation: 'upsertOneCustomer',
3369
+ model: 'Customer',
3370
+ attempt: retryCount,
3371
+ maxRetries: MAX_RETRIES,
3372
+ recordId: props.id,
3373
+ });
3250
3374
  await new Promise(resolve => setTimeout(resolve, delay));
3251
3375
  continue;
3252
3376
  }
3253
- // Log the error and rethrow
3254
- logger_1.logger.error("Database error occurred", { error: String(error) });
3377
+ // Log structured error details and rethrow
3378
+ logger_1.logger.error("Database upsert operation failed", {
3379
+ operation: 'upsertOneCustomer',
3380
+ model: 'Customer',
3381
+ error: String(error),
3382
+ recordId: props.id,
3383
+ isRetryable: isConnectionError,
3384
+ });
3255
3385
  throw error;
3256
3386
  }
3257
3387
  }
@@ -3266,7 +3396,7 @@ exports.Customer = {
3266
3396
  * @returns The count of created records or null.
3267
3397
  */
3268
3398
  async updateMany(props, globalClient) {
3269
- var _a, _b, _c, _d, _e;
3399
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
3270
3400
  // Maximum number of retries for database connection issues
3271
3401
  const MAX_RETRIES = 3;
3272
3402
  let retryCount = 0;
@@ -4379,21 +4509,52 @@ exports.Customer = {
4379
4509
  }
4380
4510
  catch (error) {
4381
4511
  lastError = error;
4512
+ // Check for constraint violations FIRST - these are NEVER retryable
4513
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
4514
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
4515
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
4516
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
4517
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
4518
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
4519
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
4520
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
4521
+ if (isConstraintViolation) {
4522
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
4523
+ logger_1.logger.error("Non-retryable constraint violation in updateManyCustomer", {
4524
+ operation: 'updateManyCustomer',
4525
+ model: 'Customer',
4526
+ error: String(error),
4527
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
4528
+ errorCategory: 'CONSTRAINT_VIOLATION',
4529
+ isRetryable: false,
4530
+ });
4531
+ throw error;
4532
+ }
4382
4533
  // Check if this is a database connection error that we should retry
4383
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
4384
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
4385
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
4386
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
4387
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
4534
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
4535
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
4536
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
4537
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
4538
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
4388
4539
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4389
4540
  retryCount++;
4390
4541
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4391
- logger_1.logger.warn("Database connection error, retrying...");
4542
+ logger_1.logger.warn("Database connection error in updateManyCustomer, retrying...", {
4543
+ operation: 'updateManyCustomer',
4544
+ model: 'Customer',
4545
+ attempt: retryCount,
4546
+ maxRetries: MAX_RETRIES,
4547
+ });
4392
4548
  await new Promise(resolve => setTimeout(resolve, delay));
4393
4549
  continue;
4394
4550
  }
4395
- // Log the error and rethrow
4396
- logger_1.logger.error("Database error occurred", { error: String(error) });
4551
+ // Log structured error details and rethrow
4552
+ logger_1.logger.error("Database updateMany operation failed", {
4553
+ operation: 'updateManyCustomer',
4554
+ model: 'Customer',
4555
+ error: String(error),
4556
+ isRetryable: isConnectionError,
4557
+ });
4397
4558
  throw error;
4398
4559
  }
4399
4560
  }
@@ -4408,7 +4569,7 @@ exports.Customer = {
4408
4569
  * @returns The deleted Customer or null.
4409
4570
  */
4410
4571
  async delete(props, globalClient) {
4411
- var _a, _b, _c, _d, _e;
4572
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
4412
4573
  // Maximum number of retries for database connection issues
4413
4574
  const MAX_RETRIES = 3;
4414
4575
  let retryCount = 0;
@@ -4452,21 +4613,58 @@ exports.Customer = {
4452
4613
  }
4453
4614
  catch (error) {
4454
4615
  lastError = error;
4616
+ // Check for constraint violations FIRST - these are NEVER retryable
4617
+ // (e.g., foreign key constraints preventing deletion)
4618
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
4619
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
4620
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
4621
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
4622
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
4623
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
4624
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
4625
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
4626
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
4627
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
4628
+ if (isConstraintViolation) {
4629
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
4630
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneCustomer", {
4631
+ operation: 'deleteOneCustomer',
4632
+ model: 'Customer',
4633
+ error: String(error),
4634
+ recordId: props.id,
4635
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
4636
+ errorCategory: 'CONSTRAINT_VIOLATION',
4637
+ isRetryable: false,
4638
+ });
4639
+ throw error;
4640
+ }
4455
4641
  // Check if this is a database connection error that we should retry
4456
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
4457
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
4458
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
4459
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
4460
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
4642
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
4643
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
4644
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
4645
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
4646
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
4461
4647
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4462
4648
  retryCount++;
4463
4649
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4464
- logger_1.logger.warn("Database connection error, retrying...");
4650
+ logger_1.logger.warn("Database connection error in deleteOneCustomer, retrying...", {
4651
+ operation: 'deleteOneCustomer',
4652
+ model: 'Customer',
4653
+ attempt: retryCount,
4654
+ maxRetries: MAX_RETRIES,
4655
+ recordId: props.id,
4656
+ });
4465
4657
  await new Promise(resolve => setTimeout(resolve, delay));
4466
4658
  continue;
4467
4659
  }
4468
- // Log the error and rethrow
4469
- logger_1.logger.error("Database error occurred", { error: String(error) });
4660
+ // Log structured error details and rethrow
4661
+ logger_1.logger.error("Database delete operation failed", {
4662
+ operation: 'deleteOneCustomer',
4663
+ model: 'Customer',
4664
+ error: String(error),
4665
+ recordId: props.id,
4666
+ isRetryable: isConnectionError,
4667
+ });
4470
4668
  throw error;
4471
4669
  }
4472
4670
  }
@@ -4544,12 +4742,22 @@ exports.Customer = {
4544
4742
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4545
4743
  retryCount++;
4546
4744
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4547
- logger_1.logger.warn("Database connection error, retrying...");
4745
+ logger_1.logger.warn("Database connection error in getCustomer, retrying...", {
4746
+ operation: 'getCustomer',
4747
+ model: 'Customer',
4748
+ attempt: retryCount,
4749
+ maxRetries: MAX_RETRIES,
4750
+ });
4548
4751
  await new Promise(resolve => setTimeout(resolve, delay));
4549
4752
  continue;
4550
4753
  }
4551
- // Log the error and rethrow
4552
- logger_1.logger.error("Database error occurred", { error: String(error) });
4754
+ // Log structured error details and rethrow
4755
+ logger_1.logger.error("Database get operation failed", {
4756
+ operation: 'getCustomer',
4757
+ model: 'Customer',
4758
+ error: String(error),
4759
+ isRetryable: isConnectionError,
4760
+ });
4553
4761
  throw error;
4554
4762
  }
4555
4763
  }
@@ -4607,12 +4815,22 @@ exports.Customer = {
4607
4815
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4608
4816
  retryCount++;
4609
4817
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4610
- logger_1.logger.warn("Database connection error, retrying...");
4818
+ logger_1.logger.warn("Database connection error in getAllCustomer, retrying...", {
4819
+ operation: 'getAllCustomer',
4820
+ model: 'Customer',
4821
+ attempt: retryCount,
4822
+ maxRetries: MAX_RETRIES,
4823
+ });
4611
4824
  await new Promise(resolve => setTimeout(resolve, delay));
4612
4825
  continue;
4613
4826
  }
4614
- // Log the error and rethrow
4615
- logger_1.logger.error("Database error occurred", { error: String(error) });
4827
+ // Log structured error details and rethrow
4828
+ logger_1.logger.error("Database getAll operation failed", {
4829
+ operation: 'getAllCustomer',
4830
+ model: 'Customer',
4831
+ error: String(error),
4832
+ isRetryable: isConnectionError,
4833
+ });
4616
4834
  throw error;
4617
4835
  }
4618
4836
  }
@@ -4701,12 +4919,22 @@ exports.Customer = {
4701
4919
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4702
4920
  retryCount++;
4703
4921
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4704
- logger_1.logger.warn("Database connection error, retrying...");
4922
+ logger_1.logger.warn("Database connection error in findManyCustomer, retrying...", {
4923
+ operation: 'findManyCustomer',
4924
+ model: 'Customer',
4925
+ attempt: retryCount,
4926
+ maxRetries: MAX_RETRIES,
4927
+ });
4705
4928
  await new Promise(resolve => setTimeout(resolve, delay));
4706
4929
  continue;
4707
4930
  }
4708
- // Log the error and rethrow
4709
- logger_1.logger.error("Database error occurred", { error: String(error) });
4931
+ // Log structured error details and rethrow
4932
+ logger_1.logger.error("Database findMany operation failed", {
4933
+ operation: 'findManyCustomer',
4934
+ model: 'Customer',
4935
+ error: String(error),
4936
+ isRetryable: isConnectionError,
4937
+ });
4710
4938
  throw error;
4711
4939
  }
4712
4940
  }