@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
@@ -73,6 +73,27 @@ export const VerificationToken = {
73
73
  }
74
74
  catch (error) {
75
75
  lastError = error;
76
+ // Check for constraint violations FIRST - these are NEVER retryable
77
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
78
+ error.message?.includes('violates unique constraint') ||
79
+ error.message?.includes('violates foreign key constraint') ||
80
+ error.message?.includes('unique constraint') ||
81
+ error.message?.includes('23514') ||
82
+ error.message?.includes('23505') ||
83
+ error.message?.includes('P2002') ||
84
+ error.message?.includes('P2003');
85
+ if (isConstraintViolation) {
86
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
87
+ logger.error("Non-retryable constraint violation in createOneVerificationToken", {
88
+ operation: 'createOneVerificationToken',
89
+ model: 'VerificationToken',
90
+ error: String(error),
91
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
92
+ errorCategory: 'CONSTRAINT_VIOLATION',
93
+ isRetryable: false,
94
+ });
95
+ throw error;
96
+ }
76
97
  // Check if this is a database connection error that we should retry
77
98
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
78
99
  error.message?.includes('Cannot reach database server') ||
@@ -82,12 +103,22 @@ export const VerificationToken = {
82
103
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
83
104
  retryCount++;
84
105
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
85
- logger.warn("Database connection error, retrying...");
106
+ logger.warn("Database connection error in createOneVerificationToken, retrying...", {
107
+ operation: 'createOneVerificationToken',
108
+ model: 'VerificationToken',
109
+ attempt: retryCount,
110
+ maxRetries: MAX_RETRIES,
111
+ });
86
112
  await new Promise(resolve => setTimeout(resolve, delay));
87
113
  continue;
88
114
  }
89
- // Log the error and rethrow
90
- logger.error("Database error occurred", { error: String(error) });
115
+ // Log structured error details and rethrow
116
+ logger.error("Database create operation failed", {
117
+ operation: 'createOneVerificationToken',
118
+ model: 'VerificationToken',
119
+ error: String(error),
120
+ isRetryable: isConnectionError,
121
+ });
91
122
  throw error;
92
123
  }
93
124
  }
@@ -147,6 +178,27 @@ export const VerificationToken = {
147
178
  }
148
179
  catch (error) {
149
180
  lastError = error;
181
+ // Check for constraint violations FIRST - these are NEVER retryable
182
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
183
+ error.message?.includes('violates unique constraint') ||
184
+ error.message?.includes('violates foreign key constraint') ||
185
+ error.message?.includes('unique constraint') ||
186
+ error.message?.includes('23514') ||
187
+ error.message?.includes('23505') ||
188
+ error.message?.includes('P2002') ||
189
+ error.message?.includes('P2003');
190
+ if (isConstraintViolation) {
191
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
192
+ logger.error("Non-retryable constraint violation in createManyVerificationToken", {
193
+ operation: 'createManyVerificationToken',
194
+ model: 'VerificationToken',
195
+ error: String(error),
196
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
197
+ errorCategory: 'CONSTRAINT_VIOLATION',
198
+ isRetryable: false,
199
+ });
200
+ throw error;
201
+ }
150
202
  // Check if this is a database connection error that we should retry
151
203
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
152
204
  error.message?.includes('Cannot reach database server') ||
@@ -156,12 +208,22 @@ export const VerificationToken = {
156
208
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
157
209
  retryCount++;
158
210
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
159
- logger.warn("Database connection error, retrying...");
211
+ logger.warn("Database connection error in createManyVerificationToken, retrying...", {
212
+ operation: 'createManyVerificationToken',
213
+ model: 'VerificationToken',
214
+ attempt: retryCount,
215
+ maxRetries: MAX_RETRIES,
216
+ });
160
217
  await new Promise(resolve => setTimeout(resolve, delay));
161
218
  continue;
162
219
  }
163
- // Log the error and rethrow
164
- logger.error("Database error occurred", { error: String(error) });
220
+ // Log structured error details and rethrow
221
+ logger.error("Database createMany operation failed", {
222
+ operation: 'createManyVerificationToken',
223
+ model: 'VerificationToken',
224
+ error: String(error),
225
+ isRetryable: isConnectionError,
226
+ });
165
227
  throw error;
166
228
  }
