@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
@@ -1993,6 +1993,27 @@ export const ModelVersion = {
1993
1993
  }
1994
1994
  catch (error) {
1995
1995
  lastError = error;
1996
+ // Check for constraint violations FIRST - these are NEVER retryable
1997
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
1998
+ error.message?.includes('violates unique constraint') ||
1999
+ error.message?.includes('violates foreign key constraint') ||
2000
+ error.message?.includes('unique constraint') ||
2001
+ error.message?.includes('23514') ||
2002
+ error.message?.includes('23505') ||
2003
+ error.message?.includes('P2002') ||
2004
+ error.message?.includes('P2003');
2005
+ if (isConstraintViolation) {
2006
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
2007
+ logger.error("Non-retryable constraint violation in createOneModelVersion", {
2008
+ operation: 'createOneModelVersion',
2009
+ model: 'ModelVersion',
2010
+ error: String(error),
2011
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
2012
+ errorCategory: 'CONSTRAINT_VIOLATION',
2013
+ isRetryable: false,
2014
+ });
2015
+ throw error;
2016
+ }
1996
2017
  // Check if this is a database connection error that we should retry
1997
2018
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
1998
2019
  error.message?.includes('Cannot reach database server') ||
@@ -2002,12 +2023,22 @@ export const ModelVersion = {
2002
2023
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
2003
2024
  retryCount++;
2004
2025
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
2005
- logger.warn("Database connection error, retrying...");
2026
+ logger.warn("Database connection error in createOneModelVersion, retrying...", {
2027
+ operation: 'createOneModelVersion',
2028
+ model: 'ModelVersion',
2029
+ attempt: retryCount,
2030
+ maxRetries: MAX_RETRIES,
2031
+ });
2006
2032
  await new Promise(resolve => setTimeout(resolve, delay));
2007
2033
  continue;
2008
2034
  }
2009
- // Log the error and rethrow
2010
- logger.error("Database error occurred", { error: String(error) });
2035
+ // Log structured error details and rethrow
2036
+ logger.error("Database create operation failed", {
2037
+ operation: 'createOneModelVersion',
2038
+ model: 'ModelVersion',
2039
+ error: String(error),
2040
+ isRetryable: isConnectionError,
2041
+ });
2011
2042
  throw error;
2012
2043
  }
2013
2044
  }
@@ -2098,6 +2129,27 @@ export const ModelVersion = {
2098
2129
  }
2099
2130
  catch (error) {
2100
2131
  lastError = error;
2132
+ // Check for constraint violations FIRST - these are NEVER retryable
2133
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
2134
+ error.message?.includes('violates unique constraint') ||
2135
+ error.message?.includes('violates foreign key constraint') ||
2136
+ error.message?.includes('unique constraint') ||
2137
+ error.message?.includes('23514') ||
2138
+ error.message?.includes('23505') ||
2139
+ error.message?.includes('P2002') ||
2140
+ error.message?.includes('P2003');
2141
+ if (isConstraintViolation) {
2142
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
2143
+ logger.error("Non-retryable constraint violation in createManyModelVersion", {
2144
+ operation: 'createManyModelVersion',
2145
+ model: 'ModelVersion',
2146
+ error: String(error),
2147
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
2148
+ errorCategory: 'CONSTRAINT_VIOLATION',
2149
+ isRetryable: false,
2150
+ });
2151
+ throw error;
2152
+ }
2101
2153
  // Check if this is a database connection error that we should retry
2102
2154
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
2103
2155
  error.message?.includes('Cannot reach database server') ||
@@ -2107,12 +2159,22 @@ export const ModelVersion = {
2107
2159
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
2108
2160
  retryCount++;
2109
2161
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
2110
- logger.warn("Database connection error, retrying...");
2162
+ logger.warn("Database connection error in createManyModelVersion, retrying...", {
2163
+ operation: 'createManyModelVersion',
2164
+ model: 'ModelVersion',
2165
+ attempt: retryCount,
2166
+ maxRetries: MAX_RETRIES,
2167
+ });
2111
2168
  await new Promise(resolve => setTimeout(resolve, delay));
2112
2169
  continue;
2113
2170
  }
2114
- // Log the error and rethrow
2115
- logger.error("Database error occurred", { error: String(error) });
2171
+ // Log structured error details and rethrow
2172
+ logger.error("Database createMany operation failed", {
2173
+ operation: 'createManyModelVersion',
2174
+ model: 'ModelVersion',
2175
+ error: String(error),
2176
+ isRetryable: isConnectionError,
2177
+ });
2116
2178
  throw error;
2117
2179
  }
