@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
|
@@ -78,6 +78,27 @@ export const TradeExecutionHistory = {
|
|
|
78
78
|
}
|
|
79
79
|
catch (error) {
|
|
80
80
|
lastError = error;
|
|
81
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
82
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
83
|
+
error.message?.includes('violates unique constraint') ||
|
|
84
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
85
|
+
error.message?.includes('unique constraint') ||
|
|
86
|
+
error.message?.includes('23514') ||
|
|
87
|
+
error.message?.includes('23505') ||
|
|
88
|
+
error.message?.includes('P2002') ||
|
|
89
|
+
error.message?.includes('P2003');
|
|
90
|
+
if (isConstraintViolation) {
|
|
91
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
92
|
+
logger.error("Non-retryable constraint violation in createOneTradeExecutionHistory", {
|
|
93
|
+
operation: 'createOneTradeExecutionHistory',
|
|
94
|
+
model: 'TradeExecutionHistory',
|
|
95
|
+
error: String(error),
|
|
96
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
97
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
98
|
+
isRetryable: false,
|
|
99
|
+
});
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
81
102
|
// Check if this is a database connection error that we should retry
|
|
82
103
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
83
104
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -87,12 +108,22 @@ export const TradeExecutionHistory = {
|
|
|
87
108
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
88
109
|
retryCount++;
|
|
89
110
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
90
|
-
logger.warn("Database connection error, retrying..."
|
|
111
|
+
logger.warn("Database connection error in createOneTradeExecutionHistory, retrying...", {
|
|
112
|
+
operation: 'createOneTradeExecutionHistory',
|
|
113
|
+
model: 'TradeExecutionHistory',
|
|
114
|
+
attempt: retryCount,
|
|
115
|
+
maxRetries: MAX_RETRIES,
|
|
116
|
+
});
|
|
91
117
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
92
118
|
continue;
|
|
93
119
|
}
|
|
94
|
-
// Log
|
|
95
|
-
logger.error("Database
|
|
120
|
+
// Log structured error details and rethrow
|
|
121
|
+
logger.error("Database create operation failed", {
|
|
122
|
+
operation: 'createOneTradeExecutionHistory',
|
|
123
|
+
model: 'TradeExecutionHistory',
|
|
124
|
+
error: String(error),
|
|
125
|
+
isRetryable: isConnectionError,
|
|
126
|
+
});
|
|
96
127
|
throw error;
|
|
97
128
|
}
|
|
98
129
|
}
|
|
@@ -154,6 +185,27 @@ export const TradeExecutionHistory = {
|
|
|
154
185
|
}
|
|
155
186
|
catch (error) {
|
|
156
187
|
lastError = error;
|
|
188
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
189
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
190
|
+
error.message?.includes('violates unique constraint') ||
|
|
191
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
192
|
+
error.message?.includes('unique constraint') ||
|
|
193
|
+
error.message?.includes('23514') ||
|
|
194
|
+
error.message?.includes('23505') ||
|
|
195
|
+
error.message?.includes('P2002') ||
|
|
196
|
+
error.message?.includes('P2003');
|
|
197
|
+
if (isConstraintViolation) {
|
|
198
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
199
|
+
logger.error("Non-retryable constraint violation in createManyTradeExecutionHistory", {
|
|
200
|
+
operation: 'createManyTradeExecutionHistory',
|
|
201
|
+
model: 'TradeExecutionHistory',
|
|
202
|
+
error: String(error),
|
|
203
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
204
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
205
|
+
isRetryable: false,
|
|
206
|
+
});
|
|
207
|
+
throw error;
|
|
208
|
+
}
|
|
157
209
|
// Check if this is a database connection error that we should retry
|
|
158
210
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
159
211
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -163,12 +215,22 @@ export const TradeExecutionHistory = {
|
|
|
163
215
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
164
216
|
retryCount++;
|
|
165
217
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
166
|
-
logger.warn("Database connection error, retrying..."
|
|
218
|
+
logger.warn("Database connection error in createManyTradeExecutionHistory, retrying...", {
|
|
219
|
+
operation: 'createManyTradeExecutionHistory',
|
|
220
|
+
model: 'TradeExecutionHistory',
|
|
221
|
+
attempt: retryCount,
|
|
222
|
+
maxRetries: MAX_RETRIES,
|
|
223
|
+
});
|
|
167
224
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
168
225
|
continue;
|
|
169
226
|
}
|
|
170
|
-
// Log
|
|
171
|
-
logger.error("Database
|
|
227
|
+
// Log structured error details and rethrow
|
|
228
|
+
logger.error("Database createMany operation failed", {
|
|
229
|
+
operation: 'createManyTradeExecutionHistory',
|
|
230
|
+
model: 'TradeExecutionHistory',
|
|
231
|
+
error: String(error),
|
|
232
|
+
isRetryable: isConnectionError,
|
|
233
|
+
});
|
|
172
234
|
throw error;
|
|
173
235
|
}
|
|
174
236
|
}
|
|
@@ -249,6 +311,28 @@ export const TradeExecutionHistory = {
|
|
|
249
311
|
}
|
|
250
312
|
catch (error) {
|
|
251
313
|
lastError = error;
|
|
314
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
315
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
316
|
+
error.message?.includes('violates unique constraint') ||
|
|
317
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
318
|
+
error.message?.includes('unique constraint') ||
|
|
319
|
+
error.message?.includes('23514') ||
|
|
320
|
+
error.message?.includes('23505') ||
|
|
321
|
+
error.message?.includes('P2002') ||
|
|
322
|
+
error.message?.includes('P2003');
|
|
323
|
+
if (isConstraintViolation) {
|
|
324
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
325
|
+
logger.error("Non-retryable constraint violation in updateOneTradeExecutionHistory", {
|
|
326
|
+
operation: 'updateOneTradeExecutionHistory',
|
|
327
|
+
model: 'TradeExecutionHistory',
|
|
328
|
+
error: String(error),
|
|
329
|
+
recordId: props.id,
|
|
330
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
331
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
332
|
+
isRetryable: false,
|
|
333
|
+
});
|
|
334
|
+
throw error;
|
|
335
|
+
}
|
|
252
336
|
// Check if this is a database connection error that we should retry
|
|
253
337
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
254
338
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -258,12 +342,24 @@ export const TradeExecutionHistory = {
|
|
|
258
342
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
259
343
|
retryCount++;
|
|
260
344
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
261
|
-
logger.warn("Database connection error, retrying..."
|
|
345
|
+
logger.warn("Database connection error in updateOneTradeExecutionHistory, retrying...", {
|
|
346
|
+
operation: 'updateOneTradeExecutionHistory',
|
|
347
|
+
model: 'TradeExecutionHistory',
|
|
348
|
+
attempt: retryCount,
|
|
349
|
+
maxRetries: MAX_RETRIES,
|
|
350
|
+
recordId: props.id,
|
|
351
|
+
});
|
|
262
352
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
263
353
|
continue;
|
|
264
354
|
}
|
|
265
|
-
// Log
|
|
266
|
-
logger.error("Database
|
|
355
|
+
// Log structured error details and rethrow
|
|
356
|
+
logger.error("Database update operation failed", {
|
|
357
|
+
operation: 'updateOneTradeExecutionHistory',
|
|
358
|
+
model: 'TradeExecutionHistory',
|
|
359
|
+
error: String(error),
|
|
360
|
+
recordId: props.id,
|
|
361
|
+
isRetryable: isConnectionError,
|
|
362
|
+
});
|
|
267
363
|
throw error;
|
|
268
364
|
}
|
|
269
365
|
}
|
|
@@ -345,6 +441,28 @@ export const TradeExecutionHistory = {
|
|
|
345
441
|
}
|
|
346
442
|
catch (error) {
|
|
347
443
|
lastError = error;
|
|
444
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
445
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
446
|
+
error.message?.includes('violates unique constraint') ||
|
|
447
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
448
|
+
error.message?.includes('unique constraint') ||
|
|
449
|
+
error.message?.includes('23514') ||
|
|
450
|
+
error.message?.includes('23505') ||
|
|
451
|
+
error.message?.includes('P2002') ||
|
|
452
|
+
error.message?.includes('P2003');
|
|
453
|
+
if (isConstraintViolation) {
|
|
454
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
455
|
+
logger.error("Non-retryable constraint violation in upsertOneTradeExecutionHistory", {
|
|
456
|
+
operation: 'upsertOneTradeExecutionHistory',
|
|
457
|
+
model: 'TradeExecutionHistory',
|
|
458
|
+
error: String(error),
|
|
459
|
+
recordId: props.id,
|
|
460
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
461
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
462
|
+
isRetryable: false,
|
|
463
|
+
});
|
|
464
|
+
throw error;
|
|
465
|
+
}
|
|
348
466
|
// Check if this is a database connection error that we should retry
|
|
349
467
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
350
468
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -354,12 +472,24 @@ export const TradeExecutionHistory = {
|
|
|
354
472
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
355
473
|
retryCount++;
|
|
356
474
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
357
|
-
logger.warn("Database connection error, retrying..."
|
|
475
|
+
logger.warn("Database connection error in upsertOneTradeExecutionHistory, retrying...", {
|
|
476
|
+
operation: 'upsertOneTradeExecutionHistory',
|
|
477
|
+
model: 'TradeExecutionHistory',
|
|
478
|
+
attempt: retryCount,
|
|
479
|
+
maxRetries: MAX_RETRIES,
|
|
480
|
+
recordId: props.id,
|
|
481
|
+
});
|
|
358
482
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
359
483
|
continue;
|
|
360
484
|
}
|
|
361
|
-
// Log
|
|
362
|
-
logger.error("Database
|
|
485
|
+
// Log structured error details and rethrow
|
|
486
|
+
logger.error("Database upsert operation failed", {
|
|
487
|
+
operation: 'upsertOneTradeExecutionHistory',
|
|
488
|
+
model: 'TradeExecutionHistory',
|
|
489
|
+
error: String(error),
|
|
490
|
+
recordId: props.id,
|
|
491
|
+
isRetryable: isConnectionError,
|
|
492
|
+
});
|
|
363
493
|
throw error;
|
|
364
494
|
}
|
|
365
495
|
}
|
|
@@ -440,6 +570,27 @@ export const TradeExecutionHistory = {
|
|
|
440
570
|
}
|
|
441
571
|
catch (error) {
|
|
442
572
|
lastError = error;
|
|
573
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
574
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
575
|
+
error.message?.includes('violates unique constraint') ||
|
|
576
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
577
|
+
error.message?.includes('unique constraint') ||
|
|
578
|
+
error.message?.includes('23514') ||
|
|
579
|
+
error.message?.includes('23505') ||
|
|
580
|
+
error.message?.includes('P2002') ||
|
|
581
|
+
error.message?.includes('P2003');
|
|
582
|
+
if (isConstraintViolation) {
|
|
583
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
584
|
+
logger.error("Non-retryable constraint violation in updateManyTradeExecutionHistory", {
|
|
585
|
+
operation: 'updateManyTradeExecutionHistory',
|
|
586
|
+
model: 'TradeExecutionHistory',
|
|
587
|
+
error: String(error),
|
|
588
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
589
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
590
|
+
isRetryable: false,
|
|
591
|
+
});
|
|
592
|
+
throw error;
|
|
593
|
+
}
|
|
443
594
|
// Check if this is a database connection error that we should retry
|
|
444
595
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
445
596
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -449,12 +600,22 @@ export const TradeExecutionHistory = {
|
|
|
449
600
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
450
601
|
retryCount++;
|
|
451
602
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
452
|
-
logger.warn("Database connection error, retrying..."
|
|
603
|
+
logger.warn("Database connection error in updateManyTradeExecutionHistory, retrying...", {
|
|
604
|
+
operation: 'updateManyTradeExecutionHistory',
|
|
605
|
+
model: 'TradeExecutionHistory',
|
|
606
|
+
attempt: retryCount,
|
|
607
|
+
maxRetries: MAX_RETRIES,
|
|
608
|
+
});
|
|
453
609
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
454
610
|
continue;
|
|
455
611
|
}
|
|
456
|
-
// Log
|
|
457
|
-
logger.error("Database
|
|
612
|
+
// Log structured error details and rethrow
|
|
613
|
+
logger.error("Database updateMany operation failed", {
|
|
614
|
+
operation: 'updateManyTradeExecutionHistory',
|
|
615
|
+
model: 'TradeExecutionHistory',
|
|
616
|
+
error: String(error),
|
|
617
|
+
isRetryable: isConnectionError,
|
|
618
|
+
});
|
|
458
619
|
throw error;
|
|
459
620
|
}
|
|
460
621
|
}
|
|
@@ -512,6 +673,31 @@ export const TradeExecutionHistory = {
|
|
|
512
673
|
}
|
|
513
674
|
catch (error) {
|
|
514
675
|
lastError = error;
|
|
676
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
677
|
+
// (e.g., foreign key constraints preventing deletion)
|
|
678
|
+
const isConstraintViolation = error.message?.includes('violates check constraint') ||
|
|
679
|
+
error.message?.includes('violates unique constraint') ||
|
|
680
|
+
error.message?.includes('violates foreign key constraint') ||
|
|
681
|
+
error.message?.includes('unique constraint') ||
|
|
682
|
+
error.message?.includes('23514') ||
|
|
683
|
+
error.message?.includes('23505') ||
|
|
684
|
+
error.message?.includes('23503') ||
|
|
685
|
+
error.message?.includes('P2002') ||
|
|
686
|
+
error.message?.includes('P2003') ||
|
|
687
|
+
error.message?.includes('P2014');
|
|
688
|
+
if (isConstraintViolation) {
|
|
689
|
+
const constraintMatch = error.message?.match(/constraint\s+"([^"]+)"/);
|
|
690
|
+
logger.error("Non-retryable constraint violation in deleteOneTradeExecutionHistory", {
|
|
691
|
+
operation: 'deleteOneTradeExecutionHistory',
|
|
692
|
+
model: 'TradeExecutionHistory',
|
|
693
|
+
error: String(error),
|
|
694
|
+
recordId: props.id,
|
|
695
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
696
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
697
|
+
isRetryable: false,
|
|
698
|
+
});
|
|
699
|
+
throw error;
|
|
700
|
+
}
|
|
515
701
|
// Check if this is a database connection error that we should retry
|
|
516
702
|
const isConnectionError = error.message?.includes('Server has closed the connection') ||
|
|
517
703
|
error.message?.includes('Cannot reach database server') ||
|
|
@@ -521,12 +707,24 @@ export const TradeExecutionHistory = {
|
|
|
521
707
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
522
708
|
retryCount++;
|
|
523
709
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
524
|
-
logger.warn("Database connection error, retrying..."
|
|
710
|
+
logger.warn("Database connection error in deleteOneTradeExecutionHistory, retrying...", {
|
|
711
|
+
operation: 'deleteOneTradeExecutionHistory',
|
|
712
|
+
model: 'TradeExecutionHistory',
|
|
713
|
+
attempt: retryCount,
|
|
714
|
+
maxRetries: MAX_RETRIES,
|
|
715
|
+
recordId: props.id,
|
|
716
|
+
});
|
|
525
717
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
526
718
|
continue;
|
|
527
719
|
}
|
|
528
|
-
// Log
|
|
529
|
-
logger.error("Database
|
|
720
|
+
// Log structured error details and rethrow
|
|
721
|
+
logger.error("Database delete operation failed", {
|
|
722
|
+
operation: 'deleteOneTradeExecutionHistory',
|
|
723
|
+
model: 'TradeExecutionHistory',
|
|
724
|
+
error: String(error),
|
|
725
|
+
recordId: props.id,
|
|
726
|
+
isRetryable: isConnectionError,
|
|
727
|
+
});
|
|
530
728
|
throw error;
|
|
531
729
|
}
|
|
532
730
|
}
|
|
@@ -592,12 +790,22 @@ export const TradeExecutionHistory = {
|
|
|
592
790
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
593
791
|
retryCount++;
|
|
594
792
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
595
|
-
logger.warn("Database connection error, retrying..."
|
|
793
|
+
logger.warn("Database connection error in getTradeExecutionHistory, retrying...", {
|
|
794
|
+
operation: 'getTradeExecutionHistory',
|
|
795
|
+
model: 'TradeExecutionHistory',
|
|
796
|
+
attempt: retryCount,
|
|
797
|
+
maxRetries: MAX_RETRIES,
|
|
798
|
+
});
|
|
596
799
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
597
800
|
continue;
|
|
598
801
|
}
|
|
599
|
-
// Log
|
|
600
|
-
logger.error("Database
|
|
802
|
+
// Log structured error details and rethrow
|
|
803
|
+
logger.error("Database get operation failed", {
|
|
804
|
+
operation: 'getTradeExecutionHistory',
|
|
805
|
+
model: 'TradeExecutionHistory',
|
|
806
|
+
error: String(error),
|
|
807
|
+
isRetryable: isConnectionError,
|
|
808
|
+
});
|
|
601
809
|
throw error;
|
|
602
810
|
}
|
|
603
811
|
}
|
|
@@ -654,12 +862,22 @@ export const TradeExecutionHistory = {
|
|
|
654
862
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
655
863
|
retryCount++;
|
|
656
864
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
657
|
-
logger.warn("Database connection error, retrying..."
|
|
865
|
+
logger.warn("Database connection error in getAllTradeExecutionHistory, retrying...", {
|
|
866
|
+
operation: 'getAllTradeExecutionHistory',
|
|
867
|
+
model: 'TradeExecutionHistory',
|
|
868
|
+
attempt: retryCount,
|
|
869
|
+
maxRetries: MAX_RETRIES,
|
|
870
|
+
});
|
|
658
871
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
659
872
|
continue;
|
|
660
873
|
}
|
|
661
|
-
// Log
|
|
662
|
-
logger.error("Database
|
|
874
|
+
// Log structured error details and rethrow
|
|
875
|
+
logger.error("Database getAll operation failed", {
|
|
876
|
+
operation: 'getAllTradeExecutionHistory',
|
|
877
|
+
model: 'TradeExecutionHistory',
|
|
878
|
+
error: String(error),
|
|
879
|
+
isRetryable: isConnectionError,
|
|
880
|
+
});
|
|
663
881
|
throw error;
|
|
664
882
|
}
|
|
665
883
|
}
|
|
@@ -732,12 +950,22 @@ export const TradeExecutionHistory = {
|
|
|
732
950
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
733
951
|
retryCount++;
|
|
734
952
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
735
|
-
logger.warn("Database connection error, retrying..."
|
|
953
|
+
logger.warn("Database connection error in findManyTradeExecutionHistory, retrying...", {
|
|
954
|
+
operation: 'findManyTradeExecutionHistory',
|
|
955
|
+
model: 'TradeExecutionHistory',
|
|
956
|
+
attempt: retryCount,
|
|
957
|
+
maxRetries: MAX_RETRIES,
|
|
958
|
+
});
|
|
736
959
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
737
960
|
continue;
|
|
738
961
|
}
|
|
739
|
-
// Log
|
|
740
|
-
logger.error("Database
|
|
962
|
+
// Log structured error details and rethrow
|
|
963
|
+
logger.error("Database findMany operation failed", {
|
|
964
|
+
operation: 'findManyTradeExecutionHistory',
|
|
965
|
+
model: 'TradeExecutionHistory',
|
|
966
|
+
error: String(error),
|
|
967
|
+
isRetryable: isConnectionError,
|
|
968
|
+
});
|
|
741
969
|
throw error;
|
|
742
970
|
}
|
|
743
971
|
}
|
package/esm/User.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"User.d.ts","sourceRoot":"","sources":["../../src/User.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AAmM7G,eAAO,MAAM,IAAI;IAEf;;;;;OAKG;IAEH;;;;;;OAMG;kBACiB,QAAQ,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"User.d.ts","sourceRoot":"","sources":["../../src/User.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,EAA4B,gBAAgB,EAAE,qBAAqB,EAAoB,MAAM,UAAU,CAAC;AAmM7G,eAAO,MAAM,IAAI;IAEf;;;;;OAKG;IAEH;;;;;;OAMG;kBACiB,QAAQ,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC;IA8a1G;;;;;;OAMG;sBACqB,QAAQ,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAyH9H;;;;;;OAMG;kBACiB,QAAQ,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC;IAw4BxG;;;;;;OAMG;kBACiB,QAAQ,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC;IAisCxG;;;;;;OAMG;sBACqB,QAAQ,EAAE,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAu4B9H;;;;;;OAMG;kBACiB,QAAQ,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC;IAmHxG;;;;;;;OAOG;eACc,QAAQ,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAwF9H;;;;;OAKG;0BACyB,gBAAgB,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC;IA4EhG;;;;;;;OAOG;oBACmB,QAAQ,iBAAiB,gBAAgB,CAAC,qBAAqB,CAAC,eAAe,GAAG,GAAG,OAAO,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC;CAgGtI,CAAC"}
|