@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
package/SignalOutcome.cjs CHANGED
@@ -41,7 +41,7 @@ exports.SignalOutcome = {
41
41
  * @returns The created SignalOutcome or null.
42
42
  */
43
43
  async create(props, globalClient) {
44
- var _a, _b, _c, _d, _e;
44
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
45
45
  // Maximum number of retries for database connection issues
46
46
  const MAX_RETRIES = 3;
47
47
  let retryCount = 0;
@@ -96,21 +96,52 @@ exports.SignalOutcome = {
96
96
  }
97
97
  catch (error) {
98
98
  lastError = error;
99
+ // Check for constraint violations FIRST - these are NEVER retryable
100
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
101
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
102
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
103
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
104
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
105
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
106
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
107
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
108
+ if (isConstraintViolation) {
109
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
110
+ logger_1.logger.error("Non-retryable constraint violation in createOneSignalOutcome", {
111
+ operation: 'createOneSignalOutcome',
112
+ model: 'SignalOutcome',
113
+ error: String(error),
114
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
115
+ errorCategory: 'CONSTRAINT_VIOLATION',
116
+ isRetryable: false,
117
+ });
118
+ throw error;
119
+ }
99
120
  // Check if this is a database connection error that we should retry
100
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
101
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
102
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
103
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
104
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
121
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
122
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
123
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
124
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
125
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
105
126
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
106
127
  retryCount++;
107
128
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
108
- logger_1.logger.warn("Database connection error, retrying...");
129
+ logger_1.logger.warn("Database connection error in createOneSignalOutcome, retrying...", {
130
+ operation: 'createOneSignalOutcome',
131
+ model: 'SignalOutcome',
132
+ attempt: retryCount,
133
+ maxRetries: MAX_RETRIES,
134
+ });
109
135
  await new Promise(resolve => setTimeout(resolve, delay));
110
136
  continue;
111
137
  }
112
- // Log the error and rethrow
113
- logger_1.logger.error("Database error occurred", { error: String(error) });
138
+ // Log structured error details and rethrow
139
+ logger_1.logger.error("Database create operation failed", {
140
+ operation: 'createOneSignalOutcome',
141
+ model: 'SignalOutcome',
142
+ error: String(error),
143
+ isRetryable: isConnectionError,
144
+ });
114
145
  throw error;
115
146
  }
116
147
  }
@@ -125,7 +156,7 @@ exports.SignalOutcome = {
125
156
  * @returns The count of created records or null.
126
157
  */
127
158
  async createMany(props, globalClient) {
128
- var _a, _b, _c, _d, _e;
159
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
129
160
  // Maximum number of retries for database connection issues
130
161
  const MAX_RETRIES = 3;
131
162
  let retryCount = 0;
@@ -179,21 +210,52 @@ exports.SignalOutcome = {
179
210
  }
180
211
  catch (error) {
181
212
  lastError = error;
213
+ // Check for constraint violations FIRST - these are NEVER retryable
214
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
215
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
216
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
217
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
218
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
219
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
220
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
221
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
222
+ if (isConstraintViolation) {
223
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
224
+ logger_1.logger.error("Non-retryable constraint violation in createManySignalOutcome", {
225
+ operation: 'createManySignalOutcome',
226
+ model: 'SignalOutcome',
227
+ error: String(error),
228
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
229
+ errorCategory: 'CONSTRAINT_VIOLATION',
230
+ isRetryable: false,
231
+ });
232
+ throw error;
233
+ }
182
234
  // Check if this is a database connection error that we should retry
183
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
184
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
185
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
186
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
187
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
235
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
236
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
237
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
238
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
239
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
188
240
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
189
241
  retryCount++;
190
242
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
191
- logger_1.logger.warn("Database connection error, retrying...");
243
+ logger_1.logger.warn("Database connection error in createManySignalOutcome, retrying...", {
244
+ operation: 'createManySignalOutcome',
245
+ model: 'SignalOutcome',
246
+ attempt: retryCount,
247
+ maxRetries: MAX_RETRIES,
248
+ });
192
249
  await new Promise(resolve => setTimeout(resolve, delay));
193
250
  continue;
194
251
  }
195
- // Log the error and rethrow
196
- logger_1.logger.error("Database error occurred", { error: String(error) });
252
+ // Log structured error details and rethrow
253
+ logger_1.logger.error("Database createMany operation failed", {
254
+ operation: 'createManySignalOutcome',
255
+ model: 'SignalOutcome',
256
+ error: String(error),
257
+ isRetryable: isConnectionError,
258
+ });
197
259
  throw error;
198
260
  }
199
261
  }
