@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/ModelVersion.cjs CHANGED
@@ -182,7 +182,7 @@ exports.ModelVersion = {
182
182
  * @returns The created ModelVersion or null.
183
183
  */
184
184
  async create(props, globalClient) {
185
- var _a, _b, _c, _d, _e;
185
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
186
186
  // Maximum number of retries for database connection issues
187
187
  const MAX_RETRIES = 3;
188
188
  let retryCount = 0;
@@ -1997,21 +1997,52 @@ exports.ModelVersion = {
1997
1997
  }
1998
1998
  catch (error) {
1999
1999
  lastError = error;
2000
+ // Check for constraint violations FIRST - these are NEVER retryable
2001
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
2002
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
2003
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
2004
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
2005
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
2006
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
2007
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
2008
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
2009
+ if (isConstraintViolation) {
2010
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
2011
+ logger_1.logger.error("Non-retryable constraint violation in createOneModelVersion", {
2012
+ operation: 'createOneModelVersion',
2013
+ model: 'ModelVersion',
2014
+ error: String(error),
2015
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
2016
+ errorCategory: 'CONSTRAINT_VIOLATION',
2017
+ isRetryable: false,
2018
+ });
2019
+ throw error;
2020
+ }
2000
2021
  // Check if this is a database connection error that we should retry
2001
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
2002
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
2003
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
2004
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
2005
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
2022
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
2023
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
2024
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
2025
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
2026
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
2006
2027
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
2007
2028
  retryCount++;
2008
2029
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
2009
- logger_1.logger.warn("Database connection error, retrying...");
2030
+ logger_1.logger.warn("Database connection error in createOneModelVersion, retrying...", {
2031
+ operation: 'createOneModelVersion',
2032
+ model: 'ModelVersion',
2033
+ attempt: retryCount,
2034
+ maxRetries: MAX_RETRIES,
2035
+ });
2010
2036
  await new Promise(resolve => setTimeout(resolve, delay));
2011
2037
  continue;
2012
2038
  }
2013
- // Log the error and rethrow
2014
- logger_1.logger.error("Database error occurred", { error: String(error) });
2039
+ // Log structured error details and rethrow
2040
+ logger_1.logger.error("Database create operation failed", {
2041
+ operation: 'createOneModelVersion',
2042
+ model: 'ModelVersion',
2043
+ error: String(error),
2044
+ isRetryable: isConnectionError,
2045
+ });
2015
2046
  throw error;
2016
2047
  }
2017
2048
  }
@@ -2026,7 +2057,7 @@ exports.ModelVersion = {
2026
2057
  * @returns The count of created records or null.
2027
2058
  */
2028
2059
  async createMany(props, globalClient) {
2029
- var _a, _b, _c, _d, _e;
2060
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
2030
2061
  // Maximum number of retries for database connection issues
2031
2062
  const MAX_RETRIES = 3;
2032
2063
  let retryCount = 0;
@@ -2103,21 +2134,52 @@ exports.ModelVersion = {
2103
2134
  }
2104
2135
  catch (error) {
2105
2136
  lastError = error;
2137
+ // Check for constraint violations FIRST - these are NEVER retryable
2138
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
2139
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
2140
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
2141
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
2142
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
2143
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
2144
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
2145
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
2146
+ if (isConstraintViolation) {
2147
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
2148
+ logger_1.logger.error("Non-retryable constraint violation in createManyModelVersion", {
2149
+ operation: 'createManyModelVersion',
2150
+ model: 'ModelVersion',
2151
+ error: String(error),
2152
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
2153
+ errorCategory: 'CONSTRAINT_VIOLATION',
2154
+ isRetryable: false,
2155
+ });
2156
+ throw error;
2157
+ }
2106
2158
  // Check if this is a database connection error that we should retry
2107
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
2108
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
2109
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
2110
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
2111
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
2159
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
2160
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
2161
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
2162
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
2163
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
2112
2164
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
2113
2165
  retryCount++;
2114
2166
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
2115
- logger_1.logger.warn("Database connection error, retrying...");
2167
+ logger_1.logger.warn("Database connection error in createManyModelVersion, retrying...", {
2168
+ operation: 'createManyModelVersion',
2169
+ model: 'ModelVersion',
2170
+ attempt: retryCount,
2171
+ maxRetries: MAX_RETRIES,
2172
+ });
2116
2173
  await new Promise(resolve => setTimeout(resolve, delay));
2117
2174
  continue;
2118
2175
  }
2119
- // Log the error and rethrow
2120
- logger_1.logger.error("Database error occurred", { error: String(error) });
2176
+ // Log structured error details and rethrow
2177
+ logger_1.logger.error("Database createMany operation failed", {
2178
+ operation: 'createManyModelVersion',
2179
+ model: 'ModelVersion',
2180
+ error: String(error),
2181
+ isRetryable: isConnectionError,
2182
+ });
2121
2183
  throw error;
2122
2184
  }
2123
2185
  }
