@adaptic/backend-legacy 0.0.903 → 0.0.905

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/ABTest.cjs +291 -63
  2. package/Account.cjs +291 -63
  3. package/AccountLinkingRequest.cjs +291 -63
  4. package/Action.cjs +291 -63
  5. package/Alert.cjs +291 -63
  6. package/Allocation.cjs +291 -63
  7. package/AlpacaAccount.cjs +291 -63
  8. package/AnalyticsConfiguration.cjs +291 -63
  9. package/AnalyticsSnapshot.cjs +291 -63
  10. package/Asset.cjs +291 -63
  11. package/AuditLog.cjs +291 -63
  12. package/Authenticator.cjs +291 -63
  13. package/Configuration.cjs +291 -63
  14. package/ConflictEvent.cjs +291 -63
  15. package/ConnectionHealthSnapshot.cjs +291 -63
  16. package/Customer.cjs +291 -63
  17. package/DeadLetterMessage.cjs +291 -63
  18. package/EconomicEvent.cjs +291 -63
  19. package/Event.cjs +291 -63
  20. package/EventSnapshot.cjs +291 -63
  21. package/FeatureImportanceAnalysis.cjs +291 -63
  22. package/InstitutionalFlowSignal.cjs +291 -63
  23. package/InstitutionalHolding.cjs +291 -63
  24. package/InstitutionalSentimentAlerts.cjs +291 -63
  25. package/InstitutionalSentimentErrors.cjs +291 -63
  26. package/InstitutionalSentimentHistory.cjs +291 -63
  27. package/InstitutionalSentimentMetrics.cjs +291 -63
  28. package/InviteToken.cjs +291 -63
  29. package/LinkedProvider.cjs +291 -63
  30. package/MLTrainingData.cjs +291 -63
  31. package/MarketSentiment.cjs +291 -63
  32. package/ModelArtifact.cjs +291 -63
  33. package/ModelVersion.cjs +291 -63
  34. package/ModelVersionArtifact.cjs +291 -63
  35. package/NewsArticle.cjs +291 -63
  36. package/NewsArticleAssetSentiment.cjs +291 -63
  37. package/OptionsContract.cjs +291 -63
  38. package/OptionsGreeksHistory.cjs +291 -63
  39. package/OptionsPosition.cjs +291 -63
  40. package/OptionsTradeExecution.cjs +291 -63
  41. package/PortfolioGreeksHistory.cjs +291 -63
  42. package/ScheduledOptionOrder.cjs +291 -63
  43. package/Session.cjs +291 -63
  44. package/SignalGeneratorMetrics.cjs +291 -63
  45. package/SignalLineage.cjs +291 -63
  46. package/SignalOutcome.cjs +291 -63
  47. package/SignalPriorityQueue.cjs +291 -63
  48. package/SyncEvent.cjs +291 -63
  49. package/SystemAlert.cjs +291 -63
  50. package/Trade.cjs +291 -63
  51. package/TradeAuditEvent.cjs +291 -63
  52. package/TradeExecutionHistory.cjs +291 -63
  53. package/User.cjs +291 -63
  54. package/VerificationToken.cjs +291 -63
  55. package/WaitlistEntry.cjs +291 -63
  56. package/esm/ABTest.d.ts.map +1 -1
  57. package/esm/ABTest.js.map +1 -1
  58. package/esm/ABTest.mjs +255 -27
  59. package/esm/Account.d.ts.map +1 -1
  60. package/esm/Account.js.map +1 -1
  61. package/esm/Account.mjs +255 -27
  62. package/esm/AccountLinkingRequest.d.ts.map +1 -1
  63. package/esm/AccountLinkingRequest.js.map +1 -1
  64. package/esm/AccountLinkingRequest.mjs +255 -27
  65. package/esm/Action.d.ts.map +1 -1
  66. package/esm/Action.js.map +1 -1
  67. package/esm/Action.mjs +255 -27
  68. package/esm/Alert.d.ts.map +1 -1
  69. package/esm/Alert.js.map +1 -1
  70. package/esm/Alert.mjs +255 -27
  71. package/esm/Allocation.d.ts.map +1 -1
  72. package/esm/Allocation.js.map +1 -1
  73. package/esm/Allocation.mjs +255 -27
  74. package/esm/AlpacaAccount.d.ts.map +1 -1
  75. package/esm/AlpacaAccount.js.map +1 -1
  76. package/esm/AlpacaAccount.mjs +255 -27
  77. package/esm/AnalyticsConfiguration.d.ts.map +1 -1
  78. package/esm/AnalyticsConfiguration.js.map +1 -1
  79. package/esm/AnalyticsConfiguration.mjs +255 -27
  80. package/esm/AnalyticsSnapshot.d.ts.map +1 -1
  81. package/esm/AnalyticsSnapshot.js.map +1 -1
  82. package/esm/AnalyticsSnapshot.mjs +255 -27
  83. package/esm/Asset.d.ts.map +1 -1
  84. package/esm/Asset.js.map +1 -1
  85. package/esm/Asset.mjs +255 -27
  86. package/esm/AuditLog.d.ts.map +1 -1
  87. package/esm/AuditLog.js.map +1 -1
  88. package/esm/AuditLog.mjs +255 -27
  89. package/esm/Authenticator.d.ts.map +1 -1
  90. package/esm/Authenticator.js.map +1 -1
  91. package/esm/Authenticator.mjs +255 -27
  92. package/esm/Configuration.d.ts.map +1 -1
  93. package/esm/Configuration.js.map +1 -1
  94. package/esm/Configuration.mjs +255 -27
  95. package/esm/ConflictEvent.d.ts.map +1 -1
  96. package/esm/ConflictEvent.js.map +1 -1
  97. package/esm/ConflictEvent.mjs +255 -27
  98. package/esm/ConnectionHealthSnapshot.d.ts.map +1 -1
  99. package/esm/ConnectionHealthSnapshot.js.map +1 -1
  100. package/esm/ConnectionHealthSnapshot.mjs +255 -27
  101. package/esm/Customer.d.ts.map +1 -1
  102. package/esm/Customer.js.map +1 -1
  103. package/esm/Customer.mjs +255 -27
  104. package/esm/DeadLetterMessage.d.ts.map +1 -1
  105. package/esm/DeadLetterMessage.js.map +1 -1
  106. package/esm/DeadLetterMessage.mjs +255 -27
  107. package/esm/EconomicEvent.d.ts.map +1 -1
  108. package/esm/EconomicEvent.js.map +1 -1
  109. package/esm/EconomicEvent.mjs +255 -27
  110. package/esm/Event.d.ts.map +1 -1
  111. package/esm/Event.js.map +1 -1
  112. package/esm/Event.mjs +255 -27
  113. package/esm/EventSnapshot.d.ts.map +1 -1
  114. package/esm/EventSnapshot.js.map +1 -1
  115. package/esm/EventSnapshot.mjs +255 -27
  116. package/esm/FeatureImportanceAnalysis.d.ts.map +1 -1
  117. package/esm/FeatureImportanceAnalysis.js.map +1 -1
  118. package/esm/FeatureImportanceAnalysis.mjs +255 -27
  119. package/esm/InstitutionalFlowSignal.d.ts.map +1 -1
  120. package/esm/InstitutionalFlowSignal.js.map +1 -1
  121. package/esm/InstitutionalFlowSignal.mjs +255 -27
  122. package/esm/InstitutionalHolding.d.ts.map +1 -1
  123. package/esm/InstitutionalHolding.js.map +1 -1
  124. package/esm/InstitutionalHolding.mjs +255 -27
  125. package/esm/InstitutionalSentimentAlerts.d.ts.map +1 -1
  126. package/esm/InstitutionalSentimentAlerts.js.map +1 -1
  127. package/esm/InstitutionalSentimentAlerts.mjs +255 -27
  128. package/esm/InstitutionalSentimentErrors.d.ts.map +1 -1
  129. package/esm/InstitutionalSentimentErrors.js.map +1 -1
  130. package/esm/InstitutionalSentimentErrors.mjs +255 -27
  131. package/esm/InstitutionalSentimentHistory.d.ts.map +1 -1
  132. package/esm/InstitutionalSentimentHistory.js.map +1 -1
  133. package/esm/InstitutionalSentimentHistory.mjs +255 -27
  134. package/esm/InstitutionalSentimentMetrics.d.ts.map +1 -1
  135. package/esm/InstitutionalSentimentMetrics.js.map +1 -1
  136. package/esm/InstitutionalSentimentMetrics.mjs +255 -27
  137. package/esm/InviteToken.d.ts.map +1 -1
  138. package/esm/InviteToken.js.map +1 -1
  139. package/esm/InviteToken.mjs +255 -27
  140. package/esm/LinkedProvider.d.ts.map +1 -1
  141. package/esm/LinkedProvider.js.map +1 -1
  142. package/esm/LinkedProvider.mjs +255 -27
  143. package/esm/MLTrainingData.d.ts.map +1 -1
  144. package/esm/MLTrainingData.js.map +1 -1
  145. package/esm/MLTrainingData.mjs +255 -27
  146. package/esm/MarketSentiment.d.ts.map +1 -1
  147. package/esm/MarketSentiment.js.map +1 -1
  148. package/esm/MarketSentiment.mjs +255 -27
  149. package/esm/ModelArtifact.d.ts.map +1 -1
  150. package/esm/ModelArtifact.js.map +1 -1
  151. package/esm/ModelArtifact.mjs +255 -27
  152. package/esm/ModelVersion.d.ts.map +1 -1
  153. package/esm/ModelVersion.js.map +1 -1
  154. package/esm/ModelVersion.mjs +255 -27
  155. package/esm/ModelVersionArtifact.d.ts.map +1 -1
  156. package/esm/ModelVersionArtifact.js.map +1 -1
  157. package/esm/ModelVersionArtifact.mjs +255 -27
  158. package/esm/NewsArticle.d.ts.map +1 -1
  159. package/esm/NewsArticle.js.map +1 -1
  160. package/esm/NewsArticle.mjs +255 -27
  161. package/esm/NewsArticleAssetSentiment.d.ts.map +1 -1
  162. package/esm/NewsArticleAssetSentiment.js.map +1 -1
  163. package/esm/NewsArticleAssetSentiment.mjs +255 -27
  164. package/esm/OptionsContract.d.ts.map +1 -1
  165. package/esm/OptionsContract.js.map +1 -1
  166. package/esm/OptionsContract.mjs +255 -27
  167. package/esm/OptionsGreeksHistory.d.ts.map +1 -1
  168. package/esm/OptionsGreeksHistory.js.map +1 -1
  169. package/esm/OptionsGreeksHistory.mjs +255 -27
  170. package/esm/OptionsPosition.d.ts.map +1 -1
  171. package/esm/OptionsPosition.js.map +1 -1
  172. package/esm/OptionsPosition.mjs +255 -27
  173. package/esm/OptionsTradeExecution.d.ts.map +1 -1
  174. package/esm/OptionsTradeExecution.js.map +1 -1
  175. package/esm/OptionsTradeExecution.mjs +255 -27
  176. package/esm/PortfolioGreeksHistory.d.ts.map +1 -1
  177. package/esm/PortfolioGreeksHistory.js.map +1 -1
  178. package/esm/PortfolioGreeksHistory.mjs +255 -27
  179. package/esm/ScheduledOptionOrder.d.ts.map +1 -1
  180. package/esm/ScheduledOptionOrder.js.map +1 -1
  181. package/esm/ScheduledOptionOrder.mjs +255 -27
  182. package/esm/Session.d.ts.map +1 -1
  183. package/esm/Session.js.map +1 -1
  184. package/esm/Session.mjs +255 -27
  185. package/esm/SignalGeneratorMetrics.d.ts.map +1 -1
  186. package/esm/SignalGeneratorMetrics.js.map +1 -1
  187. package/esm/SignalGeneratorMetrics.mjs +255 -27
  188. package/esm/SignalLineage.d.ts.map +1 -1
  189. package/esm/SignalLineage.js.map +1 -1
  190. package/esm/SignalLineage.mjs +255 -27
  191. package/esm/SignalOutcome.d.ts.map +1 -1
  192. package/esm/SignalOutcome.js.map +1 -1
  193. package/esm/SignalOutcome.mjs +255 -27
  194. package/esm/SignalPriorityQueue.d.ts.map +1 -1
  195. package/esm/SignalPriorityQueue.js.map +1 -1
  196. package/esm/SignalPriorityQueue.mjs +255 -27
  197. package/esm/SyncEvent.d.ts.map +1 -1
  198. package/esm/SyncEvent.js.map +1 -1
  199. package/esm/SyncEvent.mjs +255 -27
  200. package/esm/SystemAlert.d.ts.map +1 -1
  201. package/esm/SystemAlert.js.map +1 -1
  202. package/esm/SystemAlert.mjs +255 -27
  203. package/esm/Trade.d.ts.map +1 -1
  204. package/esm/Trade.js.map +1 -1
  205. package/esm/Trade.mjs +255 -27
  206. package/esm/TradeAuditEvent.d.ts.map +1 -1
  207. package/esm/TradeAuditEvent.js.map +1 -1
  208. package/esm/TradeAuditEvent.mjs +255 -27
  209. package/esm/TradeExecutionHistory.d.ts.map +1 -1
  210. package/esm/TradeExecutionHistory.js.map +1 -1
  211. package/esm/TradeExecutionHistory.mjs +255 -27
  212. package/esm/User.d.ts.map +1 -1
  213. package/esm/User.js.map +1 -1
  214. package/esm/User.mjs +255 -27
  215. package/esm/VerificationToken.d.ts.map +1 -1
  216. package/esm/VerificationToken.js.map +1 -1
  217. package/esm/VerificationToken.mjs +255 -27
  218. package/esm/WaitlistEntry.d.ts.map +1 -1
  219. package/esm/WaitlistEntry.js.map +1 -1
  220. package/esm/WaitlistEntry.mjs +255 -27
  221. package/esm/middleware/audit-logger.d.ts +0 -7
  222. package/esm/middleware/audit-logger.d.ts.map +1 -1
  223. package/esm/middleware/audit-logger.js.map +1 -1
  224. package/esm/middleware/audit-logger.mjs +5 -3
  225. package/esm/prismaClient.d.ts.map +1 -1
  226. package/esm/prismaClient.js.map +1 -1
  227. package/esm/prismaClient.mjs +38 -9
  228. package/package.json +1 -1
  229. package/prismaClient.cjs +38 -9
