@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.AnalyticsSnapshot = {
33
33
  * @returns The created AnalyticsSnapshot 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;
@@ -81,21 +81,52 @@ exports.AnalyticsSnapshot = {
81
81
  }
82
82
  catch (error) {
83
83
  lastError = error;
84
+ // Check for constraint violations FIRST - these are NEVER retryable
85
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
86
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
87
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
88
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
89
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
90
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
91
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
92
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
93
+ if (isConstraintViolation) {
94
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
95
+ logger_1.logger.error("Non-retryable constraint violation in createOneAnalyticsSnapshot", {
96
+ operation: 'createOneAnalyticsSnapshot',
97
+ model: 'AnalyticsSnapshot',
98
+ error: String(error),
99
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
100
+ errorCategory: 'CONSTRAINT_VIOLATION',
101
+ isRetryable: false,
102
+ });
103
+ throw error;
104
+ }
84
105
  // Check if this is a database connection error that we should retry
85
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
86
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
87
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
88
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
89
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
106
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
107
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
108
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
109
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
110
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
90
111
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
91
112
  retryCount++;
92
113
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
93
- logger_1.logger.warn("Database connection error, retrying...");
114
+ logger_1.logger.warn("Database connection error in createOneAnalyticsSnapshot, retrying...", {
115
+ operation: 'createOneAnalyticsSnapshot',
116
+ model: 'AnalyticsSnapshot',
117
+ attempt: retryCount,
118
+ maxRetries: MAX_RETRIES,
119
+ });
94
120
  await new Promise(resolve => setTimeout(resolve, delay));
95
121
  continue;
96
122
  }
97
- // Log the error and rethrow
98
- logger_1.logger.error("Database error occurred", { error: String(error) });
123
+ // Log structured error details and rethrow
124
+ logger_1.logger.error("Database create operation failed", {
125
+ operation: 'createOneAnalyticsSnapshot',
126
+ model: 'AnalyticsSnapshot',
127
+ error: String(error),
128
+ isRetryable: isConnectionError,
129
+ });
99
130
  throw error;
100
131
  }
101
132
  }
@@ -110,7 +141,7 @@ exports.AnalyticsSnapshot = {
110
141
  * @returns The count of created records or null.
111
142
  */
112
143
  async createMany(props, globalClient) {
113
- var _a, _b, _c, _d, _e;
144
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
114
145
  // Maximum number of retries for database connection issues
115
146
  const MAX_RETRIES = 3;
116
147
  let retryCount = 0;
@@ -157,21 +188,52 @@ exports.AnalyticsSnapshot = {
157
188
  }
158
189
  catch (error) {
159
190
  lastError = error;
191
+ // Check for constraint violations FIRST - these are NEVER retryable
192
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
193
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
194
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
195
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
196
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
197
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
198
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
199
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
200
+ if (isConstraintViolation) {
201
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
202
+ logger_1.logger.error("Non-retryable constraint violation in createManyAnalyticsSnapshot", {
203
+ operation: 'createManyAnalyticsSnapshot',
204
+ model: 'AnalyticsSnapshot',
205
+ error: String(error),
206
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
207
+ errorCategory: 'CONSTRAINT_VIOLATION',
208
+ isRetryable: false,
209
+ });
210
+ throw error;
211
+ }
160
212
  // Check if this is a database connection error that we should retry
161
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
162
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
163
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
164
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
165
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
213
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
214
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
215
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
216
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
217
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
166
218
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
167
219
  retryCount++;
168
220
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
169
- logger_1.logger.warn("Database connection error, retrying...");
221
+ logger_1.logger.warn("Database connection error in createManyAnalyticsSnapshot, retrying...", {
222
+ operation: 'createManyAnalyticsSnapshot',
223
+ model: 'AnalyticsSnapshot',
224
+ attempt: retryCount,
225
+ maxRetries: MAX_RETRIES,
226
+ });
170
227
  await new Promise(resolve => setTimeout(resolve, delay));
171
228
  continue;
172
229
  }
173
- // Log the error and rethrow
174
- logger_1.logger.error("Database error occurred", { error: String(error) });
230
+ // Log structured error details and rethrow
231
+ logger_1.logger.error("Database createMany operation failed", {
232
+ operation: 'createManyAnalyticsSnapshot',
233
+ model: 'AnalyticsSnapshot',
234
+ error: String(error),
235
+ isRetryable: isConnectionError,
236
+ });
175
237
  throw error;
176
238
  }
177
239
  }
