@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.
- package/ABTest.cjs +291 -63
- package/Account.cjs +291 -63
- package/AccountLinkingRequest.cjs +291 -63
- package/Action.cjs +291 -63
- package/Alert.cjs +291 -63
- package/Allocation.cjs +291 -63
- package/AlpacaAccount.cjs +291 -63
- package/AnalyticsConfiguration.cjs +291 -63
- package/AnalyticsSnapshot.cjs +291 -63
- package/Asset.cjs +291 -63
- package/AuditLog.cjs +291 -63
- package/Authenticator.cjs +291 -63
- package/Configuration.cjs +291 -63
- package/ConflictEvent.cjs +291 -63
- package/ConnectionHealthSnapshot.cjs +291 -63
- package/Customer.cjs +291 -63
- package/DeadLetterMessage.cjs +291 -63
- package/EconomicEvent.cjs +291 -63
- package/Event.cjs +291 -63
- package/EventSnapshot.cjs +291 -63
- package/FeatureImportanceAnalysis.cjs +291 -63
- package/InstitutionalFlowSignal.cjs +291 -63
- package/InstitutionalHolding.cjs +291 -63
- package/InstitutionalSentimentAlerts.cjs +291 -63
- package/InstitutionalSentimentErrors.cjs +291 -63
- package/InstitutionalSentimentHistory.cjs +291 -63
- package/InstitutionalSentimentMetrics.cjs +291 -63
- package/InviteToken.cjs +291 -63
- package/LinkedProvider.cjs +291 -63
- package/MLTrainingData.cjs +291 -63
- package/MarketSentiment.cjs +291 -63
- package/ModelArtifact.cjs +291 -63
- package/ModelVersion.cjs +291 -63
- package/ModelVersionArtifact.cjs +291 -63
- package/NewsArticle.cjs +291 -63
- package/NewsArticleAssetSentiment.cjs +291 -63
- package/OptionsContract.cjs +291 -63
- package/OptionsGreeksHistory.cjs +291 -63
- package/OptionsPosition.cjs +291 -63
- package/OptionsTradeExecution.cjs +291 -63
- package/PortfolioGreeksHistory.cjs +291 -63
- package/ScheduledOptionOrder.cjs +291 -63
- package/Session.cjs +291 -63
- package/SignalGeneratorMetrics.cjs +291 -63
- package/SignalLineage.cjs +291 -63
- package/SignalOutcome.cjs +291 -63
- package/SignalPriorityQueue.cjs +291 -63
- package/SyncEvent.cjs +291 -63
- package/SystemAlert.cjs +291 -63
- package/Trade.cjs +291 -63
- package/TradeAuditEvent.cjs +291 -63
- package/TradeExecutionHistory.cjs +291 -63
- package/User.cjs +291 -63
- package/VerificationToken.cjs +291 -63
- package/WaitlistEntry.cjs +291 -63
- package/esm/ABTest.d.ts.map +1 -1
- package/esm/ABTest.js.map +1 -1
- package/esm/ABTest.mjs +255 -27
- package/esm/Account.d.ts.map +1 -1
- package/esm/Account.js.map +1 -1
- package/esm/Account.mjs +255 -27
- package/esm/AccountLinkingRequest.d.ts.map +1 -1
- package/esm/AccountLinkingRequest.js.map +1 -1
- package/esm/AccountLinkingRequest.mjs +255 -27
- package/esm/Action.d.ts.map +1 -1
- package/esm/Action.js.map +1 -1
- package/esm/Action.mjs +255 -27
- package/esm/Alert.d.ts.map +1 -1
- package/esm/Alert.js.map +1 -1
- package/esm/Alert.mjs +255 -27
- package/esm/Allocation.d.ts.map +1 -1
- package/esm/Allocation.js.map +1 -1
- package/esm/Allocation.mjs +255 -27
- package/esm/AlpacaAccount.d.ts.map +1 -1
- package/esm/AlpacaAccount.js.map +1 -1
- package/esm/AlpacaAccount.mjs +255 -27
- package/esm/AnalyticsConfiguration.d.ts.map +1 -1
- package/esm/AnalyticsConfiguration.js.map +1 -1
- package/esm/AnalyticsConfiguration.mjs +255 -27
- package/esm/AnalyticsSnapshot.d.ts.map +1 -1
- package/esm/AnalyticsSnapshot.js.map +1 -1
- package/esm/AnalyticsSnapshot.mjs +255 -27
- package/esm/Asset.d.ts.map +1 -1
- package/esm/Asset.js.map +1 -1
- package/esm/Asset.mjs +255 -27
- package/esm/AuditLog.d.ts.map +1 -1
- package/esm/AuditLog.js.map +1 -1
- package/esm/AuditLog.mjs +255 -27
- package/esm/Authenticator.d.ts.map +1 -1
- package/esm/Authenticator.js.map +1 -1
- package/esm/Authenticator.mjs +255 -27
- package/esm/Configuration.d.ts.map +1 -1
- package/esm/Configuration.js.map +1 -1
- package/esm/Configuration.mjs +255 -27
- package/esm/ConflictEvent.d.ts.map +1 -1
- package/esm/ConflictEvent.js.map +1 -1
- package/esm/ConflictEvent.mjs +255 -27
- package/esm/ConnectionHealthSnapshot.d.ts.map +1 -1
- package/esm/ConnectionHealthSnapshot.js.map +1 -1
- package/esm/ConnectionHealthSnapshot.mjs +255 -27
- package/esm/Customer.d.ts.map +1 -1
- package/esm/Customer.js.map +1 -1
- package/esm/Customer.mjs +255 -27
- package/esm/DeadLetterMessage.d.ts.map +1 -1
- package/esm/DeadLetterMessage.js.map +1 -1
- package/esm/DeadLetterMessage.mjs +255 -27
- package/esm/EconomicEvent.d.ts.map +1 -1
- package/esm/EconomicEvent.js.map +1 -1
- package/esm/EconomicEvent.mjs +255 -27
- package/esm/Event.d.ts.map +1 -1
- package/esm/Event.js.map +1 -1
- package/esm/Event.mjs +255 -27
- package/esm/EventSnapshot.d.ts.map +1 -1
- package/esm/EventSnapshot.js.map +1 -1
- package/esm/EventSnapshot.mjs +255 -27
- package/esm/FeatureImportanceAnalysis.d.ts.map +1 -1
- package/esm/FeatureImportanceAnalysis.js.map +1 -1
- package/esm/FeatureImportanceAnalysis.mjs +255 -27
- package/esm/InstitutionalFlowSignal.d.ts.map +1 -1
- package/esm/InstitutionalFlowSignal.js.map +1 -1
- package/esm/InstitutionalFlowSignal.mjs +255 -27
- package/esm/InstitutionalHolding.d.ts.map +1 -1
- package/esm/InstitutionalHolding.js.map +1 -1
- package/esm/InstitutionalHolding.mjs +255 -27
- package/esm/InstitutionalSentimentAlerts.d.ts.map +1 -1
- package/esm/InstitutionalSentimentAlerts.js.map +1 -1
- package/esm/InstitutionalSentimentAlerts.mjs +255 -27
- package/esm/InstitutionalSentimentErrors.d.ts.map +1 -1
- package/esm/InstitutionalSentimentErrors.js.map +1 -1
- package/esm/InstitutionalSentimentErrors.mjs +255 -27
- package/esm/InstitutionalSentimentHistory.d.ts.map +1 -1
- package/esm/InstitutionalSentimentHistory.js.map +1 -1
- package/esm/InstitutionalSentimentHistory.mjs +255 -27
- package/esm/InstitutionalSentimentMetrics.d.ts.map +1 -1
- package/esm/InstitutionalSentimentMetrics.js.map +1 -1
- package/esm/InstitutionalSentimentMetrics.mjs +255 -27
- package/esm/InviteToken.d.ts.map +1 -1
- package/esm/InviteToken.js.map +1 -1
- package/esm/InviteToken.mjs +255 -27
- package/esm/LinkedProvider.d.ts.map +1 -1
- package/esm/LinkedProvider.js.map +1 -1
- package/esm/LinkedProvider.mjs +255 -27
- package/esm/MLTrainingData.d.ts.map +1 -1
- package/esm/MLTrainingData.js.map +1 -1
- package/esm/MLTrainingData.mjs +255 -27
- package/esm/MarketSentiment.d.ts.map +1 -1
- package/esm/MarketSentiment.js.map +1 -1
- package/esm/MarketSentiment.mjs +255 -27
- package/esm/ModelArtifact.d.ts.map +1 -1
- package/esm/ModelArtifact.js.map +1 -1
- package/esm/ModelArtifact.mjs +255 -27
- package/esm/ModelVersion.d.ts.map +1 -1
- package/esm/ModelVersion.js.map +1 -1
- package/esm/ModelVersion.mjs +255 -27
- package/esm/ModelVersionArtifact.d.ts.map +1 -1
- package/esm/ModelVersionArtifact.js.map +1 -1
- package/esm/ModelVersionArtifact.mjs +255 -27
- package/esm/NewsArticle.d.ts.map +1 -1
- package/esm/NewsArticle.js.map +1 -1
- package/esm/NewsArticle.mjs +255 -27
- package/esm/NewsArticleAssetSentiment.d.ts.map +1 -1
- package/esm/NewsArticleAssetSentiment.js.map +1 -1
- package/esm/NewsArticleAssetSentiment.mjs +255 -27
- package/esm/OptionsContract.d.ts.map +1 -1
- package/esm/OptionsContract.js.map +1 -1
- package/esm/OptionsContract.mjs +255 -27
- package/esm/OptionsGreeksHistory.d.ts.map +1 -1
- package/esm/OptionsGreeksHistory.js.map +1 -1
- package/esm/OptionsGreeksHistory.mjs +255 -27
- package/esm/OptionsPosition.d.ts.map +1 -1
- package/esm/OptionsPosition.js.map +1 -1
- package/esm/OptionsPosition.mjs +255 -27
- package/esm/OptionsTradeExecution.d.ts.map +1 -1
- package/esm/OptionsTradeExecution.js.map +1 -1
- package/esm/OptionsTradeExecution.mjs +255 -27
- package/esm/PortfolioGreeksHistory.d.ts.map +1 -1
- package/esm/PortfolioGreeksHistory.js.map +1 -1
- package/esm/PortfolioGreeksHistory.mjs +255 -27
- package/esm/ScheduledOptionOrder.d.ts.map +1 -1
- package/esm/ScheduledOptionOrder.js.map +1 -1
- package/esm/ScheduledOptionOrder.mjs +255 -27
- package/esm/Session.d.ts.map +1 -1
- package/esm/Session.js.map +1 -1
- package/esm/Session.mjs +255 -27
- package/esm/SignalGeneratorMetrics.d.ts.map +1 -1
- package/esm/SignalGeneratorMetrics.js.map +1 -1
- package/esm/SignalGeneratorMetrics.mjs +255 -27
- package/esm/SignalLineage.d.ts.map +1 -1
- package/esm/SignalLineage.js.map +1 -1
- package/esm/SignalLineage.mjs +255 -27
- package/esm/SignalOutcome.d.ts.map +1 -1
- package/esm/SignalOutcome.js.map +1 -1
- package/esm/SignalOutcome.mjs +255 -27
- package/esm/SignalPriorityQueue.d.ts.map +1 -1
- package/esm/SignalPriorityQueue.js.map +1 -1
- package/esm/SignalPriorityQueue.mjs +255 -27
- package/esm/SyncEvent.d.ts.map +1 -1
- package/esm/SyncEvent.js.map +1 -1
- package/esm/SyncEvent.mjs +255 -27
- package/esm/SystemAlert.d.ts.map +1 -1
- package/esm/SystemAlert.js.map +1 -1
- package/esm/SystemAlert.mjs +255 -27
- package/esm/Trade.d.ts.map +1 -1
- package/esm/Trade.js.map +1 -1
- package/esm/Trade.mjs +255 -27
- package/esm/TradeAuditEvent.d.ts.map +1 -1
- package/esm/TradeAuditEvent.js.map +1 -1
- package/esm/TradeAuditEvent.mjs +255 -27
- package/esm/TradeExecutionHistory.d.ts.map +1 -1
- package/esm/TradeExecutionHistory.js.map +1 -1
- package/esm/TradeExecutionHistory.mjs +255 -27
- package/esm/User.d.ts.map +1 -1
- package/esm/User.js.map +1 -1
- package/esm/User.mjs +255 -27
- package/esm/VerificationToken.d.ts.map +1 -1
- package/esm/VerificationToken.js.map +1 -1
- package/esm/VerificationToken.mjs +255 -27
- package/esm/WaitlistEntry.d.ts.map +1 -1
- package/esm/WaitlistEntry.js.map +1 -1
- package/esm/WaitlistEntry.mjs +255 -27
- package/esm/middleware/audit-logger.d.ts +0 -7
- package/esm/middleware/audit-logger.d.ts.map +1 -1
- package/esm/middleware/audit-logger.js.map +1 -1
- package/esm/middleware/audit-logger.mjs +5 -3
- package/esm/prismaClient.d.ts.map +1 -1
- package/esm/prismaClient.js.map +1 -1
- package/esm/prismaClient.mjs +38 -9
- package/package.json +1 -1
- package/prismaClient.cjs +38 -9
package/esm/MarketSentiment.mjs
CHANGED
|
@@ -75,6 +75,27 @@ export const MarketSentiment = {
|
|
|
75
75
|
}
|
|
76
76
|
catch (error) {
|
|
77
77
|
lastError = error;
|
|
78
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
79
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
80
|
+
error.message?.includes('violates unique constraint') ||
|
|
81
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
82
|
+
error.message?.includes('unique constraint') ||
|
|
83
|
+
error.message?.includes('23514') ||
|
|
84
|
+
error.message?.includes('23505') ||
|
|
85
|
+
error.message?.includes('P2002') ||
|
|
86
|
+
error.message?.includes('P2003');
|
|
87
|
+
if (isConstraintViolation) {
|
|
88
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
89
|
+
logger.error("Non-retryable constraint violation in createOneMarketSentiment", {
|
|
90
|
+
operation: 'createOneMarketSentiment',
|
|
91
|
+
model: 'MarketSentiment',
|
|
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
100
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
80
101
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -84,12 +105,22 @@ export const MarketSentiment = {
|
|
|
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.warn("Database connection error, retrying..."
|
|
108
|
+
logger.warn("Database connection error in createOneMarketSentiment, retrying...", {
|
|
109
|
+
operation: 'createOneMarketSentiment',
|
|
110
|
+
model: 'MarketSentiment',
|
|
111
|
+
attempt: retryCount,
|
|
112
|
+
maxRetries: MAX_RETRIES,
|
|
113
|
+
});
|
|
88
114
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
89
115
|
continue;
|
|
90
116
|
}
|
|
91
|
-
// Log
|
|
92
|
-
logger.error("Database
|
|
117
|
+
// Log structured error details and rethrow
|
|
118
|
+
logger.error("Database create operation failed", {
|
|
119
|
+
operation: 'createOneMarketSentiment',
|
|
120
|
+
model: 'MarketSentiment',
|
|
121
|
+
error: String(error),
|
|
122
|
+
isRetryable: isConnectionError,
|
|
123
|
+
});
|
|
93
124
|
throw error;
|
|
94
125
|
}
|
|
95
126
|
}
|
|
@@ -149,6 +180,27 @@ export const MarketSentiment = {
|
|
|
149
180
|
}
|
|
150
181
|
catch (error) {
|
|
151
182
|
lastError = error;
|
|
183
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
184
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
185
|
+
error.message?.includes('violates unique constraint') ||
|
|
186
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
187
|
+
error.message?.includes('unique constraint') ||
|
|
188
|
+
error.message?.includes('23514') ||
|
|
189
|
+
error.message?.includes('23505') ||
|
|
190
|
+
error.message?.includes('P2002') ||
|
|
191
|
+
error.message?.includes('P2003');
|
|
192
|
+
if (isConstraintViolation) {
|
|
193
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
194
|
+
logger.error("Non-retryable constraint violation in createManyMarketSentiment", {
|
|
195
|
+
operation: 'createManyMarketSentiment',
|
|
196
|
+
model: 'MarketSentiment',
|
|
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
205
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
154
206
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -158,12 +210,22 @@ export const MarketSentiment = {
|
|
|
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.warn("Database connection error, retrying..."
|
|
213
|
+
logger.warn("Database connection error in createManyMarketSentiment, retrying...", {
|
|
214
|
+
operation: 'createManyMarketSentiment',
|
|
215
|
+
model: 'MarketSentiment',
|
|
216
|
+
attempt: retryCount,
|
|
217
|
+
maxRetries: MAX_RETRIES,
|
|
218
|
+
});
|
|
162
219
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
163
220
|
continue;
|
|
164
221
|
}
|
|
165
|
-
// Log
|
|
166
|
-
logger.error("Database
|
|
222
|
+
// Log structured error details and rethrow
|
|
223
|
+
logger.error("Database createMany operation failed", {
|
|
224
|
+
operation: 'createManyMarketSentiment',
|
|
225
|
+
model: 'MarketSentiment',
|
|
226
|
+
error: String(error),
|
|
227
|
+
isRetryable: isConnectionError,
|
|
228
|
+
});
|
|
167
229
|
throw error;
|
|
168
230
|
}
|
|
169
231
|
}
|
|
@@ -241,6 +303,28 @@ export const MarketSentiment = {
|
|
|
241
303
|
}
|
|
242
304
|
catch (error) {
|
|
243
305
|
lastError = error;
|
|
306
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
307
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
308
|
+
error.message?.includes('violates unique constraint') ||
|
|
309
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
310
|
+
error.message?.includes('unique constraint') ||
|
|
311
|
+
error.message?.includes('23514') ||
|
|
312
|
+
error.message?.includes('23505') ||
|
|
313
|
+
error.message?.includes('P2002') ||
|
|
314
|
+
error.message?.includes('P2003');
|
|
315
|
+
if (isConstraintViolation) {
|
|
316
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
317
|
+
logger.error("Non-retryable constraint violation in updateOneMarketSentiment", {
|
|
318
|
+
operation: 'updateOneMarketSentiment',
|
|
319
|
+
model: 'MarketSentiment',
|
|
320
|
+
error: String(error),
|
|
321
|
+
recordId: props.id,
|
|
322
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
323
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
324
|
+
isRetryable: false,
|
|
325
|
+
});
|
|
326
|
+
throw error;
|
|
327
|
+
}
|
|
244
328
|
// Check if this is a database connection error that we should retry
|
|
245
329
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
246
330
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -250,12 +334,24 @@ export const MarketSentiment = {
|
|
|
250
334
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
251
335
|
retryCount++;
|
|
252
336
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
253
|
-
logger.warn("Database connection error, retrying..."
|
|
337
|
+
logger.warn("Database connection error in updateOneMarketSentiment, retrying...", {
|
|
338
|
+
operation: 'updateOneMarketSentiment',
|
|
339
|
+
model: 'MarketSentiment',
|
|
340
|
+
attempt: retryCount,
|
|
341
|
+
maxRetries: MAX_RETRIES,
|
|
342
|
+
recordId: props.id,
|
|
343
|
+
});
|
|
254
344
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
255
345
|
continue;
|
|
256
346
|
}
|
|
257
|
-
// Log
|
|
258
|
-
logger.error("Database
|
|
347
|
+
// Log structured error details and rethrow
|
|
348
|
+
logger.error("Database update operation failed", {
|
|
349
|
+
operation: 'updateOneMarketSentiment',
|
|
350
|
+
model: 'MarketSentiment',
|
|
351
|
+
error: String(error),
|
|
352
|
+
recordId: props.id,
|
|
353
|
+
isRetryable: isConnectionError,
|
|
354
|
+
});
|
|
259
355
|
throw error;
|
|
260
356
|
}
|
|
261
357
|
}
|
|
@@ -329,6 +425,28 @@ export const MarketSentiment = {
|
|
|
329
425
|
}
|
|
330
426
|
catch (error) {
|
|
331
427
|
lastError = error;
|
|
428
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
429
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
430
|
+
error.message?.includes('violates unique constraint') ||
|
|
431
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
432
|
+
error.message?.includes('unique constraint') ||
|
|
433
|
+
error.message?.includes('23514') ||
|
|
434
|
+
error.message?.includes('23505') ||
|
|
435
|
+
error.message?.includes('P2002') ||
|
|
436
|
+
error.message?.includes('P2003');
|
|
437
|
+
if (isConstraintViolation) {
|
|
438
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
439
|
+
logger.error("Non-retryable constraint violation in upsertOneMarketSentiment", {
|
|
440
|
+
operation: 'upsertOneMarketSentiment',
|
|
441
|
+
model: 'MarketSentiment',
|
|
442
|
+
error: String(error),
|
|
443
|
+
recordId: props.id,
|
|
444
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
445
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
446
|
+
isRetryable: false,
|
|
447
|
+
});
|
|
448
|
+
throw error;
|
|
449
|
+
}
|
|
332
450
|
// Check if this is a database connection error that we should retry
|
|
333
451
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
334
452
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -338,12 +456,24 @@ export const MarketSentiment = {
|
|
|
338
456
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
339
457
|
retryCount++;
|
|
340
458
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
341
|
-
logger.warn("Database connection error, retrying..."
|
|
459
|
+
logger.warn("Database connection error in upsertOneMarketSentiment, retrying...", {
|
|
460
|
+
operation: 'upsertOneMarketSentiment',
|
|
461
|
+
model: 'MarketSentiment',
|
|
462
|
+
attempt: retryCount,
|
|
463
|
+
maxRetries: MAX_RETRIES,
|
|
464
|
+
recordId: props.id,
|
|
465
|
+
});
|
|
342
466
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
343
467
|
continue;
|
|
344
468
|
}
|
|
345
|
-
// Log
|
|
346
|
-
logger.error("Database
|
|
469
|
+
// Log structured error details and rethrow
|
|
470
|
+
logger.error("Database upsert operation failed", {
|
|
471
|
+
operation: 'upsertOneMarketSentiment',
|
|
472
|
+
model: 'MarketSentiment',
|
|
473
|
+
error: String(error),
|
|
474
|
+
recordId: props.id,
|
|
475
|
+
isRetryable: isConnectionError,
|
|
476
|
+
});
|
|
347
477
|
throw error;
|
|
348
478
|
}
|
|
349
479
|
}
|
|
@@ -421,6 +551,27 @@ export const MarketSentiment = {
|
|
|
421
551
|
}
|
|
422
552
|
catch (error) {
|
|
423
553
|
lastError = error;
|
|
554
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
555
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
556
|
+
error.message?.includes('violates unique constraint') ||
|
|
557
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
558
|
+
error.message?.includes('unique constraint') ||
|
|
559
|
+
error.message?.includes('23514') ||
|
|
560
|
+
error.message?.includes('23505') ||
|
|
561
|
+
error.message?.includes('P2002') ||
|
|
562
|
+
error.message?.includes('P2003');
|
|
563
|
+
if (isConstraintViolation) {
|
|
564
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
565
|
+
logger.error("Non-retryable constraint violation in updateManyMarketSentiment", {
|
|
566
|
+
operation: 'updateManyMarketSentiment',
|
|
567
|
+
model: 'MarketSentiment',
|
|
568
|
+
error: String(error),
|
|
569
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
570
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
571
|
+
isRetryable: false,
|
|
572
|
+
});
|
|
573
|
+
throw error;
|
|
574
|
+
}
|
|
424
575
|
// Check if this is a database connection error that we should retry
|
|
425
576
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
426
577
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -430,12 +581,22 @@ export const MarketSentiment = {
|
|
|
430
581
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
431
582
|
retryCount++;
|
|
432
583
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
433
|
-
logger.warn("Database connection error, retrying..."
|
|
584
|
+
logger.warn("Database connection error in updateManyMarketSentiment, retrying...", {
|
|
585
|
+
operation: 'updateManyMarketSentiment',
|
|
586
|
+
model: 'MarketSentiment',
|
|
587
|
+
attempt: retryCount,
|
|
588
|
+
maxRetries: MAX_RETRIES,
|
|
589
|
+
});
|
|
434
590
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
435
591
|
continue;
|
|
436
592
|
}
|
|
437
|
-
// Log
|
|
438
|
-
logger.error("Database
|
|
593
|
+
// Log structured error details and rethrow
|
|
594
|
+
logger.error("Database updateMany operation failed", {
|
|
595
|
+
operation: 'updateManyMarketSentiment',
|
|
596
|
+
model: 'MarketSentiment',
|
|
597
|
+
error: String(error),
|
|
598
|
+
isRetryable: isConnectionError,
|
|
599
|
+
});
|
|
439
600
|
throw error;
|
|
440
601
|
}
|
|
441
602
|
}
|
|
@@ -493,6 +654,31 @@ export const MarketSentiment = {
|
|
|
493
654
|
}
|
|
494
655
|
catch (error) {
|
|
495
656
|
lastError = error;
|
|
657
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
658
|
+
// (e.g., foreign key constraints preventing deletion)
|
|
659
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
660
|
+
error.message?.includes('violates unique constraint') ||
|
|
661
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
662
|
+
error.message?.includes('unique constraint') ||
|
|
663
|
+
error.message?.includes('23514') ||
|
|
664
|
+
error.message?.includes('23505') ||
|
|
665
|
+
error.message?.includes('23503') ||
|
|
666
|
+
error.message?.includes('P2002') ||
|
|
667
|
+
error.message?.includes('P2003') ||
|
|
668
|
+
error.message?.includes('P2014');
|
|
669
|
+
if (isConstraintViolation) {
|
|
670
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
671
|
+
logger.error("Non-retryable constraint violation in deleteOneMarketSentiment", {
|
|
672
|
+
operation: 'deleteOneMarketSentiment',
|
|
673
|
+
model: 'MarketSentiment',
|
|
674
|
+
error: String(error),
|
|
675
|
+
recordId: props.id,
|
|
676
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
677
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
678
|
+
isRetryable: false,
|
|
679
|
+
});
|
|
680
|
+
throw error;
|
|
681
|
+
}
|
|
496
682
|
// Check if this is a database connection error that we should retry
|
|
497
683
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
498
684
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -502,12 +688,24 @@ export const MarketSentiment = {
|
|
|
502
688
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
503
689
|
retryCount++;
|
|
504
690
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
505
|
-
logger.warn("Database connection error, retrying..."
|
|
691
|
+
logger.warn("Database connection error in deleteOneMarketSentiment, retrying...", {
|
|
692
|
+
operation: 'deleteOneMarketSentiment',
|
|
693
|
+
model: 'MarketSentiment',
|
|
694
|
+
attempt: retryCount,
|
|
695
|
+
maxRetries: MAX_RETRIES,
|
|
696
|
+
recordId: props.id,
|
|
697
|
+
});
|
|
506
698
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
507
699
|
continue;
|
|
508
700
|
}
|
|
509
|
-
// Log
|
|
510
|
-
logger.error("Database
|
|
701
|
+
// Log structured error details and rethrow
|
|
702
|
+
logger.error("Database delete operation failed", {
|
|
703
|
+
operation: 'deleteOneMarketSentiment',
|
|
704
|
+
model: 'MarketSentiment',
|
|
705
|
+
error: String(error),
|
|
706
|
+
recordId: props.id,
|
|
707
|
+
isRetryable: isConnectionError,
|
|
708
|
+
});
|
|
511
709
|
throw error;
|
|
512
710
|
}
|
|
513
711
|
}
|
|
@@ -573,12 +771,22 @@ export const MarketSentiment = {
|
|
|
573
771
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
574
772
|
retryCount++;
|
|
575
773
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
576
|
-
logger.warn("Database connection error, retrying..."
|
|
774
|
+
logger.warn("Database connection error in getMarketSentiment, retrying...", {
|
|
775
|
+
operation: 'getMarketSentiment',
|
|
776
|
+
model: 'MarketSentiment',
|
|
777
|
+
attempt: retryCount,
|
|
778
|
+
maxRetries: MAX_RETRIES,
|
|
779
|
+
});
|
|
577
780
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
578
781
|
continue;
|
|
579
782
|
}
|
|
580
|
-
// Log
|
|
581
|
-
logger.error("Database
|
|
783
|
+
// Log structured error details and rethrow
|
|
784
|
+
logger.error("Database get operation failed", {
|
|
785
|
+
operation: 'getMarketSentiment',
|
|
786
|
+
model: 'MarketSentiment',
|
|
787
|
+
error: String(error),
|
|
788
|
+
isRetryable: isConnectionError,
|
|
789
|
+
});
|
|
582
790
|
throw error;
|
|
583
791
|
}
|
|
584
792
|
}
|
|
@@ -635,12 +843,22 @@ export const MarketSentiment = {
|
|
|
635
843
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
636
844
|
retryCount++;
|
|
637
845
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
638
|
-
logger.warn("Database connection error, retrying..."
|
|
846
|
+
logger.warn("Database connection error in getAllMarketSentiment, retrying...", {
|
|
847
|
+
operation: 'getAllMarketSentiment',
|
|
848
|
+
model: 'MarketSentiment',
|
|
849
|
+
attempt: retryCount,
|
|
850
|
+
maxRetries: MAX_RETRIES,
|
|
851
|
+
});
|
|
639
852
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
640
853
|
continue;
|
|
641
854
|
}
|
|
642
|
-
// Log
|
|
643
|
-
logger.error("Database
|
|
855
|
+
// Log structured error details and rethrow
|
|
856
|
+
logger.error("Database getAll operation failed", {
|
|
857
|
+
operation: 'getAllMarketSentiment',
|
|
858
|
+
model: 'MarketSentiment',
|
|
859
|
+
error: String(error),
|
|
860
|
+
isRetryable: isConnectionError,
|
|
861
|
+
});
|
|
644
862
|
throw error;
|
|
645
863
|
}
|
|
646
864
|
}
|
|
@@ -713,12 +931,22 @@ export const MarketSentiment = {
|
|
|
713
931
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
714
932
|
retryCount++;
|
|
715
933
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
716
|
-
logger.warn("Database connection error, retrying..."
|
|
934
|
+
logger.warn("Database connection error in findManyMarketSentiment, retrying...", {
|
|
935
|
+
operation: 'findManyMarketSentiment',
|
|
936
|
+
model: 'MarketSentiment',
|
|
937
|
+
attempt: retryCount,
|
|
938
|
+
maxRetries: MAX_RETRIES,
|
|
939
|
+
});
|
|
717
940
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
718
941
|
continue;
|
|
719
942
|
}
|
|
720
|
-
// Log
|
|
721
|
-
logger.error("Database
|
|
943
|
+
// Log structured error details and rethrow
|
|
944
|
+
logger.error("Database findMany operation failed", {
|
|
945
|
+
operation: 'findManyMarketSentiment',
|
|
946
|
+
model: 'MarketSentiment',
|
|
947
|
+
error: String(error),
|
|
948
|
+
isRetryable: isConnectionError,
|
|
949
|
+
});
|
|
722
950
|
throw error;
|
|
723
951
|
}
|
|
724
952
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelArtifact.d.ts","sourceRoot":"","sources":["../../src/ModelArtifact.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AACzG,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AA4K7G,eAAO,MAAM,aAAa;IAExB;;;;;OAKG;IAEH;;;;;;OAMG;kBACiB,iBAAiB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"ModelArtifact.d.ts","sourceRoot":"","sources":["../../src/ModelArtifact.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AACzG,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AA4K7G,eAAO,MAAM,aAAa;IAExB;;;;;OAKG;IAEH;;;;;;OAMG;kBACiB,iBAAiB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAuZ5H;;;;;;OAMG;sBACqB,iBAAiB,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAyHvI;;;;;;OAMG;kBACiB,iBAAiB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAg7C1H;;;;;;OAMG;kBACiB,iBAAiB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAktD1H;;;;;;OAMG;sBACqB,iBAAiB,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IA+6CvI;;;;;;OAMG;kBACiB,iBAAiB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAmH1H;;;;;;;OAOG;eACc,iBAAiB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAoFhJ;;;;;OAKG;0BACyB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,iBAAiB,EAAE,GAAG,IAAI,CAAC;IA4EzG;;;;;;;OAOG;oBACmB,iBAAiB,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,iBAAiB,EAAE,GAAG,IAAI,CAAC;CA0FxJ,CAAC"}
|