@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
@@ -82,6 +82,27 @@ export const InstitutionalSentimentMetrics = {
82
82
  }
83
83
  catch (error) {
84
84
  lastError = error;
85
+ // Check for constraint violations FIRST - these are NEVER retryable
86
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
87
+ error.message?.includes('violates unique constraint') ||
88
+ error.message?.includes('violates foreign key constraint') ||
89
+ error.message?.includes('unique constraint') ||
90
+ error.message?.includes('23514') ||
91
+ error.message?.includes('23505') ||
92
+ error.message?.includes('P2002') ||
93
+ error.message?.includes('P2003');
94
+ if (isConstraintViolation) {
95
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
96
+ logger.error("Non-retryable constraint violation in createOneInstitutionalSentimentMetrics", {
97
+ operation: 'createOneInstitutionalSentimentMetrics',
98
+ model: 'InstitutionalSentimentMetrics',
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
107
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
87
108
  error.message?.includes('Cannot reach database server') ||
@@ -91,12 +112,22 @@ export const InstitutionalSentimentMetrics = {
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.warn("Database connection error, retrying...");
115
+ logger.warn("Database connection error in createOneInstitutionalSentimentMetrics, retrying...", {
116
+ operation: 'createOneInstitutionalSentimentMetrics',
117
+ model: 'InstitutionalSentimentMetrics',
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.error("Database error occurred", { error: String(error) });
124
+ // Log structured error details and rethrow
125
+ logger.error("Database create operation failed", {
126
+ operation: 'createOneInstitutionalSentimentMetrics',
127
+ model: 'InstitutionalSentimentMetrics',
128
+ error: String(error),
129
+ isRetryable: isConnectionError,
130
+ });
100
131
  throw error;
101
132
  }
102
133
  }
@@ -160,6 +191,27 @@ export const InstitutionalSentimentMetrics = {
160
191
  }
161
192
  catch (error) {
162
193
  lastError = error;
194
+ // Check for constraint violations FIRST - these are NEVER retryable
195
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
196
+ error.message?.includes('violates unique constraint') ||
197
+ error.message?.includes('violates foreign key constraint') ||
198
+ error.message?.includes('unique constraint') ||
199
+ error.message?.includes('23514') ||
200
+ error.message?.includes('23505') ||
201
+ error.message?.includes('P2002') ||
202
+ error.message?.includes('P2003');
203
+ if (isConstraintViolation) {
204
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
205
+ logger.error("Non-retryable constraint violation in createManyInstitutionalSentimentMetrics", {
206
+ operation: 'createManyInstitutionalSentimentMetrics',
207
+ model: 'InstitutionalSentimentMetrics',
208
+ error: String(error),
209
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
210
+ errorCategory: 'CONSTRAINT_VIOLATION',
211
+ isRetryable: false,
212
+ });
213
+ throw error;
214
+ }
163
215
  // Check if this is a database connection error that we should retry
164
216
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
165
217
  error.message?.includes('Cannot reach database server') ||
@@ -169,12 +221,22 @@ export const InstitutionalSentimentMetrics = {
169
221
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
170
222
  retryCount++;
171
223
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
172
- logger.warn("Database connection error, retrying...");
224
+ logger.warn("Database connection error in createManyInstitutionalSentimentMetrics, retrying...", {
225
+ operation: 'createManyInstitutionalSentimentMetrics',
226
+ model: 'InstitutionalSentimentMetrics',
227
+ attempt: retryCount,
228
+ maxRetries: MAX_RETRIES,
229
+ });
173
230
  await new Promise(resolve => setTimeout(resolve, delay));
174
231
  continue;
175
232
  }
176
- // Log the error and rethrow
177
- logger.error("Database error occurred", { error: String(error) });
233
+ // Log structured error details and rethrow
234
+ logger.error("Database createMany operation failed", {
235
+ operation: 'createManyInstitutionalSentimentMetrics',
236
+ model: 'InstitutionalSentimentMetrics',
237
+ error: String(error),
238
+ isRetryable: isConnectionError,
239
+ });
178
240
  throw error;
179
241
  }
180
242
  }
@@ -261,6 +323,28 @@ export const InstitutionalSentimentMetrics = {
261
323
  }
262
324
  catch (error) {
263
325
  lastError = error;
326
+ // Check for constraint violations FIRST - these are NEVER retryable
327
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
328
+ error.message?.includes('violates unique constraint') ||
329
+ error.message?.includes('violates foreign key constraint') ||
330
+ error.message?.includes('unique constraint') ||
331
+ error.message?.includes('23514') ||
332
+ error.message?.includes('23505') ||
333
+ error.message?.includes('P2002') ||
334
+ error.message?.includes('P2003');
335
+ if (isConstraintViolation) {
336
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
337
+ logger.error("Non-retryable constraint violation in updateOneInstitutionalSentimentMetrics", {
338
+ operation: 'updateOneInstitutionalSentimentMetrics',
339
+ model: 'InstitutionalSentimentMetrics',
340
+ error: String(error),
341
+ recordId: props.id,
342
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
343
+ errorCategory: 'CONSTRAINT_VIOLATION',
344
+ isRetryable: false,
345
+ });
346
+ throw error;
347
+ }
264
348
  // Check if this is a database connection error that we should retry
265
349
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
266
350
  error.message?.includes('Cannot reach database server') ||
@@ -270,12 +354,24 @@ export const InstitutionalSentimentMetrics = {
270
354
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
271
355
  retryCount++;
272
356
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
273
- logger.warn("Database connection error, retrying...");
357
+ logger.warn("Database connection error in updateOneInstitutionalSentimentMetrics, retrying...", {
358
+ operation: 'updateOneInstitutionalSentimentMetrics',
359
+ model: 'InstitutionalSentimentMetrics',
360
+ attempt: retryCount,
361
+ maxRetries: MAX_RETRIES,
362
+ recordId: props.id,
363
+ });
274
364
  await new Promise(resolve => setTimeout(resolve, delay));
275
365
  continue;
276
366
  }
277
- // Log the error and rethrow
278
- logger.error("Database error occurred", { error: String(error) });
367
+ // Log structured error details and rethrow
368
+ logger.error("Database update operation failed", {
369
+ operation: 'updateOneInstitutionalSentimentMetrics',
370
+ model: 'InstitutionalSentimentMetrics',
371
+ error: String(error),
372
+ recordId: props.id,
373
+ isRetryable: isConnectionError,
374
+ });
279
375
  throw error;
280
376
  }
281
377
  }
@@ -365,6 +461,28 @@ export const InstitutionalSentimentMetrics = {
365
461
  }
366
462
  catch (error) {
367
463
  lastError = error;
464
+ // Check for constraint violations FIRST - these are NEVER retryable
465
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
466
+ error.message?.includes('violates unique constraint') ||
467
+ error.message?.includes('violates foreign key constraint') ||
468
+ error.message?.includes('unique constraint') ||
469
+ error.message?.includes('23514') ||
470
+ error.message?.includes('23505') ||
471
+ error.message?.includes('P2002') ||
472
+ error.message?.includes('P2003');
473
+ if (isConstraintViolation) {
474
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
475
+ logger.error("Non-retryable constraint violation in upsertOneInstitutionalSentimentMetrics", {
476
+ operation: 'upsertOneInstitutionalSentimentMetrics',
477
+ model: 'InstitutionalSentimentMetrics',
478
+ error: String(error),
479
+ recordId: props.id,
480
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
481
+ errorCategory: 'CONSTRAINT_VIOLATION',
482
+ isRetryable: false,
483
+ });
484
+ throw error;
485
+ }
368
486
  // Check if this is a database connection error that we should retry
369
487
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
370
488
  error.message?.includes('Cannot reach database server') ||
@@ -374,12 +492,24 @@ export const InstitutionalSentimentMetrics = {
374
492
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
375
493
  retryCount++;
376
494
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
377
- logger.warn("Database connection error, retrying...");
495
+ logger.warn("Database connection error in upsertOneInstitutionalSentimentMetrics, retrying...", {
496
+ operation: 'upsertOneInstitutionalSentimentMetrics',
497
+ model: 'InstitutionalSentimentMetrics',
498
+ attempt: retryCount,
499
+ maxRetries: MAX_RETRIES,
500
+ recordId: props.id,
501
+ });
378
502
  await new Promise(resolve => setTimeout(resolve, delay));
379
503
  continue;
380
504
  }
381
- // Log the error and rethrow
382
- logger.error("Database error occurred", { error: String(error) });
505
+ // Log structured error details and rethrow
506
+ logger.error("Database upsert operation failed", {
507
+ operation: 'upsertOneInstitutionalSentimentMetrics',
508
+ model: 'InstitutionalSentimentMetrics',
509
+ error: String(error),
510
+ recordId: props.id,
511
+ isRetryable: isConnectionError,
512
+ });
383
513
  throw error;
384
514
  }
385
515
  }
@@ -466,6 +596,27 @@ export const InstitutionalSentimentMetrics = {
466
596
  }
467
597
  catch (error) {
468
598
  lastError = error;
599
+ // Check for constraint violations FIRST - these are NEVER retryable
600
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
601
+ error.message?.includes('violates unique constraint') ||
602
+ error.message?.includes('violates foreign key constraint') ||
603
+ error.message?.includes('unique constraint') ||
604
+ error.message?.includes('23514') ||
605
+ error.message?.includes('23505') ||
606
+ error.message?.includes('P2002') ||
607
+ error.message?.includes('P2003');
608
+ if (isConstraintViolation) {
609
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
610
+ logger.error("Non-retryable constraint violation in updateManyInstitutionalSentimentMetrics", {
611
+ operation: 'updateManyInstitutionalSentimentMetrics',
612
+ model: 'InstitutionalSentimentMetrics',
613
+ error: String(error),
614
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
615
+ errorCategory: 'CONSTRAINT_VIOLATION',
616
+ isRetryable: false,
617
+ });
618
+ throw error;
619
+ }
469
620
  // Check if this is a database connection error that we should retry
470
621
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
471
622
  error.message?.includes('Cannot reach database server') ||
@@ -475,12 +626,22 @@ export const InstitutionalSentimentMetrics = {
475
626
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
476
627
  retryCount++;
477
628
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
478
- logger.warn("Database connection error, retrying...");
629
+ logger.warn("Database connection error in updateManyInstitutionalSentimentMetrics, retrying...", {
630
+ operation: 'updateManyInstitutionalSentimentMetrics',
631
+ model: 'InstitutionalSentimentMetrics',
632
+ attempt: retryCount,
633
+ maxRetries: MAX_RETRIES,
634
+ });
479
635
  await new Promise(resolve => setTimeout(resolve, delay));
480
636
  continue;
481
637
  }
482
- // Log the error and rethrow
483
- logger.error("Database error occurred", { error: String(error) });
638
+ // Log structured error details and rethrow
639
+ logger.error("Database updateMany operation failed", {
640
+ operation: 'updateManyInstitutionalSentimentMetrics',
641
+ model: 'InstitutionalSentimentMetrics',
642
+ error: String(error),
643
+ isRetryable: isConnectionError,
644
+ });
484
645
  throw error;
485
646
  }
486
647
  }
@@ -538,6 +699,31 @@ export const InstitutionalSentimentMetrics = {
538
699
  }
539
700
  catch (error) {
540
701
  lastError = error;
702
+ // Check for constraint violations FIRST - these are NEVER retryable
703
+ // (e.g., foreign key constraints preventing deletion)
704
+ const isConstraintViolation = error.message?.includes('violates check constraint') ||
705
+ error.message?.includes('violates unique constraint') ||
706
+ error.message?.includes('violates foreign key constraint') ||
707
+ error.message?.includes('unique constraint') ||
708
+ error.message?.includes('23514') ||
709
+ error.message?.includes('23505') ||
710
+ error.message?.includes('23503') ||
711
+ error.message?.includes('P2002') ||
712
+ error.message?.includes('P2003') ||
713
+ error.message?.includes('P2014');
714
+ if (isConstraintViolation) {
715
+ const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
716
+ logger.error("Non-retryable constraint violation in deleteOneInstitutionalSentimentMetrics", {
717
+ operation: 'deleteOneInstitutionalSentimentMetrics',
718
+ model: 'InstitutionalSentimentMetrics',
719
+ error: String(error),
720
+ recordId: props.id,
721
+ constraintName: constraintMatch ? constraintMatch[1] : undefined,
722
+ errorCategory: 'CONSTRAINT_VIOLATION',
723
+ isRetryable: false,
724
+ });
725
+ throw error;
726
+ }
541
727
  // Check if this is a database connection error that we should retry
542
728
  const isConnectionError = error.message?.includes('Server has closed the connection') ||
543
729
  error.message?.includes('Cannot reach database server') ||
@@ -547,12 +733,24 @@ export const InstitutionalSentimentMetrics = {
547
733
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
548
734
  retryCount++;
549
735
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
550
- logger.warn("Database connection error, retrying...");
736
+ logger.warn("Database connection error in deleteOneInstitutionalSentimentMetrics, retrying...", {
737
+ operation: 'deleteOneInstitutionalSentimentMetrics',
738
+ model: 'InstitutionalSentimentMetrics',
739
+ attempt: retryCount,
740
+ maxRetries: MAX_RETRIES,
741
+ recordId: props.id,
742
+ });
551
743
  await new Promise(resolve => setTimeout(resolve, delay));
552
744
  continue;
553
745
  }
554
- // Log the error and rethrow
555
- logger.error("Database error occurred", { error: String(error) });
746
+ // Log structured error details and rethrow
747
+ logger.error("Database delete operation failed", {
748
+ operation: 'deleteOneInstitutionalSentimentMetrics',
749
+ model: 'InstitutionalSentimentMetrics',
750
+ error: String(error),
751
+ recordId: props.id,
752
+ isRetryable: isConnectionError,
753
+ });
556
754
  throw error;
557
755
  }
558
756
  }
