@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/Action.cjs CHANGED
@@ -37,7 +37,7 @@ exports.Action = {
37
37
  * @returns The created Action or null.
38
38
  */
39
39
  async create(props, globalClient) {
40
- var _a, _b, _c, _d, _e;
40
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
41
41
  // Maximum number of retries for database connection issues
42
42
  const MAX_RETRIES = 3;
43
43
  let retryCount = 0;
@@ -133,21 +133,52 @@ exports.Action = {
133
133
  }
134
134
  catch (error) {
135
135
  lastError = error;
136
+ // Check for constraint violations FIRST - these are NEVER retryable
137
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
138
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
139
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
140
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
141
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
142
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
143
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
144
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
145
+ if (isConstraintViolation) {
146
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
147
+ logger_1.logger.error("Non-retryable constraint violation in createOneAction", {
148
+ operation: 'createOneAction',
149
+ model: 'Action',
150
+ error: String(error),
151
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
152
+ errorCategory: 'CONSTRAINT_VIOLATION',
153
+ isRetryable: false,
154
+ });
155
+ throw error;
156
+ }
136
157
  // Check if this is a database connection error that we should retry
137
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
138
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
139
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
140
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
141
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
158
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
159
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
160
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
161
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
162
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
142
163
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
143
164
  retryCount++;
144
165
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
145
- logger_1.logger.warn("Database connection error, retrying...");
166
+ logger_1.logger.warn("Database connection error in createOneAction, retrying...", {
167
+ operation: 'createOneAction',
168
+ model: 'Action',
169
+ attempt: retryCount,
170
+ maxRetries: MAX_RETRIES,
171
+ });
146
172
  await new Promise(resolve => setTimeout(resolve, delay));
147
173
  continue;
148
174
  }
149
- // Log the error and rethrow
150
- logger_1.logger.error("Database error occurred", { error: String(error) });
175
+ // Log structured error details and rethrow
176
+ logger_1.logger.error("Database create operation failed", {
177
+ operation: 'createOneAction',
178
+ model: 'Action',
179
+ error: String(error),
180
+ isRetryable: isConnectionError,
181
+ });
151
182
  throw error;
152
183
  }
153
184
  }
@@ -162,7 +193,7 @@ exports.Action = {
162
193
  * @returns The count of created records or null.
163
194
  */
164
195
  async createMany(props, globalClient) {
165
- var _a, _b, _c, _d, _e;
196
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
166
197
  // Maximum number of retries for database connection issues
167
198
  const MAX_RETRIES = 3;
168
199
  let retryCount = 0;
@@ -213,21 +244,52 @@ exports.Action = {
213
244
  }
214
245
  catch (error) {
215
246
  lastError = error;
247
+ // Check for constraint violations FIRST - these are NEVER retryable
248
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
249
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
250
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
251
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
252
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
253
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
254
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
255
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
256
+ if (isConstraintViolation) {
257
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
258
+ logger_1.logger.error("Non-retryable constraint violation in createManyAction", {
259
+ operation: 'createManyAction',
260
+ model: 'Action',
261
+ error: String(error),
262
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
263
+ errorCategory: 'CONSTRAINT_VIOLATION',
264
+ isRetryable: false,
265
+ });
266
+ throw error;
267
+ }
216
268
  // Check if this is a database connection error that we should retry
217
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
218
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
219
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
220
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
221
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
269
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
270
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
271
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
272
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
273
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
222
274
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
223
275
  retryCount++;
224
276
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
225
- logger_1.logger.warn("Database connection error, retrying...");
277
+ logger_1.logger.warn("Database connection error in createManyAction, retrying...", {
278
+ operation: 'createManyAction',
279
+ model: 'Action',
280
+ attempt: retryCount,
281
+ maxRetries: MAX_RETRIES,
282
+ });
226
283
  await new Promise(resolve => setTimeout(resolve, delay));
227
284
  continue;
228
285
  }
229
- // Log the error and rethrow
230
- logger_1.logger.error("Database error occurred", { error: String(error) });
286
+ // Log structured error details and rethrow
287
+ logger_1.logger.error("Database createMany operation failed", {
288
+ operation: 'createManyAction',
289
+ model: 'Action',
290
+ error: String(error),
291
+ isRetryable: isConnectionError,
292
+ });
231
293
  throw error;
232
294
  }
233
295
  }