package/esm/AuditLog.mjs CHANGED
@@ -85,6 +85,27 @@ export const AuditLog = {
85
85
  }
86
86
  catch (error) {
87
87
  lastError = error;
88
+ // Check for constraint violations FIRST - these are NEVER retryable
89
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
90
+ error.message?.includes('violates unique constraint') ||
91
+ error.message?.includes('violates foreign key constraint') ||
92
+ error.message?.includes('unique constraint') ||
93
+ error.message?.includes('23514') ||
94
+ error.message?.includes('23505') ||
95
+ error.message?.includes('P2002') ||
96
+ error.message?.includes('P2003');
97
+ if (isConstraintViolation) {
98
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
99
+ logger.error("Non-retryable constraint violation in createOneAuditLog", {
100
+ operation: 'createOneAuditLog',
101
+ model: 'AuditLog',
102
+ error: String(error),
103
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
104
+ errorCategory: 'CONSTRAINT_VIOLATION',
105
+ isRetryable: false,
106
+ });
107
+ throw error;
108
+ }
88
109
  // Check if this is a database connection error that we should retry
89
110
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
90
111
  error.message?.includes('Cannot reach database server') ||
@@ -94,12 +115,22 @@ export const AuditLog = {
94
115
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
95
116
  retryCount++;
96
117
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
97
- logger.warn("Database connection error, retrying...");
118
+ logger.warn("Database connection error in createOneAuditLog, retrying...", {
119
+ operation: 'createOneAuditLog',
120
+ model: 'AuditLog',
121
+ attempt: retryCount,
122
+ maxRetries: MAX_RETRIES,
123
+ });
98
124
  await new Promise(resolve => setTimeout(resolve, delay));
99
125
  continue;
100
126
  }
101
- // Log the error and rethrow
102
- logger.error("Database error occurred", { error: String(error) });
127
+ // Log structured error details and rethrow
128
+ logger.error("Database create operation failed", {
129
+ operation: 'createOneAuditLog',
130
+ model: 'AuditLog',
131
+ error: String(error),
132
+ isRetryable: isConnectionError,
133
+ });
103
134
  throw error;
104
135
  }