2118
2180
  }
@@ -9657,6 +9719,28 @@ export const ModelVersion = {
9657
9719
  }
9658
9720
  catch (error) {
9659
9721
  lastError = error;
9722
+ // Check for constraint violations FIRST - these are NEVER retryable
9723
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
9724
+ error.message?.includes('violates unique constraint') ||
9725
+ error.message?.includes('violates foreign key constraint') ||
9726
+ error.message?.includes('unique constraint') ||
9727
+ error.message?.includes('23514') ||
9728
+ error.message?.includes('23505') ||
9729
+ error.message?.includes('P2002') ||
9730
+ error.message?.includes('P2003');
9731
+ if (isConstraintViolation) {
9732
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
9733
+ logger.error("Non-retryable constraint violation in updateOneModelVersion", {
9734
+ operation: 'updateOneModelVersion',
9735
+ model: 'ModelVersion',
9736
+ error: String(error),
9737
+ recordId: props.id,
9738
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
9739
+ errorCategory: 'CONSTRAINT_VIOLATION',
9740
+ isRetryable: false,
9741
+ });
9742
+ throw error;
9743
+ }
9660
9744
  // Check if this is a database connection error that we should retry
9661
9745
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
9662
9746
  error.message?.includes('Cannot reach database server') ||
@@ -9666,12 +9750,24 @@ export const ModelVersion = {
9666
9750
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
9667
9751
  retryCount++;
9668
9752
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
9669
- logger.warn("Database connection error, retrying...");
9753
+ logger.warn("Database connection error in updateOneModelVersion, retrying...", {
9754
+ operation: 'updateOneModelVersion',
9755
+ model: 'ModelVersion',
9756
+ attempt: retryCount,
9757
+ maxRetries: MAX_RETRIES,
9758
+ recordId: props.id,
9759
+ });
9670
9760
  await new Promise(resolve => setTimeout(resolve, delay));
9671
9761
  continue;
9672
9762
  }
9673
- // Log the error and rethrow
9674
- logger.error("Database error occurred", { error: String(error) });
9763
+ // Log structured error details and rethrow
9764
+ logger.error("Database update operation failed", {
9765
+ operation: 'updateOneModelVersion',
9766
+ model: 'ModelVersion',
9767
+ error: String(error),
9768
+ recordId: props.id,
9769
+ isRetryable: isConnectionError,
9770
+ });
9675
9771
  throw error;
9676
9772
  }
9677
9773
  }
@@ -18980,6 +19076,28 @@ export const ModelVersion = {
18980
19076
  }
18981
19077
  catch (error) {
18982
19078
  lastError = error;
19079
+ // Check for constraint violations FIRST - these are NEVER retryable
19080
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
19081
+ error.message?.includes('violates unique constraint') ||
19082
+ error.message?.includes('violates foreign key constraint') ||
19083
+ error.message?.includes('unique constraint') ||
19084
+ error.message?.includes('23514') ||
19085
+ error.message?.includes('23505') ||
19086
+ error.message?.includes('P2002') ||
19087
+ error.message?.includes('P2003');
19088
+ if (isConstraintViolation) {
19089
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
19090
+ logger.error("Non-retryable constraint violation in upsertOneModelVersion", {
19091
+ operation: 'upsertOneModelVersion',
19092
+ model: 'ModelVersion',
19093
+ error: String(error),
19094
+ recordId: props.id,
19095
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
19096
+ errorCategory: 'CONSTRAINT_VIOLATION',
19097
+ isRetryable: false,
19098
+ });
19099
+ throw error;
19100
+ }
18983
19101
  // Check if this is a database connection error that we should retry
18984
19102
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
18985
19103
  error.message?.includes('Cannot reach database server') ||
@@ -18989,12 +19107,24 @@ export const ModelVersion = {
18989
19107
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
18990
19108
  retryCount++;
18991
19109
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
18992
- logger.warn("Database connection error, retrying...");
19110
+ logger.warn("Database connection error in upsertOneModelVersion, retrying...", {
19111
+ operation: 'upsertOneModelVersion',
19112
+ model: 'ModelVersion',
19113
+ attempt: retryCount,
19114
+ maxRetries: MAX_RETRIES,
19115
+ recordId: props.id,
19116
+ });
18993
19117
  await new Promise(resolve => setTimeout(resolve, delay));
18994
19118
  continue;
18995
19119
  }
18996
- // Log the error and rethrow
18997
- logger.error("Database error occurred", { error: String(error) });
19120
+ // Log structured error details and rethrow
19121
+ logger.error("Database upsert operation failed", {
19122
+ operation: 'upsertOneModelVersion',
19123
+ model: 'ModelVersion',
19124
+ error: String(error),
19125
+ recordId: props.id,
19126
+ isRetryable: isConnectionError,
19127
+ });
18998
19128
  throw error;
18999
19129
  }
