@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
@@ -484,6 +484,27 @@ export const InviteToken = {
484
484
  }
485
485
  catch (error) {
486
486
  lastError = error;
487
+ // Check for constraint violations FIRST - these are NEVER retryable
488
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
489
+ error.message?.includes('violates unique constraint') ||
490
+ error.message?.includes('violates foreign key constraint') ||
491
+ error.message?.includes('unique constraint') ||
492
+ error.message?.includes('23514') ||
493
+ error.message?.includes('23505') ||
494
+ error.message?.includes('P2002') ||
495
+ error.message?.includes('P2003');
496
+ if (isConstraintViolation) {
497
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
498
+ logger.error("Non-retryable constraint violation in createOneInviteToken", {
499
+ operation: 'createOneInviteToken',
500
+ model: 'InviteToken',
501
+ error: String(error),
502
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
503
+ errorCategory: 'CONSTRAINT_VIOLATION',
504
+ isRetryable: false,
505
+ });
506
+ throw error;
507
+ }
487
508
  // Check if this is a database connection error that we should retry
488
509
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
489
510
  error.message?.includes('Cannot reach database server') ||
@@ -493,12 +514,22 @@ export const InviteToken = {
493
514
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
494
515
  retryCount++;
495
516
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
496
- logger.warn("Database connection error, retrying...");
517
+ logger.warn("Database connection error in createOneInviteToken, retrying...", {
518
+ operation: 'createOneInviteToken',
519
+ model: 'InviteToken',
520
+ attempt: retryCount,
521
+ maxRetries: MAX_RETRIES,
522
+ });
497
523
  await new Promise(resolve => setTimeout(resolve, delay));
498
524
  continue;
499
525
  }
500
- // Log the error and rethrow
501
- logger.error("Database error occurred", { error: String(error) });
526
+ // Log structured error details and rethrow
527
+ logger.error("Database create operation failed", {
528
+ operation: 'createOneInviteToken',
529
+ model: 'InviteToken',
530
+ error: String(error),
531
+ isRetryable: isConnectionError,
532
+ });
502
533
  throw error;
503
534
  }
504
535
  }
@@ -561,6 +592,27 @@ export const InviteToken = {
561
592
  }
562
593
  catch (error) {
563
594
  lastError = error;
595
+ // Check for constraint violations FIRST - these are NEVER retryable
596
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
597
+ error.message?.includes('violates unique constraint') ||
598
+ error.message?.includes('violates foreign key constraint') ||
599
+ error.message?.includes('unique constraint') ||
600
+ error.message?.includes('23514') ||
601
+ error.message?.includes('23505') ||
602
+ error.message?.includes('P2002') ||
603
+ error.message?.includes('P2003');
604
+ if (isConstraintViolation) {
605
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
606
+ logger.error("Non-retryable constraint violation in createManyInviteToken", {
607
+ operation: 'createManyInviteToken',
608
+ model: 'InviteToken',
609
+ error: String(error),
610
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
611
+ errorCategory: 'CONSTRAINT_VIOLATION',
612
+ isRetryable: false,
613
+ });
614
+ throw error;
615
+ }
564
616
  // Check if this is a database connection error that we should retry
565
617
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
566
618
  error.message?.includes('Cannot reach database server') ||
@@ -570,12 +622,22 @@ export const InviteToken = {
570
622
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
571
623
  retryCount++;
572
624
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
573
- logger.warn("Database connection error, retrying...");
625
+ logger.warn("Database connection error in createManyInviteToken, retrying...", {
626
+ operation: 'createManyInviteToken',
627
+ model: 'InviteToken',
628
+ attempt: retryCount,
629
+ maxRetries: MAX_RETRIES,
630
+ });
574
631
  await new Promise(resolve => setTimeout(resolve, delay));
575
632
  continue;
576
633
  }
577
- // Log the error and rethrow
578
- logger.error("Database error occurred", { error: String(error) });
634
+ // Log structured error details and rethrow
635
+ logger.error("Database createMany operation failed", {
636
+ operation: 'createManyInviteToken',
637
+ model: 'InviteToken',
638
+ error: String(error),
639
+ isRetryable: isConnectionError,
640
+ });
579
641
  throw error;
580
642
  }
581
643
  }
@@ -1673,6 +1735,28 @@ export const InviteToken = {
1673
1735
  }
