@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
@@ -522,6 +522,27 @@ export const ModelArtifact = {
522
522
  }
523
523
  catch (error) {
524
524
  lastError = error;
525
+ // Check for constraint violations FIRST - these are NEVER retryable
526
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
527
+ error.message?.includes('violates unique constraint') ||
528
+ error.message?.includes('violates foreign key constraint') ||
529
+ error.message?.includes('unique constraint') ||
530
+ error.message?.includes('23514') ||
531
+ error.message?.includes('23505') ||
532
+ error.message?.includes('P2002') ||
533
+ error.message?.includes('P2003');
534
+ if (isConstraintViolation) {
535
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
536
+ logger.error("Non-retryable constraint violation in createOneModelArtifact", {
537
+ operation: 'createOneModelArtifact',
538
+ model: 'ModelArtifact',
539
+ error: String(error),
540
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
541
+ errorCategory: 'CONSTRAINT_VIOLATION',
542
+ isRetryable: false,
543
+ });
544
+ throw error;
545
+ }
525
546
  // Check if this is a database connection error that we should retry
526
547
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
527
548
  error.message?.includes('Cannot reach database server') ||
@@ -531,12 +552,22 @@ export const ModelArtifact = {
531
552
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
532
553
  retryCount++;
533
554
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
534
- logger.warn("Database connection error, retrying...");
555
+ logger.warn("Database connection error in createOneModelArtifact, retrying...", {
556
+ operation: 'createOneModelArtifact',
557
+ model: 'ModelArtifact',
558
+ attempt: retryCount,
559
+ maxRetries: MAX_RETRIES,
560
+ });
535
561
  await new Promise(resolve => setTimeout(resolve, delay));
536
562
  continue;
537
563
  }
538
- // Log the error and rethrow
539
- logger.error("Database error occurred", { error: String(error) });
564
+ // Log structured error details and rethrow
565
+ logger.error("Database create operation failed", {
566
+ operation: 'createOneModelArtifact',
567
+ model: 'ModelArtifact',
568
+ error: String(error),
569
+ isRetryable: isConnectionError,
570
+ });
540
571
  throw error;
541
572
  }
542
573
  }
@@ -606,6 +637,27 @@ export const ModelArtifact = {
606
637
  }
607
638
  catch (error) {
608
639
  lastError = error;
640
+ // Check for constraint violations FIRST - these are NEVER retryable
641
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
642
+ error.message?.includes('violates unique constraint') ||
643
+ error.message?.includes('violates foreign key constraint') ||
644
+ error.message?.includes('unique constraint') ||
645
+ error.message?.includes('23514') ||
646
+ error.message?.includes('23505') ||
647
+ error.message?.includes('P2002') ||
648
+ error.message?.includes('P2003');
649
+ if (isConstraintViolation) {
650
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
651
+ logger.error("Non-retryable constraint violation in createManyModelArtifact", {
652
+ operation: 'createManyModelArtifact',
653
+ model: 'ModelArtifact',
654
+ error: String(error),
655
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
656
+ errorCategory: 'CONSTRAINT_VIOLATION',
657
+ isRetryable: false,
658
+ });
659
+ throw error;
660
+ }
609
661
  // Check if this is a database connection error that we should retry
610
662
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
611
663
  error.message?.includes('Cannot reach database server') ||
@@ -615,12 +667,22 @@ export const ModelArtifact = {
615
667
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
616
668
  retryCount++;
617
669
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
618
- logger.warn("Database connection error, retrying...");
670
+ logger.warn("Database connection error in createManyModelArtifact, retrying...", {
671
+ operation: 'createManyModelArtifact',
672
+ model: 'ModelArtifact',
673
+ attempt: retryCount,
674
+ maxRetries: MAX_RETRIES,
675
+ });
619
676
  await new Promise(resolve => setTimeout(resolve, delay));
620
677
  continue;
621
678
  }
622
- // Log the error and rethrow
623
- logger.error("Database error occurred", { error: String(error) });
679
+ // Log structured error details and rethrow
680
+ logger.error("Database createMany operation failed", {
681
+ operation: 'createManyModelArtifact',
682
+ model: 'ModelArtifact',
683
+ error: String(error),
684
+ isRetryable: isConnectionError,
685
+ });
624
686
  throw error;
625
687
  }
626
688
  }
@@ -2022,6 +2084,28 @@ export const ModelArtifact = {
2022
2084
  }
