@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
@@ -571,6 +571,27 @@ export const WaitlistEntry = {
571
571
  }
572
572
  catch (error) {
573
573
  lastError = error;
574
+ // Check for constraint violations FIRST - these are NEVER retryable
575
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
576
+ error.message?.includes('violates unique constraint') ||
577
+ error.message?.includes('violates foreign key constraint') ||
578
+ error.message?.includes('unique constraint') ||
579
+ error.message?.includes('23514') ||
580
+ error.message?.includes('23505') ||
581
+ error.message?.includes('P2002') ||
582
+ error.message?.includes('P2003');
583
+ if (isConstraintViolation) {
584
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
585
+ logger.error("Non-retryable constraint violation in createOneWaitlistEntry", {
586
+ operation: 'createOneWaitlistEntry',
587
+ model: 'WaitlistEntry',
588
+ error: String(error),
589
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
590
+ errorCategory: 'CONSTRAINT_VIOLATION',
591
+ isRetryable: false,
592
+ });
593
+ throw error;
594
+ }
574
595
  // Check if this is a database connection error that we should retry
575
596
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
576
597
  error.message?.includes('Cannot reach database server') ||
@@ -580,12 +601,22 @@ export const WaitlistEntry = {
580
601
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
581
602
  retryCount++;
582
603
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
583
- logger.warn("Database connection error, retrying...");
604
+ logger.warn("Database connection error in createOneWaitlistEntry, retrying...", {
605
+ operation: 'createOneWaitlistEntry',
606
+ model: 'WaitlistEntry',
607
+ attempt: retryCount,
608
+ maxRetries: MAX_RETRIES,
609
+ });
584
610
  await new Promise(resolve => setTimeout(resolve, delay));
585
611
  continue;
586
612
  }
587
- // Log the error and rethrow
588
- logger.error("Database error occurred", { error: String(error) });
613
+ // Log structured error details and rethrow
614
+ logger.error("Database create operation failed", {
615
+ operation: 'createOneWaitlistEntry',
616
+ model: 'WaitlistEntry',
617
+ error: String(error),
618
+ isRetryable: isConnectionError,
619
+ });
589
620
  throw error;
590
621
  }
591
622
  }
@@ -652,6 +683,27 @@ export const WaitlistEntry = {
652
683
  }
653
684
  catch (error) {
654
685
  lastError = error;
686
+ // Check for constraint violations FIRST - these are NEVER retryable
687
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
688
+ error.message?.includes('violates unique constraint') ||
689
+ error.message?.includes('violates foreign key constraint') ||
690
+ error.message?.includes('unique constraint') ||
691
+ error.message?.includes('23514') ||
692
+ error.message?.includes('23505') ||
693
+ error.message?.includes('P2002') ||
694
+ error.message?.includes('P2003');
695
+ if (isConstraintViolation) {
696
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
697
+ logger.error("Non-retryable constraint violation in createManyWaitlistEntry", {
698
+ operation: 'createManyWaitlistEntry',
699
+ model: 'WaitlistEntry',
700
+ error: String(error),
701
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
702
+ errorCategory: 'CONSTRAINT_VIOLATION',
703
+ isRetryable: false,
704
+ });
705
+ throw error;
706
+ }
655
707
  // Check if this is a database connection error that we should retry
656
708
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
657
709
  error.message?.includes('Cannot reach database server') ||
@@ -661,12 +713,22 @@ export const WaitlistEntry = {
661
713
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
662
714
  retryCount++;
663
715
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
664
- logger.warn("Database connection error, retrying...");
716
+ logger.warn("Database connection error in createManyWaitlistEntry, retrying...", {
717
+ operation: 'createManyWaitlistEntry',
718
+ model: 'WaitlistEntry',
719
+ attempt: retryCount,
720
+ maxRetries: MAX_RETRIES,
721
+ });
665
722
  await new Promise(resolve => setTimeout(resolve, delay));
666
723
  continue;
667
724
  }
668
- // Log the error and rethrow
669
- logger.error("Database error occurred", { error: String(error) });
725
+ // Log structured error details and rethrow
726
+ logger.error("Database createMany operation failed", {
727
+ operation: 'createManyWaitlistEntry',
728
+ model: 'WaitlistEntry',
729
+ error: String(error),
730
+ isRetryable: isConnectionError,
731
+ });
670
732
  throw error;
671
733
  }
