@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
@@ -50,7 +50,7 @@ exports.TradeAuditEvent = {
50
50
  * @returns The created TradeAuditEvent or null.
51
51
  */
52
52
  async create(props, globalClient) {
53
- var _a, _b, _c, _d, _e;
53
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
54
54
  // Maximum number of retries for database connection issues
55
55
  const MAX_RETRIES = 3;
56
56
  let retryCount = 0;
@@ -116,21 +116,52 @@ exports.TradeAuditEvent = {
116
116
  }
117
117
  catch (error) {
118
118
  lastError = error;
119
+ // Check for constraint violations FIRST - these are NEVER retryable
120
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
121
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
122
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
123
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
124
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
125
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
126
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
127
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
128
+ if (isConstraintViolation) {
129
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
130
+ logger_1.logger.error("Non-retryable constraint violation in createOneTradeAuditEvent", {
131
+ operation: 'createOneTradeAuditEvent',
132
+ model: 'TradeAuditEvent',
133
+ error: String(error),
134
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
135
+ errorCategory: 'CONSTRAINT_VIOLATION',
136
+ isRetryable: false,
137
+ });
138
+ throw error;
139
+ }
119
140
  // Check if this is a database connection error that we should retry
120
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
121
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
122
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
123
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
124
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
141
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
142
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
143
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
144
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
145
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
125
146
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
126
147
  retryCount++;
127
148
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
128
- logger_1.logger.warn("Database connection error, retrying...");
149
+ logger_1.logger.warn("Database connection error in createOneTradeAuditEvent, retrying...", {
150
+ operation: 'createOneTradeAuditEvent',
151
+ model: 'TradeAuditEvent',
152
+ attempt: retryCount,
153
+ maxRetries: MAX_RETRIES,
154
+ });
129
155
  await new Promise(resolve => setTimeout(resolve, delay));
130
156
  continue;
131
157
  }
132
- // Log the error and rethrow
133
- logger_1.logger.error("Database error occurred", { error: String(error) });
158
+ // Log structured error details and rethrow
159
+ logger_1.logger.error("Database create operation failed", {
160
+ operation: 'createOneTradeAuditEvent',
161
+ model: 'TradeAuditEvent',
162
+ error: String(error),
163
+ isRetryable: isConnectionError,
164
+ });
134
165
  throw error;
135
166
  }
136
167
  }
@@ -145,7 +176,7 @@ exports.TradeAuditEvent = {
145
176
  * @returns The count of created records or null.
146
177
  */
147
178
  async createMany(props, globalClient) {
148
- var _a, _b, _c, _d, _e;
179
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
149
180
  // Maximum number of retries for database connection issues
150
181
  const MAX_RETRIES = 3;
151
182
  let retryCount = 0;
@@ -210,21 +241,52 @@ exports.TradeAuditEvent = {
210
241
  }
211
242
  catch (error) {
212
243
  lastError = error;
244
+ // Check for constraint violations FIRST - these are NEVER retryable
245
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
246
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
247
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
248
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
249
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
250
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
251
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
252
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
253
+ if (isConstraintViolation) {
254
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
255
+ logger_1.logger.error("Non-retryable constraint violation in createManyTradeAuditEvent", {
256
+ operation: 'createManyTradeAuditEvent',
257
+ model: 'TradeAuditEvent',
258
+ error: String(error),
259
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
260
+ errorCategory: 'CONSTRAINT_VIOLATION',
261
+ isRetryable: false,
262
+ });
263
+ throw error;
264
+ }
213
265
  // Check if this is a database connection error that we should retry
214
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
215
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
216
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
217
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
218
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
266
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
267
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
268
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
269
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
270
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
219
271
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
220
272
  retryCount++;
221
273
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
222
- logger_1.logger.warn("Database connection error, retrying...");
274
+ logger_1.logger.warn("Database connection error in createManyTradeAuditEvent, retrying...", {
275
+ operation: 'createManyTradeAuditEvent',
276
+ model: 'TradeAuditEvent',
277
+ attempt: retryCount,
278
+ maxRetries: MAX_RETRIES,
279
+ });
223
280
  await new Promise(resolve => setTimeout(resolve, delay));
224
281
  continue;
225
282
  }
226
- // Log the error and rethrow
227
- logger_1.logger.error("Database error occurred", { error: String(error) });
283
+ // Log structured error details and rethrow
284
+ logger_1.logger.error("Database createMany operation failed", {
285
+ operation: 'createManyTradeAuditEvent',
286
+ model: 'TradeAuditEvent',
287
+ error: String(error),
288
+ isRetryable: isConnectionError,
289
+ });
228
290
  throw error;
229
291
  }
230
292
  }