@@ -618,12 +816,22 @@ export const InstitutionalSentimentMetrics = {
618
816
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
619
817
  retryCount++;
620
818
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
621
- logger.warn("Database connection error, retrying...");
819
+ logger.warn("Database connection error in getInstitutionalSentimentMetrics, retrying...", {
820
+ operation: 'getInstitutionalSentimentMetrics',
821
+ model: 'InstitutionalSentimentMetrics',
822
+ attempt: retryCount,
823
+ maxRetries: MAX_RETRIES,
824
+ });
622
825
  await new Promise(resolve => setTimeout(resolve, delay));
623
826
  continue;
624
827
  }
625
- // Log the error and rethrow
626
- logger.error("Database error occurred", { error: String(error) });
828
+ // Log structured error details and rethrow
829
+ logger.error("Database get operation failed", {
830
+ operation: 'getInstitutionalSentimentMetrics',
831
+ model: 'InstitutionalSentimentMetrics',
832
+ error: String(error),
833
+ isRetryable: isConnectionError,
834
+ });
627
835
  throw error;
628
836
  }
629
837
  }
@@ -680,12 +888,22 @@ export const InstitutionalSentimentMetrics = {
680
888
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
681
889
  retryCount++;
682
890
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
683
- logger.warn("Database connection error, retrying...");
891
+ logger.warn("Database connection error in getAllInstitutionalSentimentMetrics, retrying...", {
892
+ operation: 'getAllInstitutionalSentimentMetrics',
893
+ model: 'InstitutionalSentimentMetrics',
894
+ attempt: retryCount,
895
+ maxRetries: MAX_RETRIES,
896
+ });
684
897
  await new Promise(resolve => setTimeout(resolve, delay));
685
898
  continue;
686
899
  }
