@adaptic/backend-legacy 0.0.904 → 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 (225) 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/prismaClient.d.ts.map +1 -1
  222. package/esm/prismaClient.js.map +1 -1
  223. package/esm/prismaClient.mjs +38 -9
  224. package/package.json +1 -1
  225. package/prismaClient.cjs +38 -9
package/Trade.cjs CHANGED
@@ -67,7 +67,7 @@ exports.Trade = {
67
67
  * @returns The created Trade or null.
68
68
  */
69
69
  async create(props, globalClient) {
70
- var _a, _b, _c, _d, _e;
70
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
71
71
  // Maximum number of retries for database connection issues
72
72
  const MAX_RETRIES = 3;
73
73
  let retryCount = 0;
@@ -161,21 +161,52 @@ exports.Trade = {
161
161
  }
162
162
  catch (error) {
163
163
  lastError = error;
164
+ // Check for constraint violations FIRST - these are NEVER retryable
165
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
166
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
167
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
168
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
169
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
170
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
171
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
172
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
173
+ if (isConstraintViolation) {
174
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
175
+ logger_1.logger.error("Non-retryable constraint violation in createOneTrade", {
176
+ operation: 'createOneTrade',
177
+ model: 'Trade',
178
+ error: String(error),
179
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
180
+ errorCategory: 'CONSTRAINT_VIOLATION',
181
+ isRetryable: false,
182
+ });
183
+ throw error;
184
+ }
164
185
  // Check if this is a database connection error that we should retry
165
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
166
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
167
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
168
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
169
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
186
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
187
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
188
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
189
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
190
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
170
191
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
171
192
  retryCount++;
172
193
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
173
- logger_1.logger.warn("Database connection error, retrying...");
194
+ logger_1.logger.warn("Database connection error in createOneTrade, retrying...", {
195
+ operation: 'createOneTrade',
196
+ model: 'Trade',
197
+ attempt: retryCount,
198
+ maxRetries: MAX_RETRIES,
199
+ });
174
200
  await new Promise(resolve => setTimeout(resolve, delay));
175
201
  continue;
176
202
  }
177
- // Log the error and rethrow
178
- logger_1.logger.error("Database error occurred", { error: String(error) });
203
+ // Log structured error details and rethrow
204
+ logger_1.logger.error("Database create operation failed", {
205
+ operation: 'createOneTrade',
206
+ model: 'Trade',
207
+ error: String(error),
208
+ isRetryable: isConnectionError,
209
+ });
179
210
  throw error;
180
211
  }
181
212
  }
@@ -190,7 +221,7 @@ exports.Trade = {
190
221
  * @returns The count of created records or null.
191
222
  */
192
223
  async createMany(props, globalClient) {
193
- var _a, _b, _c, _d, _e;
224
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
194
225
  // Maximum number of retries for database connection issues
195
226
  const MAX_RETRIES = 3;
196
227
  let retryCount = 0;
@@ -258,21 +289,52 @@ exports.Trade = {
258
289
  }
259
290
  catch (error) {
260
291
  lastError = error;
292
+ // Check for constraint violations FIRST - these are NEVER retryable
293
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
294
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
295
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
296
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
297
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
298
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
299
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
300
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
301
+ if (isConstraintViolation) {
302
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
303
+ logger_1.logger.error("Non-retryable constraint violation in createManyTrade", {
304
+ operation: 'createManyTrade',
305
+ model: 'Trade',
306
+ error: String(error),
307
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
308
+ errorCategory: 'CONSTRAINT_VIOLATION',
309
+ isRetryable: false,
310
+ });
311
+ throw error;
312
+ }
261
313
  // Check if this is a database connection error that we should retry
262
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
263
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
264
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
265
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
266
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
314
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
315
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
316
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
317
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
318
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
267
319
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
268
320
  retryCount++;
269
321
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
270
- logger_1.logger.warn("Database connection error, retrying...");
322
+ logger_1.logger.warn("Database connection error in createManyTrade, retrying...", {
323
+ operation: 'createManyTrade',
324
+ model: 'Trade',
325
+ attempt: retryCount,
326
+ maxRetries: MAX_RETRIES,
327
+ });
271
328
  await new Promise(resolve => setTimeout(resolve, delay));
272
329
  continue;
273
330
  }
274
- // Log the error and rethrow
275
- logger_1.logger.error("Database error occurred", { error: String(error) });
331
+ // Log structured error details and rethrow
332
+ logger_1.logger.error("Database createMany operation failed", {
333
+ operation: 'createManyTrade',
334
+ model: 'Trade',
335
+ error: String(error),
336
+ isRetryable: isConnectionError,
337
+ });
276
338
  throw error;
277
339
  }
278
340
  }
