@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
@@ -46,7 +46,7 @@ exports.SignalGeneratorMetrics = {
46
46
  * @returns The created SignalGeneratorMetrics or null.
47
47
  */
48
48
  async create(props, globalClient) {
49
- var _a, _b, _c, _d, _e;
49
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
50
50
  // Maximum number of retries for database connection issues
51
51
  const MAX_RETRIES = 3;
52
52
  let retryCount = 0;
@@ -100,21 +100,52 @@ exports.SignalGeneratorMetrics = {
100
100
  }
101
101
  catch (error) {
102
102
  lastError = error;
103
+ // Check for constraint violations FIRST - these are NEVER retryable
104
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
105
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
106
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
107
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
108
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
109
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
110
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
111
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
112
+ if (isConstraintViolation) {
113
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
114
+ logger_1.logger.error("Non-retryable constraint violation in createOneSignalGeneratorMetrics", {
115
+ operation: 'createOneSignalGeneratorMetrics',
116
+ model: 'SignalGeneratorMetrics',
117
+ error: String(error),
118
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
119
+ errorCategory: 'CONSTRAINT_VIOLATION',
120
+ isRetryable: false,
121
+ });
122
+ throw error;
123
+ }
103
124
  // Check if this is a database connection error that we should retry
104
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
105
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
106
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
107
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
108
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
125
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
126
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
127
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
128
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
129
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
109
130
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
110
131
  retryCount++;
111
132
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
112
- logger_1.logger.warn("Database connection error, retrying...");
133
+ logger_1.logger.warn("Database connection error in createOneSignalGeneratorMetrics, retrying...", {
134
+ operation: 'createOneSignalGeneratorMetrics',
135
+ model: 'SignalGeneratorMetrics',
136
+ attempt: retryCount,
137
+ maxRetries: MAX_RETRIES,
138
+ });
113
139
  await new Promise(resolve => setTimeout(resolve, delay));
114
140
  continue;
115
141
  }
116
- // Log the error and rethrow
117
- logger_1.logger.error("Database error occurred", { error: String(error) });
142
+ // Log structured error details and rethrow
143
+ logger_1.logger.error("Database create operation failed", {
144
+ operation: 'createOneSignalGeneratorMetrics',
145
+ model: 'SignalGeneratorMetrics',
146
+ error: String(error),
147
+ isRetryable: isConnectionError,
148
+ });
118
149
  throw error;
119
150
  }
120
151
  }
@@ -129,7 +160,7 @@ exports.SignalGeneratorMetrics = {
129
160
  * @returns The count of created records or null.
130
161
  */
131
162
  async createMany(props, globalClient) {
132
- var _a, _b, _c, _d, _e;
163
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
133
164
  // Maximum number of retries for database connection issues
134
165
  const MAX_RETRIES = 3;
135
166
  let retryCount = 0;
@@ -182,21 +213,52 @@ exports.SignalGeneratorMetrics = {
182
213
  }
183
214
  catch (error) {
184
215
  lastError = error;
216
+ // Check for constraint violations FIRST - these are NEVER retryable
217
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
218
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
219
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
220
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
221
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
222
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
223
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
224
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
225
+ if (isConstraintViolation) {
226
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
227
+ logger_1.logger.error("Non-retryable constraint violation in createManySignalGeneratorMetrics", {
228
+ operation: 'createManySignalGeneratorMetrics',
229
+ model: 'SignalGeneratorMetrics',
230
+ error: String(error),
231
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
232
+ errorCategory: 'CONSTRAINT_VIOLATION',
233
+ isRetryable: false,
234
+ });
235
+ throw error;
236
+ }
185
237
  // Check if this is a database connection error that we should retry
186
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
187
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
188
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
189
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
190
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
238
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
239
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
240
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
241
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
242
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
191
243
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
192
244
  retryCount++;
193
245
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
194
- logger_1.logger.warn("Database connection error, retrying...");
246
+ logger_1.logger.warn("Database connection error in createManySignalGeneratorMetrics, retrying...", {
247
+ operation: 'createManySignalGeneratorMetrics',
248
+ model: 'SignalGeneratorMetrics',
249
+ attempt: retryCount,
250
+ maxRetries: MAX_RETRIES,
251
+ });
195
252
  await new Promise(resolve => setTimeout(resolve, delay));
196
253
  continue;
197
254
  }
198
- // Log the error and rethrow
199
- logger_1.logger.error("Database error occurred", { error: String(error) });
255
+ // Log structured error details and rethrow
256
+ logger_1.logger.error("Database createMany operation failed", {
257
+ operation: 'createManySignalGeneratorMetrics',
258
+ model: 'SignalGeneratorMetrics',
259
+ error: String(error),
260
+ isRetryable: isConnectionError,
261
+ });
200
262
  throw error;
201
263
  }
202
264
  }