687
- // Log the error and rethrow
688
- logger.error("Database error occurred", { error: String(error) });
900
+ // Log structured error details and rethrow
901
+ logger.error("Database getAll operation failed", {
902
+ operation: 'getAllInstitutionalSentimentMetrics',
903
+ model: 'InstitutionalSentimentMetrics',
904
+ error: String(error),
905
+ isRetryable: isConnectionError,
906
+ });
689
907
  throw error;
690
908
  }
691
909
  }
@@ -758,12 +976,22 @@ export const InstitutionalSentimentMetrics = {
758
976
  if (isConnectionError && retryCount < MAX_RETRIES - 1) {
759
977
  retryCount++;
760
978
  const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
761
- logger.warn("Database connection error, retrying...");
979
+ logger.warn("Database connection error in findManyInstitutionalSentimentMetrics, retrying...", {
980
+ operation: 'findManyInstitutionalSentimentMetrics',
981
+ model: 'InstitutionalSentimentMetrics',
982
+ attempt: retryCount,
983
+ maxRetries: MAX_RETRIES,
984
+ });
762
985
  await new Promise(resolve => setTimeout(resolve, delay));
763
986
  continue;
764
987
  }
765
- // Log the error and rethrow
766
- logger.error("Database error occurred", { error: String(error) });
988
+ // Log structured error details and rethrow
989
+ logger.error("Database findMany operation failed", {
990
+ operation: 'findManyInstitutionalSentimentMetrics',
991
+ model: 'InstitutionalSentimentMetrics',
992
+ error: String(error),
993
+ isRetryable: isConnectionError,
994
+ });
767
995
  throw error;
768
996
  }
