@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/Alert.cjs CHANGED
@@ -42,7 +42,7 @@ exports.Alert = {
42
42
  * @returns The created Alert or null.
43
43
  */
44
44
  async create(props, globalClient) {
45
- var _a, _b, _c, _d, _e;
45
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
46
46
  // Maximum number of retries for database connection issues
47
47
  const MAX_RETRIES = 3;
48
48
  let retryCount = 0;
@@ -381,21 +381,52 @@ exports.Alert = {
381
381
  }
382
382
  catch (error) {
383
383
  lastError = error;
384
+ // Check for constraint violations FIRST - these are NEVER retryable
385
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
386
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
387
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
388
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
389
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
390
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
391
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
392
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
393
+ if (isConstraintViolation) {
394
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
395
+ logger_1.logger.error("Non-retryable constraint violation in createOneAlert", {
396
+ operation: 'createOneAlert',
397
+ model: 'Alert',
398
+ error: String(error),
399
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
400
+ errorCategory: 'CONSTRAINT_VIOLATION',
401
+ isRetryable: false,
402
+ });
403
+ throw error;
404
+ }
384
405
  // Check if this is a database connection error that we should retry
385
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
386
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
387
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
388
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
389
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
406
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
407
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
408
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
409
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
410
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
390
411
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
391
412
  retryCount++;
392
413
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
393
- logger_1.logger.warn("Database connection error, retrying...");
414
+ logger_1.logger.warn("Database connection error in createOneAlert, retrying...", {
415
+ operation: 'createOneAlert',
416
+ model: 'Alert',
417
+ attempt: retryCount,
418
+ maxRetries: MAX_RETRIES,
419
+ });
394
420
  await new Promise(resolve => setTimeout(resolve, delay));
395
421
  continue;
396
422
  }
397
- // Log the error and rethrow
398
- logger_1.logger.error("Database error occurred", { error: String(error) });
423
+ // Log structured error details and rethrow
424
+ logger_1.logger.error("Database create operation failed", {
425
+ operation: 'createOneAlert',
426
+ model: 'Alert',
427
+ error: String(error),
428
+ isRetryable: isConnectionError,
429
+ });
399
430
  throw error;
400
431
  }
401
432
  }
@@ -410,7 +441,7 @@ exports.Alert = {
410
441
  * @returns The count of created records or null.
411
442
  */
412
443
  async createMany(props, globalClient) {
413
- var _a, _b, _c, _d, _e;
444
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
414
445
  // Maximum number of retries for database connection issues
415
446
  const MAX_RETRIES = 3;
416
447
  let retryCount = 0;
@@ -466,21 +497,52 @@ exports.Alert = {
466
497
  }
467
498
  catch (error) {
468
499
  lastError = error;
500
+ // Check for constraint violations FIRST - these are NEVER retryable
501
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
502
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
503
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
504
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
505
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
506
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
507
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
508
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
509
+ if (isConstraintViolation) {
510
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
511
+ logger_1.logger.error("Non-retryable constraint violation in createManyAlert", {
512
+ operation: 'createManyAlert',
513
+ model: 'Alert',
514
+ error: String(error),
515
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
516
+ errorCategory: 'CONSTRAINT_VIOLATION',
517
+ isRetryable: false,
518
+ });
519
+ throw error;
520
+ }
469
521
  // Check if this is a database connection error that we should retry
470
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
471
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
472
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
473
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
474
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
522
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
523
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
524
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
525
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
526
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
475
527
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
476
528
  retryCount++;
477
529
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
478
- logger_1.logger.warn("Database connection error, retrying...");
530
+ logger_1.logger.warn("Database connection error in createManyAlert, retrying...", {
531
+ operation: 'createManyAlert',
532
+ model: 'Alert',
533
+ attempt: retryCount,
534
+ maxRetries: MAX_RETRIES,
535
+ });
479
536
  await new Promise(resolve => setTimeout(resolve, delay));
480
537
  continue;
481
538
  }
482
- // Log the error and rethrow
483
- logger_1.logger.error("Database error occurred", { error: String(error) });
539
+ // Log structured error details and rethrow
540
+ logger_1.logger.error("Database createMany operation failed", {
541
+ operation: 'createManyAlert',
542
+ model: 'Alert',
543
+ error: String(error),
544
+ isRetryable: isConnectionError,
545
+ });
484
546
  throw error;
485
547
  }
486
548
  }
