@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/SystemAlert.cjs CHANGED
@@ -49,7 +49,7 @@ exports.SystemAlert = {
49
49
  * @returns The created SystemAlert or null.
50
50
  */
51
51
  async create(props, globalClient) {
52
- var _a, _b, _c, _d, _e;
52
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
53
53
  // Maximum number of retries for database connection issues
54
54
  const MAX_RETRIES = 3;
55
55
  let retryCount = 0;
@@ -113,21 +113,52 @@ exports.SystemAlert = {
113
113
  }
114
114
  catch (error) {
115
115
  lastError = error;
116
+ // Check for constraint violations FIRST - these are NEVER retryable
117
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
118
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
119
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
120
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
121
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
122
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
123
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
124
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
125
+ if (isConstraintViolation) {
126
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
127
+ logger_1.logger.error("Non-retryable constraint violation in createOneSystemAlert", {
128
+ operation: 'createOneSystemAlert',
129
+ model: 'SystemAlert',
130
+ error: String(error),
131
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
132
+ errorCategory: 'CONSTRAINT_VIOLATION',
133
+ isRetryable: false,
134
+ });
135
+ throw error;
136
+ }
116
137
  // Check if this is a database connection error that we should retry
117
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
118
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
119
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
120
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
121
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
138
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
139
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
140
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
141
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
142
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
122
143
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
123
144
  retryCount++;
124
145
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
125
- logger_1.logger.warn("Database connection error, retrying...");
146
+ logger_1.logger.warn("Database connection error in createOneSystemAlert, retrying...", {
147
+ operation: 'createOneSystemAlert',
148
+ model: 'SystemAlert',
149
+ attempt: retryCount,
150
+ maxRetries: MAX_RETRIES,
151
+ });
126
152
  await new Promise(resolve => setTimeout(resolve, delay));
127
153
  continue;
128
154
  }
129
- // Log the error and rethrow
130
- logger_1.logger.error("Database error occurred", { error: String(error) });
155
+ // Log structured error details and rethrow
156
+ logger_1.logger.error("Database create operation failed", {
157
+ operation: 'createOneSystemAlert',
158
+ model: 'SystemAlert',
159
+ error: String(error),
160
+ isRetryable: isConnectionError,
161
+ });
131
162
  throw error;
132
163
  }
133
164
  }
@@ -142,7 +173,7 @@ exports.SystemAlert = {
142
173
  * @returns The count of created records or null.
143
174
  */
144
175
  async createMany(props, globalClient) {
145
- var _a, _b, _c, _d, _e;
176
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
146
177
  // Maximum number of retries for database connection issues
147
178
  const MAX_RETRIES = 3;
148
179
  let retryCount = 0;
@@ -205,21 +236,52 @@ exports.SystemAlert = {
205
236
  }
206
237
  catch (error) {
207
238
  lastError = error;
239
+ // Check for constraint violations FIRST - these are NEVER retryable
240
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
241
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
242
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
243
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
244
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
245
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
246
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
247
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
248
+ if (isConstraintViolation) {
249
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
250
+ logger_1.logger.error("Non-retryable constraint violation in createManySystemAlert", {
251
+ operation: 'createManySystemAlert',
252
+ model: 'SystemAlert',
253
+ error: String(error),
254
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
255
+ errorCategory: 'CONSTRAINT_VIOLATION',
256
+ isRetryable: false,
257
+ });
258
+ throw error;
259
+ }
208
260
  // Check if this is a database connection error that we should retry
209
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
210
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
211
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
212
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
213
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
261
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
262
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
263
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
264
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
265
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
214
266
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
215
267
  retryCount++;
216
268
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
217
- logger_1.logger.warn("Database connection error, retrying...");
269
+ logger_1.logger.warn("Database connection error in createManySystemAlert, retrying...", {
270
+ operation: 'createManySystemAlert',
271
+ model: 'SystemAlert',
272
+ attempt: retryCount,
273
+ maxRetries: MAX_RETRIES,
274
+ });
218
275
  await new Promise(resolve => setTimeout(resolve, delay));
219
276
  continue;
220
277
  }
221
- // Log the error and rethrow
222
- logger_1.logger.error("Database error occurred", { error: String(error) });
278
+ // Log structured error details and rethrow
279
+ logger_1.logger.error("Database createMany operation failed", {
280
+ operation: 'createManySystemAlert',
281
+ model: 'SystemAlert',
282
+ error: String(error),
283
+ isRetryable: isConnectionError,
284
+ });
223
285
  throw error;
224
286
  }
225
287
  }
