@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
@@ -985,6 +985,27 @@ export const ModelVersionArtifact = {
985
985
  }
986
986
  catch (error) {
987
987
  lastError = error;
988
+ // Check for constraint violations FIRST - these are NEVER retryable
989
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
990
+ error.message?.includes('violates unique constraint') ||
991
+ error.message?.includes('violates foreign key constraint') ||
992
+ error.message?.includes('unique constraint') ||
993
+ error.message?.includes('23514') ||
994
+ error.message?.includes('23505') ||
995
+ error.message?.includes('P2002') ||
996
+ error.message?.includes('P2003');
997
+ if (isConstraintViolation) {
998
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
999
+ logger.error("Non-retryable constraint violation in createOneModelVersionArtifact", {
1000
+ operation: 'createOneModelVersionArtifact',
1001
+ model: 'ModelVersionArtifact',
1002
+ error: String(error),
1003
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1004
+ errorCategory: 'CONSTRAINT_VIOLATION',
1005
+ isRetryable: false,
1006
+ });
1007
+ throw error;
1008
+ }
988
1009
  // Check if this is a database connection error that we should retry
989
1010
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
990
1011
  error.message?.includes('Cannot reach database server') ||
@@ -994,12 +1015,22 @@ export const ModelVersionArtifact = {
994
1015
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
995
1016
  retryCount++;
996
1017
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
997
- logger.warn("Database connection error, retrying...");
1018
+ logger.warn("Database connection error in createOneModelVersionArtifact, retrying...", {
1019
+ operation: 'createOneModelVersionArtifact',
1020
+ model: 'ModelVersionArtifact',
1021
+ attempt: retryCount,
1022
+ maxRetries: MAX_RETRIES,
1023
+ });
998
1024
  await new Promise(resolve => setTimeout(resolve, delay));
999
1025
  continue;
1000
1026
  }
1001
- // Log the error and rethrow
1002
- logger.error("Database error occurred", { error: String(error) });
1027
+ // Log structured error details and rethrow
1028
+ logger.error("Database create operation failed", {
1029
+ operation: 'createOneModelVersionArtifact',
1030
+ model: 'ModelVersionArtifact',
1031
+ error: String(error),
1032
+ isRetryable: isConnectionError,
1033
+ });
1003
1034
  throw error;
1004
1035
  }
1005
1036
  }
@@ -1058,6 +1089,27 @@ export const ModelVersionArtifact = {
1058
1089
  }
1059
1090
  catch (error) {
1060
1091
  lastError = error;
1092
+ // Check for constraint violations FIRST - these are NEVER retryable
1093
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
1094
+ error.message?.includes('violates unique constraint') ||
1095
+ error.message?.includes('violates foreign key constraint') ||
1096
+ error.message?.includes('unique constraint') ||
1097
+ error.message?.includes('23514') ||
1098
+ error.message?.includes('23505') ||
1099
+ error.message?.includes('P2002') ||
1100
+ error.message?.includes('P2003');
1101
+ if (isConstraintViolation) {
1102
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
1103
+ logger.error("Non-retryable constraint violation in createManyModelVersionArtifact", {
1104
+ operation: 'createManyModelVersionArtifact',
1105
+ model: 'ModelVersionArtifact',
1106
+ error: String(error),
1107
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
1108
+ errorCategory: 'CONSTRAINT_VIOLATION',
1109
+ isRetryable: false,
1110
+ });
1111
+ throw error;
1112
+ }
1061
1113
  // Check if this is a database connection error that we should retry
1062
1114
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
1063
1115
  error.message?.includes('Cannot reach database server') ||
@@ -1067,12 +1119,22 @@ export const ModelVersionArtifact = {
1067
1119
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
1068
1120
  retryCount++;
1069
1121
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
1070
- logger.warn("Database connection error, retrying...");
1122
+ logger.warn("Database connection error in createManyModelVersionArtifact, retrying...", {
1123
+ operation: 'createManyModelVersionArtifact',
1124
+ model: 'ModelVersionArtifact',
1125
+ attempt: retryCount,
1126
+ maxRetries: MAX_RETRIES,
1127
+ });
1071
1128
  await new Promise(resolve => setTimeout(resolve, delay));
1072
1129
  continue;
1073
1130
  }
1074
- // Log the error and rethrow
1075
- logger.error("Database error occurred", { error: String(error) });
1131
+ // Log structured error details and rethrow
1132
+ logger.error("Database createMany operation failed", {
1133
+ operation: 'createManyModelVersionArtifact',
1134
+ model: 'ModelVersionArtifact',
1135
+ error: String(error),
1136
+ isRetryable: isConnectionError,
1137
+ });
1076
1138
  throw error;
1077
1139
  }
