@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
@@ -50,7 +50,7 @@ exports.PortfolioGreeksHistory = {
50
50
  * @returns The created PortfolioGreeksHistory or null.
51
51
  */
52
52
  async create(props, globalClient) {
53
- var _a, _b, _c, _d, _e;
53
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
54
54
  // Maximum number of retries for database connection issues
55
55
  const MAX_RETRIES = 3;
56
56
  let retryCount = 0;
@@ -104,21 +104,52 @@ exports.PortfolioGreeksHistory = {
104
104
  }
105
105
  catch (error) {
106
106
  lastError = error;
107
+ // Check for constraint violations FIRST - these are NEVER retryable
108
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
109
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
110
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
111
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
112
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
113
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
114
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
115
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
116
+ if (isConstraintViolation) {
117
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
118
+ logger_1.logger.error("Non-retryable constraint violation in createOnePortfolioGreeksHistory", {
119
+ operation: 'createOnePortfolioGreeksHistory',
120
+ model: 'PortfolioGreeksHistory',
121
+ error: String(error),
122
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
123
+ errorCategory: 'CONSTRAINT_VIOLATION',
124
+ isRetryable: false,
125
+ });
126
+ throw error;
127
+ }
107
128
  // Check if this is a database connection error that we should retry
108
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
109
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
110
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
111
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
112
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
129
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
130
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
131
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
132
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
133
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
113
134
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
114
135
  retryCount++;
115
136
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
116
- logger_1.logger.warn("Database connection error, retrying...");
137
+ logger_1.logger.warn("Database connection error in createOnePortfolioGreeksHistory, retrying...", {
138
+ operation: 'createOnePortfolioGreeksHistory',
139
+ model: 'PortfolioGreeksHistory',
140
+ attempt: retryCount,
141
+ maxRetries: MAX_RETRIES,
142
+ });
117
143
  await new Promise(resolve => setTimeout(resolve, delay));
118
144
  continue;
119
145
  }
120
- // Log the error and rethrow
121
- logger_1.logger.error("Database error occurred", { error: String(error) });
146
+ // Log structured error details and rethrow
147
+ logger_1.logger.error("Database create operation failed", {
148
+ operation: 'createOnePortfolioGreeksHistory',
149
+ model: 'PortfolioGreeksHistory',
150
+ error: String(error),
151
+ isRetryable: isConnectionError,
152
+ });
122
153
  throw error;
123
154
  }
124
155
  }
@@ -133,7 +164,7 @@ exports.PortfolioGreeksHistory = {
133
164
  * @returns The count of created records or null.
134
165
  */
135
166
  async createMany(props, globalClient) {
136
- var _a, _b, _c, _d, _e;
167
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
137
168
  // Maximum number of retries for database connection issues
138
169
  const MAX_RETRIES = 3;
139
170
  let retryCount = 0;
@@ -186,21 +217,52 @@ exports.PortfolioGreeksHistory = {
186
217
  }
187
218
  catch (error) {
188
219
  lastError = error;
220
+ // Check for constraint violations FIRST - these are NEVER retryable
221
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
222
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
223
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
224
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
225
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
226
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
227
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
228
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
229
+ if (isConstraintViolation) {
230
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
231
+ logger_1.logger.error("Non-retryable constraint violation in createManyPortfolioGreeksHistory", {
232
+ operation: 'createManyPortfolioGreeksHistory',
233
+ model: 'PortfolioGreeksHistory',
234
+ error: String(error),
235
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
236
+ errorCategory: 'CONSTRAINT_VIOLATION',
237
+ isRetryable: false,
238
+ });
239
+ throw error;
240
+ }
189
241
  // Check if this is a database connection error that we should retry
190
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
191
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
192
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
193
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
194
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
242
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
243
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
244
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
245
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
246
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
195
247
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
196
248
  retryCount++;
197
249
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
198
- logger_1.logger.warn("Database connection error, retrying...");
250
+ logger_1.logger.warn("Database connection error in createManyPortfolioGreeksHistory, retrying...", {
251
+ operation: 'createManyPortfolioGreeksHistory',
252
+ model: 'PortfolioGreeksHistory',
253
+ attempt: retryCount,
254
+ maxRetries: MAX_RETRIES,
255
+ });
199
256
  await new Promise(resolve => setTimeout(resolve, delay));
200
257
  continue;
201
258
  }
202
- // Log the error and rethrow
203
- logger_1.logger.error("Database error occurred", { error: String(error) });
259
+ // Log structured error details and rethrow
260
+ logger_1.logger.error("Database createMany operation failed", {
261
+ operation: 'createManyPortfolioGreeksHistory',
262
+ model: 'PortfolioGreeksHistory',
263
+ error: String(error),
264
+ isRetryable: isConnectionError,
265
+ });
204
266
  throw error;
205
267
  }
206
268
  }
