@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/esm/ABTest.mjs CHANGED
@@ -1684,6 +1684,27 @@ export const ABTest = {
1684
1684
  }
1685
1685
  catch (error) {
1686
1686
  lastError = error;
1687
+ // Check for constraint violations FIRST - these are NEVER retryable
1688
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
1689
+ error.message?.includes('violates unique constraint') ||
1690
+ error.message?.includes('violates foreign key constraint') ||
1691
+ error.message?.includes('unique constraint') ||
1692
+ error.message?.includes('23514') ||
1693
+ error.message?.includes('23505') ||
1694
+ error.message?.includes('P2002') ||
1695
+ error.message?.includes('P2003');
1696
+ if (isConstraintViolation) {
1697
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
1698
+ logger.error("Non-retryable constraint violation in createOneABTest", {
1699
+ operation: 'createOneABTest',
1700
+ model: 'ABTest',
1701
+ error: String(error),
1702
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1703
+ errorCategory: 'CONSTRAINT_VIOLATION',
1704
+ isRetryable: false,
1705
+ });
1706
+ throw error;
1707
+ }
1687
1708
  // Check if this is a database connection error that we should retry
1688
1709
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
1689
1710
  error.message?.includes('Cannot reach database server') ||
@@ -1693,12 +1714,22 @@ export const ABTest = {
1693
1714
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1694
1715
  retryCount++;
1695
1716
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1696
- logger.warn("Database connection error, retrying...");
1717
+ logger.warn("Database connection error in createOneABTest, retrying...", {
1718
+ operation: 'createOneABTest',
1719
+ model: 'ABTest',
1720
+ attempt: retryCount,
1721
+ maxRetries: MAX_RETRIES,
1722
+ });
1697
1723
  await new Promise(resolve => setTimeout(resolve, delay));
1698
1724
  continue;
1699
1725
  }
1700
- // Log the error and rethrow
1701
- logger.error("Database error occurred", { error: String(error) });
1726
+ // Log structured error details and rethrow
1727
+ logger.error("Database create operation failed", {
1728
+ operation: 'createOneABTest',
1729
+ model: 'ABTest',
1730
+ error: String(error),
1731
+ isRetryable: isConnectionError,
1732
+ });
1702
1733
  throw error;
1703
1734
  }
1704
1735
  }
@@ -1780,6 +1811,27 @@ export const ABTest = {
1780
1811
  }
1781
1812
  catch (error) {
1782
1813
  lastError = error;
1814
+ // Check for constraint violations FIRST - these are NEVER retryable
1815
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
1816
+ error.message?.includes('violates unique constraint') ||
1817
+ error.message?.includes('violates foreign key constraint') ||
1818
+ error.message?.includes('unique constraint') ||
1819
+ error.message?.includes('23514') ||
1820
+ error.message?.includes('23505') ||
1821
+ error.message?.includes('P2002') ||
1822
+ error.message?.includes('P2003');
1823
+ if (isConstraintViolation) {
1824
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
1825
+ logger.error("Non-retryable constraint violation in createManyABTest", {
1826
+ operation: 'createManyABTest',
1827
+ model: 'ABTest',
1828
+ error: String(error),
1829
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1830
+ errorCategory: 'CONSTRAINT_VIOLATION',
1831
+ isRetryable: false,
1832
+ });
1833
+ throw error;
1834
+ }
1783
1835
  // Check if this is a database connection error that we should retry
1784
1836
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
1785
1837
  error.message?.includes('Cannot reach database server') ||
@@ -1789,12 +1841,22 @@ export const ABTest = {
1789
1841
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1790
1842
  retryCount++;
1791
1843
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1792
- logger.warn("Database connection error, retrying...");
1844
+ logger.warn("Database connection error in createManyABTest, retrying...", {
1845
+ operation: 'createManyABTest',
1846
+ model: 'ABTest',
1847
+ attempt: retryCount,
1848
+ maxRetries: MAX_RETRIES,
1849
+ });
1793
1850
  await new Promise(resolve => setTimeout(resolve, delay));
1794
1851
  continue;
1795
1852
  }
1796
- // Log the error and rethrow
1797
- logger.error("Database error occurred", { error: String(error) });
1853
+ // Log structured error details and rethrow
1854
+ logger.error("Database createMany operation failed", {
1855
+ operation: 'createManyABTest',
1856
+ model: 'ABTest',
1857
+ error: String(error),
1858
+ isRetryable: isConnectionError,
1859
+ });
1798
1860
  throw error;
1799
1861
  }
