@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/Event.cjs CHANGED
@@ -51,7 +51,7 @@ exports.Event = {
51
51
  * @returns The created Event or null.
52
52
  */
53
53
  async create(props, globalClient) {
54
- var _a, _b, _c, _d, _e;
54
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
55
55
  // Maximum number of retries for database connection issues
56
56
  const MAX_RETRIES = 3;
57
57
  let retryCount = 0;
@@ -117,21 +117,52 @@ exports.Event = {
117
117
  }
118
118
  catch (error) {
119
119
  lastError = error;
120
+ // Check for constraint violations FIRST - these are NEVER retryable
121
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
122
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
123
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
124
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
125
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
126
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
127
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
128
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
129
+ if (isConstraintViolation) {
130
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
131
+ logger_1.logger.error("Non-retryable constraint violation in createOneEvent", {
132
+ operation: 'createOneEvent',
133
+ model: 'Event',
134
+ error: String(error),
135
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
136
+ errorCategory: 'CONSTRAINT_VIOLATION',
137
+ isRetryable: false,
138
+ });
139
+ throw error;
140
+ }
120
141
  // Check if this is a database connection error that we should retry
121
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
122
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
123
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
124
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
125
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
142
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
143
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
144
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
145
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
146
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
126
147
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
127
148
  retryCount++;
128
149
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
129
- logger_1.logger.warn("Database connection error, retrying...");
150
+ logger_1.logger.warn("Database connection error in createOneEvent, retrying...", {
151
+ operation: 'createOneEvent',
152
+ model: 'Event',
153
+ attempt: retryCount,
154
+ maxRetries: MAX_RETRIES,
155
+ });
130
156
  await new Promise(resolve => setTimeout(resolve, delay));
131
157
  continue;
132
158
  }
133
- // Log the error and rethrow
134
- logger_1.logger.error("Database error occurred", { error: String(error) });
159
+ // Log structured error details and rethrow
160
+ logger_1.logger.error("Database create operation failed", {
161
+ operation: 'createOneEvent',
162
+ model: 'Event',
163
+ error: String(error),
164
+ isRetryable: isConnectionError,
165
+ });
135
166
  throw error;
136
167
  }
137
168
  }
@@ -146,7 +177,7 @@ exports.Event = {
146
177
  * @returns The count of created records or null.
147
178
  */
148
179
  async createMany(props, globalClient) {
149
- var _a, _b, _c, _d, _e;
180
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
150
181
  // Maximum number of retries for database connection issues
151
182
  const MAX_RETRIES = 3;
152
183
  let retryCount = 0;
@@ -211,21 +242,52 @@ exports.Event = {
211
242
  }
212
243
  catch (error) {
213
244
  lastError = error;
245
+ // Check for constraint violations FIRST - these are NEVER retryable
246
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
247
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
248
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
249
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
250
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
251
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
252
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
253
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
254
+ if (isConstraintViolation) {
255
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
256
+ logger_1.logger.error("Non-retryable constraint violation in createManyEvent", {
257
+ operation: 'createManyEvent',
258
+ model: 'Event',
259
+ error: String(error),
260
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
261
+ errorCategory: 'CONSTRAINT_VIOLATION',
262
+ isRetryable: false,
263
+ });
264
+ throw error;
265
+ }
214
266
  // Check if this is a database connection error that we should retry
215
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
216
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
217
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
218
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
219
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
267
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
268
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
269
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
270
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
271
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
220
272
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
221
273
  retryCount++;
222
274
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
223
- logger_1.logger.warn("Database connection error, retrying...");
275
+ logger_1.logger.warn("Database connection error in createManyEvent, retrying...", {
276
+ operation: 'createManyEvent',
277
+ model: 'Event',
278
+ attempt: retryCount,
279
+ maxRetries: MAX_RETRIES,
280
+ });
224
281
  await new Promise(resolve => setTimeout(resolve, delay));
225
282
  continue;
226
283
  }
227
- // Log the error and rethrow
228
- logger_1.logger.error("Database error occurred", { error: String(error) });
284
+ // Log structured error details and rethrow
285
+ logger_1.logger.error("Database createMany operation failed", {
286
+ operation: 'createManyEvent',
287
+ model: 'Event',
288
+ error: String(error),
289
+ isRetryable: isConnectionError,
290
+ });
229
291
  throw error;
230
292
  }
231
293
  }
