@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/MarketSentiment.cjs
CHANGED
|
@@ -32,7 +32,7 @@ exports.MarketSentiment = {
|
|
|
32
32
|
* @returns The created MarketSentiment or null.
|
|
33
33
|
*/
|
|
34
34
|
async create(props, globalClient) {
|
|
35
|
-
var _a, _b, _c, _d, _e;
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
36
36
|
// Maximum number of retries for database connection issues
|
|
37
37
|
const MAX_RETRIES = 3;
|
|
38
38
|
let retryCount = 0;
|
|
@@ -79,21 +79,52 @@ exports.MarketSentiment = {
|
|
|
79
79
|
}
|
|
80
80
|
catch (error) {
|
|
81
81
|
lastError = error;
|
|
82
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
83
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
84
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
85
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
86
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
87
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
88
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
89
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
90
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
91
|
+
if (isConstraintViolation) {
|
|
92
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
93
|
+
logger_1.logger.error("Non-retryable constraint violation in createOneMarketSentiment", {
|
|
94
|
+
operation: 'createOneMarketSentiment',
|
|
95
|
+
model: 'MarketSentiment',
|
|
96
|
+
error: String(error),
|
|
97
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
98
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
99
|
+
isRetryable: false,
|
|
100
|
+
});
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
82
103
|
// Check if this is a database connection error that we should retry
|
|
83
|
-
const isConnectionError = ((
|
|
84
|
-
((
|
|
85
|
-
((
|
|
86
|
-
((
|
|
87
|
-
(error.networkError && ((
|
|
104
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
105
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
106
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
107
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
108
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
88
109
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
89
110
|
retryCount++;
|
|
90
111
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
91
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
112
|
+
logger_1.logger.warn("Database connection error in createOneMarketSentiment, retrying...", {
|
|
113
|
+
operation: 'createOneMarketSentiment',
|
|
114
|
+
model: 'MarketSentiment',
|
|
115
|
+
attempt: retryCount,
|
|
116
|
+
maxRetries: MAX_RETRIES,
|
|
117
|
+
});
|
|
92
118
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
93
119
|
continue;
|
|
94
120
|
}
|
|
95
|
-
// Log
|
|
96
|
-
logger_1.logger.error("Database
|
|
121
|
+
// Log structured error details and rethrow
|
|
122
|
+
logger_1.logger.error("Database create operation failed", {
|
|
123
|
+
operation: 'createOneMarketSentiment',
|
|
124
|
+
model: 'MarketSentiment',
|
|
125
|
+
error: String(error),
|
|
126
|
+
isRetryable: isConnectionError,
|
|
127
|
+
});
|
|
97
128
|
throw error;
|
|
98
129
|
}
|
|
99
130
|
}
|
|
@@ -108,7 +139,7 @@ exports.MarketSentiment = {
|
|
|
108
139
|
* @returns The count of created records or null.
|
|
109
140
|
*/
|
|
110
141
|
async createMany(props, globalClient) {
|
|
111
|
-
var _a, _b, _c, _d, _e;
|
|
142
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
112
143
|
// Maximum number of retries for database connection issues
|
|
113
144
|
const MAX_RETRIES = 3;
|
|
114
145
|
let retryCount = 0;
|
|
@@ -154,21 +185,52 @@ exports.MarketSentiment = {
|
|
|
154
185
|
}
|
|
155
186
|
catch (error) {
|
|
156
187
|
lastError = error;
|
|
188
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
189
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
190
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
191
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
192
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
193
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
194
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
195
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
196
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
197
|
+
if (isConstraintViolation) {
|
|
198
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
199
|
+
logger_1.logger.error("Non-retryable constraint violation in createManyMarketSentiment", {
|
|
200
|
+
operation: 'createManyMarketSentiment',
|
|
201
|
+
model: 'MarketSentiment',
|
|
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
|
-
const isConnectionError = ((
|
|
159
|
-
((
|
|
160
|
-
((
|
|
161
|
-
((
|
|
162
|
-
(error.networkError && ((
|
|
210
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
211
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
212
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
213
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
214
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
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_1.logger.warn("Database connection error, retrying..."
|
|
218
|
+
logger_1.logger.warn("Database connection error in createManyMarketSentiment, retrying...", {
|
|
219
|
+
operation: 'createManyMarketSentiment',
|
|
220
|
+
model: 'MarketSentiment',
|
|
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_1.logger.error("Database
|
|
227
|
+
// Log structured error details and rethrow
|
|
228
|
+
logger_1.logger.error("Database createMany operation failed", {
|
|
229
|
+
operation: 'createManyMarketSentiment',
|
|
230
|
+
model: 'MarketSentiment',
|
|
231
|
+
error: String(error),
|
|
232
|
+
isRetryable: isConnectionError,
|
|
233
|
+
});
|
|
172
234
|
throw error;
|
|
173
235
|
}
|
|
174
236
|
}
|
|
@@ -183,7 +245,7 @@ exports.MarketSentiment = {
|
|
|
183
245
|
* @returns The updated MarketSentiment or null.
|
|
184
246
|
*/
|
|
185
247
|
async update(props, globalClient) {
|
|
186
|
-
var _a, _b, _c, _d, _e;
|
|
248
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
187
249
|
// Maximum number of retries for database connection issues
|
|
188
250
|
const MAX_RETRIES = 3;
|
|
189
251
|
let retryCount = 0;
|
|
@@ -247,21 +309,55 @@ exports.MarketSentiment = {
|
|
|
247
309
|
}
|
|
248
310
|
catch (error) {
|
|
249
311
|
lastError = error;
|
|
312
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
313
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
314
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
315
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
316
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
317
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
318
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
319
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
320
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
321
|
+
if (isConstraintViolation) {
|
|
322
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
323
|
+
logger_1.logger.error("Non-retryable constraint violation in updateOneMarketSentiment", {
|
|
324
|
+
operation: 'updateOneMarketSentiment',
|
|
325
|
+
model: 'MarketSentiment',
|
|
326
|
+
error: String(error),
|
|
327
|
+
recordId: props.id,
|
|
328
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
329
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
330
|
+
isRetryable: false,
|
|
331
|
+
});
|
|
332
|
+
throw error;
|
|
333
|
+
}
|
|
250
334
|
// Check if this is a database connection error that we should retry
|
|
251
|
-
const isConnectionError = ((
|
|
252
|
-
((
|
|
253
|
-
((
|
|
254
|
-
((
|
|
255
|
-
(error.networkError && ((
|
|
335
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
336
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
337
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
338
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
339
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
256
340
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
257
341
|
retryCount++;
|
|
258
342
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
259
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
343
|
+
logger_1.logger.warn("Database connection error in updateOneMarketSentiment, retrying...", {
|
|
344
|
+
operation: 'updateOneMarketSentiment',
|
|
345
|
+
model: 'MarketSentiment',
|
|
346
|
+
attempt: retryCount,
|
|
347
|
+
maxRetries: MAX_RETRIES,
|
|
348
|
+
recordId: props.id,
|
|
349
|
+
});
|
|
260
350
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
261
351
|
continue;
|
|
262
352
|
}
|
|
263
|
-
// Log
|
|
264
|
-
logger_1.logger.error("Database
|
|
353
|
+
// Log structured error details and rethrow
|
|
354
|
+
logger_1.logger.error("Database update operation failed", {
|
|
355
|
+
operation: 'updateOneMarketSentiment',
|
|
356
|
+
model: 'MarketSentiment',
|
|
357
|
+
error: String(error),
|
|
358
|
+
recordId: props.id,
|
|
359
|
+
isRetryable: isConnectionError,
|
|
360
|
+
});
|
|
265
361
|
throw error;
|
|
266
362
|
}
|
|
267
363
|
}
|
|
@@ -276,7 +372,7 @@ exports.MarketSentiment = {
|
|
|
276
372
|
* @returns The updated MarketSentiment or null.
|
|
277
373
|
*/
|
|
278
374
|
async upsert(props, globalClient) {
|
|
279
|
-
var _a, _b, _c, _d, _e;
|
|
375
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
280
376
|
// Maximum number of retries for database connection issues
|
|
281
377
|
const MAX_RETRIES = 3;
|
|
282
378
|
let retryCount = 0;
|
|
@@ -336,21 +432,55 @@ exports.MarketSentiment = {
|
|
|
336
432
|
}
|
|
337
433
|
catch (error) {
|
|
338
434
|
lastError = error;
|
|
435
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
436
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
437
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
438
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
439
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
440
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
441
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
442
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
443
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
444
|
+
if (isConstraintViolation) {
|
|
445
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
446
|
+
logger_1.logger.error("Non-retryable constraint violation in upsertOneMarketSentiment", {
|
|
447
|
+
operation: 'upsertOneMarketSentiment',
|
|
448
|
+
model: 'MarketSentiment',
|
|
449
|
+
error: String(error),
|
|
450
|
+
recordId: props.id,
|
|
451
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
452
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
453
|
+
isRetryable: false,
|
|
454
|
+
});
|
|
455
|
+
throw error;
|
|
456
|
+
}
|
|
339
457
|
// Check if this is a database connection error that we should retry
|
|
340
|
-
const isConnectionError = ((
|
|
341
|
-
((
|
|
342
|
-
((
|
|
343
|
-
((
|
|
344
|
-
(error.networkError && ((
|
|
458
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
459
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
460
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
461
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
462
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
345
463
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
346
464
|
retryCount++;
|
|
347
465
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
348
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
466
|
+
logger_1.logger.warn("Database connection error in upsertOneMarketSentiment, retrying...", {
|
|
467
|
+
operation: 'upsertOneMarketSentiment',
|
|
468
|
+
model: 'MarketSentiment',
|
|
469
|
+
attempt: retryCount,
|
|
470
|
+
maxRetries: MAX_RETRIES,
|
|
471
|
+
recordId: props.id,
|
|
472
|
+
});
|
|
349
473
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
350
474
|
continue;
|
|
351
475
|
}
|
|
352
|
-
// Log
|
|
353
|
-
logger_1.logger.error("Database
|
|
476
|
+
// Log structured error details and rethrow
|
|
477
|
+
logger_1.logger.error("Database upsert operation failed", {
|
|
478
|
+
operation: 'upsertOneMarketSentiment',
|
|
479
|
+
model: 'MarketSentiment',
|
|
480
|
+
error: String(error),
|
|
481
|
+
recordId: props.id,
|
|
482
|
+
isRetryable: isConnectionError,
|
|
483
|
+
});
|
|
354
484
|
throw error;
|
|
355
485
|
}
|
|
356
486
|
}
|
|
@@ -365,7 +495,7 @@ exports.MarketSentiment = {
|
|
|
365
495
|
* @returns The count of created records or null.
|
|
366
496
|
*/
|
|
367
497
|
async updateMany(props, globalClient) {
|
|
368
|
-
var _a, _b, _c, _d, _e;
|
|
498
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
369
499
|
// Maximum number of retries for database connection issues
|
|
370
500
|
const MAX_RETRIES = 3;
|
|
371
501
|
let retryCount = 0;
|
|
@@ -429,21 +559,52 @@ exports.MarketSentiment = {
|
|
|
429
559
|
}
|
|
430
560
|
catch (error) {
|
|
431
561
|
lastError = error;
|
|
562
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
563
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
564
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
565
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
566
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
567
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
568
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
569
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
570
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
571
|
+
if (isConstraintViolation) {
|
|
572
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
573
|
+
logger_1.logger.error("Non-retryable constraint violation in updateManyMarketSentiment", {
|
|
574
|
+
operation: 'updateManyMarketSentiment',
|
|
575
|
+
model: 'MarketSentiment',
|
|
576
|
+
error: String(error),
|
|
577
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
578
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
579
|
+
isRetryable: false,
|
|
580
|
+
});
|
|
581
|
+
throw error;
|
|
582
|
+
}
|
|
432
583
|
// Check if this is a database connection error that we should retry
|
|
433
|
-
const isConnectionError = ((
|
|
434
|
-
((
|
|
435
|
-
((
|
|
436
|
-
((
|
|
437
|
-
(error.networkError && ((
|
|
584
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
585
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
586
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
587
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
588
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
438
589
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
439
590
|
retryCount++;
|
|
440
591
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
441
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
592
|
+
logger_1.logger.warn("Database connection error in updateManyMarketSentiment, retrying...", {
|
|
593
|
+
operation: 'updateManyMarketSentiment',
|
|
594
|
+
model: 'MarketSentiment',
|
|
595
|
+
attempt: retryCount,
|
|
596
|
+
maxRetries: MAX_RETRIES,
|
|
597
|
+
});
|
|
442
598
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
443
599
|
continue;
|
|
444
600
|
}
|
|
445
|
-
// Log
|
|
446
|
-
logger_1.logger.error("Database
|
|
601
|
+
// Log structured error details and rethrow
|
|
602
|
+
logger_1.logger.error("Database updateMany operation failed", {
|
|
603
|
+
operation: 'updateManyMarketSentiment',
|
|
604
|
+
model: 'MarketSentiment',
|
|
605
|
+
error: String(error),
|
|
606
|
+
isRetryable: isConnectionError,
|
|
607
|
+
});
|
|
447
608
|
throw error;
|
|
448
609
|
}
|
|
449
610
|
}
|
|
@@ -458,7 +619,7 @@ exports.MarketSentiment = {
|
|
|
458
619
|
* @returns The deleted MarketSentiment or null.
|
|
459
620
|
*/
|
|
460
621
|
async delete(props, globalClient) {
|
|
461
|
-
var _a, _b, _c, _d, _e;
|
|
622
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
462
623
|
// Maximum number of retries for database connection issues
|
|
463
624
|
const MAX_RETRIES = 3;
|
|
464
625
|
let retryCount = 0;
|
|
@@ -502,21 +663,58 @@ exports.MarketSentiment = {
|
|
|
502
663
|
}
|
|
503
664
|
catch (error) {
|
|
504
665
|
lastError = error;
|
|
666
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
667
|
+
// (e.g., foreign key constraints preventing deletion)
|
|
668
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
669
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
670
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
671
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
672
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
673
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
674
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
|
|
675
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
|
|
676
|
+
((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
|
|
677
|
+
((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
|
|
678
|
+
if (isConstraintViolation) {
|
|
679
|
+
const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
|
|
680
|
+
logger_1.logger.error("Non-retryable constraint violation in deleteOneMarketSentiment", {
|
|
681
|
+
operation: 'deleteOneMarketSentiment',
|
|
682
|
+
model: 'MarketSentiment',
|
|
683
|
+
error: String(error),
|
|
684
|
+
recordId: props.id,
|
|
685
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
686
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
687
|
+
isRetryable: false,
|
|
688
|
+
});
|
|
689
|
+
throw error;
|
|
690
|
+
}
|
|
505
691
|
// Check if this is a database connection error that we should retry
|
|
506
|
-
const isConnectionError = ((
|
|
507
|
-
((
|
|
508
|
-
((
|
|
509
|
-
((
|
|
510
|
-
(error.networkError && ((
|
|
692
|
+
const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
|
|
693
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
|
|
694
|
+
((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
|
|
695
|
+
((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
696
|
+
(error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
|
|
511
697
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
512
698
|
retryCount++;
|
|
513
699
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
514
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
700
|
+
logger_1.logger.warn("Database connection error in deleteOneMarketSentiment, retrying...", {
|
|
701
|
+
operation: 'deleteOneMarketSentiment',
|
|
702
|
+
model: 'MarketSentiment',
|
|
703
|
+
attempt: retryCount,
|
|
704
|
+
maxRetries: MAX_RETRIES,
|
|
705
|
+
recordId: props.id,
|
|
706
|
+
});
|
|
515
707
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
516
708
|
continue;
|
|
517
709
|
}
|
|
518
|
-
// Log
|
|
519
|
-
logger_1.logger.error("Database
|
|
710
|
+
// Log structured error details and rethrow
|
|
711
|
+
logger_1.logger.error("Database delete operation failed", {
|
|
712
|
+
operation: 'deleteOneMarketSentiment',
|
|
713
|
+
model: 'MarketSentiment',
|
|
714
|
+
error: String(error),
|
|
715
|
+
recordId: props.id,
|
|
716
|
+
isRetryable: isConnectionError,
|
|
717
|
+
});
|
|
520
718
|
throw error;
|
|
521
719
|
}
|
|
522
720
|
}
|
|
@@ -583,12 +781,22 @@ exports.MarketSentiment = {
|
|
|
583
781
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
584
782
|
retryCount++;
|
|
585
783
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
586
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
784
|
+
logger_1.logger.warn("Database connection error in getMarketSentiment, retrying...", {
|
|
785
|
+
operation: 'getMarketSentiment',
|
|
786
|
+
model: 'MarketSentiment',
|
|
787
|
+
attempt: retryCount,
|
|
788
|
+
maxRetries: MAX_RETRIES,
|
|
789
|
+
});
|
|
587
790
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
588
791
|
continue;
|
|
589
792
|
}
|
|
590
|
-
// Log
|
|
591
|
-
logger_1.logger.error("Database
|
|
793
|
+
// Log structured error details and rethrow
|
|
794
|
+
logger_1.logger.error("Database get operation failed", {
|
|
795
|
+
operation: 'getMarketSentiment',
|
|
796
|
+
model: 'MarketSentiment',
|
|
797
|
+
error: String(error),
|
|
798
|
+
isRetryable: isConnectionError,
|
|
799
|
+
});
|
|
592
800
|
throw error;
|
|
593
801
|
}
|
|
594
802
|
}
|
|
@@ -646,12 +854,22 @@ exports.MarketSentiment = {
|
|
|
646
854
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
647
855
|
retryCount++;
|
|
648
856
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
649
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
857
|
+
logger_1.logger.warn("Database connection error in getAllMarketSentiment, retrying...", {
|
|
858
|
+
operation: 'getAllMarketSentiment',
|
|
859
|
+
model: 'MarketSentiment',
|
|
860
|
+
attempt: retryCount,
|
|
861
|
+
maxRetries: MAX_RETRIES,
|
|
862
|
+
});
|
|
650
863
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
651
864
|
continue;
|
|
652
865
|
}
|
|
653
|
-
// Log
|
|
654
|
-
logger_1.logger.error("Database
|
|
866
|
+
// Log structured error details and rethrow
|
|
867
|
+
logger_1.logger.error("Database getAll operation failed", {
|
|
868
|
+
operation: 'getAllMarketSentiment',
|
|
869
|
+
model: 'MarketSentiment',
|
|
870
|
+
error: String(error),
|
|
871
|
+
isRetryable: isConnectionError,
|
|
872
|
+
});
|
|
655
873
|
throw error;
|
|
656
874
|
}
|
|
657
875
|
}
|
|
@@ -725,12 +943,22 @@ exports.MarketSentiment = {
|
|
|
725
943
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
726
944
|
retryCount++;
|
|
727
945
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
728
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
946
|
+
logger_1.logger.warn("Database connection error in findManyMarketSentiment, retrying...", {
|
|
947
|
+
operation: 'findManyMarketSentiment',
|
|
948
|
+
model: 'MarketSentiment',
|
|
949
|
+
attempt: retryCount,
|
|
950
|
+
maxRetries: MAX_RETRIES,
|
|
951
|
+
});
|
|
729
952
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
730
953
|
continue;
|
|
731
954
|
}
|
|
732
|
-
// Log
|
|
733
|
-
logger_1.logger.error("Database
|
|
955
|
+
// Log structured error details and rethrow
|
|
956
|
+
logger_1.logger.error("Database findMany operation failed", {
|
|
957
|
+
operation: 'findManyMarketSentiment',
|
|
958
|
+
model: 'MarketSentiment',
|
|
959
|
+
error: String(error),
|
|
960
|
+
isRetryable: isConnectionError,
|
|
961
|
+
});
|
|
734
962
|
throw error;
|
|
735
963
|
}
|
|
736
964
|
}
|