@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
@@ -38,7 +38,7 @@ exports.InstitutionalSentimentAlerts = {
38
38
  * @returns The created InstitutionalSentimentAlerts or null.
39
39
  */
40
40
  async create(props, globalClient) {
41
- var _a, _b, _c, _d, _e;
41
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
42
42
  // Maximum number of retries for database connection issues
43
43
  const MAX_RETRIES = 3;
44
44
  let retryCount = 0;
@@ -91,21 +91,52 @@ exports.InstitutionalSentimentAlerts = {
91
91
  }
92
92
  catch (error) {
93
93
  lastError = error;
94
+ // Check for constraint violations FIRST - these are NEVER retryable
95
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
96
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
97
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
98
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
99
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
100
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
101
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
102
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
103
+ if (isConstraintViolation) {
104
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
105
+ logger_1.logger.error("Non-retryable constraint violation in createOneInstitutionalSentimentAlerts", {
106
+ operation: 'createOneInstitutionalSentimentAlerts',
107
+ model: 'InstitutionalSentimentAlerts',
108
+ error: String(error),
109
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
110
+ errorCategory: 'CONSTRAINT_VIOLATION',
111
+ isRetryable: false,
112
+ });
113
+ throw error;
114
+ }
94
115
  // Check if this is a database connection error that we should retry
95
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
96
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
97
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
98
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
99
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
116
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
117
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
118
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
119
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
120
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
100
121
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
101
122
  retryCount++;
102
123
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
103
- logger_1.logger.warn("Database connection error, retrying...");
124
+ logger_1.logger.warn("Database connection error in createOneInstitutionalSentimentAlerts, retrying...", {
125
+ operation: 'createOneInstitutionalSentimentAlerts',
126
+ model: 'InstitutionalSentimentAlerts',
127
+ attempt: retryCount,
128
+ maxRetries: MAX_RETRIES,
129
+ });
104
130
  await new Promise(resolve => setTimeout(resolve, delay));
105
131
  continue;
106
132
  }
107
- // Log the error and rethrow
108
- logger_1.logger.error("Database error occurred", { error: String(error) });
133
+ // Log structured error details and rethrow
134
+ logger_1.logger.error("Database create operation failed", {
135
+ operation: 'createOneInstitutionalSentimentAlerts',
136
+ model: 'InstitutionalSentimentAlerts',
137
+ error: String(error),
138
+ isRetryable: isConnectionError,
139
+ });
109
140
  throw error;
110
141
  }
111
142
  }
@@ -120,7 +151,7 @@ exports.InstitutionalSentimentAlerts = {
120
151
  * @returns The count of created records or null.
121
152
  */
122
153
  async createMany(props, globalClient) {
123
- var _a, _b, _c, _d, _e;
154
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
124
155
  // Maximum number of retries for database connection issues
125
156
  const MAX_RETRIES = 3;
126
157
  let retryCount = 0;
@@ -172,21 +203,52 @@ exports.InstitutionalSentimentAlerts = {
172
203
  }
173
204
  catch (error) {
174
205
  lastError = error;
206
+ // Check for constraint violations FIRST - these are NEVER retryable
207
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
208
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
209
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
210
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
211
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
212
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
213
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
214
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
215
+ if (isConstraintViolation) {
216
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
217
+ logger_1.logger.error("Non-retryable constraint violation in createManyInstitutionalSentimentAlerts", {
218
+ operation: 'createManyInstitutionalSentimentAlerts',
219
+ model: 'InstitutionalSentimentAlerts',
220
+ error: String(error),
221
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
222
+ errorCategory: 'CONSTRAINT_VIOLATION',
223
+ isRetryable: false,
224
+ });
225
+ throw error;
226
+ }
175
227
  // Check if this is a database connection error that we should retry
176
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
177
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
178
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
179
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
180
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
228
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
229
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
230
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
231
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
232
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
181
233
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
182
234
  retryCount++;
183
235
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
184
- logger_1.logger.warn("Database connection error, retrying...");
236
+ logger_1.logger.warn("Database connection error in createManyInstitutionalSentimentAlerts, retrying...", {
237
+ operation: 'createManyInstitutionalSentimentAlerts',
238
+ model: 'InstitutionalSentimentAlerts',
239
+ attempt: retryCount,
240
+ maxRetries: MAX_RETRIES,
241
+ });
185
242
  await new Promise(resolve => setTimeout(resolve, delay));
186
243
  continue;
187
244
  }
188
- // Log the error and rethrow
189
- logger_1.logger.error("Database error occurred", { error: String(error) });
245
+ // Log structured error details and rethrow
246
+ logger_1.logger.error("Database createMany operation failed", {
247
+ operation: 'createManyInstitutionalSentimentAlerts',
248
+ model: 'InstitutionalSentimentAlerts',
249
+ error: String(error),
250
+ isRetryable: isConnectionError,
251
+ });
190
252
  throw error;
191
253
  }
192
254
  }