105
136
  }
@@ -165,6 +196,27 @@ export const AuditLog = {
165
196
  }
166
197
  catch (error) {
167
198
  lastError = error;
199
+ // Check for constraint violations FIRST - these are NEVER retryable
200
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
201
+ error.message?.includes('violates unique constraint') ||
202
+ error.message?.includes('violates foreign key constraint') ||
203
+ error.message?.includes('unique constraint') ||
204
+ error.message?.includes('23514') ||
205
+ error.message?.includes('23505') ||
206
+ error.message?.includes('P2002') ||
207
+ error.message?.includes('P2003');
208
+ if (isConstraintViolation) {
209
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
210
+ logger.error("Non-retryable constraint violation in createManyAuditLog", {
211
+ operation: 'createManyAuditLog',
212
+ model: 'AuditLog',
213
+ error: String(error),
214
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
215
+ errorCategory: 'CONSTRAINT_VIOLATION',
216
+ isRetryable: false,
217
+ });
218
+ throw error;
219
+ }
168
220
  // Check if this is a database connection error that we should retry
169
221
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
170
222
  error.message?.includes('Cannot reach database server') ||
@@ -174,12 +226,22 @@ export const AuditLog = {
174
226
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
175
227
  retryCount++;
176
228
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
177
- logger.warn("Database connection error, retrying...");
229
+ logger.warn("Database connection error in createManyAuditLog, retrying...", {
230
+ operation: 'createManyAuditLog',
231
+ model: 'AuditLog',
232
+ attempt: retryCount,
233
+ maxRetries: MAX_RETRIES,
234
+ });
178
235
  await new Promise(resolve => setTimeout(resolve, delay));
179
236
  continue;
180
237
  }
181
- // Log the error and rethrow
182
- logger.error("Database error occurred", { error: String(error) });
238
+ // Log structured error details and rethrow
239
+ logger.error("Database createMany operation failed", {
240
+ operation: 'createManyAuditLog',
241
+ model: 'AuditLog',
242
+ error: String(error),
243
+ isRetryable: isConnectionError,
244
+ });
183
245
  throw error;
184
246
  }
