@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
@@ -75,6 +75,27 @@ export const MarketSentiment = {
75
75
  }
76
76
  catch (error) {
77
77
  lastError = error;
78
+ // Check for constraint violations FIRST - these are NEVER retryable
79
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
80
+ error.message?.includes('violates unique constraint') ||
81
+ error.message?.includes('violates foreign key constraint') ||
82
+ error.message?.includes('unique constraint') ||
83
+ error.message?.includes('23514') ||
84
+ error.message?.includes('23505') ||
85
+ error.message?.includes('P2002') ||
86
+ error.message?.includes('P2003');
87
+ if (isConstraintViolation) {
88
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
89
+ logger.error("Non-retryable constraint violation in createOneMarketSentiment", {
90
+ operation: 'createOneMarketSentiment',
91
+ model: 'MarketSentiment',
92
+ error: String(error),
93
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
94
+ errorCategory: 'CONSTRAINT_VIOLATION',
95
+ isRetryable: false,
96
+ });
97
+ throw error;
98
+ }
78
99
  // Check if this is a database connection error that we should retry
79
100
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
80
101
  error.message?.includes('Cannot reach database server') ||
@@ -84,12 +105,22 @@ export const MarketSentiment = {
84
105
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
85
106
  retryCount++;
86
107
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
87
- logger.warn("Database connection error, retrying...");
108
+ logger.warn("Database connection error in createOneMarketSentiment, retrying...", {
109
+ operation: 'createOneMarketSentiment',
110
+ model: 'MarketSentiment',
111
+ attempt: retryCount,
112
+ maxRetries: MAX_RETRIES,
113
+ });
88
114
  await new Promise(resolve => setTimeout(resolve, delay));
89
115
  continue;
90
116
  }
91
- // Log the error and rethrow
92
- logger.error("Database error occurred", { error: String(error) });
117
+ // Log structured error details and rethrow
118
+ logger.error("Database create operation failed", {
119
+ operation: 'createOneMarketSentiment',
120
+ model: 'MarketSentiment',
121
+ error: String(error),
122
+ isRetryable: isConnectionError,
123
+ });
93
124
  throw error;
94
125
  }
95
126
  }
@@ -149,6 +180,27 @@ export const MarketSentiment = {
149
180
  }
150
181
  catch (error) {
151
182
  lastError = error;
183
+ // Check for constraint violations FIRST - these are NEVER retryable
184
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
185
+ error.message?.includes('violates unique constraint') ||
186
+ error.message?.includes('violates foreign key constraint') ||
187
+ error.message?.includes('unique constraint') ||
188
+ error.message?.includes('23514') ||
189
+ error.message?.includes('23505') ||
190
+ error.message?.includes('P2002') ||
191
+ error.message?.includes('P2003');
192
+ if (isConstraintViolation) {
193
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
194
+ logger.error("Non-retryable constraint violation in createManyMarketSentiment", {
195
+ operation: 'createManyMarketSentiment',
196
+ model: 'MarketSentiment',
197
+ error: String(error),
198
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
199
+ errorCategory: 'CONSTRAINT_VIOLATION',
200
+ isRetryable: false,
201
+ });
202
+ throw error;
203
+ }
152
204
  // Check if this is a database connection error that we should retry
153
205
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
154
206
  error.message?.includes('Cannot reach database server') ||
@@ -158,12 +210,22 @@ export const MarketSentiment = {
158
210
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
159
211
  retryCount++;
160
212
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
161
- logger.warn("Database connection error, retrying...");
213
+ logger.warn("Database connection error in createManyMarketSentiment, retrying...", {
214
+ operation: 'createManyMarketSentiment',
215
+ model: 'MarketSentiment',
216
+ attempt: retryCount,
217
+ maxRetries: MAX_RETRIES,
218
+ });
162
219
  await new Promise(resolve => setTimeout(resolve, delay));
163
220
  continue;
164
221
  }
165
- // Log the error and rethrow
166
- logger.error("Database error occurred", { error: String(error) });
222
+ // Log structured error details and rethrow
223
+ logger.error("Database createMany operation failed", {
224
+ operation: 'createManyMarketSentiment',
225
+ model: 'MarketSentiment',
226
+ error: String(error),
227
+ isRetryable: isConnectionError,
228
+ });
167
229
  throw error;
168
230
  }
