@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
@@ -113,7 +113,7 @@ exports.InstitutionalFlowSignal = {
113
113
  * @returns The created InstitutionalFlowSignal or null.
114
114
  */
115
115
  async create(props, globalClient) {
116
- var _a, _b, _c, _d, _e;
116
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
117
117
  // Maximum number of retries for database connection issues
118
118
  const MAX_RETRIES = 3;
119
119
  let retryCount = 0;
@@ -309,21 +309,52 @@ exports.InstitutionalFlowSignal = {
309
309
  }
310
310
  catch (error) {
311
311
  lastError = error;
312
+ // Check for constraint violations FIRST - these are NEVER retryable
313
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
314
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
315
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
316
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
317
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
318
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
319
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
320
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
321
+ if (isConstraintViolation) {
322
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
323
+ logger_1.logger.error("Non-retryable constraint violation in createOneInstitutionalFlowSignal", {
324
+ operation: 'createOneInstitutionalFlowSignal',
325
+ model: 'InstitutionalFlowSignal',
326
+ error: String(error),
327
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
328
+ errorCategory: 'CONSTRAINT_VIOLATION',
329
+ isRetryable: false,
330
+ });
331
+ throw error;
332
+ }
312
333
  // Check if this is a database connection error that we should retry
313
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
314
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
315
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
316
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
317
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
334
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
335
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
336
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
337
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
338
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
318
339
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
319
340
  retryCount++;
320
341
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
321
- logger_1.logger.warn("Database connection error, retrying...");
342
+ logger_1.logger.warn("Database connection error in createOneInstitutionalFlowSignal, retrying...", {
343
+ operation: 'createOneInstitutionalFlowSignal',
344
+ model: 'InstitutionalFlowSignal',
345
+ attempt: retryCount,
346
+ maxRetries: MAX_RETRIES,
347
+ });
322
348
  await new Promise(resolve => setTimeout(resolve, delay));
323
349
  continue;
324
350
  }
325
- // Log the error and rethrow
326
- logger_1.logger.error("Database error occurred", { error: String(error) });
351
+ // Log structured error details and rethrow
352
+ logger_1.logger.error("Database create operation failed", {
353
+ operation: 'createOneInstitutionalFlowSignal',
354
+ model: 'InstitutionalFlowSignal',
355
+ error: String(error),
356
+ isRetryable: isConnectionError,
357
+ });
327
358
  throw error;
328
359
  }
329
360
  }
@@ -338,7 +369,7 @@ exports.InstitutionalFlowSignal = {
338
369
  * @returns The count of created records or null.
339
370
  */
340
371
  async createMany(props, globalClient) {
341
- var _a, _b, _c, _d, _e;
372
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
342
373
  // Maximum number of retries for database connection issues
343
374
  const MAX_RETRIES = 3;
344
375
  let retryCount = 0;
@@ -385,21 +416,52 @@ exports.InstitutionalFlowSignal = {
385
416
  }
386
417
  catch (error) {
387
418
  lastError = error;
419
+ // Check for constraint violations FIRST - these are NEVER retryable
420
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
421
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
422
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
423
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
424
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
425
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
426
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
427
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
428
+ if (isConstraintViolation) {
429
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
430
+ logger_1.logger.error("Non-retryable constraint violation in createManyInstitutionalFlowSignal", {
431
+ operation: 'createManyInstitutionalFlowSignal',
432
+ model: 'InstitutionalFlowSignal',
433
+ error: String(error),
434
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
435
+ errorCategory: 'CONSTRAINT_VIOLATION',
436
+ isRetryable: false,
437
+ });
438
+ throw error;
439
+ }
388
440
  // Check if this is a database connection error that we should retry
389
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
390
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
391
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
392
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
393
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
441
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
442
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
443
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
444
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
445
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
394
446
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
395
447
  retryCount++;
396
448
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
397
- logger_1.logger.warn("Database connection error, retrying...");
449
+ logger_1.logger.warn("Database connection error in createManyInstitutionalFlowSignal, retrying...", {
450
+ operation: 'createManyInstitutionalFlowSignal',
451
+ model: 'InstitutionalFlowSignal',
452
+ attempt: retryCount,
453
+ maxRetries: MAX_RETRIES,
454
+ });
398
455
  await new Promise(resolve => setTimeout(resolve, delay));
399
456
  continue;
400
457
  }
401
- // Log the error and rethrow
402
- logger_1.logger.error("Database error occurred", { error: String(error) });
458
+ // Log structured error details and rethrow
459
+ logger_1.logger.error("Database createMany operation failed", {
460
+ operation: 'createManyInstitutionalFlowSignal',
461
+ model: 'InstitutionalFlowSignal',
462
+ error: String(error),
463
+ isRetryable: isConnectionError,
464
+ });
403
465
  throw error;
404
466
  }
405
467
  }
