@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
@@ -29,7 +29,7 @@ exports.ScheduledOptionOrder = {
29
29
  * @returns The created ScheduledOptionOrder or null.
30
30
  */
31
31
  async create(props, globalClient) {
32
- var _a, _b, _c, _d, _e;
32
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
33
33
  // Maximum number of retries for database connection issues
34
34
  const MAX_RETRIES = 3;
35
35
  let retryCount = 0;
@@ -75,21 +75,52 @@ exports.ScheduledOptionOrder = {
75
75
  }
76
76
  catch (error) {
77
77
  lastError = error;
78
+ // Check for constraint violations FIRST - these are NEVER retryable
79
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
80
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
81
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
82
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
83
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
84
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
85
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
86
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
87
+ if (isConstraintViolation) {
88
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
89
+ logger_1.logger.error("Non-retryable constraint violation in createOneScheduledOptionOrder", {
90
+ operation: 'createOneScheduledOptionOrder',
91
+ model: 'ScheduledOptionOrder',
92
+ error: String(error),
93
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
94
+ errorCategory: 'CONSTRAINT_VIOLATION',
95
+ isRetryable: false,
96
+ });
97
+ throw error;
98
+ }
78
99
  // Check if this is a database connection error that we should retry
79
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
80
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
81
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
82
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
83
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
100
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
101
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
102
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
103
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
104
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
84
105
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
85
106
  retryCount++;
86
107
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
87
- logger_1.logger.warn("Database connection error, retrying...");
108
+ logger_1.logger.warn("Database connection error in createOneScheduledOptionOrder, retrying...", {
109
+ operation: 'createOneScheduledOptionOrder',
110
+ model: 'ScheduledOptionOrder',
111
+ attempt: retryCount,
112
+ maxRetries: MAX_RETRIES,
113
+ });
88
114
  await new Promise(resolve => setTimeout(resolve, delay));
89
115
  continue;
90
116
  }
91
- // Log the error and rethrow
92
- logger_1.logger.error("Database error occurred", { error: String(error) });
117
+ // Log structured error details and rethrow
118
+ logger_1.logger.error("Database create operation failed", {
119
+ operation: 'createOneScheduledOptionOrder',
120
+ model: 'ScheduledOptionOrder',
121
+ error: String(error),
122
+ isRetryable: isConnectionError,
123
+ });
93
124
  throw error;
94
125
  }
95
126
  }
@@ -104,7 +135,7 @@ exports.ScheduledOptionOrder = {
104
135
  * @returns The count of created records or null.
105
136
  */
106
137
  async createMany(props, globalClient) {
107
- var _a, _b, _c, _d, _e;
138
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
108
139
  // Maximum number of retries for database connection issues
109
140
  const MAX_RETRIES = 3;
110
141
  let retryCount = 0;
@@ -149,21 +180,52 @@ exports.ScheduledOptionOrder = {
149
180
  }
150
181
  catch (error) {
151
182
  lastError = error;
183
+ // Check for constraint violations FIRST - these are NEVER retryable
184
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
185
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
186
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
187
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
188
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
189
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
190
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
191
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
192
+ if (isConstraintViolation) {
193
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
194
+ logger_1.logger.error("Non-retryable constraint violation in createManyScheduledOptionOrder", {
195
+ operation: 'createManyScheduledOptionOrder',
196
+ model: 'ScheduledOptionOrder',
197
+ error: String(error),
198
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
199
+ errorCategory: 'CONSTRAINT_VIOLATION',
200
+ isRetryable: false,
201
+ });
202
+ throw error;
203
+ }
152
204
  // Check if this is a database connection error that we should retry
153
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
154
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
155
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
156
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
157
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
205
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
206
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
207
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
208
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
209
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
158
210
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
159
211
  retryCount++;
160
212
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
161
- logger_1.logger.warn("Database connection error, retrying...");
213
+ logger_1.logger.warn("Database connection error in createManyScheduledOptionOrder, retrying...", {
214
+ operation: 'createManyScheduledOptionOrder',
215
+ model: 'ScheduledOptionOrder',
216
+ attempt: retryCount,
217
+ maxRetries: MAX_RETRIES,
218
+ });
162
219
  await new Promise(resolve => setTimeout(resolve, delay));
163
220
  continue;
164
221
  }
165
- // Log the error and rethrow
166
- logger_1.logger.error("Database error occurred", { error: String(error) });
222
+ // Log structured error details and rethrow
223
+ logger_1.logger.error("Database createMany operation failed", {
224
+ operation: 'createManyScheduledOptionOrder',
225
+ model: 'ScheduledOptionOrder',
226
+ error: String(error),
227
+ isRetryable: isConnectionError,
228
+ });
167
229
  throw error;
168
230
  }
169
231
  }