2023
2085
  catch (error) {
2024
2086
  lastError = error;
2087
+ // Check for constraint violations FIRST - these are NEVER retryable
2088
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
2089
+ error.message?.includes('violates unique constraint') ||
2090
+ error.message?.includes('violates foreign key constraint') ||
2091
+ error.message?.includes('unique constraint') ||
2092
+ error.message?.includes('23514') ||
2093
+ error.message?.includes('23505') ||
2094
+ error.message?.includes('P2002') ||
2095
+ error.message?.includes('P2003');
2096
+ if (isConstraintViolation) {
2097
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
2098
+ logger.error("Non-retryable constraint violation in updateOneModelArtifact", {
2099
+ operation: 'updateOneModelArtifact',
2100
+ model: 'ModelArtifact',
2101
+ error: String(error),
2102
+ recordId: props.id,
2103
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
2104
+ errorCategory: 'CONSTRAINT_VIOLATION',
2105
+ isRetryable: false,
2106
+ });
2107
+ throw error;
2108
+ }
2025
2109
  // Check if this is a database connection error that we should retry
2026
2110
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
2027
2111
  error.message?.includes('Cannot reach database server') ||
@@ -2031,12 +2115,24 @@ export const ModelArtifact = {
2031
2115
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
2032
2116
  retryCount++;
2033
2117
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
2034
- logger.warn("Database connection error, retrying...");
2118
+ logger.warn("Database connection error in updateOneModelArtifact, retrying...", {
2119
+ operation: 'updateOneModelArtifact',
2120
+ model: 'ModelArtifact',
2121
+ attempt: retryCount,
2122
+ maxRetries: MAX_RETRIES,
2123
+ recordId: props.id,
2124
+ });
2035
2125
  await new Promise(resolve => setTimeout(resolve, delay));
2036
2126
  continue;
2037
2127
  }
2038
- // Log the error and rethrow
2039
- logger.error("Database error occurred", { error: String(error) });
2128
+ // Log structured error details and rethrow
2129
+ logger.error("Database update operation failed", {
2130
+ operation: 'updateOneModelArtifact',
2131
+ model: 'ModelArtifact',
2132
+ error: String(error),
2133
+ recordId: props.id,
2134
+ isRetryable: isConnectionError,
2135
+ });
2040
2136
  throw error;
2041
2137
  }
2042
2138
  }
@@ -3728,6 +3824,28 @@ export const ModelArtifact = {
3728
3824
  }
3729
3825
  catch (error) {
3730
3826
  lastError = error;
3827
+ // Check for constraint violations FIRST - these are NEVER retryable
3828
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
3829
+ error.message?.includes('violates unique constraint') ||
3830
+ error.message?.includes('violates foreign key constraint') ||
3831
+ error.message?.includes('unique constraint') ||
3832
+ error.message?.includes('23514') ||
3833
+ error.message?.includes('23505') ||
3834
+ error.message?.includes('P2002') ||
3835
+ error.message?.includes('P2003');
3836
+ if (isConstraintViolation) {
3837
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
3838
+ logger.error("Non-retryable constraint violation in upsertOneModelArtifact", {
3839
+ operation: 'upsertOneModelArtifact',
3840
+ model: 'ModelArtifact',
3841
+ error: String(error),
3842
+ recordId: props.id,
3843
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
3844
+ errorCategory: 'CONSTRAINT_VIOLATION',
3845
+ isRetryable: false,
3846
+ });
3847
+ throw error;
3848
+ }
3731
3849
  // Check if this is a database connection error that we should retry
3732
3850
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
3733
3851
  error.message?.includes('Cannot reach database server') ||
@@ -3737,12 +3855,24 @@ export const ModelArtifact = {
3737
3855
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
3738
3856
  retryCount++;
3739
3857
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
3740
- logger.warn("Database connection error, retrying...");
3858
+ logger.warn("Database connection error in upsertOneModelArtifact, retrying...", {
3859
+ operation: 'upsertOneModelArtifact',
3860
+ model: 'ModelArtifact',
3861
+ attempt: retryCount,
3862
+ maxRetries: MAX_RETRIES,
3863
+ recordId: props.id,
3864
+ });
3741
3865
  await new Promise(resolve => setTimeout(resolve, delay));
3742
3866
  continue;
3743
3867
  }
3744
- // Log the error and rethrow
3745
- logger.error("Database error occurred", { error: String(error) });
3868
+ // Log structured error details and rethrow
3869
+ logger.error("Database upsert operation failed", {
3870
+ operation: 'upsertOneModelArtifact',
3871
+ model: 'ModelArtifact',
3872
+ error: String(error),
3873
+ recordId: props.id,
3874
+ isRetryable: isConnectionError,
3875
+ });
3746
3876
  throw error;
3747
3877
  }
