@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
@@ -30,7 +30,7 @@ exports.VerificationToken = {
30
30
  * @returns The created VerificationToken or null.
31
31
  */
32
32
  async create(props, globalClient) {
33
- var _a, _b, _c, _d, _e;
33
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
34
34
  // Maximum number of retries for database connection issues
35
35
  const MAX_RETRIES = 3;
36
36
  let retryCount = 0;
@@ -77,21 +77,52 @@ exports.VerificationToken = {
77
77
  }
78
78
  catch (error) {
79
79
  lastError = error;
80
+ // Check for constraint violations FIRST - these are NEVER retryable
81
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
82
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
83
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
84
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
85
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
86
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
87
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
88
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
89
+ if (isConstraintViolation) {
90
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
91
+ logger_1.logger.error("Non-retryable constraint violation in createOneVerificationToken", {
92
+ operation: 'createOneVerificationToken',
93
+ model: 'VerificationToken',
94
+ error: String(error),
95
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
96
+ errorCategory: 'CONSTRAINT_VIOLATION',
97
+ isRetryable: false,
98
+ });
99
+ throw error;
100
+ }
80
101
  // Check if this is a database connection error that we should retry
81
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
82
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
83
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
84
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
85
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
102
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
103
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
104
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
105
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
106
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
86
107
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
87
108
  retryCount++;
88
109
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
89
- logger_1.logger.warn("Database connection error, retrying...");
110
+ logger_1.logger.warn("Database connection error in createOneVerificationToken, retrying...", {
111
+ operation: 'createOneVerificationToken',
112
+ model: 'VerificationToken',
113
+ attempt: retryCount,
114
+ maxRetries: MAX_RETRIES,
115
+ });
90
116
  await new Promise(resolve => setTimeout(resolve, delay));
91
117
  continue;
92
118
  }
93
- // Log the error and rethrow
94
- logger_1.logger.error("Database error occurred", { error: String(error) });
119
+ // Log structured error details and rethrow
120
+ logger_1.logger.error("Database create operation failed", {
121
+ operation: 'createOneVerificationToken',
122
+ model: 'VerificationToken',
123
+ error: String(error),
124
+ isRetryable: isConnectionError,
125
+ });
95
126
  throw error;
96
127
  }
97
128
  }
@@ -106,7 +137,7 @@ exports.VerificationToken = {
106
137
  * @returns The count of created records or null.
107
138
  */
108
139
  async createMany(props, globalClient) {
109
- var _a, _b, _c, _d, _e;
140
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
110
141
  // Maximum number of retries for database connection issues
111
142
  const MAX_RETRIES = 3;
112
143
  let retryCount = 0;
@@ -152,21 +183,52 @@ exports.VerificationToken = {
152
183
  }
153
184
  catch (error) {
154
185
  lastError = error;
186
+ // Check for constraint violations FIRST - these are NEVER retryable
187
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
188
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
189
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
190
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
191
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
192
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
193
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
194
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
195
+ if (isConstraintViolation) {
196
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
197
+ logger_1.logger.error("Non-retryable constraint violation in createManyVerificationToken", {
198
+ operation: 'createManyVerificationToken',
199
+ model: 'VerificationToken',
200
+ error: String(error),
201
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
202
+ errorCategory: 'CONSTRAINT_VIOLATION',
203
+ isRetryable: false,
204
+ });
205
+ throw error;
206
+ }
155
207
  // Check if this is a database connection error that we should retry
156
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
157
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
158
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
159
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
160
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
208
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
209
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
210
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
211
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
212
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
161
213
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
162
214
  retryCount++;
163
215
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
164
- logger_1.logger.warn("Database connection error, retrying...");
216
+ logger_1.logger.warn("Database connection error in createManyVerificationToken, retrying...", {
217
+ operation: 'createManyVerificationToken',
218
+ model: 'VerificationToken',
219
+ attempt: retryCount,
220
+ maxRetries: MAX_RETRIES,
221
+ });
165
222
  await new Promise(resolve => setTimeout(resolve, delay));
166
223
  continue;
167
224
  }
168
- // Log the error and rethrow
169
- logger_1.logger.error("Database error occurred", { error: String(error) });
225
+ // Log structured error details and rethrow
226
+ logger_1.logger.error("Database createMany operation failed", {
227
+ operation: 'createManyVerificationToken',
228
+ model: 'VerificationToken',
229
+ error: String(error),
230
+ isRetryable: isConnectionError,
231
+ });
170
232
  throw error;
171
233
  }
172
234
  }