@@ -234,7 +296,7 @@ exports.SystemAlert = {
234
296
  * @returns The updated SystemAlert or null.
235
297
  */
236
298
  async update(props, globalClient) {
237
- var _a, _b, _c, _d, _e;
299
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
238
300
  // Maximum number of retries for database connection issues
239
301
  const MAX_RETRIES = 3;
240
302
  let retryCount = 0;
@@ -355,21 +417,55 @@ exports.SystemAlert = {
355
417
  }
356
418
  catch (error) {
357
419
  lastError = error;
420
+ // Check for constraint violations FIRST - these are NEVER retryable
421
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
422
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
423
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
424
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
425
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
426
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
427
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
428
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
429
+ if (isConstraintViolation) {
430
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
431
+ logger_1.logger.error("Non-retryable constraint violation in updateOneSystemAlert", {
432
+ operation: 'updateOneSystemAlert',
433
+ model: 'SystemAlert',
434
+ error: String(error),
435
+ recordId: props.id,
436
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
437
+ errorCategory: 'CONSTRAINT_VIOLATION',
438
+ isRetryable: false,
439
+ });
440
+ throw error;
441
+ }
358
442
  // Check if this is a database connection error that we should retry
359
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
360
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
361
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
362
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
363
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
443
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
444
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
445
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
446
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
447
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
364
448
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
365
449
  retryCount++;
366
450
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
367
- logger_1.logger.warn("Database connection error, retrying...");
451
+ logger_1.logger.warn("Database connection error in updateOneSystemAlert, retrying...", {
452
+ operation: 'updateOneSystemAlert',
453
+ model: 'SystemAlert',
454
+ attempt: retryCount,
455
+ maxRetries: MAX_RETRIES,
456
+ recordId: props.id,
457
+ });
368
458
  await new Promise(resolve => setTimeout(resolve, delay));
369
459
  continue;
370
460
  }
371
- // Log the error and rethrow
372
- logger_1.logger.error("Database error occurred", { error: String(error) });
461
+ // Log structured error details and rethrow
462
+ logger_1.logger.error("Database update operation failed", {
463
+ operation: 'updateOneSystemAlert',
464
+ model: 'SystemAlert',
465
+ error: String(error),
466
+ recordId: props.id,
467
+ isRetryable: isConnectionError,
468
+ });
373
469
  throw error;
374
470
  }
375
471
  }
@@ -384,7 +480,7 @@ exports.SystemAlert = {
384
480
  * @returns The updated SystemAlert or null.
385
481
  */
386
482
  async upsert(props, globalClient) {
387
- var _a, _b, _c, _d, _e;
483
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
388
484
  // Maximum number of retries for database connection issues
389
485
  const MAX_RETRIES = 3;
390
486
  let retryCount = 0;
@@ -518,21 +614,55 @@ exports.SystemAlert = {
518
614
  }
519
615
  catch (error) {
520
616
  lastError = error;
617
+ // Check for constraint violations FIRST - these are NEVER retryable
618
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
619
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
620
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
621
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
622
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
623
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
624
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
625
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
626
+ if (isConstraintViolation) {
627
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
628
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneSystemAlert", {
629
+ operation: 'upsertOneSystemAlert',
630
+ model: 'SystemAlert',
631
+ error: String(error),
632
+ recordId: props.id,
633
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
634
+ errorCategory: 'CONSTRAINT_VIOLATION',
635
+ isRetryable: false,
636
+ });
637
+ throw error;
638
+ }
521
639
  // Check if this is a database connection error that we should retry
522
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
523
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
524
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
525
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
526
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
640
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
641
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
642
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
643
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
644
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
527
645
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
528
646
  retryCount++;
529
647
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
530
- logger_1.logger.warn("Database connection error, retrying...");
648
+ logger_1.logger.warn("Database connection error in upsertOneSystemAlert, retrying...", {
649
+ operation: 'upsertOneSystemAlert',
650
+ model: 'SystemAlert',
651
+ attempt: retryCount,
652
+ maxRetries: MAX_RETRIES,
653
+ recordId: props.id,
654
+ });
531
655
  await new Promise(resolve => setTimeout(resolve, delay));
532
656
  continue;
533
657
  }
