@adaptic/backend-legacy 0.0.903 → 0.0.905

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/ABTest.cjs +291 -63
  2. package/Account.cjs +291 -63
  3. package/AccountLinkingRequest.cjs +291 -63
  4. package/Action.cjs +291 -63
  5. package/Alert.cjs +291 -63
  6. package/Allocation.cjs +291 -63
  7. package/AlpacaAccount.cjs +291 -63
  8. package/AnalyticsConfiguration.cjs +291 -63
  9. package/AnalyticsSnapshot.cjs +291 -63
  10. package/Asset.cjs +291 -63
  11. package/AuditLog.cjs +291 -63
  12. package/Authenticator.cjs +291 -63
  13. package/Configuration.cjs +291 -63
  14. package/ConflictEvent.cjs +291 -63
  15. package/ConnectionHealthSnapshot.cjs +291 -63
  16. package/Customer.cjs +291 -63
  17. package/DeadLetterMessage.cjs +291 -63
  18. package/EconomicEvent.cjs +291 -63
  19. package/Event.cjs +291 -63
  20. package/EventSnapshot.cjs +291 -63
  21. package/FeatureImportanceAnalysis.cjs +291 -63
  22. package/InstitutionalFlowSignal.cjs +291 -63
  23. package/InstitutionalHolding.cjs +291 -63
  24. package/InstitutionalSentimentAlerts.cjs +291 -63
  25. package/InstitutionalSentimentErrors.cjs +291 -63
  26. package/InstitutionalSentimentHistory.cjs +291 -63
  27. package/InstitutionalSentimentMetrics.cjs +291 -63
  28. package/InviteToken.cjs +291 -63
  29. package/LinkedProvider.cjs +291 -63
  30. package/MLTrainingData.cjs +291 -63
  31. package/MarketSentiment.cjs +291 -63
  32. package/ModelArtifact.cjs +291 -63
  33. package/ModelVersion.cjs +291 -63
  34. package/ModelVersionArtifact.cjs +291 -63
  35. package/NewsArticle.cjs +291 -63
  36. package/NewsArticleAssetSentiment.cjs +291 -63
  37. package/OptionsContract.cjs +291 -63
  38. package/OptionsGreeksHistory.cjs +291 -63
  39. package/OptionsPosition.cjs +291 -63
  40. package/OptionsTradeExecution.cjs +291 -63
  41. package/PortfolioGreeksHistory.cjs +291 -63
  42. package/ScheduledOptionOrder.cjs +291 -63
  43. package/Session.cjs +291 -63
  44. package/SignalGeneratorMetrics.cjs +291 -63
  45. package/SignalLineage.cjs +291 -63
  46. package/SignalOutcome.cjs +291 -63
  47. package/SignalPriorityQueue.cjs +291 -63
  48. package/SyncEvent.cjs +291 -63
  49. package/SystemAlert.cjs +291 -63
  50. package/Trade.cjs +291 -63
  51. package/TradeAuditEvent.cjs +291 -63
  52. package/TradeExecutionHistory.cjs +291 -63
  53. package/User.cjs +291 -63
  54. package/VerificationToken.cjs +291 -63
  55. package/WaitlistEntry.cjs +291 -63
  56. package/esm/ABTest.d.ts.map +1 -1
  57. package/esm/ABTest.js.map +1 -1
  58. package/esm/ABTest.mjs +255 -27
  59. package/esm/Account.d.ts.map +1 -1
  60. package/esm/Account.js.map +1 -1
  61. package/esm/Account.mjs +255 -27
  62. package/esm/AccountLinkingRequest.d.ts.map +1 -1
  63. package/esm/AccountLinkingRequest.js.map +1 -1
  64. package/esm/AccountLinkingRequest.mjs +255 -27
  65. package/esm/Action.d.ts.map +1 -1
  66. package/esm/Action.js.map +1 -1
  67. package/esm/Action.mjs +255 -27
  68. package/esm/Alert.d.ts.map +1 -1
  69. package/esm/Alert.js.map +1 -1
  70. package/esm/Alert.mjs +255 -27
  71. package/esm/Allocation.d.ts.map +1 -1
  72. package/esm/Allocation.js.map +1 -1
  73. package/esm/Allocation.mjs +255 -27
  74. package/esm/AlpacaAccount.d.ts.map +1 -1
  75. package/esm/AlpacaAccount.js.map +1 -1
  76. package/esm/AlpacaAccount.mjs +255 -27
  77. package/esm/AnalyticsConfiguration.d.ts.map +1 -1
  78. package/esm/AnalyticsConfiguration.js.map +1 -1
  79. package/esm/AnalyticsConfiguration.mjs +255 -27
  80. package/esm/AnalyticsSnapshot.d.ts.map +1 -1
  81. package/esm/AnalyticsSnapshot.js.map +1 -1
  82. package/esm/AnalyticsSnapshot.mjs +255 -27
  83. package/esm/Asset.d.ts.map +1 -1
  84. package/esm/Asset.js.map +1 -1
  85. package/esm/Asset.mjs +255 -27
  86. package/esm/AuditLog.d.ts.map +1 -1
  87. package/esm/AuditLog.js.map +1 -1
  88. package/esm/AuditLog.mjs +255 -27
  89. package/esm/Authenticator.d.ts.map +1 -1
  90. package/esm/Authenticator.js.map +1 -1
  91. package/esm/Authenticator.mjs +255 -27
  92. package/esm/Configuration.d.ts.map +1 -1
  93. package/esm/Configuration.js.map +1 -1
  94. package/esm/Configuration.mjs +255 -27
  95. package/esm/ConflictEvent.d.ts.map +1 -1
  96. package/esm/ConflictEvent.js.map +1 -1
  97. package/esm/ConflictEvent.mjs +255 -27
  98. package/esm/ConnectionHealthSnapshot.d.ts.map +1 -1
  99. package/esm/ConnectionHealthSnapshot.js.map +1 -1
  100. package/esm/ConnectionHealthSnapshot.mjs +255 -27
  101. package/esm/Customer.d.ts.map +1 -1
  102. package/esm/Customer.js.map +1 -1
  103. package/esm/Customer.mjs +255 -27
  104. package/esm/DeadLetterMessage.d.ts.map +1 -1
  105. package/esm/DeadLetterMessage.js.map +1 -1
  106. package/esm/DeadLetterMessage.mjs +255 -27
  107. package/esm/EconomicEvent.d.ts.map +1 -1
  108. package/esm/EconomicEvent.js.map +1 -1
  109. package/esm/EconomicEvent.mjs +255 -27
  110. package/esm/Event.d.ts.map +1 -1
  111. package/esm/Event.js.map +1 -1
  112. package/esm/Event.mjs +255 -27
  113. package/esm/EventSnapshot.d.ts.map +1 -1
  114. package/esm/EventSnapshot.js.map +1 -1
  115. package/esm/EventSnapshot.mjs +255 -27
  116. package/esm/FeatureImportanceAnalysis.d.ts.map +1 -1
  117. package/esm/FeatureImportanceAnalysis.js.map +1 -1
  118. package/esm/FeatureImportanceAnalysis.mjs +255 -27
  119. package/esm/InstitutionalFlowSignal.d.ts.map +1 -1
  120. package/esm/InstitutionalFlowSignal.js.map +1 -1
  121. package/esm/InstitutionalFlowSignal.mjs +255 -27
  122. package/esm/InstitutionalHolding.d.ts.map +1 -1
  123. package/esm/InstitutionalHolding.js.map +1 -1
  124. package/esm/InstitutionalHolding.mjs +255 -27
  125. package/esm/InstitutionalSentimentAlerts.d.ts.map +1 -1
  126. package/esm/InstitutionalSentimentAlerts.js.map +1 -1
  127. package/esm/InstitutionalSentimentAlerts.mjs +255 -27
  128. package/esm/InstitutionalSentimentErrors.d.ts.map +1 -1
  129. package/esm/InstitutionalSentimentErrors.js.map +1 -1
  130. package/esm/InstitutionalSentimentErrors.mjs +255 -27
  131. package/esm/InstitutionalSentimentHistory.d.ts.map +1 -1
  132. package/esm/InstitutionalSentimentHistory.js.map +1 -1
  133. package/esm/InstitutionalSentimentHistory.mjs +255 -27
  134. package/esm/InstitutionalSentimentMetrics.d.ts.map +1 -1
  135. package/esm/InstitutionalSentimentMetrics.js.map +1 -1
  136. package/esm/InstitutionalSentimentMetrics.mjs +255 -27
  137. package/esm/InviteToken.d.ts.map +1 -1
  138. package/esm/InviteToken.js.map +1 -1
  139. package/esm/InviteToken.mjs +255 -27
  140. package/esm/LinkedProvider.d.ts.map +1 -1
  141. package/esm/LinkedProvider.js.map +1 -1
  142. package/esm/LinkedProvider.mjs +255 -27
  143. package/esm/MLTrainingData.d.ts.map +1 -1
  144. package/esm/MLTrainingData.js.map +1 -1
  145. package/esm/MLTrainingData.mjs +255 -27
  146. package/esm/MarketSentiment.d.ts.map +1 -1
  147. package/esm/MarketSentiment.js.map +1 -1
  148. package/esm/MarketSentiment.mjs +255 -27
  149. package/esm/ModelArtifact.d.ts.map +1 -1
  150. package/esm/ModelArtifact.js.map +1 -1
  151. package/esm/ModelArtifact.mjs +255 -27
  152. package/esm/ModelVersion.d.ts.map +1 -1
  153. package/esm/ModelVersion.js.map +1 -1
  154. package/esm/ModelVersion.mjs +255 -27
  155. package/esm/ModelVersionArtifact.d.ts.map +1 -1
  156. package/esm/ModelVersionArtifact.js.map +1 -1
  157. package/esm/ModelVersionArtifact.mjs +255 -27
  158. package/esm/NewsArticle.d.ts.map +1 -1
  159. package/esm/NewsArticle.js.map +1 -1
  160. package/esm/NewsArticle.mjs +255 -27
  161. package/esm/NewsArticleAssetSentiment.d.ts.map +1 -1
  162. package/esm/NewsArticleAssetSentiment.js.map +1 -1
  163. package/esm/NewsArticleAssetSentiment.mjs +255 -27
  164. package/esm/OptionsContract.d.ts.map +1 -1
  165. package/esm/OptionsContract.js.map +1 -1
  166. package/esm/OptionsContract.mjs +255 -27
  167. package/esm/OptionsGreeksHistory.d.ts.map +1 -1
  168. package/esm/OptionsGreeksHistory.js.map +1 -1
  169. package/esm/OptionsGreeksHistory.mjs +255 -27
  170. package/esm/OptionsPosition.d.ts.map +1 -1
  171. package/esm/OptionsPosition.js.map +1 -1
  172. package/esm/OptionsPosition.mjs +255 -27
  173. package/esm/OptionsTradeExecution.d.ts.map +1 -1
  174. package/esm/OptionsTradeExecution.js.map +1 -1
  175. package/esm/OptionsTradeExecution.mjs +255 -27
  176. package/esm/PortfolioGreeksHistory.d.ts.map +1 -1
  177. package/esm/PortfolioGreeksHistory.js.map +1 -1
  178. package/esm/PortfolioGreeksHistory.mjs +255 -27
  179. package/esm/ScheduledOptionOrder.d.ts.map +1 -1
  180. package/esm/ScheduledOptionOrder.js.map +1 -1
  181. package/esm/ScheduledOptionOrder.mjs +255 -27
  182. package/esm/Session.d.ts.map +1 -1
  183. package/esm/Session.js.map +1 -1
  184. package/esm/Session.mjs +255 -27
  185. package/esm/SignalGeneratorMetrics.d.ts.map +1 -1
  186. package/esm/SignalGeneratorMetrics.js.map +1 -1
  187. package/esm/SignalGeneratorMetrics.mjs +255 -27
  188. package/esm/SignalLineage.d.ts.map +1 -1
  189. package/esm/SignalLineage.js.map +1 -1
  190. package/esm/SignalLineage.mjs +255 -27
  191. package/esm/SignalOutcome.d.ts.map +1 -1
  192. package/esm/SignalOutcome.js.map +1 -1
  193. package/esm/SignalOutcome.mjs +255 -27
  194. package/esm/SignalPriorityQueue.d.ts.map +1 -1
  195. package/esm/SignalPriorityQueue.js.map +1 -1
  196. package/esm/SignalPriorityQueue.mjs +255 -27
  197. package/esm/SyncEvent.d.ts.map +1 -1
  198. package/esm/SyncEvent.js.map +1 -1
  199. package/esm/SyncEvent.mjs +255 -27
  200. package/esm/SystemAlert.d.ts.map +1 -1
  201. package/esm/SystemAlert.js.map +1 -1
  202. package/esm/SystemAlert.mjs +255 -27
  203. package/esm/Trade.d.ts.map +1 -1
  204. package/esm/Trade.js.map +1 -1
  205. package/esm/Trade.mjs +255 -27
  206. package/esm/TradeAuditEvent.d.ts.map +1 -1
  207. package/esm/TradeAuditEvent.js.map +1 -1
  208. package/esm/TradeAuditEvent.mjs +255 -27
  209. package/esm/TradeExecutionHistory.d.ts.map +1 -1
  210. package/esm/TradeExecutionHistory.js.map +1 -1
  211. package/esm/TradeExecutionHistory.mjs +255 -27
  212. package/esm/User.d.ts.map +1 -1
  213. package/esm/User.js.map +1 -1
  214. package/esm/User.mjs +255 -27
  215. package/esm/VerificationToken.d.ts.map +1 -1
  216. package/esm/VerificationToken.js.map +1 -1
  217. package/esm/VerificationToken.mjs +255 -27
  218. package/esm/WaitlistEntry.d.ts.map +1 -1
  219. package/esm/WaitlistEntry.js.map +1 -1
  220. package/esm/WaitlistEntry.mjs +255 -27
  221. package/esm/middleware/audit-logger.d.ts +0 -7
  222. package/esm/middleware/audit-logger.d.ts.map +1 -1
  223. package/esm/middleware/audit-logger.js.map +1 -1
  224. package/esm/middleware/audit-logger.mjs +5 -3
  225. package/esm/prismaClient.d.ts.map +1 -1
  226. package/esm/prismaClient.js.map +1 -1
  227. package/esm/prismaClient.mjs +38 -9
  228. package/package.json +1 -1
  229. package/prismaClient.cjs +38 -9