@@ -181,7 +243,7 @@ exports.VerificationToken = {
181
243
  * @returns The updated VerificationToken or null.
182
244
  */
183
245
  async update(props, globalClient) {
184
- var _a, _b, _c, _d, _e;
246
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
185
247
  // Maximum number of retries for database connection issues
186
248
  const MAX_RETRIES = 3;
187
249
  let retryCount = 0;
@@ -239,21 +301,55 @@ exports.VerificationToken = {
239
301
  }
240
302
  catch (error) {
241
303
  lastError = error;
304
+ // Check for constraint violations FIRST - these are NEVER retryable
305
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
306
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
307
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
308
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
309
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
310
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
311
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
312
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
313
+ if (isConstraintViolation) {
314
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
315
+ logger_1.logger.error("Non-retryable constraint violation in updateOneVerificationToken", {
316
+ operation: 'updateOneVerificationToken',
317
+ model: 'VerificationToken',
318
+ error: String(error),
319
+ recordId: props.id,
320
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
321
+ errorCategory: 'CONSTRAINT_VIOLATION',
322
+ isRetryable: false,
323
+ });
324
+ throw error;
325
+ }
242
326
  // Check if this is a database connection error that we should retry
243
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
244
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
245
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
246
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
247
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
327
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
328
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
329
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
330
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
331
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
248
332
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
249
333
  retryCount++;
250
334
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
251
- logger_1.logger.warn("Database connection error, retrying...");
335
+ logger_1.logger.warn("Database connection error in updateOneVerificationToken, retrying...", {
336
+ operation: 'updateOneVerificationToken',
337
+ model: 'VerificationToken',
338
+ attempt: retryCount,
339
+ maxRetries: MAX_RETRIES,
340
+ recordId: props.id,
341
+ });
252
342
  await new Promise(resolve => setTimeout(resolve, delay));
253
343
  continue;
254
344
  }
255
- // Log the error and rethrow
256
- logger_1.logger.error("Database error occurred", { error: String(error) });
345
+ // Log structured error details and rethrow
346
+ logger_1.logger.error("Database update operation failed", {
347
+ operation: 'updateOneVerificationToken',
348
+ model: 'VerificationToken',
349
+ error: String(error),
350
+ recordId: props.id,
351
+ isRetryable: isConnectionError,
352
+ });
257
353
  throw error;
258
354
  }
259
355
  }
@@ -268,7 +364,7 @@ exports.VerificationToken = {
268
364
  * @returns The updated VerificationToken or null.
269
365
  */
270
366
  async upsert(props, globalClient) {
271
- var _a, _b, _c, _d, _e;
367
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
272
368
  // Maximum number of retries for database connection issues
273
369
  const MAX_RETRIES = 3;
274
370
  let retryCount = 0;
@@ -328,21 +424,55 @@ exports.VerificationToken = {
328
424
  }
329
425
  catch (error) {
330
426
  lastError = error;
427
+ // Check for constraint violations FIRST - these are NEVER retryable
428
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
429
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
430
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
431
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
432
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
433
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
434
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
435
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
436
+ if (isConstraintViolation) {
437
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
438
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneVerificationToken", {
439
+ operation: 'upsertOneVerificationToken',
440
+ model: 'VerificationToken',
441
+ error: String(error),
442
+ recordId: props.id,
443
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
444
+ errorCategory: 'CONSTRAINT_VIOLATION',
445
+ isRetryable: false,
446
+ });
447
+ throw error;
448
+ }
331
449
  // Check if this is a database connection error that we should retry
332
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
333
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
334
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
335
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
336
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
450
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
451
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
452
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
453
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
454
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
337
455
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
338
456
  retryCount++;
339
457
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
340
- logger_1.logger.warn("Database connection error, retrying...");
458
+ logger_1.logger.warn("Database connection error in upsertOneVerificationToken, retrying...", {
459
+ operation: 'upsertOneVerificationToken',
460
+ model: 'VerificationToken',
461
+ attempt: retryCount,
462
+ maxRetries: MAX_RETRIES,
463
+ recordId: props.id,
464
+ });
341
465
  await new Promise(resolve => setTimeout(resolve, delay));
342
466
  continue;
343
467
  }