@@ -215,7 +277,7 @@ exports.PortfolioGreeksHistory = {
215
277
  * @returns The updated PortfolioGreeksHistory or null.
216
278
  */
217
279
  async update(props, globalClient) {
218
- var _a, _b, _c, _d, _e;
280
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
219
281
  // Maximum number of retries for database connection issues
220
282
  const MAX_RETRIES = 3;
221
283
  let retryCount = 0;
@@ -339,21 +401,55 @@ exports.PortfolioGreeksHistory = {
339
401
  }
340
402
  catch (error) {
341
403
  lastError = error;
404
+ // Check for constraint violations FIRST - these are NEVER retryable
405
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
406
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
407
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
408
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
409
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
410
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
411
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
412
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
413
+ if (isConstraintViolation) {
414
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
415
+ logger_1.logger.error("Non-retryable constraint violation in updateOnePortfolioGreeksHistory", {
416
+ operation: 'updateOnePortfolioGreeksHistory',
417
+ model: 'PortfolioGreeksHistory',
418
+ error: String(error),
419
+ recordId: props.id,
420
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
421
+ errorCategory: 'CONSTRAINT_VIOLATION',
422
+ isRetryable: false,
423
+ });
424
+ throw error;
425
+ }
342
426
  // Check if this is a database connection error that we should retry
343
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
344
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
345
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
346
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
347
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
427
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
428
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
429
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
430
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
431
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
348
432
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
349
433
  retryCount++;
350
434
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
351
- logger_1.logger.warn("Database connection error, retrying...");
435
+ logger_1.logger.warn("Database connection error in updateOnePortfolioGreeksHistory, retrying...", {
436
+ operation: 'updateOnePortfolioGreeksHistory',
437
+ model: 'PortfolioGreeksHistory',
438
+ attempt: retryCount,
439
+ maxRetries: MAX_RETRIES,
440
+ recordId: props.id,
441
+ });
352
442
  await new Promise(resolve => setTimeout(resolve, delay));
353
443
  continue;
354
444
  }
355
- // Log the error and rethrow
356
- logger_1.logger.error("Database error occurred", { error: String(error) });
445
+ // Log structured error details and rethrow
446
+ logger_1.logger.error("Database update operation failed", {
447
+ operation: 'updateOnePortfolioGreeksHistory',
448
+ model: 'PortfolioGreeksHistory',
449
+ error: String(error),
450
+ recordId: props.id,
451
+ isRetryable: isConnectionError,
452
+ });
357
453
  throw error;
358
454
  }
359
455
  }
@@ -368,7 +464,7 @@ exports.PortfolioGreeksHistory = {
368
464
  * @returns The updated PortfolioGreeksHistory or null.
369
465
  */
370
466
  async upsert(props, globalClient) {
371
- var _a, _b, _c, _d, _e;
467
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
372
468
  // Maximum number of retries for database connection issues
373
469
  const MAX_RETRIES = 3;
374
470
  let retryCount = 0;
@@ -498,21 +594,55 @@ exports.PortfolioGreeksHistory = {
498
594
  }
499
595
  catch (error) {
500
596
  lastError = error;
597
+ // Check for constraint violations FIRST - these are NEVER retryable
598
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
599
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
600
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
601
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
602
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
603
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
604
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
605
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
606
+ if (isConstraintViolation) {
607
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
608
+ logger_1.logger.error("Non-retryable constraint violation in upsertOnePortfolioGreeksHistory", {
609
+ operation: 'upsertOnePortfolioGreeksHistory',
610
+ model: 'PortfolioGreeksHistory',
611
+ error: String(error),
612
+ recordId: props.id,
613
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
614
+ errorCategory: 'CONSTRAINT_VIOLATION',
615
+ isRetryable: false,
616
+ });
617
+ throw error;
618
+ }
501
619
  // Check if this is a database connection error that we should retry
502
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
503
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
504
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
505
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
506
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
620
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
621
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
622
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
623
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
624
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
507
625
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
508
626
  retryCount++;
509
627
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
510
- logger_1.logger.warn("Database connection error, retrying...");
628
+ logger_1.logger.warn("Database connection error in upsertOnePortfolioGreeksHistory, retrying...", {
629
+ operation: 'upsertOnePortfolioGreeksHistory',
630
+ model: 'PortfolioGreeksHistory',
631
+ attempt: retryCount,
632
+ maxRetries: MAX_RETRIES,
633
+ recordId: props.id,
634
+ });
511
635
  await new Promise(resolve => setTimeout(resolve, delay));
512
636
  continue;
513
637
  }
514
- // Log the error and rethrow
515
- logger_1.logger.error("Database error occurred", { error: String(error) });
638
+ // Log structured error details and rethrow
639
+ logger_1.logger.error("Database upsert operation failed", {
640
+ operation: 'upsertOnePortfolioGreeksHistory',
641
+ model: 'PortfolioGreeksHistory',
642
+ error: String(error),
643
+ recordId: props.id,
644
+ isRetryable: isConnectionError,
645
+ });
516
646
  throw error;
517
647
  }
518
648
  }