1800
1862
  }
@@ -7968,6 +8030,28 @@ export const ABTest = {
7968
8030
  }
7969
8031
  catch (error) {
7970
8032
  lastError = error;
8033
+ // Check for constraint violations FIRST - these are NEVER retryable
8034
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
8035
+ error.message?.includes('violates unique constraint') ||
8036
+ error.message?.includes('violates foreign key constraint') ||
8037
+ error.message?.includes('unique constraint') ||
8038
+ error.message?.includes('23514') ||
8039
+ error.message?.includes('23505') ||
8040
+ error.message?.includes('P2002') ||
8041
+ error.message?.includes('P2003');
8042
+ if (isConstraintViolation) {
8043
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
8044
+ logger.error("Non-retryable constraint violation in updateOneABTest", {
8045
+ operation: 'updateOneABTest',
8046
+ model: 'ABTest',
8047
+ error: String(error),
8048
+ recordId: props.id,
8049
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
8050
+ errorCategory: 'CONSTRAINT_VIOLATION',
8051
+ isRetryable: false,
8052
+ });
8053
+ throw error;
8054
+ }
7971
8055
  // Check if this is a database connection error that we should retry
7972
8056
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
7973
8057
  error.message?.includes('Cannot reach database server') ||
@@ -7977,12 +8061,24 @@ export const ABTest = {
7977
8061
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
7978
8062
  retryCount++;
7979
8063
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
7980
- logger.warn("Database connection error, retrying...");
8064
+ logger.warn("Database connection error in updateOneABTest, retrying...", {
8065
+ operation: 'updateOneABTest',
8066
+ model: 'ABTest',
8067
+ attempt: retryCount,
8068
+ maxRetries: MAX_RETRIES,
8069
+ recordId: props.id,
8070
+ });
7981
8071
  await new Promise(resolve => setTimeout(resolve, delay));
7982
8072
  continue;
7983
8073
  }
7984
- // Log the error and rethrow
7985
- logger.error("Database error occurred", { error: String(error) });
8074
+ // Log structured error details and rethrow
8075
+ logger.error("Database update operation failed", {
8076
+ operation: 'updateOneABTest',
8077
+ model: 'ABTest',
8078
+ error: String(error),
8079
+ recordId: props.id,
8080
+ isRetryable: isConnectionError,
8081
+ });
7986
8082
  throw error;
7987
8083
  }
7988
8084
  }
@@ -15552,6 +15648,28 @@ export const ABTest = {
15552
15648
  }
15553
15649
  catch (error) {
15554
15650
  lastError = error;
15651
+ // Check for constraint violations FIRST - these are NEVER retryable
15652
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
15653
+ error.message?.includes('violates unique constraint') ||
15654
+ error.message?.includes('violates foreign key constraint') ||
15655
+ error.message?.includes('unique constraint') ||
15656
+ error.message?.includes('23514') ||
15657
+ error.message?.includes('23505') ||
15658
+ error.message?.includes('P2002') ||
15659
+ error.message?.includes('P2003');
15660
+ if (isConstraintViolation) {
15661
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
15662
+ logger.error("Non-retryable constraint violation in upsertOneABTest", {
15663
+ operation: 'upsertOneABTest',
15664
+ model: 'ABTest',
15665
+ error: String(error),
15666
+ recordId: props.id,
15667
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
15668
+ errorCategory: 'CONSTRAINT_VIOLATION',
15669
+ isRetryable: false,
15670
+ });
15671
+ throw error;
15672
+ }
15555
15673
  // Check if this is a database connection error that we should retry
15556
15674
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
15557
15675
  error.message?.includes('Cannot reach database server') ||
@@ -15561,12 +15679,24 @@ export const ABTest = {
15561
15679
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
15562
15680
  retryCount++;
15563
15681
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
15564
- logger.warn("Database connection error, retrying...");
15682
+ logger.warn("Database connection error in upsertOneABTest, retrying...", {
15683
+ operation: 'upsertOneABTest',
15684
+ model: 'ABTest',
15685
+ attempt: retryCount,
15686
+ maxRetries: MAX_RETRIES,
15687
+ recordId: props.id,
15688
+ });
15565
15689
  await new Promise(resolve => setTimeout(resolve, delay));
15566
15690
  continue;
15567
15691
  }
15568
- // Log the error and rethrow
15569
- logger.error("Database error occurred", { error: String(error) });
15692
+ // Log structured error details and rethrow
15693
+ logger.error("Database upsert operation failed", {
15694
+ operation: 'upsertOneABTest',
15695
+ model: 'ABTest',
15696
+ error: String(error),
15697
+ recordId: props.id,
15698
+ isRetryable: isConnectionError,
15699
+ });
15570
15700
  throw error;
15571
15701
  }