package/Authenticator.cjs CHANGED
@@ -208,7 +208,7 @@ exports.Authenticator = {
208
208
  * @returns The created Authenticator or null.
209
209
  */
210
210
  async create(props, globalClient) {
211
- var _a, _b, _c, _d, _e;
211
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
212
212
  // Maximum number of retries for database connection issues
213
213
  const MAX_RETRIES = 3;
214
214
  let retryCount = 0;
@@ -573,21 +573,52 @@ exports.Authenticator = {
573
573
  }
574
574
  catch (error) {
575
575
  lastError = error;
576
+ // Check for constraint violations FIRST - these are NEVER retryable
577
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
578
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
579
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
580
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
581
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
582
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
583
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
584
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
585
+ if (isConstraintViolation) {
586
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
587
+ logger_1.logger.error("Non-retryable constraint violation in createOneAuthenticator", {
588
+ operation: 'createOneAuthenticator',
589
+ model: 'Authenticator',
590
+ error: String(error),
591
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
592
+ errorCategory: 'CONSTRAINT_VIOLATION',
593
+ isRetryable: false,
594
+ });
595
+ throw error;
596
+ }
576
597
  // Check if this is a database connection error that we should retry
577
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
578
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
579
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
580
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
581
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
598
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
599
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
600
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
601
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
602
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
582
603
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
583
604
  retryCount++;
584
605
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
585
- logger_1.logger.warn("Database connection error, retrying...");
606
+ logger_1.logger.warn("Database connection error in createOneAuthenticator, retrying...", {
607
+ operation: 'createOneAuthenticator',
608
+ model: 'Authenticator',
609
+ attempt: retryCount,
610
+ maxRetries: MAX_RETRIES,
611
+ });
586
612
  await new Promise(resolve => setTimeout(resolve, delay));
587
613
  continue;
588
614
  }
589
- // Log the error and rethrow
590
- logger_1.logger.error("Database error occurred", { error: String(error) });
615
+ // Log structured error details and rethrow
616
+ logger_1.logger.error("Database create operation failed", {
617
+ operation: 'createOneAuthenticator',
618
+ model: 'Authenticator',
619
+ error: String(error),
620
+ isRetryable: isConnectionError,
621
+ });
591
622
  throw error;
592
623
  }
593
624
  }