@@ -2132,7 +2194,7 @@ exports.ModelVersion = {
2132
2194
  * @returns The updated ModelVersion or null.
2133
2195
  */
2134
2196
  async update(props, globalClient) {
2135
- var _a, _b, _c, _d, _e;
2197
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
2136
2198
  // Maximum number of retries for database connection issues
2137
2199
  const MAX_RETRIES = 3;
2138
2200
  let retryCount = 0;
@@ -9663,21 +9725,55 @@ exports.ModelVersion = {
9663
9725
  }
9664
9726
  catch (error) {
9665
9727
  lastError = error;
9728
+ // Check for constraint violations FIRST - these are NEVER retryable
9729
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
9730
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
9731
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
9732
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
9733
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
9734
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
9735
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
9736
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
9737
+ if (isConstraintViolation) {
9738
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
9739
+ logger_1.logger.error("Non-retryable constraint violation in updateOneModelVersion", {
9740
+ operation: 'updateOneModelVersion',
9741
+ model: 'ModelVersion',
9742
+ error: String(error),
9743
+ recordId: props.id,
9744
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
9745
+ errorCategory: 'CONSTRAINT_VIOLATION',
9746
+ isRetryable: false,
9747
+ });
9748
+ throw error;
9749
+ }
9666
9750
  // Check if this is a database connection error that we should retry
9667
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
9668
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
9669
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
9670
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
9671
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
9751
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
9752
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
9753
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
9754
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
9755
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
9672
9756
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
9673
9757
  retryCount++;
9674
9758
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
9675
- logger_1.logger.warn("Database connection error, retrying...");
9759
+ logger_1.logger.warn("Database connection error in updateOneModelVersion, retrying...", {
9760
+ operation: 'updateOneModelVersion',
9761
+ model: 'ModelVersion',
9762
+ attempt: retryCount,
9763
+ maxRetries: MAX_RETRIES,
9764
+ recordId: props.id,
9765
+ });
9676
9766
  await new Promise(resolve => setTimeout(resolve, delay));
9677
9767
  continue;
9678
9768
  }
9679
- // Log the error and rethrow
9680
- logger_1.logger.error("Database error occurred", { error: String(error) });
9769
+ // Log structured error details and rethrow
9770
+ logger_1.logger.error("Database update operation failed", {
9771
+ operation: 'updateOneModelVersion',
9772
+ model: 'ModelVersion',
9773
+ error: String(error),
9774
+ recordId: props.id,
9775
+ isRetryable: isConnectionError,
9776
+ });
9681
9777
  throw error;
9682
9778
  }
9683
9779
  }
@@ -9692,7 +9788,7 @@ exports.ModelVersion = {
9692
9788
  * @returns The updated ModelVersion or null.
9693
9789
  */
9694
9790
  async upsert(props, globalClient) {
9695
- var _a, _b, _c, _d, _e;
9791
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
9696
9792
  // Maximum number of retries for database connection issues
9697
9793
  const MAX_RETRIES = 3;
9698
9794
  let retryCount = 0;
@@ -18987,21 +19083,55 @@ exports.ModelVersion = {
18987
19083
  }
18988
19084
  catch (error) {
18989
19085
  lastError = error;
19086
+ // Check for constraint violations FIRST - these are NEVER retryable
19087
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
19088
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
19089
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
19090
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
19091
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
19092
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
19093
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
19094
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
19095
+ if (isConstraintViolation) {
19096
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
19097
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneModelVersion", {
19098
+ operation: 'upsertOneModelVersion',
19099
+ model: 'ModelVersion',
19100
+ error: String(error),
19101
+ recordId: props.id,
19102
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
19103
+ errorCategory: 'CONSTRAINT_VIOLATION',
19104
+ isRetryable: false,
19105
+ });
19106
+ throw error;
19107
+ }
18990
19108
  // Check if this is a database connection error that we should retry
18991
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
18992
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
18993
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
18994
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
18995
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
19109
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
19110
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
19111
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
19112
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
19113
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
18996
19114
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
18997
19115
  retryCount++;
18998
19116
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
18999
- logger_1.logger.warn("Database connection error, retrying...");
19117
+ logger_1.logger.warn("Database connection error in upsertOneModelVersion, retrying...", {
19118
+ operation: 'upsertOneModelVersion',
19119
+ model: 'ModelVersion',
19120
+ attempt: retryCount,
19121
+ maxRetries: MAX_RETRIES,
19122
+ recordId: props.id,
19123
+ });
19000
19124
  await new Promise(resolve => setTimeout(resolve, delay));
19001
19125
  continue;
19002
19126
  }