@@ -186,7 +248,7 @@ exports.AnalyticsSnapshot = {
186
248
  * @returns The updated AnalyticsSnapshot or null.
187
249
  */
188
250
  async update(props, globalClient) {
189
- var _a, _b, _c, _d, _e;
251
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
190
252
  // Maximum number of retries for database connection issues
191
253
  const MAX_RETRIES = 3;
192
254
  let retryCount = 0;
@@ -256,21 +318,55 @@ exports.AnalyticsSnapshot = {
256
318
  }
257
319
  catch (error) {
258
320
  lastError = error;
321
+ // Check for constraint violations FIRST - these are NEVER retryable
322
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
323
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
324
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
325
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
326
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
327
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
328
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
329
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
330
+ if (isConstraintViolation) {
331
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
332
+ logger_1.logger.error("Non-retryable constraint violation in updateOneAnalyticsSnapshot", {
333
+ operation: 'updateOneAnalyticsSnapshot',
334
+ model: 'AnalyticsSnapshot',
335
+ error: String(error),
336
+ recordId: props.id,
337
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
338
+ errorCategory: 'CONSTRAINT_VIOLATION',
339
+ isRetryable: false,
340
+ });
341
+ throw error;
342
+ }
259
343
  // Check if this is a database connection error that we should retry
260
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
261
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
262
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
263
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
264
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
344
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
345
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
346
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
347
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
348
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
265
349
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
266
350
  retryCount++;
267
351
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
268
- logger_1.logger.warn("Database connection error, retrying...");
352
+ logger_1.logger.warn("Database connection error in updateOneAnalyticsSnapshot, retrying...", {
353
+ operation: 'updateOneAnalyticsSnapshot',
354
+ model: 'AnalyticsSnapshot',
355
+ attempt: retryCount,
356
+ maxRetries: MAX_RETRIES,
357
+ recordId: props.id,
358
+ });
269
359
  await new Promise(resolve => setTimeout(resolve, delay));
270
360
  continue;
271
361
  }
272
- // Log the error and rethrow
273
- logger_1.logger.error("Database error occurred", { error: String(error) });
362
+ // Log structured error details and rethrow
363
+ logger_1.logger.error("Database update operation failed", {
364
+ operation: 'updateOneAnalyticsSnapshot',
365
+ model: 'AnalyticsSnapshot',
366
+ error: String(error),
367
+ recordId: props.id,
368
+ isRetryable: isConnectionError,
369
+ });
274
370
  throw error;
275
371
  }
276
372
  }