@@ -602,7 +633,7 @@ exports.Authenticator = {
602
633
  * @returns The count of created records or null.
603
634
  */
604
635
  async createMany(props, globalClient) {
605
- var _a, _b, _c, _d, _e;
636
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
606
637
  // Maximum number of retries for database connection issues
607
638
  const MAX_RETRIES = 3;
608
639
  let retryCount = 0;
@@ -649,21 +680,52 @@ exports.Authenticator = {
649
680
  }
650
681
  catch (error) {
651
682
  lastError = error;
683
+ // Check for constraint violations FIRST - these are NEVER retryable
684
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
685
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
686
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
687
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
688
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
689
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
690
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
691
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
692
+ if (isConstraintViolation) {
693
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
694
+ logger_1.logger.error("Non-retryable constraint violation in createManyAuthenticator", {
695
+ operation: 'createManyAuthenticator',
696
+ model: 'Authenticator',
697
+ error: String(error),
698
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
699
+ errorCategory: 'CONSTRAINT_VIOLATION',
700
+ isRetryable: false,
701
+ });
702
+ throw error;
703
+ }
652
704
  // Check if this is a database connection error that we should retry
653
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
654
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
655
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
656
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
657
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
705
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
706
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
707
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
708
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
709
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
658
710
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
659
711
  retryCount++;
660
712
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
661
- logger_1.logger.warn("Database connection error, retrying...");
713
+ logger_1.logger.warn("Database connection error in createManyAuthenticator, retrying...", {
714
+ operation: 'createManyAuthenticator',
715
+ model: 'Authenticator',
716
+ attempt: retryCount,
717
+ maxRetries: MAX_RETRIES,
718
+ });
662
719
  await new Promise(resolve => setTimeout(resolve, delay));
663
720
  continue;
664
721
  }
665
- // Log the error and rethrow
666
- logger_1.logger.error("Database error occurred", { error: String(error) });
722
+ // Log structured error details and rethrow
723
+ logger_1.logger.error("Database createMany operation failed", {
724
+ operation: 'createManyAuthenticator',
725
+ model: 'Authenticator',
726
+ error: String(error),
727
+ isRetryable: isConnectionError,
728
+ });
667
729
  throw error;
668
730
  }
669
731
  }
