@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
@@ -563,6 +563,27 @@ export const AccountLinkingRequest = {
563
563
  }
564
564
  catch (error) {
565
565
  lastError = error;
566
+ // Check for constraint violations FIRST - these are NEVER retryable
567
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
568
+ error.message?.includes('violates unique constraint') ||
569
+ error.message?.includes('violates foreign key constraint') ||
570
+ error.message?.includes('unique constraint') ||
571
+ error.message?.includes('23514') ||
572
+ error.message?.includes('23505') ||
573
+ error.message?.includes('P2002') ||
574
+ error.message?.includes('P2003');
575
+ if (isConstraintViolation) {
576
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
577
+ logger.error("Non-retryable constraint violation in createOneAccountLinkingRequest", {
578
+ operation: 'createOneAccountLinkingRequest',
579
+ model: 'AccountLinkingRequest',
580
+ error: String(error),
581
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
582
+ errorCategory: 'CONSTRAINT_VIOLATION',
583
+ isRetryable: false,
584
+ });
585
+ throw error;
586
+ }
566
587
  // Check if this is a database connection error that we should retry
567
588
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
568
589
  error.message?.includes('Cannot reach database server') ||
@@ -572,12 +593,22 @@ export const AccountLinkingRequest = {
572
593
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
573
594
  retryCount++;
574
595
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
575
- logger.warn("Database connection error, retrying...");
596
+ logger.warn("Database connection error in createOneAccountLinkingRequest, retrying...", {
597
+ operation: 'createOneAccountLinkingRequest',
598
+ model: 'AccountLinkingRequest',
599
+ attempt: retryCount,
600
+ maxRetries: MAX_RETRIES,
601
+ });
576
602
  await new Promise(resolve => setTimeout(resolve, delay));
577
603
  continue;
578
604
  }
579
- // Log the error and rethrow
580
- logger.error("Database error occurred", { error: String(error) });
605
+ // Log structured error details and rethrow
606
+ logger.error("Database create operation failed", {
607
+ operation: 'createOneAccountLinkingRequest',
608
+ model: 'AccountLinkingRequest',
609
+ error: String(error),
610
+ isRetryable: isConnectionError,
611
+ });
581
612
  throw error;
582
613
  }
583
614
  }
@@ -646,6 +677,27 @@ export const AccountLinkingRequest = {
646
677
  }
647
678
  catch (error) {
648
679
  lastError = error;
680
+ // Check for constraint violations FIRST - these are NEVER retryable
681
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
682
+ error.message?.includes('violates unique constraint') ||
683
+ error.message?.includes('violates foreign key constraint') ||
684
+ error.message?.includes('unique constraint') ||
685
+ error.message?.includes('23514') ||
686
+ error.message?.includes('23505') ||
687
+ error.message?.includes('P2002') ||
688
+ error.message?.includes('P2003');
689
+ if (isConstraintViolation) {
690
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
691
+ logger.error("Non-retryable constraint violation in createManyAccountLinkingRequest", {
692
+ operation: 'createManyAccountLinkingRequest',
693
+ model: 'AccountLinkingRequest',
694
+ error: String(error),
695
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
696
+ errorCategory: 'CONSTRAINT_VIOLATION',
697
+ isRetryable: false,
698
+ });
699
+ throw error;
700
+ }
649
701
  // Check if this is a database connection error that we should retry
650
702
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
651
703
  error.message?.includes('Cannot reach database server') ||
@@ -655,12 +707,22 @@ export const AccountLinkingRequest = {
655
707
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
656
708
  retryCount++;
657
709
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
658
- logger.warn("Database connection error, retrying...");
710
+ logger.warn("Database connection error in createManyAccountLinkingRequest, retrying...", {
711
+ operation: 'createManyAccountLinkingRequest',
712
+ model: 'AccountLinkingRequest',
713
+ attempt: retryCount,
714
+ maxRetries: MAX_RETRIES,
715
+ });
659
716
  await new Promise(resolve => setTimeout(resolve, delay));
660
717
  continue;
661
718
  }
662
- // Log the error and rethrow
663
- logger.error("Database error occurred", { error: String(error) });
719
+ // Log structured error details and rethrow
720
+ logger.error("Database createMany operation failed", {
721
+ operation: 'createManyAccountLinkingRequest',
722
+ model: 'AccountLinkingRequest',
723
+ error: String(error),
724
+ isRetryable: isConnectionError,
725
+ });
664
726
  throw error;
665
727
  }