3748
3878
  }
@@ -5144,6 +5274,27 @@ export const ModelArtifact = {
5144
5274
  }
5145
5275
  catch (error) {
5146
5276
  lastError = error;
5277
+ // Check for constraint violations FIRST - these are NEVER retryable
5278
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
5279
+ error.message?.includes('violates unique constraint') ||
5280
+ error.message?.includes('violates foreign key constraint') ||
5281
+ error.message?.includes('unique constraint') ||
5282
+ error.message?.includes('23514') ||
5283
+ error.message?.includes('23505') ||
5284
+ error.message?.includes('P2002') ||
5285
+ error.message?.includes('P2003');
5286
+ if (isConstraintViolation) {
5287
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
5288
+ logger.error("Non-retryable constraint violation in updateManyModelArtifact", {
5289
+ operation: 'updateManyModelArtifact',
5290
+ model: 'ModelArtifact',
5291
+ error: String(error),
5292
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
5293
+ errorCategory: 'CONSTRAINT_VIOLATION',
5294
+ isRetryable: false,
5295
+ });
5296
+ throw error;
5297
+ }
5147
5298
  // Check if this is a database connection error that we should retry
5148
5299
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
5149
5300
  error.message?.includes('Cannot reach database server') ||
@@ -5153,12 +5304,22 @@ export const ModelArtifact = {
5153
5304
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
5154
5305
  retryCount++;
5155
5306
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
5156
- logger.warn("Database connection error, retrying...");
5307
+ logger.warn("Database connection error in updateManyModelArtifact, retrying...", {
5308
+ operation: 'updateManyModelArtifact',
5309
+ model: 'ModelArtifact',
5310
+ attempt: retryCount,
5311
+ maxRetries: MAX_RETRIES,
5312
+ });
5157
5313
  await new Promise(resolve => setTimeout(resolve, delay));
5158
5314
  continue;
5159
5315
  }
5160
- // Log the error and rethrow
5161
- logger.error("Database error occurred", { error: String(error) });
5316
+ // Log structured error details and rethrow
5317
+ logger.error("Database updateMany operation failed", {
5318
+ operation: 'updateManyModelArtifact',
5319
+ model: 'ModelArtifact',
5320
+ error: String(error),
5321
+ isRetryable: isConnectionError,
5322
+ });
5162
5323
  throw error;
5163
5324
  }
5164
5325
  }
@@ -5216,6 +5377,31 @@ export const ModelArtifact = {
5216
5377
  }
5217
5378
  catch (error) {
5218
5379
  lastError = error;
5380
+ // Check for constraint violations FIRST - these are NEVER retryable
5381
+ // (e.g., foreign key constraints preventing deletion)
5382
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
5383
+ error.message?.includes('violates unique constraint') ||
5384
+ error.message?.includes('violates foreign key constraint') ||
5385
+ error.message?.includes('unique constraint') ||
5386
+ error.message?.includes('23514') ||
5387
+ error.message?.includes('23505') ||
5388
+ error.message?.includes('23503') ||
5389
+ error.message?.includes('P2002') ||
5390
+ error.message?.includes('P2003') ||
5391
+ error.message?.includes('P2014');
5392
+ if (isConstraintViolation) {
5393
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
5394
+ logger.error("Non-retryable constraint violation in deleteOneModelArtifact", {
5395
+ operation: 'deleteOneModelArtifact',
5396
+ model: 'ModelArtifact',
5397
+ error: String(error),
5398
+ recordId: props.id,
5399
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
5400
+ errorCategory: 'CONSTRAINT_VIOLATION',
5401
+ isRetryable: false,
5402
+ });
5403
+ throw error;
5404
+ }
5219
5405
  // Check if this is a database connection error that we should retry
5220
5406
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
5221
5407
  error.message?.includes('Cannot reach database server') ||
@@ -5225,12 +5411,24 @@ export const ModelArtifact = {
5225
5411
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
5226
5412
  retryCount++;
5227
5413
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
5228
- logger.warn("Database connection error, retrying...");
5414
+ logger.warn("Database connection error in deleteOneModelArtifact, retrying...", {
5415
+ operation: 'deleteOneModelArtifact',
5416
+ model: 'ModelArtifact',
5417
+ attempt: retryCount,
5418
+ maxRetries: MAX_RETRIES,
5419
+ recordId: props.id,
5420
+ });
5229
5421
  await new Promise(resolve => setTimeout(resolve, delay));
5230
5422
  continue;
5231
5423
  }
5232
- // Log the error and rethrow
5233
- logger.error("Database error occurred", { error: String(error) });
5424
+ // Log structured error details and rethrow
5425
+ logger.error("Database delete operation failed", {
5426
+ operation: 'deleteOneModelArtifact',
5427
+ model: 'ModelArtifact',
5428
+ error: String(error),
5429
+ recordId: props.id,
5430
+ isRetryable: isConnectionError,
5431
+ });
5234
5432
  throw error;
5235
5433
  }