@@ -208,7 +270,7 @@ exports.SignalOutcome = {
208
270
  * @returns The updated SignalOutcome or null.
209
271
  */
210
272
  async update(props, globalClient) {
211
- var _a, _b, _c, _d, _e;
273
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
212
274
  // Maximum number of retries for database connection issues
213
275
  const MAX_RETRIES = 3;
214
276
  let retryCount = 0;
@@ -305,21 +367,55 @@ exports.SignalOutcome = {
305
367
  }
306
368
  catch (error) {
307
369
  lastError = error;
370
+ // Check for constraint violations FIRST - these are NEVER retryable
371
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
372
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
373
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
374
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
375
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
376
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
377
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
378
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
379
+ if (isConstraintViolation) {
380
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
381
+ logger_1.logger.error("Non-retryable constraint violation in updateOneSignalOutcome", {
382
+ operation: 'updateOneSignalOutcome',
383
+ model: 'SignalOutcome',
384
+ error: String(error),
385
+ recordId: props.id,
386
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
387
+ errorCategory: 'CONSTRAINT_VIOLATION',
388
+ isRetryable: false,
389
+ });
390
+ throw error;
391
+ }
308
392
  // Check if this is a database connection error that we should retry
309
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
310
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
311
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
312
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
313
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
393
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
394
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
395
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
396
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
397
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
314
398
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
315
399
  retryCount++;
316
400
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
317
- logger_1.logger.warn("Database connection error, retrying...");
401
+ logger_1.logger.warn("Database connection error in updateOneSignalOutcome, retrying...", {
402
+ operation: 'updateOneSignalOutcome',
403
+ model: 'SignalOutcome',
404
+ attempt: retryCount,
405
+ maxRetries: MAX_RETRIES,
406
+ recordId: props.id,
407
+ });
318
408
  await new Promise(resolve => setTimeout(resolve, delay));
319
409
  continue;
320
410
  }
321
- // Log the error and rethrow
322
- logger_1.logger.error("Database error occurred", { error: String(error) });
411
+ // Log structured error details and rethrow
412
+ logger_1.logger.error("Database update operation failed", {
413
+ operation: 'updateOneSignalOutcome',
414
+ model: 'SignalOutcome',
415
+ error: String(error),
416
+ recordId: props.id,
417
+ isRetryable: isConnectionError,
418
+ });
323
419
  throw error;
324
420
  }
325
421
  }
@@ -334,7 +430,7 @@ exports.SignalOutcome = {
334
430
  * @returns The updated SignalOutcome or null.
335
431
  */
336
432
  async upsert(props, globalClient) {
337
- var _a, _b, _c, _d, _e;
433
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
338
434
  // Maximum number of retries for database connection issues
339
435
  const MAX_RETRIES = 3;
340
436
  let retryCount = 0;
@@ -441,21 +537,55 @@ exports.SignalOutcome = {
441
537
  }
442
538
  catch (error) {
443
539
  lastError = error;
540
+ // Check for constraint violations FIRST - these are NEVER retryable
541
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
542
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
543
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
544
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
545
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
546
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
547
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
548
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
549
+ if (isConstraintViolation) {
550
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
551
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneSignalOutcome", {
552
+ operation: 'upsertOneSignalOutcome',
553
+ model: 'SignalOutcome',
554
+ error: String(error),
555
+ recordId: props.id,
556
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
557
+ errorCategory: 'CONSTRAINT_VIOLATION',
558
+ isRetryable: false,
559
+ });
560
+ throw error;
561
+ }
444
562
  // Check if this is a database connection error that we should retry
445
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
446
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
447
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
448
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
449
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
563
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
564
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
565
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
566
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
567
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
450
568
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
451
569
  retryCount++;
452
570
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
453
- logger_1.logger.warn("Database connection error, retrying...");
571
+ logger_1.logger.warn("Database connection error in upsertOneSignalOutcome, retrying...", {
572
+ operation: 'upsertOneSignalOutcome',
573
+ model: 'SignalOutcome',
574
+ attempt: retryCount,
575
+ maxRetries: MAX_RETRIES,
576
+ recordId: props.id,
577
+ });
454
578
  await new Promise(resolve => setTimeout(resolve, delay));
455
579
  continue;
456
580
  }