@@ -678,7 +740,7 @@ exports.Authenticator = {
678
740
  * @returns The updated Authenticator or null.
679
741
  */
680
742
  async update(props, globalClient) {
681
- var _a, _b, _c, _d, _e;
743
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
682
744
  // Maximum number of retries for database connection issues
683
745
  const MAX_RETRIES = 3;
684
746
  let retryCount = 0;
@@ -1819,21 +1881,55 @@ exports.Authenticator = {
1819
1881
  }
1820
1882
  catch (error) {
1821
1883
  lastError = error;
1884
+ // Check for constraint violations FIRST - these are NEVER retryable
1885
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
1886
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
1887
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
1888
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
1889
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
1890
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
1891
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
1892
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
1893
+ if (isConstraintViolation) {
1894
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
1895
+ logger_1.logger.error("Non-retryable constraint violation in updateOneAuthenticator", {
1896
+ operation: 'updateOneAuthenticator',
1897
+ model: 'Authenticator',
1898
+ error: String(error),
1899
+ recordId: props.id,
1900
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1901
+ errorCategory: 'CONSTRAINT_VIOLATION',
1902
+ isRetryable: false,
1903
+ });
1904
+ throw error;
1905
+ }
1822
1906
  // Check if this is a database connection error that we should retry
1823
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
1824
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
1825
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
1826
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
1827
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
1907
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
1908
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
1909
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
1910
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
1911
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
1828
1912
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1829
1913
  retryCount++;
1830
1914
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1831
- logger_1.logger.warn("Database connection error, retrying...");
1915
+ logger_1.logger.warn("Database connection error in updateOneAuthenticator, retrying...", {
1916
+ operation: 'updateOneAuthenticator',
1917
+ model: 'Authenticator',
1918
+ attempt: retryCount,
1919
+ maxRetries: MAX_RETRIES,
1920
+ recordId: props.id,
1921
+ });
1832
1922
  await new Promise(resolve => setTimeout(resolve, delay));
1833
1923
  continue;
1834
1924
  }
1835
- // Log the error and rethrow
1836
- logger_1.logger.error("Database error occurred", { error: String(error) });
1925
+ // Log structured error details and rethrow
1926
+ logger_1.logger.error("Database update operation failed", {
1927
+ operation: 'updateOneAuthenticator',
1928
+ model: 'Authenticator',
1929
+ error: String(error),
1930
+ recordId: props.id,
1931
+ isRetryable: isConnectionError,
1932
+ });
1837
1933
  throw error;
1838
1934
  }
1839
1935
  }