1078
1140
  }
@@ -4476,6 +4538,28 @@ export const ModelVersionArtifact = {
4476
4538
  }
4477
4539
  catch (error) {
4478
4540
  lastError = error;
4541
+ // Check for constraint violations FIRST - these are NEVER retryable
4542
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
4543
+ error.message?.includes('violates unique constraint') ||
4544
+ error.message?.includes('violates foreign key constraint') ||
4545
+ error.message?.includes('unique constraint') ||
4546
+ error.message?.includes('23514') ||
4547
+ error.message?.includes('23505') ||
4548
+ error.message?.includes('P2002') ||
4549
+ error.message?.includes('P2003');
4550
+ if (isConstraintViolation) {
4551
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
4552
+ logger.error("Non-retryable constraint violation in updateOneModelVersionArtifact", {
4553
+ operation: 'updateOneModelVersionArtifact',
4554
+ model: 'ModelVersionArtifact',
4555
+ error: String(error),
4556
+ recordId: props.id,
4557
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
4558
+ errorCategory: 'CONSTRAINT_VIOLATION',
4559
+ isRetryable: false,
4560
+ });
4561
+ throw error;
4562
+ }
4479
4563
  // Check if this is a database connection error that we should retry
4480
4564
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
4481
4565
  error.message?.includes('Cannot reach database server') ||
@@ -4485,12 +4569,24 @@ export const ModelVersionArtifact = {
4485
4569
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
4486
4570
  retryCount++;
4487
4571
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
4488
- logger.warn("Database connection error, retrying...");
4572
+ logger.warn("Database connection error in updateOneModelVersionArtifact, retrying...", {
4573
+ operation: 'updateOneModelVersionArtifact',
4574
+ model: 'ModelVersionArtifact',
4575
+ attempt: retryCount,
4576
+ maxRetries: MAX_RETRIES,
4577
+ recordId: props.id,
4578
+ });
4489
4579
  await new Promise(resolve => setTimeout(resolve, delay));
4490
4580
  continue;
4491
4581
  }
4492
- // Log the error and rethrow
4493
- logger.error("Database error occurred", { error: String(error) });
4582
+ // Log structured error details and rethrow
4583
+ logger.error("Database update operation failed", {
4584
+ operation: 'updateOneModelVersionArtifact',
4585
+ model: 'ModelVersionArtifact',
4586
+ error: String(error),
4587
+ recordId: props.id,
4588
+ isRetryable: isConnectionError,
4589
+ });
4494
4590
  throw error;
4495
4591
  }
4496
4592
  }
@@ -8653,6 +8749,28 @@ export const ModelVersionArtifact = {
8653
8749
  }