@@ -178,7 +240,7 @@ exports.ScheduledOptionOrder = {
178
240
  * @returns The updated ScheduledOptionOrder or null.
179
241
  */
180
242
  async update(props, globalClient) {
181
- var _a, _b, _c, _d, _e;
243
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
182
244
  // Maximum number of retries for database connection issues
183
245
  const MAX_RETRIES = 3;
184
246
  let retryCount = 0;
@@ -233,21 +295,55 @@ exports.ScheduledOptionOrder = {
233
295
  }
234
296
  catch (error) {
235
297
  lastError = error;
298
+ // Check for constraint violations FIRST - these are NEVER retryable
299
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
300
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
301
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
302
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
303
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
304
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
305
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
306
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
307
+ if (isConstraintViolation) {
308
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
309
+ logger_1.logger.error("Non-retryable constraint violation in updateOneScheduledOptionOrder", {
310
+ operation: 'updateOneScheduledOptionOrder',
311
+ model: 'ScheduledOptionOrder',
312
+ error: String(error),
313
+ recordId: props.id,
314
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
315
+ errorCategory: 'CONSTRAINT_VIOLATION',
316
+ isRetryable: false,
317
+ });
318
+ throw error;
319
+ }
236
320
  // Check if this is a database connection error that we should retry
237
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
238
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
239
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
240
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
241
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
321
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
322
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
323
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
324
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
325
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
242
326
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
243
327
  retryCount++;
244
328
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
245
- logger_1.logger.warn("Database connection error, retrying...");
329
+ logger_1.logger.warn("Database connection error in updateOneScheduledOptionOrder, retrying...", {
330
+ operation: 'updateOneScheduledOptionOrder',
331
+ model: 'ScheduledOptionOrder',
332
+ attempt: retryCount,
333
+ maxRetries: MAX_RETRIES,
334
+ recordId: props.id,
335
+ });
246
336
  await new Promise(resolve => setTimeout(resolve, delay));
247
337
  continue;
248
338
  }
249
- // Log the error and rethrow
250
- logger_1.logger.error("Database error occurred", { error: String(error) });
339
+ // Log structured error details and rethrow
340
+ logger_1.logger.error("Database update operation failed", {
341
+ operation: 'updateOneScheduledOptionOrder',
342
+ model: 'ScheduledOptionOrder',
343
+ error: String(error),
344
+ recordId: props.id,
345
+ isRetryable: isConnectionError,
346
+ });
251
347
  throw error;
252
348
  }
253
349
  }
@@ -262,7 +358,7 @@ exports.ScheduledOptionOrder = {
262
358
  * @returns The updated ScheduledOptionOrder or null.
263
359
  */
264
360
  async upsert(props, globalClient) {
265
- var _a, _b, _c, _d, _e;
361
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
266
362
  // Maximum number of retries for database connection issues
267
363
  const MAX_RETRIES = 3;
268
364
  let retryCount = 0;
@@ -318,21 +414,55 @@ exports.ScheduledOptionOrder = {
318
414
  }
319
415
  catch (error) {
320
416
  lastError = error;
417
+ // Check for constraint violations FIRST - these are NEVER retryable
418
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
419
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
420
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
421
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
422
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
423
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
424
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
425
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
426
+ if (isConstraintViolation) {
427
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
428
+ logger_1.logger.error("Non-retryable constraint violation in upsertOneScheduledOptionOrder", {
429
+ operation: 'upsertOneScheduledOptionOrder',
430
+ model: 'ScheduledOptionOrder',
431
+ error: String(error),
432
+ recordId: props.id,
433
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
434
+ errorCategory: 'CONSTRAINT_VIOLATION',
435
+ isRetryable: false,
436
+ });
437
+ throw error;
438
+ }
321
439
  // Check if this is a database connection error that we should retry
322
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
323
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
324
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
325
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
326
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
440
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
441
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
442
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
443
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
444
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
327
445
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
328
446
  retryCount++;
329
447
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
330
- logger_1.logger.warn("Database connection error, retrying...");
448
+ logger_1.logger.warn("Database connection error in upsertOneScheduledOptionOrder, retrying...", {
449
+ operation: 'upsertOneScheduledOptionOrder',
450
+ model: 'ScheduledOptionOrder',
451
+ attempt: retryCount,
452
+ maxRetries: MAX_RETRIES,
453
+ recordId: props.id,
454
+ });
331
455
  await new Promise(resolve => setTimeout(resolve, delay));
332
456
  continue;
333
457
  }
334
- // Log the error and rethrow
335
- logger_1.logger.error("Database error occurred", { error: String(error) });
458
+ // Log structured error details and rethrow
459
+ logger_1.logger.error("Database upsert operation failed", {
460
+ operation: 'upsertOneScheduledOptionOrder',
461
+ model: 'ScheduledOptionOrder',
462
+ error: String(error),
463
+ recordId: props.id,
464
+ isRetryable: isConnectionError,
465
+ });
336
466
  throw error;
337
467
  }
338
468
  }