169
231
  }
@@ -241,6 +303,28 @@ export const MarketSentiment = {
241
303
  }
242
304
  catch (error) {
243
305
  lastError = error;
306
+ // Check for constraint violations FIRST - these are NEVER retryable
307
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
308
+ error.message?.includes('violates unique constraint') ||
309
+ error.message?.includes('violates foreign key constraint') ||
310
+ error.message?.includes('unique constraint') ||
311
+ error.message?.includes('23514') ||
312
+ error.message?.includes('23505') ||
313
+ error.message?.includes('P2002') ||
314
+ error.message?.includes('P2003');
315
+ if (isConstraintViolation) {
316
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
317
+ logger.error("Non-retryable constraint violation in updateOneMarketSentiment", {
318
+ operation: 'updateOneMarketSentiment',
319
+ model: 'MarketSentiment',
320
+ error: String(error),
321
+ recordId: props.id,
322
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
323
+ errorCategory: 'CONSTRAINT_VIOLATION',
324
+ isRetryable: false,
325
+ });
326
+ throw error;
327
+ }
244
328
  // Check if this is a database connection error that we should retry
245
329
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
246
330
  error.message?.includes('Cannot reach database server') ||
@@ -250,12 +334,24 @@ export const MarketSentiment = {
250
334
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
251
335
  retryCount++;
252
336
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
253
- logger.warn("Database connection error, retrying...");
337
+ logger.warn("Database connection error in updateOneMarketSentiment, retrying...", {
338
+ operation: 'updateOneMarketSentiment',
339
+ model: 'MarketSentiment',
340
+ attempt: retryCount,
341
+ maxRetries: MAX_RETRIES,
342
+ recordId: props.id,
343
+ });
254
344
  await new Promise(resolve => setTimeout(resolve, delay));
255
345
  continue;
256
346
  }
257
- // Log the error and rethrow
258
- logger.error("Database error occurred", { error: String(error) });
347
+ // Log structured error details and rethrow
348
+ logger.error("Database update operation failed", {
349
+ operation: 'updateOneMarketSentiment',
350
+ model: 'MarketSentiment',
351
+ error: String(error),
352
+ recordId: props.id,
353
+ isRetryable: isConnectionError,
354
+ });
259
355
  throw error;
260
356
  }
261
357
  }
@@ -329,6 +425,28 @@ export const MarketSentiment = {
329
425
  }
330
426
  catch (error) {
331
427
  lastError = error;
428
+ // Check for constraint violations FIRST - these are NEVER retryable
429
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
430
+ error.message?.includes('violates unique constraint') ||
431
+ error.message?.includes('violates foreign key constraint') ||
432
+ error.message?.includes('unique constraint') ||
433
+ error.message?.includes('23514') ||
434
+ error.message?.includes('23505') ||
435
+ error.message?.includes('P2002') ||
436
+ error.message?.includes('P2003');
437
+ if (isConstraintViolation) {
438
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
439
+ logger.error("Non-retryable constraint violation in upsertOneMarketSentiment", {
440
+ operation: 'upsertOneMarketSentiment',
441
+ model: 'MarketSentiment',
442
+ error: String(error),
443
+ recordId: props.id,
444
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
445
+ errorCategory: 'CONSTRAINT_VIOLATION',
446
+ isRetryable: false,
447
+ });
448
+ throw error;
449
+ }
332
450
  // Check if this is a database connection error that we should retry
333
451
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
334
452
  error.message?.includes('Cannot reach database server') ||
@@ -338,12 +456,24 @@ export const MarketSentiment = {
338
456
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
339
457
  retryCount++;
340
458
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
341
- logger.warn("Database connection error, retrying...");
459
+ logger.warn("Database connection error in upsertOneMarketSentiment, retrying...", {
460
+ operation: 'upsertOneMarketSentiment',
461
+ model: 'MarketSentiment',
462
+ attempt: retryCount,
463
+ maxRetries: MAX_RETRIES,
464
+ recordId: props.id,
465
+ });
342
466
  await new Promise(resolve => setTimeout(resolve, delay));
343
467
  continue;
344
468
  }
345
- // Log the error and rethrow
346
- logger.error("Database error occurred", { error: String(error) });
469
+ // Log structured error details and rethrow
470
+ logger.error("Database upsert operation failed", {
471
+ operation: 'upsertOneMarketSentiment',
472
+ model: 'MarketSentiment',
473
+ error: String(error),
474
+ recordId: props.id,
475
+ isRetryable: isConnectionError,
476
+ });
347
477
  throw error;
348
478
  }