1674
1736
  catch (error) {
1675
1737
  lastError = error;
1738
+ // Check for constraint violations FIRST - these are NEVER retryable
1739
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
1740
+ error.message?.includes('violates unique constraint') ||
1741
+ error.message?.includes('violates foreign key constraint') ||
1742
+ error.message?.includes('unique constraint') ||
1743
+ error.message?.includes('23514') ||
1744
+ error.message?.includes('23505') ||
1745
+ error.message?.includes('P2002') ||
1746
+ error.message?.includes('P2003');
1747
+ if (isConstraintViolation) {
1748
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
1749
+ logger.error("Non-retryable constraint violation in updateOneInviteToken", {
1750
+ operation: 'updateOneInviteToken',
1751
+ model: 'InviteToken',
1752
+ error: String(error),
1753
+ recordId: props.id,
1754
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1755
+ errorCategory: 'CONSTRAINT_VIOLATION',
1756
+ isRetryable: false,
1757
+ });
1758
+ throw error;
1759
+ }
1676
1760
  // Check if this is a database connection error that we should retry
1677
1761
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
1678
1762
  error.message?.includes('Cannot reach database server') ||
@@ -1682,12 +1766,24 @@ export const InviteToken = {
1682
1766
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1683
1767
  retryCount++;
1684
1768
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1685
- logger.warn("Database connection error, retrying...");
1769
+ logger.warn("Database connection error in updateOneInviteToken, retrying...", {
1770
+ operation: 'updateOneInviteToken',
1771
+ model: 'InviteToken',
1772
+ attempt: retryCount,
1773
+ maxRetries: MAX_RETRIES,
1774
+ recordId: props.id,
1775
+ });
1686
1776
  await new Promise(resolve => setTimeout(resolve, delay));
1687
1777
  continue;
1688
1778
  }
1689
- // Log the error and rethrow
1690
- logger.error("Database error occurred", { error: String(error) });
1779
+ // Log structured error details and rethrow
1780
+ logger.error("Database update operation failed", {
1781
+ operation: 'updateOneInviteToken',
1782
+ model: 'InviteToken',
1783
+ error: String(error),
1784
+ recordId: props.id,
1785
+ isRetryable: isConnectionError,
1786
+ });
1691
1787
  throw error;
1692
1788
  }
1693
1789
  }
@@ -3046,6 +3142,28 @@ export const InviteToken = {
3046
3142
  }
3047
3143
  catch (error) {
3048
3144
  lastError = error;
3145
+ // Check for constraint violations FIRST - these are NEVER retryable
3146
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
3147
+ error.message?.includes('violates unique constraint') ||
3148
+ error.message?.includes('violates foreign key constraint') ||
3149
+ error.message?.includes('unique constraint') ||
3150
+ error.message?.includes('23514') ||
3151
+ error.message?.includes('23505') ||
3152
+ error.message?.includes('P2002') ||
3153
+ error.message?.includes('P2003');
3154
+ if (isConstraintViolation) {
3155
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
3156
+ logger.error("Non-retryable constraint violation in upsertOneInviteToken", {
3157
+ operation: 'upsertOneInviteToken',
3158
+ model: 'InviteToken',
3159
+ error: String(error),
3160
+ recordId: props.id,
3161
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
3162
+ errorCategory: 'CONSTRAINT_VIOLATION',
3163
+ isRetryable: false,
3164
+ });
3165
+ throw error;
3166
+ }
3049
3167
  // Check if this is a database connection error that we should retry
3050
3168
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
3051
3169
  error.message?.includes('Cannot reach database server') ||
@@ -3055,12 +3173,24 @@ export const InviteToken = {
3055
3173
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
3056
3174
  retryCount++;
3057
3175
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
3058
- logger.warn("Database connection error, retrying...");
3176
+ logger.warn("Database connection error in upsertOneInviteToken, retrying...", {
3177
+ operation: 'upsertOneInviteToken',
3178
+ model: 'InviteToken',
3179
+ attempt: retryCount,
3180
+ maxRetries: MAX_RETRIES,
3181
+ recordId: props.id,
3182
+ });
3059
3183
  await new Promise(resolve => setTimeout(resolve, delay));
3060
3184
  continue;
3061
3185
  }
3062
- // Log the error and rethrow
3063
- logger.error("Database error occurred", { error: String(error) });
3186
+ // Log structured error details and rethrow
3187
+ logger.error("Database upsert operation failed", {
3188
+ operation: 'upsertOneInviteToken',
3189
+ model: 'InviteToken',
3190
+ error: String(error),
3191
+ recordId: props.id,
3192
+ isRetryable: isConnectionError,
3193
+ });
3064
3194
  throw error;
3065
3195
  }