167
229
  }
@@ -233,6 +295,28 @@ export const VerificationToken = {
233
295
  }
234
296
  catch (error) {
235
297
  lastError = error;
298
+ // Check for constraint violations FIRST - these are NEVER retryable
299
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
300
+ error.message?.includes('violates unique constraint') ||
301
+ error.message?.includes('violates foreign key constraint') ||
302
+ error.message?.includes('unique constraint') ||
303
+ error.message?.includes('23514') ||
304
+ error.message?.includes('23505') ||
305
+ error.message?.includes('P2002') ||
306
+ error.message?.includes('P2003');
307
+ if (isConstraintViolation) {
308
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
309
+ logger.error("Non-retryable constraint violation in updateOneVerificationToken", {
310
+ operation: 'updateOneVerificationToken',
311
+ model: 'VerificationToken',
312
+ error: String(error),
313
+ recordId: props.id,
314
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
315
+ errorCategory: 'CONSTRAINT_VIOLATION',
316
+ isRetryable: false,
317
+ });
318
+ throw error;
319
+ }
236
320
  // Check if this is a database connection error that we should retry
237
321
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
238
322
  error.message?.includes('Cannot reach database server') ||
@@ -242,12 +326,24 @@ export const VerificationToken = {
242
326
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
243
327
  retryCount++;
244
328
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
245
- logger.warn("Database connection error, retrying...");
329
+ logger.warn("Database connection error in updateOneVerificationToken, retrying...", {
330
+ operation: 'updateOneVerificationToken',
331
+ model: 'VerificationToken',
332
+ attempt: retryCount,
333
+ maxRetries: MAX_RETRIES,
334
+ recordId: props.id,
335
+ });
246
336
  await new Promise(resolve => setTimeout(resolve, delay));
247
337
  continue;
248
338
  }
249
- // Log the error and rethrow
250
- logger.error("Database error occurred", { error: String(error) });
339
+ // Log structured error details and rethrow
340
+ logger.error("Database update operation failed", {
341
+ operation: 'updateOneVerificationToken',
342
+ model: 'VerificationToken',
343
+ error: String(error),
344
+ recordId: props.id,
345
+ isRetryable: isConnectionError,
346
+ });
251
347
  throw error;
252
348
  }
253
349
  }
@@ -321,6 +417,28 @@ export const VerificationToken = {
321
417
  }
322
418
  catch (error) {
323
419
  lastError = error;
420
+ // Check for constraint violations FIRST - these are NEVER retryable
421
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
422
+ error.message?.includes('violates unique constraint') ||
423
+ error.message?.includes('violates foreign key constraint') ||
424
+ error.message?.includes('unique constraint') ||
425
+ error.message?.includes('23514') ||
426
+ error.message?.includes('23505') ||
427
+ error.message?.includes('P2002') ||
428
+ error.message?.includes('P2003');
429
+ if (isConstraintViolation) {
430
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
431
+ logger.error("Non-retryable constraint violation in upsertOneVerificationToken", {
432
+ operation: 'upsertOneVerificationToken',
433
+ model: 'VerificationToken',
434
+ error: String(error),
435
+ recordId: props.id,
436
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
437
+ errorCategory: 'CONSTRAINT_VIOLATION',
438
+ isRetryable: false,
439
+ });
440
+ throw error;
441
+ }
324
442
  // Check if this is a database connection error that we should retry
325
443
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
326
444
  error.message?.includes('Cannot reach database server') ||
@@ -330,12 +448,24 @@ export const VerificationToken = {
330
448
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
331
449
  retryCount++;
332
450
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
333
- logger.warn("Database connection error, retrying...");
451
+ logger.warn("Database connection error in upsertOneVerificationToken, retrying...", {
452
+ operation: 'upsertOneVerificationToken',
453
+ model: 'VerificationToken',
454
+ attempt: retryCount,
455
+ maxRetries: MAX_RETRIES,
456
+ recordId: props.id,
457
+ });
334
458
  await new Promise(resolve => setTimeout(resolve, delay));
335
459
  continue;
336
460
  }
337
- // Log the error and rethrow
338
- logger.error("Database error occurred", { error: String(error) });
461
+ // Log structured error details and rethrow
462
+ logger.error("Database upsert operation failed", {
463
+ operation: 'upsertOneVerificationToken',
464
+ model: 'VerificationToken',
465
+ error: String(error),
466
+ recordId: props.id,
467
+ isRetryable: isConnectionError,
468
+ });
339
469
  throw error;
340
470
  }