15572
15702
  }
@@ -21740,6 +21870,27 @@ export const ABTest = {
21740
21870
  }
21741
21871
  catch (error) {
21742
21872
  lastError = error;
21873
+ // Check for constraint violations FIRST - these are NEVER retryable
21874
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
21875
+ error.message?.includes('violates unique constraint') ||
21876
+ error.message?.includes('violates foreign key constraint') ||
21877
+ error.message?.includes('unique constraint') ||
21878
+ error.message?.includes('23514') ||
21879
+ error.message?.includes('23505') ||
21880
+ error.message?.includes('P2002') ||
21881
+ error.message?.includes('P2003');
21882
+ if (isConstraintViolation) {
21883
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
21884
+ logger.error("Non-retryable constraint violation in updateManyABTest", {
21885
+ operation: 'updateManyABTest',
21886
+ model: 'ABTest',
21887
+ error: String(error),
21888
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
21889
+ errorCategory: 'CONSTRAINT_VIOLATION',
21890
+ isRetryable: false,
21891
+ });
21892
+ throw error;
21893
+ }
21743
21894
  // Check if this is a database connection error that we should retry
21744
21895
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
21745
21896
  error.message?.includes('Cannot reach database server') ||
@@ -21749,12 +21900,22 @@ export const ABTest = {
21749
21900
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
21750
21901
  retryCount++;
21751
21902
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
21752
- logger.warn("Database connection error, retrying...");
21903
+ logger.warn("Database connection error in updateManyABTest, retrying...", {
21904
+ operation: 'updateManyABTest',
21905
+ model: 'ABTest',
21906
+ attempt: retryCount,
21907
+ maxRetries: MAX_RETRIES,
21908
+ });
21753
21909
  await new Promise(resolve => setTimeout(resolve, delay));
21754
21910
  continue;
21755
21911
  }
21756
- // Log the error and rethrow
21757
- logger.error("Database error occurred", { error: String(error) });
21912
+ // Log structured error details and rethrow
21913
+ logger.error("Database updateMany operation failed", {
21914
+ operation: 'updateManyABTest',
21915
+ model: 'ABTest',
21916
+ error: String(error),
21917
+ isRetryable: isConnectionError,
21918
+ });
21758
21919
  throw error;
21759
21920
  }
21760
21921
  }
@@ -21812,6 +21973,31 @@ export const ABTest = {
21812
21973
  }
21813
21974
  catch (error) {
21814
21975
  lastError = error;
21976
+ // Check for constraint violations FIRST - these are NEVER retryable
21977
+ // (e.g., foreign key constraints preventing deletion)
21978
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
21979
+ error.message?.includes('violates unique constraint') ||
21980
+ error.message?.includes('violates foreign key constraint') ||
21981
+ error.message?.includes('unique constraint') ||
21982
+ error.message?.includes('23514') ||
21983
+ error.message?.includes('23505') ||
21984
+ error.message?.includes('23503') ||
21985
+ error.message?.includes('P2002') ||
21986
+ error.message?.includes('P2003') ||
21987
+ error.message?.includes('P2014');
21988
+ if (isConstraintViolation) {
21989
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
21990
+ logger.error("Non-retryable constraint violation in deleteOneABTest", {
21991
+ operation: 'deleteOneABTest',
21992
+ model: 'ABTest',
21993
+ error: String(error),
21994
+ recordId: props.id,
21995
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
21996
+ errorCategory: 'CONSTRAINT_VIOLATION',
21997
+ isRetryable: false,
21998
+ });
21999
+ throw error;
22000
+ }
21815
22001
  // Check if this is a database connection error that we should retry
21816
22002
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
21817
22003
  error.message?.includes('Cannot reach database server') ||
@@ -21821,12 +22007,24 @@ export const ABTest = {
21821
22007
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
21822
22008
  retryCount++;
21823
22009
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
21824
- logger.warn("Database connection error, retrying...");
22010
+ logger.warn("Database connection error in deleteOneABTest, retrying...", {
22011
+ operation: 'deleteOneABTest',
22012
+ model: 'ABTest',
22013
+ attempt: retryCount,
22014
+ maxRetries: MAX_RETRIES,
22015
+ recordId: props.id,
22016
+ });
21825
22017
  await new Promise(resolve => setTimeout(resolve, delay));
21826
22018
  continue;
21827
22019
  }
21828
- // Log the error and rethrow
21829
- logger.error("Database error occurred", { error: String(error) });
22020
+ // Log structured error details and rethrow
22021
+ logger.error("Database delete operation failed", {
22022
+ operation: 'deleteOneABTest',
22023
+ model: 'ABTest',
22024
+ error: String(error),
22025
+ recordId: props.id,
22026
+ isRetryable: isConnectionError,
22027
+ });
21830
22028
  throw error;
21831
22029
  }