3066
3196
  }
@@ -4158,6 +4288,27 @@ export const InviteToken = {
4158
4288
  }
4159
4289
  catch (error) {
4160
4290
  lastError = error;
4291
+ // Check for constraint violations FIRST - these are NEVER retryable
4292
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
4293
+ error.message?.includes('violates unique constraint') ||
4294
+ error.message?.includes('violates foreign key constraint') ||
4295
+ error.message?.includes('unique constraint') ||
4296
+ error.message?.includes('23514') ||
4297
+ error.message?.includes('23505') ||
4298
+ error.message?.includes('P2002') ||
4299
+ error.message?.includes('P2003');
4300
+ if (isConstraintViolation) {
4301
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
4302
+ logger.error("Non-retryable constraint violation in updateManyInviteToken", {
4303
+ operation: 'updateManyInviteToken',
4304
+ model: 'InviteToken',
4305
+ error: String(error),
4306
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
4307
+ errorCategory: 'CONSTRAINT_VIOLATION',
4308
+ isRetryable: false,
4309
+ });
4310
+ throw error;
4311
+ }
4161
4312
  // Check if this is a database connection error that we should retry
4162
4313
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
4163
4314
  error.message?.includes('Cannot reach database server') ||
@@ -4167,12 +4318,22 @@ export const InviteToken = {
4167
4318
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4168
4319
  retryCount++;
4169
4320
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4170
- logger.warn("Database connection error, retrying...");
4321
+ logger.warn("Database connection error in updateManyInviteToken, retrying...", {
4322
+ operation: 'updateManyInviteToken',
4323
+ model: 'InviteToken',
4324
+ attempt: retryCount,
4325
+ maxRetries: MAX_RETRIES,
4326
+ });
4171
4327
  await new Promise(resolve => setTimeout(resolve, delay));
4172
4328
  continue;
4173
4329
  }
4174
- // Log the error and rethrow
4175
- logger.error("Database error occurred", { error: String(error) });
4330
+ // Log structured error details and rethrow
4331
+ logger.error("Database updateMany operation failed", {
4332
+ operation: 'updateManyInviteToken',
4333
+ model: 'InviteToken',
4334
+ error: String(error),
4335
+ isRetryable: isConnectionError,
4336
+ });
4176
4337
  throw error;
4177
4338
  }
4178
4339
  }
@@ -4230,6 +4391,31 @@ export const InviteToken = {
4230
4391
  }
4231
4392
  catch (error) {
4232
4393
  lastError = error;
4394
+ // Check for constraint violations FIRST - these are NEVER retryable
4395
+ // (e.g., foreign key constraints preventing deletion)
4396
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
4397
+ error.message?.includes('violates unique constraint') ||
4398
+ error.message?.includes('violates foreign key constraint') ||
4399
+ error.message?.includes('unique constraint') ||
4400
+ error.message?.includes('23514') ||
4401
+ error.message?.includes('23505') ||
4402
+ error.message?.includes('23503') ||
4403
+ error.message?.includes('P2002') ||
4404
+ error.message?.includes('P2003') ||
4405
+ error.message?.includes('P2014');
4406
+ if (isConstraintViolation) {
4407
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
4408
+ logger.error("Non-retryable constraint violation in deleteOneInviteToken", {
4409
+ operation: 'deleteOneInviteToken',
4410
+ model: 'InviteToken',
4411
+ error: String(error),
4412
+ recordId: props.id,
4413
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
4414
+ errorCategory: 'CONSTRAINT_VIOLATION',
4415
+ isRetryable: false,
4416
+ });
4417
+ throw error;
4418
+ }
4233
4419
  // Check if this is a database connection error that we should retry
4234
4420
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
4235
4421
  error.message?.includes('Cannot reach database server') ||
@@ -4239,12 +4425,24 @@ export const InviteToken = {
4239
4425
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4240
4426
  retryCount++;
4241
4427
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4242
- logger.warn("Database connection error, retrying...");
4428
+ logger.warn("Database connection error in deleteOneInviteToken, retrying...", {
4429
+ operation: 'deleteOneInviteToken',
4430
+ model: 'InviteToken',
4431
+ attempt: retryCount,
4432
+ maxRetries: MAX_RETRIES,
4433
+ recordId: props.id,
4434
+ });
4243
4435
  await new Promise(resolve => setTimeout(resolve, delay));
4244
4436
  continue;
4245
4437
  }
4246
- // Log the error and rethrow
4247
- logger.error("Database error occurred", { error: String(error) });
4438
+ // Log structured error details and rethrow
4439
+ logger.error("Database delete operation failed", {
4440
+ operation: 'deleteOneInviteToken',
4441
+ model: 'InviteToken',
4442
+ error: String(error),
4443
+ recordId: props.id,
4444
+ isRetryable: isConnectionError,
4445
+ });
4248
4446
  throw error;
4249
4447
  }