@@ -240,7 +302,7 @@ exports.Event = {
240
302
  * @returns The updated Event or null.
241
303
  */
242
304
  async update(props, globalClient) {
243
- var _a, _b, _c, _d, _e;
305
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
244
306
  // Maximum number of retries for database connection issues
245
307
  const MAX_RETRIES = 3;
246
308
  let retryCount = 0;
@@ -386,21 +448,55 @@ exports.Event = {
386
448
  }
387
449
  catch (error) {
388
450
  lastError = error;
451
+ // Check for constraint violations FIRST - these are NEVER retryable
452
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
453
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
454
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
455
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
456
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
457
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
458
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
459
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
460
+ if (isConstraintViolation) {
461
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
462
+ logger_1.logger.error("Non-retryable constraint violation in updateOneEvent", {
463
+ operation: 'updateOneEvent',
464
+ model: 'Event',
465
+ error: String(error),
466
+ recordId: props.id,
467
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
468
+ errorCategory: 'CONSTRAINT_VIOLATION',
469
+ isRetryable: false,
470
+ });
471
+ throw error;
472
+ }
389
473
  // Check if this is a database connection error that we should retry
390
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
391
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
392
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
393
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
394
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
474
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
475
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
476
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
477
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
478
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
395
479
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
396
480
  retryCount++;
397
481
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
398
- logger_1.logger.warn("Database connection error, retrying...");
482
+ logger_1.logger.warn("Database connection error in updateOneEvent, retrying...", {
483
+ operation: 'updateOneEvent',
484
+ model: 'Event',
485
+ attempt: retryCount,
486
+ maxRetries: MAX_RETRIES,
487
+ recordId: props.id,
488
+ });
399
489
  await new Promise(resolve => setTimeout(resolve, delay));
400
490
  continue;
401
491
  }
402
- // Log the error and rethrow
403
- logger_1.logger.error("Database error occurred", { error: String(error) });
492
+ // Log structured error details and rethrow
493
+ logger_1.logger.error("Database update operation failed", {
494
+ operation: 'updateOneEvent',
495
+ model: 'Event',
496
+ error: String(error),
497
+ recordId: props.id,
498
+ isRetryable: isConnectionError,
499
+ });
404
500
  throw error;
405
501
  }
406
502
  }
@@ -415,7 +511,7 @@ exports.Event = {
415
511
  * @returns The updated Event or null.
416
512
  */
417
513
  async upsert(props, globalClient) {
418
- var _a, _b, _c, _d, _e;
514
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
419
515
  // Maximum number of retries for database connection issues
420
516
  const MAX_RETRIES = 3;
421
517
  let retryCount = 0;
@@ -576,21 +672,55 @@ exports.Event = {
576
672
  }
577
673
  catch (error) {
578
674
  lastError = error;
675
+ // Check for constraint violations FIRST - these are NEVER retryable
676
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
677
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
678
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
679
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
680
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
681
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
682
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
683
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
684
+ if (isConstraintViolation) {
685
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
686
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneEvent", {
687
+ operation: 'upsertOneEvent',
688
+ model: 'Event',
689
+ error: String(error),
690
+ recordId: props.id,
691
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
692
+ errorCategory: 'CONSTRAINT_VIOLATION',
693
+ isRetryable: false,
694
+ });
695
+ throw error;
696
+ }
579
697
  // Check if this is a database connection error that we should retry
580
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
581
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
582
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
583
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
584
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
698
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
699
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
700
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
701
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
702
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
585
703
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
586
704
  retryCount++;
587
705
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
588
- logger_1.logger.warn("Database connection error, retrying...");
706
+ logger_1.logger.warn("Database connection error in upsertOneEvent, retrying...", {
707
+ operation: 'upsertOneEvent',
708
+ model: 'Event',
709
+ attempt: retryCount,
710
+ maxRetries: MAX_RETRIES,
711
+ recordId: props.id,
712
+ });
589
713
  await new Promise(resolve => setTimeout(resolve, delay));
590
714
  continue;
591
715
  }