@@ -495,7 +557,7 @@ exports.Alert = {
495
557
  * @returns The updated Alert or null.
496
558
  */
497
559
  async update(props, globalClient) {
498
- var _a, _b, _c, _d, _e;
560
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
499
561
  // Maximum number of retries for database connection issues
500
562
  const MAX_RETRIES = 3;
501
563
  let retryCount = 0;
@@ -1644,21 +1706,55 @@ exports.Alert = {
1644
1706
  }
1645
1707
  catch (error) {
1646
1708
  lastError = error;
1709
+ // Check for constraint violations FIRST - these are NEVER retryable
1710
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
1711
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
1712
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
1713
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
1714
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
1715
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
1716
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
1717
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
1718
+ if (isConstraintViolation) {
1719
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
1720
+ logger_1.logger.error("Non-retryable constraint violation in updateOneAlert", {
1721
+ operation: 'updateOneAlert',
1722
+ model: 'Alert',
1723
+ error: String(error),
1724
+ recordId: props.id,
1725
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1726
+ errorCategory: 'CONSTRAINT_VIOLATION',
1727
+ isRetryable: false,
1728
+ });
1729
+ throw error;
1730
+ }
1647
1731
  // Check if this is a database connection error that we should retry
1648
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
1649
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
1650
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
1651
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
1652
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
1732
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
1733
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
1734
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
1735
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
1736
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
1653
1737
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1654
1738
  retryCount++;
1655
1739
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1656
- logger_1.logger.warn("Database connection error, retrying...");
1740
+ logger_1.logger.warn("Database connection error in updateOneAlert, retrying...", {
1741
+ operation: 'updateOneAlert',
1742
+ model: 'Alert',
1743
+ attempt: retryCount,
1744
+ maxRetries: MAX_RETRIES,
1745
+ recordId: props.id,
1746
+ });
1657
1747
  await new Promise(resolve => setTimeout(resolve, delay));
1658
1748
  continue;
1659
1749
  }
1660
- // Log the error and rethrow
1661
- logger_1.logger.error("Database error occurred", { error: String(error) });
1750
+ // Log structured error details and rethrow
1751
+ logger_1.logger.error("Database update operation failed", {
1752
+ operation: 'updateOneAlert',
1753
+ model: 'Alert',
1754
+ error: String(error),
1755
+ recordId: props.id,
1756
+ isRetryable: isConnectionError,
1757
+ });
1662
1758
  throw error;
1663
1759
  }
1664
1760
  }
@@ -1673,7 +1769,7 @@ exports.Alert = {
1673
1769
  * @returns The updated Alert or null.
1674
1770
  */
1675
1771
  async upsert(props, globalClient) {
1676
- var _a, _b, _c, _d, _e;
1772
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1677
1773
  // Maximum number of retries for database connection issues
1678
1774
  const MAX_RETRIES = 3;
1679
1775
  let retryCount = 0;
@@ -3110,21 +3206,55 @@ exports.Alert = {
3110
3206
  }
3111
3207
  catch (error) {
3112
3208
  lastError = error;
3209
+ // Check for constraint violations FIRST - these are NEVER retryable
3210
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
3211
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
3212
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
3213
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
3214
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
3215
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
3216
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
3217
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
3218
+ if (isConstraintViolation) {
3219
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
3220
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneAlert", {
3221
+ operation: 'upsertOneAlert',
3222
+ model: 'Alert',
3223
+ error: String(error),
3224
+ recordId: props.id,
3225
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
3226
+ errorCategory: 'CONSTRAINT_VIOLATION',
3227
+ isRetryable: false,
3228
+ });
3229
+ throw error;
3230
+ }
3113
3231
  // Check if this is a database connection error that we should retry
3114
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
3115
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
3116
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
3117
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
3118
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
3232
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
3233
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
3234
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
3235
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
3236
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
3119
3237
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
3120
3238
  retryCount++;
3121
3239
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
3122
- logger_1.logger.warn("Database connection error, retrying...");
3240
+ logger_1.logger.warn("Database connection error in upsertOneAlert, retrying...", {
3241
+ operation: 'upsertOneAlert',
3242
+ model: 'Alert',
3243
+ attempt: retryCount,
3244
+ maxRetries: MAX_RETRIES,
3245
+ recordId: props.id,
3246
+ });
3123
3247
  await new Promise(resolve => setTimeout(resolve, delay));
3124
3248
  continue;
3125
3249
  }
