@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/Allocation.cjs CHANGED
@@ -151,7 +151,7 @@ exports.Allocation = {
151
151
  * @returns The created Allocation or null.
152
152
  */
153
153
  async create(props, globalClient) {
154
- var _a, _b, _c, _d, _e;
154
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
155
155
  // Validate allocation percentages before creating
156
156
  (0, allocation_validator_1.assertValidAllocation)({
157
157
  equities: props.equities,
@@ -504,21 +504,52 @@ exports.Allocation = {
504
504
  }
505
505
  catch (error) {
506
506
  lastError = error;
507
+ // Check for constraint violations FIRST - these are NEVER retryable
508
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
509
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
510
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
511
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
512
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
513
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
514
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
515
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
516
+ if (isConstraintViolation) {
517
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
518
+ logger_1.logger.error("Non-retryable constraint violation in createOneAllocation", {
519
+ operation: 'createOneAllocation',
520
+ model: 'Allocation',
521
+ error: String(error),
522
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
523
+ errorCategory: 'CONSTRAINT_VIOLATION',
524
+ isRetryable: false,
525
+ });
526
+ throw error;
527
+ }
507
528
  // Check if this is a database connection error that we should retry
508
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
509
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
510
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
511
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
512
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
529
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
530
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
531
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
532
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
533
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
513
534
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
514
535
  retryCount++;
515
536
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
516
- logger_1.logger.warn("Database connection error, retrying...");
537
+ logger_1.logger.warn("Database connection error in createOneAllocation, retrying...", {
538
+ operation: 'createOneAllocation',
539
+ model: 'Allocation',
540
+ attempt: retryCount,
541
+ maxRetries: MAX_RETRIES,
542
+ });
517
543
  await new Promise(resolve => setTimeout(resolve, delay));
518
544
  continue;
519
545
  }
520
- // Log the error and rethrow
521
- logger_1.logger.error("Database error occurred", { error: String(error) });
546
+ // Log structured error details and rethrow
547
+ logger_1.logger.error("Database create operation failed", {
548
+ operation: 'createOneAllocation',
549
+ model: 'Allocation',
550
+ error: String(error),
551
+ isRetryable: isConnectionError,
552
+ });
522
553
  throw error;
523
554
  }
524
555
  }
@@ -533,7 +564,7 @@ exports.Allocation = {
533
564
  * @returns The count of created records or null.
534
565
  */
535
566
  async createMany(props, globalClient) {
536
- var _a, _b, _c, _d, _e;
567
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
537
568
  // Maximum number of retries for database connection issues
538
569
  const MAX_RETRIES = 3;
539
570
  let retryCount = 0;
@@ -585,21 +616,52 @@ exports.Allocation = {
585
616
  }
586
617
  catch (error) {
587
618
  lastError = error;
619
+ // Check for constraint violations FIRST - these are NEVER retryable
620
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
621
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
622
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
623
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
624
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
625
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
626
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
627
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
628
+ if (isConstraintViolation) {
629
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
630
+ logger_1.logger.error("Non-retryable constraint violation in createManyAllocation", {
631
+ operation: 'createManyAllocation',
632
+ model: 'Allocation',
633
+ error: String(error),
634
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
635
+ errorCategory: 'CONSTRAINT_VIOLATION',
636
+ isRetryable: false,
637
+ });
638
+ throw error;
639
+ }
588
640
  // Check if this is a database connection error that we should retry
589
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
590
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
591
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
592
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
593
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
641
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
642
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
643
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
644
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
645
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
594
646
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
595
647
  retryCount++;
596
648
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
597
- logger_1.logger.warn("Database connection error, retrying...");
649
+ logger_1.logger.warn("Database connection error in createManyAllocation, retrying...", {
650
+ operation: 'createManyAllocation',
651
+ model: 'Allocation',
652
+ attempt: retryCount,
653
+ maxRetries: MAX_RETRIES,
654
+ });
598
655
  await new Promise(resolve => setTimeout(resolve, delay));
599
656
  continue;
600
657
  }
601
- // Log the error and rethrow
602
- logger_1.logger.error("Database error occurred", { error: String(error) });
658
+ // Log structured error details and rethrow
659
+ logger_1.logger.error("Database createMany operation failed", {
660
+ operation: 'createManyAllocation',
661
+ model: 'Allocation',
662
+ error: String(error),
663
+ isRetryable: isConnectionError,
664
+ });
603
665
  throw error;
604
666
  }
605
667
  }
@@ -614,7 +676,7 @@ exports.Allocation = {
614
676
  * @returns The updated Allocation or null.
615
677
  */
616
678
  async update(props, globalClient) {
617
- var _a, _b, _c, _d, _e;
679
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
618
680
  // Validate allocation percentages before updating
619
681
  (0, allocation_validator_1.assertValidAllocation)({
620
682
  equities: props.equities,
@@ -1780,21 +1842,55 @@ exports.Allocation = {
1780
1842
  }
1781
1843
  catch (error) {
1782
1844
  lastError = error;
1845
+ // Check for constraint violations FIRST - these are NEVER retryable
1846
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
1847
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
1848
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
1849
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
1850
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
1851
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
1852
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
1853
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
1854
+ if (isConstraintViolation) {
1855
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
1856
+ logger_1.logger.error("Non-retryable constraint violation in updateOneAllocation", {
1857
+ operation: 'updateOneAllocation',
1858
+ model: 'Allocation',
1859
+ error: String(error),
1860
+ recordId: props.id,
1861
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1862
+ errorCategory: 'CONSTRAINT_VIOLATION',
1863
+ isRetryable: false,
1864
+ });
1865
+ throw error;
1866
+ }
1783
1867
  // Check if this is a database connection error that we should retry
1784
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
1785
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
1786
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
1787
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
1788
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
1868
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
1869
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
1870
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
1871
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
1872
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
1789
1873
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1790
1874
  retryCount++;
1791
1875
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1792
- logger_1.logger.warn("Database connection error, retrying...");
1876
+ logger_1.logger.warn("Database connection error in updateOneAllocation, retrying...", {
1877
+ operation: 'updateOneAllocation',
1878
+ model: 'Allocation',
1879
+ attempt: retryCount,
1880
+ maxRetries: MAX_RETRIES,
1881
+ recordId: props.id,
1882
+ });
1793
1883
  await new Promise(resolve => setTimeout(resolve, delay));
1794
1884
  continue;
1795
1885
  }
1796
- // Log the error and rethrow
1797
- logger_1.logger.error("Database error occurred", { error: String(error) });
1886
+ // Log structured error details and rethrow
1887
+ logger_1.logger.error("Database update operation failed", {
1888
+ operation: 'updateOneAllocation',
1889
+ model: 'Allocation',
1890
+ error: String(error),
1891
+ recordId: props.id,
1892
+ isRetryable: isConnectionError,
1893
+ });
1798
1894
  throw error;
1799
1895
  }
1800
1896
  }
@@ -1809,7 +1905,7 @@ exports.Allocation = {
1809
1905
  * @returns The updated Allocation or null.
1810
1906
  */
1811
1907
  async upsert(props, globalClient) {
1812
- var _a, _b, _c, _d, _e;
1908
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1813
1909
  // Maximum number of retries for database connection issues
1814
1910
  const MAX_RETRIES = 3;
1815
1911
  let retryCount = 0;
@@ -3259,21 +3355,55 @@ exports.Allocation = {
3259
3355
  }
3260
3356
  catch (error) {
3261
3357
  lastError = error;
3358
+ // Check for constraint violations FIRST - these are NEVER retryable
3359
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
3360
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
3361
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
3362
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
3363
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
3364
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
3365
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
3366
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
3367
+ if (isConstraintViolation) {
3368
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
3369
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneAllocation", {
3370
+ operation: 'upsertOneAllocation',
3371
+ model: 'Allocation',
3372
+ error: String(error),
3373
+ recordId: props.id,
3374
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
3375
+ errorCategory: 'CONSTRAINT_VIOLATION',
3376
+ isRetryable: false,
3377
+ });
3378
+ throw error;
3379
+ }
3262
3380
  // Check if this is a database connection error that we should retry
3263
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
3264
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
3265
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
3266
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
3267
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
3381
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
3382
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
3383
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
3384
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
3385
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
3268
3386
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
3269
3387
  retryCount++;
3270
3388
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
3271
- logger_1.logger.warn("Database connection error, retrying...");
3389
+ logger_1.logger.warn("Database connection error in upsertOneAllocation, retrying...", {
3390
+ operation: 'upsertOneAllocation',
3391
+ model: 'Allocation',
3392
+ attempt: retryCount,
3393
+ maxRetries: MAX_RETRIES,
3394
+ recordId: props.id,
3395
+ });
3272
3396
  await new Promise(resolve => setTimeout(resolve, delay));
3273
3397
  continue;
3274
3398
  }
3275
- // Log the error and rethrow
3276
- logger_1.logger.error("Database error occurred", { error: String(error) });
3399
+ // Log structured error details and rethrow
3400
+ logger_1.logger.error("Database upsert operation failed", {
3401
+ operation: 'upsertOneAllocation',
3402
+ model: 'Allocation',
3403
+ error: String(error),
3404
+ recordId: props.id,
3405
+ isRetryable: isConnectionError,
3406
+ });
3277
3407
  throw error;
3278
3408
  }
3279
3409
  }
@@ -3288,7 +3418,7 @@ exports.Allocation = {
3288
3418
  * @returns The count of created records or null.
3289
3419
  */
3290
3420
  async updateMany(props, globalClient) {
3291
- var _a, _b, _c, _d, _e;
3421
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
3292
3422
  // Maximum number of retries for database connection issues
3293
3423
  const MAX_RETRIES = 3;
3294
3424
  let retryCount = 0;
@@ -4445,21 +4575,52 @@ exports.Allocation = {
4445
4575
  }
4446
4576
  catch (error) {
4447
4577
  lastError = error;
4578
+ // Check for constraint violations FIRST - these are NEVER retryable
4579
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
4580
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
4581
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
4582
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
4583
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
4584
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
4585
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
4586
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
4587
+ if (isConstraintViolation) {
4588
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
4589
+ logger_1.logger.error("Non-retryable constraint violation in updateManyAllocation", {
4590
+ operation: 'updateManyAllocation',
4591
+ model: 'Allocation',
4592
+ error: String(error),
4593
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
4594
+ errorCategory: 'CONSTRAINT_VIOLATION',
4595
+ isRetryable: false,
4596
+ });
4597
+ throw error;
4598
+ }
4448
4599
  // Check if this is a database connection error that we should retry
4449
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
4450
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
4451
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
4452
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
4453
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
4600
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
4601
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
4602
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
4603
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
4604
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
4454
4605
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4455
4606
  retryCount++;
4456
4607
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4457
- logger_1.logger.warn("Database connection error, retrying...");
4608
+ logger_1.logger.warn("Database connection error in updateManyAllocation, retrying...", {
4609
+ operation: 'updateManyAllocation',
4610
+ model: 'Allocation',
4611
+ attempt: retryCount,
4612
+ maxRetries: MAX_RETRIES,
4613
+ });
4458
4614
  await new Promise(resolve => setTimeout(resolve, delay));
4459
4615
  continue;
4460
4616
  }
4461
- // Log the error and rethrow
4462
- logger_1.logger.error("Database error occurred", { error: String(error) });
4617
+ // Log structured error details and rethrow
4618
+ logger_1.logger.error("Database updateMany operation failed", {
4619
+ operation: 'updateManyAllocation',
4620
+ model: 'Allocation',
4621
+ error: String(error),
4622
+ isRetryable: isConnectionError,
4623
+ });
4463
4624
  throw error;
4464
4625
  }
4465
4626
  }
@@ -4474,7 +4635,7 @@ exports.Allocation = {
4474
4635
  * @returns The deleted Allocation or null.
4475
4636
  */
4476
4637
  async delete(props, globalClient) {
4477
- var _a, _b, _c, _d, _e;
4638
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
4478
4639
  // Maximum number of retries for database connection issues
4479
4640
  const MAX_RETRIES = 3;
4480
4641
  let retryCount = 0;
@@ -4518,21 +4679,58 @@ exports.Allocation = {
4518
4679
  }
4519
4680
  catch (error) {
4520
4681
  lastError = error;
4682
+ // Check for constraint violations FIRST - these are NEVER retryable
4683
+ // (e.g., foreign key constraints preventing deletion)
4684
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
4685
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
4686
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
4687
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
4688
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
4689
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
4690
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
4691
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
4692
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
4693
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
4694
+ if (isConstraintViolation) {
4695
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
4696
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneAllocation", {
4697
+ operation: 'deleteOneAllocation',
4698
+ model: 'Allocation',
4699
+ error: String(error),
4700
+ recordId: props.id,
4701
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
4702
+ errorCategory: 'CONSTRAINT_VIOLATION',
4703
+ isRetryable: false,
4704
+ });
4705
+ throw error;
4706
+ }
4521
4707
  // Check if this is a database connection error that we should retry
4522
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
4523
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
4524
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
4525
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
4526
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
4708
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
4709
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
4710
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
4711
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
4712
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
4527
4713
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4528
4714
  retryCount++;
4529
4715
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4530
- logger_1.logger.warn("Database connection error, retrying...");
4716
+ logger_1.logger.warn("Database connection error in deleteOneAllocation, retrying...", {
4717
+ operation: 'deleteOneAllocation',
4718
+ model: 'Allocation',
4719
+ attempt: retryCount,
4720
+ maxRetries: MAX_RETRIES,
4721
+ recordId: props.id,
4722
+ });
4531
4723
  await new Promise(resolve => setTimeout(resolve, delay));
4532
4724
  continue;
4533
4725
  }
4534
- // Log the error and rethrow
4535
- logger_1.logger.error("Database error occurred", { error: String(error) });
4726
+ // Log structured error details and rethrow
4727
+ logger_1.logger.error("Database delete operation failed", {
4728
+ operation: 'deleteOneAllocation',
4729
+ model: 'Allocation',
4730
+ error: String(error),
4731
+ recordId: props.id,
4732
+ isRetryable: isConnectionError,
4733
+ });
4536
4734
  throw error;
4537
4735
  }
4538
4736
  }