@@ -527,7 +657,7 @@ exports.PortfolioGreeksHistory = {
527
657
  * @returns The count of created records or null.
528
658
  */
529
659
  async updateMany(props, globalClient) {
530
- var _a, _b, _c, _d, _e;
660
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
531
661
  // Maximum number of retries for database connection issues
532
662
  const MAX_RETRIES = 3;
533
663
  let retryCount = 0;
@@ -651,21 +781,52 @@ exports.PortfolioGreeksHistory = {
651
781
  }
652
782
  catch (error) {
653
783
  lastError = error;
784
+ // Check for constraint violations FIRST - these are NEVER retryable
785
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
786
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
787
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
788
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
789
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
790
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
791
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
792
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
793
+ if (isConstraintViolation) {
794
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
795
+ logger_1.logger.error("Non-retryable constraint violation in updateManyPortfolioGreeksHistory", {
796
+ operation: 'updateManyPortfolioGreeksHistory',
797
+ model: 'PortfolioGreeksHistory',
798
+ error: String(error),
799
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
800
+ errorCategory: 'CONSTRAINT_VIOLATION',
801
+ isRetryable: false,
802
+ });
803
+ throw error;
804
+ }
654
805
  // Check if this is a database connection error that we should retry
655
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
656
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
657
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
658
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
659
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
806
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
807
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
808
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
809
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
810
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
660
811
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
661
812
  retryCount++;
662
813
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
663
- logger_1.logger.warn("Database connection error, retrying...");
814
+ logger_1.logger.warn("Database connection error in updateManyPortfolioGreeksHistory, retrying...", {
815
+ operation: 'updateManyPortfolioGreeksHistory',
816
+ model: 'PortfolioGreeksHistory',
817
+ attempt: retryCount,
818
+ maxRetries: MAX_RETRIES,
819
+ });
664
820
  await new Promise(resolve => setTimeout(resolve, delay));
665
821
  continue;
666
822
  }
667
- // Log the error and rethrow
668
- logger_1.logger.error("Database error occurred", { error: String(error) });
823
+ // Log structured error details and rethrow
824
+ logger_1.logger.error("Database updateMany operation failed", {
825
+ operation: 'updateManyPortfolioGreeksHistory',
826
+ model: 'PortfolioGreeksHistory',
827
+ error: String(error),
828
+ isRetryable: isConnectionError,
829
+ });
669
830
  throw error;
670
831
  }
671
832
  }
@@ -680,7 +841,7 @@ exports.PortfolioGreeksHistory = {
680
841
  * @returns The deleted PortfolioGreeksHistory or null.
681
842
  */
682
843
  async delete(props, globalClient) {
683
- var _a, _b, _c, _d, _e;
844
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
684
845
  // Maximum number of retries for database connection issues
685
846
  const MAX_RETRIES = 3;
686
847
  let retryCount = 0;
@@ -724,21 +885,58 @@ exports.PortfolioGreeksHistory = {
724
885
  }
725
886
  catch (error) {
726
887
  lastError = error;
888
+ // Check for constraint violations FIRST - these are NEVER retryable
889
+ // (e.g., foreign key constraints preventing deletion)
890
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
891
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
892
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
893
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
894
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
895
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
896
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
897
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
898
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
899
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
900
+ if (isConstraintViolation) {
901
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
902
+ logger_1.logger.error("Non-retryable constraint violation in deleteOnePortfolioGreeksHistory", {
903
+ operation: 'deleteOnePortfolioGreeksHistory',
904
+ model: 'PortfolioGreeksHistory',
905
+ error: String(error),
906
+ recordId: props.id,
907
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
908
+ errorCategory: 'CONSTRAINT_VIOLATION',
909
+ isRetryable: false,
910
+ });
911
+ throw error;
912
+ }
727
913
  // Check if this is a database connection error that we should retry
728
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
729
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
730
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
731
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
732
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
914
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
915
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
916
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
917
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
918
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
733
919
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
734
920
  retryCount++;
735
921
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
736
- logger_1.logger.warn("Database connection error, retrying...");
922
+ logger_1.logger.warn("Database connection error in deleteOnePortfolioGreeksHistory, retrying...", {
923
+ operation: 'deleteOnePortfolioGreeksHistory',
924
+ model: 'PortfolioGreeksHistory',
925
+ attempt: retryCount,
926
+ maxRetries: MAX_RETRIES,
927
+ recordId: props.id,
928
+ });
737
929
  await new Promise(resolve => setTimeout(resolve, delay));
738
930
  continue;
739
931
  }
740
- // Log the error and rethrow
741
- logger_1.logger.error("Database error occurred", { error: String(error) });
932
+ // Log structured error details and rethrow
933
+ logger_1.logger.error("Database delete operation failed", {
934
+ operation: 'deleteOnePortfolioGreeksHistory',
935
+ model: 'PortfolioGreeksHistory',
936
+ error: String(error),
937
+ recordId: props.id,
938
+ isRetryable: isConnectionError,
939
+ });
742
940
  throw error;
743
941
  }
744
942
  }
