@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
@@ -35,7 +35,7 @@ exports.InstitutionalSentimentMetrics = {
35
35
  * @returns The created InstitutionalSentimentMetrics or null.
36
36
  */
37
37
  async create(props, globalClient) {
38
- var _a, _b, _c, _d, _e;
38
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
39
39
  // Maximum number of retries for database connection issues
40
40
  const MAX_RETRIES = 3;
41
41
  let retryCount = 0;
@@ -86,21 +86,52 @@ exports.InstitutionalSentimentMetrics = {
86
86
  }
87
87
  catch (error) {
88
88
  lastError = error;
89
+ // Check for constraint violations FIRST - these are NEVER retryable
90
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
91
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
92
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
93
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
94
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
95
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
96
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
97
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
98
+ if (isConstraintViolation) {
99
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
100
+ logger_1.logger.error("Non-retryable constraint violation in createOneInstitutionalSentimentMetrics", {
101
+ operation: 'createOneInstitutionalSentimentMetrics',
102
+ model: 'InstitutionalSentimentMetrics',
103
+ error: String(error),
104
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
105
+ errorCategory: 'CONSTRAINT_VIOLATION',
106
+ isRetryable: false,
107
+ });
108
+ throw error;
109
+ }
89
110
  // Check if this is a database connection error that we should retry
90
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
91
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
92
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
93
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
94
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
111
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
112
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
113
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
114
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
115
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
95
116
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
96
117
  retryCount++;
97
118
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
98
- logger_1.logger.warn("Database connection error, retrying...");
119
+ logger_1.logger.warn("Database connection error in createOneInstitutionalSentimentMetrics, retrying...", {
120
+ operation: 'createOneInstitutionalSentimentMetrics',
121
+ model: 'InstitutionalSentimentMetrics',
122
+ attempt: retryCount,
123
+ maxRetries: MAX_RETRIES,
124
+ });
99
125
  await new Promise(resolve => setTimeout(resolve, delay));
100
126
  continue;
101
127
  }
102
- // Log the error and rethrow
103
- logger_1.logger.error("Database error occurred", { error: String(error) });
128
+ // Log structured error details and rethrow
129
+ logger_1.logger.error("Database create operation failed", {
130
+ operation: 'createOneInstitutionalSentimentMetrics',
131
+ model: 'InstitutionalSentimentMetrics',
132
+ error: String(error),
133
+ isRetryable: isConnectionError,
134
+ });
104
135
  throw error;
105
136
  }
106
137
  }
@@ -115,7 +146,7 @@ exports.InstitutionalSentimentMetrics = {
115
146
  * @returns The count of created records or null.
116
147
  */
117
148
  async createMany(props, globalClient) {
118
- var _a, _b, _c, _d, _e;
149
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
119
150
  // Maximum number of retries for database connection issues
120
151
  const MAX_RETRIES = 3;
121
152
  let retryCount = 0;
@@ -165,21 +196,52 @@ exports.InstitutionalSentimentMetrics = {
165
196
  }
166
197
  catch (error) {
167
198
  lastError = error;
199
+ // Check for constraint violations FIRST - these are NEVER retryable
200
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
201
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
202
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
203
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
204
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
205
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
206
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
207
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
208
+ if (isConstraintViolation) {
209
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
210
+ logger_1.logger.error("Non-retryable constraint violation in createManyInstitutionalSentimentMetrics", {
211
+ operation: 'createManyInstitutionalSentimentMetrics',
212
+ model: 'InstitutionalSentimentMetrics',
213
+ error: String(error),
214
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
215
+ errorCategory: 'CONSTRAINT_VIOLATION',
216
+ isRetryable: false,
217
+ });
218
+ throw error;
219
+ }
168
220
  // Check if this is a database connection error that we should retry
169
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
170
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
171
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
172
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
173
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
221
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
222
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
223
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
224
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
225
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
174
226
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
175
227
  retryCount++;
176
228
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
177
- logger_1.logger.warn("Database connection error, retrying...");
229
+ logger_1.logger.warn("Database connection error in createManyInstitutionalSentimentMetrics, retrying...", {
230
+ operation: 'createManyInstitutionalSentimentMetrics',
231
+ model: 'InstitutionalSentimentMetrics',
232
+ attempt: retryCount,
233
+ maxRetries: MAX_RETRIES,
234
+ });
178
235
  await new Promise(resolve => setTimeout(resolve, delay));
179
236
  continue;
180
237
  }
181
- // Log the error and rethrow
182
- logger_1.logger.error("Database error occurred", { error: String(error) });
238
+ // Log structured error details and rethrow
239
+ logger_1.logger.error("Database createMany operation failed", {
240
+ operation: 'createManyInstitutionalSentimentMetrics',
241
+ model: 'InstitutionalSentimentMetrics',
242
+ error: String(error),
243
+ isRetryable: isConnectionError,
244
+ });
183
245
  throw error;
184
246
  }
185
247
  }