@@ -4600,12 +4798,22 @@ exports.Allocation = {
4600
4798
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4601
4799
  retryCount++;
4602
4800
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4603
- logger_1.logger.warn("Database connection error, retrying...");
4801
+ logger_1.logger.warn("Database connection error in getAllocation, retrying...", {
4802
+ operation: 'getAllocation',
4803
+ model: 'Allocation',
4804
+ attempt: retryCount,
4805
+ maxRetries: MAX_RETRIES,
4806
+ });
4604
4807
  await new Promise(resolve => setTimeout(resolve, delay));
4605
4808
  continue;
4606
4809
  }
4607
- // Log the error and rethrow
4608
- logger_1.logger.error("Database error occurred", { error: String(error) });
4810
+ // Log structured error details and rethrow
4811
+ logger_1.logger.error("Database get operation failed", {
4812
+ operation: 'getAllocation',
4813
+ model: 'Allocation',
4814
+ error: String(error),
4815
+ isRetryable: isConnectionError,
4816
+ });
4609
4817
  throw error;
4610
4818
  }
4611
4819
  }
@@ -4663,12 +4871,22 @@ exports.Allocation = {
4663
4871
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4664
4872
  retryCount++;
4665
4873
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4666
- logger_1.logger.warn("Database connection error, retrying...");
4874
+ logger_1.logger.warn("Database connection error in getAllAllocation, retrying...", {
4875
+ operation: 'getAllAllocation',
4876
+ model: 'Allocation',
4877
+ attempt: retryCount,
4878
+ maxRetries: MAX_RETRIES,
4879
+ });
4667
4880
  await new Promise(resolve => setTimeout(resolve, delay));
4668
4881
  continue;
4669
4882
  }