341
471
  }
@@ -407,6 +537,27 @@ export const VerificationToken = {
407
537
  }
408
538
  catch (error) {
409
539
  lastError = error;
540
+ // Check for constraint violations FIRST - these are NEVER retryable
541
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
542
+ error.message?.includes('violates unique constraint') ||
543
+ error.message?.includes('violates foreign key constraint') ||
544
+ error.message?.includes('unique constraint') ||
545
+ error.message?.includes('23514') ||
546
+ error.message?.includes('23505') ||
547
+ error.message?.includes('P2002') ||
548
+ error.message?.includes('P2003');
549
+ if (isConstraintViolation) {
550
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
551
+ logger.error("Non-retryable constraint violation in updateManyVerificationToken", {
552
+ operation: 'updateManyVerificationToken',
553
+ model: 'VerificationToken',
554
+ error: String(error),
555
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
556
+ errorCategory: 'CONSTRAINT_VIOLATION',
557
+ isRetryable: false,
558
+ });
559
+ throw error;
560
+ }
410
561
  // Check if this is a database connection error that we should retry
411
562
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
412
563
  error.message?.includes('Cannot reach database server') ||
@@ -416,12 +567,22 @@ export const VerificationToken = {
416
567
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
417
568
  retryCount++;
418
569
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
419
- logger.warn("Database connection error, retrying...");
570
+ logger.warn("Database connection error in updateManyVerificationToken, retrying...", {
571
+ operation: 'updateManyVerificationToken',
572
+ model: 'VerificationToken',
573
+ attempt: retryCount,
574
+ maxRetries: MAX_RETRIES,
575
+ });
420
576
  await new Promise(resolve => setTimeout(resolve, delay));
421
577
  continue;
422
578
  }
423
- // Log the error and rethrow
424
- logger.error("Database error occurred", { error: String(error) });
579
+ // Log structured error details and rethrow
580
+ logger.error("Database updateMany operation failed", {
581
+ operation: 'updateManyVerificationToken',
582
+ model: 'VerificationToken',
583
+ error: String(error),
584
+ isRetryable: isConnectionError,
585
+ });
425
586
  throw error;
426
587
  }
427
588
  }
@@ -479,6 +640,31 @@ export const VerificationToken = {
479
640
  }
480
641
  catch (error) {
481
642
  lastError = error;
643
+ // Check for constraint violations FIRST - these are NEVER retryable
644
+ // (e.g., foreign key constraints preventing deletion)
645
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
646
+ error.message?.includes('violates unique constraint') ||
647
+ error.message?.includes('violates foreign key constraint') ||
648
+ error.message?.includes('unique constraint') ||
649
+ error.message?.includes('23514') ||
650
+ error.message?.includes('23505') ||
651
+ error.message?.includes('23503') ||
652
+ error.message?.includes('P2002') ||
653
+ error.message?.includes('P2003') ||
654
+ error.message?.includes('P2014');
655
+ if (isConstraintViolation) {
656
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
657
+ logger.error("Non-retryable constraint violation in deleteOneVerificationToken", {
658
+ operation: 'deleteOneVerificationToken',
659
+ model: 'VerificationToken',
660
+ error: String(error),
661
+ recordId: props.id,
662
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
663
+ errorCategory: 'CONSTRAINT_VIOLATION',
664
+ isRetryable: false,
665
+ });
666
+ throw error;
667
+ }
482
668
  // Check if this is a database connection error that we should retry
483
669
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
484
670
  error.message?.includes('Cannot reach database server') ||
@@ -488,12 +674,24 @@ export const VerificationToken = {
488
674
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
489
675
  retryCount++;
490
676
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
491
- logger.warn("Database connection error, retrying...");
677
+ logger.warn("Database connection error in deleteOneVerificationToken, retrying...", {
678
+ operation: 'deleteOneVerificationToken',
679
+ model: 'VerificationToken',
680
+ attempt: retryCount,
681
+ maxRetries: MAX_RETRIES,
682
+ recordId: props.id,
683
+ });
492
684
  await new Promise(resolve => setTimeout(resolve, delay));
493
685
  continue;
494
686
  }
495
- // Log the error and rethrow
496
- logger.error("Database error occurred", { error: String(error) });
687
+ // Log structured error details and rethrow
688
+ logger.error("Database delete operation failed", {
689
+ operation: 'deleteOneVerificationToken',
690
+ model: 'VerificationToken',
691
+ error: String(error),
692
+ recordId: props.id,
693
+ isRetryable: isConnectionError,
694
+ });
497
695
  throw error;
498
696
  }