672
734
  }
@@ -1762,6 +1824,28 @@ export const WaitlistEntry = {
1762
1824
  }
1763
1825
  catch (error) {
1764
1826
  lastError = error;
1827
+ // Check for constraint violations FIRST - these are NEVER retryable
1828
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
1829
+ error.message?.includes('violates unique constraint') ||
1830
+ error.message?.includes('violates foreign key constraint') ||
1831
+ error.message?.includes('unique constraint') ||
1832
+ error.message?.includes('23514') ||
1833
+ error.message?.includes('23505') ||
1834
+ error.message?.includes('P2002') ||
1835
+ error.message?.includes('P2003');
1836
+ if (isConstraintViolation) {
1837
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
1838
+ logger.error("Non-retryable constraint violation in updateOneWaitlistEntry", {
1839
+ operation: 'updateOneWaitlistEntry',
1840
+ model: 'WaitlistEntry',
1841
+ error: String(error),
1842
+ recordId: props.id,
1843
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1844
+ errorCategory: 'CONSTRAINT_VIOLATION',
1845
+ isRetryable: false,
1846
+ });
1847
+ throw error;
1848
+ }
1765
1849
  // Check if this is a database connection error that we should retry
1766
1850
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
1767
1851
  error.message?.includes('Cannot reach database server') ||
@@ -1771,12 +1855,24 @@ export const WaitlistEntry = {
1771
1855
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1772
1856
  retryCount++;
1773
1857
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1774
- logger.warn("Database connection error, retrying...");
1858
+ logger.warn("Database connection error in updateOneWaitlistEntry, retrying...", {
1859
+ operation: 'updateOneWaitlistEntry',
1860
+ model: 'WaitlistEntry',
1861
+ attempt: retryCount,
1862
+ maxRetries: MAX_RETRIES,
1863
+ recordId: props.id,
1864
+ });
1775
1865
  await new Promise(resolve => setTimeout(resolve, delay));
1776
1866
  continue;
1777
1867
  }
1778
- // Log the error and rethrow
1779
- logger.error("Database error occurred", { error: String(error) });
1868
+ // Log structured error details and rethrow
1869
+ logger.error("Database update operation failed", {
1870
+ operation: 'updateOneWaitlistEntry',
1871
+ model: 'WaitlistEntry',
1872
+ error: String(error),
1873
+ recordId: props.id,
1874
+ isRetryable: isConnectionError,
1875
+ });
1780
1876
  throw error;
1781
1877
  }
1782
1878
  }
@@ -3188,6 +3284,28 @@ export const WaitlistEntry = {
3188
3284
  }
3189
3285
  catch (error) {
3190
3286
  lastError = error;
3287
+ // Check for constraint violations FIRST - these are NEVER retryable
3288
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
3289
+ error.message?.includes('violates unique constraint') ||
3290
+ error.message?.includes('violates foreign key constraint') ||
3291
+ error.message?.includes('unique constraint') ||
3292
+ error.message?.includes('23514') ||
3293
+ error.message?.includes('23505') ||
3294
+ error.message?.includes('P2002') ||
3295
+ error.message?.includes('P2003');
3296
+ if (isConstraintViolation) {
3297
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
3298
+ logger.error("Non-retryable constraint violation in upsertOneWaitlistEntry", {
3299
+ operation: 'upsertOneWaitlistEntry',
3300
+ model: 'WaitlistEntry',
3301
+ error: String(error),
3302
+ recordId: props.id,
3303
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
3304
+ errorCategory: 'CONSTRAINT_VIOLATION',
3305
+ isRetryable: false,
3306
+ });
3307
+ throw error;
3308
+ }
3191
3309
  // Check if this is a database connection error that we should retry
3192
3310
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
3193
3311
  error.message?.includes('Cannot reach database server') ||
@@ -3197,12 +3315,24 @@ export const WaitlistEntry = {
3197
3315
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
3198
3316
  retryCount++;
3199
3317
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
3200
- logger.warn("Database connection error, retrying...");
3318
+ logger.warn("Database connection error in upsertOneWaitlistEntry, retrying...", {
3319
+ operation: 'upsertOneWaitlistEntry',
3320
+ model: 'WaitlistEntry',
3321
+ attempt: retryCount,
3322
+ maxRetries: MAX_RETRIES,
3323
+ recordId: props.id,
3324
+ });
3201
3325
  await new Promise(resolve => setTimeout(resolve, delay));
3202
3326
  continue;
3203
3327
  }
3204
- // Log the error and rethrow
3205
- logger.error("Database error occurred", { error: String(error) });
3328
+ // Log structured error details and rethrow
3329
+ logger.error("Database upsert operation failed", {
3330
+ operation: 'upsertOneWaitlistEntry',
3331
+ model: 'WaitlistEntry',
3332
+ error: String(error),
3333
+ recordId: props.id,
3334
+ isRetryable: isConnectionError,
3335
+ });
3206
3336
  throw error;
3207
3337
  }