@@ -285,7 +381,7 @@ exports.AnalyticsSnapshot = {
285
381
  * @returns The updated AnalyticsSnapshot or null.
286
382
  */
287
383
  async upsert(props, globalClient) {
288
- var _a, _b, _c, _d, _e;
384
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
289
385
  // Maximum number of retries for database connection issues
290
386
  const MAX_RETRIES = 3;
291
387
  let retryCount = 0;
@@ -352,21 +448,55 @@ exports.AnalyticsSnapshot = {
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 upsertOneAnalyticsSnapshot", {
463
+ operation: 'upsertOneAnalyticsSnapshot',
464
+ model: 'AnalyticsSnapshot',
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 upsertOneAnalyticsSnapshot, retrying...", {
483
+ operation: 'upsertOneAnalyticsSnapshot',
484
+ model: 'AnalyticsSnapshot',
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: 'upsertOneAnalyticsSnapshot',
495
+ model: 'AnalyticsSnapshot',
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.AnalyticsSnapshot = {
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;
@@ -451,21 +581,52 @@ exports.AnalyticsSnapshot = {
451
581
  }
452
582
  catch (error) {
453
583
  lastError = error;
584
+ // Check for constraint violations FIRST - these are NEVER retryable
585
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
586
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
587
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
588
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
589
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
590
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
591
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
592
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
593
+ if (isConstraintViolation) {
594
+ const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
595
+ logger_1.logger.error("Non-retryable constraint violation in updateManyAnalyticsSnapshot", {
596
+ operation: 'updateManyAnalyticsSnapshot',
597
+ model: 'AnalyticsSnapshot',
598
+ error: String(error),
599
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
600
+ errorCategory: 'CONSTRAINT_VIOLATION',
601
+ isRetryable: false,
602
+ });
603
+ throw error;
604
+ }
454
605
  // Check if this is a database connection error that we should retry
455
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
456
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
457
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
458
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
459
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
606
+ const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
607
+ ((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
608
+ ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
609
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
610
+ (error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
460
611
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
461
612
  retryCount++;
462
613
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
463
- logger_1.logger.warn("Database connection error, retrying...");
614
+ logger_1.logger.warn("Database connection error in updateManyAnalyticsSnapshot, retrying...", {
615
+ operation: 'updateManyAnalyticsSnapshot',
616
+ model: 'AnalyticsSnapshot',
617
+ attempt: retryCount,
618
+ maxRetries: MAX_RETRIES,
619
+ });
464
620
  await new Promise(resolve => setTimeout(resolve, delay));
465
621
  continue;
466
622
  }
467
- // Log the error and rethrow
468
- logger_1.logger.error("Database error occurred", { error: String(error) });
623
+ // Log structured error details and rethrow
624
+ logger_1.logger.error("Database updateMany operation failed", {
625
+ operation: 'updateManyAnalyticsSnapshot',
626
+ model: 'AnalyticsSnapshot',
627
+ error: String(error),
628
+ isRetryable: isConnectionError,
629
+ });
469
630
  throw error;
470
631
  }
471
632
  }
@@ -480,7 +641,7 @@ exports.AnalyticsSnapshot = {
480
641
  * @returns The deleted AnalyticsSnapshot or null.
481
642
  */
482
643
  async delete(props, globalClient) {
483
- var _a, _b, _c, _d, _e;
644
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
484
645
  // Maximum number of retries for database connection issues
485
646
  const MAX_RETRIES = 3;
486
647
  let retryCount = 0;
@@ -524,21 +685,58 @@ exports.AnalyticsSnapshot = {
524
685
  }
525
686
  catch (error) {
526
687
  lastError = error;
688
+ // Check for constraint violations FIRST - these are NEVER retryable
689
+ // (e.g., foreign key constraints preventing deletion)
690
+ const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
691
+ ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
692
+ ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
693
+ ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
694
+ ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
695
+ ((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
696
+ ((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
697
+ ((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
698
+ ((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
699
+ ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
700
+ if (isConstraintViolation) {
701
+ const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
702
+ logger_1.logger.error("Non-retryable constraint violation in deleteOneAnalyticsSnapshot", {
703
+ operation: 'deleteOneAnalyticsSnapshot',
704
+ model: 'AnalyticsSnapshot',
705
+ error: String(error),
706
+ recordId: props.id,
707
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
708
+ errorCategory: 'CONSTRAINT_VIOLATION',
709
+ isRetryable: false,
710
+ });
711
+ throw error;
712
+ }
527
713
  // Check if this is a database connection error that we should retry
528
- const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
529
- ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
530
- ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
531
- ((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
532
- (error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
714
+ const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
715
+ ((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
716
+ ((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
717
+ ((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
718
+ (error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
533
719
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
534
720
  retryCount++;
535
721
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
536
- logger_1.logger.warn("Database connection error, retrying...");
722
+ logger_1.logger.warn("Database connection error in deleteOneAnalyticsSnapshot, retrying...", {
723
+ operation: 'deleteOneAnalyticsSnapshot',
724
+ model: 'AnalyticsSnapshot',
725
+ attempt: retryCount,
726
+ maxRetries: MAX_RETRIES,
727
+ recordId: props.id,
728
+ });
537
729
  await new Promise(resolve => setTimeout(resolve, delay));
538
730
  continue;
539
731
  }
540
- // Log the error and rethrow
541
- logger_1.logger.error("Database error occurred", { error: String(error) });
732
+ // Log structured error details and rethrow
733
+ logger_1.logger.error("Database delete operation failed", {
734
+ operation: 'deleteOneAnalyticsSnapshot',
735
+ model: 'AnalyticsSnapshot',
736
+ error: String(error),
737
+ recordId: props.id,
738
+ isRetryable: isConnectionError,
739
+ });
542
740
  throw error;
543
741
  }
544
742
  }
@@ -608,12 +806,22 @@ exports.AnalyticsSnapshot = {
608
806
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
609
807
  retryCount++;
610
808
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
611
- logger_1.logger.warn("Database connection error, retrying...");
809
+ logger_1.logger.warn("Database connection error in getAnalyticsSnapshot, retrying...", {
810
+ operation: 'getAnalyticsSnapshot',
811
+ model: 'AnalyticsSnapshot',
812
+ attempt: retryCount,
813
+ maxRetries: MAX_RETRIES,
814
+ });
612
815
  await new Promise(resolve => setTimeout(resolve, delay));
613
816
  continue;
614
817
  }
615
- // Log the error and rethrow
616
- logger_1.logger.error("Database error occurred", { error: String(error) });
818
+ // Log structured error details and rethrow
819
+ logger_1.logger.error("Database get operation failed", {
820
+ operation: 'getAnalyticsSnapshot',
821
+ model: 'AnalyticsSnapshot',
822
+ error: String(error),
823
+ isRetryable: isConnectionError,
824
+ });
617
825
  throw error;
618
826
  }
619
827
  }
@@ -671,12 +879,22 @@ exports.AnalyticsSnapshot = {
671
879
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
672
880
  retryCount++;
673
881
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
674
- logger_1.logger.warn("Database connection error, retrying...");
882
+ logger_1.logger.warn("Database connection error in getAllAnalyticsSnapshot, retrying...", {
883
+ operation: 'getAllAnalyticsSnapshot',
884
+ model: 'AnalyticsSnapshot',
885
+ attempt: retryCount,
886
+ maxRetries: MAX_RETRIES,
887
+ });
675
888
  await new Promise(resolve => setTimeout(resolve, delay));
676
889
  continue;
677
890
  }
678
- // Log the error and rethrow
679
- logger_1.logger.error("Database error occurred", { error: String(error) });
891
+ // Log structured error details and rethrow
892
+ logger_1.logger.error("Database getAll operation failed", {
893
+ operation: 'getAllAnalyticsSnapshot',
894
+ model: 'AnalyticsSnapshot',
895
+ error: String(error),
896
+ isRetryable: isConnectionError,
897
+ });
680
898
  throw error;
681
899
  }
682
900
  }
@@ -753,12 +971,22 @@ exports.AnalyticsSnapshot = {
753
971
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
754
972
  retryCount++;
755
973
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
756
- logger_1.logger.warn("Database connection error, retrying...");
974
+ logger_1.logger.warn("Database connection error in findManyAnalyticsSnapshot, retrying...", {
975
+ operation: 'findManyAnalyticsSnapshot',
976
+ model: 'AnalyticsSnapshot',
977
+ attempt: retryCount,
978
+ maxRetries: MAX_RETRIES,
979
+ });
757
980
  await new Promise(resolve => setTimeout(resolve, delay));
758
981
  continue;
759
982
  }
760
- // Log the error and rethrow
761
- logger_1.logger.error("Database error occurred", { error: String(error) });
983
+ // Log structured error details and rethrow
984
+ logger_1.logger.error("Database findMany operation failed", {
985
+ operation: 'findManyAnalyticsSnapshot',
986
+ model: 'AnalyticsSnapshot',
987
+ error: String(error),
988
+ isRetryable: isConnectionError,
989
+ });
762
990
  throw error;
763
991
  }
764
992
  }