@@ -1848,7 +1944,7 @@ exports.Authenticator = {
1848
1944
  * @returns The updated Authenticator or null.
1849
1945
  */
1850
1946
  async upsert(props, globalClient) {
1851
- var _a, _b, _c, _d, _e;
1947
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1852
1948
  // Maximum number of retries for database connection issues
1853
1949
  const MAX_RETRIES = 3;
1854
1950
  let retryCount = 0;
@@ -3303,21 +3399,55 @@ exports.Authenticator = {
3303
3399
  }
3304
3400
  catch (error) {
3305
3401
  lastError = error;
3402
+ // Check for constraint violations FIRST - these are NEVER retryable
3403
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
3404
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
3405
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
3406
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
3407
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
3408
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
3409
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
3410
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
3411
+ if (isConstraintViolation) {
3412
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
3413
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneAuthenticator", {
3414
+ operation: 'upsertOneAuthenticator',
3415
+ model: 'Authenticator',
3416
+ error: String(error),
3417
+ recordId: props.id,
3418
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
3419
+ errorCategory: 'CONSTRAINT_VIOLATION',
3420
+ isRetryable: false,
3421
+ });
3422
+ throw error;
3423
+ }
3306
3424
  // Check if this is a database connection error that we should retry
3307
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
3308
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
3309
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
3310
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
3311
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
3425
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
3426
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
3427
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
3428
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
3429
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
3312
3430
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
3313
3431
  retryCount++;
3314
3432
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
3315
- logger_1.logger.warn("Database connection error, retrying...");
3433
+ logger_1.logger.warn("Database connection error in upsertOneAuthenticator, retrying...", {
3434
+ operation: 'upsertOneAuthenticator',
3435
+ model: 'Authenticator',
3436
+ attempt: retryCount,
3437
+ maxRetries: MAX_RETRIES,
3438
+ recordId: props.id,
3439
+ });
3316
3440
  await new Promise(resolve => setTimeout(resolve, delay));
3317
3441
  continue;
3318
3442
  }