@@ -239,7 +301,7 @@ exports.TradeAuditEvent = {
239
301
  * @returns The updated TradeAuditEvent or null.
240
302
  */
241
303
  async update(props, globalClient) {
242
- var _a, _b, _c, _d, _e;
304
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
243
305
  // Maximum number of retries for database connection issues
244
306
  const MAX_RETRIES = 3;
245
307
  let retryCount = 0;
@@ -382,21 +444,55 @@ exports.TradeAuditEvent = {
382
444
  }
383
445
  catch (error) {
384
446
  lastError = error;
447
+ // Check for constraint violations FIRST - these are NEVER retryable
448
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
449
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
450
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
451
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
452
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
453
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
454
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
455
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
456
+ if (isConstraintViolation) {
457
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
458
+ logger_1.logger.error("Non-retryable constraint violation in updateOneTradeAuditEvent", {
459
+ operation: 'updateOneTradeAuditEvent',
460
+ model: 'TradeAuditEvent',
461
+ error: String(error),
462
+ recordId: props.id,
463
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
464
+ errorCategory: 'CONSTRAINT_VIOLATION',
465
+ isRetryable: false,
466
+ });
467
+ throw error;
468
+ }
385
469
  // Check if this is a database connection error that we should retry
386
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
387
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
388
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
389
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
390
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
470
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
471
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
472
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
473
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
474
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
391
475
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
392
476
  retryCount++;
393
477
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
394
- logger_1.logger.warn("Database connection error, retrying...");
478
+ logger_1.logger.warn("Database connection error in updateOneTradeAuditEvent, retrying...", {
479
+ operation: 'updateOneTradeAuditEvent',
480
+ model: 'TradeAuditEvent',
481
+ attempt: retryCount,
482
+ maxRetries: MAX_RETRIES,
483
+ recordId: props.id,
484
+ });
395
485
  await new Promise(resolve => setTimeout(resolve, delay));
396
486
  continue;
397
487
  }
398
- // Log the error and rethrow
399
- logger_1.logger.error("Database error occurred", { error: String(error) });
488
+ // Log structured error details and rethrow
489
+ logger_1.logger.error("Database update operation failed", {
490
+ operation: 'updateOneTradeAuditEvent',
491
+ model: 'TradeAuditEvent',
492
+ error: String(error),
493
+ recordId: props.id,
494
+ isRetryable: isConnectionError,
495
+ });
400
496
  throw error;
401
497
  }
402
498
  }
@@ -411,7 +507,7 @@ exports.TradeAuditEvent = {
411
507
  * @returns The updated TradeAuditEvent or null.
412
508
  */
413
509
  async upsert(props, globalClient) {
414
- var _a, _b, _c, _d, _e;
510
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
415
511
  // Maximum number of retries for database connection issues
416
512
  const MAX_RETRIES = 3;
417
513
  let retryCount = 0;
@@ -572,21 +668,55 @@ exports.TradeAuditEvent = {
572
668
  }
573
669
  catch (error) {
574
670
  lastError = error;
671
+ // Check for constraint violations FIRST - these are NEVER retryable
672
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
673
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
674
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
675
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
676
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
677
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
678
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
679
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
680
+ if (isConstraintViolation) {
681
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
682
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneTradeAuditEvent", {
683
+ operation: 'upsertOneTradeAuditEvent',
684
+ model: 'TradeAuditEvent',
685
+ error: String(error),
686
+ recordId: props.id,
687
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
688
+ errorCategory: 'CONSTRAINT_VIOLATION',
689
+ isRetryable: false,
690
+ });
691
+ throw error;
692
+ }
575
693
  // Check if this is a database connection error that we should retry
576
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
577
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
578
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
579
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
580
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
694
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
695
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
696
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
697
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
698
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
581
699
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
582
700
  retryCount++;
583
701
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
584
- logger_1.logger.warn("Database connection error, retrying...");
702
+ logger_1.logger.warn("Database connection error in upsertOneTradeAuditEvent, retrying...", {
703
+ operation: 'upsertOneTradeAuditEvent',
704
+ model: 'TradeAuditEvent',
705
+ attempt: retryCount,
706
+ maxRetries: MAX_RETRIES,
707
+ recordId: props.id,
708
+ });
585
709
  await new Promise(resolve => setTimeout(resolve, delay));
586
710
  continue;
587
711
  }