@@ -347,7 +477,7 @@ exports.ScheduledOptionOrder = {
347
477
  * @returns The count of created records or null.
348
478
  */
349
479
  async updateMany(props, globalClient) {
350
- var _a, _b, _c, _d, _e;
480
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
351
481
  // Maximum number of retries for database connection issues
352
482
  const MAX_RETRIES = 3;
353
483
  let retryCount = 0;
@@ -402,21 +532,52 @@ exports.ScheduledOptionOrder = {
402
532
  }
403
533
  catch (error) {
404
534
  lastError = error;
535
+ // Check for constraint violations FIRST - these are NEVER retryable
536
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
537
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
538
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
539
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
540
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
541
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
542
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
543
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
544
+ if (isConstraintViolation) {
545
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
546
+ logger_1.logger.error("Non-retryable constraint violation in updateManyScheduledOptionOrder", {
547
+ operation: 'updateManyScheduledOptionOrder',
548
+ model: 'ScheduledOptionOrder',
549
+ error: String(error),
550
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
551
+ errorCategory: 'CONSTRAINT_VIOLATION',
552
+ isRetryable: false,
553
+ });
554
+ throw error;
555
+ }
405
556
  // Check if this is a database connection error that we should retry
406
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
407
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
408
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
409
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
410
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
557
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
558
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
559
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
560
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
561
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
411
562
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
412
563
  retryCount++;
413
564
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
414
- logger_1.logger.warn("Database connection error, retrying...");
565
+ logger_1.logger.warn("Database connection error in updateManyScheduledOptionOrder, retrying...", {
566
+ operation: 'updateManyScheduledOptionOrder',
567
+ model: 'ScheduledOptionOrder',
568
+ attempt: retryCount,
569
+ maxRetries: MAX_RETRIES,
570
+ });
415
571
  await new Promise(resolve => setTimeout(resolve, delay));
416
572
  continue;
417
573
  }
418
- // Log the error and rethrow
419
- logger_1.logger.error("Database error occurred", { error: String(error) });
574
+ // Log structured error details and rethrow
575
+ logger_1.logger.error("Database updateMany operation failed", {
576
+ operation: 'updateManyScheduledOptionOrder',
577
+ model: 'ScheduledOptionOrder',
578
+ error: String(error),
579
+ isRetryable: isConnectionError,
580
+ });
420
581
  throw error;
421
582
  }
422
583
  }
@@ -431,7 +592,7 @@ exports.ScheduledOptionOrder = {
431
592
  * @returns The deleted ScheduledOptionOrder or null.
432
593
  */
433
594
  async delete(props, globalClient) {
434
- var _a, _b, _c, _d, _e;
595
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
435
596
  // Maximum number of retries for database connection issues
436
597
  const MAX_RETRIES = 3;
437
598
  let retryCount = 0;
@@ -475,21 +636,58 @@ exports.ScheduledOptionOrder = {
475
636
  }
476
637
  catch (error) {
477
638
  lastError = error;
639
+ // Check for constraint violations FIRST - these are NEVER retryable
640
+ // (e.g., foreign key constraints preventing deletion)
641
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
642
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
643
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
644
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
645
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
646
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
647
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
648
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
649
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
650
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
651
+ if (isConstraintViolation) {
652
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
653
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneScheduledOptionOrder", {
654
+ operation: 'deleteOneScheduledOptionOrder',
655
+ model: 'ScheduledOptionOrder',
656
+ error: String(error),
657
+ recordId: props.id,
658
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
659
+ errorCategory: 'CONSTRAINT_VIOLATION',
660
+ isRetryable: false,
661
+ });
662
+ throw error;
663
+ }
478
664
  // Check if this is a database connection error that we should retry
479
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
480
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
481
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
482
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
483
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
665
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
666
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
667
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
668
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
669
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
484
670
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
485
671
  retryCount++;
486
672
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
487
- logger_1.logger.warn("Database connection error, retrying...");
673
+ logger_1.logger.warn("Database connection error in deleteOneScheduledOptionOrder, retrying...", {
674
+ operation: 'deleteOneScheduledOptionOrder',
675
+ model: 'ScheduledOptionOrder',
676
+ attempt: retryCount,
677
+ maxRetries: MAX_RETRIES,
678
+ recordId: props.id,
679
+ });
488
680
  await new Promise(resolve => setTimeout(resolve, delay));
489
681
  continue;
490
682
  }
