@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.SignalPriorityQueue = {
46
46
  * @returns The created SignalPriorityQueue 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;
@@ -104,21 +104,52 @@ exports.SignalPriorityQueue = {
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 createOneSignalPriorityQueue", {
119
+ operation: 'createOneSignalPriorityQueue',
120
+ model: 'SignalPriorityQueue',
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 createOneSignalPriorityQueue, retrying...", {
138
+ operation: 'createOneSignalPriorityQueue',
139
+ model: 'SignalPriorityQueue',
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: 'createOneSignalPriorityQueue',
149
+ model: 'SignalPriorityQueue',
150
+ error: String(error),
151
+ isRetryable: isConnectionError,
152
+ });
122
153
  throw error;
123
154
  }
124
155
  }
@@ -133,7 +164,7 @@ exports.SignalPriorityQueue = {
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;
@@ -190,21 +221,52 @@ exports.SignalPriorityQueue = {
190
221
  }
191
222
  catch (error) {
192
223
  lastError = error;
224
+ // Check for constraint violations FIRST - these are NEVER retryable
225
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
226
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
227
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
228
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
229
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
230
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
231
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
232
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
233
+ if (isConstraintViolation) {
234
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
235
+ logger_1.logger.error("Non-retryable constraint violation in createManySignalPriorityQueue", {
236
+ operation: 'createManySignalPriorityQueue',
237
+ model: 'SignalPriorityQueue',
238
+ error: String(error),
239
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
240
+ errorCategory: 'CONSTRAINT_VIOLATION',
241
+ isRetryable: false,
242
+ });
243
+ throw error;
244
+ }
193
245
  // Check if this is a database connection error that we should retry
194
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
195
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
196
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
197
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
198
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
246
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
247
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
248
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
249
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
250
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
199
251
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
200
252
  retryCount++;
201
253
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
202
- logger_1.logger.warn("Database connection error, retrying...");
254
+ logger_1.logger.warn("Database connection error in createManySignalPriorityQueue, retrying...", {
255
+ operation: 'createManySignalPriorityQueue',
256
+ model: 'SignalPriorityQueue',
257
+ attempt: retryCount,
258
+ maxRetries: MAX_RETRIES,
259
+ });
203
260
  await new Promise(resolve => setTimeout(resolve, delay));
204
261
  continue;
205
262
  }
206
- // Log the error and rethrow
207
- logger_1.logger.error("Database error occurred", { error: String(error) });
263
+ // Log structured error details and rethrow
264
+ logger_1.logger.error("Database createMany operation failed", {
265
+ operation: 'createManySignalPriorityQueue',
266
+ model: 'SignalPriorityQueue',
267
+ error: String(error),
268
+ isRetryable: isConnectionError,
269
+ });
208
270
  throw error;
209
271
  }
210
272
  }
