@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
@@ -33,7 +33,7 @@ exports.TradeExecutionHistory = {
33
33
  * @returns The created TradeExecutionHistory or null.
34
34
  */
35
35
  async create(props, globalClient) {
36
- var _a, _b, _c, _d, _e;
36
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
37
37
  // Maximum number of retries for database connection issues
38
38
  const MAX_RETRIES = 3;
39
39
  let retryCount = 0;
@@ -82,21 +82,52 @@ exports.TradeExecutionHistory = {
82
82
  }
83
83
  catch (error) {
84
84
  lastError = error;
85
+ // Check for constraint violations FIRST - these are NEVER retryable
86
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
87
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
88
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
89
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
90
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
91
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
92
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
93
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
94
+ if (isConstraintViolation) {
95
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
96
+ logger_1.logger.error("Non-retryable constraint violation in createOneTradeExecutionHistory", {
97
+ operation: 'createOneTradeExecutionHistory',
98
+ model: 'TradeExecutionHistory',
99
+ error: String(error),
100
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
101
+ errorCategory: 'CONSTRAINT_VIOLATION',
102
+ isRetryable: false,
103
+ });
104
+ throw error;
105
+ }
85
106
  // Check if this is a database connection error that we should retry
86
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
87
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
88
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
89
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
90
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
107
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
108
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
109
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
110
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
111
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
91
112
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
92
113
  retryCount++;
93
114
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
94
- logger_1.logger.warn("Database connection error, retrying...");
115
+ logger_1.logger.warn("Database connection error in createOneTradeExecutionHistory, retrying...", {
116
+ operation: 'createOneTradeExecutionHistory',
117
+ model: 'TradeExecutionHistory',
118
+ attempt: retryCount,
119
+ maxRetries: MAX_RETRIES,
120
+ });
95
121
  await new Promise(resolve => setTimeout(resolve, delay));
96
122
  continue;
97
123
  }
98
- // Log the error and rethrow
99
- logger_1.logger.error("Database error occurred", { error: String(error) });
124
+ // Log structured error details and rethrow
125
+ logger_1.logger.error("Database create operation failed", {
126
+ operation: 'createOneTradeExecutionHistory',
127
+ model: 'TradeExecutionHistory',
128
+ error: String(error),
129
+ isRetryable: isConnectionError,
130
+ });
100
131
  throw error;
101
132
  }
102
133
  }
@@ -111,7 +142,7 @@ exports.TradeExecutionHistory = {
111
142
  * @returns The count of created records or null.
112
143
  */
113
144
  async createMany(props, globalClient) {
114
- var _a, _b, _c, _d, _e;
145
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
115
146
  // Maximum number of retries for database connection issues
116
147
  const MAX_RETRIES = 3;
117
148
  let retryCount = 0;
@@ -159,21 +190,52 @@ exports.TradeExecutionHistory = {
159
190
  }
160
191
  catch (error) {
161
192
  lastError = error;
193
+ // Check for constraint violations FIRST - these are NEVER retryable
194
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
195
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
196
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
197
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
198
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
199
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
200
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
201
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
202
+ if (isConstraintViolation) {
203
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
204
+ logger_1.logger.error("Non-retryable constraint violation in createManyTradeExecutionHistory", {
205
+ operation: 'createManyTradeExecutionHistory',
206
+ model: 'TradeExecutionHistory',
207
+ error: String(error),
208
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
209
+ errorCategory: 'CONSTRAINT_VIOLATION',
210
+ isRetryable: false,
211
+ });
212
+ throw error;
213
+ }
162
214
  // Check if this is a database connection error that we should retry
163
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
164
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
165
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
166
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
167
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
215
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
216
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
217
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
218
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
219
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
168
220
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
169
221
  retryCount++;
170
222
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
171
- logger_1.logger.warn("Database connection error, retrying...");
223
+ logger_1.logger.warn("Database connection error in createManyTradeExecutionHistory, retrying...", {
224
+ operation: 'createManyTradeExecutionHistory',
225
+ model: 'TradeExecutionHistory',
226
+ attempt: retryCount,
227
+ maxRetries: MAX_RETRIES,
228
+ });
172
229
  await new Promise(resolve => setTimeout(resolve, delay));
173
230
  continue;
174
231
  }
175
- // Log the error and rethrow
176
- logger_1.logger.error("Database error occurred", { error: String(error) });
232
+ // Log structured error details and rethrow
233
+ logger_1.logger.error("Database createMany operation failed", {
234
+ operation: 'createManyTradeExecutionHistory',
235
+ model: 'TradeExecutionHistory',
236
+ error: String(error),
237
+ isRetryable: isConnectionError,
238
+ });
177
239
  throw error;
178
240
  }
179
241
  }