5236
5434
  }
@@ -5296,12 +5494,22 @@ export const ModelArtifact = {
5296
5494
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
5297
5495
  retryCount++;
5298
5496
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
5299
- logger.warn("Database connection error, retrying...");
5497
+ logger.warn("Database connection error in getModelArtifact, retrying...", {
5498
+ operation: 'getModelArtifact',
5499
+ model: 'ModelArtifact',
5500
+ attempt: retryCount,
5501
+ maxRetries: MAX_RETRIES,
5502
+ });
5300
5503
  await new Promise(resolve => setTimeout(resolve, delay));
5301
5504
  continue;
5302
5505
  }
5303
- // Log the error and rethrow
5304
- logger.error("Database error occurred", { error: String(error) });
5506
+ // Log structured error details and rethrow
5507
+ logger.error("Database get operation failed", {
5508
+ operation: 'getModelArtifact',
5509
+ model: 'ModelArtifact',
5510
+ error: String(error),
5511
+ isRetryable: isConnectionError,
5512
+ });
5305
5513
  throw error;
5306
5514
  }
5307
5515
  }
@@ -5358,12 +5566,22 @@ export const ModelArtifact = {
5358
5566
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
5359
5567
  retryCount++;
5360
5568
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
5361
- logger.warn("Database connection error, retrying...");
5569
+ logger.warn("Database connection error in getAllModelArtifact, retrying...", {
5570
+ operation: 'getAllModelArtifact',
5571
+ model: 'ModelArtifact',
5572
+ attempt: retryCount,
5573
+ maxRetries: MAX_RETRIES,
5574
+ });
5362
5575
  await new Promise(resolve => setTimeout(resolve, delay));
5363
5576
  continue;
5364
5577
  }
5365
- // Log the error and rethrow
5366
- logger.error("Database error occurred", { error: String(error) });
5578
+ // Log structured error details and rethrow
5579
+ logger.error("Database getAll operation failed", {
5580
+ operation: 'getAllModelArtifact',
5581
+ model: 'ModelArtifact',
5582
+ error: String(error),
5583
+ isRetryable: isConnectionError,
5584
+ });
5367
5585
  throw error;
5368
5586
  }
5369
5587
  }
@@ -5436,12 +5654,22 @@ export const ModelArtifact = {
5436
5654
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
5437
5655
  retryCount++;
5438
5656
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
5439
- logger.warn("Database connection error, retrying...");
5657
+ logger.warn("Database connection error in findManyModelArtifact, retrying...", {
5658
+ operation: 'findManyModelArtifact',
5659
+ model: 'ModelArtifact',
5660
+ attempt: retryCount,
5661
+ maxRetries: MAX_RETRIES,
5662
+ });
5440
5663
  await new Promise(resolve => setTimeout(resolve, delay));
5441
5664
  continue;
5442
5665
  }
5443
- // Log the error and rethrow
5444
- logger.error("Database error occurred", { error: String(error) });
5666
+ // Log structured error details and rethrow
5667
+ logger.error("Database findMany operation failed", {
5668
+ operation: 'findManyModelArtifact',
5669
+ model: 'ModelArtifact',
5670
+ error: String(error),
5671
+ isRetryable: isConnectionError,
5672
+ });
5445
5673
  throw error;
5446
5674
  }
5447
5675
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ModelVersion.d.ts","sourceRoot":"","sources":["../../src/ModelVersion.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,I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