@adaptic/backend-legacy 0.0.904 → 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/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/Trade.cjs
CHANGED
|
@@ -67,7 +67,7 @@ exports.Trade = {
|
|
|
67
67
|
* @returns The created Trade or null.
|
|
68
68
|
*/
|
|
69
69
|
async create(props, globalClient) {
|
|
70
|
-
var _a, _b, _c, _d, _e;
|
|
70
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
71
71
|
// Maximum number of retries for database connection issues
|
|
72
72
|
const MAX_RETRIES = 3;
|
|
73
73
|
let retryCount = 0;
|
|
@@ -161,21 +161,52 @@ exports.Trade = {
|
|
|
161
161
|
}
|
|
162
162
|
catch (error) {
|
|
163
163
|
lastError = error;
|
|
164
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
165
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
166
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
167
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
168
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
169
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
170
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
171
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
172
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
173
|
+
if (isConstraintViolation) {
|
|
174
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
175
|
+
logger_1.logger.error("Non-retryable constraint violation in createOneTrade", {
|
|
176
|
+
operation: 'createOneTrade',
|
|
177
|
+
model: 'Trade',
|
|
178
|
+
error: String(error),
|
|
179
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
180
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
181
|
+
isRetryable: false,
|
|
182
|
+
});
|
|
183
|
+
throw error;
|
|
184
|
+
}
|
|
164
185
|
// Check if this is a database connection error that we should retry
|
|
165
|
-
const isConnectionError = ((
|
|
166
|
-
((
|
|
167
|
-
((
|
|
168
|
-
((
|
|
169
|
-
(error.networkError && ((
|
|
186
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
187
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
188
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
189
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
190
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
170
191
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
171
192
|
retryCount++;
|
|
172
193
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
173
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
194
|
+
logger_1.logger.warn("Database connection error in createOneTrade, retrying...", {
|
|
195
|
+
operation: 'createOneTrade',
|
|
196
|
+
model: 'Trade',
|
|
197
|
+
attempt: retryCount,
|
|
198
|
+
maxRetries: MAX_RETRIES,
|
|
199
|
+
});
|
|
174
200
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
175
201
|
continue;
|
|
176
202
|
}
|
|
177
|
-
// Log
|
|
178
|
-
logger_1.logger.error("Database
|
|
203
|
+
// Log structured error details and rethrow
|
|
204
|
+
logger_1.logger.error("Database create operation failed", {
|
|
205
|
+
operation: 'createOneTrade',
|
|
206
|
+
model: 'Trade',
|
|
207
|
+
error: String(error),
|
|
208
|
+
isRetryable: isConnectionError,
|
|
209
|
+
});
|
|
179
210
|
throw error;
|
|
180
211
|
}
|
|
181
212
|
}
|
|
@@ -190,7 +221,7 @@ exports.Trade = {
|
|
|
190
221
|
* @returns The count of created records or null.
|
|
191
222
|
*/
|
|
192
223
|
async createMany(props, globalClient) {
|
|
193
|
-
var _a, _b, _c, _d, _e;
|
|
224
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
194
225
|
// Maximum number of retries for database connection issues
|
|
195
226
|
const MAX_RETRIES = 3;
|
|
196
227
|
let retryCount = 0;
|
|
@@ -258,21 +289,52 @@ exports.Trade = {
|
|
|
258
289
|
}
|
|
259
290
|
catch (error) {
|
|
260
291
|
lastError = error;
|
|
292
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
293
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
294
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
295
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
296
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
297
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
298
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
299
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
300
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
301
|
+
if (isConstraintViolation) {
|
|
302
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
303
|
+
logger_1.logger.error("Non-retryable constraint violation in createManyTrade", {
|
|
304
|
+
operation: 'createManyTrade',
|
|
305
|
+
model: 'Trade',
|
|
306
|
+
error: String(error),
|
|
307
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
308
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
309
|
+
isRetryable: false,
|
|
310
|
+
});
|
|
311
|
+
throw error;
|
|
312
|
+
}
|
|
261
313
|
// Check if this is a database connection error that we should retry
|
|
262
|
-
const isConnectionError = ((
|
|
263
|
-
((
|
|
264
|
-
((
|
|
265
|
-
((
|
|
266
|
-
(error.networkError && ((
|
|
314
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
315
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
316
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
317
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
318
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
267
319
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
268
320
|
retryCount++;
|
|
269
321
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
270
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
322
|
+
logger_1.logger.warn("Database connection error in createManyTrade, retrying...", {
|
|
323
|
+
operation: 'createManyTrade',
|
|
324
|
+
model: 'Trade',
|
|
325
|
+
attempt: retryCount,
|
|
326
|
+
maxRetries: MAX_RETRIES,
|
|
327
|
+
});
|
|
271
328
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
272
329
|
continue;
|
|
273
330
|
}
|
|
274
|
-
// Log
|
|
275
|
-
logger_1.logger.error("Database
|
|
331
|
+
// Log structured error details and rethrow
|
|
332
|
+
logger_1.logger.error("Database createMany operation failed", {
|
|
333
|
+
operation: 'createManyTrade',
|
|
334
|
+
model: 'Trade',
|
|
335
|
+
error: String(error),
|
|
336
|
+
isRetryable: isConnectionError,
|
|
337
|
+
});
|
|
276
338
|
throw error;
|
|
277
339
|
}
|
|
278
340
|
}
|
|
@@ -287,7 +349,7 @@ exports.Trade = {
|
|
|
287
349
|
* @returns The updated Trade or null.
|
|
288
350
|
*/
|
|
289
351
|
async update(props, globalClient) {
|
|
290
|
-
var _a, _b, _c, _d, _e;
|
|
352
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
291
353
|
// Maximum number of retries for database connection issues
|
|
292
354
|
const MAX_RETRIES = 3;
|
|
293
355
|
let retryCount = 0;
|
|
@@ -473,21 +535,55 @@ exports.Trade = {
|
|
|
473
535
|
}
|
|
474
536
|
catch (error) {
|
|
475
537
|
lastError = error;
|
|
538
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
539
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
540
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
541
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
542
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
543
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
544
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
545
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
546
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
547
|
+
if (isConstraintViolation) {
|
|
548
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
549
|
+
logger_1.logger.error("Non-retryable constraint violation in updateOneTrade", {
|
|
550
|
+
operation: 'updateOneTrade',
|
|
551
|
+
model: 'Trade',
|
|
552
|
+
error: String(error),
|
|
553
|
+
recordId: props.id,
|
|
554
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
555
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
556
|
+
isRetryable: false,
|
|
557
|
+
});
|
|
558
|
+
throw error;
|
|
559
|
+
}
|
|
476
560
|
// Check if this is a database connection error that we should retry
|
|
477
|
-
const isConnectionError = ((
|
|
478
|
-
((
|
|
479
|
-
((
|
|
480
|
-
((
|
|
481
|
-
(error.networkError && ((
|
|
561
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
562
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
563
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
564
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
565
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
482
566
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
483
567
|
retryCount++;
|
|
484
568
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
485
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
569
|
+
logger_1.logger.warn("Database connection error in updateOneTrade, retrying...", {
|
|
570
|
+
operation: 'updateOneTrade',
|
|
571
|
+
model: 'Trade',
|
|
572
|
+
attempt: retryCount,
|
|
573
|
+
maxRetries: MAX_RETRIES,
|
|
574
|
+
recordId: props.id,
|
|
575
|
+
});
|
|
486
576
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
487
577
|
continue;
|
|
488
578
|
}
|
|
489
|
-
// Log
|
|
490
|
-
logger_1.logger.error("Database
|
|
579
|
+
// Log structured error details and rethrow
|
|
580
|
+
logger_1.logger.error("Database update operation failed", {
|
|
581
|
+
operation: 'updateOneTrade',
|
|
582
|
+
model: 'Trade',
|
|
583
|
+
error: String(error),
|
|
584
|
+
recordId: props.id,
|
|
585
|
+
isRetryable: isConnectionError,
|
|
586
|
+
});
|
|
491
587
|
throw error;
|
|
492
588
|
}
|
|
493
589
|
}
|
|
@@ -502,7 +598,7 @@ exports.Trade = {
|
|
|
502
598
|
* @returns The updated Trade or null.
|
|
503
599
|
*/
|
|
504
600
|
async upsert(props, globalClient) {
|
|
505
|
-
var _a, _b, _c, _d, _e;
|
|
601
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
506
602
|
// Maximum number of retries for database connection issues
|
|
507
603
|
const MAX_RETRIES = 3;
|
|
508
604
|
let retryCount = 0;
|
|
@@ -731,21 +827,55 @@ exports.Trade = {
|
|
|
731
827
|
}
|
|
732
828
|
catch (error) {
|
|
733
829
|
lastError = error;
|
|
830
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
831
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
832
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
833
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
834
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
835
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
836
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
837
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
838
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
839
|
+
if (isConstraintViolation) {
|
|
840
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
841
|
+
logger_1.logger.error("Non-retryable constraint violation in upsertOneTrade", {
|
|
842
|
+
operation: 'upsertOneTrade',
|
|
843
|
+
model: 'Trade',
|
|
844
|
+
error: String(error),
|
|
845
|
+
recordId: props.id,
|
|
846
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
847
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
848
|
+
isRetryable: false,
|
|
849
|
+
});
|
|
850
|
+
throw error;
|
|
851
|
+
}
|
|
734
852
|
// Check if this is a database connection error that we should retry
|
|
735
|
-
const isConnectionError = ((
|
|
736
|
-
((
|
|
737
|
-
((
|
|
738
|
-
((
|
|
739
|
-
(error.networkError && ((
|
|
853
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
854
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
855
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
856
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
857
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
740
858
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
741
859
|
retryCount++;
|
|
742
860
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
743
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
861
|
+
logger_1.logger.warn("Database connection error in upsertOneTrade, retrying...", {
|
|
862
|
+
operation: 'upsertOneTrade',
|
|
863
|
+
model: 'Trade',
|
|
864
|
+
attempt: retryCount,
|
|
865
|
+
maxRetries: MAX_RETRIES,
|
|
866
|
+
recordId: props.id,
|
|
867
|
+
});
|
|
744
868
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
745
869
|
continue;
|
|
746
870
|
}
|
|
747
|
-
// Log
|
|
748
|
-
logger_1.logger.error("Database
|
|
871
|
+
// Log structured error details and rethrow
|
|
872
|
+
logger_1.logger.error("Database upsert operation failed", {
|
|
873
|
+
operation: 'upsertOneTrade',
|
|
874
|
+
model: 'Trade',
|
|
875
|
+
error: String(error),
|
|
876
|
+
recordId: props.id,
|
|
877
|
+
isRetryable: isConnectionError,
|
|
878
|
+
});
|
|
749
879
|
throw error;
|
|
750
880
|
}
|
|
751
881
|
}
|
|
@@ -760,7 +890,7 @@ exports.Trade = {
|
|
|
760
890
|
* @returns The count of created records or null.
|
|
761
891
|
*/
|
|
762
892
|
async updateMany(props, globalClient) {
|
|
763
|
-
var _a, _b, _c, _d, _e;
|
|
893
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
764
894
|
// Maximum number of retries for database connection issues
|
|
765
895
|
const MAX_RETRIES = 3;
|
|
766
896
|
let retryCount = 0;
|
|
@@ -946,21 +1076,52 @@ exports.Trade = {
|
|
|
946
1076
|
}
|
|
947
1077
|
catch (error) {
|
|
948
1078
|
lastError = error;
|
|
1079
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
1080
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
1081
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
1082
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
1083
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
1084
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
1085
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
1086
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
1087
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
1088
|
+
if (isConstraintViolation) {
|
|
1089
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
1090
|
+
logger_1.logger.error("Non-retryable constraint violation in updateManyTrade", {
|
|
1091
|
+
operation: 'updateManyTrade',
|
|
1092
|
+
model: 'Trade',
|
|
1093
|
+
error: String(error),
|
|
1094
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
1095
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
1096
|
+
isRetryable: false,
|
|
1097
|
+
});
|
|
1098
|
+
throw error;
|
|
1099
|
+
}
|
|
949
1100
|
// Check if this is a database connection error that we should retry
|
|
950
|
-
const isConnectionError = ((
|
|
951
|
-
((
|
|
952
|
-
((
|
|
953
|
-
((
|
|
954
|
-
(error.networkError && ((
|
|
1101
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
1102
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
1103
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
1104
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
1105
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
955
1106
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
956
1107
|
retryCount++;
|
|
957
1108
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
958
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
1109
|
+
logger_1.logger.warn("Database connection error in updateManyTrade, retrying...", {
|
|
1110
|
+
operation: 'updateManyTrade',
|
|
1111
|
+
model: 'Trade',
|
|
1112
|
+
attempt: retryCount,
|
|
1113
|
+
maxRetries: MAX_RETRIES,
|
|
1114
|
+
});
|
|
959
1115
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
960
1116
|
continue;
|
|
961
1117
|
}
|
|
962
|
-
// Log
|
|
963
|
-
logger_1.logger.error("Database
|
|
1118
|
+
// Log structured error details and rethrow
|
|
1119
|
+
logger_1.logger.error("Database updateMany operation failed", {
|
|
1120
|
+
operation: 'updateManyTrade',
|
|
1121
|
+
model: 'Trade',
|
|
1122
|
+
error: String(error),
|
|
1123
|
+
isRetryable: isConnectionError,
|
|
1124
|
+
});
|
|
964
1125
|
throw error;
|
|
965
1126
|
}
|
|
966
1127
|
}
|
|
@@ -975,7 +1136,7 @@ exports.Trade = {
|
|
|
975
1136
|
* @returns The deleted Trade or null.
|
|
976
1137
|
*/
|
|
977
1138
|
async delete(props, globalClient) {
|
|
978
|
-
var _a, _b, _c, _d, _e;
|
|
1139
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
979
1140
|
// Maximum number of retries for database connection issues
|
|
980
1141
|
const MAX_RETRIES = 3;
|
|
981
1142
|
let retryCount = 0;
|
|
@@ -1019,21 +1180,58 @@ exports.Trade = {
|
|
|
1019
1180
|
}
|
|
1020
1181
|
catch (error) {
|
|
1021
1182
|
lastError = error;
|
|
1183
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
1184
|
+
// (e.g., foreign key constraints preventing deletion)
|
|
1185
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
1186
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
1187
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
1188
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
1189
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
1190
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
1191
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
|
|
1192
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
|
|
1193
|
+
((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
|
|
1194
|
+
((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
|
|
1195
|
+
if (isConstraintViolation) {
|
|
1196
|
+
const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
|
|
1197
|
+
logger_1.logger.error("Non-retryable constraint violation in deleteOneTrade", {
|
|
1198
|
+
operation: 'deleteOneTrade',
|
|
1199
|
+
model: 'Trade',
|
|
1200
|
+
error: String(error),
|
|
1201
|
+
recordId: props.id,
|
|
1202
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
1203
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
1204
|
+
isRetryable: false,
|
|
1205
|
+
});
|
|
1206
|
+
throw error;
|
|
1207
|
+
}
|
|
1022
1208
|
// Check if this is a database connection error that we should retry
|
|
1023
|
-
const isConnectionError = ((
|
|
1024
|
-
((
|
|
1025
|
-
((
|
|
1026
|
-
((
|
|
1027
|
-
(error.networkError && ((
|
|
1209
|
+
const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
|
|
1210
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
|
|
1211
|
+
((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
|
|
1212
|
+
((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
1213
|
+
(error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
|
|
1028
1214
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
1029
1215
|
retryCount++;
|
|
1030
1216
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
1031
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
1217
|
+
logger_1.logger.warn("Database connection error in deleteOneTrade, retrying...", {
|
|
1218
|
+
operation: 'deleteOneTrade',
|
|
1219
|
+
model: 'Trade',
|
|
1220
|
+
attempt: retryCount,
|
|
1221
|
+
maxRetries: MAX_RETRIES,
|
|
1222
|
+
recordId: props.id,
|
|
1223
|
+
});
|
|
1032
1224
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
1033
1225
|
continue;
|
|
1034
1226
|
}
|
|
1035
|
-
// Log
|
|
1036
|
-
logger_1.logger.error("Database
|
|
1227
|
+
// Log structured error details and rethrow
|
|
1228
|
+
logger_1.logger.error("Database delete operation failed", {
|
|
1229
|
+
operation: 'deleteOneTrade',
|
|
1230
|
+
model: 'Trade',
|
|
1231
|
+
error: String(error),
|
|
1232
|
+
recordId: props.id,
|
|
1233
|
+
isRetryable: isConnectionError,
|
|
1234
|
+
});
|
|
1037
1235
|
throw error;
|
|
1038
1236
|
}
|
|
1039
1237
|
}
|
|
@@ -1106,12 +1304,22 @@ exports.Trade = {
|
|
|
1106
1304
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
1107
1305
|
retryCount++;
|
|
1108
1306
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
1109
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
1307
|
+
logger_1.logger.warn("Database connection error in getTrade, retrying...", {
|
|
1308
|
+
operation: 'getTrade',
|
|
1309
|
+
model: 'Trade',
|
|
1310
|
+
attempt: retryCount,
|
|
1311
|
+
maxRetries: MAX_RETRIES,
|
|
1312
|
+
});
|
|
1110
1313
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
1111
1314
|
continue;
|
|
1112
1315
|
}
|
|
1113
|
-
// Log
|
|
1114
|
-
logger_1.logger.error("Database
|
|
1316
|
+
// Log structured error details and rethrow
|
|
1317
|
+
logger_1.logger.error("Database get operation failed", {
|
|
1318
|
+
operation: 'getTrade',
|
|
1319
|
+
model: 'Trade',
|
|
1320
|
+
error: String(error),
|
|
1321
|
+
isRetryable: isConnectionError,
|
|
1322
|
+
});
|
|
1115
1323
|
throw error;
|
|
1116
1324
|
}
|
|
1117
1325
|
}
|
|
@@ -1169,12 +1377,22 @@ exports.Trade = {
|
|
|
1169
1377
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
1170
1378
|
retryCount++;
|
|
1171
1379
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
1172
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
1380
|
+
logger_1.logger.warn("Database connection error in getAllTrade, retrying...", {
|
|
1381
|
+
operation: 'getAllTrade',
|
|
1382
|
+
model: 'Trade',
|
|
1383
|
+
attempt: retryCount,
|
|
1384
|
+
maxRetries: MAX_RETRIES,
|
|
1385
|
+
});
|
|
1173
1386
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
1174
1387
|
continue;
|
|
1175
1388
|
}
|
|
1176
|
-
// Log
|
|
1177
|
-
logger_1.logger.error("Database
|
|
1389
|
+
// Log structured error details and rethrow
|
|
1390
|
+
logger_1.logger.error("Database getAll operation failed", {
|
|
1391
|
+
operation: 'getAllTrade',
|
|
1392
|
+
model: 'Trade',
|
|
1393
|
+
error: String(error),
|
|
1394
|
+
isRetryable: isConnectionError,
|
|
1395
|
+
});
|
|
1178
1396
|
throw error;
|
|
1179
1397
|
}
|
|
1180
1398
|
}
|
|
@@ -1254,12 +1472,22 @@ exports.Trade = {
|
|
|
1254
1472
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
1255
1473
|
retryCount++;
|
|
1256
1474
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
1257
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
1475
|
+
logger_1.logger.warn("Database connection error in findManyTrade, retrying...", {
|
|
1476
|
+
operation: 'findManyTrade',
|
|
1477
|
+
model: 'Trade',
|
|
1478
|
+
attempt: retryCount,
|
|
1479
|
+
maxRetries: MAX_RETRIES,
|
|
1480
|
+
});
|
|
1258
1481
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
1259
1482
|
continue;
|
|
1260
1483
|
}
|
|
1261
|
-
// Log
|
|
1262
|
-
logger_1.logger.error("Database
|
|
1484
|
+
// Log structured error details and rethrow
|
|
1485
|
+
logger_1.logger.error("Database findMany operation failed", {
|
|
1486
|
+
operation: 'findManyTrade',
|
|
1487
|
+
model: 'Trade',
|
|
1488
|
+
error: String(error),
|
|
1489
|
+
isRetryable: isConnectionError,
|
|
1490
|
+
});
|
|
1263
1491
|
throw error;
|
|
1264
1492
|
}
|
|
1265
1493
|
}
|