@@ -414,7 +476,7 @@ exports.InstitutionalFlowSignal = {
414
476
  * @returns The updated InstitutionalFlowSignal or null.
415
477
  */
416
478
  async update(props, globalClient) {
417
- var _a, _b, _c, _d, _e;
479
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
418
480
  // Maximum number of retries for database connection issues
419
481
  const MAX_RETRIES = 3;
420
482
  let retryCount = 0;
@@ -1023,21 +1085,55 @@ exports.InstitutionalFlowSignal = {
1023
1085
  }
1024
1086
  catch (error) {
1025
1087
  lastError = error;
1088
+ // Check for constraint violations FIRST - these are NEVER retryable
1089
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
1090
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
1091
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
1092
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
1093
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
1094
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
1095
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
1096
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
1097
+ if (isConstraintViolation) {
1098
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
1099
+ logger_1.logger.error("Non-retryable constraint violation in updateOneInstitutionalFlowSignal", {
1100
+ operation: 'updateOneInstitutionalFlowSignal',
1101
+ model: 'InstitutionalFlowSignal',
1102
+ error: String(error),
1103
+ recordId: props.id,
1104
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1105
+ errorCategory: 'CONSTRAINT_VIOLATION',
1106
+ isRetryable: false,
1107
+ });
1108
+ throw error;
1109
+ }
1026
1110
  // Check if this is a database connection error that we should retry
1027
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
1028
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
1029
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
1030
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
1031
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
1111
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
1112
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
1113
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
1114
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
1115
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
1032
1116
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1033
1117
  retryCount++;
1034
1118
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1035
- logger_1.logger.warn("Database connection error, retrying...");
1119
+ logger_1.logger.warn("Database connection error in updateOneInstitutionalFlowSignal, retrying...", {
1120
+ operation: 'updateOneInstitutionalFlowSignal',
1121
+ model: 'InstitutionalFlowSignal',
1122
+ attempt: retryCount,
1123
+ maxRetries: MAX_RETRIES,
1124
+ recordId: props.id,
1125
+ });
1036
1126
  await new Promise(resolve => setTimeout(resolve, delay));
1037
1127
  continue;
1038
1128
  }
1039
- // Log the error and rethrow
1040
- logger_1.logger.error("Database error occurred", { error: String(error) });
1129
+ // Log structured error details and rethrow
1130
+ logger_1.logger.error("Database update operation failed", {
1131
+ operation: 'updateOneInstitutionalFlowSignal',
1132
+ model: 'InstitutionalFlowSignal',
1133
+ error: String(error),
1134
+ recordId: props.id,
1135
+ isRetryable: isConnectionError,
1136
+ });
1041
1137
  throw error;
1042
1138
  }
1043
1139
  }