@@ -219,7 +281,7 @@ exports.SignalPriorityQueue = {
219
281
  * @returns The updated SignalPriorityQueue or null.
220
282
  */
221
283
  async update(props, globalClient) {
222
- var _a, _b, _c, _d, _e;
284
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
223
285
  // Maximum number of retries for database connection issues
224
286
  const MAX_RETRIES = 3;
225
287
  let retryCount = 0;
@@ -329,21 +391,55 @@ exports.SignalPriorityQueue = {
329
391
  }
330
392
  catch (error) {
331
393
  lastError = error;
394
+ // Check for constraint violations FIRST - these are NEVER retryable
395
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
396
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
397
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
398
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
399
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
400
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
401
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
402
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
403
+ if (isConstraintViolation) {
404
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
405
+ logger_1.logger.error("Non-retryable constraint violation in updateOneSignalPriorityQueue", {
406
+ operation: 'updateOneSignalPriorityQueue',
407
+ model: 'SignalPriorityQueue',
408
+ error: String(error),
409
+ recordId: props.id,
410
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
411
+ errorCategory: 'CONSTRAINT_VIOLATION',
412
+ isRetryable: false,
413
+ });
414
+ throw error;
415
+ }
332
416
  // Check if this is a database connection error that we should retry
333
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
334
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
335
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
336
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
337
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
417
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
418
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
419
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
420
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
421
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
338
422
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
339
423
  retryCount++;
340
424
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
341
- logger_1.logger.warn("Database connection error, retrying...");
425
+ logger_1.logger.warn("Database connection error in updateOneSignalPriorityQueue, retrying...", {
426
+ operation: 'updateOneSignalPriorityQueue',
427
+ model: 'SignalPriorityQueue',
428
+ attempt: retryCount,
429
+ maxRetries: MAX_RETRIES,
430
+ recordId: props.id,
431
+ });
342
432
  await new Promise(resolve => setTimeout(resolve, delay));
343
433
  continue;
344
434
  }
345
- // Log the error and rethrow
346
- logger_1.logger.error("Database error occurred", { error: String(error) });
435
+ // Log structured error details and rethrow
436
+ logger_1.logger.error("Database update operation failed", {
437
+ operation: 'updateOneSignalPriorityQueue',
438
+ model: 'SignalPriorityQueue',
439
+ error: String(error),
440
+ recordId: props.id,
441
+ isRetryable: isConnectionError,
442
+ });
347
443
  throw error;
348
444
  }
349
445
  }
@@ -358,7 +454,7 @@ exports.SignalPriorityQueue = {
358
454
  * @returns The updated SignalPriorityQueue or null.
359
455
  */
360
456
  async upsert(props, globalClient) {
361
- var _a, _b, _c, _d, _e;
457
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
362
458
  // Maximum number of retries for database connection issues
363
459
  const MAX_RETRIES = 3;
364
460
  let retryCount = 0;
@@ -478,21 +574,55 @@ exports.SignalPriorityQueue = {
478
574
  }
479
575
  catch (error) {
480
576
  lastError = error;
577
+ // Check for constraint violations FIRST - these are NEVER retryable
578
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
579
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
580
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
581
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
582
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
583
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
584
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
585
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
586
+ if (isConstraintViolation) {
587
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
588
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneSignalPriorityQueue", {
589
+ operation: 'upsertOneSignalPriorityQueue',
590
+ model: 'SignalPriorityQueue',
591
+ error: String(error),
592
+ recordId: props.id,
593
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
594
+ errorCategory: 'CONSTRAINT_VIOLATION',
595
+ isRetryable: false,
596
+ });
597
+ throw error;
598
+ }
481
599
  // Check if this is a database connection error that we should retry
482
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
483
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
484
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
485
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
486
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
600
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
601
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
602
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
603
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
604
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
487
605
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
488
606
  retryCount++;
489
607
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
490
- logger_1.logger.warn("Database connection error, retrying...");
608
+ logger_1.logger.warn("Database connection error in upsertOneSignalPriorityQueue, retrying...", {
609
+ operation: 'upsertOneSignalPriorityQueue',
610
+ model: 'SignalPriorityQueue',
611
+ attempt: retryCount,
612
+ maxRetries: MAX_RETRIES,
613
+ recordId: props.id,
614
+ });
491
615
  await new Promise(resolve => setTimeout(resolve, delay));
492
616
  continue;
493
617
  }
494
- // Log the error and rethrow
495
- logger_1.logger.error("Database error occurred", { error: String(error) });
618
+ // Log structured error details and rethrow
619
+ logger_1.logger.error("Database upsert operation failed", {
620
+ operation: 'upsertOneSignalPriorityQueue',
621
+ model: 'SignalPriorityQueue',
622
+ error: String(error),
623
+ recordId: props.id,
624
+ isRetryable: isConnectionError,
625
+ });
496
626
  throw error;
497
627
  }
498
628
  }
