@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
@@ -32,7 +32,7 @@ exports.MarketSentiment = {
32
32
  * @returns The created MarketSentiment or null.
33
33
  */
34
34
  async create(props, globalClient) {
35
- var _a, _b, _c, _d, _e;
35
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
36
36
  // Maximum number of retries for database connection issues
37
37
  const MAX_RETRIES = 3;
38
38
  let retryCount = 0;
@@ -79,21 +79,52 @@ exports.MarketSentiment = {
79
79
  }
80
80
  catch (error) {
81
81
  lastError = error;
82
+ // Check for constraint violations FIRST - these are NEVER retryable
83
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
84
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
85
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
86
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
87
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
88
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
89
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
90
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
91
+ if (isConstraintViolation) {
92
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
93
+ logger_1.logger.error("Non-retryable constraint violation in createOneMarketSentiment", {
94
+ operation: 'createOneMarketSentiment',
95
+ model: 'MarketSentiment',
96
+ error: String(error),
97
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
98
+ errorCategory: 'CONSTRAINT_VIOLATION',
99
+ isRetryable: false,
100
+ });
101
+ throw error;
102
+ }
82
103
  // Check if this is a database connection error that we should retry
83
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
84
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
85
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
86
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
87
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
104
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
105
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
106
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
107
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
108
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
88
109
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
89
110
  retryCount++;
90
111
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
91
- logger_1.logger.warn("Database connection error, retrying...");
112
+ logger_1.logger.warn("Database connection error in createOneMarketSentiment, retrying...", {
113
+ operation: 'createOneMarketSentiment',
114
+ model: 'MarketSentiment',
115
+ attempt: retryCount,
116
+ maxRetries: MAX_RETRIES,
117
+ });
92
118
  await new Promise(resolve => setTimeout(resolve, delay));
93
119
  continue;
94
120
  }
95
- // Log the error and rethrow
96
- logger_1.logger.error("Database error occurred", { error: String(error) });
121
+ // Log structured error details and rethrow
122
+ logger_1.logger.error("Database create operation failed", {
123
+ operation: 'createOneMarketSentiment',
124
+ model: 'MarketSentiment',
125
+ error: String(error),
126
+ isRetryable: isConnectionError,
127
+ });
97
128
  throw error;
98
129
  }
99
130
  }
@@ -108,7 +139,7 @@ exports.MarketSentiment = {
108
139
  * @returns The count of created records or null.
109
140
  */
110
141
  async createMany(props, globalClient) {
111
- var _a, _b, _c, _d, _e;
142
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
112
143
  // Maximum number of retries for database connection issues
113
144
  const MAX_RETRIES = 3;
114
145
  let retryCount = 0;
@@ -154,21 +185,52 @@ exports.MarketSentiment = {
154
185
  }
155
186
  catch (error) {
156
187
  lastError = error;
188
+ // Check for constraint violations FIRST - these are NEVER retryable
189
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
190
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
191
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
192
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
193
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
194
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
195
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
196
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
197
+ if (isConstraintViolation) {
198
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
199
+ logger_1.logger.error("Non-retryable constraint violation in createManyMarketSentiment", {
200
+ operation: 'createManyMarketSentiment',
201
+ model: 'MarketSentiment',
202
+ error: String(error),
203
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
204
+ errorCategory: 'CONSTRAINT_VIOLATION',
205
+ isRetryable: false,
206
+ });
207
+ throw error;
208
+ }
157
209
  // Check if this is a database connection error that we should retry
158
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
159
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
160
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
161
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
162
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
210
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
211
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
212
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
213
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
214
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
163
215
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
164
216
  retryCount++;
165
217
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
166
- logger_1.logger.warn("Database connection error, retrying...");
218
+ logger_1.logger.warn("Database connection error in createManyMarketSentiment, retrying...", {
219
+ operation: 'createManyMarketSentiment',
220
+ model: 'MarketSentiment',
221
+ attempt: retryCount,
222
+ maxRetries: MAX_RETRIES,
223
+ });
167
224
  await new Promise(resolve => setTimeout(resolve, delay));
168
225
  continue;
169
226
  }
170
- // Log the error and rethrow
171
- logger_1.logger.error("Database error occurred", { error: String(error) });
227
+ // Log structured error details and rethrow
228
+ logger_1.logger.error("Database createMany operation failed", {
229
+ operation: 'createManyMarketSentiment',
230
+ model: 'MarketSentiment',
231
+ error: String(error),
232
+ isRetryable: isConnectionError,
233
+ });
172
234
  throw error;
173
235
  }
174
236
  }