@@ -194,7 +256,7 @@ exports.InstitutionalSentimentMetrics = {
194
256
  * @returns The updated InstitutionalSentimentMetrics or null.
195
257
  */
196
258
  async update(props, globalClient) {
197
- var _a, _b, _c, _d, _e;
259
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
198
260
  // Maximum number of retries for database connection issues
199
261
  const MAX_RETRIES = 3;
200
262
  let retryCount = 0;
@@ -267,21 +329,55 @@ exports.InstitutionalSentimentMetrics = {
267
329
  }
268
330
  catch (error) {
269
331
  lastError = error;
332
+ // Check for constraint violations FIRST - these are NEVER retryable
333
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
334
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
335
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
336
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
337
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
338
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
339
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
340
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
341
+ if (isConstraintViolation) {
342
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
343
+ logger_1.logger.error("Non-retryable constraint violation in updateOneInstitutionalSentimentMetrics", {
344
+ operation: 'updateOneInstitutionalSentimentMetrics',
345
+ model: 'InstitutionalSentimentMetrics',
346
+ error: String(error),
347
+ recordId: props.id,
348
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
349
+ errorCategory: 'CONSTRAINT_VIOLATION',
350
+ isRetryable: false,
351
+ });
352
+ throw error;
353
+ }
270
354
  // Check if this is a database connection error that we should retry
271
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
272
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
273
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
274
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
275
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
355
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
356
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
357
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
358
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
359
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
276
360
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
277
361
  retryCount++;
278
362
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
279
- logger_1.logger.warn("Database connection error, retrying...");
363
+ logger_1.logger.warn("Database connection error in updateOneInstitutionalSentimentMetrics, retrying...", {
364
+ operation: 'updateOneInstitutionalSentimentMetrics',
365
+ model: 'InstitutionalSentimentMetrics',
366
+ attempt: retryCount,
367
+ maxRetries: MAX_RETRIES,
368
+ recordId: props.id,
369
+ });
280
370
  await new Promise(resolve => setTimeout(resolve, delay));
281
371
  continue;
282
372
  }
283
- // Log the error and rethrow
284
- logger_1.logger.error("Database error occurred", { error: String(error) });
373
+ // Log structured error details and rethrow
374
+ logger_1.logger.error("Database update operation failed", {
375
+ operation: 'updateOneInstitutionalSentimentMetrics',
376
+ model: 'InstitutionalSentimentMetrics',
377
+ error: String(error),
378
+ recordId: props.id,
379
+ isRetryable: isConnectionError,
380
+ });
285
381
  throw error;
286
382
  }
287
383
  }
@@ -296,7 +392,7 @@ exports.InstitutionalSentimentMetrics = {
296
392
  * @returns The updated InstitutionalSentimentMetrics or null.
297
393
  */
298
394
  async upsert(props, globalClient) {
299
- var _a, _b, _c, _d, _e;
395
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
300
396
  // Maximum number of retries for database connection issues
301
397
  const MAX_RETRIES = 3;
302
398
  let retryCount = 0;
@@ -372,21 +468,55 @@ exports.InstitutionalSentimentMetrics = {
372
468
  }
373
469
  catch (error) {
374
470
  lastError = error;
471
+ // Check for constraint violations FIRST - these are NEVER retryable
472
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
473
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
474
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
475
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
476
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
477
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
478
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
479
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
480
+ if (isConstraintViolation) {
481
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
482
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneInstitutionalSentimentMetrics", {
483
+ operation: 'upsertOneInstitutionalSentimentMetrics',
484
+ model: 'InstitutionalSentimentMetrics',
485
+ error: String(error),
486
+ recordId: props.id,
487
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
488
+ errorCategory: 'CONSTRAINT_VIOLATION',
489
+ isRetryable: false,
490
+ });
491
+ throw error;
492
+ }
375
493
  // Check if this is a database connection error that we should retry
376
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
377
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
378
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
379
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
380
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
494
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
495
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
496
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
497
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
498
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
381
499
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
382
500
  retryCount++;
383
501
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
384
- logger_1.logger.warn("Database connection error, retrying...");
502
+ logger_1.logger.warn("Database connection error in upsertOneInstitutionalSentimentMetrics, retrying...", {
503
+ operation: 'upsertOneInstitutionalSentimentMetrics',
504
+ model: 'InstitutionalSentimentMetrics',
505
+ attempt: retryCount,
506
+ maxRetries: MAX_RETRIES,
507
+ recordId: props.id,
508
+ });
385
509
  await new Promise(resolve => setTimeout(resolve, delay));
386
510
  continue;
387
511
  }