@@ -201,7 +263,7 @@ exports.InstitutionalSentimentAlerts = {
201
263
  * @returns The updated InstitutionalSentimentAlerts or null.
202
264
  */
203
265
  async update(props, globalClient) {
204
- var _a, _b, _c, _d, _e;
266
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
205
267
  // Maximum number of retries for database connection issues
206
268
  const MAX_RETRIES = 3;
207
269
  let retryCount = 0;
@@ -283,21 +345,55 @@ exports.InstitutionalSentimentAlerts = {
283
345
  }
284
346
  catch (error) {
285
347
  lastError = error;
348
+ // Check for constraint violations FIRST - these are NEVER retryable
349
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
350
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
351
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
352
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
353
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
354
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
355
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
356
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
357
+ if (isConstraintViolation) {
358
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
359
+ logger_1.logger.error("Non-retryable constraint violation in updateOneInstitutionalSentimentAlerts", {
360
+ operation: 'updateOneInstitutionalSentimentAlerts',
361
+ model: 'InstitutionalSentimentAlerts',
362
+ error: String(error),
363
+ recordId: props.id,
364
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
365
+ errorCategory: 'CONSTRAINT_VIOLATION',
366
+ isRetryable: false,
367
+ });
368
+ throw error;
369
+ }
286
370
  // Check if this is a database connection error that we should retry
287
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
288
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
289
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
290
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
291
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
371
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
372
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
373
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
374
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
375
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
292
376
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
293
377
  retryCount++;
294
378
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
295
- logger_1.logger.warn("Database connection error, retrying...");
379
+ logger_1.logger.warn("Database connection error in updateOneInstitutionalSentimentAlerts, retrying...", {
380
+ operation: 'updateOneInstitutionalSentimentAlerts',
381
+ model: 'InstitutionalSentimentAlerts',
382
+ attempt: retryCount,
383
+ maxRetries: MAX_RETRIES,
384
+ recordId: props.id,
385
+ });
296
386
  await new Promise(resolve => setTimeout(resolve, delay));
297
387
  continue;
298
388
  }
299
- // Log the error and rethrow
300
- logger_1.logger.error("Database error occurred", { error: String(error) });
389
+ // Log structured error details and rethrow
390
+ logger_1.logger.error("Database update operation failed", {
391
+ operation: 'updateOneInstitutionalSentimentAlerts',
392
+ model: 'InstitutionalSentimentAlerts',
393
+ error: String(error),
394
+ recordId: props.id,
395
+ isRetryable: isConnectionError,
396
+ });
301
397
  throw error;
302
398
  }
303
399
  }
@@ -312,7 +408,7 @@ exports.InstitutionalSentimentAlerts = {
312
408
  * @returns The updated InstitutionalSentimentAlerts or null.
313
409
  */
314
410
  async upsert(props, globalClient) {
315
- var _a, _b, _c, _d, _e;
411
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
316
412
  // Maximum number of retries for database connection issues
317
413
  const MAX_RETRIES = 3;
318
414
  let retryCount = 0;
@@ -396,21 +492,55 @@ exports.InstitutionalSentimentAlerts = {
396
492
  }
397
493
  catch (error) {
398
494
  lastError = error;
495
+ // Check for constraint violations FIRST - these are NEVER retryable
496
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
497
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
498
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
499
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
500
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
501
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
502
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
503
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
504
+ if (isConstraintViolation) {
505
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
506
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneInstitutionalSentimentAlerts", {
507
+ operation: 'upsertOneInstitutionalSentimentAlerts',
508
+ model: 'InstitutionalSentimentAlerts',
509
+ error: String(error),
510
+ recordId: props.id,
511
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
512
+ errorCategory: 'CONSTRAINT_VIOLATION',
513
+ isRetryable: false,
514
+ });
515
+ throw error;
516
+ }
399
517
  // Check if this is a database connection error that we should retry
400
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
401
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
402
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
403
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
404
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
518
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
519
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
520
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
521
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
522
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
405
523
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
406
524
  retryCount++;
407
525
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
408
- logger_1.logger.warn("Database connection error, retrying...");
526
+ logger_1.logger.warn("Database connection error in upsertOneInstitutionalSentimentAlerts, retrying...", {
527
+ operation: 'upsertOneInstitutionalSentimentAlerts',
528
+ model: 'InstitutionalSentimentAlerts',
529
+ attempt: retryCount,
530
+ maxRetries: MAX_RETRIES,
531
+ recordId: props.id,
532
+ });
409
533
  await new Promise(resolve => setTimeout(resolve, delay));
410
534
  continue;
411
535
  }