@@ -287,7 +349,7 @@ exports.Trade = {
287
349
  * @returns The updated Trade or null.
288
350
  */
289
351
  async update(props, globalClient) {
290
- var _a, _b, _c, _d, _e;
352
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
291
353
  // Maximum number of retries for database connection issues
292
354
  const MAX_RETRIES = 3;
293
355
  let retryCount = 0;
@@ -473,21 +535,55 @@ exports.Trade = {
473
535
  }
474
536
  catch (error) {
475
537
  lastError = error;
538
+ // Check for constraint violations FIRST - these are NEVER retryable
539
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
540
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
541
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
542
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
543
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
544
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
545
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
546
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
547
+ if (isConstraintViolation) {
548
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
549
+ logger_1.logger.error("Non-retryable constraint violation in updateOneTrade", {
550
+ operation: 'updateOneTrade',
551
+ model: 'Trade',
552
+ error: String(error),
553
+ recordId: props.id,
554
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
555
+ errorCategory: 'CONSTRAINT_VIOLATION',
556
+ isRetryable: false,
557
+ });
558
+ throw error;
559
+ }
476
560
  // Check if this is a database connection error that we should retry
477
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
478
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
479
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
480
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
481
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
561
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
562
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
563
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
564
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
565
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
482
566
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
483
567
  retryCount++;
484
568
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
485
- logger_1.logger.warn("Database connection error, retrying...");
569
+ logger_1.logger.warn("Database connection error in updateOneTrade, retrying...", {
570
+ operation: 'updateOneTrade',
571
+ model: 'Trade',
572
+ attempt: retryCount,
573
+ maxRetries: MAX_RETRIES,
574
+ recordId: props.id,
575
+ });
486
576
  await new Promise(resolve => setTimeout(resolve, delay));
487
577
  continue;
488
578
  }
489
- // Log the error and rethrow
490
- logger_1.logger.error("Database error occurred", { error: String(error) });
579
+ // Log structured error details and rethrow
580
+ logger_1.logger.error("Database update operation failed", {
581
+ operation: 'updateOneTrade',
582
+ model: 'Trade',
583
+ error: String(error),
584
+ recordId: props.id,
585
+ isRetryable: isConnectionError,
586
+ });
491
587
  throw error;
492
588
  }
493
589
  }
@@ -502,7 +598,7 @@ exports.Trade = {
502
598
  * @returns The updated Trade or null.
503
599
  */
504
600
  async upsert(props, globalClient) {
505
- var _a, _b, _c, _d, _e;
601
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
506
602
  // Maximum number of retries for database connection issues
507
603
  const MAX_RETRIES = 3;
508
604
  let retryCount = 0;
@@ -731,21 +827,55 @@ exports.Trade = {
731
827
  }
732
828
  catch (error) {
733
829
  lastError = error;
830
+ // Check for constraint violations FIRST - these are NEVER retryable
831
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
832
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
833
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
834
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
835
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
836
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
837
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
838
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
839
+ if (isConstraintViolation) {
840
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
841
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneTrade", {
842
+ operation: 'upsertOneTrade',
843
+ model: 'Trade',
844
+ error: String(error),
845
+ recordId: props.id,
846
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
847
+ errorCategory: 'CONSTRAINT_VIOLATION',
848
+ isRetryable: false,
849
+ });
850
+ throw error;
851
+ }
734
852
  // Check if this is a database connection error that we should retry
735
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
736
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
737
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
738
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
739
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
853
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
854
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
855
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
856
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
857
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
740
858
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
741
859
  retryCount++;
742
860
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
743
- logger_1.logger.warn("Database connection error, retrying...");
861
+ logger_1.logger.warn("Database connection error in upsertOneTrade, retrying...", {
862
+ operation: 'upsertOneTrade',
863
+ model: 'Trade',
864
+ attempt: retryCount,
865
+ maxRetries: MAX_RETRIES,
866
+ recordId: props.id,
867
+ });
744
868
  await new Promise(resolve => setTimeout(resolve, delay));
745
869
  continue;
746
870
  }