588
- // Log the error and rethrow
589
- logger_1.logger.error("Database error occurred", { error: String(error) });
712
+ // Log structured error details and rethrow
713
+ logger_1.logger.error("Database upsert operation failed", {
714
+ operation: 'upsertOneTradeAuditEvent',
715
+ model: 'TradeAuditEvent',
716
+ error: String(error),
717
+ recordId: props.id,
718
+ isRetryable: isConnectionError,
719
+ });
590
720
  throw error;
591
721
  }
592
722
  }
@@ -601,7 +731,7 @@ exports.TradeAuditEvent = {
601
731
  * @returns The count of created records or null.
602
732
  */
603
733
  async updateMany(props, globalClient) {
604
- var _a, _b, _c, _d, _e;
734
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
605
735
  // Maximum number of retries for database connection issues
606
736
  const MAX_RETRIES = 3;
607
737
  let retryCount = 0;
@@ -744,21 +874,52 @@ exports.TradeAuditEvent = {
744
874
  }
745
875
  catch (error) {
746
876
  lastError = error;
877
+ // Check for constraint violations FIRST - these are NEVER retryable
878
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
879
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
880
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
881
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
882
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
883
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
884
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
885
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
886
+ if (isConstraintViolation) {
887
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
888
+ logger_1.logger.error("Non-retryable constraint violation in updateManyTradeAuditEvent", {
889
+ operation: 'updateManyTradeAuditEvent',
890
+ model: 'TradeAuditEvent',
891
+ error: String(error),
892
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
893
+ errorCategory: 'CONSTRAINT_VIOLATION',
894
+ isRetryable: false,
895
+ });
896
+ throw error;
897
+ }
747
898
  // Check if this is a database connection error that we should retry
748
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
749
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
750
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
751
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
752
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
899
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
900
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
901
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
902
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
903
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
753
904
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
754
905
  retryCount++;
755
906
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
756
- logger_1.logger.warn("Database connection error, retrying...");
907
+ logger_1.logger.warn("Database connection error in updateManyTradeAuditEvent, retrying...", {
908
+ operation: 'updateManyTradeAuditEvent',
909
+ model: 'TradeAuditEvent',
910
+ attempt: retryCount,
911
+ maxRetries: MAX_RETRIES,
912
+ });
757
913
  await new Promise(resolve => setTimeout(resolve, delay));
758
914
  continue;
759
915
  }
760
- // Log the error and rethrow
761
- logger_1.logger.error("Database error occurred", { error: String(error) });
916
+ // Log structured error details and rethrow
917
+ logger_1.logger.error("Database updateMany operation failed", {
918
+ operation: 'updateManyTradeAuditEvent',
919
+ model: 'TradeAuditEvent',
920
+ error: String(error),
921
+ isRetryable: isConnectionError,
922
+ });
762
923
  throw error;
763
924
  }
764
925
  }
@@ -773,7 +934,7 @@ exports.TradeAuditEvent = {
773
934
  * @returns The deleted TradeAuditEvent or null.
774
935
  */
775
936
  async delete(props, globalClient) {
776
- var _a, _b, _c, _d, _e;
937
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
777
938
  // Maximum number of retries for database connection issues
778
939
  const MAX_RETRIES = 3;
779
940
  let retryCount = 0;
@@ -817,21 +978,58 @@ exports.TradeAuditEvent = {
817
978
  }
818
979
  catch (error) {
819
980
  lastError = error;
981
+ // Check for constraint violations FIRST - these are NEVER retryable
982
+ // (e.g., foreign key constraints preventing deletion)
983
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
984
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
985
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
986
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
987
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
988
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
989
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
990
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
991
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
992
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
993
+ if (isConstraintViolation) {
994
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
995
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneTradeAuditEvent", {
996
+ operation: 'deleteOneTradeAuditEvent',
997
+ model: 'TradeAuditEvent',
998
+ error: String(error),
999
+ recordId: props.id,
1000
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1001
+ errorCategory: 'CONSTRAINT_VIOLATION',
1002
+ isRetryable: false,
1003
+ });
1004
+ throw error;
1005
+ }
820
1006
  // Check if this is a database connection error that we should retry
821
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
822
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
823
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
824
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
825
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
1007
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
1008
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
1009
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
1010
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
1011
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
826
1012
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
827
1013
  retryCount++;
828
1014
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
829
- logger_1.logger.warn("Database connection error, retrying...");
1015
+ logger_1.logger.warn("Database connection error in deleteOneTradeAuditEvent, retrying...", {
1016
+ operation: 'deleteOneTradeAuditEvent',
1017
+ model: 'TradeAuditEvent',
1018
+ attempt: retryCount,
1019
+ maxRetries: MAX_RETRIES,
1020
+ recordId: props.id,
1021
+ });
830
1022
  await new Promise(resolve => setTimeout(resolve, delay));
831
1023
  continue;
832
1024
  }