534
- // Log the error and rethrow
535
- logger_1.logger.error("Database error occurred", { error: String(error) });
658
+ // Log structured error details and rethrow
659
+ logger_1.logger.error("Database upsert operation failed", {
660
+ operation: 'upsertOneSystemAlert',
661
+ model: 'SystemAlert',
662
+ error: String(error),
663
+ recordId: props.id,
664
+ isRetryable: isConnectionError,
665
+ });
536
666
  throw error;
537
667
  }
538
668
  }
@@ -547,7 +677,7 @@ exports.SystemAlert = {
547
677
  * @returns The count of created records or null.
548
678
  */
549
679
  async updateMany(props, globalClient) {
550
- var _a, _b, _c, _d, _e;
680
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
551
681
  // Maximum number of retries for database connection issues
552
682
  const MAX_RETRIES = 3;
553
683
  let retryCount = 0;
@@ -668,21 +798,52 @@ exports.SystemAlert = {
668
798
  }
669
799
  catch (error) {
670
800
  lastError = error;
801
+ // Check for constraint violations FIRST - these are NEVER retryable
802
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
803
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
804
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
805
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
806
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
807
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
808
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
809
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
810
+ if (isConstraintViolation) {
811
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
812
+ logger_1.logger.error("Non-retryable constraint violation in updateManySystemAlert", {
813
+ operation: 'updateManySystemAlert',
814
+ model: 'SystemAlert',
815
+ error: String(error),
816
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
817
+ errorCategory: 'CONSTRAINT_VIOLATION',
818
+ isRetryable: false,
819
+ });
820
+ throw error;
821
+ }
671
822
  // Check if this is a database connection error that we should retry
672
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
673
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
674
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
675
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
676
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
823
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
824
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
825
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
826
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
827
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
677
828
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
678
829
  retryCount++;
679
830
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
680
- logger_1.logger.warn("Database connection error, retrying...");
831
+ logger_1.logger.warn("Database connection error in updateManySystemAlert, retrying...", {
832
+ operation: 'updateManySystemAlert',
833
+ model: 'SystemAlert',
834
+ attempt: retryCount,
835
+ maxRetries: MAX_RETRIES,
836
+ });
681
837
  await new Promise(resolve => setTimeout(resolve, delay));
682
838
  continue;
683
839
  }
684
- // Log the error and rethrow
685
- logger_1.logger.error("Database error occurred", { error: String(error) });
840
+ // Log structured error details and rethrow
841
+ logger_1.logger.error("Database updateMany operation failed", {
842
+ operation: 'updateManySystemAlert',
843
+ model: 'SystemAlert',
844
+ error: String(error),
845
+ isRetryable: isConnectionError,
846
+ });
686
847
  throw error;
687
848
  }
688
849
  }
@@ -697,7 +858,7 @@ exports.SystemAlert = {
697
858
  * @returns The deleted SystemAlert or null.
698
859
  */
699
860
  async delete(props, globalClient) {
700
- var _a, _b, _c, _d, _e;
861
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
701
862
  // Maximum number of retries for database connection issues
702
863
  const MAX_RETRIES = 3;
703
864
  let retryCount = 0;
@@ -741,21 +902,58 @@ exports.SystemAlert = {
741
902
  }
742
903
  catch (error) {
743
904
  lastError = error;
905
+ // Check for constraint violations FIRST - these are NEVER retryable
906
+ // (e.g., foreign key constraints preventing deletion)
907
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
908
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
909
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
910
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
911
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
912
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
913
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
914
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
915
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
916
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
917
+ if (isConstraintViolation) {
918
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
919
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneSystemAlert", {
920
+ operation: 'deleteOneSystemAlert',
921
+ model: 'SystemAlert',
922
+ error: String(error),
923
+ recordId: props.id,
924
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
925
+ errorCategory: 'CONSTRAINT_VIOLATION',
926
+ isRetryable: false,
927
+ });
928
+ throw error;
929
+ }
744
930
  // Check if this is a database connection error that we should retry
745
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
746
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
747
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
748
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
749
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
931
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
932
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
933
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
934
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
935
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
750
936
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
751
937
  retryCount++;
752
938
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
753
- logger_1.logger.warn("Database connection error, retrying...");
939
+ logger_1.logger.warn("Database connection error in deleteOneSystemAlert, retrying...", {
940
+ operation: 'deleteOneSystemAlert',
941
+ model: 'SystemAlert',
942
+ attempt: retryCount,
943
+ maxRetries: MAX_RETRIES,
944
+ recordId: props.id,
945
+ });
754
946
  await new Promise(resolve => setTimeout(resolve, delay));
755
947
  continue;
756
948
  }
