@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
@@ -73,7 +73,7 @@ exports.InstitutionalSentimentHistory = {
73
73
  * @returns The created InstitutionalSentimentHistory or null.
74
74
  */
75
75
  async create(props, globalClient) {
76
- var _a, _b, _c, _d, _e;
76
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
77
77
  // Maximum number of retries for database connection issues
78
78
  const MAX_RETRIES = 3;
79
79
  let retryCount = 0;
@@ -161,21 +161,52 @@ exports.InstitutionalSentimentHistory = {
161
161
  }
162
162
  catch (error) {
163
163
  lastError = error;
164
+ // Check for constraint violations FIRST - these are NEVER retryable
165
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
166
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
167
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
168
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
169
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
170
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
171
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
172
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
173
+ if (isConstraintViolation) {
174
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
175
+ logger_1.logger.error("Non-retryable constraint violation in createOneInstitutionalSentimentHistory", {
176
+ operation: 'createOneInstitutionalSentimentHistory',
177
+ model: 'InstitutionalSentimentHistory',
178
+ error: String(error),
179
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
180
+ errorCategory: 'CONSTRAINT_VIOLATION',
181
+ isRetryable: false,
182
+ });
183
+ throw error;
184
+ }
164
185
  // Check if this is a database connection error that we should retry
165
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
166
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
167
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
168
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
169
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
186
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
187
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
188
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
189
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
190
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
170
191
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
171
192
  retryCount++;
172
193
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
173
- logger_1.logger.warn("Database connection error, retrying...");
194
+ logger_1.logger.warn("Database connection error in createOneInstitutionalSentimentHistory, retrying...", {
195
+ operation: 'createOneInstitutionalSentimentHistory',
196
+ model: 'InstitutionalSentimentHistory',
197
+ attempt: retryCount,
198
+ maxRetries: MAX_RETRIES,
199
+ });
174
200
  await new Promise(resolve => setTimeout(resolve, delay));
175
201
  continue;
176
202
  }
177
- // Log the error and rethrow
178
- logger_1.logger.error("Database error occurred", { error: String(error) });
203
+ // Log structured error details and rethrow
204
+ logger_1.logger.error("Database create operation failed", {
205
+ operation: 'createOneInstitutionalSentimentHistory',
206
+ model: 'InstitutionalSentimentHistory',
207
+ error: String(error),
208
+ isRetryable: isConnectionError,
209
+ });
179
210
  throw error;
180
211
  }
181
212
  }
@@ -190,7 +221,7 @@ exports.InstitutionalSentimentHistory = {
190
221
  * @returns The count of created records or null.
191
222
  */
192
223
  async createMany(props, globalClient) {
193
- var _a, _b, _c, _d, _e;
224
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
194
225
  // Maximum number of retries for database connection issues
195
226
  const MAX_RETRIES = 3;
196
227
  let retryCount = 0;
@@ -277,21 +308,52 @@ exports.InstitutionalSentimentHistory = {
277
308
  }
278
309
  catch (error) {
279
310
  lastError = error;
311
+ // Check for constraint violations FIRST - these are NEVER retryable
312
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
313
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
314
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
315
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
316
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
317
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
318
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
319
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
320
+ if (isConstraintViolation) {
321
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
322
+ logger_1.logger.error("Non-retryable constraint violation in createManyInstitutionalSentimentHistory", {
323
+ operation: 'createManyInstitutionalSentimentHistory',
324
+ model: 'InstitutionalSentimentHistory',
325
+ error: String(error),
326
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
327
+ errorCategory: 'CONSTRAINT_VIOLATION',
328
+ isRetryable: false,
329
+ });
330
+ throw error;
331
+ }
280
332
  // Check if this is a database connection error that we should retry
281
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
282
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
283
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
284
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
285
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
333
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
334
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
335
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
336
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
337
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
286
338
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
287
339
  retryCount++;
288
340
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
289
- logger_1.logger.warn("Database connection error, retrying...");
341
+ logger_1.logger.warn("Database connection error in createManyInstitutionalSentimentHistory, retrying...", {
342
+ operation: 'createManyInstitutionalSentimentHistory',
343
+ model: 'InstitutionalSentimentHistory',
344
+ attempt: retryCount,
345
+ maxRetries: MAX_RETRIES,
346
+ });
290
347
  await new Promise(resolve => setTimeout(resolve, delay));
291
348
  continue;
292
349
  }
293
- // Log the error and rethrow
294
- logger_1.logger.error("Database error occurred", { error: String(error) });
350
+ // Log structured error details and rethrow
351
+ logger_1.logger.error("Database createMany operation failed", {
352
+ operation: 'createManyInstitutionalSentimentHistory',
353
+ model: 'InstitutionalSentimentHistory',
354
+ error: String(error),
355
+ isRetryable: isConnectionError,
356
+ });
295
357
  throw error;
296
358
  }
297
359
  }
