@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.InstitutionalHolding = {
113
113
  * @returns The created InstitutionalHolding 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.InstitutionalHolding = {
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 createOneInstitutionalHolding", {
324
+ operation: 'createOneInstitutionalHolding',
325
+ model: 'InstitutionalHolding',
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 createOneInstitutionalHolding, retrying...", {
343
+ operation: 'createOneInstitutionalHolding',
344
+ model: 'InstitutionalHolding',
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: 'createOneInstitutionalHolding',
354
+ model: 'InstitutionalHolding',
355
+ error: String(error),
356
+ isRetryable: isConnectionError,
357
+ });
327
358
  throw error;
328
359
  }
329
360
  }
@@ -338,7 +369,7 @@ exports.InstitutionalHolding = {
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;
@@ -386,21 +417,52 @@ exports.InstitutionalHolding = {
386
417
  }
387
418
  catch (error) {
388
419
  lastError = error;
420
+ // Check for constraint violations FIRST - these are NEVER retryable
421
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
422
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
423
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
424
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
425
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
426
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
427
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
428
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
429
+ if (isConstraintViolation) {
430
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
431
+ logger_1.logger.error("Non-retryable constraint violation in createManyInstitutionalHolding", {
432
+ operation: 'createManyInstitutionalHolding',
433
+ model: 'InstitutionalHolding',
434
+ error: String(error),
435
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
436
+ errorCategory: 'CONSTRAINT_VIOLATION',
437
+ isRetryable: false,
438
+ });
439
+ throw error;
440
+ }
389
441
  // 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')));
442
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
443
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
444
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
445
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
446
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
395
447
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
396
448
  retryCount++;
397
449
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
398
- logger_1.logger.warn("Database connection error, retrying...");
450
+ logger_1.logger.warn("Database connection error in createManyInstitutionalHolding, retrying...", {
451
+ operation: 'createManyInstitutionalHolding',
452
+ model: 'InstitutionalHolding',
453
+ attempt: retryCount,
454
+ maxRetries: MAX_RETRIES,
455
+ });
399
456
  await new Promise(resolve => setTimeout(resolve, delay));
400
457
  continue;
401
458
  }
402
- // Log the error and rethrow
403
- logger_1.logger.error("Database error occurred", { error: String(error) });
459
+ // Log structured error details and rethrow
460
+ logger_1.logger.error("Database createMany operation failed", {
461
+ operation: 'createManyInstitutionalHolding',
462
+ model: 'InstitutionalHolding',
463
+ error: String(error),
464
+ isRetryable: isConnectionError,
465
+ });
404
466
  throw error;
405
467
  }
406
468
  }
@@ -415,7 +477,7 @@ exports.InstitutionalHolding = {
415
477
  * @returns The updated InstitutionalHolding or null.
416
478
  */
417
479
  async update(props, globalClient) {
418
- var _a, _b, _c, _d, _e;
480
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
419
481
  // Maximum number of retries for database connection issues
420
482
  const MAX_RETRIES = 3;
421
483
  let retryCount = 0;
@@ -1025,21 +1087,55 @@ exports.InstitutionalHolding = {
1025
1087
  }
1026
1088
  catch (error) {
1027
1089
  lastError = error;
1090
+ // Check for constraint violations FIRST - these are NEVER retryable
1091
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
1092
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
1093
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
1094
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
1095
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
1096
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
1097
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
1098
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
1099
+ if (isConstraintViolation) {
1100
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
1101
+ logger_1.logger.error("Non-retryable constraint violation in updateOneInstitutionalHolding", {
1102
+ operation: 'updateOneInstitutionalHolding',
1103
+ model: 'InstitutionalHolding',
1104
+ error: String(error),
1105
+ recordId: props.id,
1106
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1107
+ errorCategory: 'CONSTRAINT_VIOLATION',
1108
+ isRetryable: false,
1109
+ });
1110
+ throw error;
1111
+ }
1028
1112
  // Check if this is a database connection error that we should retry
1029
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
1030
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
1031
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
1032
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
1033
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
1113
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
1114
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
1115
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
1116
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
1117
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
1034
1118
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1035
1119
  retryCount++;
1036
1120
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1037
- logger_1.logger.warn("Database connection error, retrying...");
1121
+ logger_1.logger.warn("Database connection error in updateOneInstitutionalHolding, retrying...", {
1122
+ operation: 'updateOneInstitutionalHolding',
1123
+ model: 'InstitutionalHolding',
1124
+ attempt: retryCount,
1125
+ maxRetries: MAX_RETRIES,
1126
+ recordId: props.id,
1127
+ });
1038
1128
  await new Promise(resolve => setTimeout(resolve, delay));
1039
1129
  continue;
1040
1130
  }
1041
- // Log the error and rethrow
1042
- logger_1.logger.error("Database error occurred", { error: String(error) });
1131
+ // Log structured error details and rethrow
1132
+ logger_1.logger.error("Database update operation failed", {
1133
+ operation: 'updateOneInstitutionalHolding',
1134
+ model: 'InstitutionalHolding',
1135
+ error: String(error),
1136
+ recordId: props.id,
1137
+ isRetryable: isConnectionError,
1138
+ });
1043
1139
  throw error;
1044
1140
  }
1045
1141
  }