757
- // Log the error and rethrow
758
- logger_1.logger.error("Database error occurred", { error: String(error) });
949
+ // Log structured error details and rethrow
950
+ logger_1.logger.error("Database delete operation failed", {
951
+ operation: 'deleteOneSystemAlert',
952
+ model: 'SystemAlert',
953
+ error: String(error),
954
+ recordId: props.id,
955
+ isRetryable: isConnectionError,
956
+ });
759
957
  throw error;
760
958
  }
761
959
  }
@@ -828,12 +1026,22 @@ exports.SystemAlert = {
828
1026
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
829
1027
  retryCount++;
830
1028
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
831
- logger_1.logger.warn("Database connection error, retrying...");
1029
+ logger_1.logger.warn("Database connection error in getSystemAlert, retrying...", {
1030
+ operation: 'getSystemAlert',
1031
+ model: 'SystemAlert',
1032
+ attempt: retryCount,
1033
+ maxRetries: MAX_RETRIES,
1034
+ });
832
1035
  await new Promise(resolve => setTimeout(resolve, delay));
833
1036
  continue;
834
1037
  }
835
- // Log the error and rethrow
836
- logger_1.logger.error("Database error occurred", { error: String(error) });
1038
+ // Log structured error details and rethrow
1039
+ logger_1.logger.error("Database get operation failed", {
1040
+ operation: 'getSystemAlert',
1041
+ model: 'SystemAlert',
1042
+ error: String(error),
1043
+ isRetryable: isConnectionError,
1044
+ });
837
1045
  throw error;
838
1046
  }
839
1047
  }
@@ -891,12 +1099,22 @@ exports.SystemAlert = {
891
1099
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
892
1100
  retryCount++;
893
1101
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
894
- logger_1.logger.warn("Database connection error, retrying...");
1102
+ logger_1.logger.warn("Database connection error in getAllSystemAlert, retrying...", {
1103
+ operation: 'getAllSystemAlert',
1104
+ model: 'SystemAlert',
1105
+ attempt: retryCount,
1106
+ maxRetries: MAX_RETRIES,
1107
+ });
895
1108
  await new Promise(resolve => setTimeout(resolve, delay));
896
1109
  continue;
897
1110
  }
898
- // Log the error and rethrow
899
- logger_1.logger.error("Database error occurred", { error: String(error) });
1111
+ // Log structured error details and rethrow
1112
+ logger_1.logger.error("Database getAll operation failed", {
1113
+ operation: 'getAllSystemAlert',
1114
+ model: 'SystemAlert',
1115
+ error: String(error),
1116
+ isRetryable: isConnectionError,
1117
+ });
900
1118
  throw error;
901
1119
  }
902
1120
  }
@@ -976,12 +1194,22 @@ exports.SystemAlert = {
976
1194
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
977
1195
  retryCount++;
978
1196
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
979
- logger_1.logger.warn("Database connection error, retrying...");
1197
+ logger_1.logger.warn("Database connection error in findManySystemAlert, retrying...", {
1198
+ operation: 'findManySystemAlert',
1199
+ model: 'SystemAlert',
1200
+ attempt: retryCount,
1201
+ maxRetries: MAX_RETRIES,
1202
+ });
980
1203
  await new Promise(resolve => setTimeout(resolve, delay));
981
1204
  continue;
982
1205
  }
983
- // Log the error and rethrow
984
- logger_1.logger.error("Database error occurred", { error: String(error) });
1206
+ // Log structured error details and rethrow
1207
+ logger_1.logger.error("Database findMany operation failed", {
1208
+ operation: 'findManySystemAlert',
1209
+ model: 'SystemAlert',
1210
+ error: String(error),
1211
+ isRetryable: isConnectionError,
1212
+ });
985
1213
  throw error;
986
1214
  }
987
1215
  }