185
247
  }
@@ -272,6 +334,28 @@ export const AuditLog = {
272
334
  }
273
335
  catch (error) {
274
336
  lastError = error;
337
+ // Check for constraint violations FIRST - these are NEVER retryable
338
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
339
+ error.message?.includes('violates unique constraint') ||
340
+ error.message?.includes('violates foreign key constraint') ||
341
+ error.message?.includes('unique constraint') ||
342
+ error.message?.includes('23514') ||
343
+ error.message?.includes('23505') ||
344
+ error.message?.includes('P2002') ||
345
+ error.message?.includes('P2003');
346
+ if (isConstraintViolation) {
347
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
348
+ logger.error("Non-retryable constraint violation in updateOneAuditLog", {
349
+ operation: 'updateOneAuditLog',
350
+ model: 'AuditLog',
351
+ error: String(error),
352
+ recordId: props.id,
353
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
354
+ errorCategory: 'CONSTRAINT_VIOLATION',
355
+ isRetryable: false,
356
+ });
357
+ throw error;
358
+ }
275
359
  // Check if this is a database connection error that we should retry
276
360
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
277
361
  error.message?.includes('Cannot reach database server') ||
@@ -281,12 +365,24 @@ export const AuditLog = {
281
365
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
282
366
  retryCount++;
283
367
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
284
- logger.warn("Database connection error, retrying...");
368
+ logger.warn("Database connection error in updateOneAuditLog, retrying...", {
369
+ operation: 'updateOneAuditLog',
370
+ model: 'AuditLog',
371
+ attempt: retryCount,
372
+ maxRetries: MAX_RETRIES,
373
+ recordId: props.id,
374
+ });
285
375
  await new Promise(resolve => setTimeout(resolve, delay));
286
376
  continue;
287
377
  }
288
- // Log the error and rethrow
289
- logger.error("Database error occurred", { error: String(error) });
378
+ // Log structured error details and rethrow
379
+ logger.error("Database update operation failed", {
380
+ operation: 'updateOneAuditLog',
381
+ model: 'AuditLog',
382
+ error: String(error),
383
+ recordId: props.id,
384
+ isRetryable: isConnectionError,
385
+ });
290
386
  throw error;
291
387
  }