349
479
  }
@@ -421,6 +551,27 @@ export const MarketSentiment = {
421
551
  }
422
552
  catch (error) {
423
553
  lastError = error;
554
+ // Check for constraint violations FIRST - these are NEVER retryable
555
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
556
+ error.message?.includes('violates unique constraint') ||
557
+ error.message?.includes('violates foreign key constraint') ||
558
+ error.message?.includes('unique constraint') ||
559
+ error.message?.includes('23514') ||
560
+ error.message?.includes('23505') ||
561
+ error.message?.includes('P2002') ||
562
+ error.message?.includes('P2003');
563
+ if (isConstraintViolation) {
564
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
565
+ logger.error("Non-retryable constraint violation in updateManyMarketSentiment", {
566
+ operation: 'updateManyMarketSentiment',
567
+ model: 'MarketSentiment',
568
+ error: String(error),
569
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
570
+ errorCategory: 'CONSTRAINT_VIOLATION',
571
+ isRetryable: false,
572
+ });
573
+ throw error;
574
+ }
424
575
  // Check if this is a database connection error that we should retry
425
576
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
426
577
  error.message?.includes('Cannot reach database server') ||
@@ -430,12 +581,22 @@ export const MarketSentiment = {
430
581
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
431
582
  retryCount++;
432
583
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
433
- logger.warn("Database connection error, retrying...");
584
+ logger.warn("Database connection error in updateManyMarketSentiment, retrying...", {
585
+ operation: 'updateManyMarketSentiment',
586
+ model: 'MarketSentiment',
587
+ attempt: retryCount,
588
+ maxRetries: MAX_RETRIES,
589
+ });
434
590
  await new Promise(resolve => setTimeout(resolve, delay));
435
591
  continue;
436
592
  }
437
- // Log the error and rethrow
438
- logger.error("Database error occurred", { error: String(error) });
593
+ // Log structured error details and rethrow
594
+ logger.error("Database updateMany operation failed", {
595
+ operation: 'updateManyMarketSentiment',
596
+ model: 'MarketSentiment',
597
+ error: String(error),
598
+ isRetryable: isConnectionError,
599
+ });
439
600
  throw error;
440
601
  }
441
602
  }
@@ -493,6 +654,31 @@ export const MarketSentiment = {
493
654
  }
494
655
  catch (error) {
495
656
  lastError = error;
657
+ // Check for constraint violations FIRST - these are NEVER retryable
658
+ // (e.g., foreign key constraints preventing deletion)
659
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
660
+ error.message?.includes('violates unique constraint') ||
661
+ error.message?.includes('violates foreign key constraint') ||
662
+ error.message?.includes('unique constraint') ||
663
+ error.message?.includes('23514') ||
664
+ error.message?.includes('23505') ||
665
+ error.message?.includes('23503') ||
666
+ error.message?.includes('P2002') ||
667
+ error.message?.includes('P2003') ||
668
+ error.message?.includes('P2014');
669
+ if (isConstraintViolation) {
670
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
671
+ logger.error("Non-retryable constraint violation in deleteOneMarketSentiment", {
672
+ operation: 'deleteOneMarketSentiment',
673
+ model: 'MarketSentiment',
674
+ error: String(error),
675
+ recordId: props.id,
676
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
677
+ errorCategory: 'CONSTRAINT_VIOLATION',
678
+ isRetryable: false,
679
+ });
680
+ throw error;
681
+ }
496
682
  // Check if this is a database connection error that we should retry
497
683
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
498
684
  error.message?.includes('Cannot reach database server') ||
@@ -502,12 +688,24 @@ export const MarketSentiment = {
502
688
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
503
689
  retryCount++;
504
690
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
505
- logger.warn("Database connection error, retrying...");
691
+ logger.warn("Database connection error in deleteOneMarketSentiment, retrying...", {
692
+ operation: 'deleteOneMarketSentiment',
693
+ model: 'MarketSentiment',
694
+ attempt: retryCount,
695
+ maxRetries: MAX_RETRIES,
696
+ recordId: props.id,
697
+ });
506
698
  await new Promise(resolve => setTimeout(resolve, delay));
507
699
  continue;
508
700
  }
509
- // Log the error and rethrow
510
- logger.error("Database error occurred", { error: String(error) });
701
+ // Log structured error details and rethrow
702
+ logger.error("Database delete operation failed", {
703
+ operation: 'deleteOneMarketSentiment',
704
+ model: 'MarketSentiment',
705
+ error: String(error),
706
+ recordId: props.id,
707
+ isRetryable: isConnectionError,
708
+ });
511
709
  throw error;
512
710
  }