3126
- // Log the error and rethrow
3127
- logger_1.logger.error("Database error occurred", { error: String(error) });
3250
+ // Log structured error details and rethrow
3251
+ logger_1.logger.error("Database upsert operation failed", {
3252
+ operation: 'upsertOneAlert',
3253
+ model: 'Alert',
3254
+ error: String(error),
3255
+ recordId: props.id,
3256
+ isRetryable: isConnectionError,
3257
+ });
3128
3258
  throw error;
3129
3259
  }
3130
3260
  }
@@ -3139,7 +3269,7 @@ exports.Alert = {
3139
3269
  * @returns The count of created records or null.
3140
3270
  */
3141
3271
  async updateMany(props, globalClient) {
3142
- var _a, _b, _c, _d, _e;
3272
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
3143
3273
  // Maximum number of retries for database connection issues
3144
3274
  const MAX_RETRIES = 3;
3145
3275
  let retryCount = 0;
@@ -4288,21 +4418,52 @@ exports.Alert = {
4288
4418
  }
4289
4419
  catch (error) {
4290
4420
  lastError = error;
4421
+ // Check for constraint violations FIRST - these are NEVER retryable
4422
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
4423
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
4424
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
4425
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
4426
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
4427
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
4428
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
4429
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
4430
+ if (isConstraintViolation) {
4431
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
4432
+ logger_1.logger.error("Non-retryable constraint violation in updateManyAlert", {
4433
+ operation: 'updateManyAlert',
4434
+ model: 'Alert',
4435
+ error: String(error),
4436
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
4437
+ errorCategory: 'CONSTRAINT_VIOLATION',
4438
+ isRetryable: false,
4439
+ });
4440
+ throw error;
4441
+ }
4291
4442
  // Check if this is a database connection error that we should retry
4292
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
4293
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
4294
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
4295
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
4296
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
4443
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
4444
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
4445
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
4446
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
4447
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
4297
4448
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4298
4449
  retryCount++;
4299
4450
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4300
- logger_1.logger.warn("Database connection error, retrying...");
4451
+ logger_1.logger.warn("Database connection error in updateManyAlert, retrying...", {
4452
+ operation: 'updateManyAlert',
4453
+ model: 'Alert',
4454
+ attempt: retryCount,
4455
+ maxRetries: MAX_RETRIES,
4456
+ });
4301
4457
  await new Promise(resolve => setTimeout(resolve, delay));
4302
4458
  continue;
4303
4459
  }
4304
- // Log the error and rethrow
4305
- logger_1.logger.error("Database error occurred", { error: String(error) });
4460
+ // Log structured error details and rethrow
4461
+ logger_1.logger.error("Database updateMany operation failed", {
4462
+ operation: 'updateManyAlert',
4463
+ model: 'Alert',
4464
+ error: String(error),
4465
+ isRetryable: isConnectionError,
4466
+ });
4306
4467
  throw error;
4307
4468
  }
4308
4469
  }
@@ -4317,7 +4478,7 @@ exports.Alert = {
4317
4478
  * @returns The deleted Alert or null.
4318
4479
  */
4319
4480
  async delete(props, globalClient) {
4320
- var _a, _b, _c, _d, _e;
4481
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
4321
4482
  // Maximum number of retries for database connection issues
4322
4483
  const MAX_RETRIES = 3;
4323
4484
  let retryCount = 0;
@@ -4361,21 +4522,58 @@ exports.Alert = {
4361
4522
  }
4362
4523
  catch (error) {
4363
4524
  lastError = error;
4525
+ // Check for constraint violations FIRST - these are NEVER retryable
4526
+ // (e.g., foreign key constraints preventing deletion)
4527
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
4528
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
4529
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
4530
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
4531
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
4532
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
4533
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
4534
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
4535
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
4536
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
4537
+ if (isConstraintViolation) {
4538
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
4539
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneAlert", {
4540
+ operation: 'deleteOneAlert',
4541
+ model: 'Alert',
4542
+ error: String(error),
4543
+ recordId: props.id,
4544
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
4545
+ errorCategory: 'CONSTRAINT_VIOLATION',
4546
+ isRetryable: false,
4547
+ });
4548
+ throw error;
4549
+ }
4364
4550
  // Check if this is a database connection error that we should retry
4365
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
4366
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
4367
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
4368
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
4369
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
4551
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
4552
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
4553
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
4554
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
4555
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
4370
4556
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4371
4557
  retryCount++;
4372
4558
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4373
- logger_1.logger.warn("Database connection error, retrying...");
4559
+ logger_1.logger.warn("Database connection error in deleteOneAlert, retrying...", {
4560
+ operation: 'deleteOneAlert',
4561
+ model: 'Alert',
4562
+ attempt: retryCount,
4563
+ maxRetries: MAX_RETRIES,
4564
+ recordId: props.id,
4565
+ });
4374
4566
  await new Promise(resolve => setTimeout(resolve, delay));
4375
4567
  continue;
4376
4568
  }