344
- // Log the error and rethrow
345
- logger_1.logger.error("Database error occurred", { error: String(error) });
468
+ // Log structured error details and rethrow
469
+ logger_1.logger.error("Database upsert operation failed", {
470
+ operation: 'upsertOneVerificationToken',
471
+ model: 'VerificationToken',
472
+ error: String(error),
473
+ recordId: props.id,
474
+ isRetryable: isConnectionError,
475
+ });
346
476
  throw error;
347
477
  }
348
478
  }
@@ -357,7 +487,7 @@ exports.VerificationToken = {
357
487
  * @returns The count of created records or null.
358
488
  */
359
489
  async updateMany(props, globalClient) {
360
- var _a, _b, _c, _d, _e;
490
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
361
491
  // Maximum number of retries for database connection issues
362
492
  const MAX_RETRIES = 3;
363
493
  let retryCount = 0;
@@ -415,21 +545,52 @@ exports.VerificationToken = {
415
545
  }
416
546
  catch (error) {
417
547
  lastError = error;
548
+ // Check for constraint violations FIRST - these are NEVER retryable
549
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
550
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
551
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
552
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
553
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
554
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
555
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
556
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
557
+ if (isConstraintViolation) {
558
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
559
+ logger_1.logger.error("Non-retryable constraint violation in updateManyVerificationToken", {
560
+ operation: 'updateManyVerificationToken',
561
+ model: 'VerificationToken',
562
+ error: String(error),
563
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
564
+ errorCategory: 'CONSTRAINT_VIOLATION',
565
+ isRetryable: false,
566
+ });
567
+ throw error;
568
+ }
418
569
  // Check if this is a database connection error that we should retry
419
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
420
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
421
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
422
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
423
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
570
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
571
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
572
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
573
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
574
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
424
575
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
425
576
  retryCount++;
426
577
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
427
- logger_1.logger.warn("Database connection error, retrying...");
578
+ logger_1.logger.warn("Database connection error in updateManyVerificationToken, retrying...", {
579
+ operation: 'updateManyVerificationToken',
580
+ model: 'VerificationToken',
581
+ attempt: retryCount,
582
+ maxRetries: MAX_RETRIES,
583
+ });
428
584
  await new Promise(resolve => setTimeout(resolve, delay));
429
585
  continue;
430
586
  }
431
- // Log the error and rethrow
432
- logger_1.logger.error("Database error occurred", { error: String(error) });
587
+ // Log structured error details and rethrow
588
+ logger_1.logger.error("Database updateMany operation failed", {
589
+ operation: 'updateManyVerificationToken',
590
+ model: 'VerificationToken',
591
+ error: String(error),
592
+ isRetryable: isConnectionError,
593
+ });
433
594
  throw error;
434
595
  }
435
596
  }
@@ -444,7 +605,7 @@ exports.VerificationToken = {
444
605
  * @returns The deleted VerificationToken or null.
445
606
  */
446
607
  async delete(props, globalClient) {
447
- var _a, _b, _c, _d, _e;
608
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
448
609
  // Maximum number of retries for database connection issues
449
610
  const MAX_RETRIES = 3;
450
611
  let retryCount = 0;
@@ -488,21 +649,58 @@ exports.VerificationToken = {
488
649
  }
489
650
  catch (error) {
490
651
  lastError = error;
652
+ // Check for constraint violations FIRST - these are NEVER retryable
653
+ // (e.g., foreign key constraints preventing deletion)
654
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
655
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
656
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
657
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
658
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
659
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
660
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
661
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
662
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
663
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
664
+ if (isConstraintViolation) {
665
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
666
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneVerificationToken", {
667
+ operation: 'deleteOneVerificationToken',
668
+ model: 'VerificationToken',
669
+ error: String(error),
670
+ recordId: props.id,
671
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
672
+ errorCategory: 'CONSTRAINT_VIOLATION',
673
+ isRetryable: false,
674
+ });
675
+ throw error;
676
+ }
491
677
  // Check if this is a database connection error that we should retry
492
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
493
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
494
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
495
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
496
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
678
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
679
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
680
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
681
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
682
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
497
683
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
498
684
  retryCount++;
499
685
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
500
- logger_1.logger.warn("Database connection error, retrying...");
686
+ logger_1.logger.warn("Database connection error in deleteOneVerificationToken, retrying...", {
687
+ operation: 'deleteOneVerificationToken',
688
+ model: 'VerificationToken',
689
+ attempt: retryCount,
690
+ maxRetries: MAX_RETRIES,
691
+ recordId: props.id,
692
+ });
501
693
  await new Promise(resolve => setTimeout(resolve, delay));
502
694
  continue;
503
695
  }