3319
- // Log the error and rethrow
3320
- logger_1.logger.error("Database error occurred", { error: String(error) });
3443
+ // Log structured error details and rethrow
3444
+ logger_1.logger.error("Database upsert operation failed", {
3445
+ operation: 'upsertOneAuthenticator',
3446
+ model: 'Authenticator',
3447
+ error: String(error),
3448
+ recordId: props.id,
3449
+ isRetryable: isConnectionError,
3450
+ });
3321
3451
  throw error;
3322
3452
  }
3323
3453
  }
@@ -3332,7 +3462,7 @@ exports.Authenticator = {
3332
3462
  * @returns The count of created records or null.
3333
3463
  */
3334
3464
  async updateMany(props, globalClient) {
3335
- var _a, _b, _c, _d, _e;
3465
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
3336
3466
  // Maximum number of retries for database connection issues
3337
3467
  const MAX_RETRIES = 3;
3338
3468
  let retryCount = 0;
@@ -4473,21 +4603,52 @@ exports.Authenticator = {
4473
4603
  }
4474
4604
  catch (error) {
4475
4605
  lastError = error;
4606
+ // Check for constraint violations FIRST - these are NEVER retryable
4607
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
4608
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
4609
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
4610
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
4611
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
4612
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
4613
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
4614
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
4615
+ if (isConstraintViolation) {
4616
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
4617
+ logger_1.logger.error("Non-retryable constraint violation in updateManyAuthenticator", {
4618
+ operation: 'updateManyAuthenticator',
4619
+ model: 'Authenticator',
4620
+ error: String(error),
4621
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
4622
+ errorCategory: 'CONSTRAINT_VIOLATION',
4623
+ isRetryable: false,
4624
+ });
4625
+ throw error;
4626
+ }
4476
4627
  // Check if this is a database connection error that we should retry
4477
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
4478
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
4479
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
4480
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
4481
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
4628
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
4629
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
4630
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
4631
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
4632
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
4482
4633
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4483
4634
  retryCount++;
4484
4635
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4485
- logger_1.logger.warn("Database connection error, retrying...");
4636
+ logger_1.logger.warn("Database connection error in updateManyAuthenticator, retrying...", {
4637
+ operation: 'updateManyAuthenticator',
4638
+ model: 'Authenticator',
4639
+ attempt: retryCount,
4640
+ maxRetries: MAX_RETRIES,
4641
+ });
4486
4642
  await new Promise(resolve => setTimeout(resolve, delay));
4487
4643
  continue;
4488
4644
  }
4489
- // Log the error and rethrow
4490
- logger_1.logger.error("Database error occurred", { error: String(error) });
4645
+ // Log structured error details and rethrow
4646
+ logger_1.logger.error("Database updateMany operation failed", {
4647
+ operation: 'updateManyAuthenticator',
4648
+ model: 'Authenticator',
4649
+ error: String(error),
4650
+ isRetryable: isConnectionError,
4651
+ });
4491
4652
  throw error;
4492
4653
  }
4493
4654
  }