@@ -306,7 +368,7 @@ exports.InstitutionalSentimentHistory = {
306
368
  * @returns The updated InstitutionalSentimentHistory or null.
307
369
  */
308
370
  async update(props, globalClient) {
309
- var _a, _b, _c, _d, _e;
371
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
310
372
  // Maximum number of retries for database connection issues
311
373
  const MAX_RETRIES = 3;
312
374
  let retryCount = 0;
@@ -496,21 +558,55 @@ exports.InstitutionalSentimentHistory = {
496
558
  }
497
559
  catch (error) {
498
560
  lastError = error;
561
+ // Check for constraint violations FIRST - these are NEVER retryable
562
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
563
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
564
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
565
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
566
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
567
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
568
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
569
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
570
+ if (isConstraintViolation) {
571
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
572
+ logger_1.logger.error("Non-retryable constraint violation in updateOneInstitutionalSentimentHistory", {
573
+ operation: 'updateOneInstitutionalSentimentHistory',
574
+ model: 'InstitutionalSentimentHistory',
575
+ error: String(error),
576
+ recordId: props.id,
577
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
578
+ errorCategory: 'CONSTRAINT_VIOLATION',
579
+ isRetryable: false,
580
+ });
581
+ throw error;
582
+ }
499
583
  // Check if this is a database connection error that we should retry
500
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
501
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
502
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
503
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
504
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
584
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
585
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
586
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
587
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
588
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
505
589
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
506
590
  retryCount++;
507
591
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
508
- logger_1.logger.warn("Database connection error, retrying...");
592
+ logger_1.logger.warn("Database connection error in updateOneInstitutionalSentimentHistory, retrying...", {
593
+ operation: 'updateOneInstitutionalSentimentHistory',
594
+ model: 'InstitutionalSentimentHistory',
595
+ attempt: retryCount,
596
+ maxRetries: MAX_RETRIES,
597
+ recordId: props.id,
598
+ });
509
599
  await new Promise(resolve => setTimeout(resolve, delay));
510
600
  continue;
511
601
  }
512
- // Log the error and rethrow
513
- logger_1.logger.error("Database error occurred", { error: String(error) });
602
+ // Log structured error details and rethrow
603
+ logger_1.logger.error("Database update operation failed", {
604
+ operation: 'updateOneInstitutionalSentimentHistory',
605
+ model: 'InstitutionalSentimentHistory',
606
+ error: String(error),
607
+ recordId: props.id,
608
+ isRetryable: isConnectionError,
609
+ });
514
610
  throw error;
515
611
  }
516
612
  }
@@ -525,7 +621,7 @@ exports.InstitutionalSentimentHistory = {
525
621
  * @returns The updated InstitutionalSentimentHistory or null.
526
622
  */
527
623
  async upsert(props, globalClient) {
528
- var _a, _b, _c, _d, _e;
624
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
529
625
  // Maximum number of retries for database connection issues
530
626
  const MAX_RETRIES = 3;
531
627
  let retryCount = 0;
@@ -752,21 +848,55 @@ exports.InstitutionalSentimentHistory = {
752
848
  }
753
849
  catch (error) {
754
850
  lastError = error;
851
+ // Check for constraint violations FIRST - these are NEVER retryable
852
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
853
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
854
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
855
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
856
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
857
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
858
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
859
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
860
+ if (isConstraintViolation) {
861
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
862
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneInstitutionalSentimentHistory", {
863
+ operation: 'upsertOneInstitutionalSentimentHistory',
864
+ model: 'InstitutionalSentimentHistory',
865
+ error: String(error),
866
+ recordId: props.id,
867
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
868
+ errorCategory: 'CONSTRAINT_VIOLATION',
869
+ isRetryable: false,
870
+ });
871
+ throw error;
872
+ }
755
873
  // Check if this is a database connection error that we should retry
756
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
757
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
758
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
759
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
760
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
874
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
875
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
876
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
877
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
878
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
761
879
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
762
880
  retryCount++;
763
881
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
764
- logger_1.logger.warn("Database connection error, retrying...");
882
+ logger_1.logger.warn("Database connection error in upsertOneInstitutionalSentimentHistory, retrying...", {
883
+ operation: 'upsertOneInstitutionalSentimentHistory',
884
+ model: 'InstitutionalSentimentHistory',
885
+ attempt: retryCount,
886
+ maxRetries: MAX_RETRIES,
887
+ recordId: props.id,
888
+ });
765
889
  await new Promise(resolve => setTimeout(resolve, delay));
766
890
  continue;
767
891
  }