504
- // Log the error and rethrow
505
- logger_1.logger.error("Database error occurred", { error: String(error) });
696
+ // Log structured error details and rethrow
697
+ logger_1.logger.error("Database delete operation failed", {
698
+ operation: 'deleteOneVerificationToken',
699
+ model: 'VerificationToken',
700
+ error: String(error),
701
+ recordId: props.id,
702
+ isRetryable: isConnectionError,
703
+ });
506
704
  throw error;
507
705
  }
508
706
  }
@@ -569,12 +767,22 @@ exports.VerificationToken = {
569
767
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
570
768
  retryCount++;
571
769
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
572
- logger_1.logger.warn("Database connection error, retrying...");
770
+ logger_1.logger.warn("Database connection error in getVerificationToken, retrying...", {
771
+ operation: 'getVerificationToken',
772
+ model: 'VerificationToken',
773
+ attempt: retryCount,
774
+ maxRetries: MAX_RETRIES,
775
+ });
573
776
  await new Promise(resolve => setTimeout(resolve, delay));
574
777
  continue;
575
778
  }
576
- // Log the error and rethrow
577
- logger_1.logger.error("Database error occurred", { error: String(error) });
779
+ // Log structured error details and rethrow
780
+ logger_1.logger.error("Database get operation failed", {
781
+ operation: 'getVerificationToken',
782
+ model: 'VerificationToken',
783
+ error: String(error),
784
+ isRetryable: isConnectionError,
785
+ });
578
786
  throw error;
579
787
  }
580
788
  }
@@ -632,12 +840,22 @@ exports.VerificationToken = {
632
840
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
633
841
  retryCount++;
634
842
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
635
- logger_1.logger.warn("Database connection error, retrying...");
843
+ logger_1.logger.warn("Database connection error in getAllVerificationToken, retrying...", {
844
+ operation: 'getAllVerificationToken',
845
+ model: 'VerificationToken',
846
+ attempt: retryCount,
847
+ maxRetries: MAX_RETRIES,
848
+ });
636
849
  await new Promise(resolve => setTimeout(resolve, delay));
637
850
  continue;
638
851
  }
639
- // Log the error and rethrow
640
- logger_1.logger.error("Database error occurred", { error: String(error) });
852
+ // Log structured error details and rethrow
853
+ logger_1.logger.error("Database getAll operation failed", {
854
+ operation: 'getAllVerificationToken',
855
+ model: 'VerificationToken',
856
+ error: String(error),
857
+ isRetryable: isConnectionError,
858
+ });
641
859
  throw error;
642
860
  }
643
861
  }
@@ -711,12 +929,22 @@ exports.VerificationToken = {
711
929
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
712
930
  retryCount++;
713
931
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
714
- logger_1.logger.warn("Database connection error, retrying...");
932
+ logger_1.logger.warn("Database connection error in findManyVerificationToken, retrying...", {
933
+ operation: 'findManyVerificationToken',
934
+ model: 'VerificationToken',
935
+ attempt: retryCount,
936
+ maxRetries: MAX_RETRIES,
937
+ });
715
938
  await new Promise(resolve => setTimeout(resolve, delay));
716
939
  continue;
717
940
  }
718
- // Log the error and rethrow
719
- logger_1.logger.error("Database error occurred", { error: String(error) });
941
+ // Log structured error details and rethrow
942
+ logger_1.logger.error("Database findMany operation failed", {
943
+ operation: 'findManyVerificationToken',
944
+ model: 'VerificationToken',
945
+ error: String(error),
946
+ isRetryable: isConnectionError,
947
+ });
720
948
  throw error;
721
949
  }
722
950
  }