@@ -183,7 +245,7 @@ exports.MarketSentiment = {
183
245
  * @returns The updated MarketSentiment or null.
184
246
  */
185
247
  async update(props, globalClient) {
186
- var _a, _b, _c, _d, _e;
248
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
187
249
  // Maximum number of retries for database connection issues
188
250
  const MAX_RETRIES = 3;
189
251
  let retryCount = 0;
@@ -247,21 +309,55 @@ exports.MarketSentiment = {
247
309
  }
248
310
  catch (error) {
249
311
  lastError = error;
312
+ // Check for constraint violations FIRST - these are NEVER retryable
313
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
314
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
315
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
316
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
317
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
318
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
319
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
320
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
321
+ if (isConstraintViolation) {
322
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
323
+ logger_1.logger.error("Non-retryable constraint violation in updateOneMarketSentiment", {
324
+ operation: 'updateOneMarketSentiment',
325
+ model: 'MarketSentiment',
326
+ error: String(error),
327
+ recordId: props.id,
328
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
329
+ errorCategory: 'CONSTRAINT_VIOLATION',
330
+ isRetryable: false,
331
+ });
332
+ throw error;
333
+ }
250
334
  // Check if this is a database connection error that we should retry
251
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
252
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
253
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
254
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
255
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
335
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
336
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
337
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
338
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
339
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
256
340
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
257
341
  retryCount++;
258
342
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
259
- logger_1.logger.warn("Database connection error, retrying...");
343
+ logger_1.logger.warn("Database connection error in updateOneMarketSentiment, retrying...", {
344
+ operation: 'updateOneMarketSentiment',
345
+ model: 'MarketSentiment',
346
+ attempt: retryCount,
347
+ maxRetries: MAX_RETRIES,
348
+ recordId: props.id,
349
+ });
260
350
  await new Promise(resolve => setTimeout(resolve, delay));
261
351
  continue;
262
352
  }
263
- // Log the error and rethrow
264
- logger_1.logger.error("Database error occurred", { error: String(error) });
353
+ // Log structured error details and rethrow
354
+ logger_1.logger.error("Database update operation failed", {
355
+ operation: 'updateOneMarketSentiment',
356
+ model: 'MarketSentiment',
357
+ error: String(error),
358
+ recordId: props.id,
359
+ isRetryable: isConnectionError,
360
+ });
265
361
  throw error;
266
362
  }
267
363
  }
@@ -276,7 +372,7 @@ exports.MarketSentiment = {
276
372
  * @returns The updated MarketSentiment or null.
277
373
  */
278
374
  async upsert(props, globalClient) {
279
- var _a, _b, _c, _d, _e;
375
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
280
376
  // Maximum number of retries for database connection issues
281
377
  const MAX_RETRIES = 3;
282
378
  let retryCount = 0;
@@ -336,21 +432,55 @@ exports.MarketSentiment = {
336
432
  }
337
433
  catch (error) {
338
434
  lastError = error;
435
+ // Check for constraint violations FIRST - these are NEVER retryable
436
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
437
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
438
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
439
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
440
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
441
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
442
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
443
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
444
+ if (isConstraintViolation) {
445
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
446
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneMarketSentiment", {
447
+ operation: 'upsertOneMarketSentiment',
448
+ model: 'MarketSentiment',
449
+ error: String(error),
450
+ recordId: props.id,
451
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
452
+ errorCategory: 'CONSTRAINT_VIOLATION',
453
+ isRetryable: false,
454
+ });
455
+ throw error;
456
+ }
339
457
  // Check if this is a database connection error that we should retry
340
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
341
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
342
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
343
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
344
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
458
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
459
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
460
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
461
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
462
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
345
463
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
346
464
  retryCount++;
347
465
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
348
- logger_1.logger.warn("Database connection error, retrying...");
466
+ logger_1.logger.warn("Database connection error in upsertOneMarketSentiment, retrying...", {
467
+ operation: 'upsertOneMarketSentiment',
468
+ model: 'MarketSentiment',
469
+ attempt: retryCount,
470
+ maxRetries: MAX_RETRIES,
471
+ recordId: props.id,
472
+ });
349
473
  await new Promise(resolve => setTimeout(resolve, delay));
350
474
  continue;
351
475
  }