666
728
  }
@@ -1790,6 +1852,28 @@ export const AccountLinkingRequest = {
1790
1852
  }
1791
1853
  catch (error) {
1792
1854
  lastError = error;
1855
+ // Check for constraint violations FIRST - these are NEVER retryable
1856
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
1857
+ error.message?.includes('violates unique constraint') ||
1858
+ error.message?.includes('violates foreign key constraint') ||
1859
+ error.message?.includes('unique constraint') ||
1860
+ error.message?.includes('23514') ||
1861
+ error.message?.includes('23505') ||
1862
+ error.message?.includes('P2002') ||
1863
+ error.message?.includes('P2003');
1864
+ if (isConstraintViolation) {
1865
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
1866
+ logger.error("Non-retryable constraint violation in updateOneAccountLinkingRequest", {
1867
+ operation: 'updateOneAccountLinkingRequest',
1868
+ model: 'AccountLinkingRequest',
1869
+ error: String(error),
1870
+ recordId: props.id,
1871
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1872
+ errorCategory: 'CONSTRAINT_VIOLATION',
1873
+ isRetryable: false,
1874
+ });
1875
+ throw error;
1876
+ }
1793
1877
  // Check if this is a database connection error that we should retry
1794
1878
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
1795
1879
  error.message?.includes('Cannot reach database server') ||
@@ -1799,12 +1883,24 @@ export const AccountLinkingRequest = {
1799
1883
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1800
1884
  retryCount++;
1801
1885
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1802
- logger.warn("Database connection error, retrying...");
1886
+ logger.warn("Database connection error in updateOneAccountLinkingRequest, retrying...", {
1887
+ operation: 'updateOneAccountLinkingRequest',
1888
+ model: 'AccountLinkingRequest',
1889
+ attempt: retryCount,
1890
+ maxRetries: MAX_RETRIES,
1891
+ recordId: props.id,
1892
+ });
1803
1893
  await new Promise(resolve => setTimeout(resolve, delay));
1804
1894
  continue;
1805
1895
  }
1806
- // Log the error and rethrow
1807
- logger.error("Database error occurred", { error: String(error) });
1896
+ // Log structured error details and rethrow
1897
+ logger.error("Database update operation failed", {
1898
+ operation: 'updateOneAccountLinkingRequest',
1899
+ model: 'AccountLinkingRequest',
1900
+ error: String(error),
1901
+ recordId: props.id,
1902
+ isRetryable: isConnectionError,
1903
+ });
1808
1904
  throw error;
1809
1905
  }
1810
1906
  }
@@ -3245,6 +3341,28 @@ export const AccountLinkingRequest = {
3245
3341
  }