592
- // Log the error and rethrow
593
- logger_1.logger.error("Database error occurred", { error: String(error) });
716
+ // Log structured error details and rethrow
717
+ logger_1.logger.error("Database upsert operation failed", {
718
+ operation: 'upsertOneEvent',
719
+ model: 'Event',
720
+ error: String(error),
721
+ recordId: props.id,
722
+ isRetryable: isConnectionError,
723
+ });
594
724
  throw error;
595
725
  }
596
726
  }
@@ -605,7 +735,7 @@ exports.Event = {
605
735
  * @returns The count of created records or null.
606
736
  */
607
737
  async updateMany(props, globalClient) {
608
- var _a, _b, _c, _d, _e;
738
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
609
739
  // Maximum number of retries for database connection issues
610
740
  const MAX_RETRIES = 3;
611
741
  let retryCount = 0;
@@ -751,21 +881,52 @@ exports.Event = {
751
881
  }
752
882
  catch (error) {
753
883
  lastError = error;
884
+ // Check for constraint violations FIRST - these are NEVER retryable
885
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
886
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
887
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
888
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
889
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
890
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
891
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
892
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
893
+ if (isConstraintViolation) {
894
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
895
+ logger_1.logger.error("Non-retryable constraint violation in updateManyEvent", {
896
+ operation: 'updateManyEvent',
897
+ model: 'Event',
898
+ error: String(error),
899
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
900
+ errorCategory: 'CONSTRAINT_VIOLATION',
901
+ isRetryable: false,
902
+ });
903
+ throw error;
904
+ }
754
905
  // Check if this is a database connection error that we should retry
755
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
756
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
757
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
758
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
759
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
906
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
907
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
908
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
909
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
910
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
760
911
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
761
912
  retryCount++;
762
913
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
763
- logger_1.logger.warn("Database connection error, retrying...");
914
+ logger_1.logger.warn("Database connection error in updateManyEvent, retrying...", {
915
+ operation: 'updateManyEvent',
916
+ model: 'Event',
917
+ attempt: retryCount,
918
+ maxRetries: MAX_RETRIES,
919
+ });
764
920
  await new Promise(resolve => setTimeout(resolve, delay));
765
921
  continue;
766
922
  }
767
- // Log the error and rethrow
768
- logger_1.logger.error("Database error occurred", { error: String(error) });
923
+ // Log structured error details and rethrow
924
+ logger_1.logger.error("Database updateMany operation failed", {
925
+ operation: 'updateManyEvent',
926
+ model: 'Event',
927
+ error: String(error),
928
+ isRetryable: isConnectionError,
929
+ });
769
930
  throw error;
770
931
  }
771
932
  }
@@ -780,7 +941,7 @@ exports.Event = {
780
941
  * @returns The deleted Event or null.
781
942
  */
782
943
  async delete(props, globalClient) {
783
- var _a, _b, _c, _d, _e;
944
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
784
945
  // Maximum number of retries for database connection issues
785
946
  const MAX_RETRIES = 3;
786
947
  let retryCount = 0;
@@ -824,21 +985,58 @@ exports.Event = {
824
985
  }
825
986
  catch (error) {
826
987
  lastError = error;
988
+ // Check for constraint violations FIRST - these are NEVER retryable
989
+ // (e.g., foreign key constraints preventing deletion)
990
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
991
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
992
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
993
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
994
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
995
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
996
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
997
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
998
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
999
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
1000
+ if (isConstraintViolation) {
1001
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
1002
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneEvent", {
1003
+ operation: 'deleteOneEvent',
1004
+ model: 'Event',
1005
+ error: String(error),
1006
+ recordId: props.id,
1007
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1008
+ errorCategory: 'CONSTRAINT_VIOLATION',
1009
+ isRetryable: false,
1010
+ });
1011
+ throw error;
1012
+ }
827
1013
  // Check if this is a database connection error that we should retry
828
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
829
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
830
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
831
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
832
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
1014
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
1015
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
1016
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
1017
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
1018
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
833
1019
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
834
1020
  retryCount++;
835
1021
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
836
- logger_1.logger.warn("Database connection error, retrying...");
1022
+ logger_1.logger.warn("Database connection error in deleteOneEvent, retrying...", {
1023
+ operation: 'deleteOneEvent',
1024
+ model: 'Event',
1025
+ attempt: retryCount,
1026
+ maxRetries: MAX_RETRIES,
1027
+ recordId: props.id,
1028
+ });
837
1029
  await new Promise(resolve => setTimeout(resolve, delay));
838
1030
  continue;
839
1031
  }