499
697
  }
@@ -559,12 +757,22 @@ export const VerificationToken = {
559
757
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
560
758
  retryCount++;
561
759
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
562
- logger.warn("Database connection error, retrying...");
760
+ logger.warn("Database connection error in getVerificationToken, retrying...", {
761
+ operation: 'getVerificationToken',
762
+ model: 'VerificationToken',
763
+ attempt: retryCount,
764
+ maxRetries: MAX_RETRIES,
765
+ });
563
766
  await new Promise(resolve => setTimeout(resolve, delay));
564
767
  continue;
565
768
  }
566
- // Log the error and rethrow
567
- logger.error("Database error occurred", { error: String(error) });
769
+ // Log structured error details and rethrow
770
+ logger.error("Database get operation failed", {
771
+ operation: 'getVerificationToken',
772
+ model: 'VerificationToken',
773
+ error: String(error),
774
+ isRetryable: isConnectionError,
775
+ });
568
776
  throw error;
569
777
  }
570
778
  }
@@ -621,12 +829,22 @@ export const VerificationToken = {
621
829
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
622
830
  retryCount++;
623
831
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
624
- logger.warn("Database connection error, retrying...");
832
+ logger.warn("Database connection error in getAllVerificationToken, retrying...", {
833
+ operation: 'getAllVerificationToken',
834
+ model: 'VerificationToken',
835
+ attempt: retryCount,
836
+ maxRetries: MAX_RETRIES,
837
+ });
625
838
  await new Promise(resolve => setTimeout(resolve, delay));
626
839
  continue;
627
840
  }
628
- // Log the error and rethrow
629
- logger.error("Database error occurred", { error: String(error) });
841
+ // Log structured error details and rethrow
842
+ logger.error("Database getAll operation failed", {
843
+ operation: 'getAllVerificationToken',
844
+ model: 'VerificationToken',
845
+ error: String(error),
846
+ isRetryable: isConnectionError,
847
+ });
630
848
  throw error;
631
849
  }
632
850
  }
@@ -699,12 +917,22 @@ export const VerificationToken = {
699
917
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
700
918
  retryCount++;
701
919
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
702
- logger.warn("Database connection error, retrying...");
920
+ logger.warn("Database connection error in findManyVerificationToken, retrying...", {
921
+ operation: 'findManyVerificationToken',
922
+ model: 'VerificationToken',
923
+ attempt: retryCount,
924
+ maxRetries: MAX_RETRIES,
925
+ });
703
926
  await new Promise(resolve => setTimeout(resolve, delay));
704
927
  continue;
705
928
  }
706
- // Log the error and rethrow
707
- logger.error("Database error occurred", { error: String(error) });
929
+ // Log structured error details and rethrow
930
+ logger.error("Database findMany operation failed", {
931
+ operation: 'findManyVerificationToken',
932
+ model: 'VerificationToken',
933
+ error: String(error),
934
+ isRetryable: isConnectionError,
935
+ });
708
936
  throw error;
709
937
  }
710
938
  }
@@ -1 +1 @@
1
- {"version":3,"file":"WaitlistEntry.d.ts","sourceRoot":"","sources":["../../src/WaitlistEntry.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;IA+Y5H;;;;;;OAMG;sBACqB,iBAAiB,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAoFvI;;;;;;OAMG;kBACiB,iBAAiB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAylC1H;;;;;;O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