352
- // Log the error and rethrow
353
- logger_1.logger.error("Database error occurred", { error: String(error) });
476
+ // Log structured error details and rethrow
477
+ logger_1.logger.error("Database upsert operation failed", {
478
+ operation: 'upsertOneMarketSentiment',
479
+ model: 'MarketSentiment',
480
+ error: String(error),
481
+ recordId: props.id,
482
+ isRetryable: isConnectionError,
483
+ });
354
484
  throw error;
355
485
  }
356
486
  }
@@ -365,7 +495,7 @@ exports.MarketSentiment = {
365
495
  * @returns The count of created records or null.
366
496
  */
367
497
  async updateMany(props, globalClient) {
368
- var _a, _b, _c, _d, _e;
498
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
369
499
  // Maximum number of retries for database connection issues
370
500
  const MAX_RETRIES = 3;
371
501
  let retryCount = 0;
@@ -429,21 +559,52 @@ exports.MarketSentiment = {
429
559
  }
430
560
  catch (error) {
431
561
  lastError = error;
562
+ // Check for constraint violations FIRST - these are NEVER retryable
563
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
564
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
565
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
566
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
567
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
568
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
569
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
570
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
571
+ if (isConstraintViolation) {
572
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
573
+ logger_1.logger.error("Non-retryable constraint violation in updateManyMarketSentiment", {
574
+ operation: 'updateManyMarketSentiment',
575
+ model: 'MarketSentiment',
576
+ error: String(error),
577
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
578
+ errorCategory: 'CONSTRAINT_VIOLATION',
579
+ isRetryable: false,
580
+ });
581
+ throw error;
582
+ }
432
583
  // Check if this is a database connection error that we should retry
433
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
434
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
435
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
436
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
437
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
584
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
585
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
586
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
587
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
588
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
438
589
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
439
590
  retryCount++;
440
591
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
441
- logger_1.logger.warn("Database connection error, retrying...");
592
+ logger_1.logger.warn("Database connection error in updateManyMarketSentiment, retrying...", {
593
+ operation: 'updateManyMarketSentiment',
594
+ model: 'MarketSentiment',
595
+ attempt: retryCount,
596
+ maxRetries: MAX_RETRIES,
597
+ });
442
598
  await new Promise(resolve => setTimeout(resolve, delay));
443
599
  continue;
444
600
  }
445
- // Log the error and rethrow
446
- logger_1.logger.error("Database error occurred", { error: String(error) });
601
+ // Log structured error details and rethrow
602
+ logger_1.logger.error("Database updateMany operation failed", {
603
+ operation: 'updateManyMarketSentiment',
604
+ model: 'MarketSentiment',
605
+ error: String(error),
606
+ isRetryable: isConnectionError,
607
+ });
447
608
  throw error;
448
609
  }
449
610
  }
@@ -458,7 +619,7 @@ exports.MarketSentiment = {
458
619
  * @returns The deleted MarketSentiment or null.
459
620
  */
460
621
  async delete(props, globalClient) {
461
- var _a, _b, _c, _d, _e;
622
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
462
623
  // Maximum number of retries for database connection issues
463
624
  const MAX_RETRIES = 3;
464
625
  let retryCount = 0;
@@ -502,21 +663,58 @@ exports.MarketSentiment = {
502
663
  }
503
664
  catch (error) {
504
665
  lastError = error;
666
+ // Check for constraint violations FIRST - these are NEVER retryable
667
+ // (e.g., foreign key constraints preventing deletion)
668
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
669
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
670
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
671
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
672
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
673
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
674
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
675
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
676
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
677
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
678
+ if (isConstraintViolation) {
679
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
680
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneMarketSentiment", {
681
+ operation: 'deleteOneMarketSentiment',
682
+ model: 'MarketSentiment',
683
+ error: String(error),
684
+ recordId: props.id,
685
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
686
+ errorCategory: 'CONSTRAINT_VIOLATION',
687
+ isRetryable: false,
688
+ });
689
+ throw error;
690
+ }
505
691
  // Check if this is a database connection error that we should retry
506
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
507
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
508
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
509
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
510
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
692
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
693
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
694
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
695
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
696
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
511
697
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
512
698
  retryCount++;
513
699
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
514
- logger_1.logger.warn("Database connection error, retrying...");
700
+ logger_1.logger.warn("Database connection error in deleteOneMarketSentiment, retrying...", {
701
+ operation: 'deleteOneMarketSentiment',
702
+ model: 'MarketSentiment',
703
+ attempt: retryCount,
704
+ maxRetries: MAX_RETRIES,
705
+ recordId: props.id,
706
+ });
515
707
  await new Promise(resolve => setTimeout(resolve, delay));
516
708
  continue;
517
709
  }