3246
3342
  catch (error) {
3247
3343
  lastError = error;
3344
+ // Check for constraint violations FIRST - these are NEVER retryable
3345
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
3346
+ error.message?.includes('violates unique constraint') ||
3347
+ error.message?.includes('violates foreign key constraint') ||
3348
+ error.message?.includes('unique constraint') ||
3349
+ error.message?.includes('23514') ||
3350
+ error.message?.includes('23505') ||
3351
+ error.message?.includes('P2002') ||
3352
+ error.message?.includes('P2003');
3353
+ if (isConstraintViolation) {
3354
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
3355
+ logger.error("Non-retryable constraint violation in upsertOneAccountLinkingRequest", {
3356
+ operation: 'upsertOneAccountLinkingRequest',
3357
+ model: 'AccountLinkingRequest',
3358
+ error: String(error),
3359
+ recordId: props.id,
3360
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
3361
+ errorCategory: 'CONSTRAINT_VIOLATION',
3362
+ isRetryable: false,
3363
+ });
3364
+ throw error;
3365
+ }
3248
3366
  // Check if this is a database connection error that we should retry
3249
3367
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
3250
3368
  error.message?.includes('Cannot reach database server') ||
@@ -3254,12 +3372,24 @@ export const AccountLinkingRequest = {
3254
3372
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
3255
3373
  retryCount++;
3256
3374
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
3257
- logger.warn("Database connection error, retrying...");
3375
+ logger.warn("Database connection error in upsertOneAccountLinkingRequest, retrying...", {
3376
+ operation: 'upsertOneAccountLinkingRequest',
3377
+ model: 'AccountLinkingRequest',
3378
+ attempt: retryCount,
3379
+ maxRetries: MAX_RETRIES,
3380
+ recordId: props.id,
3381
+ });
3258
3382
  await new Promise(resolve => setTimeout(resolve, delay));
3259
3383
  continue;
3260
3384
  }
3261
- // Log the error and rethrow
3262
- logger.error("Database error occurred", { error: String(error) });
3385
+ // Log structured error details and rethrow
3386
+ logger.error("Database upsert operation failed", {
3387
+ operation: 'upsertOneAccountLinkingRequest',
3388
+ model: 'AccountLinkingRequest',
3389
+ error: String(error),
3390
+ recordId: props.id,
3391
+ isRetryable: isConnectionError,
3392
+ });
3263
3393
  throw error;
3264
3394
  }
3265
3395
  }
@@ -4389,6 +4519,27 @@ export const AccountLinkingRequest = {
4389
4519
  }
4390
4520
  catch (error) {
4391
4521
  lastError = error;
4522
+ // Check for constraint violations FIRST - these are NEVER retryable
4523
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
4524
+ error.message?.includes('violates unique constraint') ||
4525
+ error.message?.includes('violates foreign key constraint') ||
4526
+ error.message?.includes('unique constraint') ||
4527
+ error.message?.includes('23514') ||
4528
+ error.message?.includes('23505') ||
4529
+ error.message?.includes('P2002') ||
4530
+ error.message?.includes('P2003');
4531
+ if (isConstraintViolation) {
4532
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
4533
+ logger.error("Non-retryable constraint violation in updateManyAccountLinkingRequest", {
4534
+ operation: 'updateManyAccountLinkingRequest',
4535
+ model: 'AccountLinkingRequest',
4536
+ error: String(error),
4537
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
4538
+ errorCategory: 'CONSTRAINT_VIOLATION',
4539
+ isRetryable: false,
4540
+ });
4541
+ throw error;
4542
+ }
4392
4543
  // Check if this is a database connection error that we should retry
4393
4544
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
4394
4545
  error.message?.includes('Cannot reach database server') ||
@@ -4398,12 +4549,22 @@ export const AccountLinkingRequest = {
4398
4549
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4399
4550
  retryCount++;
4400
4551
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4401
- logger.warn("Database connection error, retrying...");
4552
+ logger.warn("Database connection error in updateManyAccountLinkingRequest, retrying...", {
4553
+ operation: 'updateManyAccountLinkingRequest',
4554
+ model: 'AccountLinkingRequest',
4555
+ attempt: retryCount,
4556
+ maxRetries: MAX_RETRIES,
4557
+ });
4402
4558
  await new Promise(resolve => setTimeout(resolve, delay));
4403
4559
  continue;
4404
4560
  }
4405
- // Log the error and rethrow
4406
- logger.error("Database error occurred", { error: String(error) });
4561
+ // Log structured error details and rethrow
4562
+ logger.error("Database updateMany operation failed", {
4563
+ operation: 'updateManyAccountLinkingRequest',
4564
+ model: 'AccountLinkingRequest',
4565
+ error: String(error),
4566
+ isRetryable: isConnectionError,
4567
+ });
4407
4568
  throw error;
4408
4569
  }