491
- // Log the error and rethrow
492
- logger_1.logger.error("Database error occurred", { error: String(error) });
683
+ // Log structured error details and rethrow
684
+ logger_1.logger.error("Database delete operation failed", {
685
+ operation: 'deleteOneScheduledOptionOrder',
686
+ model: 'ScheduledOptionOrder',
687
+ error: String(error),
688
+ recordId: props.id,
689
+ isRetryable: isConnectionError,
690
+ });
493
691
  throw error;
494
692
  }
495
693
  }
@@ -556,12 +754,22 @@ exports.ScheduledOptionOrder = {
556
754
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
557
755
  retryCount++;
558
756
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
559
- logger_1.logger.warn("Database connection error, retrying...");
757
+ logger_1.logger.warn("Database connection error in getScheduledOptionOrder, retrying...", {
758
+ operation: 'getScheduledOptionOrder',
759
+ model: 'ScheduledOptionOrder',
760
+ attempt: retryCount,
761
+ maxRetries: MAX_RETRIES,
762
+ });
560
763
  await new Promise(resolve => setTimeout(resolve, delay));
561
764
  continue;
562
765
  }
563
- // Log the error and rethrow
564
- logger_1.logger.error("Database error occurred", { error: String(error) });
766
+ // Log structured error details and rethrow
767
+ logger_1.logger.error("Database get operation failed", {
768
+ operation: 'getScheduledOptionOrder',
769
+ model: 'ScheduledOptionOrder',
770
+ error: String(error),
771
+ isRetryable: isConnectionError,
772
+ });
565
773
  throw error;
566
774
  }
567
775
  }
@@ -619,12 +827,22 @@ exports.ScheduledOptionOrder = {
619
827
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
620
828
  retryCount++;
621
829
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
622
- logger_1.logger.warn("Database connection error, retrying...");
830
+ logger_1.logger.warn("Database connection error in getAllScheduledOptionOrder, retrying...", {
831
+ operation: 'getAllScheduledOptionOrder',
832
+ model: 'ScheduledOptionOrder',
833
+ attempt: retryCount,
834
+ maxRetries: MAX_RETRIES,
835
+ });
623
836
  await new Promise(resolve => setTimeout(resolve, delay));
624
837
  continue;
625
838
  }
626
- // Log the error and rethrow
627
- logger_1.logger.error("Database error occurred", { error: String(error) });
839
+ // Log structured error details and rethrow
840
+ logger_1.logger.error("Database getAll operation failed", {
841
+ operation: 'getAllScheduledOptionOrder',
842
+ model: 'ScheduledOptionOrder',
843
+ error: String(error),
844
+ isRetryable: isConnectionError,
845
+ });
628
846
  throw error;
629
847
  }
630
848
  }
@@ -698,12 +916,22 @@ exports.ScheduledOptionOrder = {
698
916
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
699
917
  retryCount++;
700
918
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
701
- logger_1.logger.warn("Database connection error, retrying...");
919
+ logger_1.logger.warn("Database connection error in findManyScheduledOptionOrder, retrying...", {
920
+ operation: 'findManyScheduledOptionOrder',
921
+ model: 'ScheduledOptionOrder',
922
+ attempt: retryCount,
923
+ maxRetries: MAX_RETRIES,
924
+ });
702
925
  await new Promise(resolve => setTimeout(resolve, delay));
703
926
  continue;
704
927
  }
705
- // Log the error and rethrow
706
- logger_1.logger.error("Database error occurred", { error: String(error) });
928
+ // Log structured error details and rethrow
929
+ logger_1.logger.error("Database findMany operation failed", {
930
+ operation: 'findManyScheduledOptionOrder',
931
+ model: 'ScheduledOptionOrder',
932
+ error: String(error),
933
+ isRetryable: isConnectionError,
934
+ });
707
935
  throw error;
708
936
  }
709
937
  }