@@ -188,7 +250,7 @@ exports.TradeExecutionHistory = {
188
250
  * @returns The updated TradeExecutionHistory or null.
189
251
  */
190
252
  async update(props, globalClient) {
191
- var _a, _b, _c, _d, _e;
253
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
192
254
  // Maximum number of retries for database connection issues
193
255
  const MAX_RETRIES = 3;
194
256
  let retryCount = 0;
@@ -255,21 +317,55 @@ exports.TradeExecutionHistory = {
255
317
  }
256
318
  catch (error) {
257
319
  lastError = error;
320
+ // Check for constraint violations FIRST - these are NEVER retryable
321
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
322
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
323
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
324
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
325
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
326
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
327
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
328
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
329
+ if (isConstraintViolation) {
330
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
331
+ logger_1.logger.error("Non-retryable constraint violation in updateOneTradeExecutionHistory", {
332
+ operation: 'updateOneTradeExecutionHistory',
333
+ model: 'TradeExecutionHistory',
334
+ error: String(error),
335
+ recordId: props.id,
336
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
337
+ errorCategory: 'CONSTRAINT_VIOLATION',
338
+ isRetryable: false,
339
+ });
340
+ throw error;
341
+ }
258
342
  // Check if this is a database connection error that we should retry
259
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
260
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
261
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
262
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
263
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
343
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
344
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
345
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
346
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
347
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
264
348
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
265
349
  retryCount++;
266
350
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
267
- logger_1.logger.warn("Database connection error, retrying...");
351
+ logger_1.logger.warn("Database connection error in updateOneTradeExecutionHistory, retrying...", {
352
+ operation: 'updateOneTradeExecutionHistory',
353
+ model: 'TradeExecutionHistory',
354
+ attempt: retryCount,
355
+ maxRetries: MAX_RETRIES,
356
+ recordId: props.id,
357
+ });
268
358
  await new Promise(resolve => setTimeout(resolve, delay));
269
359
  continue;
270
360
  }
271
- // Log the error and rethrow
272
- logger_1.logger.error("Database error occurred", { error: String(error) });
361
+ // Log structured error details and rethrow
362
+ logger_1.logger.error("Database update operation failed", {
363
+ operation: 'updateOneTradeExecutionHistory',
364
+ model: 'TradeExecutionHistory',
365
+ error: String(error),
366
+ recordId: props.id,
367
+ isRetryable: isConnectionError,
368
+ });
273
369
  throw error;
274
370
  }
275
371
  }
@@ -284,7 +380,7 @@ exports.TradeExecutionHistory = {
284
380
  * @returns The updated TradeExecutionHistory or null.
285
381
  */
286
382
  async upsert(props, globalClient) {
287
- var _a, _b, _c, _d, _e;
383
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
288
384
  // Maximum number of retries for database connection issues
289
385
  const MAX_RETRIES = 3;
290
386
  let retryCount = 0;
@@ -352,21 +448,55 @@ exports.TradeExecutionHistory = {
352
448
  }
353
449
  catch (error) {
354
450
  lastError = error;
451
+ // Check for constraint violations FIRST - these are NEVER retryable
452
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
453
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
454
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
455
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
456
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
457
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
458
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
459
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
460
+ if (isConstraintViolation) {
461
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
462
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneTradeExecutionHistory", {
463
+ operation: 'upsertOneTradeExecutionHistory',
464
+ model: 'TradeExecutionHistory',
465
+ error: String(error),
466
+ recordId: props.id,
467
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
468
+ errorCategory: 'CONSTRAINT_VIOLATION',
469
+ isRetryable: false,
470
+ });
471
+ throw error;
472
+ }
355
473
  // Check if this is a database connection error that we should retry
356
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
357
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
358
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
359
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
360
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
474
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
475
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
476
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
477
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
478
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
361
479
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
362
480
  retryCount++;
363
481
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
364
- logger_1.logger.warn("Database connection error, retrying...");
482
+ logger_1.logger.warn("Database connection error in upsertOneTradeExecutionHistory, retrying...", {
483
+ operation: 'upsertOneTradeExecutionHistory',
484
+ model: 'TradeExecutionHistory',
485
+ attempt: retryCount,
486
+ maxRetries: MAX_RETRIES,
487
+ recordId: props.id,
488
+ });
365
489
  await new Promise(resolve => setTimeout(resolve, delay));
366
490
  continue;
367
491
  }