@@ -211,7 +273,7 @@ exports.SignalGeneratorMetrics = {
211
273
  * @returns The updated SignalGeneratorMetrics or null.
212
274
  */
213
275
  async update(props, globalClient) {
214
- var _a, _b, _c, _d, _e;
276
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
215
277
  // Maximum number of retries for database connection issues
216
278
  const MAX_RETRIES = 3;
217
279
  let retryCount = 0;
@@ -320,21 +382,55 @@ exports.SignalGeneratorMetrics = {
320
382
  }
321
383
  catch (error) {
322
384
  lastError = error;
385
+ // Check for constraint violations FIRST - these are NEVER retryable
386
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
387
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
388
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
389
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
390
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
391
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
392
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
393
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
394
+ if (isConstraintViolation) {
395
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
396
+ logger_1.logger.error("Non-retryable constraint violation in updateOneSignalGeneratorMetrics", {
397
+ operation: 'updateOneSignalGeneratorMetrics',
398
+ model: 'SignalGeneratorMetrics',
399
+ error: String(error),
400
+ recordId: props.id,
401
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
402
+ errorCategory: 'CONSTRAINT_VIOLATION',
403
+ isRetryable: false,
404
+ });
405
+ throw error;
406
+ }
323
407
  // Check if this is a database connection error that we should retry
324
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
325
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
326
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
327
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
328
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
408
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
409
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
410
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
411
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
412
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
329
413
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
330
414
  retryCount++;
331
415
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
332
- logger_1.logger.warn("Database connection error, retrying...");
416
+ logger_1.logger.warn("Database connection error in updateOneSignalGeneratorMetrics, retrying...", {
417
+ operation: 'updateOneSignalGeneratorMetrics',
418
+ model: 'SignalGeneratorMetrics',
419
+ attempt: retryCount,
420
+ maxRetries: MAX_RETRIES,
421
+ recordId: props.id,
422
+ });
333
423
  await new Promise(resolve => setTimeout(resolve, delay));
334
424
  continue;
335
425
  }
336
- // Log the error and rethrow
337
- logger_1.logger.error("Database error occurred", { error: String(error) });
426
+ // Log structured error details and rethrow
427
+ logger_1.logger.error("Database update operation failed", {
428
+ operation: 'updateOneSignalGeneratorMetrics',
429
+ model: 'SignalGeneratorMetrics',
430
+ error: String(error),
431
+ recordId: props.id,
432
+ isRetryable: isConnectionError,
433
+ });
338
434
  throw error;
339
435
  }
340
436
  }
@@ -349,7 +445,7 @@ exports.SignalGeneratorMetrics = {
349
445
  * @returns The updated SignalGeneratorMetrics or null.
350
446
  */
351
447
  async upsert(props, globalClient) {
352
- var _a, _b, _c, _d, _e;
448
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
353
449
  // Maximum number of retries for database connection issues
354
450
  const MAX_RETRIES = 3;
355
451
  let retryCount = 0;
@@ -464,21 +560,55 @@ exports.SignalGeneratorMetrics = {
464
560
  }
465
561
  catch (error) {
466
562
  lastError = error;
563
+ // Check for constraint violations FIRST - these are NEVER retryable
564
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
565
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
566
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
567
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
568
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
569
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
570
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
571
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
572
+ if (isConstraintViolation) {
573
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
574
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneSignalGeneratorMetrics", {
575
+ operation: 'upsertOneSignalGeneratorMetrics',
576
+ model: 'SignalGeneratorMetrics',
577
+ error: String(error),
578
+ recordId: props.id,
579
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
580
+ errorCategory: 'CONSTRAINT_VIOLATION',
581
+ isRetryable: false,
582
+ });
583
+ throw error;
584
+ }
467
585
  // Check if this is a database connection error that we should retry
468
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
469
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
470
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
471
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
472
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
586
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
587
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
588
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
589
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
590
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
473
591
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
474
592
  retryCount++;
475
593
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
476
- logger_1.logger.warn("Database connection error, retrying...");
594
+ logger_1.logger.warn("Database connection error in upsertOneSignalGeneratorMetrics, retrying...", {
595
+ operation: 'upsertOneSignalGeneratorMetrics',
596
+ model: 'SignalGeneratorMetrics',
597
+ attempt: retryCount,
598
+ maxRetries: MAX_RETRIES,
599
+ recordId: props.id,
600
+ });
477
601
  await new Promise(resolve => setTimeout(resolve, delay));
478
602
  continue;
479
603
  }