833
- // Log the error and rethrow
834
- logger_1.logger.error("Database error occurred", { error: String(error) });
1025
+ // Log structured error details and rethrow
1026
+ logger_1.logger.error("Database delete operation failed", {
1027
+ operation: 'deleteOneTradeAuditEvent',
1028
+ model: 'TradeAuditEvent',
1029
+ error: String(error),
1030
+ recordId: props.id,
1031
+ isRetryable: isConnectionError,
1032
+ });
835
1033
  throw error;
836
1034
  }
837
1035
  }
@@ -923,12 +1121,22 @@ exports.TradeAuditEvent = {
923
1121
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
924
1122
  retryCount++;
925
1123
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
926
- logger_1.logger.warn("Database connection error, retrying...");
1124
+ logger_1.logger.warn("Database connection error in getTradeAuditEvent, retrying...", {
1125
+ operation: 'getTradeAuditEvent',
1126
+ model: 'TradeAuditEvent',
1127
+ attempt: retryCount,
1128
+ maxRetries: MAX_RETRIES,
1129
+ });
927
1130
  await new Promise(resolve => setTimeout(resolve, delay));
928
1131
  continue;
929
1132
  }
930
- // Log the error and rethrow
931
- logger_1.logger.error("Database error occurred", { error: String(error) });
1133
+ // Log structured error details and rethrow
1134
+ logger_1.logger.error("Database get operation failed", {
1135
+ operation: 'getTradeAuditEvent',
1136
+ model: 'TradeAuditEvent',
1137
+ error: String(error),
1138
+ isRetryable: isConnectionError,
1139
+ });
932
1140
  throw error;
933
1141
  }
934
1142
  }
@@ -986,12 +1194,22 @@ exports.TradeAuditEvent = {
986
1194
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
987
1195
  retryCount++;
988
1196
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
989
- logger_1.logger.warn("Database connection error, retrying...");
1197
+ logger_1.logger.warn("Database connection error in getAllTradeAuditEvent, retrying...", {
1198
+ operation: 'getAllTradeAuditEvent',
1199
+ model: 'TradeAuditEvent',
1200
+ attempt: retryCount,
1201
+ maxRetries: MAX_RETRIES,
1202
+ });
990
1203
  await new Promise(resolve => setTimeout(resolve, delay));
991
1204
  continue;
992
1205
  }
993
- // Log the error and rethrow
994
- logger_1.logger.error("Database error occurred", { error: String(error) });
1206
+ // Log structured error details and rethrow
1207
+ logger_1.logger.error("Database getAll operation failed", {
1208
+ operation: 'getAllTradeAuditEvent',
1209
+ model: 'TradeAuditEvent',
1210
+ error: String(error),
1211
+ isRetryable: isConnectionError,
1212
+ });
995
1213
  throw error;
996
1214
  }
997
1215
  }
@@ -1092,12 +1310,22 @@ exports.TradeAuditEvent = {
1092
1310
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1093
1311
  retryCount++;
1094
1312
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1095
- logger_1.logger.warn("Database connection error, retrying...");
1313
+ logger_1.logger.warn("Database connection error in findManyTradeAuditEvent, retrying...", {
1314
+ operation: 'findManyTradeAuditEvent',
1315
+ model: 'TradeAuditEvent',
1316
+ attempt: retryCount,
1317
+ maxRetries: MAX_RETRIES,
1318
+ });
1096
1319
  await new Promise(resolve => setTimeout(resolve, delay));
1097
1320
  continue;
1098
1321
  }
1099
- // Log the error and rethrow
1100
- logger_1.logger.error("Database error occurred", { error: String(error) });
1322
+ // Log structured error details and rethrow
1323
+ logger_1.logger.error("Database findMany operation failed", {
1324
+ operation: 'findManyTradeAuditEvent',
1325
+ model: 'TradeAuditEvent',
1326
+ error: String(error),
1327
+ isRetryable: isConnectionError,
1328
+ });
1101
1329
  throw error;
1102
1330
  }
1103
1331
  }