388
- // Log the error and rethrow
389
- logger_1.logger.error("Database error occurred", { error: String(error) });
512
+ // Log structured error details and rethrow
513
+ logger_1.logger.error("Database upsert operation failed", {
514
+ operation: 'upsertOneInstitutionalSentimentMetrics',
515
+ model: 'InstitutionalSentimentMetrics',
516
+ error: String(error),
517
+ recordId: props.id,
518
+ isRetryable: isConnectionError,
519
+ });
390
520
  throw error;
391
521
  }
392
522
  }
@@ -401,7 +531,7 @@ exports.InstitutionalSentimentMetrics = {
401
531
  * @returns The count of created records or null.
402
532
  */
403
533
  async updateMany(props, globalClient) {
404
- var _a, _b, _c, _d, _e;
534
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
405
535
  // Maximum number of retries for database connection issues
406
536
  const MAX_RETRIES = 3;
407
537
  let retryCount = 0;
@@ -474,21 +604,52 @@ exports.InstitutionalSentimentMetrics = {
474
604
  }
475
605
  catch (error) {
476
606
  lastError = error;
607
+ // Check for constraint violations FIRST - these are NEVER retryable
608
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
609
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
610
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
611
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
612
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
613
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
614
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
615
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
616
+ if (isConstraintViolation) {
617
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
618
+ logger_1.logger.error("Non-retryable constraint violation in updateManyInstitutionalSentimentMetrics", {
619
+ operation: 'updateManyInstitutionalSentimentMetrics',
620
+ model: 'InstitutionalSentimentMetrics',
621
+ error: String(error),
622
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
623
+ errorCategory: 'CONSTRAINT_VIOLATION',
624
+ isRetryable: false,
625
+ });
626
+ throw error;
627
+ }
477
628
  // Check if this is a database connection error that we should retry
478
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
479
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
480
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
481
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
482
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
629
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
630
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
631
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
632
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
633
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
483
634
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
484
635
  retryCount++;
485
636
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
486
- logger_1.logger.warn("Database connection error, retrying...");
637
+ logger_1.logger.warn("Database connection error in updateManyInstitutionalSentimentMetrics, retrying...", {
638
+ operation: 'updateManyInstitutionalSentimentMetrics',
639
+ model: 'InstitutionalSentimentMetrics',
640
+ attempt: retryCount,
641
+ maxRetries: MAX_RETRIES,
642
+ });
487
643
  await new Promise(resolve => setTimeout(resolve, delay));
488
644
  continue;
489
645
  }
490
- // Log the error and rethrow
491
- logger_1.logger.error("Database error occurred", { error: String(error) });
646
+ // Log structured error details and rethrow
647
+ logger_1.logger.error("Database updateMany operation failed", {
648
+ operation: 'updateManyInstitutionalSentimentMetrics',
649
+ model: 'InstitutionalSentimentMetrics',
650
+ error: String(error),
651
+ isRetryable: isConnectionError,
652
+ });
492
653
  throw error;
493
654
  }
494
655
  }
@@ -503,7 +664,7 @@ exports.InstitutionalSentimentMetrics = {
503
664
  * @returns The deleted InstitutionalSentimentMetrics or null.
504
665
  */
505
666
  async delete(props, globalClient) {
506
- var _a, _b, _c, _d, _e;
667
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
507
668
  // Maximum number of retries for database connection issues
508
669
  const MAX_RETRIES = 3;
509
670
  let retryCount = 0;
@@ -547,21 +708,58 @@ exports.InstitutionalSentimentMetrics = {
547
708
  }
548
709
  catch (error) {
549
710
  lastError = error;
711
+ // Check for constraint violations FIRST - these are NEVER retryable
712
+ // (e.g., foreign key constraints preventing deletion)
713
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
714
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
715
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
716
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
717
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
718
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
719
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
720
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
721
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
722
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
723
+ if (isConstraintViolation) {
724
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
725
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneInstitutionalSentimentMetrics", {
726
+ operation: 'deleteOneInstitutionalSentimentMetrics',
727
+ model: 'InstitutionalSentimentMetrics',
728
+ error: String(error),
729
+ recordId: props.id,
730
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
731
+ errorCategory: 'CONSTRAINT_VIOLATION',
732
+ isRetryable: false,
733
+ });
734
+ throw error;
735
+ }
550
736
  // Check if this is a database connection error that we should retry
551
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
552
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
553
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
554
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
555
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
737
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
738
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
739
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
740
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
741
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
556
742
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
557
743
  retryCount++;
558
744
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
559
- logger_1.logger.warn("Database connection error, retrying...");
745
+ logger_1.logger.warn("Database connection error in deleteOneInstitutionalSentimentMetrics, retrying...", {
746
+ operation: 'deleteOneInstitutionalSentimentMetrics',
747
+ model: 'InstitutionalSentimentMetrics',
748
+ attempt: retryCount,
749
+ maxRetries: MAX_RETRIES,
750
+ recordId: props.id,
751
+ });
560
752
  await new Promise(resolve => setTimeout(resolve, delay));
561
753
  continue;
562
754
  }