368
- // Log the error and rethrow
369
- logger_1.logger.error("Database error occurred", { error: String(error) });
492
+ // Log structured error details and rethrow
493
+ logger_1.logger.error("Database upsert operation failed", {
494
+ operation: 'upsertOneTradeExecutionHistory',
495
+ model: 'TradeExecutionHistory',
496
+ error: String(error),
497
+ recordId: props.id,
498
+ isRetryable: isConnectionError,
499
+ });
370
500
  throw error;
371
501
  }
372
502
  }
@@ -381,7 +511,7 @@ exports.TradeExecutionHistory = {
381
511
  * @returns The count of created records or null.
382
512
  */
383
513
  async updateMany(props, globalClient) {
384
- var _a, _b, _c, _d, _e;
514
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
385
515
  // Maximum number of retries for database connection issues
386
516
  const MAX_RETRIES = 3;
387
517
  let retryCount = 0;
@@ -448,21 +578,52 @@ exports.TradeExecutionHistory = {
448
578
  }
449
579
  catch (error) {
450
580
  lastError = error;
581
+ // Check for constraint violations FIRST - these are NEVER retryable
582
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
583
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
584
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
585
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
586
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
587
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
588
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
589
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
590
+ if (isConstraintViolation) {
591
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
592
+ logger_1.logger.error("Non-retryable constraint violation in updateManyTradeExecutionHistory", {
593
+ operation: 'updateManyTradeExecutionHistory',
594
+ model: 'TradeExecutionHistory',
595
+ error: String(error),
596
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
597
+ errorCategory: 'CONSTRAINT_VIOLATION',
598
+ isRetryable: false,
599
+ });
600
+ throw error;
601
+ }
451
602
  // Check if this is a database connection error that we should retry
452
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
453
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
454
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
455
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
456
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
603
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
604
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
605
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
606
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
607
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
457
608
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
458
609
  retryCount++;
459
610
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
460
- logger_1.logger.warn("Database connection error, retrying...");
611
+ logger_1.logger.warn("Database connection error in updateManyTradeExecutionHistory, retrying...", {
612
+ operation: 'updateManyTradeExecutionHistory',
613
+ model: 'TradeExecutionHistory',
614
+ attempt: retryCount,
615
+ maxRetries: MAX_RETRIES,
616
+ });
461
617
  await new Promise(resolve => setTimeout(resolve, delay));
462
618
  continue;
463
619
  }
464
- // Log the error and rethrow
465
- logger_1.logger.error("Database error occurred", { error: String(error) });
620
+ // Log structured error details and rethrow
621
+ logger_1.logger.error("Database updateMany operation failed", {
622
+ operation: 'updateManyTradeExecutionHistory',
623
+ model: 'TradeExecutionHistory',
624
+ error: String(error),
625
+ isRetryable: isConnectionError,
626
+ });
466
627
  throw error;
467
628
  }
468
629
  }
@@ -477,7 +638,7 @@ exports.TradeExecutionHistory = {
477
638
  * @returns The deleted TradeExecutionHistory or null.
478
639
  */
479
640
  async delete(props, globalClient) {
480
- var _a, _b, _c, _d, _e;
641
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
481
642
  // Maximum number of retries for database connection issues
482
643
  const MAX_RETRIES = 3;
483
644
  let retryCount = 0;
@@ -521,21 +682,58 @@ exports.TradeExecutionHistory = {
521
682
  }
522
683
  catch (error) {
523
684
  lastError = error;
685
+ // Check for constraint violations FIRST - these are NEVER retryable
686
+ // (e.g., foreign key constraints preventing deletion)
687
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
688
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
689
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
690
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
691
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
692
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
693
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
694
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
695
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
696
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
697
+ if (isConstraintViolation) {
698
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
699
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneTradeExecutionHistory", {
700
+ operation: 'deleteOneTradeExecutionHistory',
701
+ model: 'TradeExecutionHistory',
702
+ error: String(error),
703
+ recordId: props.id,
704
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
705
+ errorCategory: 'CONSTRAINT_VIOLATION',
706
+ isRetryable: false,
707
+ });
708
+ throw error;
709
+ }
524
710
  // Check if this is a database connection error that we should retry
525
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
526
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
527
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
528
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
529
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
711
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
712
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
713
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
714
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
715
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
530
716
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
531
717
  retryCount++;
532
718
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
533
- logger_1.logger.warn("Database connection error, retrying...");
719
+ logger_1.logger.warn("Database connection error in deleteOneTradeExecutionHistory, retrying...", {
720
+ operation: 'deleteOneTradeExecutionHistory',
721
+ model: 'TradeExecutionHistory',
722
+ attempt: retryCount,
723
+ maxRetries: MAX_RETRIES,
724
+ recordId: props.id,
725
+ });
534
726
  await new Promise(resolve => setTimeout(resolve, delay));
535
727
  continue;
536
728
  }