19003
- // Log the error and rethrow
19004
- logger_1.logger.error("Database error occurred", { error: String(error) });
19127
+ // Log structured error details and rethrow
19128
+ logger_1.logger.error("Database upsert operation failed", {
19129
+ operation: 'upsertOneModelVersion',
19130
+ model: 'ModelVersion',
19131
+ error: String(error),
19132
+ recordId: props.id,
19133
+ isRetryable: isConnectionError,
19134
+ });
19005
19135
  throw error;
19006
19136
  }
19007
19137
  }
@@ -19016,7 +19146,7 @@ exports.ModelVersion = {
19016
19146
  * @returns The count of created records or null.
19017
19147
  */
19018
19148
  async updateMany(props, globalClient) {
19019
- var _a, _b, _c, _d, _e;
19149
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
19020
19150
  // Maximum number of retries for database connection issues
19021
19151
  const MAX_RETRIES = 3;
19022
19152
  let retryCount = 0;
@@ -26547,21 +26677,52 @@ exports.ModelVersion = {
26547
26677
  }
26548
26678
  catch (error) {
26549
26679
  lastError = error;
26680
+ // Check for constraint violations FIRST - these are NEVER retryable
26681
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
26682
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
26683
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
26684
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
26685
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
26686
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
26687
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
26688
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
26689
+ if (isConstraintViolation) {
26690
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
26691
+ logger_1.logger.error("Non-retryable constraint violation in updateManyModelVersion", {
26692
+ operation: 'updateManyModelVersion',
26693
+ model: 'ModelVersion',
26694
+ error: String(error),
26695
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
26696
+ errorCategory: 'CONSTRAINT_VIOLATION',
26697
+ isRetryable: false,
26698
+ });
26699
+ throw error;
26700
+ }
26550
26701
  // Check if this is a database connection error that we should retry
26551
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
26552
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
26553
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
26554
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
26555
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
26702
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
26703
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
26704
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
26705
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
26706
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
26556
26707
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
26557
26708
  retryCount++;
26558
26709
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
26559
- logger_1.logger.warn("Database connection error, retrying...");
26710
+ logger_1.logger.warn("Database connection error in updateManyModelVersion, retrying...", {
26711
+ operation: 'updateManyModelVersion',
26712
+ model: 'ModelVersion',
26713
+ attempt: retryCount,
26714
+ maxRetries: MAX_RETRIES,
26715
+ });
26560
26716
  await new Promise(resolve => setTimeout(resolve, delay));
26561
26717
  continue;
26562
26718
  }
26563
- // Log the error and rethrow
26564
- logger_1.logger.error("Database error occurred", { error: String(error) });
26719
+ // Log structured error details and rethrow
26720
+ logger_1.logger.error("Database updateMany operation failed", {
26721
+ operation: 'updateManyModelVersion',
26722
+ model: 'ModelVersion',
26723
+ error: String(error),
26724
+ isRetryable: isConnectionError,
26725
+ });
26565
26726
  throw error;
26566
26727
  }
26567
26728
  }
@@ -26576,7 +26737,7 @@ exports.ModelVersion = {
26576
26737
  * @returns The deleted ModelVersion or null.
26577
26738
  */
26578
26739
  async delete(props, globalClient) {
26579
- var _a, _b, _c, _d, _e;
26740
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
26580
26741
  // Maximum number of retries for database connection issues
26581
26742
  const MAX_RETRIES = 3;
26582
26743
  let retryCount = 0;
@@ -26620,21 +26781,58 @@ exports.ModelVersion = {
26620
26781
  }
26621
26782
  catch (error) {
26622
26783
  lastError = error;
26784
+ // Check for constraint violations FIRST - these are NEVER retryable
26785
+ // (e.g., foreign key constraints preventing deletion)
26786
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
26787
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
26788
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
26789
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
26790
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
26791
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
26792
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
26793
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
26794
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
26795
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
26796
+ if (isConstraintViolation) {
26797
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
26798
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneModelVersion", {
26799
+ operation: 'deleteOneModelVersion',
26800
+ model: 'ModelVersion',
26801
+ error: String(error),
26802
+ recordId: props.id,
26803
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
26804
+ errorCategory: 'CONSTRAINT_VIOLATION',
26805
+ isRetryable: false,
26806
+ });
26807
+ throw error;
26808
+ }
26623
26809
  // Check if this is a database connection error that we should retry
26624
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
26625
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
26626
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
26627
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
26628
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
26810
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
26811
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
26812
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
26813
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
26814
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
26629
26815
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
26630
26816
  retryCount++;
26631
26817
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
26632
- logger_1.logger.warn("Database connection error, retrying...");
26818
+ logger_1.logger.warn("Database connection error in deleteOneModelVersion, retrying...", {
26819
+ operation: 'deleteOneModelVersion',
26820
+ model: 'ModelVersion',
26821
+ attempt: retryCount,
26822
+ maxRetries: MAX_RETRIES,
26823
+ recordId: props.id,
26824
+ });
26633
26825
  await new Promise(resolve => setTimeout(resolve, delay));
26634
26826
  continue;
26635
26827
  }