457
- // Log the error and rethrow
458
- logger_1.logger.error("Database error occurred", { error: String(error) });
581
+ // Log structured error details and rethrow
582
+ logger_1.logger.error("Database upsert operation failed", {
583
+ operation: 'upsertOneSignalOutcome',
584
+ model: 'SignalOutcome',
585
+ error: String(error),
586
+ recordId: props.id,
587
+ isRetryable: isConnectionError,
588
+ });
459
589
  throw error;
460
590
  }
461
591
  }
@@ -470,7 +600,7 @@ exports.SignalOutcome = {
470
600
  * @returns The count of created records or null.
471
601
  */
472
602
  async updateMany(props, globalClient) {
473
- var _a, _b, _c, _d, _e;
603
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
474
604
  // Maximum number of retries for database connection issues
475
605
  const MAX_RETRIES = 3;
476
606
  let retryCount = 0;
@@ -567,21 +697,52 @@ exports.SignalOutcome = {
567
697
  }
568
698
  catch (error) {
569
699
  lastError = error;
700
+ // Check for constraint violations FIRST - these are NEVER retryable
701
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
702
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
703
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
704
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
705
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
706
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
707
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
708
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
709
+ if (isConstraintViolation) {
710
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
711
+ logger_1.logger.error("Non-retryable constraint violation in updateManySignalOutcome", {
712
+ operation: 'updateManySignalOutcome',
713
+ model: 'SignalOutcome',
714
+ error: String(error),
715
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
716
+ errorCategory: 'CONSTRAINT_VIOLATION',
717
+ isRetryable: false,
718
+ });
719
+ throw error;
720
+ }
570
721
  // Check if this is a database connection error that we should retry
571
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
572
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
573
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
574
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
575
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
722
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
723
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
724
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
725
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
726
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
576
727
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
577
728
  retryCount++;
578
729
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
579
- logger_1.logger.warn("Database connection error, retrying...");
730
+ logger_1.logger.warn("Database connection error in updateManySignalOutcome, retrying...", {
731
+ operation: 'updateManySignalOutcome',
732
+ model: 'SignalOutcome',
733
+ attempt: retryCount,
734
+ maxRetries: MAX_RETRIES,
735
+ });
580
736
  await new Promise(resolve => setTimeout(resolve, delay));
581
737
  continue;
582
738
  }
583
- // Log the error and rethrow
584
- logger_1.logger.error("Database error occurred", { error: String(error) });
739
+ // Log structured error details and rethrow
740
+ logger_1.logger.error("Database updateMany operation failed", {
741
+ operation: 'updateManySignalOutcome',
742
+ model: 'SignalOutcome',
743
+ error: String(error),
744
+ isRetryable: isConnectionError,
745
+ });
585
746
  throw error;
586
747
  }
587
748
  }
@@ -596,7 +757,7 @@ exports.SignalOutcome = {
596
757
  * @returns The deleted SignalOutcome or null.
597
758
  */
598
759
  async delete(props, globalClient) {
599
- var _a, _b, _c, _d, _e;
760
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
600
761
  // Maximum number of retries for database connection issues
601
762
  const MAX_RETRIES = 3;
602
763
  let retryCount = 0;
@@ -640,21 +801,58 @@ exports.SignalOutcome = {
640
801
  }
641
802
  catch (error) {
642
803
  lastError = error;
804
+ // Check for constraint violations FIRST - these are NEVER retryable
805
+ // (e.g., foreign key constraints preventing deletion)
806
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
807
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
808
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
809
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
810
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
811
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
812
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
813
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
814
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
815
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
816
+ if (isConstraintViolation) {
817
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
818
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneSignalOutcome", {
819
+ operation: 'deleteOneSignalOutcome',
820
+ model: 'SignalOutcome',
821
+ error: String(error),
822
+ recordId: props.id,
823
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
824
+ errorCategory: 'CONSTRAINT_VIOLATION',
825
+ isRetryable: false,
826
+ });
827
+ throw error;
828
+ }
643
829
  // Check if this is a database connection error that we should retry
644
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
645
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
646
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
647
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
648
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
830
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
831
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
832
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
833
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
834
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
649
835
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
650
836
  retryCount++;
651
837
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
652
- logger_1.logger.warn("Database connection error, retrying...");
838
+ logger_1.logger.warn("Database connection error in deleteOneSignalOutcome, retrying...", {
839
+ operation: 'deleteOneSignalOutcome',
840
+ model: 'SignalOutcome',
841
+ attempt: retryCount,
842
+ maxRetries: MAX_RETRIES,
843
+ recordId: props.id,
844
+ });
653
845
  await new Promise(resolve => setTimeout(resolve, delay));
654
846
  continue;
655
847
  }