537
- // Log the error and rethrow
538
- logger_1.logger.error("Database error occurred", { error: String(error) });
729
+ // Log structured error details and rethrow
730
+ logger_1.logger.error("Database delete operation failed", {
731
+ operation: 'deleteOneTradeExecutionHistory',
732
+ model: 'TradeExecutionHistory',
733
+ error: String(error),
734
+ recordId: props.id,
735
+ isRetryable: isConnectionError,
736
+ });
539
737
  throw error;
540
738
  }
541
739
  }
@@ -602,12 +800,22 @@ exports.TradeExecutionHistory = {
602
800
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
603
801
  retryCount++;
604
802
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
605
- logger_1.logger.warn("Database connection error, retrying...");
803
+ logger_1.logger.warn("Database connection error in getTradeExecutionHistory, retrying...", {
804
+ operation: 'getTradeExecutionHistory',
805
+ model: 'TradeExecutionHistory',
806
+ attempt: retryCount,
807
+ maxRetries: MAX_RETRIES,
808
+ });
606
809
  await new Promise(resolve => setTimeout(resolve, delay));
607
810
  continue;
608
811
  }
609
- // Log the error and rethrow
610
- logger_1.logger.error("Database error occurred", { error: String(error) });
812
+ // Log structured error details and rethrow
813
+ logger_1.logger.error("Database get operation failed", {
814
+ operation: 'getTradeExecutionHistory',
815
+ model: 'TradeExecutionHistory',
816
+ error: String(error),
817
+ isRetryable: isConnectionError,
818
+ });
611
819
  throw error;
612
820
  }
613
821
  }
@@ -665,12 +873,22 @@ exports.TradeExecutionHistory = {
665
873
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
666
874
  retryCount++;
667
875
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
668
- logger_1.logger.warn("Database connection error, retrying...");
876
+ logger_1.logger.warn("Database connection error in getAllTradeExecutionHistory, retrying...", {
877
+ operation: 'getAllTradeExecutionHistory',
878
+ model: 'TradeExecutionHistory',
879
+ attempt: retryCount,
880
+ maxRetries: MAX_RETRIES,
881
+ });
669
882
  await new Promise(resolve => setTimeout(resolve, delay));
670
883
  continue;
671
884
  }
672
- // Log the error and rethrow
673
- logger_1.logger.error("Database error occurred", { error: String(error) });
885
+ // Log structured error details and rethrow
886
+ logger_1.logger.error("Database getAll operation failed", {
887
+ operation: 'getAllTradeExecutionHistory',
888
+ model: 'TradeExecutionHistory',
889
+ error: String(error),
890
+ isRetryable: isConnectionError,
891
+ });
674
892
  throw error;
675
893
  }
676
894
  }
@@ -744,12 +962,22 @@ exports.TradeExecutionHistory = {
744
962
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
745
963
  retryCount++;
746
964
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
747
- logger_1.logger.warn("Database connection error, retrying...");
965
+ logger_1.logger.warn("Database connection error in findManyTradeExecutionHistory, retrying...", {
966
+ operation: 'findManyTradeExecutionHistory',
967
+ model: 'TradeExecutionHistory',
968
+ attempt: retryCount,
969
+ maxRetries: MAX_RETRIES,
970
+ });
748
971
  await new Promise(resolve => setTimeout(resolve, delay));
749
972
  continue;
750
973
  }
751
- // Log the error and rethrow
752
- logger_1.logger.error("Database error occurred", { error: String(error) });
974
+ // Log structured error details and rethrow
975
+ logger_1.logger.error("Database findMany operation failed", {
976
+ operation: 'findManyTradeExecutionHistory',
977
+ model: 'TradeExecutionHistory',
978
+ error: String(error),
979
+ isRetryable: isConnectionError,
980
+ });
753
981
  throw error;
754
982
  }
755
983
  }