292
388
  }
@@ -387,6 +483,28 @@ export const AuditLog = {
387
483
  }
388
484
  catch (error) {
389
485
  lastError = error;
486
+ // Check for constraint violations FIRST - these are NEVER retryable
487
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
488
+ error.message?.includes('violates unique constraint') ||
489
+ error.message?.includes('violates foreign key constraint') ||
490
+ error.message?.includes('unique constraint') ||
491
+ error.message?.includes('23514') ||
492
+ error.message?.includes('23505') ||
493
+ error.message?.includes('P2002') ||
494
+ error.message?.includes('P2003');
495
+ if (isConstraintViolation) {
496
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
497
+ logger.error("Non-retryable constraint violation in upsertOneAuditLog", {
498
+ operation: 'upsertOneAuditLog',
499
+ model: 'AuditLog',
500
+ error: String(error),
501
+ recordId: props.id,
502
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
503
+ errorCategory: 'CONSTRAINT_VIOLATION',
504
+ isRetryable: false,
505
+ });
506
+ throw error;
507
+ }
390
508
  // Check if this is a database connection error that we should retry
391
509
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
392
510
  error.message?.includes('Cannot reach database server') ||
@@ -396,12 +514,24 @@ export const AuditLog = {
396
514
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
397
515
  retryCount++;
398
516
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
399
- logger.warn("Database connection error, retrying...");
517
+ logger.warn("Database connection error in upsertOneAuditLog, retrying...", {
518
+ operation: 'upsertOneAuditLog',
519
+ model: 'AuditLog',
520
+ attempt: retryCount,
521
+ maxRetries: MAX_RETRIES,
522
+ recordId: props.id,
523
+ });
400
524
  await new Promise(resolve => setTimeout(resolve, delay));
401
525
  continue;
402
526
  }
403
- // Log the error and rethrow
404
- logger.error("Database error occurred", { error: String(error) });
527
+ // Log structured error details and rethrow
528
+ logger.error("Database upsert operation failed", {
529
+ operation: 'upsertOneAuditLog',
530
+ model: 'AuditLog',
531
+ error: String(error),
532
+ recordId: props.id,
533
+ isRetryable: isConnectionError,
534
+ });
405
535
  throw error;
406
536
  }