@@ -507,7 +637,7 @@ exports.SignalPriorityQueue = {
507
637
  * @returns The count of created records or null.
508
638
  */
509
639
  async updateMany(props, globalClient) {
510
- var _a, _b, _c, _d, _e;
640
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
511
641
  // Maximum number of retries for database connection issues
512
642
  const MAX_RETRIES = 3;
513
643
  let retryCount = 0;
@@ -617,21 +747,52 @@ exports.SignalPriorityQueue = {
617
747
  }
618
748
  catch (error) {
619
749
  lastError = error;
750
+ // Check for constraint violations FIRST - these are NEVER retryable
751
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
752
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
753
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
754
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
755
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
756
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
757
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
758
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
759
+ if (isConstraintViolation) {
760
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
761
+ logger_1.logger.error("Non-retryable constraint violation in updateManySignalPriorityQueue", {
762
+ operation: 'updateManySignalPriorityQueue',
763
+ model: 'SignalPriorityQueue',
764
+ error: String(error),
765
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
766
+ errorCategory: 'CONSTRAINT_VIOLATION',
767
+ isRetryable: false,
768
+ });
769
+ throw error;
770
+ }
620
771
  // Check if this is a database connection error that we should retry
621
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
622
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
623
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
624
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
625
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
772
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
773
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
774
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
775
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
776
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
626
777
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
627
778
  retryCount++;
628
779
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
629
- logger_1.logger.warn("Database connection error, retrying...");
780
+ logger_1.logger.warn("Database connection error in updateManySignalPriorityQueue, retrying...", {
781
+ operation: 'updateManySignalPriorityQueue',
782
+ model: 'SignalPriorityQueue',
783
+ attempt: retryCount,
784
+ maxRetries: MAX_RETRIES,
785
+ });
630
786
  await new Promise(resolve => setTimeout(resolve, delay));
631
787
  continue;
632
788
  }
633
- // Log the error and rethrow
634
- logger_1.logger.error("Database error occurred", { error: String(error) });
789
+ // Log structured error details and rethrow
790
+ logger_1.logger.error("Database updateMany operation failed", {
791
+ operation: 'updateManySignalPriorityQueue',
792
+ model: 'SignalPriorityQueue',
793
+ error: String(error),
794
+ isRetryable: isConnectionError,
795
+ });
635
796
  throw error;
636
797
  }
637
798
  }
@@ -646,7 +807,7 @@ exports.SignalPriorityQueue = {
646
807
  * @returns The deleted SignalPriorityQueue or null.
647
808
  */
648
809
  async delete(props, globalClient) {
649
- var _a, _b, _c, _d, _e;
810
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
650
811
  // Maximum number of retries for database connection issues
651
812
  const MAX_RETRIES = 3;
652
813
  let retryCount = 0;
@@ -690,21 +851,58 @@ exports.SignalPriorityQueue = {
690
851
  }
691
852
  catch (error) {
692
853
  lastError = error;
854
+ // Check for constraint violations FIRST - these are NEVER retryable
855
+ // (e.g., foreign key constraints preventing deletion)
856
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
857
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
858
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
859
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
860
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
861
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
862
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
863
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
864
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
865
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
866
+ if (isConstraintViolation) {
867
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
868
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneSignalPriorityQueue", {
869
+ operation: 'deleteOneSignalPriorityQueue',
870
+ model: 'SignalPriorityQueue',
871
+ error: String(error),
872
+ recordId: props.id,
873
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
874
+ errorCategory: 'CONSTRAINT_VIOLATION',
875
+ isRetryable: false,
876
+ });
877
+ throw error;
878
+ }
693
879
  // Check if this is a database connection error that we should retry
694
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
695
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
696
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
697
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
698
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
880
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
881
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
882
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
883
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
884
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
699
885
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
700
886
  retryCount++;
701
887
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
702
- logger_1.logger.warn("Database connection error, retrying...");
888
+ logger_1.logger.warn("Database connection error in deleteOneSignalPriorityQueue, retrying...", {
889
+ operation: 'deleteOneSignalPriorityQueue',
890
+ model: 'SignalPriorityQueue',
891
+ attempt: retryCount,
892
+ maxRetries: MAX_RETRIES,
893
+ recordId: props.id,
894
+ });
703
895
  await new Promise(resolve => setTimeout(resolve, delay));
704
896
  continue;
705
897
  }