8654
8750
  catch (error) {
8655
8751
  lastError = error;
8752
+ // Check for constraint violations FIRST - these are NEVER retryable
8753
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
8754
+ error.message?.includes('violates unique constraint') ||
8755
+ error.message?.includes('violates foreign key constraint') ||
8756
+ error.message?.includes('unique constraint') ||
8757
+ error.message?.includes('23514') ||
8758
+ error.message?.includes('23505') ||
8759
+ error.message?.includes('P2002') ||
8760
+ error.message?.includes('P2003');
8761
+ if (isConstraintViolation) {
8762
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
8763
+ logger.error("Non-retryable constraint violation in upsertOneModelVersionArtifact", {
8764
+ operation: 'upsertOneModelVersionArtifact',
8765
+ model: 'ModelVersionArtifact',
8766
+ error: String(error),
8767
+ recordId: props.id,
8768
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
8769
+ errorCategory: 'CONSTRAINT_VIOLATION',
8770
+ isRetryable: false,
8771
+ });
8772
+ throw error;
8773
+ }
8656
8774
  // Check if this is a database connection error that we should retry
8657
8775
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
8658
8776
  error.message?.includes('Cannot reach database server') ||
@@ -8662,12 +8780,24 @@ export const ModelVersionArtifact = {
8662
8780
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
8663
8781
  retryCount++;
8664
8782
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
8665
- logger.warn("Database connection error, retrying...");
8783
+ logger.warn("Database connection error in upsertOneModelVersionArtifact, retrying...", {
8784
+ operation: 'upsertOneModelVersionArtifact',
8785
+ model: 'ModelVersionArtifact',
8786
+ attempt: retryCount,
8787
+ maxRetries: MAX_RETRIES,
8788
+ recordId: props.id,
8789
+ });
8666
8790
  await new Promise(resolve => setTimeout(resolve, delay));
8667
8791
  continue;
8668
8792
  }
8669
- // Log the error and rethrow
8670
- logger.error("Database error occurred", { error: String(error) });
8793
+ // Log structured error details and rethrow
8794
+ logger.error("Database upsert operation failed", {
8795
+ operation: 'upsertOneModelVersionArtifact',
8796
+ model: 'ModelVersionArtifact',
8797
+ error: String(error),
8798
+ recordId: props.id,
8799
+ isRetryable: isConnectionError,
8800
+ });
8671
8801
  throw error;
8672
8802
  }
8673
8803
  }
@@ -12071,6 +12201,27 @@ export const ModelVersionArtifact = {
12071
12201
  }
12072
12202
  catch (error) {
12073
12203
  lastError = error;
12204
+ // Check for constraint violations FIRST - these are NEVER retryable
12205
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
12206
+ error.message?.includes('violates unique constraint') ||
12207
+ error.message?.includes('violates foreign key constraint') ||
12208
+ error.message?.includes('unique constraint') ||
12209
+ error.message?.includes('23514') ||
12210
+ error.message?.includes('23505') ||
12211
+ error.message?.includes('P2002') ||
12212
+ error.message?.includes('P2003');
12213
+ if (isConstraintViolation) {
12214
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
12215
+ logger.error("Non-retryable constraint violation in updateManyModelVersionArtifact", {
12216
+ operation: 'updateManyModelVersionArtifact',
12217
+ model: 'ModelVersionArtifact',
12218
+ error: String(error),
12219
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
12220
+ errorCategory: 'CONSTRAINT_VIOLATION',
12221
+ isRetryable: false,
12222
+ });
12223
+ throw error;
12224
+ }
12074
12225
  // Check if this is a database connection error that we should retry
12075
12226
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
12076
12227
  error.message?.includes('Cannot reach database server') ||
@@ -12080,12 +12231,22 @@ export const ModelVersionArtifact = {
12080
12231
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
12081
12232
  retryCount++;
12082
12233
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
12083
- logger.warn("Database connection error, retrying...");
12234
+ logger.warn("Database connection error in updateManyModelVersionArtifact, retrying...", {
12235
+ operation: 'updateManyModelVersionArtifact',
12236
+ model: 'ModelVersionArtifact',
12237
+ attempt: retryCount,
12238
+ maxRetries: MAX_RETRIES,
12239
+ });
12084
12240
  await new Promise(resolve => setTimeout(resolve, delay));
12085
12241
  continue;
12086
12242
  }
12087
- // Log the error and rethrow
12088
- logger.error("Database error occurred", { error: String(error) });
12243
+ // Log structured error details and rethrow
12244
+ logger.error("Database updateMany operation failed", {
12245
+ operation: 'updateManyModelVersionArtifact',
12246
+ model: 'ModelVersionArtifact',
12247
+ error: String(error),
12248
+ isRetryable: isConnectionError,
12249
+ });
12089
12250
  throw error;
12090
12251
  }