26636
- // Log the error and rethrow
26637
- logger_1.logger.error("Database error occurred", { error: String(error) });
26828
+ // Log structured error details and rethrow
26829
+ logger_1.logger.error("Database delete operation failed", {
26830
+ operation: 'deleteOneModelVersion',
26831
+ model: 'ModelVersion',
26832
+ error: String(error),
26833
+ recordId: props.id,
26834
+ isRetryable: isConnectionError,
26835
+ });
26638
26836
  throw error;
26639
26837
  }
26640
26838
  }
@@ -26701,12 +26899,22 @@ exports.ModelVersion = {
26701
26899
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
26702
26900
  retryCount++;
26703
26901
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
26704
- logger_1.logger.warn("Database connection error, retrying...");
26902
+ logger_1.logger.warn("Database connection error in getModelVersion, retrying...", {
26903
+ operation: 'getModelVersion',
26904
+ model: 'ModelVersion',
26905
+ attempt: retryCount,
26906
+ maxRetries: MAX_RETRIES,
26907
+ });
26705
26908
  await new Promise(resolve => setTimeout(resolve, delay));
26706
26909
  continue;
26707
26910
  }
26708
- // Log the error and rethrow
26709
- logger_1.logger.error("Database error occurred", { error: String(error) });
26911
+ // Log structured error details and rethrow
26912
+ logger_1.logger.error("Database get operation failed", {
26913
+ operation: 'getModelVersion',
26914
+ model: 'ModelVersion',
26915
+ error: String(error),
26916
+ isRetryable: isConnectionError,
26917
+ });
26710
26918
  throw error;
26711
26919
  }
26712
26920
  }
@@ -26764,12 +26972,22 @@ exports.ModelVersion = {
26764
26972
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
26765
26973
  retryCount++;
26766
26974
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
26767
- logger_1.logger.warn("Database connection error, retrying...");
26975
+ logger_1.logger.warn("Database connection error in getAllModelVersion, retrying...", {
26976
+ operation: 'getAllModelVersion',
26977
+ model: 'ModelVersion',
26978
+ attempt: retryCount,
26979
+ maxRetries: MAX_RETRIES,
26980
+ });
26768
26981
  await new Promise(resolve => setTimeout(resolve, delay));
26769
26982
  continue;
26770
26983
  }
26771
- // Log the error and rethrow
26772
- logger_1.logger.error("Database error occurred", { error: String(error) });
26984
+ // Log structured error details and rethrow
26985
+ logger_1.logger.error("Database getAll operation failed", {
26986
+ operation: 'getAllModelVersion',
26987
+ model: 'ModelVersion',
26988
+ error: String(error),
26989
+ isRetryable: isConnectionError,
26990
+ });
26773
26991
  throw error;
26774
26992
  }
26775
26993
  }
@@ -26843,12 +27061,22 @@ exports.ModelVersion = {
26843
27061
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
26844
27062
  retryCount++;
26845
27063
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
26846
- logger_1.logger.warn("Database connection error, retrying...");
27064
+ logger_1.logger.warn("Database connection error in findManyModelVersion, retrying...", {
27065
+ operation: 'findManyModelVersion',
27066
+ model: 'ModelVersion',
27067
+ attempt: retryCount,
27068
+ maxRetries: MAX_RETRIES,
27069
+ });
26847
27070
  await new Promise(resolve => setTimeout(resolve, delay));
26848
27071
  continue;
26849
27072
  }
26850
- // Log the error and rethrow
26851
- logger_1.logger.error("Database error occurred", { error: String(error) });
27073
+ // Log structured error details and rethrow
27074
+ logger_1.logger.error("Database findMany operation failed", {
27075
+ operation: 'findManyModelVersion',
27076
+ model: 'ModelVersion',
27077
+ error: String(error),
27078
+ isRetryable: isConnectionError,
27079
+ });
26852
27080
  throw error;
26853
27081
  }
26854
27082
  }