@@ -242,7 +304,7 @@ exports.Action = {
242
304
  * @returns The updated Action or null.
243
305
  */
244
306
  async update(props, globalClient) {
245
- var _a, _b, _c, _d, _e;
307
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
246
308
  // Maximum number of retries for database connection issues
247
309
  const MAX_RETRIES = 3;
248
310
  let retryCount = 0;
@@ -449,21 +511,55 @@ exports.Action = {
449
511
  }
450
512
  catch (error) {
451
513
  lastError = error;
514
+ // Check for constraint violations FIRST - these are NEVER retryable
515
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
516
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
517
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
518
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
519
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
520
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
521
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
522
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
523
+ if (isConstraintViolation) {
524
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
525
+ logger_1.logger.error("Non-retryable constraint violation in updateOneAction", {
526
+ operation: 'updateOneAction',
527
+ model: 'Action',
528
+ error: String(error),
529
+ recordId: props.id,
530
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
531
+ errorCategory: 'CONSTRAINT_VIOLATION',
532
+ isRetryable: false,
533
+ });
534
+ throw error;
535
+ }
452
536
  // Check if this is a database connection error that we should retry
453
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
454
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
455
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
456
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
457
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
537
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
538
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
539
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
540
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
541
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
458
542
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
459
543
  retryCount++;
460
544
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
461
- logger_1.logger.warn("Database connection error, retrying...");
545
+ logger_1.logger.warn("Database connection error in updateOneAction, retrying...", {
546
+ operation: 'updateOneAction',
547
+ model: 'Action',
548
+ attempt: retryCount,
549
+ maxRetries: MAX_RETRIES,
550
+ recordId: props.id,
551
+ });
462
552
  await new Promise(resolve => setTimeout(resolve, delay));
463
553
  continue;
464
554
  }
465
- // Log the error and rethrow
466
- logger_1.logger.error("Database error occurred", { error: String(error) });
555
+ // Log structured error details and rethrow
556
+ logger_1.logger.error("Database update operation failed", {
557
+ operation: 'updateOneAction',
558
+ model: 'Action',
559
+ error: String(error),
560
+ recordId: props.id,
561
+ isRetryable: isConnectionError,
562
+ });
467
563
  throw error;
468
564
  }
469
565
  }
@@ -478,7 +574,7 @@ exports.Action = {
478
574
  * @returns The updated Action or null.
479
575
  */
480
576
  async upsert(props, globalClient) {
481
- var _a, _b, _c, _d, _e;
577
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
482
578
  // Maximum number of retries for database connection issues
483
579
  const MAX_RETRIES = 3;
484
580
  let retryCount = 0;
@@ -730,21 +826,55 @@ exports.Action = {
730
826
  }
731
827
  catch (error) {
732
828
  lastError = error;
829
+ // Check for constraint violations FIRST - these are NEVER retryable
830
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
831
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
832
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
833
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
834
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
835
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
836
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
837
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
838
+ if (isConstraintViolation) {
839
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
840
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneAction", {
841
+ operation: 'upsertOneAction',
842
+ model: 'Action',
843
+ error: String(error),
844
+ recordId: props.id,
845
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
846
+ errorCategory: 'CONSTRAINT_VIOLATION',
847
+ isRetryable: false,
848
+ });
849
+ throw error;
850
+ }
733
851
  // Check if this is a database connection error that we should retry
734
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
735
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
736
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
737
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
738
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
852
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
853
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
854
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
855
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
856
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
739
857
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
740
858
  retryCount++;
741
859
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
742
- logger_1.logger.warn("Database connection error, retrying...");
860
+ logger_1.logger.warn("Database connection error in upsertOneAction, retrying...", {
861
+ operation: 'upsertOneAction',
862
+ model: 'Action',
863
+ attempt: retryCount,
864
+ maxRetries: MAX_RETRIES,
865
+ recordId: props.id,
866
+ });
743
867
  await new Promise(resolve => setTimeout(resolve, delay));
744
868
  continue;
745
869
  }