@@ -1052,7 +1148,7 @@ exports.InstitutionalFlowSignal = {
1052
1148
  * @returns The updated InstitutionalFlowSignal or null.
1053
1149
  */
1054
1150
  async upsert(props, globalClient) {
1055
- var _a, _b, _c, _d, _e;
1151
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1056
1152
  // Maximum number of retries for database connection issues
1057
1153
  const MAX_RETRIES = 3;
1058
1154
  let retryCount = 0;
@@ -1809,21 +1905,55 @@ exports.InstitutionalFlowSignal = {
1809
1905
  }
1810
1906
  catch (error) {
1811
1907
  lastError = error;
1908
+ // Check for constraint violations FIRST - these are NEVER retryable
1909
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
1910
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
1911
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
1912
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
1913
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
1914
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
1915
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
1916
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
1917
+ if (isConstraintViolation) {
1918
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
1919
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneInstitutionalFlowSignal", {
1920
+ operation: 'upsertOneInstitutionalFlowSignal',
1921
+ model: 'InstitutionalFlowSignal',
1922
+ error: String(error),
1923
+ recordId: props.id,
1924
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1925
+ errorCategory: 'CONSTRAINT_VIOLATION',
1926
+ isRetryable: false,
1927
+ });
1928
+ throw error;
1929
+ }
1812
1930
  // Check if this is a database connection error that we should retry
1813
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
1814
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
1815
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
1816
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
1817
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
1931
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
1932
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
1933
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
1934
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
1935
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
1818
1936
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1819
1937
  retryCount++;
1820
1938
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1821
- logger_1.logger.warn("Database connection error, retrying...");
1939
+ logger_1.logger.warn("Database connection error in upsertOneInstitutionalFlowSignal, retrying...", {
1940
+ operation: 'upsertOneInstitutionalFlowSignal',
1941
+ model: 'InstitutionalFlowSignal',
1942
+ attempt: retryCount,
1943
+ maxRetries: MAX_RETRIES,
1944
+ recordId: props.id,
1945
+ });
1822
1946
  await new Promise(resolve => setTimeout(resolve, delay));
1823
1947
  continue;
1824
1948
  }
1825
- // Log the error and rethrow
1826
- logger_1.logger.error("Database error occurred", { error: String(error) });
1949
+ // Log structured error details and rethrow
1950
+ logger_1.logger.error("Database upsert operation failed", {
1951
+ operation: 'upsertOneInstitutionalFlowSignal',
1952
+ model: 'InstitutionalFlowSignal',
1953
+ error: String(error),
1954
+ recordId: props.id,
1955
+ isRetryable: isConnectionError,
1956
+ });
1827
1957
  throw error;
1828
1958
  }
1829
1959
  }
@@ -1838,7 +1968,7 @@ exports.InstitutionalFlowSignal = {
1838
1968
  * @returns The count of created records or null.
1839
1969
  */
1840
1970
  async updateMany(props, globalClient) {
1841
- var _a, _b, _c, _d, _e;
1971
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1842
1972
  // Maximum number of retries for database connection issues
1843
1973
  const MAX_RETRIES = 3;
1844
1974
  let retryCount = 0;
@@ -2447,21 +2577,52 @@ exports.InstitutionalFlowSignal = {
2447
2577
  }
2448
2578
  catch (error) {
2449
2579
  lastError = error;
2580
+ // Check for constraint violations FIRST - these are NEVER retryable
2581
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
2582
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
2583
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
2584
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
2585
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
2586
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
2587
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
2588
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
2589
+ if (isConstraintViolation) {
2590
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
2591
+ logger_1.logger.error("Non-retryable constraint violation in updateManyInstitutionalFlowSignal", {
2592
+ operation: 'updateManyInstitutionalFlowSignal',
2593
+ model: 'InstitutionalFlowSignal',
2594
+ error: String(error),
2595
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
2596
+ errorCategory: 'CONSTRAINT_VIOLATION',
2597
+ isRetryable: false,
2598
+ });
2599
+ throw error;
2600
+ }
2450
2601
  // Check if this is a database connection error that we should retry
2451
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
2452
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
2453
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
2454
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
2455
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
2602
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
2603
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
2604
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
2605
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
2606
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
2456
2607
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
2457
2608
  retryCount++;
2458
2609
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
2459
- logger_1.logger.warn("Database connection error, retrying...");
2610
+ logger_1.logger.warn("Database connection error in updateManyInstitutionalFlowSignal, retrying...", {
2611
+ operation: 'updateManyInstitutionalFlowSignal',
2612
+ model: 'InstitutionalFlowSignal',
2613
+ attempt: retryCount,
2614
+ maxRetries: MAX_RETRIES,
2615
+ });
2460
2616
  await new Promise(resolve => setTimeout(resolve, delay));
2461
2617
  continue;
2462
2618
  }
2463
- // Log the error and rethrow
2464
- logger_1.logger.error("Database error occurred", { error: String(error) });
2619
+ // Log structured error details and rethrow
2620
+ logger_1.logger.error("Database updateMany operation failed", {
2621
+ operation: 'updateManyInstitutionalFlowSignal',
2622
+ model: 'InstitutionalFlowSignal',
2623
+ error: String(error),
2624
+ isRetryable: isConnectionError,
2625
+ });
2465
2626
  throw error;
2466
2627
  }
2467
2628
  }