407
537
  }
@@ -494,6 +624,27 @@ export const AuditLog = {
494
624
  }
495
625
  catch (error) {
496
626
  lastError = error;
627
+ // Check for constraint violations FIRST - these are NEVER retryable
628
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
629
+ error.message?.includes('violates unique constraint') ||
630
+ error.message?.includes('violates foreign key constraint') ||
631
+ error.message?.includes('unique constraint') ||
632
+ error.message?.includes('23514') ||
633
+ error.message?.includes('23505') ||
634
+ error.message?.includes('P2002') ||
635
+ error.message?.includes('P2003');
636
+ if (isConstraintViolation) {
637
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
638
+ logger.error("Non-retryable constraint violation in updateManyAuditLog", {
639
+ operation: 'updateManyAuditLog',
640
+ model: 'AuditLog',
641
+ error: String(error),
642
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
643
+ errorCategory: 'CONSTRAINT_VIOLATION',
644
+ isRetryable: false,
645
+ });
646
+ throw error;
647
+ }
497
648
  // Check if this is a database connection error that we should retry
498
649
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
499
650
  error.message?.includes('Cannot reach database server') ||
@@ -503,12 +654,22 @@ export const AuditLog = {
503
654
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
504
655
  retryCount++;
505
656
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
506
- logger.warn("Database connection error, retrying...");
657
+ logger.warn("Database connection error in updateManyAuditLog, retrying...", {
658
+ operation: 'updateManyAuditLog',
659
+ model: 'AuditLog',
660
+ attempt: retryCount,
661
+ maxRetries: MAX_RETRIES,
662
+ });
507
663
  await new Promise(resolve => setTimeout(resolve, delay));
508
664
  continue;
509
665
  }
510
- // Log the error and rethrow
511
- logger.error("Database error occurred", { error: String(error) });
666
+ // Log structured error details and rethrow
667
+ logger.error("Database updateMany operation failed", {
668
+ operation: 'updateManyAuditLog',
669
+ model: 'AuditLog',
670
+ error: String(error),
671
+ isRetryable: isConnectionError,
672
+ });
512
673
  throw error;
513
674
  }