769
997
  }
@@ -1 +1 @@
1
- {"version":3,"file":"InviteToken.d.ts","sourceRoot":"","sources":["../../src/InviteToken.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,mDAAmD,CAAC;AACnG,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AAsK7G,eAAO,MAAM,WAAW;IAEtB;;;;;OAKG;IAEH;;;;;;OAMG;kBACiB,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IAqVxH;;;;;;OAMG;sBACqB,eAAe,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAgFrI;;;;;;OAMG;kBACiB,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IA2lCtH;;;;;;OAMG;kBACiB,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IAg2CtH;;;;;;OAMG;sBACqB,eAAe,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IA6lCrI;;;;;;OAMG;kBACiB,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IA2EtH;;;;;;;OAOG;eACc,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IA8E5I;;;;;OAKG;0BACyB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;IAkEvG;;;;;;;OAOG;oBACmB,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;CAmFpJ,CAAC"}
1
+ {"version":3,"file":"InviteToken.d.ts","sourceRoot":"","sources":["../../src/InviteToken.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,mDAAmD,CAAC;AACnG,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AAsK7G,eAAO,MAAM,WAAW;IAEtB;;;;;OAKG;IAEH;;;;;;OAMG;kBACiB,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IAuXxH;;;;;;OAMG;sBACqB,eAAe,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAkHrI;;;;;;OAMG;kBACiB,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IAgoCtH;;;;;;OAMG;kBACiB,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IAq4CtH;;;;;;OAMG;sBACqB,eAAe,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IA+nCrI;;;;;;OAMG;kBACiB,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IAmHtH;;;;;;;OAOG;eACc,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAwF5I;;;;;OAKG;0BACyB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;IA4EvG;;;;;;;OAOG;oBACmB,eAAe,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;CA6FpJ,CAAC"}