@@ -1054,7 +1150,7 @@ exports.InstitutionalHolding = {
1054
1150
  * @returns The updated InstitutionalHolding or null.
1055
1151
  */
1056
1152
  async upsert(props, globalClient) {
1057
- var _a, _b, _c, _d, _e;
1153
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1058
1154
  // Maximum number of retries for database connection issues
1059
1155
  const MAX_RETRIES = 3;
1060
1156
  let retryCount = 0;
@@ -1809,21 +1905,55 @@ exports.InstitutionalHolding = {
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 upsertOneInstitutionalHolding", {
1920
+ operation: 'upsertOneInstitutionalHolding',
1921
+ model: 'InstitutionalHolding',
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 upsertOneInstitutionalHolding, retrying...", {
1940
+ operation: 'upsertOneInstitutionalHolding',
1941
+ model: 'InstitutionalHolding',
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: 'upsertOneInstitutionalHolding',
1952
+ model: 'InstitutionalHolding',
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.InstitutionalHolding = {
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;
@@ -2448,21 +2578,52 @@ exports.InstitutionalHolding = {
2448
2578
  }
2449
2579
  catch (error) {
2450
2580
  lastError = error;
2581
+ // Check for constraint violations FIRST - these are NEVER retryable
2582
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
2583
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
2584
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
2585
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
2586
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
2587
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
2588
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
2589
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
2590
+ if (isConstraintViolation) {
2591
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
2592
+ logger_1.logger.error("Non-retryable constraint violation in updateManyInstitutionalHolding", {
2593
+ operation: 'updateManyInstitutionalHolding',
2594
+ model: 'InstitutionalHolding',
2595
+ error: String(error),
2596
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
2597
+ errorCategory: 'CONSTRAINT_VIOLATION',
2598
+ isRetryable: false,
2599
+ });
2600
+ throw error;
2601
+ }
2451
2602
  // Check if this is a database connection error that we should retry
2452
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
2453
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
2454
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
2455
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
2456
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
2603
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
2604
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
2605
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
2606
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
2607
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
2457
2608
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
2458
2609
  retryCount++;
2459
2610
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
2460
- logger_1.logger.warn("Database connection error, retrying...");
2611
+ logger_1.logger.warn("Database connection error in updateManyInstitutionalHolding, retrying...", {
2612
+ operation: 'updateManyInstitutionalHolding',
2613
+ model: 'InstitutionalHolding',
2614
+ attempt: retryCount,
2615
+ maxRetries: MAX_RETRIES,
2616
+ });
2461
2617
  await new Promise(resolve => setTimeout(resolve, delay));
2462
2618
  continue;
2463
2619
  }
2464
- // Log the error and rethrow
2465
- logger_1.logger.error("Database error occurred", { error: String(error) });
2620
+ // Log structured error details and rethrow
2621
+ logger_1.logger.error("Database updateMany operation failed", {
2622
+ operation: 'updateManyInstitutionalHolding',
2623
+ model: 'InstitutionalHolding',
2624
+ error: String(error),
2625
+ isRetryable: isConnectionError,
2626
+ });
2466
2627
  throw error;
2467
2628
  }
2468
2629
  }
@@ -2477,7 +2638,7 @@ exports.InstitutionalHolding = {
2477
2638
  * @returns The deleted InstitutionalHolding or null.
2478
2639
  */
2479
2640
  async delete(props, globalClient) {
2480
- var _a, _b, _c, _d, _e;
2641
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
2481
2642
  // Maximum number of retries for database connection issues
2482
2643
  const MAX_RETRIES = 3;
2483
2644
  let retryCount = 0;
@@ -2521,21 +2682,58 @@ exports.InstitutionalHolding = {
2521
2682
  }
2522
2683
  catch (error) {
2523
2684
  lastError = error;
2685
+ // Check for constraint violations FIRST - these are NEVER retryable
2686
+ // (e.g., foreign key constraints preventing deletion)
2687
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
2688
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
2689
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
2690
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
2691
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
2692
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
2693
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
2694
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
2695
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
2696
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
2697
+ if (isConstraintViolation) {
2698
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
2699
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneInstitutionalHolding", {
2700
+ operation: 'deleteOneInstitutionalHolding',
2701
+ model: 'InstitutionalHolding',
2702
+ error: String(error),
2703
+ recordId: props.id,
2704
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
2705
+ errorCategory: 'CONSTRAINT_VIOLATION',
2706
+ isRetryable: false,
2707
+ });
2708
+ throw error;
2709
+ }
2524
2710
  // Check if this is a database connection error that we should retry
2525
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
2526
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
2527
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
2528
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
2529
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
2711
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
2712
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
2713
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
2714
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
2715
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
2530
2716
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
2531
2717
  retryCount++;
2532
2718
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
2533
- logger_1.logger.warn("Database connection error, retrying...");
2719
+ logger_1.logger.warn("Database connection error in deleteOneInstitutionalHolding, retrying...", {
2720
+ operation: 'deleteOneInstitutionalHolding',
2721
+ model: 'InstitutionalHolding',
2722
+ attempt: retryCount,
2723
+ maxRetries: MAX_RETRIES,
2724
+ recordId: props.id,
2725
+ });
2534
2726
  await new Promise(resolve => setTimeout(resolve, delay));
2535
2727
  continue;
2536
2728
  }
2537
- // Log the error and rethrow
2538
- logger_1.logger.error("Database error occurred", { error: String(error) });
2729
+ // Log structured error details and rethrow
2730
+ logger_1.logger.error("Database delete operation failed", {
2731
+ operation: 'deleteOneInstitutionalHolding',
2732
+ model: 'InstitutionalHolding',
2733
+ error: String(error),
2734
+ recordId: props.id,
2735
+ isRetryable: isConnectionError,
2736
+ });
2539
2737
  throw error;
2540
2738
  }
2541
2739
  }