@@ -4502,7 +4663,7 @@ exports.Authenticator = {
4502
4663
  * @returns The deleted Authenticator or null.
4503
4664
  */
4504
4665
  async delete(props, globalClient) {
4505
- var _a, _b, _c, _d, _e;
4666
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
4506
4667
  // Maximum number of retries for database connection issues
4507
4668
  const MAX_RETRIES = 3;
4508
4669
  let retryCount = 0;
@@ -4546,21 +4707,58 @@ exports.Authenticator = {
4546
4707
  }
4547
4708
  catch (error) {
4548
4709
  lastError = error;
4710
+ // Check for constraint violations FIRST - these are NEVER retryable
4711
+ // (e.g., foreign key constraints preventing deletion)
4712
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
4713
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
4714
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
4715
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
4716
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
4717
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
4718
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
4719
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
4720
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
4721
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
4722
+ if (isConstraintViolation) {
4723
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
4724
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneAuthenticator", {
4725
+ operation: 'deleteOneAuthenticator',
4726
+ model: 'Authenticator',
4727
+ error: String(error),
4728
+ recordId: props.id,
4729
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
4730
+ errorCategory: 'CONSTRAINT_VIOLATION',
4731
+ isRetryable: false,
4732
+ });
4733
+ throw error;
4734
+ }
4549
4735
  // Check if this is a database connection error that we should retry
4550
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
4551
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
4552
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
4553
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
4554
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
4736
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
4737
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
4738
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
4739
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
4740
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
4555
4741
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4556
4742
  retryCount++;
4557
4743
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4558
- logger_1.logger.warn("Database connection error, retrying...");
4744
+ logger_1.logger.warn("Database connection error in deleteOneAuthenticator, retrying...", {
4745
+ operation: 'deleteOneAuthenticator',
4746
+ model: 'Authenticator',
4747
+ attempt: retryCount,
4748
+ maxRetries: MAX_RETRIES,
4749
+ recordId: props.id,
4750
+ });
4559
4751
  await new Promise(resolve => setTimeout(resolve, delay));
4560
4752
  continue;
4561
4753
  }