480
- // Log the error and rethrow
481
- logger_1.logger.error("Database error occurred", { error: String(error) });
604
+ // Log structured error details and rethrow
605
+ logger_1.logger.error("Database upsert operation failed", {
606
+ operation: 'upsertOneSignalGeneratorMetrics',
607
+ model: 'SignalGeneratorMetrics',
608
+ error: String(error),
609
+ recordId: props.id,
610
+ isRetryable: isConnectionError,
611
+ });
482
612
  throw error;
483
613
  }
484
614
  }
@@ -493,7 +623,7 @@ exports.SignalGeneratorMetrics = {
493
623
  * @returns The count of created records or null.
494
624
  */
495
625
  async updateMany(props, globalClient) {
496
- var _a, _b, _c, _d, _e;
626
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
497
627
  // Maximum number of retries for database connection issues
498
628
  const MAX_RETRIES = 3;
499
629
  let retryCount = 0;
@@ -602,21 +732,52 @@ exports.SignalGeneratorMetrics = {
602
732
  }
603
733
  catch (error) {
604
734
  lastError = error;
735
+ // Check for constraint violations FIRST - these are NEVER retryable
736
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
737
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
738
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
739
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
740
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
741
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
742
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
743
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
744
+ if (isConstraintViolation) {
745
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
746
+ logger_1.logger.error("Non-retryable constraint violation in updateManySignalGeneratorMetrics", {
747
+ operation: 'updateManySignalGeneratorMetrics',
748
+ model: 'SignalGeneratorMetrics',
749
+ error: String(error),
750
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
751
+ errorCategory: 'CONSTRAINT_VIOLATION',
752
+ isRetryable: false,
753
+ });
754
+ throw error;
755
+ }
605
756
  // Check if this is a database connection error that we should retry
606
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
607
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
608
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
609
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
610
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
757
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
758
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
759
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
760
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
761
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
611
762
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
612
763
  retryCount++;
613
764
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
614
- logger_1.logger.warn("Database connection error, retrying...");
765
+ logger_1.logger.warn("Database connection error in updateManySignalGeneratorMetrics, retrying...", {
766
+ operation: 'updateManySignalGeneratorMetrics',
767
+ model: 'SignalGeneratorMetrics',
768
+ attempt: retryCount,
769
+ maxRetries: MAX_RETRIES,
770
+ });
615
771
  await new Promise(resolve => setTimeout(resolve, delay));
616
772
  continue;
617
773
  }
618
- // Log the error and rethrow
619
- logger_1.logger.error("Database error occurred", { error: String(error) });
774
+ // Log structured error details and rethrow
775
+ logger_1.logger.error("Database updateMany operation failed", {
776
+ operation: 'updateManySignalGeneratorMetrics',
777
+ model: 'SignalGeneratorMetrics',
778
+ error: String(error),
779
+ isRetryable: isConnectionError,
780
+ });
620
781
  throw error;
621
782
  }
622
783
  }
@@ -631,7 +792,7 @@ exports.SignalGeneratorMetrics = {
631
792
  * @returns The deleted SignalGeneratorMetrics or null.
632
793
  */
633
794
  async delete(props, globalClient) {
634
- var _a, _b, _c, _d, _e;
795
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
635
796
  // Maximum number of retries for database connection issues
636
797
  const MAX_RETRIES = 3;
637
798
  let retryCount = 0;
@@ -675,21 +836,58 @@ exports.SignalGeneratorMetrics = {
675
836
  }
676
837
  catch (error) {
677
838
  lastError = error;
839
+ // Check for constraint violations FIRST - these are NEVER retryable
840
+ // (e.g., foreign key constraints preventing deletion)
841
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
842
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
843
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
844
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
845
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
846
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
847
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
848
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
849
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
850
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
851
+ if (isConstraintViolation) {
852
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
853
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneSignalGeneratorMetrics", {
854
+ operation: 'deleteOneSignalGeneratorMetrics',
855
+ model: 'SignalGeneratorMetrics',
856
+ error: String(error),
857
+ recordId: props.id,
858
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
859
+ errorCategory: 'CONSTRAINT_VIOLATION',
860
+ isRetryable: false,
861
+ });
862
+ throw error;
863
+ }
678
864
  // Check if this is a database connection error that we should retry
679
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
680
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
681
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
682
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
683
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
865
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
866
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
867
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
868
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
869
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
684
870
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
685
871
  retryCount++;
686
872
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
687
- logger_1.logger.warn("Database connection error, retrying...");
873
+ logger_1.logger.warn("Database connection error in deleteOneSignalGeneratorMetrics, retrying...", {
874
+ operation: 'deleteOneSignalGeneratorMetrics',
875
+ model: 'SignalGeneratorMetrics',
876
+ attempt: retryCount,
877
+ maxRetries: MAX_RETRIES,
878
+ recordId: props.id,
879
+ });
688
880
  await new Promise(resolve => setTimeout(resolve, delay));
689
881
  continue;
690
882
  }