746
- // Log the error and rethrow
747
- logger_1.logger.error("Database error occurred", { error: String(error) });
870
+ // Log structured error details and rethrow
871
+ logger_1.logger.error("Database upsert operation failed", {
872
+ operation: 'upsertOneAction',
873
+ model: 'Action',
874
+ error: String(error),
875
+ recordId: props.id,
876
+ isRetryable: isConnectionError,
877
+ });
748
878
  throw error;
749
879
  }
750
880
  }
@@ -759,7 +889,7 @@ exports.Action = {
759
889
  * @returns The count of created records or null.
760
890
  */
761
891
  async updateMany(props, globalClient) {
762
- var _a, _b, _c, _d, _e;
892
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
763
893
  // Maximum number of retries for database connection issues
764
894
  const MAX_RETRIES = 3;
765
895
  let retryCount = 0;
@@ -966,21 +1096,52 @@ exports.Action = {
966
1096
  }
967
1097
  catch (error) {
968
1098
  lastError = error;
1099
+ // Check for constraint violations FIRST - these are NEVER retryable
1100
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
1101
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
1102
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
1103
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
1104
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
1105
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
1106
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
1107
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
1108
+ if (isConstraintViolation) {
1109
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
1110
+ logger_1.logger.error("Non-retryable constraint violation in updateManyAction", {
1111
+ operation: 'updateManyAction',
1112
+ model: 'Action',
1113
+ error: String(error),
1114
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1115
+ errorCategory: 'CONSTRAINT_VIOLATION',
1116
+ isRetryable: false,
1117
+ });
1118
+ throw error;
1119
+ }
969
1120
  // Check if this is a database connection error that we should retry
970
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
971
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
972
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
973
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
974
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
1121
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
1122
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
1123
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
1124
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
1125
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
975
1126
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
976
1127
  retryCount++;
977
1128
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
978
- logger_1.logger.warn("Database connection error, retrying...");
1129
+ logger_1.logger.warn("Database connection error in updateManyAction, retrying...", {
1130
+ operation: 'updateManyAction',
1131
+ model: 'Action',
1132
+ attempt: retryCount,
1133
+ maxRetries: MAX_RETRIES,
1134
+ });
979
1135
  await new Promise(resolve => setTimeout(resolve, delay));
980
1136
  continue;
981
1137
  }
982
- // Log the error and rethrow
983
- logger_1.logger.error("Database error occurred", { error: String(error) });
1138
+ // Log structured error details and rethrow
1139
+ logger_1.logger.error("Database updateMany operation failed", {
1140
+ operation: 'updateManyAction',
1141
+ model: 'Action',
1142
+ error: String(error),
1143
+ isRetryable: isConnectionError,
1144
+ });
984
1145
  throw error;
985
1146
  }
986
1147
  }
@@ -995,7 +1156,7 @@ exports.Action = {
995
1156
  * @returns The deleted Action or null.
996
1157
  */
997
1158
  async delete(props, globalClient) {
998
- var _a, _b, _c, _d, _e;
1159
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
999
1160
  // Maximum number of retries for database connection issues
1000
1161
  const MAX_RETRIES = 3;
1001
1162
  let retryCount = 0;
@@ -1039,21 +1200,58 @@ exports.Action = {
1039
1200
  }
1040
1201
  catch (error) {
1041
1202
  lastError = error;
1203
+ // Check for constraint violations FIRST - these are NEVER retryable
1204
+ // (e.g., foreign key constraints preventing deletion)
1205
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
1206
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
1207
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
1208
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
1209
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
1210
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
1211
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
1212
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
1213
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
1214
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
1215
+ if (isConstraintViolation) {
1216
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
1217
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneAction", {
1218
+ operation: 'deleteOneAction',
1219
+ model: 'Action',
1220
+ error: String(error),
1221
+ recordId: props.id,
1222
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1223
+ errorCategory: 'CONSTRAINT_VIOLATION',
1224
+ isRetryable: false,
1225
+ });
1226
+ throw error;
1227
+ }
1042
1228
  // Check if this is a database connection error that we should retry
1043
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
1044
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
1045
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
1046
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
1047
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
1229
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
1230
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
1231
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
1232
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
1233
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
1048
1234
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1049
1235
  retryCount++;
1050
1236
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1051
- logger_1.logger.warn("Database connection error, retrying...");
1237
+ logger_1.logger.warn("Database connection error in deleteOneAction, retrying...", {
1238
+ operation: 'deleteOneAction',
1239
+ model: 'Action',
1240
+ attempt: retryCount,
1241
+ maxRetries: MAX_RETRIES,
1242
+ recordId: props.id,
1243
+ });
1052
1244
  await new Promise(resolve => setTimeout(resolve, delay));
1053
1245
  continue;
1054
1246
  }