19000
19130
  }
@@ -26539,6 +26669,27 @@ export const ModelVersion = {
26539
26669
  }
26540
26670
  catch (error) {
26541
26671
  lastError = error;
26672
+ // Check for constraint violations FIRST - these are NEVER retryable
26673
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
26674
+ error.message?.includes('violates unique constraint') ||
26675
+ error.message?.includes('violates foreign key constraint') ||
26676
+ error.message?.includes('unique constraint') ||
26677
+ error.message?.includes('23514') ||
26678
+ error.message?.includes('23505') ||
26679
+ error.message?.includes('P2002') ||
26680
+ error.message?.includes('P2003');
26681
+ if (isConstraintViolation) {
26682
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
26683
+ logger.error("Non-retryable constraint violation in updateManyModelVersion", {
26684
+ operation: 'updateManyModelVersion',
26685
+ model: 'ModelVersion',
26686
+ error: String(error),
26687
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
26688
+ errorCategory: 'CONSTRAINT_VIOLATION',
26689
+ isRetryable: false,
26690
+ });
26691
+ throw error;
26692
+ }
26542
26693
  // Check if this is a database connection error that we should retry
26543
26694
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
26544
26695
  error.message?.includes('Cannot reach database server') ||
@@ -26548,12 +26699,22 @@ export const ModelVersion = {
26548
26699
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
26549
26700
  retryCount++;
26550
26701
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
26551
- logger.warn("Database connection error, retrying...");
26702
+ logger.warn("Database connection error in updateManyModelVersion, retrying...", {
26703
+ operation: 'updateManyModelVersion',
26704
+ model: 'ModelVersion',
26705
+ attempt: retryCount,
26706
+ maxRetries: MAX_RETRIES,
26707
+ });
26552
26708
  await new Promise(resolve => setTimeout(resolve, delay));
26553
26709
  continue;
26554
26710
  }
26555
- // Log the error and rethrow
26556
- logger.error("Database error occurred", { error: String(error) });
26711
+ // Log structured error details and rethrow
26712
+ logger.error("Database updateMany operation failed", {
26713
+ operation: 'updateManyModelVersion',
26714
+ model: 'ModelVersion',
26715
+ error: String(error),
26716
+ isRetryable: isConnectionError,
26717
+ });
26557
26718
  throw error;
26558
26719
  }
26559
26720
  }
@@ -26611,6 +26772,31 @@ export const ModelVersion = {
26611
26772
  }
26612
26773
  catch (error) {
26613
26774
  lastError = error;
26775
+ // Check for constraint violations FIRST - these are NEVER retryable
26776
+ // (e.g., foreign key constraints preventing deletion)
26777
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
26778
+ error.message?.includes('violates unique constraint') ||
26779
+ error.message?.includes('violates foreign key constraint') ||
26780
+ error.message?.includes('unique constraint') ||
26781
+ error.message?.includes('23514') ||
26782
+ error.message?.includes('23505') ||
26783
+ error.message?.includes('23503') ||
26784
+ error.message?.includes('P2002') ||
26785
+ error.message?.includes('P2003') ||
26786
+ error.message?.includes('P2014');
26787
+ if (isConstraintViolation) {
26788
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
26789
+ logger.error("Non-retryable constraint violation in deleteOneModelVersion", {
26790
+ operation: 'deleteOneModelVersion',
26791
+ model: 'ModelVersion',
26792
+ error: String(error),
26793
+ recordId: props.id,
26794
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
26795
+ errorCategory: 'CONSTRAINT_VIOLATION',
26796
+ isRetryable: false,
26797
+ });
26798
+ throw error;
26799
+ }
26614
26800
  // Check if this is a database connection error that we should retry
26615
26801
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
26616
26802
  error.message?.includes('Cannot reach database server') ||
@@ -26620,12 +26806,24 @@ export const ModelVersion = {
26620
26806
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
26621
26807
  retryCount++;
26622
26808
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
26623
- logger.warn("Database connection error, retrying...");
26809
+ logger.warn("Database connection error in deleteOneModelVersion, retrying...", {
26810
+ operation: 'deleteOneModelVersion',
26811
+ model: 'ModelVersion',
26812
+ attempt: retryCount,
26813
+ maxRetries: MAX_RETRIES,
26814
+ recordId: props.id,
26815
+ });
26624
26816
  await new Promise(resolve => setTimeout(resolve, delay));
26625
26817
  continue;
26626
26818
  }
26627
- // Log the error and rethrow
26628
- logger.error("Database error occurred", { error: String(error) });
26819
+ // Log structured error details and rethrow
26820
+ logger.error("Database delete operation failed", {
26821
+ operation: 'deleteOneModelVersion',
26822
+ model: 'ModelVersion',
26823
+ error: String(error),
26824
+ recordId: props.id,
26825
+ isRetryable: isConnectionError,
26826
+ });
26629
26827
  throw error;
26630
26828
  }