768
- // Log the error and rethrow
769
- logger_1.logger.error("Database error occurred", { error: String(error) });
892
+ // Log structured error details and rethrow
893
+ logger_1.logger.error("Database upsert operation failed", {
894
+ operation: 'upsertOneInstitutionalSentimentHistory',
895
+ model: 'InstitutionalSentimentHistory',
896
+ error: String(error),
897
+ recordId: props.id,
898
+ isRetryable: isConnectionError,
899
+ });
770
900
  throw error;
771
901
  }
772
902
  }
@@ -781,7 +911,7 @@ exports.InstitutionalSentimentHistory = {
781
911
  * @returns The count of created records or null.
782
912
  */
783
913
  async updateMany(props, globalClient) {
784
- var _a, _b, _c, _d, _e;
914
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
785
915
  // Maximum number of retries for database connection issues
786
916
  const MAX_RETRIES = 3;
787
917
  let retryCount = 0;
@@ -971,21 +1101,52 @@ exports.InstitutionalSentimentHistory = {
971
1101
  }
972
1102
  catch (error) {
973
1103
  lastError = error;
1104
+ // Check for constraint violations FIRST - these are NEVER retryable
1105
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
1106
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
1107
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
1108
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
1109
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
1110
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
1111
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
1112
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
1113
+ if (isConstraintViolation) {
1114
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
1115
+ logger_1.logger.error("Non-retryable constraint violation in updateManyInstitutionalSentimentHistory", {
1116
+ operation: 'updateManyInstitutionalSentimentHistory',
1117
+ model: 'InstitutionalSentimentHistory',
1118
+ error: String(error),
1119
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1120
+ errorCategory: 'CONSTRAINT_VIOLATION',
1121
+ isRetryable: false,
1122
+ });
1123
+ throw error;
1124
+ }
974
1125
  // Check if this is a database connection error that we should retry
975
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
976
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
977
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
978
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
979
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
1126
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
1127
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
1128
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
1129
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
1130
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
980
1131
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
981
1132
  retryCount++;
982
1133
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
983
- logger_1.logger.warn("Database connection error, retrying...");
1134
+ logger_1.logger.warn("Database connection error in updateManyInstitutionalSentimentHistory, retrying...", {
1135
+ operation: 'updateManyInstitutionalSentimentHistory',
1136
+ model: 'InstitutionalSentimentHistory',
1137
+ attempt: retryCount,
1138
+ maxRetries: MAX_RETRIES,
1139
+ });
984
1140
  await new Promise(resolve => setTimeout(resolve, delay));
985
1141
  continue;
986
1142
  }
987
- // Log the error and rethrow
988
- logger_1.logger.error("Database error occurred", { error: String(error) });
1143
+ // Log structured error details and rethrow
1144
+ logger_1.logger.error("Database updateMany operation failed", {
1145
+ operation: 'updateManyInstitutionalSentimentHistory',
1146
+ model: 'InstitutionalSentimentHistory',
1147
+ error: String(error),
1148
+ isRetryable: isConnectionError,
1149
+ });
989
1150
  throw error;
990
1151
  }
991
1152
  }
@@ -1000,7 +1161,7 @@ exports.InstitutionalSentimentHistory = {
1000
1161
  * @returns The deleted InstitutionalSentimentHistory or null.
1001
1162
  */
1002
1163
  async delete(props, globalClient) {
1003
- var _a, _b, _c, _d, _e;
1164
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
1004
1165
  // Maximum number of retries for database connection issues
1005
1166
  const MAX_RETRIES = 3;
1006
1167
  let retryCount = 0;
@@ -1044,21 +1205,58 @@ exports.InstitutionalSentimentHistory = {
1044
1205
  }
1045
1206
  catch (error) {
1046
1207
  lastError = error;
1208
+ // Check for constraint violations FIRST - these are NEVER retryable
1209
+ // (e.g., foreign key constraints preventing deletion)
1210
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
1211
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
1212
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
1213
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
1214
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
1215
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
1216
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
1217
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
1218
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
1219
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
1220
+ if (isConstraintViolation) {
1221
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
1222
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneInstitutionalSentimentHistory", {
1223
+ operation: 'deleteOneInstitutionalSentimentHistory',
1224
+ model: 'InstitutionalSentimentHistory',
1225
+ error: String(error),
1226
+ recordId: props.id,
1227
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1228
+ errorCategory: 'CONSTRAINT_VIOLATION',
1229
+ isRetryable: false,
1230
+ });
1231
+ throw error;
1232
+ }
1047
1233
  // Check if this is a database connection error that we should retry
1048
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
1049
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
1050
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
1051
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
1052
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
1234
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
1235
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
1236
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
1237
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
1238
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
1053
1239
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1054
1240
  retryCount++;
1055
1241
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1056
- logger_1.logger.warn("Database connection error, retrying...");
1242
+ logger_1.logger.warn("Database connection error in deleteOneInstitutionalSentimentHistory, retrying...", {
1243
+ operation: 'deleteOneInstitutionalSentimentHistory',
1244
+ model: 'InstitutionalSentimentHistory',
1245
+ attempt: retryCount,
1246
+ maxRetries: MAX_RETRIES,
1247
+ recordId: props.id,
1248
+ });
1057
1249
  await new Promise(resolve => setTimeout(resolve, delay));
1058
1250
  continue;
1059
1251
  }