@@ -2476,7 +2637,7 @@ exports.InstitutionalFlowSignal = {
2476
2637
  * @returns The deleted InstitutionalFlowSignal or null.
2477
2638
  */
2478
2639
  async delete(props, globalClient) {
2479
- var _a, _b, _c, _d, _e;
2640
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
2480
2641
  // Maximum number of retries for database connection issues
2481
2642
  const MAX_RETRIES = 3;
2482
2643
  let retryCount = 0;
@@ -2520,21 +2681,58 @@ exports.InstitutionalFlowSignal = {
2520
2681
  }
2521
2682
  catch (error) {
2522
2683
  lastError = error;
2684
+ // Check for constraint violations FIRST - these are NEVER retryable
2685
+ // (e.g., foreign key constraints preventing deletion)
2686
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
2687
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
2688
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
2689
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
2690
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
2691
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
2692
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
2693
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
2694
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
2695
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
2696
+ if (isConstraintViolation) {
2697
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
2698
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneInstitutionalFlowSignal", {
2699
+ operation: 'deleteOneInstitutionalFlowSignal',
2700
+ model: 'InstitutionalFlowSignal',
2701
+ error: String(error),
2702
+ recordId: props.id,
2703
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
2704
+ errorCategory: 'CONSTRAINT_VIOLATION',
2705
+ isRetryable: false,
2706
+ });
2707
+ throw error;
2708
+ }
2523
2709
  // Check if this is a database connection error that we should retry
2524
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
2525
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
2526
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
2527
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
2528
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
2710
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
2711
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
2712
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
2713
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
2714
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
2529
2715
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
2530
2716
  retryCount++;
2531
2717
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
2532
- logger_1.logger.warn("Database connection error, retrying...");
2718
+ logger_1.logger.warn("Database connection error in deleteOneInstitutionalFlowSignal, retrying...", {
2719
+ operation: 'deleteOneInstitutionalFlowSignal',
2720
+ model: 'InstitutionalFlowSignal',
2721
+ attempt: retryCount,
2722
+ maxRetries: MAX_RETRIES,
2723
+ recordId: props.id,
2724
+ });
2533
2725
  await new Promise(resolve => setTimeout(resolve, delay));
2534
2726
  continue;
2535
2727
  }
2536
- // Log the error and rethrow
2537
- logger_1.logger.error("Database error occurred", { error: String(error) });
2728
+ // Log structured error details and rethrow
2729
+ logger_1.logger.error("Database delete operation failed", {
2730
+ operation: 'deleteOneInstitutionalFlowSignal',
2731
+ model: 'InstitutionalFlowSignal',
2732
+ error: String(error),
2733
+ recordId: props.id,
2734
+ isRetryable: isConnectionError,
2735
+ });
2538
2736
  throw error;