563
- // Log the error and rethrow
564
- logger_1.logger.error("Database error occurred", { error: String(error) });
755
+ // Log structured error details and rethrow
756
+ logger_1.logger.error("Database delete operation failed", {
757
+ operation: 'deleteOneInstitutionalSentimentMetrics',
758
+ model: 'InstitutionalSentimentMetrics',
759
+ error: String(error),
760
+ recordId: props.id,
761
+ isRetryable: isConnectionError,
762
+ });
565
763
  throw error;
566
764
  }
567
765
  }
@@ -628,12 +826,22 @@ exports.InstitutionalSentimentMetrics = {
628
826
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
629
827
  retryCount++;
630
828
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
631
- logger_1.logger.warn("Database connection error, retrying...");
829
+ logger_1.logger.warn("Database connection error in getInstitutionalSentimentMetrics, retrying...", {
830
+ operation: 'getInstitutionalSentimentMetrics',
831
+ model: 'InstitutionalSentimentMetrics',
832
+ attempt: retryCount,
833
+ maxRetries: MAX_RETRIES,
834
+ });
632
835
  await new Promise(resolve => setTimeout(resolve, delay));
633
836
  continue;
634
837
  }
635
- // Log the error and rethrow
636
- logger_1.logger.error("Database error occurred", { error: String(error) });
838
+ // Log structured error details and rethrow
839
+ logger_1.logger.error("Database get operation failed", {
840
+ operation: 'getInstitutionalSentimentMetrics',
841
+ model: 'InstitutionalSentimentMetrics',
842
+ error: String(error),
843
+ isRetryable: isConnectionError,
844
+ });
637
845
  throw error;
638
846
  }
639
847
  }
@@ -691,12 +899,22 @@ exports.InstitutionalSentimentMetrics = {
691
899
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
692
900
  retryCount++;
693
901
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
694
- logger_1.logger.warn("Database connection error, retrying...");
902
+ logger_1.logger.warn("Database connection error in getAllInstitutionalSentimentMetrics, retrying...", {
903
+ operation: 'getAllInstitutionalSentimentMetrics',
904
+ model: 'InstitutionalSentimentMetrics',
905
+ attempt: retryCount,
906
+ maxRetries: MAX_RETRIES,
907
+ });
695
908
  await new Promise(resolve => setTimeout(resolve, delay));
696
909
  continue;
697
910
  }
698
- // Log the error and rethrow
699
- logger_1.logger.error("Database error occurred", { error: String(error) });
911
+ // Log structured error details and rethrow
912
+ logger_1.logger.error("Database getAll operation failed", {
913
+ operation: 'getAllInstitutionalSentimentMetrics',
914
+ model: 'InstitutionalSentimentMetrics',
915
+ error: String(error),
916
+ isRetryable: isConnectionError,
917
+ });
700
918
  throw error;
701
919
  }
702
920
  }
@@ -770,12 +988,22 @@ exports.InstitutionalSentimentMetrics = {
770
988
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
771
989
  retryCount++;
772
990
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
773
- logger_1.logger.warn("Database connection error, retrying...");
991
+ logger_1.logger.warn("Database connection error in findManyInstitutionalSentimentMetrics, retrying...", {
992
+ operation: 'findManyInstitutionalSentimentMetrics',
993
+ model: 'InstitutionalSentimentMetrics',
994
+ attempt: retryCount,
995
+ maxRetries: MAX_RETRIES,
996
+ });
774
997
  await new Promise(resolve => setTimeout(resolve, delay));
775
998
  continue;
776
999
  }
777
- // Log the error and rethrow
778
- logger_1.logger.error("Database error occurred", { error: String(error) });
1000
+ // Log structured error details and rethrow
1001
+ logger_1.logger.error("Database findMany operation failed", {
1002
+ operation: 'findManyInstitutionalSentimentMetrics',
1003
+ model: 'InstitutionalSentimentMetrics',
1004
+ error: String(error),
1005
+ isRetryable: isConnectionError,
1006
+ });
779
1007
  throw error;
780
1008
  }
781
1009
  }