514
675
  }
@@ -566,6 +727,31 @@ export const AuditLog = {
566
727
  }
567
728
  catch (error) {
568
729
  lastError = error;
730
+ // Check for constraint violations FIRST - these are NEVER retryable
731
+ // (e.g., foreign key constraints preventing deletion)
732
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
733
+ error.message?.includes('violates unique constraint') ||
734
+ error.message?.includes('violates foreign key constraint') ||
735
+ error.message?.includes('unique constraint') ||
736
+ error.message?.includes('23514') ||
737
+ error.message?.includes('23505') ||
738
+ error.message?.includes('23503') ||
739
+ error.message?.includes('P2002') ||
740
+ error.message?.includes('P2003') ||
741
+ error.message?.includes('P2014');
742
+ if (isConstraintViolation) {
743
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
744
+ logger.error("Non-retryable constraint violation in deleteOneAuditLog", {
745
+ operation: 'deleteOneAuditLog',
746
+ model: 'AuditLog',
747
+ error: String(error),
748
+ recordId: props.id,
749
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
750
+ errorCategory: 'CONSTRAINT_VIOLATION',
751
+ isRetryable: false,
752
+ });
753
+ throw error;
754
+ }
569
755
  // Check if this is a database connection error that we should retry
570
756
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
571
757
  error.message?.includes('Cannot reach database server') ||
@@ -575,12 +761,24 @@ export const AuditLog = {
575
761
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
576
762
  retryCount++;
577
763
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
578
- logger.warn("Database connection error, retrying...");
764
+ logger.warn("Database connection error in deleteOneAuditLog, retrying...", {
765
+ operation: 'deleteOneAuditLog',
766
+ model: 'AuditLog',
767
+ attempt: retryCount,
768
+ maxRetries: MAX_RETRIES,
769
+ recordId: props.id,
770
+ });
579
771
  await new Promise(resolve => setTimeout(resolve, delay));
580
772
  continue;
581
773
  }
582
- // Log the error and rethrow
583
- logger.error("Database error occurred", { error: String(error) });
774
+ // Log structured error details and rethrow
775
+ logger.error("Database delete operation failed", {
776
+ operation: 'deleteOneAuditLog',
777
+ model: 'AuditLog',
778
+ error: String(error),
779
+ recordId: props.id,
780
+ isRetryable: isConnectionError,
781
+ });
584
782
  throw error;
585
783
  }