656
- // Log the error and rethrow
657
- logger_1.logger.error("Database error occurred", { error: String(error) });
848
+ // Log structured error details and rethrow
849
+ logger_1.logger.error("Database delete operation failed", {
850
+ operation: 'deleteOneSignalOutcome',
851
+ model: 'SignalOutcome',
852
+ error: String(error),
853
+ recordId: props.id,
854
+ isRetryable: isConnectionError,
855
+ });
658
856
  throw error;
659
857
  }
660
858
  }
@@ -727,12 +925,22 @@ exports.SignalOutcome = {
727
925
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
728
926
  retryCount++;
729
927
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
730
- logger_1.logger.warn("Database connection error, retrying...");
928
+ logger_1.logger.warn("Database connection error in getSignalOutcome, retrying...", {
929
+ operation: 'getSignalOutcome',
930
+ model: 'SignalOutcome',
931
+ attempt: retryCount,
932
+ maxRetries: MAX_RETRIES,
933
+ });
731
934
  await new Promise(resolve => setTimeout(resolve, delay));
732
935
  continue;
733
936
  }
734
- // Log the error and rethrow
735
- logger_1.logger.error("Database error occurred", { error: String(error) });
937
+ // Log structured error details and rethrow
938
+ logger_1.logger.error("Database get operation failed", {
939
+ operation: 'getSignalOutcome',
940
+ model: 'SignalOutcome',
941
+ error: String(error),
942
+ isRetryable: isConnectionError,
943
+ });
736
944
  throw error;
737
945
  }
738
946
  }
@@ -790,12 +998,22 @@ exports.SignalOutcome = {
790
998
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
791
999
  retryCount++;
792
1000
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
793
- logger_1.logger.warn("Database connection error, retrying...");
1001
+ logger_1.logger.warn("Database connection error in getAllSignalOutcome, retrying...", {
1002
+ operation: 'getAllSignalOutcome',
1003
+ model: 'SignalOutcome',
1004
+ attempt: retryCount,
1005
+ maxRetries: MAX_RETRIES,
1006
+ });
794
1007
  await new Promise(resolve => setTimeout(resolve, delay));
795
1008
  continue;
796
1009
  }
797
- // Log the error and rethrow
798
- logger_1.logger.error("Database error occurred", { error: String(error) });
1010
+ // Log structured error details and rethrow
1011
+ logger_1.logger.error("Database getAll operation failed", {
1012
+ operation: 'getAllSignalOutcome',
1013
+ model: 'SignalOutcome',
1014
+ error: String(error),
1015
+ isRetryable: isConnectionError,
1016
+ });
799
1017
  throw error;
800
1018
  }
801
1019
  }
@@ -875,12 +1093,22 @@ exports.SignalOutcome = {
875
1093
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
876
1094
  retryCount++;
877
1095
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
878
- logger_1.logger.warn("Database connection error, retrying...");
1096
+ logger_1.logger.warn("Database connection error in findManySignalOutcome, retrying...", {
1097
+ operation: 'findManySignalOutcome',
1098
+ model: 'SignalOutcome',
1099
+ attempt: retryCount,
1100
+ maxRetries: MAX_RETRIES,
1101
+ });
879
1102
  await new Promise(resolve => setTimeout(resolve, delay));
880
1103
  continue;
881
1104
  }
882
- // Log the error and rethrow
883
- logger_1.logger.error("Database error occurred", { error: String(error) });
1105
+ // Log structured error details and rethrow
1106
+ logger_1.logger.error("Database findMany operation failed", {
1107
+ operation: 'findManySignalOutcome',
1108
+ model: 'SignalOutcome',
1109
+ error: String(error),
1110
+ isRetryable: isConnectionError,
1111
+ });
884
1112
  throw error;
885
1113
  }
886
1114
  }