747
- // Log the error and rethrow
748
- logger_1.logger.error("Database error occurred", { error: String(error) });
871
+ // Log structured error details and rethrow
872
+ logger_1.logger.error("Database upsert operation failed", {
873
+ operation: 'upsertOneTrade',
874
+ model: 'Trade',
875
+ error: String(error),
876
+ recordId: props.id,
877
+ isRetryable: isConnectionError,
878
+ });
749
879
  throw error;
750
880
  }
751
881
  }
@@ -760,7 +890,7 @@ exports.Trade = {
760
890
  * @returns The count of created records or null.
761
891
  */
762
892
  async updateMany(props, globalClient) {
763
- var _a, _b, _c, _d, _e;
893
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
764
894
  // Maximum number of retries for database connection issues
765
895
  const MAX_RETRIES = 3;
766
896
  let retryCount = 0;
@@ -946,21 +1076,52 @@ exports.Trade = {
946
1076
  }
947
1077
  catch (error) {
948
1078
  lastError = error;
1079
+ // Check for constraint violations FIRST - these are NEVER retryable
1080
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
1081
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
1082
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
1083
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
1084
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
1085
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
1086
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
1087
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
1088
+ if (isConstraintViolation) {
1089
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
1090
+ logger_1.logger.error("Non-retryable constraint violation in updateManyTrade", {
1091
+ operation: 'updateManyTrade',
1092
+ model: 'Trade',
1093
+ error: String(error),
1094
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1095
+ errorCategory: 'CONSTRAINT_VIOLATION',
1096
+ isRetryable: false,
1097
+ });
1098
+ throw error;
1099
+ }
949
1100
  // Check if this is a database connection error that we should retry
950
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
951
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
952
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
953
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
954
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
1101
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
1102
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
1103
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
1104
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
1105
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
955
1106
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
956
1107
  retryCount++;
957
1108
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
958
- logger_1.logger.warn("Database connection error, retrying...");
1109
+ logger_1.logger.warn("Database connection error in updateManyTrade, retrying...", {
1110
+ operation: 'updateManyTrade',
1111
+ model: 'Trade',
1112
+ attempt: retryCount,
1113
+ maxRetries: MAX_RETRIES,
1114
+ });
959
1115
  await new Promise(resolve => setTimeout(resolve, delay));
960
1116
  continue;
961
1117
  }
962
- // Log the error and rethrow
963
- logger_1.logger.error("Database error occurred", { error: String(error) });
1118
+ // Log structured error details and rethrow
1119
+ logger_1.logger.error("Database updateMany operation failed", {
1120
+ operation: 'updateManyTrade',
1121
+ model: 'Trade',
1122
+ error: String(error),
1123
+ isRetryable: isConnectionError,
1124
+ });
964
1125
  throw error;
965
1126
  }
966
1127
  }
@@ -975,7 +1136,7 @@ exports.Trade = {
975
1136
  * @returns The deleted Trade or null.
976
1137
  */
977
1138
  async delete(props, globalClient) {
978
- var _a, _b, _c, _d, _e;
1139
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
979
1140
  // Maximum number of retries for database connection issues
980
1141
  const MAX_RETRIES = 3;
981
1142
  let retryCount = 0;
@@ -1019,21 +1180,58 @@ exports.Trade = {
1019
1180
  }
1020
1181
  catch (error) {
1021
1182
  lastError = error;
1183
+ // Check for constraint violations FIRST - these are NEVER retryable
1184
+ // (e.g., foreign key constraints preventing deletion)
1185
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
1186
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
1187
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
1188
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
1189
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
1190
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
1191
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
1192
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
1193
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
1194
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
1195
+ if (isConstraintViolation) {
1196
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
1197
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneTrade", {
1198
+ operation: 'deleteOneTrade',
1199
+ model: 'Trade',
1200
+ error: String(error),
1201
+ recordId: props.id,
1202
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1203
+ errorCategory: 'CONSTRAINT_VIOLATION',
1204
+ isRetryable: false,
1205
+ });
1206
+ throw error;
1207
+ }
1022
1208
  // Check if this is a database connection error that we should retry
1023
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
1024
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
1025
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
1026
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
1027
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
1209
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
1210
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
1211
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
1212
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
1213
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
1028
1214
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1029
1215
  retryCount++;
1030
1216
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1031
- logger_1.logger.warn("Database connection error, retrying...");
1217
+ logger_1.logger.warn("Database connection error in deleteOneTrade, retrying...", {
1218
+ operation: 'deleteOneTrade',
1219
+ model: 'Trade',
1220
+ attempt: retryCount,
1221
+ maxRetries: MAX_RETRIES,
1222
+ recordId: props.id,
1223
+ });
1032
1224
  await new Promise(resolve => setTimeout(resolve, delay));
1033
1225
  continue;
1034
1226
  }