4409
4570
  }
@@ -4461,6 +4622,31 @@ export const AccountLinkingRequest = {
4461
4622
  }
4462
4623
  catch (error) {
4463
4624
  lastError = error;
4625
+ // Check for constraint violations FIRST - these are NEVER retryable
4626
+ // (e.g., foreign key constraints preventing deletion)
4627
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
4628
+ error.message?.includes('violates unique constraint') ||
4629
+ error.message?.includes('violates foreign key constraint') ||
4630
+ error.message?.includes('unique constraint') ||
4631
+ error.message?.includes('23514') ||
4632
+ error.message?.includes('23505') ||
4633
+ error.message?.includes('23503') ||
4634
+ error.message?.includes('P2002') ||
4635
+ error.message?.includes('P2003') ||
4636
+ error.message?.includes('P2014');
4637
+ if (isConstraintViolation) {
4638
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
4639
+ logger.error("Non-retryable constraint violation in deleteOneAccountLinkingRequest", {
4640
+ operation: 'deleteOneAccountLinkingRequest',
4641
+ model: 'AccountLinkingRequest',
4642
+ error: String(error),
4643
+ recordId: props.id,
4644
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
4645
+ errorCategory: 'CONSTRAINT_VIOLATION',
4646
+ isRetryable: false,
4647
+ });
4648
+ throw error;
4649
+ }
4464
4650
  // Check if this is a database connection error that we should retry
4465
4651
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
4466
4652
  error.message?.includes('Cannot reach database server') ||
@@ -4470,12 +4656,24 @@ export const AccountLinkingRequest = {
4470
4656
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4471
4657
  retryCount++;
4472
4658
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4473
- logger.warn("Database connection error, retrying...");
4659
+ logger.warn("Database connection error in deleteOneAccountLinkingRequest, retrying...", {
4660
+ operation: 'deleteOneAccountLinkingRequest',
4661
+ model: 'AccountLinkingRequest',
4662
+ attempt: retryCount,
4663
+ maxRetries: MAX_RETRIES,
4664
+ recordId: props.id,
4665
+ });
4474
4666
  await new Promise(resolve => setTimeout(resolve, delay));
4475
4667
  continue;
4476
4668
  }
4477
- // Log the error and rethrow
4478
- logger.error("Database error occurred", { error: String(error) });
4669
+ // Log structured error details and rethrow
4670
+ logger.error("Database delete operation failed", {
4671
+ operation: 'deleteOneAccountLinkingRequest',
4672
+ model: 'AccountLinkingRequest',
4673
+ error: String(error),
4674
+ recordId: props.id,
4675
+ isRetryable: isConnectionError,
4676
+ });
4479
4677
  throw error;
4480
4678
  }
4481
4679
  }
@@ -4550,12 +4748,22 @@ export const AccountLinkingRequest = {
4550
4748
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4551
4749
  retryCount++;
4552
4750
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4553
- logger.warn("Database connection error, retrying...");
4751
+ logger.warn("Database connection error in getAccountLinkingRequest, retrying...", {
4752
+ operation: 'getAccountLinkingRequest',
4753
+ model: 'AccountLinkingRequest',
4754
+ attempt: retryCount,
4755
+ maxRetries: MAX_RETRIES,
4756
+ });
4554
4757
  await new Promise(resolve => setTimeout(resolve, delay));
4555
4758
  continue;
4556
4759
  }
4557
- // Log the error and rethrow
4558
- logger.error("Database error occurred", { error: String(error) });
4760
+ // Log structured error details and rethrow
4761
+ logger.error("Database get operation failed", {
4762
+ operation: 'getAccountLinkingRequest',
4763
+ model: 'AccountLinkingRequest',
4764
+ error: String(error),
4765
+ isRetryable: isConnectionError,
4766
+ });
4559
4767
  throw error;
4560
4768
  }
4561
4769
  }