1055
- // Log the error and rethrow
1056
- logger_1.logger.error("Database error occurred", { error: String(error) });
1247
+ // Log structured error details and rethrow
1248
+ logger_1.logger.error("Database delete operation failed", {
1249
+ operation: 'deleteOneAction',
1250
+ model: 'Action',
1251
+ error: String(error),
1252
+ recordId: props.id,
1253
+ isRetryable: isConnectionError,
1254
+ });
1057
1255
  throw error;
1058
1256
  }
1059
1257
  }
@@ -1124,12 +1322,22 @@ exports.Action = {
1124
1322
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1125
1323
  retryCount++;
1126
1324
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1127
- logger_1.logger.warn("Database connection error, retrying...");
1325
+ logger_1.logger.warn("Database connection error in getAction, retrying...", {
1326
+ operation: 'getAction',
1327
+ model: 'Action',
1328
+ attempt: retryCount,
1329
+ maxRetries: MAX_RETRIES,
1330
+ });
1128
1331
  await new Promise(resolve => setTimeout(resolve, delay));
1129
1332
  continue;
1130
1333
  }
1131
- // Log the error and rethrow
1132
- logger_1.logger.error("Database error occurred", { error: String(error) });
1334
+ // Log structured error details and rethrow
1335
+ logger_1.logger.error("Database get operation failed", {
1336
+ operation: 'getAction',
1337
+ model: 'Action',
1338
+ error: String(error),
1339
+ isRetryable: isConnectionError,
1340
+ });
1133
1341
  throw error;
1134
1342
  }
1135
1343
  }
@@ -1187,12 +1395,22 @@ exports.Action = {
1187
1395
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1188
1396
  retryCount++;
1189
1397
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1190
- logger_1.logger.warn("Database connection error, retrying...");
1398
+ logger_1.logger.warn("Database connection error in getAllAction, retrying...", {
1399
+ operation: 'getAllAction',
1400
+ model: 'Action',
1401
+ attempt: retryCount,
1402
+ maxRetries: MAX_RETRIES,
1403
+ });
1191
1404
  await new Promise(resolve => setTimeout(resolve, delay));
1192
1405
  continue;
1193
1406
  }
1194
- // Log the error and rethrow
1195
- logger_1.logger.error("Database error occurred", { error: String(error) });
1407
+ // Log structured error details and rethrow
1408
+ logger_1.logger.error("Database getAll operation failed", {
1409
+ operation: 'getAllAction',
1410
+ model: 'Action',
1411
+ error: String(error),
1412
+ isRetryable: isConnectionError,
1413
+ });
1196
1414
  throw error;
1197
1415
  }
1198
1416
  }
@@ -1269,12 +1487,22 @@ exports.Action = {
1269
1487
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1270
1488
  retryCount++;
1271
1489
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1272
- logger_1.logger.warn("Database connection error, retrying...");
1490
+ logger_1.logger.warn("Database connection error in findManyAction, retrying...", {
1491
+ operation: 'findManyAction',
1492
+ model: 'Action',
1493
+ attempt: retryCount,
1494
+ maxRetries: MAX_RETRIES,
1495
+ });
1273
1496
  await new Promise(resolve => setTimeout(resolve, delay));
1274
1497
  continue;
1275
1498
  }
1276
- // Log the error and rethrow
1277
- logger_1.logger.error("Database error occurred", { error: String(error) });
1499
+ // Log structured error details and rethrow
1500
+ logger_1.logger.error("Database findMany operation failed", {
1501
+ operation: 'findManyAction',
1502
+ model: 'Action',
1503
+ error: String(error),
1504
+ isRetryable: isConnectionError,
1505
+ });
1278
1506
  throw error;
1279
1507
  }
1280
1508
  }