513
711
  }
@@ -573,12 +771,22 @@ export const MarketSentiment = {
573
771
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
574
772
  retryCount++;
575
773
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
576
- logger.warn("Database connection error, retrying...");
774
+ logger.warn("Database connection error in getMarketSentiment, retrying...", {
775
+ operation: 'getMarketSentiment',
776
+ model: 'MarketSentiment',
777
+ attempt: retryCount,
778
+ maxRetries: MAX_RETRIES,
779
+ });
577
780
  await new Promise(resolve => setTimeout(resolve, delay));
578
781
  continue;
579
782
  }
580
- // Log the error and rethrow
581
- logger.error("Database error occurred", { error: String(error) });
783
+ // Log structured error details and rethrow
784
+ logger.error("Database get operation failed", {
785
+ operation: 'getMarketSentiment',
786
+ model: 'MarketSentiment',
787
+ error: String(error),
788
+ isRetryable: isConnectionError,
789
+ });
582
790
  throw error;
583
791
  }
584
792
  }
@@ -635,12 +843,22 @@ export const MarketSentiment = {
635
843
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
636
844
  retryCount++;
637
845
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
638
- logger.warn("Database connection error, retrying...");
846
+ logger.warn("Database connection error in getAllMarketSentiment, retrying...", {
847
+ operation: 'getAllMarketSentiment',
848
+ model: 'MarketSentiment',
849
+ attempt: retryCount,
850
+ maxRetries: MAX_RETRIES,
851
+ });
639
852
  await new Promise(resolve => setTimeout(resolve, delay));
640
853
  continue;
641
854
  }
642
- // Log the error and rethrow
643
- logger.error("Database error occurred", { error: String(error) });
855
+ // Log structured error details and rethrow
856
+ logger.error("Database getAll operation failed", {
857
+ operation: 'getAllMarketSentiment',
858
+ model: 'MarketSentiment',
859
+ error: String(error),
860
+ isRetryable: isConnectionError,
861
+ });
644
862
  throw error;
645
863
  }
646
864
  }
@@ -713,12 +931,22 @@ export const MarketSentiment = {
713
931
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
714
932
  retryCount++;
715
933
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
716
- logger.warn("Database connection error, retrying...");
934
+ logger.warn("Database connection error in findManyMarketSentiment, retrying...", {
935
+ operation: 'findManyMarketSentiment',
936
+ model: 'MarketSentiment',
937
+ attempt: retryCount,
938
+ maxRetries: MAX_RETRIES,
939
+ });
717
940
  await new Promise(resolve => setTimeout(resolve, delay));
718
941
  continue;
719
942
  }
720
- // Log the error and rethrow
721
- logger.error("Database error occurred", { error: String(error) });
943
+ // Log structured error details and rethrow
944
+ logger.error("Database findMany operation failed", {
945
+ operation: 'findManyMarketSentiment',
946
+ model: 'MarketSentiment',
947
+ error: String(error),
948
+ isRetryable: isConnectionError,
949
+ });
722
950
  throw error;
723
951
  }
724
952
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ModelArtifact.d.ts","sourceRoot":"","sources":["../../src/ModelArtifact.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AACzG,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AA4K7G,eAAO,MAAM,aAAa;IAExB;;;;;OAKG;IAEH;;;;;;OAMG;kBACiB,iBAAiB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAqX5H;;;;;;OAMG;sBACqB,iBAAiB,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAuFvI;;;;;;OAMG;kBACiB,iBA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