518
- // Log the error and rethrow
519
- logger_1.logger.error("Database error occurred", { error: String(error) });
710
+ // Log structured error details and rethrow
711
+ logger_1.logger.error("Database delete operation failed", {
712
+ operation: 'deleteOneMarketSentiment',
713
+ model: 'MarketSentiment',
714
+ error: String(error),
715
+ recordId: props.id,
716
+ isRetryable: isConnectionError,
717
+ });
520
718
  throw error;
521
719
  }
522
720
  }
@@ -583,12 +781,22 @@ exports.MarketSentiment = {
583
781
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
584
782
  retryCount++;
585
783
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
586
- logger_1.logger.warn("Database connection error, retrying...");
784
+ logger_1.logger.warn("Database connection error in getMarketSentiment, retrying...", {
785
+ operation: 'getMarketSentiment',
786
+ model: 'MarketSentiment',
787
+ attempt: retryCount,
788
+ maxRetries: MAX_RETRIES,
789
+ });
587
790
  await new Promise(resolve => setTimeout(resolve, delay));
588
791
  continue;
589
792
  }
590
- // Log the error and rethrow
591
- logger_1.logger.error("Database error occurred", { error: String(error) });
793
+ // Log structured error details and rethrow
794
+ logger_1.logger.error("Database get operation failed", {
795
+ operation: 'getMarketSentiment',
796
+ model: 'MarketSentiment',
797
+ error: String(error),
798
+ isRetryable: isConnectionError,
799
+ });
592
800
  throw error;
593
801
  }
594
802
  }
@@ -646,12 +854,22 @@ exports.MarketSentiment = {
646
854
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
647
855
  retryCount++;
648
856
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
649
- logger_1.logger.warn("Database connection error, retrying...");
857
+ logger_1.logger.warn("Database connection error in getAllMarketSentiment, retrying...", {
858
+ operation: 'getAllMarketSentiment',
859
+ model: 'MarketSentiment',
860
+ attempt: retryCount,
861
+ maxRetries: MAX_RETRIES,
862
+ });
650
863
  await new Promise(resolve => setTimeout(resolve, delay));
651
864
  continue;
652
865
  }
653
- // Log the error and rethrow
654
- logger_1.logger.error("Database error occurred", { error: String(error) });
866
+ // Log structured error details and rethrow
867
+ logger_1.logger.error("Database getAll operation failed", {
868
+ operation: 'getAllMarketSentiment',
869
+ model: 'MarketSentiment',
870
+ error: String(error),
871
+ isRetryable: isConnectionError,
872
+ });
655
873
  throw error;
656
874
  }
657
875
  }
@@ -725,12 +943,22 @@ exports.MarketSentiment = {
725
943
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
726
944
  retryCount++;
727
945
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
728
- logger_1.logger.warn("Database connection error, retrying...");
946
+ logger_1.logger.warn("Database connection error in findManyMarketSentiment, retrying...", {
947
+ operation: 'findManyMarketSentiment',
948
+ model: 'MarketSentiment',
949
+ attempt: retryCount,
950
+ maxRetries: MAX_RETRIES,
951
+ });
729
952
  await new Promise(resolve => setTimeout(resolve, delay));
730
953
  continue;
731
954
  }
732
- // Log the error and rethrow
733
- logger_1.logger.error("Database error occurred", { error: String(error) });
955
+ // Log structured error details and rethrow
956
+ logger_1.logger.error("Database findMany operation failed", {
957
+ operation: 'findManyMarketSentiment',
958
+ model: 'MarketSentiment',
959
+ error: String(error),
960
+ isRetryable: isConnectionError,
961
+ });
734
962
  throw error;
735
963
  }
736
964
  }