412
- // Log the error and rethrow
413
- logger_1.logger.error("Database error occurred", { error: String(error) });
536
+ // Log structured error details and rethrow
537
+ logger_1.logger.error("Database upsert operation failed", {
538
+ operation: 'upsertOneInstitutionalSentimentAlerts',
539
+ model: 'InstitutionalSentimentAlerts',
540
+ error: String(error),
541
+ recordId: props.id,
542
+ isRetryable: isConnectionError,
543
+ });
414
544
  throw error;
415
545
  }
416
546
  }
@@ -425,7 +555,7 @@ exports.InstitutionalSentimentAlerts = {
425
555
  * @returns The count of created records or null.
426
556
  */
427
557
  async updateMany(props, globalClient) {
428
- var _a, _b, _c, _d, _e;
558
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
429
559
  // Maximum number of retries for database connection issues
430
560
  const MAX_RETRIES = 3;
431
561
  let retryCount = 0;
@@ -507,21 +637,52 @@ exports.InstitutionalSentimentAlerts = {
507
637
  }
508
638
  catch (error) {
509
639
  lastError = error;
640
+ // Check for constraint violations FIRST - these are NEVER retryable
641
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
642
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
643
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
644
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
645
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
646
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
647
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
648
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
649
+ if (isConstraintViolation) {
650
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
651
+ logger_1.logger.error("Non-retryable constraint violation in updateManyInstitutionalSentimentAlerts", {
652
+ operation: 'updateManyInstitutionalSentimentAlerts',
653
+ model: 'InstitutionalSentimentAlerts',
654
+ error: String(error),
655
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
656
+ errorCategory: 'CONSTRAINT_VIOLATION',
657
+ isRetryable: false,
658
+ });
659
+ throw error;
660
+ }
510
661
  // Check if this is a database connection error that we should retry
511
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
512
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
513
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
514
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
515
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
662
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
663
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
664
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
665
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
666
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
516
667
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
517
668
  retryCount++;
518
669
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
519
- logger_1.logger.warn("Database connection error, retrying...");
670
+ logger_1.logger.warn("Database connection error in updateManyInstitutionalSentimentAlerts, retrying...", {
671
+ operation: 'updateManyInstitutionalSentimentAlerts',
672
+ model: 'InstitutionalSentimentAlerts',
673
+ attempt: retryCount,
674
+ maxRetries: MAX_RETRIES,
675
+ });
520
676
  await new Promise(resolve => setTimeout(resolve, delay));
521
677
  continue;
522
678
  }
523
- // Log the error and rethrow
524
- logger_1.logger.error("Database error occurred", { error: String(error) });
679
+ // Log structured error details and rethrow
680
+ logger_1.logger.error("Database updateMany operation failed", {
681
+ operation: 'updateManyInstitutionalSentimentAlerts',
682
+ model: 'InstitutionalSentimentAlerts',
683
+ error: String(error),
684
+ isRetryable: isConnectionError,
685
+ });
525
686
  throw error;
526
687
  }
527
688
  }
@@ -536,7 +697,7 @@ exports.InstitutionalSentimentAlerts = {
536
697
  * @returns The deleted InstitutionalSentimentAlerts or null.
537
698
  */
538
699
  async delete(props, globalClient) {
539
- var _a, _b, _c, _d, _e;
700
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
540
701
  // Maximum number of retries for database connection issues
541
702
  const MAX_RETRIES = 3;
542
703
  let retryCount = 0;
@@ -580,21 +741,58 @@ exports.InstitutionalSentimentAlerts = {
580
741
  }
581
742
  catch (error) {
582
743
  lastError = error;
744
+ // Check for constraint violations FIRST - these are NEVER retryable
745
+ // (e.g., foreign key constraints preventing deletion)
746
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
747
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
748
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
749
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
750
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
751
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
752
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
753
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
754
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
755
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
756
+ if (isConstraintViolation) {
757
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
758
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneInstitutionalSentimentAlerts", {
759
+ operation: 'deleteOneInstitutionalSentimentAlerts',
760
+ model: 'InstitutionalSentimentAlerts',
761
+ error: String(error),
762
+ recordId: props.id,
763
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
764
+ errorCategory: 'CONSTRAINT_VIOLATION',
765
+ isRetryable: false,
766
+ });
767
+ throw error;
768
+ }
583
769
  // Check if this is a database connection error that we should retry
584
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
585
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
586
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
587
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
588
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
770
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
771
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
772
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
773
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
774
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
589
775
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
590
776
  retryCount++;
591
777
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
592
- logger_1.logger.warn("Database connection error, retrying...");
778
+ logger_1.logger.warn("Database connection error in deleteOneInstitutionalSentimentAlerts, retrying...", {
779
+ operation: 'deleteOneInstitutionalSentimentAlerts',
780
+ model: 'InstitutionalSentimentAlerts',
781
+ attempt: retryCount,
782
+ maxRetries: MAX_RETRIES,
783
+ recordId: props.id,
784
+ });
593
785
  await new Promise(resolve => setTimeout(resolve, delay));
594
786
  continue;
595
787
  }