706
- // Log the error and rethrow
707
- logger_1.logger.error("Database error occurred", { error: String(error) });
898
+ // Log structured error details and rethrow
899
+ logger_1.logger.error("Database delete operation failed", {
900
+ operation: 'deleteOneSignalPriorityQueue',
901
+ model: 'SignalPriorityQueue',
902
+ error: String(error),
903
+ recordId: props.id,
904
+ isRetryable: isConnectionError,
905
+ });
708
906
  throw error;
709
907
  }
710
908
  }
@@ -775,12 +973,22 @@ exports.SignalPriorityQueue = {
775
973
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
776
974
  retryCount++;
777
975
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
778
- logger_1.logger.warn("Database connection error, retrying...");
976
+ logger_1.logger.warn("Database connection error in getSignalPriorityQueue, retrying...", {
977
+ operation: 'getSignalPriorityQueue',
978
+ model: 'SignalPriorityQueue',
979
+ attempt: retryCount,
980
+ maxRetries: MAX_RETRIES,
981
+ });
779
982
  await new Promise(resolve => setTimeout(resolve, delay));
780
983
  continue;
781
984
  }
782
- // Log the error and rethrow
783
- logger_1.logger.error("Database error occurred", { error: String(error) });
985
+ // Log structured error details and rethrow
986
+ logger_1.logger.error("Database get operation failed", {
987
+ operation: 'getSignalPriorityQueue',
988
+ model: 'SignalPriorityQueue',
989
+ error: String(error),
990
+ isRetryable: isConnectionError,
991
+ });
784
992
  throw error;
785
993
  }
786
994
  }
@@ -838,12 +1046,22 @@ exports.SignalPriorityQueue = {
838
1046
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
839
1047
  retryCount++;
840
1048
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
841
- logger_1.logger.warn("Database connection error, retrying...");
1049
+ logger_1.logger.warn("Database connection error in getAllSignalPriorityQueue, retrying...", {
1050
+ operation: 'getAllSignalPriorityQueue',
1051
+ model: 'SignalPriorityQueue',
1052
+ attempt: retryCount,
1053
+ maxRetries: MAX_RETRIES,
1054
+ });
842
1055
  await new Promise(resolve => setTimeout(resolve, delay));
843
1056
  continue;
844
1057
  }
845
- // Log the error and rethrow
846
- logger_1.logger.error("Database error occurred", { error: String(error) });
1058
+ // Log structured error details and rethrow
1059
+ logger_1.logger.error("Database getAll operation failed", {
1060
+ operation: 'getAllSignalPriorityQueue',
1061
+ model: 'SignalPriorityQueue',
1062
+ error: String(error),
1063
+ isRetryable: isConnectionError,
1064
+ });
847
1065
  throw error;
848
1066
  }
849
1067
  }
@@ -923,12 +1141,22 @@ exports.SignalPriorityQueue = {
923
1141
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
924
1142
  retryCount++;
925
1143
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
926
- logger_1.logger.warn("Database connection error, retrying...");
1144
+ logger_1.logger.warn("Database connection error in findManySignalPriorityQueue, retrying...", {
1145
+ operation: 'findManySignalPriorityQueue',
1146
+ model: 'SignalPriorityQueue',
1147
+ attempt: retryCount,
1148
+ maxRetries: MAX_RETRIES,
1149
+ });
927
1150
  await new Promise(resolve => setTimeout(resolve, delay));
928
1151
  continue;
929
1152
  }
930
- // Log the error and rethrow
931
- logger_1.logger.error("Database error occurred", { error: String(error) });
1153
+ // Log structured error details and rethrow
1154
+ logger_1.logger.error("Database findMany operation failed", {
1155
+ operation: 'findManySignalPriorityQueue',
1156
+ model: 'SignalPriorityQueue',
1157
+ error: String(error),
1158
+ isRetryable: isConnectionError,
1159
+ });
932
1160
  throw error;
933
1161
  }
934
1162
  }