4562
- // Log the error and rethrow
4563
- logger_1.logger.error("Database error occurred", { error: String(error) });
4754
+ // Log structured error details and rethrow
4755
+ logger_1.logger.error("Database delete operation failed", {
4756
+ operation: 'deleteOneAuthenticator',
4757
+ model: 'Authenticator',
4758
+ error: String(error),
4759
+ recordId: props.id,
4760
+ isRetryable: isConnectionError,
4761
+ });
4564
4762
  throw error;
4565
4763
  }
4566
4764
  }
@@ -4630,12 +4828,22 @@ exports.Authenticator = {
4630
4828
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4631
4829
  retryCount++;
4632
4830
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4633
- logger_1.logger.warn("Database connection error, retrying...");
4831
+ logger_1.logger.warn("Database connection error in getAuthenticator, retrying...", {
4832
+ operation: 'getAuthenticator',
4833
+ model: 'Authenticator',
4834
+ attempt: retryCount,
4835
+ maxRetries: MAX_RETRIES,
4836
+ });
4634
4837
  await new Promise(resolve => setTimeout(resolve, delay));
4635
4838
  continue;
4636
4839
  }
4637
- // Log the error and rethrow
4638
- logger_1.logger.error("Database error occurred", { error: String(error) });
4840
+ // Log structured error details and rethrow
4841
+ logger_1.logger.error("Database get operation failed", {
4842
+ operation: 'getAuthenticator',
4843
+ model: 'Authenticator',
4844
+ error: String(error),
4845
+ isRetryable: isConnectionError,
4846
+ });
4639
4847
  throw error;
4640
4848
  }
4641
4849
  }
@@ -4693,12 +4901,22 @@ exports.Authenticator = {
4693
4901
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4694
4902
  retryCount++;
4695
4903
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4696
- logger_1.logger.warn("Database connection error, retrying...");
4904
+ logger_1.logger.warn("Database connection error in getAllAuthenticator, retrying...", {
4905
+ operation: 'getAllAuthenticator',
4906
+ model: 'Authenticator',
4907
+ attempt: retryCount,
4908
+ maxRetries: MAX_RETRIES,
4909
+ });
4697
4910
  await new Promise(resolve => setTimeout(resolve, delay));
4698
4911
  continue;
4699
4912
  }
4700
- // Log the error and rethrow
4701
- logger_1.logger.error("Database error occurred", { error: String(error) });
4913
+ // Log structured error details and rethrow
4914
+ logger_1.logger.error("Database getAll operation failed", {
4915
+ operation: 'getAllAuthenticator',
4916
+ model: 'Authenticator',
4917
+ error: String(error),
4918
+ isRetryable: isConnectionError,
4919
+ });
4702
4920
  throw error;
4703
4921
  }
4704
4922
  }
@@ -4775,12 +4993,22 @@ exports.Authenticator = {
4775
4993
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4776
4994
  retryCount++;
4777
4995
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4778
- logger_1.logger.warn("Database connection error, retrying...");
4996
+ logger_1.logger.warn("Database connection error in findManyAuthenticator, retrying...", {
4997
+ operation: 'findManyAuthenticator',
4998
+ model: 'Authenticator',
4999
+ attempt: retryCount,
5000
+ maxRetries: MAX_RETRIES,
5001
+ });
4779
5002
  await new Promise(resolve => setTimeout(resolve, delay));
4780
5003
  continue;
4781
5004
  }
4782
- // Log the error and rethrow
4783
- logger_1.logger.error("Database error occurred", { error: String(error) });
5005
+ // Log structured error details and rethrow
5006
+ logger_1.logger.error("Database findMany operation failed", {
5007
+ operation: 'findManyAuthenticator',
5008
+ model: 'Authenticator',
5009
+ error: String(error),
5010
+ isRetryable: isConnectionError,
5011
+ });
4784
5012
  throw error;
4785
5013
  }
4786
5014
  }