@@ -4612,12 +4820,22 @@ export const AccountLinkingRequest = {
4612
4820
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4613
4821
  retryCount++;
4614
4822
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4615
- logger.warn("Database connection error, retrying...");
4823
+ logger.warn("Database connection error in getAllAccountLinkingRequest, retrying...", {
4824
+ operation: 'getAllAccountLinkingRequest',
4825
+ model: 'AccountLinkingRequest',
4826
+ attempt: retryCount,
4827
+ maxRetries: MAX_RETRIES,
4828
+ });
4616
4829
  await new Promise(resolve => setTimeout(resolve, delay));
4617
4830
  continue;
4618
4831
  }
4619
- // Log the error and rethrow
4620
- logger.error("Database error occurred", { error: String(error) });
4832
+ // Log structured error details and rethrow
4833
+ logger.error("Database getAll operation failed", {
4834
+ operation: 'getAllAccountLinkingRequest',
4835
+ model: 'AccountLinkingRequest',
4836
+ error: String(error),
4837
+ isRetryable: isConnectionError,
4838
+ });
4621
4839
  throw error;
4622
4840
  }
4623
4841
  }
@@ -4699,12 +4917,22 @@ export const AccountLinkingRequest = {
4699
4917
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4700
4918
  retryCount++;
4701
4919
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4702
- logger.warn("Database connection error, retrying...");
4920
+ logger.warn("Database connection error in findManyAccountLinkingRequest, retrying...", {
4921
+ operation: 'findManyAccountLinkingRequest',
4922
+ model: 'AccountLinkingRequest',
4923
+ attempt: retryCount,
4924
+ maxRetries: MAX_RETRIES,
4925
+ });
4703
4926
  await new Promise(resolve => setTimeout(resolve, delay));
4704
4927
  continue;
4705
4928
  }
4706
- // Log the error and rethrow
4707
- logger.error("Database error occurred", { error: String(error) });
4929
+ // Log structured error details and rethrow
4930
+ logger.error("Database findMany operation failed", {
4931
+ operation: 'findManyAccountLinkingRequest',
4932
+ model: 'AccountLinkingRequest',
4933
+ error: String(error),
4934
+ isRetryable: isConnectionError,
4935
+ });
4708
4936
  throw error;
4709
4937
  }
4710
4938
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Action.d.ts","sourceRoot":"","sources":["../../src/Action.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,8CAA8C,CAAC;AACpF,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AAwB7G,eAAO,MAAM,MAAM;IAEjB;;;;;OAKG;IAEH;;;;;;OAMG;kBACiB,UAAU,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IAgI9G;;;;;;OAMG;sBACqB,UAAU,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAkFhI;;;;;;OAMG;kBACiB,UAAU,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IA8O5G;;;;;;OAMG;kBACiB,UAAU,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IA2R5G;;;;;;OAMG;sBACqB,UAAU,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAgPhI;;;;;;OAMG;kBACiB,UAAU,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IA2E5G;;;;;;;OAOG;eACc,UAAU,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IA8ElI;;;;;OAKG;0BACyB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC;IAkElG;;;;;;;OAOG;oBACmB,UAAU,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC;CAmF1I,CAAC"}
1
+ {"version":3,"file":"Action.d.ts","sourceRoot":"","sources":["../../src/Action.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,8CAA8C,CAAC;AACpF,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AAwB7G,eAAO,MAAM,MAAM;IAEjB;;;;;OAKG;IAEH;;;;;;OAMG;kBACiB,UAAU,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IAkK9G;;;;;;OAMG;sBACqB,UAAU,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAoHhI;;;;;;OAMG;kBACiB,UAAU,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IAmR5G;;;;;;OAMG;kBACiB,UAAU,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IAgU5G;;;;;;OAMG;sBACqB,UAAU,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAkRhI;;;;;;OAMG;kBACiB,UAAU,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IAmH5G;;;;;;;OAOG;eACc,UAAU,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAwFlI;;;;;OAKG;0BACyB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC;IA4ElG;;;;;;;OAOG;oBACmB,UAAU,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC;CA6F1I,CAAC"}