4670
- // Log the error and rethrow
4671
- logger_1.logger.error("Database error occurred", { error: String(error) });
4883
+ // Log structured error details and rethrow
4884
+ logger_1.logger.error("Database getAll operation failed", {
4885
+ operation: 'getAllAllocation',
4886
+ model: 'Allocation',
4887
+ error: String(error),
4888
+ isRetryable: isConnectionError,
4889
+ });
4672
4890
  throw error;
4673
4891
  }
4674
4892
  }
@@ -4745,12 +4963,22 @@ exports.Allocation = {
4745
4963
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4746
4964
  retryCount++;
4747
4965
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4748
- logger_1.logger.warn("Database connection error, retrying...");
4966
+ logger_1.logger.warn("Database connection error in findManyAllocation, retrying...", {
4967
+ operation: 'findManyAllocation',
4968
+ model: 'Allocation',
4969
+ attempt: retryCount,
4970
+ maxRetries: MAX_RETRIES,
4971
+ });
4749
4972
  await new Promise(resolve => setTimeout(resolve, delay));
4750
4973
  continue;
4751
4974
  }
4752
- // Log the error and rethrow
4753
- logger_1.logger.error("Database error occurred", { error: String(error) });
4975
+ // Log structured error details and rethrow
4976
+ logger_1.logger.error("Database findMany operation failed", {
4977
+ operation: 'findManyAllocation',
4978
+ model: 'Allocation',
4979
+ error: String(error),
4980
+ isRetryable: isConnectionError,
4981
+ });
4754
4982
  throw error;
4755
4983
  }
4756
4984
  }