596
- // Log the error and rethrow
597
- logger_1.logger.error("Database error occurred", { error: String(error) });
788
+ // Log structured error details and rethrow
789
+ logger_1.logger.error("Database delete operation failed", {
790
+ operation: 'deleteOneInstitutionalSentimentAlerts',
791
+ model: 'InstitutionalSentimentAlerts',
792
+ error: String(error),
793
+ recordId: props.id,
794
+ isRetryable: isConnectionError,
795
+ });
598
796
  throw error;
599
797
  }
600
798
  }
@@ -661,12 +859,22 @@ exports.InstitutionalSentimentAlerts = {
661
859
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
662
860
  retryCount++;
663
861
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
664
- logger_1.logger.warn("Database connection error, retrying...");
862
+ logger_1.logger.warn("Database connection error in getInstitutionalSentimentAlerts, retrying...", {
863
+ operation: 'getInstitutionalSentimentAlerts',
864
+ model: 'InstitutionalSentimentAlerts',
865
+ attempt: retryCount,
866
+ maxRetries: MAX_RETRIES,
867
+ });
665
868
  await new Promise(resolve => setTimeout(resolve, delay));
666
869
  continue;
667
870
  }
668
- // Log the error and rethrow
669
- logger_1.logger.error("Database error occurred", { error: String(error) });
871
+ // Log structured error details and rethrow
872
+ logger_1.logger.error("Database get operation failed", {
873
+ operation: 'getInstitutionalSentimentAlerts',
874
+ model: 'InstitutionalSentimentAlerts',
875
+ error: String(error),
876
+ isRetryable: isConnectionError,
877
+ });
670
878
  throw error;
671
879
  }
672
880
  }
@@ -724,12 +932,22 @@ exports.InstitutionalSentimentAlerts = {
724
932
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
725
933
  retryCount++;
726
934
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
727
- logger_1.logger.warn("Database connection error, retrying...");
935
+ logger_1.logger.warn("Database connection error in getAllInstitutionalSentimentAlerts, retrying...", {
936
+ operation: 'getAllInstitutionalSentimentAlerts',
937
+ model: 'InstitutionalSentimentAlerts',
938
+ attempt: retryCount,
939
+ maxRetries: MAX_RETRIES,
940
+ });
728
941
  await new Promise(resolve => setTimeout(resolve, delay));
729
942
  continue;
730
943
  }
731
- // Log the error and rethrow
732
- logger_1.logger.error("Database error occurred", { error: String(error) });
944
+ // Log structured error details and rethrow
945
+ logger_1.logger.error("Database getAll operation failed", {
946
+ operation: 'getAllInstitutionalSentimentAlerts',
947
+ model: 'InstitutionalSentimentAlerts',
948
+ error: String(error),
949
+ isRetryable: isConnectionError,
950
+ });
733
951
  throw error;
734
952
  }
735
953
  }
@@ -803,12 +1021,22 @@ exports.InstitutionalSentimentAlerts = {
803
1021
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
804
1022
  retryCount++;
805
1023
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
806
- logger_1.logger.warn("Database connection error, retrying...");
1024
+ logger_1.logger.warn("Database connection error in findManyInstitutionalSentimentAlerts, retrying...", {
1025
+ operation: 'findManyInstitutionalSentimentAlerts',
1026
+ model: 'InstitutionalSentimentAlerts',
1027
+ attempt: retryCount,
1028
+ maxRetries: MAX_RETRIES,
1029
+ });
807
1030
  await new Promise(resolve => setTimeout(resolve, delay));
808
1031
  continue;
809
1032
  }
810
- // Log the error and rethrow
811
- logger_1.logger.error("Database error occurred", { error: String(error) });
1033
+ // Log structured error details and rethrow
1034
+ logger_1.logger.error("Database findMany operation failed", {
1035
+ operation: 'findManyInstitutionalSentimentAlerts',
1036
+ model: 'InstitutionalSentimentAlerts',
1037
+ error: String(error),
1038
+ isRetryable: isConnectionError,
1039
+ });
812
1040
  throw error;
813
1041
  }
814
1042
  }