3208
3338
  }
@@ -4298,6 +4428,27 @@ export const WaitlistEntry = {
4298
4428
  }
4299
4429
  catch (error) {
4300
4430
  lastError = error;
4431
+ // Check for constraint violations FIRST - these are NEVER retryable
4432
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
4433
+ error.message?.includes('violates unique constraint') ||
4434
+ error.message?.includes('violates foreign key constraint') ||
4435
+ error.message?.includes('unique constraint') ||
4436
+ error.message?.includes('23514') ||
4437
+ error.message?.includes('23505') ||
4438
+ error.message?.includes('P2002') ||
4439
+ error.message?.includes('P2003');
4440
+ if (isConstraintViolation) {
4441
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
4442
+ logger.error("Non-retryable constraint violation in updateManyWaitlistEntry", {
4443
+ operation: 'updateManyWaitlistEntry',
4444
+ model: 'WaitlistEntry',
4445
+ error: String(error),
4446
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
4447
+ errorCategory: 'CONSTRAINT_VIOLATION',
4448
+ isRetryable: false,
4449
+ });
4450
+ throw error;
4451
+ }
4301
4452
  // Check if this is a database connection error that we should retry
4302
4453
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
4303
4454
  error.message?.includes('Cannot reach database server') ||
@@ -4307,12 +4458,22 @@ export const WaitlistEntry = {
4307
4458
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4308
4459
  retryCount++;
4309
4460
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4310
- logger.warn("Database connection error, retrying...");
4461
+ logger.warn("Database connection error in updateManyWaitlistEntry, retrying...", {
4462
+ operation: 'updateManyWaitlistEntry',
4463
+ model: 'WaitlistEntry',
4464
+ attempt: retryCount,
4465
+ maxRetries: MAX_RETRIES,
4466
+ });
4311
4467
  await new Promise(resolve => setTimeout(resolve, delay));
4312
4468
  continue;
4313
4469
  }
4314
- // Log the error and rethrow
4315
- logger.error("Database error occurred", { error: String(error) });
4470
+ // Log structured error details and rethrow
4471
+ logger.error("Database updateMany operation failed", {
4472
+ operation: 'updateManyWaitlistEntry',
4473
+ model: 'WaitlistEntry',
4474
+ error: String(error),
4475
+ isRetryable: isConnectionError,
4476
+ });
4316
4477
  throw error;
4317
4478
  }
4318
4479
  }
@@ -4370,6 +4531,31 @@ export const WaitlistEntry = {
4370
4531
  }