26631
26829
  }
@@ -26691,12 +26889,22 @@ export const ModelVersion = {
26691
26889
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
26692
26890
  retryCount++;
26693
26891
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
26694
- logger.warn("Database connection error, retrying...");
26892
+ logger.warn("Database connection error in getModelVersion, retrying...", {
26893
+ operation: 'getModelVersion',
26894
+ model: 'ModelVersion',
26895
+ attempt: retryCount,
26896
+ maxRetries: MAX_RETRIES,
26897
+ });
26695
26898
  await new Promise(resolve => setTimeout(resolve, delay));
26696
26899
  continue;
26697
26900
  }
26698
- // Log the error and rethrow
26699
- logger.error("Database error occurred", { error: String(error) });
26901
+ // Log structured error details and rethrow
26902
+ logger.error("Database get operation failed", {
26903
+ operation: 'getModelVersion',
26904
+ model: 'ModelVersion',
26905
+ error: String(error),
26906
+ isRetryable: isConnectionError,
26907
+ });
26700
26908
  throw error;
26701
26909
  }
26702
26910
  }
@@ -26753,12 +26961,22 @@ export const ModelVersion = {
26753
26961
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
26754
26962
  retryCount++;
26755
26963
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
26756
- logger.warn("Database connection error, retrying...");
26964
+ logger.warn("Database connection error in getAllModelVersion, retrying...", {
26965
+ operation: 'getAllModelVersion',
26966
+ model: 'ModelVersion',
26967
+ attempt: retryCount,
26968
+ maxRetries: MAX_RETRIES,
26969
+ });
26757
26970
  await new Promise(resolve => setTimeout(resolve, delay));
26758
26971
  continue;
26759
26972
  }
26760
- // Log the error and rethrow
26761
- logger.error("Database error occurred", { error: String(error) });
26973
+ // Log structured error details and rethrow
26974
+ logger.error("Database getAll operation failed", {
26975
+ operation: 'getAllModelVersion',
26976
+ model: 'ModelVersion',
26977
+ error: String(error),
26978
+ isRetryable: isConnectionError,
26979
+ });
26762
26980
  throw error;
26763
26981
  }
26764
26982
  }
@@ -26831,12 +27049,22 @@ export const ModelVersion = {
26831
27049
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
26832
27050
  retryCount++;
26833
27051
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
26834
- logger.warn("Database connection error, retrying...");
27052
+ logger.warn("Database connection error in findManyModelVersion, retrying...", {
27053
+ operation: 'findManyModelVersion',
27054
+ model: 'ModelVersion',
27055
+ attempt: retryCount,
27056
+ maxRetries: MAX_RETRIES,
27057
+ });
26835
27058
  await new Promise(resolve => setTimeout(resolve, delay));
26836
27059
  continue;
26837
27060
  }
26838
- // Log the error and rethrow
26839
- logger.error("Database error occurred", { error: String(error) });
27061
+ // Log structured error details and rethrow
27062
+ logger.error("Database findMany operation failed", {
27063
+ operation: 'findManyModelVersion',
27064
+ model: 'ModelVersion',
27065
+ error: String(error),
27066
+ isRetryable: isConnectionError,
27067
+ });
26840
27068
  throw error;
26841
27069
  }
26842
27070
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ModelVersionArt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