@@ -811,12 +1009,22 @@ exports.PortfolioGreeksHistory = {
811
1009
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
812
1010
  retryCount++;
813
1011
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
814
- logger_1.logger.warn("Database connection error, retrying...");
1012
+ logger_1.logger.warn("Database connection error in getPortfolioGreeksHistory, retrying...", {
1013
+ operation: 'getPortfolioGreeksHistory',
1014
+ model: 'PortfolioGreeksHistory',
1015
+ attempt: retryCount,
1016
+ maxRetries: MAX_RETRIES,
1017
+ });
815
1018
  await new Promise(resolve => setTimeout(resolve, delay));
816
1019
  continue;
817
1020
  }
818
- // Log the error and rethrow
819
- logger_1.logger.error("Database error occurred", { error: String(error) });
1021
+ // Log structured error details and rethrow
1022
+ logger_1.logger.error("Database get operation failed", {
1023
+ operation: 'getPortfolioGreeksHistory',
1024
+ model: 'PortfolioGreeksHistory',
1025
+ error: String(error),
1026
+ isRetryable: isConnectionError,
1027
+ });
820
1028
  throw error;
821
1029
  }
822
1030
  }
@@ -874,12 +1082,22 @@ exports.PortfolioGreeksHistory = {
874
1082
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
875
1083
  retryCount++;
876
1084
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
877
- logger_1.logger.warn("Database connection error, retrying...");
1085
+ logger_1.logger.warn("Database connection error in getAllPortfolioGreeksHistory, retrying...", {
1086
+ operation: 'getAllPortfolioGreeksHistory',
1087
+ model: 'PortfolioGreeksHistory',
1088
+ attempt: retryCount,
1089
+ maxRetries: MAX_RETRIES,
1090
+ });
878
1091
  await new Promise(resolve => setTimeout(resolve, delay));
879
1092
  continue;
880
1093
  }
881
- // Log the error and rethrow
882
- logger_1.logger.error("Database error occurred", { error: String(error) });
1094
+ // Log structured error details and rethrow
1095
+ logger_1.logger.error("Database getAll operation failed", {
1096
+ operation: 'getAllPortfolioGreeksHistory',
1097
+ model: 'PortfolioGreeksHistory',
1098
+ error: String(error),
1099
+ isRetryable: isConnectionError,
1100
+ });
883
1101
  throw error;
884
1102
  }
885
1103
  }
@@ -959,12 +1177,22 @@ exports.PortfolioGreeksHistory = {
959
1177
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
960
1178
  retryCount++;
961
1179
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
962
- logger_1.logger.warn("Database connection error, retrying...");
1180
+ logger_1.logger.warn("Database connection error in findManyPortfolioGreeksHistory, retrying...", {
1181
+ operation: 'findManyPortfolioGreeksHistory',
1182
+ model: 'PortfolioGreeksHistory',
1183
+ attempt: retryCount,
1184
+ maxRetries: MAX_RETRIES,
1185
+ });
963
1186
  await new Promise(resolve => setTimeout(resolve, delay));
964
1187
  continue;
965
1188
  }
966
- // Log the error and rethrow
967
- logger_1.logger.error("Database error occurred", { error: String(error) });
1189
+ // Log structured error details and rethrow
1190
+ logger_1.logger.error("Database findMany operation failed", {
1191
+ operation: 'findManyPortfolioGreeksHistory',
1192
+ model: 'PortfolioGreeksHistory',
1193
+ error: String(error),
1194
+ isRetryable: isConnectionError,
1195
+ });
968
1196
  throw error;
969
1197
  }
970
1198
  }