4371
4532
  catch (error) {
4372
4533
  lastError = error;
4534
+ // Check for constraint violations FIRST - these are NEVER retryable
4535
+ // (e.g., foreign key constraints preventing deletion)
4536
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
4537
+ error.message?.includes('violates unique constraint') ||
4538
+ error.message?.includes('violates foreign key constraint') ||
4539
+ error.message?.includes('unique constraint') ||
4540
+ error.message?.includes('23514') ||
4541
+ error.message?.includes('23505') ||
4542
+ error.message?.includes('23503') ||
4543
+ error.message?.includes('P2002') ||
4544
+ error.message?.includes('P2003') ||
4545
+ error.message?.includes('P2014');
4546
+ if (isConstraintViolation) {
4547
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
4548
+ logger.error("Non-retryable constraint violation in deleteOneWaitlistEntry", {
4549
+ operation: 'deleteOneWaitlistEntry',
4550
+ model: 'WaitlistEntry',
4551
+ error: String(error),
4552
+ recordId: props.id,
4553
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
4554
+ errorCategory: 'CONSTRAINT_VIOLATION',
4555
+ isRetryable: false,
4556
+ });
4557
+ throw error;
4558
+ }
4373
4559
  // Check if this is a database connection error that we should retry
4374
4560
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
4375
4561
  error.message?.includes('Cannot reach database server') ||
@@ -4379,12 +4565,24 @@ export const WaitlistEntry = {
4379
4565
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4380
4566
  retryCount++;
4381
4567
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4382
- logger.warn("Database connection error, retrying...");
4568
+ logger.warn("Database connection error in deleteOneWaitlistEntry, retrying...", {
4569
+ operation: 'deleteOneWaitlistEntry',
4570
+ model: 'WaitlistEntry',
4571
+ attempt: retryCount,
4572
+ maxRetries: MAX_RETRIES,
4573
+ recordId: props.id,
4574
+ });
4383
4575
  await new Promise(resolve => setTimeout(resolve, delay));
4384
4576
  continue;
4385
4577
  }
4386
- // Log the error and rethrow
4387
- logger.error("Database error occurred", { error: String(error) });
4578
+ // Log structured error details and rethrow
4579
+ logger.error("Database delete operation failed", {
4580
+ operation: 'deleteOneWaitlistEntry',
4581
+ model: 'WaitlistEntry',
4582
+ error: String(error),
4583
+ recordId: props.id,
4584
+ isRetryable: isConnectionError,
4585
+ });
4388
4586
  throw error;
4389
4587
  }
4390
4588
  }
@@ -4451,12 +4649,22 @@ export const WaitlistEntry = {
4451
4649
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4452
4650
  retryCount++;
4453
4651
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4454
- logger.warn("Database connection error, retrying...");
4652
+ logger.warn("Database connection error in getWaitlistEntry, retrying...", {
4653
+ operation: 'getWaitlistEntry',
4654
+ model: 'WaitlistEntry',
4655
+ attempt: retryCount,
4656
+ maxRetries: MAX_RETRIES,
4657
+ });
4455
4658
  await new Promise(resolve => setTimeout(resolve, delay));
4456
4659
  continue;
4457
4660
  }
4458
- // Log the error and rethrow
4459
- logger.error("Database error occurred", { error: String(error) });
4661
+ // Log structured error details and rethrow
4662
+ logger.error("Database get operation failed", {
4663
+ operation: 'getWaitlistEntry',
4664
+ model: 'WaitlistEntry',
4665
+ error: String(error),
4666
+ isRetryable: isConnectionError,
4667
+ });
4460
4668
  throw error;
4461
4669
  }
4462
4670
  }
@@ -4513,12 +4721,22 @@ export const WaitlistEntry = {
4513
4721
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4514
4722
  retryCount++;
4515
4723
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4516
- logger.warn("Database connection error, retrying...");
4724
+ logger.warn("Database connection error in getAllWaitlistEntry, retrying...", {
4725
+ operation: 'getAllWaitlistEntry',
4726
+ model: 'WaitlistEntry',
4727
+ attempt: retryCount,
4728
+ maxRetries: MAX_RETRIES,
4729
+ });
4517
4730
  await new Promise(resolve => setTimeout(resolve, delay));
4518
4731
  continue;
4519
4732
  }
4520
- // Log the error and rethrow
4521
- logger.error("Database error occurred", { error: String(error) });
4733
+ // Log structured error details and rethrow
4734
+ logger.error("Database getAll operation failed", {
4735
+ operation: 'getAllWaitlistEntry',
4736
+ model: 'WaitlistEntry',
4737
+ error: String(error),
4738
+ isRetryable: isConnectionError,
4739
+ });
4522
4740
  throw error;
4523
4741
  }
4524
4742
  }