4377
- // Log the error and rethrow
4378
- logger_1.logger.error("Database error occurred", { error: String(error) });
4569
+ // Log structured error details and rethrow
4570
+ logger_1.logger.error("Database delete operation failed", {
4571
+ operation: 'deleteOneAlert',
4572
+ model: 'Alert',
4573
+ error: String(error),
4574
+ recordId: props.id,
4575
+ isRetryable: isConnectionError,
4576
+ });
4379
4577
  throw error;
4380
4578
  }
4381
4579
  }
@@ -4448,12 +4646,22 @@ exports.Alert = {
4448
4646
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4449
4647
  retryCount++;
4450
4648
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4451
- logger_1.logger.warn("Database connection error, retrying...");
4649
+ logger_1.logger.warn("Database connection error in getAlert, retrying...", {
4650
+ operation: 'getAlert',
4651
+ model: 'Alert',
4652
+ attempt: retryCount,
4653
+ maxRetries: MAX_RETRIES,
4654
+ });
4452
4655
  await new Promise(resolve => setTimeout(resolve, delay));
4453
4656
  continue;
4454
4657
  }
4455
- // Log the error and rethrow
4456
- logger_1.logger.error("Database error occurred", { error: String(error) });
4658
+ // Log structured error details and rethrow
4659
+ logger_1.logger.error("Database get operation failed", {
4660
+ operation: 'getAlert',
4661
+ model: 'Alert',
4662
+ error: String(error),
4663
+ isRetryable: isConnectionError,
4664
+ });
4457
4665
  throw error;
4458
4666
  }
4459
4667
  }
@@ -4511,12 +4719,22 @@ exports.Alert = {
4511
4719
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4512
4720
  retryCount++;
4513
4721
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4514
- logger_1.logger.warn("Database connection error, retrying...");
4722
+ logger_1.logger.warn("Database connection error in getAllAlert, retrying...", {
4723
+ operation: 'getAllAlert',
4724
+ model: 'Alert',
4725
+ attempt: retryCount,
4726
+ maxRetries: MAX_RETRIES,
4727
+ });
4515
4728
  await new Promise(resolve => setTimeout(resolve, delay));
4516
4729
  continue;
4517
4730
  }
4518
- // Log the error and rethrow
4519
- logger_1.logger.error("Database error occurred", { error: String(error) });
4731
+ // Log structured error details and rethrow
4732
+ logger_1.logger.error("Database getAll operation failed", {
4733
+ operation: 'getAllAlert',
4734
+ model: 'Alert',
4735
+ error: String(error),
4736
+ isRetryable: isConnectionError,
4737
+ });
4520
4738
  throw error;
4521
4739
  }
4522
4740
  }
@@ -4596,12 +4814,22 @@ exports.Alert = {
4596
4814
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4597
4815
  retryCount++;
4598
4816
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4599
- logger_1.logger.warn("Database connection error, retrying...");
4817
+ logger_1.logger.warn("Database connection error in findManyAlert, retrying...", {
4818
+ operation: 'findManyAlert',
4819
+ model: 'Alert',
4820
+ attempt: retryCount,
4821
+ maxRetries: MAX_RETRIES,
4822
+ });
4600
4823
  await new Promise(resolve => setTimeout(resolve, delay));
4601
4824
  continue;
4602
4825
  }
4603
- // Log the error and rethrow
4604
- logger_1.logger.error("Database error occurred", { error: String(error) });
4826
+ // Log structured error details and rethrow
4827
+ logger_1.logger.error("Database findMany operation failed", {
4828
+ operation: 'findManyAlert',
4829
+ model: 'Alert',
4830
+ error: String(error),
4831
+ isRetryable: isConnectionError,
4832
+ });
4605
4833
  throw error;
4606
4834
  }
4607
4835
  }