12091
12252
  }
@@ -12143,6 +12304,31 @@ export const ModelVersionArtifact = {
12143
12304
  }
12144
12305
  catch (error) {
12145
12306
  lastError = error;
12307
+ // Check for constraint violations FIRST - these are NEVER retryable
12308
+ // (e.g., foreign key constraints preventing deletion)
12309
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
12310
+ error.message?.includes('violates unique constraint') ||
12311
+ error.message?.includes('violates foreign key constraint') ||
12312
+ error.message?.includes('unique constraint') ||
12313
+ error.message?.includes('23514') ||
12314
+ error.message?.includes('23505') ||
12315
+ error.message?.includes('23503') ||
12316
+ error.message?.includes('P2002') ||
12317
+ error.message?.includes('P2003') ||
12318
+ error.message?.includes('P2014');
12319
+ if (isConstraintViolation) {
12320
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
12321
+ logger.error("Non-retryable constraint violation in deleteOneModelVersionArtifact", {
12322
+ operation: 'deleteOneModelVersionArtifact',
12323
+ model: 'ModelVersionArtifact',
12324
+ error: String(error),
12325
+ recordId: props.id,
12326
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
12327
+ errorCategory: 'CONSTRAINT_VIOLATION',
12328
+ isRetryable: false,
12329
+ });
12330
+ throw error;
12331
+ }
12146
12332
  // Check if this is a database connection error that we should retry
12147
12333
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
12148
12334
  error.message?.includes('Cannot reach database server') ||
@@ -12152,12 +12338,24 @@ export const ModelVersionArtifact = {
12152
12338
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
12153
12339
  retryCount++;
12154
12340
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
12155
- logger.warn("Database connection error, retrying...");
12341
+ logger.warn("Database connection error in deleteOneModelVersionArtifact, retrying...", {
12342
+ operation: 'deleteOneModelVersionArtifact',
12343
+ model: 'ModelVersionArtifact',
12344
+ attempt: retryCount,
12345
+ maxRetries: MAX_RETRIES,
12346
+ recordId: props.id,
12347
+ });
12156
12348
  await new Promise(resolve => setTimeout(resolve, delay));
12157
12349
  continue;
12158
12350
  }
12159
- // Log the error and rethrow
12160
- logger.error("Database error occurred", { error: String(error) });
12351
+ // Log structured error details and rethrow
12352
+ logger.error("Database delete operation failed", {
12353
+ operation: 'deleteOneModelVersionArtifact',
12354
+ model: 'ModelVersionArtifact',
12355
+ error: String(error),
12356
+ recordId: props.id,
12357
+ isRetryable: isConnectionError,
12358
+ });
12161
12359
  throw error;
12162
12360
  }
12163
12361
  }
@@ -12229,12 +12427,22 @@ export const ModelVersionArtifact = {
12229
12427
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
12230
12428
  retryCount++;
12231
12429
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
12232
- logger.warn("Database connection error, retrying...");
12430
+ logger.warn("Database connection error in getModelVersionArtifact, retrying...", {
12431
+ operation: 'getModelVersionArtifact',
12432
+ model: 'ModelVersionArtifact',
12433
+ attempt: retryCount,
12434
+ maxRetries: MAX_RETRIES,
12435
+ });
12233
12436
  await new Promise(resolve => setTimeout(resolve, delay));
12234
12437
  continue;
12235
12438
  }
12236
- // Log the error and rethrow
12237
- logger.error("Database error occurred", { error: String(error) });
12439
+ // Log structured error details and rethrow
12440
+ logger.error("Database get operation failed", {
12441
+ operation: 'getModelVersionArtifact',
12442
+ model: 'ModelVersionArtifact',
12443
+ error: String(error),
12444
+ isRetryable: isConnectionError,
12445
+ });
12238
12446
  throw error;
12239
12447
  }
12240
12448
  }