2539
2737
  }
2540
2738
  }
@@ -2604,12 +2802,22 @@ exports.InstitutionalFlowSignal = {
2604
2802
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
2605
2803
  retryCount++;
2606
2804
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
2607
- logger_1.logger.warn("Database connection error, retrying...");
2805
+ logger_1.logger.warn("Database connection error in getInstitutionalFlowSignal, retrying...", {
2806
+ operation: 'getInstitutionalFlowSignal',
2807
+ model: 'InstitutionalFlowSignal',
2808
+ attempt: retryCount,
2809
+ maxRetries: MAX_RETRIES,
2810
+ });
2608
2811
  await new Promise(resolve => setTimeout(resolve, delay));
2609
2812
  continue;
2610
2813
  }
2611
- // Log the error and rethrow
2612
- logger_1.logger.error("Database error occurred", { error: String(error) });
2814
+ // Log structured error details and rethrow
2815
+ logger_1.logger.error("Database get operation failed", {
2816
+ operation: 'getInstitutionalFlowSignal',
2817
+ model: 'InstitutionalFlowSignal',
2818
+ error: String(error),
2819
+ isRetryable: isConnectionError,
2820
+ });
2613
2821
  throw error;
2614
2822
  }
2615
2823
  }
@@ -2667,12 +2875,22 @@ exports.InstitutionalFlowSignal = {
2667
2875
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
2668
2876
  retryCount++;
2669
2877
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
2670
- logger_1.logger.warn("Database connection error, retrying...");
2878
+ logger_1.logger.warn("Database connection error in getAllInstitutionalFlowSignal, retrying...", {
2879
+ operation: 'getAllInstitutionalFlowSignal',
2880
+ model: 'InstitutionalFlowSignal',
2881
+ attempt: retryCount,
2882
+ maxRetries: MAX_RETRIES,
2883
+ });
2671
2884
  await new Promise(resolve => setTimeout(resolve, delay));
2672
2885
  continue;
2673
2886
  }
2674
- // Log the error and rethrow
2675
- logger_1.logger.error("Database error occurred", { error: String(error) });
2887
+ // Log structured error details and rethrow
2888
+ logger_1.logger.error("Database getAll operation failed", {
2889
+ operation: 'getAllInstitutionalFlowSignal',
2890
+ model: 'InstitutionalFlowSignal',
2891
+ error: String(error),
2892
+ isRetryable: isConnectionError,
2893
+ });
2676
2894
  throw error;
2677
2895
  }
2678
2896
  }
@@ -2749,12 +2967,22 @@ exports.InstitutionalFlowSignal = {
2749
2967
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
2750
2968
  retryCount++;
2751
2969
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
2752
- logger_1.logger.warn("Database connection error, retrying...");
2970
+ logger_1.logger.warn("Database connection error in findManyInstitutionalFlowSignal, retrying...", {
2971
+ operation: 'findManyInstitutionalFlowSignal',
2972
+ model: 'InstitutionalFlowSignal',
2973
+ attempt: retryCount,
2974
+ maxRetries: MAX_RETRIES,
2975
+ });
2753
2976
  await new Promise(resolve => setTimeout(resolve, delay));
2754
2977
  continue;
2755
2978
  }
2756
- // Log the error and rethrow
2757
- logger_1.logger.error("Database error occurred", { error: String(error) });
2979
+ // Log structured error details and rethrow
2980
+ logger_1.logger.error("Database findMany operation failed", {
2981
+ operation: 'findManyInstitutionalFlowSignal',
2982
+ model: 'InstitutionalFlowSignal',
2983
+ error: String(error),
2984
+ isRetryable: isConnectionError,
2985
+ });
2758
2986
  throw error;
2759
2987
  }
2760
2988
  }