21832
22030
  }
@@ -21901,12 +22099,22 @@ export const ABTest = {
21901
22099
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
21902
22100
  retryCount++;
21903
22101
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
21904
- logger.warn("Database connection error, retrying...");
22102
+ logger.warn("Database connection error in getABTest, retrying...", {
22103
+ operation: 'getABTest',
22104
+ model: 'ABTest',
22105
+ attempt: retryCount,
22106
+ maxRetries: MAX_RETRIES,
22107
+ });
21905
22108
  await new Promise(resolve => setTimeout(resolve, delay));
21906
22109
  continue;
21907
22110
  }
21908
- // Log the error and rethrow
21909
- logger.error("Database error occurred", { error: String(error) });
22111
+ // Log structured error details and rethrow
22112
+ logger.error("Database get operation failed", {
22113
+ operation: 'getABTest',
22114
+ model: 'ABTest',
22115
+ error: String(error),
22116
+ isRetryable: isConnectionError,
22117
+ });
21910
22118
  throw error;
21911
22119
  }
21912
22120
  }
@@ -21963,12 +22171,22 @@ export const ABTest = {
21963
22171
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
21964
22172
  retryCount++;
21965
22173
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
21966
- logger.warn("Database connection error, retrying...");
22174
+ logger.warn("Database connection error in getAllABTest, retrying...", {
22175
+ operation: 'getAllABTest',
22176
+ model: 'ABTest',
22177
+ attempt: retryCount,
22178
+ maxRetries: MAX_RETRIES,
22179
+ });
21967
22180
  await new Promise(resolve => setTimeout(resolve, delay));
21968
22181
  continue;
21969
22182
  }
21970
- // Log the error and rethrow
21971
- logger.error("Database error occurred", { error: String(error) });
22183
+ // Log structured error details and rethrow
22184
+ logger.error("Database getAll operation failed", {
22185
+ operation: 'getAllABTest',
22186
+ model: 'ABTest',
22187
+ error: String(error),
22188
+ isRetryable: isConnectionError,
22189
+ });
21972
22190
  throw error;
21973
22191
  }
21974
22192
  }
@@ -22050,12 +22268,22 @@ export const ABTest = {
22050
22268
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
22051
22269
  retryCount++;
22052
22270
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
22053
- logger.warn("Database connection error, retrying...");
22271
+ logger.warn("Database connection error in findManyABTest, retrying...", {
22272
+ operation: 'findManyABTest',
22273
+ model: 'ABTest',
22274
+ attempt: retryCount,
22275
+ maxRetries: MAX_RETRIES,
22276
+ });
22054
22277
  await new Promise(resolve => setTimeout(resolve, delay));
22055
22278
  continue;
22056
22279
  }
22057
- // Log the error and rethrow
22058
- logger.error("Database error occurred", { error: String(error) });
22280
+ // Log structured error details and rethrow
22281
+ logger.error("Database findMany operation failed", {
22282
+ operation: 'findManyABTest',
22283
+ model: 'ABTest',
22284
+ error: String(error),
22285
+ isRetryable: isConnectionError,
22286
+ });
22059
22287
  throw error;
22060
22288
  }
22061
22289
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Account.d.ts","sourceRoot":"","sources":["../../src/Account.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,+CAA+C,CAAC;AACvF,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU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