840
- // Log the error and rethrow
841
- logger_1.logger.error("Database error occurred", { error: String(error) });
1032
+ // Log structured error details and rethrow
1033
+ logger_1.logger.error("Database delete operation failed", {
1034
+ operation: 'deleteOneEvent',
1035
+ model: 'Event',
1036
+ error: String(error),
1037
+ recordId: props.id,
1038
+ isRetryable: isConnectionError,
1039
+ });
842
1040
  throw error;
843
1041
  }
844
1042
  }
@@ -930,12 +1128,22 @@ exports.Event = {
930
1128
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
931
1129
  retryCount++;
932
1130
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
933
- logger_1.logger.warn("Database connection error, retrying...");
1131
+ logger_1.logger.warn("Database connection error in getEvent, retrying...", {
1132
+ operation: 'getEvent',
1133
+ model: 'Event',
1134
+ attempt: retryCount,
1135
+ maxRetries: MAX_RETRIES,
1136
+ });
934
1137
  await new Promise(resolve => setTimeout(resolve, delay));
935
1138
  continue;
936
1139
  }
937
- // Log the error and rethrow
938
- logger_1.logger.error("Database error occurred", { error: String(error) });
1140
+ // Log structured error details and rethrow
1141
+ logger_1.logger.error("Database get operation failed", {
1142
+ operation: 'getEvent',
1143
+ model: 'Event',
1144
+ error: String(error),
1145
+ isRetryable: isConnectionError,
1146
+ });
939
1147
  throw error;
940
1148
  }
941
1149
  }
@@ -993,12 +1201,22 @@ exports.Event = {
993
1201
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
994
1202
  retryCount++;
995
1203
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
996
- logger_1.logger.warn("Database connection error, retrying...");
1204
+ logger_1.logger.warn("Database connection error in getAllEvent, retrying...", {
1205
+ operation: 'getAllEvent',
1206
+ model: 'Event',
1207
+ attempt: retryCount,
1208
+ maxRetries: MAX_RETRIES,
1209
+ });
997
1210
  await new Promise(resolve => setTimeout(resolve, delay));
998
1211
  continue;
999
1212
  }
1000
- // Log the error and rethrow
1001
- logger_1.logger.error("Database error occurred", { error: String(error) });
1213
+ // Log structured error details and rethrow
1214
+ logger_1.logger.error("Database getAll operation failed", {
1215
+ operation: 'getAllEvent',
1216
+ model: 'Event',
1217
+ error: String(error),
1218
+ isRetryable: isConnectionError,
1219
+ });
1002
1220
  throw error;
1003
1221
  }
1004
1222
  }
@@ -1099,12 +1317,22 @@ exports.Event = {
1099
1317
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1100
1318
  retryCount++;
1101
1319
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1102
- logger_1.logger.warn("Database connection error, retrying...");
1320
+ logger_1.logger.warn("Database connection error in findManyEvent, retrying...", {
1321
+ operation: 'findManyEvent',
1322
+ model: 'Event',
1323
+ attempt: retryCount,
1324
+ maxRetries: MAX_RETRIES,
1325
+ });
1103
1326
  await new Promise(resolve => setTimeout(resolve, delay));
1104
1327
  continue;
1105
1328
  }
1106
- // Log the error and rethrow
1107
- logger_1.logger.error("Database error occurred", { error: String(error) });
1329
+ // Log structured error details and rethrow
1330
+ logger_1.logger.error("Database findMany operation failed", {
1331
+ operation: 'findManyEvent',
1332
+ model: 'Event',
1333
+ error: String(error),
1334
+ isRetryable: isConnectionError,
1335
+ });
1108
1336
  throw error;
1109
1337
  }
1110
1338
  }