586
784
  }
@@ -649,12 +847,22 @@ export const AuditLog = {
649
847
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
650
848
  retryCount++;
651
849
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
652
- logger.warn("Database connection error, retrying...");
850
+ logger.warn("Database connection error in getAuditLog, retrying...", {
851
+ operation: 'getAuditLog',
852
+ model: 'AuditLog',
853
+ attempt: retryCount,
854
+ maxRetries: MAX_RETRIES,
855
+ });
653
856
  await new Promise(resolve => setTimeout(resolve, delay));
654
857
  continue;
655
858
  }
656
- // Log the error and rethrow
657
- logger.error("Database error occurred", { error: String(error) });
859
+ // Log structured error details and rethrow
860
+ logger.error("Database get operation failed", {
861
+ operation: 'getAuditLog',
862
+ model: 'AuditLog',
863
+ error: String(error),
864
+ isRetryable: isConnectionError,
865
+ });
658
866
  throw error;
659
867
  }
660
868
  }
@@ -711,12 +919,22 @@ export const AuditLog = {
711
919
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
712
920
  retryCount++;
713
921
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
714
- logger.warn("Database connection error, retrying...");
922
+ logger.warn("Database connection error in getAllAuditLog, retrying...", {
923
+ operation: 'getAllAuditLog',
924
+ model: 'AuditLog',
925
+ attempt: retryCount,
926
+ maxRetries: MAX_RETRIES,
927
+ });
715
928
  await new Promise(resolve => setTimeout(resolve, delay));
716
929
  continue;
717
930
  }
718
- // Log the error and rethrow
719
- logger.error("Database error occurred", { error: String(error) });
931
+ // Log structured error details and rethrow
932
+ logger.error("Database getAll operation failed", {
933
+ operation: 'getAllAuditLog',
934
+ model: 'AuditLog',
935
+ error: String(error),
936
+ isRetryable: isConnectionError,
937
+ });
720
938
  throw error;
721
939
  }
722
940
  }
@@ -792,12 +1010,22 @@ export const AuditLog = {
792
1010
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
793
1011
  retryCount++;
794
1012
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
795
- logger.warn("Database connection error, retrying...");
1013
+ logger.warn("Database connection error in findManyAuditLog, retrying...", {
1014
+ operation: 'findManyAuditLog',
1015
+ model: 'AuditLog',
1016
+ attempt: retryCount,
1017
+ maxRetries: MAX_RETRIES,
1018
+ });
796
1019
  await new Promise(resolve => setTimeout(resolve, delay));
797
1020
  continue;
798
1021
  }
799
- // Log the error and rethrow
800
- logger.error("Database error occurred", { error: String(error) });
1022
+ // Log structured error details and rethrow
1023
+ logger.error("Database findMany operation failed", {
1024
+ operation: 'findManyAuditLog',
1025
+ model: 'AuditLog',
1026
+ error: String(error),
1027
+ isRetryable: isConnectionError,
1028
+ });
801
1029
  throw error;
802
1030
  }
803
1031
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Authenticator.d.ts","sourceRoot":"","sources":["../../src/Authenticator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AACzG,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AAmM7G,eAAO,MAAM,aAAa;IAExB;;;;;OAKG;IAEH;;;;;;OAMG;kBACiB,iBAAiB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA6Y5H;;;;;;OAMG;sBACqB,iBAAiB,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IA8EvI;;;;;;OAMG;kBACiB,iBAAiB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAopC1H;;;;;;OAMG;kBACiB,iBAAiB,iBAAiB,gBAAgB,CAAC,qBAAq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