@@ -12291,12 +12499,22 @@ export const ModelVersionArtifact = {
12291
12499
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
12292
12500
  retryCount++;
12293
12501
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
12294
- logger.warn("Database connection error, retrying...");
12502
+ logger.warn("Database connection error in getAllModelVersionArtifact, retrying...", {
12503
+ operation: 'getAllModelVersionArtifact',
12504
+ model: 'ModelVersionArtifact',
12505
+ attempt: retryCount,
12506
+ maxRetries: MAX_RETRIES,
12507
+ });
12295
12508
  await new Promise(resolve => setTimeout(resolve, delay));
12296
12509
  continue;
12297
12510
  }
12298
- // Log the error and rethrow
12299
- logger.error("Database error occurred", { error: String(error) });
12511
+ // Log structured error details and rethrow
12512
+ logger.error("Database getAll operation failed", {
12513
+ operation: 'getAllModelVersionArtifact',
12514
+ model: 'ModelVersionArtifact',
12515
+ error: String(error),
12516
+ isRetryable: isConnectionError,
12517
+ });
12300
12518
  throw error;
12301
12519
  }
12302
12520
  }
@@ -12375,12 +12593,22 @@ export const ModelVersionArtifact = {
12375
12593
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
12376
12594
  retryCount++;
12377
12595
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
12378
- logger.warn("Database connection error, retrying...");
12596
+ logger.warn("Database connection error in findManyModelVersionArtifact, retrying...", {
12597
+ operation: 'findManyModelVersionArtifact',
12598
+ model: 'ModelVersionArtifact',
12599
+ attempt: retryCount,
12600
+ maxRetries: MAX_RETRIES,
12601
+ });
12379
12602
  await new Promise(resolve => setTimeout(resolve, delay));
12380
12603
  continue;
12381
12604
  }
12382
- // Log the error and rethrow
12383
- logger.error("Database error occurred", { error: String(error) });
12605
+ // Log structured error details and rethrow
12606
+ logger.error("Database findMany operation failed", {
12607
+ operation: 'findManyModelVersionArtifact',
12608
+ model: 'ModelVersionArtifact',
12609
+ error: String(error),
12610
+ isRetryable: isConnectionError,
12611
+ });
12384
12612
  throw error;
12385
12613
  }
12386
12614
  }
@@ -1 +1 @@
1
- {"version":3,"file":"NewsArticle.d.ts","sourceRoot":"","sources":["../../src/NewsArticle.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,mDAAmD,CAAC;AACnG,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AA4H7G,eAAO,MAAM,WAAW;IAEtB;;;;;OAKG;IAEH;;;;;;OAMG;kBACiB,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IAmOxH;;;;;;OAMG;sBACqB,eAAe,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IA2FrI;;;;;;OAMG;kBACiB,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IAwpBtH;;;;;;OAMG;kBACiB,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IAwyBtH;;;;;;OAMG;sBACqB,eAAe,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IA0pBrI;;;;;;OAMG;kBACiB,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IA2EtH;;;;;;;OAOG;eACc,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IA8E5I;;;;;OAKG;0BACyB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;IAkEvG;;;;;;;OAOG;oBACmB,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;CAsFpJ,CAAC"}
1
+ {"version":3,"file":"NewsArticle.d.ts","sourceRoot":"","sources":["../../src/NewsArticle.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,mDAAmD,CAAC;AACnG,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AA4H7G,eAAO,MAAM,WAAW;IAEtB;;;;;OAKG;IAEH;;;;;;OAMG;kBACiB,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IAqQxH;;;;;;OAMG;sBACqB,eAAe,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IA6HrI;;;;;;OAMG;kBACiB,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IA6rBtH;;;;;;OAMG;kBACiB,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IA60BtH;;;;;;OAMG;sBACqB,eAAe,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IA4rBrI;;;;;;OAMG;kBACiB,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IAmHtH;;;;;;;OAOG;eACc,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAwF5I;;;;;OAKG;0BACyB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;IA4EvG;;;;;;;OAOG;oBACmB,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;CAgGpJ,CAAC"}