@@ -2605,12 +2803,22 @@ exports.InstitutionalHolding = {
2605
2803
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
2606
2804
  retryCount++;
2607
2805
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
2608
- logger_1.logger.warn("Database connection error, retrying...");
2806
+ logger_1.logger.warn("Database connection error in getInstitutionalHolding, retrying...", {
2807
+ operation: 'getInstitutionalHolding',
2808
+ model: 'InstitutionalHolding',
2809
+ attempt: retryCount,
2810
+ maxRetries: MAX_RETRIES,
2811
+ });
2609
2812
  await new Promise(resolve => setTimeout(resolve, delay));
2610
2813
  continue;
2611
2814
  }
2612
- // Log the error and rethrow
2613
- logger_1.logger.error("Database error occurred", { error: String(error) });
2815
+ // Log structured error details and rethrow
2816
+ logger_1.logger.error("Database get operation failed", {
2817
+ operation: 'getInstitutionalHolding',
2818
+ model: 'InstitutionalHolding',
2819
+ error: String(error),
2820
+ isRetryable: isConnectionError,
2821
+ });
2614
2822
  throw error;
2615
2823
  }
2616
2824
  }
@@ -2668,12 +2876,22 @@ exports.InstitutionalHolding = {
2668
2876
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
2669
2877
  retryCount++;
2670
2878
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
2671
- logger_1.logger.warn("Database connection error, retrying...");
2879
+ logger_1.logger.warn("Database connection error in getAllInstitutionalHolding, retrying...", {
2880
+ operation: 'getAllInstitutionalHolding',
2881
+ model: 'InstitutionalHolding',
2882
+ attempt: retryCount,
2883
+ maxRetries: MAX_RETRIES,
2884
+ });
2672
2885
  await new Promise(resolve => setTimeout(resolve, delay));
2673
2886
  continue;
2674
2887
  }
2675
- // Log the error and rethrow
2676
- logger_1.logger.error("Database error occurred", { error: String(error) });
2888
+ // Log structured error details and rethrow
2889
+ logger_1.logger.error("Database getAll operation failed", {
2890
+ operation: 'getAllInstitutionalHolding',
2891
+ model: 'InstitutionalHolding',
2892
+ error: String(error),
2893
+ isRetryable: isConnectionError,
2894
+ });
2677
2895
  throw error;
2678
2896
  }
2679
2897
  }
@@ -2750,12 +2968,22 @@ exports.InstitutionalHolding = {
2750
2968
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
2751
2969
  retryCount++;
2752
2970
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
2753
- logger_1.logger.warn("Database connection error, retrying...");
2971
+ logger_1.logger.warn("Database connection error in findManyInstitutionalHolding, retrying...", {
2972
+ operation: 'findManyInstitutionalHolding',
2973
+ model: 'InstitutionalHolding',
2974
+ attempt: retryCount,
2975
+ maxRetries: MAX_RETRIES,
2976
+ });
2754
2977
  await new Promise(resolve => setTimeout(resolve, delay));
2755
2978
  continue;
2756
2979
  }
2757
- // Log the error and rethrow
2758
- logger_1.logger.error("Database error occurred", { error: String(error) });
2980
+ // Log structured error details and rethrow
2981
+ logger_1.logger.error("Database findMany operation failed", {
2982
+ operation: 'findManyInstitutionalHolding',
2983
+ model: 'InstitutionalHolding',
2984
+ error: String(error),
2985
+ isRetryable: isConnectionError,
2986
+ });
2759
2987
  throw error;
2760
2988
  }
2761
2989
  }