1035
- // Log the error and rethrow
1036
- logger_1.logger.error("Database error occurred", { error: String(error) });
1227
+ // Log structured error details and rethrow
1228
+ logger_1.logger.error("Database delete operation failed", {
1229
+ operation: 'deleteOneTrade',
1230
+ model: 'Trade',
1231
+ error: String(error),
1232
+ recordId: props.id,
1233
+ isRetryable: isConnectionError,
1234
+ });
1037
1235
  throw error;
1038
1236
  }
1039
1237
  }
@@ -1106,12 +1304,22 @@ exports.Trade = {
1106
1304
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1107
1305
  retryCount++;
1108
1306
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1109
- logger_1.logger.warn("Database connection error, retrying...");
1307
+ logger_1.logger.warn("Database connection error in getTrade, retrying...", {
1308
+ operation: 'getTrade',
1309
+ model: 'Trade',
1310
+ attempt: retryCount,
1311
+ maxRetries: MAX_RETRIES,
1312
+ });
1110
1313
  await new Promise(resolve => setTimeout(resolve, delay));
1111
1314
  continue;
1112
1315
  }
1113
- // Log the error and rethrow
1114
- logger_1.logger.error("Database error occurred", { error: String(error) });
1316
+ // Log structured error details and rethrow
1317
+ logger_1.logger.error("Database get operation failed", {
1318
+ operation: 'getTrade',
1319
+ model: 'Trade',
1320
+ error: String(error),
1321
+ isRetryable: isConnectionError,
1322
+ });
1115
1323
  throw error;
1116
1324
  }
1117
1325
  }
@@ -1169,12 +1377,22 @@ exports.Trade = {
1169
1377
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1170
1378
  retryCount++;
1171
1379
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1172
- logger_1.logger.warn("Database connection error, retrying...");
1380
+ logger_1.logger.warn("Database connection error in getAllTrade, retrying...", {
1381
+ operation: 'getAllTrade',
1382
+ model: 'Trade',
1383
+ attempt: retryCount,
1384
+ maxRetries: MAX_RETRIES,
1385
+ });
1173
1386
  await new Promise(resolve => setTimeout(resolve, delay));
1174
1387
  continue;
1175
1388
  }
1176
- // Log the error and rethrow
1177
- logger_1.logger.error("Database error occurred", { error: String(error) });
1389
+ // Log structured error details and rethrow
1390
+ logger_1.logger.error("Database getAll operation failed", {
1391
+ operation: 'getAllTrade',
1392
+ model: 'Trade',
1393
+ error: String(error),
1394
+ isRetryable: isConnectionError,
1395
+ });
1178
1396
  throw error;
1179
1397
  }
1180
1398
  }
@@ -1254,12 +1472,22 @@ exports.Trade = {
1254
1472
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1255
1473
  retryCount++;
1256
1474
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1257
- logger_1.logger.warn("Database connection error, retrying...");
1475
+ logger_1.logger.warn("Database connection error in findManyTrade, retrying...", {
1476
+ operation: 'findManyTrade',
1477
+ model: 'Trade',
1478
+ attempt: retryCount,
1479
+ maxRetries: MAX_RETRIES,
1480
+ });
1258
1481
  await new Promise(resolve => setTimeout(resolve, delay));
1259
1482
  continue;
1260
1483
  }
1261
- // Log the error and rethrow
1262
- logger_1.logger.error("Database error occurred", { error: String(error) });
1484
+ // Log structured error details and rethrow
1485
+ logger_1.logger.error("Database findMany operation failed", {
1486
+ operation: 'findManyTrade',
1487
+ model: 'Trade',
1488
+ error: String(error),
1489
+ isRetryable: isConnectionError,
1490
+ });
1263
1491
  throw error;
1264
1492
  }
1265
1493
  }