@@ -4594,12 +4812,22 @@ export const WaitlistEntry = {
4594
4812
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4595
4813
  retryCount++;
4596
4814
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4597
- logger.warn("Database connection error, retrying...");
4815
+ logger.warn("Database connection error in findManyWaitlistEntry, retrying...", {
4816
+ operation: 'findManyWaitlistEntry',
4817
+ model: 'WaitlistEntry',
4818
+ attempt: retryCount,
4819
+ maxRetries: MAX_RETRIES,
4820
+ });
4598
4821
  await new Promise(resolve => setTimeout(resolve, delay));
4599
4822
  continue;
4600
4823
  }
4601
- // Log the error and rethrow
4602
- logger.error("Database error occurred", { error: String(error) });
4824
+ // Log structured error details and rethrow
4825
+ logger.error("Database findMany operation failed", {
4826
+ operation: 'findManyWaitlistEntry',
4827
+ model: 'WaitlistEntry',
4828
+ error: String(error),
4829
+ isRetryable: isConnectionError,
4830
+ });
4603
4831
  throw error;
4604
4832
  }
4605
4833
  }
@@ -44,13 +44,6 @@ interface MutationAuditData {
44
44
  * @returns Parsed mutation data or null if not a recognized mutation pattern
45
45
  */
46
46
  declare function parseMutationOperation(operationName: string): MutationAuditData | null;
47
- /**
48
- * Extracts the user ID from the context user object.
49
- * Handles both JWT-decoded objects and raw string tokens.
50
- *
51
- * @param user - The user object from GraphQL context
52
- * @returns The user ID string or null
53
- */
54
47
  declare function extractUserId(user: AuditUser | string | null | undefined): string | null;
55
48
  /**
56
49
  * Extracts the record ID from the mutation result data.
@@ -1 +1 @@
1
- {"version":3,"file":"audit-logger.d.ts","sourceRoot":"","sources":["../../../src/middleware/audit-logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAGnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGnD,0DAA0D;AAC1D,UAAU,SAAS;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wDAAwD;AACxD,UAAU,YAAY;IACpB,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAAC;IACjC,GAAG,CAAC,EAAE;QACJ,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;KACzD,CAAC;CACH;AAED,iEAAiE;AACjE,UAAU,iBAAiB;IACzB,aAAa,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CA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AC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;gCAC7D,SAAS,EAAE,SAAS,CAAC,SAAS;gCAC9B,aAAa,EAAE,SAAS,CAAC,aAAa;6BACvC,CAAC,CAAC;wBACL,CAAC;oBACH,CAAC;gBACH,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,oBAAoB,GACrB,CAAC"}
1
+ {"version":3,"file":"audit-logger.js","sourceRoot":"","sources":["../../../src/middleware/audit-logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AA4BzC,uFAAuF;AACvF,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC9B,UAAU;IACV,SAAS;IACT,mBAAmB;IACnB,eAAe;CAChB,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,SAAS,sBAAsB,CAC7B,aAAqB;IAErB,MAAM,aAAa,GAAG,yCAAyC,CAAC;IAChE,MAAM,aAAa,GAAG,yCAAyC,CAAC;IAChE,MAAM,aAAa,GAAG,+BAA+B,CAAC;IAEtD,IAAI,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC9C,IAAI,KAAK,EAAE,CAAC;QACV,OAAO;YACL,aAAa,EAAE,QAAQ;YACvB,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;YACnB,aAAa;SACd,CAAC;IACJ,CAAC;IAED,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC1C,IAAI,KAAK,EAAE,CAAC;QACV,OAAO;YACL,aAAa,EAAE,QAAQ;YACvB,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;YACnB,aAAa;SACd,CAAC;IACJ,CAAC;IAED,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,aAAa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AC,QAAQ,EAAE,CAAC;gCAC1B,MAAM,gBAAgB,GAAG,YAAY,CAAC,QAIrC,CAAC;gCACF,MAAM,gBAAgB,CAAC,MAAM,CAAC;oCAC5B,IAAI,EAAE;wCACJ,MAAM;wCACN,aAAa,EAAE,SAAS,CAAC,aAAa;wCACtC,SAAS,EAAE,SAAS,CAAC,SAAS;wCAC9B,QAAQ;wCACR,aAAa;wCACb,aAAa,EAAE,SAAS,CAAC,aAAa;wCACtC,SAAS;wCACT,QAAQ,EAAE;4CACR,oBAAoB,EAAE,OAAO,CAAC,aAAa,IAAI,IAAI;yCACpD;qCACF;iCACF,CAAC,CAAC;4BACL,CAAC;iCAAM,CAAC;gCACN,MAAM,CAAC,IAAI,CACT,6DAA6D,CAC9D,CAAC;4BACJ,CAAC;wBACH,CAAC;wBAAC,OAAO,KAAK,EAAE,CAAC;4BACf,6DAA6D;4BAC7D,MAAM,CAAC,KAAK,CAAC,+CAA+C,EAAE;gCAC5D,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;gCAC7D,SAAS,EAAE,SAAS,CAAC,SAAS;gCAC9B,aAAa,EAAE,SAAS,CAAC,aAAa;6BACvC,CAAC,CAAC;wBACL,CAAC;oBACH,CAAC;gBACH,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,oBAAoB,GACrB,CAAC"}
@@ -63,12 +63,14 @@ function parseMutationOperation(operationName) {
63
63
  * @param user - The user object from GraphQL context
64
64
  * @returns The user ID string or null
65
65
  */
66
+ const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
66
67
  function extractUserId(user) {
67
68
  if (!user)
68
69
  return null;
69
- if (typeof user === 'string')
70
- return user;
71
- return user.sub || user.id || null;
70
+ const rawId = typeof user === 'string' ? user : (user.sub || user.id || null);
71
+ if (!rawId)
72
+ return null;
73
+ return UUID_REGEX.test(rawId) ? rawId : null;
72
74
  }
73
75
  /**
74
76
  * Extracts the record ID from the mutation result data.
@@ -1 +1 @@
1
- {"version":3,"file":"prismaClient.d.ts","sourceRoot":"","sources":["../../src/prismaClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,MAAM,EAAE,YAAY,GAAG,SAAS,CAAC;CACtC;AA4ID,QAAA,MAAM,MAAM,EAAE,YAA4B,CAAC;AAE3C,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"prismaClient.d.ts","sourceRoot":"","sources":["../../src/prismaClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,MAAM,EAAE,YAAY,GAAG,SAAS,CAAC;CACtC;AA4KD,QAAA,MAAM,MAAM,EAAE,YAA4B,CAAC;AAE3C,eAAe,MAAM,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"prismaClient.js","sourceRoot":"","sources":["../../src/prismaClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAUxC;;;GAGG;AACH,MAAM,kBAAkB,GAA2B;IACjD,WAAW,EAAE,CAAC;IACd,OAAO,EAAE,EAAE;IACX,UAAU,EAAE,EAAE;CACf,CAAC;AAEF,0FAA0F;AAC1F,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAEtC;;;;;;;;GAQG;AACH,SAAS,eAAe;IACtB,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;IACnD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-based log handlers for pool exhaustion detection
95
+ // Register event-based log handlers with structured error diagnostics
96
96
  client.$on('error', (e) => {
97
97
  const message = e.message || '';
98
- if (message.includes('pool') ||
99
- message.includes('connection') ||
100
- message.includes('timeout')) {
101
- logger.error('Database connection pool exhaustion detected', {
102
- poolSize,
103
- errorMessage: message,
104
- });
98
+ // Build structured error information for actionable diagnostics
99
+ const errorInfo = {
100
+ message,
101
+ timestamp: e.timestamp,
102
+ poolSize,
103
+ };
104
+ // Extract Prisma error code (e.g., P2002 unique constraint, P2003 foreign key)
105
+ const prismaCodeMatch = message.match(/error code:\s*(P\d+)/i)
106
+ || message.match(/(P\d{4})/);
107
+ if (prismaCodeMatch) {
108
+ errorInfo.prismaErrorCode = prismaCodeMatch[1];
109
+ }
110
+ // Extract Postgres error code (e.g., 23514 check constraint, 23505 unique)
111
+ const pgCodeMatch = message.match(/(?:error code|code):\s*(\d{5})/);
112
+ if (pgCodeMatch) {
113
+ errorInfo.postgresErrorCode = pgCodeMatch[1];
114
+ }
115
+ // Extract constraint name for violation diagnostics
116
+ const constraintMatch = message.match(/constraint\s+"([^"]+)"/);
117
+ if (constraintMatch) {
118
+ errorInfo.constraintName = constraintMatch[1];
119
+ }
120
+ // Extract model or table name
121
+ const modelMatch = message.match(/(?:model|table|relation)\s+"?(\w+)"?/i);
122
+ if (modelMatch) {
123
+ errorInfo.model = modelMatch[1];
124
+ }
125
+ // Categorize for alerting and triage
126
+ if (message.includes('pool') || message.includes('connection') || message.includes('timeout')) {
127
+ errorInfo.category = 'CONNECTION_POOL';
128
+ logger.error('Database connection pool issue detected', errorInfo);
129
+ }
130
+ else if (prismaCodeMatch || pgCodeMatch) {
131
+ errorInfo.category = 'DATA_INTEGRITY';
132
+ logger.error('Prisma data integrity error', errorInfo);
105
133
  }
106
134
  else {
107
- logger.error('Prisma client error', { errorMessage: message });
135
+ errorInfo.category = 'UNKNOWN';
136
+ logger.error('Prisma client error', errorInfo);
108
137
  }
109
138
  });
110
139
  client.$on('warn', (e) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptic/backend-legacy",
3
- "version": "0.0.903",
3
+ "version": "0.0.905",
4
4
  "description": "Backend executable CRUD functions with dynamic variables construction, and type definitions for the Adaptic AI platform.",
5
5
  "type": "module",
6
6
  "types": "index.d.ts",
package/prismaClient.cjs CHANGED
@@ -94,19 +94,48 @@ if (!global.prisma) {
94
94
  },
95
95
  },
96
96
  });
97
- // Register event-based log handlers for pool exhaustion detection
97
+ // Register event-based log handlers with structured error diagnostics
98
98
  client.$on('error', (e) => {
99
99
  const message = e.message || '';
100
- if (message.includes('pool') ||
101
- message.includes('connection') ||
102
- message.includes('timeout')) {
103
- logger_1.logger.error('Database connection pool exhaustion detected', {
104
- poolSize,
105
- errorMessage: message,
106
- });
100
+ // Build structured error information for actionable diagnostics
101
+ const errorInfo = {
102
+ message,
103
+ timestamp: e.timestamp,
104
+ poolSize,
105
+ };
106
+ // Extract Prisma error code (e.g., P2002 unique constraint, P2003 foreign key)
107
+ const prismaCodeMatch = message.match(/error code:\s*(P\d+)/i)
108
+ || message.match(/(P\d{4})/);
109
+ if (prismaCodeMatch) {
110
+ errorInfo.prismaErrorCode = prismaCodeMatch[1];
111
+ }
112
+ // Extract Postgres error code (e.g., 23514 check constraint, 23505 unique)
113
+ const pgCodeMatch = message.match(/(?:error code|code):\s*(\d{5})/);
114
+ if (pgCodeMatch) {
115
+ errorInfo.postgresErrorCode = pgCodeMatch[1];
116
+ }
117
+ // Extract constraint name for violation diagnostics
118
+ const constraintMatch = message.match(/constraint\s+"([^"]+)"/);
119
+ if (constraintMatch) {
120
+ errorInfo.constraintName = constraintMatch[1];
121
+ }
122
+ // Extract model or table name
123
+ const modelMatch = message.match(/(?:model|table|relation)\s+"?(\w+)"?/i);
124
+ if (modelMatch) {
125
+ errorInfo.model = modelMatch[1];
126
+ }
127
+ // Categorize for alerting and triage
128
+ if (message.includes('pool') || message.includes('connection') || message.includes('timeout')) {
129
+ errorInfo.category = 'CONNECTION_POOL';
130
+ logger_1.logger.error('Database connection pool issue detected', errorInfo);
131
+ }
132
+ else if (prismaCodeMatch || pgCodeMatch) {
133
+ errorInfo.category = 'DATA_INTEGRITY';
134
+ logger_1.logger.error('Prisma data integrity error', errorInfo);
107
135
  }
108
136
  else {
109
- logger_1.logger.error('Prisma client error', { errorMessage: message });
137
+ errorInfo.category = 'UNKNOWN';
138
+ logger_1.logger.error('Prisma client error', errorInfo);
110
139
  }
111
140
  });
112
141
  client.$on('warn', (e) => {