691
- // Log the error and rethrow
692
- logger_1.logger.error("Database error occurred", { error: String(error) });
883
+ // Log structured error details and rethrow
884
+ logger_1.logger.error("Database delete operation failed", {
885
+ operation: 'deleteOneSignalGeneratorMetrics',
886
+ model: 'SignalGeneratorMetrics',
887
+ error: String(error),
888
+ recordId: props.id,
889
+ isRetryable: isConnectionError,
890
+ });
693
891
  throw error;
694
892
  }
695
893
  }
@@ -759,12 +957,22 @@ exports.SignalGeneratorMetrics = {
759
957
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
760
958
  retryCount++;
761
959
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
762
- logger_1.logger.warn("Database connection error, retrying...");
960
+ logger_1.logger.warn("Database connection error in getSignalGeneratorMetrics, retrying...", {
961
+ operation: 'getSignalGeneratorMetrics',
962
+ model: 'SignalGeneratorMetrics',
963
+ attempt: retryCount,
964
+ maxRetries: MAX_RETRIES,
965
+ });
763
966
  await new Promise(resolve => setTimeout(resolve, delay));
764
967
  continue;
765
968
  }
766
- // Log the error and rethrow
767
- logger_1.logger.error("Database error occurred", { error: String(error) });
969
+ // Log structured error details and rethrow
970
+ logger_1.logger.error("Database get operation failed", {
971
+ operation: 'getSignalGeneratorMetrics',
972
+ model: 'SignalGeneratorMetrics',
973
+ error: String(error),
974
+ isRetryable: isConnectionError,
975
+ });
768
976
  throw error;
769
977
  }
770
978
  }
@@ -822,12 +1030,22 @@ exports.SignalGeneratorMetrics = {
822
1030
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
823
1031
  retryCount++;
824
1032
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
825
- logger_1.logger.warn("Database connection error, retrying...");
1033
+ logger_1.logger.warn("Database connection error in getAllSignalGeneratorMetrics, retrying...", {
1034
+ operation: 'getAllSignalGeneratorMetrics',
1035
+ model: 'SignalGeneratorMetrics',
1036
+ attempt: retryCount,
1037
+ maxRetries: MAX_RETRIES,
1038
+ });
826
1039
  await new Promise(resolve => setTimeout(resolve, delay));
827
1040
  continue;
828
1041
  }
829
- // Log the error and rethrow
830
- logger_1.logger.error("Database error occurred", { error: String(error) });
1042
+ // Log structured error details and rethrow
1043
+ logger_1.logger.error("Database getAll operation failed", {
1044
+ operation: 'getAllSignalGeneratorMetrics',
1045
+ model: 'SignalGeneratorMetrics',
1046
+ error: String(error),
1047
+ isRetryable: isConnectionError,
1048
+ });
831
1049
  throw error;
832
1050
  }
833
1051
  }
@@ -904,12 +1122,22 @@ exports.SignalGeneratorMetrics = {
904
1122
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
905
1123
  retryCount++;
906
1124
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
907
- logger_1.logger.warn("Database connection error, retrying...");
1125
+ logger_1.logger.warn("Database connection error in findManySignalGeneratorMetrics, retrying...", {
1126
+ operation: 'findManySignalGeneratorMetrics',
1127
+ model: 'SignalGeneratorMetrics',
1128
+ attempt: retryCount,
1129
+ maxRetries: MAX_RETRIES,
1130
+ });
908
1131
  await new Promise(resolve => setTimeout(resolve, delay));
909
1132
  continue;
910
1133
  }
911
- // Log the error and rethrow
912
- logger_1.logger.error("Database error occurred", { error: String(error) });
1134
+ // Log structured error details and rethrow
1135
+ logger_1.logger.error("Database findMany operation failed", {
1136
+ operation: 'findManySignalGeneratorMetrics',
1137
+ model: 'SignalGeneratorMetrics',
1138
+ error: String(error),
1139
+ isRetryable: isConnectionError,
1140
+ });
913
1141
  throw error;
914
1142
  }
915
1143
  }