4250
4448
  }
@@ -4314,12 +4512,22 @@ export const InviteToken = {
4314
4512
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4315
4513
  retryCount++;
4316
4514
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4317
- logger.warn("Database connection error, retrying...");
4515
+ logger.warn("Database connection error in getInviteToken, retrying...", {
4516
+ operation: 'getInviteToken',
4517
+ model: 'InviteToken',
4518
+ attempt: retryCount,
4519
+ maxRetries: MAX_RETRIES,
4520
+ });
4318
4521
  await new Promise(resolve => setTimeout(resolve, delay));
4319
4522
  continue;
4320
4523
  }
4321
- // Log the error and rethrow
4322
- logger.error("Database error occurred", { error: String(error) });
4524
+ // Log structured error details and rethrow
4525
+ logger.error("Database get operation failed", {
4526
+ operation: 'getInviteToken',
4527
+ model: 'InviteToken',
4528
+ error: String(error),
4529
+ isRetryable: isConnectionError,
4530
+ });
4323
4531
  throw error;
4324
4532
  }
4325
4533
  }
@@ -4376,12 +4584,22 @@ export const InviteToken = {
4376
4584
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4377
4585
  retryCount++;
4378
4586
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4379
- logger.warn("Database connection error, retrying...");
4587
+ logger.warn("Database connection error in getAllInviteToken, retrying...", {
4588
+ operation: 'getAllInviteToken',
4589
+ model: 'InviteToken',
4590
+ attempt: retryCount,
4591
+ maxRetries: MAX_RETRIES,
4592
+ });
4380
4593
  await new Promise(resolve => setTimeout(resolve, delay));
4381
4594
  continue;
4382
4595
  }
4383
- // Log the error and rethrow
4384
- logger.error("Database error occurred", { error: String(error) });
4596
+ // Log structured error details and rethrow
4597
+ logger.error("Database getAll operation failed", {
4598
+ operation: 'getAllInviteToken',
4599
+ model: 'InviteToken',
4600
+ error: String(error),
4601
+ isRetryable: isConnectionError,
4602
+ });
4385
4603
  throw error;
4386
4604
  }
4387
4605
  }
@@ -4457,12 +4675,22 @@ export const InviteToken = {
4457
4675
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4458
4676
  retryCount++;
4459
4677
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4460
- logger.warn("Database connection error, retrying...");
4678
+ logger.warn("Database connection error in findManyInviteToken, retrying...", {
4679
+ operation: 'findManyInviteToken',
4680
+ model: 'InviteToken',
4681
+ attempt: retryCount,
4682
+ maxRetries: MAX_RETRIES,
4683
+ });
4461
4684
  await new Promise(resolve => setTimeout(resolve, delay));
4462
4685
  continue;
4463
4686
  }
4464
- // Log the error and rethrow
4465
- logger.error("Database error occurred", { error: String(error) });
4687
+ // Log structured error details and rethrow
4688
+ logger.error("Database findMany operation failed", {
4689
+ operation: 'findManyInviteToken',
4690
+ model: 'InviteToken',
4691
+ error: String(error),
4692
+ isRetryable: isConnectionError,
4693
+ });
4466
4694
  throw error;
4467
4695
  }
4468
4696
  }
@@ -1 +1 @@
1
- {"version":3,"file":"LinkedProvider.d.ts","sourceRoot":"","sources":["../../src/LinkedProvider.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,sDAAsD,CAAC;AAC5G,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AAmM7G,eAAO,MAAM,cAAc;IAE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