1060
- // Log the error and rethrow
1061
- logger_1.logger.error("Database error occurred", { error: String(error) });
1252
+ // Log structured error details and rethrow
1253
+ logger_1.logger.error("Database delete operation failed", {
1254
+ operation: 'deleteOneInstitutionalSentimentHistory',
1255
+ model: 'InstitutionalSentimentHistory',
1256
+ error: String(error),
1257
+ recordId: props.id,
1258
+ isRetryable: isConnectionError,
1259
+ });
1062
1260
  throw error;
1063
1261
  }
1064
1262
  }
@@ -1128,12 +1326,22 @@ exports.InstitutionalSentimentHistory = {
1128
1326
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1129
1327
  retryCount++;
1130
1328
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1131
- logger_1.logger.warn("Database connection error, retrying...");
1329
+ logger_1.logger.warn("Database connection error in getInstitutionalSentimentHistory, retrying...", {
1330
+ operation: 'getInstitutionalSentimentHistory',
1331
+ model: 'InstitutionalSentimentHistory',
1332
+ attempt: retryCount,
1333
+ maxRetries: MAX_RETRIES,
1334
+ });
1132
1335
  await new Promise(resolve => setTimeout(resolve, delay));
1133
1336
  continue;
1134
1337
  }
1135
- // Log the error and rethrow
1136
- logger_1.logger.error("Database error occurred", { error: String(error) });
1338
+ // Log structured error details and rethrow
1339
+ logger_1.logger.error("Database get operation failed", {
1340
+ operation: 'getInstitutionalSentimentHistory',
1341
+ model: 'InstitutionalSentimentHistory',
1342
+ error: String(error),
1343
+ isRetryable: isConnectionError,
1344
+ });
1137
1345
  throw error;
1138
1346
  }
1139
1347
  }
@@ -1191,12 +1399,22 @@ exports.InstitutionalSentimentHistory = {
1191
1399
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1192
1400
  retryCount++;
1193
1401
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1194
- logger_1.logger.warn("Database connection error, retrying...");
1402
+ logger_1.logger.warn("Database connection error in getAllInstitutionalSentimentHistory, retrying...", {
1403
+ operation: 'getAllInstitutionalSentimentHistory',
1404
+ model: 'InstitutionalSentimentHistory',
1405
+ attempt: retryCount,
1406
+ maxRetries: MAX_RETRIES,
1407
+ });
1195
1408
  await new Promise(resolve => setTimeout(resolve, delay));
1196
1409
  continue;
1197
1410
  }
1198
- // Log the error and rethrow
1199
- logger_1.logger.error("Database error occurred", { error: String(error) });
1411
+ // Log structured error details and rethrow
1412
+ logger_1.logger.error("Database getAll operation failed", {
1413
+ operation: 'getAllInstitutionalSentimentHistory',
1414
+ model: 'InstitutionalSentimentHistory',
1415
+ error: String(error),
1416
+ isRetryable: isConnectionError,
1417
+ });
1200
1418
  throw error;
1201
1419
  }
1202
1420
  }
@@ -1273,12 +1491,22 @@ exports.InstitutionalSentimentHistory = {
1273
1491
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1274
1492
  retryCount++;
1275
1493
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1276
- logger_1.logger.warn("Database connection error, retrying...");
1494
+ logger_1.logger.warn("Database connection error in findManyInstitutionalSentimentHistory, retrying...", {
1495
+ operation: 'findManyInstitutionalSentimentHistory',
1496
+ model: 'InstitutionalSentimentHistory',
1497
+ attempt: retryCount,
1498
+ maxRetries: MAX_RETRIES,
1499
+ });
1277
1500
  await new Promise(resolve => setTimeout(resolve, delay));
1278
1501
  continue;
1279
1502
  }
1280
- // Log the error and rethrow
1281
- logger_1.logger.error("Database error occurred", { error: String(error) });
1503
+ // Log structured error details and rethrow
1504
+ logger_1.logger.error("Database findMany operation failed", {
1505
+ operation: 'findManyInstitutionalSentimentHistory',
1506
+ model: 'InstitutionalSentimentHistory',
1507
+ error: String(error),
1508
+ isRetryable: isConnectionError,
1509
+ });
1282
1510
  throw error;
1283
1511
  }
1284
1512
  }