@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/SystemAlert.cjs
CHANGED
|
@@ -49,7 +49,7 @@ exports.SystemAlert = {
|
|
|
49
49
|
* @returns The created SystemAlert or null.
|
|
50
50
|
*/
|
|
51
51
|
async create(props, globalClient) {
|
|
52
|
-
var _a, _b, _c, _d, _e;
|
|
52
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
53
53
|
// Maximum number of retries for database connection issues
|
|
54
54
|
const MAX_RETRIES = 3;
|
|
55
55
|
let retryCount = 0;
|
|
@@ -113,21 +113,52 @@ exports.SystemAlert = {
|
|
|
113
113
|
}
|
|
114
114
|
catch (error) {
|
|
115
115
|
lastError = error;
|
|
116
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
117
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
118
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
119
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
120
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
121
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
122
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
123
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
124
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
125
|
+
if (isConstraintViolation) {
|
|
126
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
127
|
+
logger_1.logger.error("Non-retryable constraint violation in createOneSystemAlert", {
|
|
128
|
+
operation: 'createOneSystemAlert',
|
|
129
|
+
model: 'SystemAlert',
|
|
130
|
+
error: String(error),
|
|
131
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
132
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
133
|
+
isRetryable: false,
|
|
134
|
+
});
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
116
137
|
// Check if this is a database connection error that we should retry
|
|
117
|
-
const isConnectionError = ((
|
|
118
|
-
((
|
|
119
|
-
((
|
|
120
|
-
((
|
|
121
|
-
(error.networkError && ((
|
|
138
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
139
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
140
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
141
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
142
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
122
143
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
123
144
|
retryCount++;
|
|
124
145
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
125
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
146
|
+
logger_1.logger.warn("Database connection error in createOneSystemAlert, retrying...", {
|
|
147
|
+
operation: 'createOneSystemAlert',
|
|
148
|
+
model: 'SystemAlert',
|
|
149
|
+
attempt: retryCount,
|
|
150
|
+
maxRetries: MAX_RETRIES,
|
|
151
|
+
});
|
|
126
152
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
127
153
|
continue;
|
|
128
154
|
}
|
|
129
|
-
// Log
|
|
130
|
-
logger_1.logger.error("Database
|
|
155
|
+
// Log structured error details and rethrow
|
|
156
|
+
logger_1.logger.error("Database create operation failed", {
|
|
157
|
+
operation: 'createOneSystemAlert',
|
|
158
|
+
model: 'SystemAlert',
|
|
159
|
+
error: String(error),
|
|
160
|
+
isRetryable: isConnectionError,
|
|
161
|
+
});
|
|
131
162
|
throw error;
|
|
132
163
|
}
|
|
133
164
|
}
|
|
@@ -142,7 +173,7 @@ exports.SystemAlert = {
|
|
|
142
173
|
* @returns The count of created records or null.
|
|
143
174
|
*/
|
|
144
175
|
async createMany(props, globalClient) {
|
|
145
|
-
var _a, _b, _c, _d, _e;
|
|
176
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
146
177
|
// Maximum number of retries for database connection issues
|
|
147
178
|
const MAX_RETRIES = 3;
|
|
148
179
|
let retryCount = 0;
|
|
@@ -205,21 +236,52 @@ exports.SystemAlert = {
|
|
|
205
236
|
}
|
|
206
237
|
catch (error) {
|
|
207
238
|
lastError = error;
|
|
239
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
240
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
241
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
242
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
243
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
244
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
245
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
246
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
247
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
248
|
+
if (isConstraintViolation) {
|
|
249
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
250
|
+
logger_1.logger.error("Non-retryable constraint violation in createManySystemAlert", {
|
|
251
|
+
operation: 'createManySystemAlert',
|
|
252
|
+
model: 'SystemAlert',
|
|
253
|
+
error: String(error),
|
|
254
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
255
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
256
|
+
isRetryable: false,
|
|
257
|
+
});
|
|
258
|
+
throw error;
|
|
259
|
+
}
|
|
208
260
|
// Check if this is a database connection error that we should retry
|
|
209
|
-
const isConnectionError = ((
|
|
210
|
-
((
|
|
211
|
-
((
|
|
212
|
-
((
|
|
213
|
-
(error.networkError && ((
|
|
261
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
262
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
263
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
264
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
265
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
214
266
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
215
267
|
retryCount++;
|
|
216
268
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
217
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
269
|
+
logger_1.logger.warn("Database connection error in createManySystemAlert, retrying...", {
|
|
270
|
+
operation: 'createManySystemAlert',
|
|
271
|
+
model: 'SystemAlert',
|
|
272
|
+
attempt: retryCount,
|
|
273
|
+
maxRetries: MAX_RETRIES,
|
|
274
|
+
});
|
|
218
275
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
219
276
|
continue;
|
|
220
277
|
}
|
|
221
|
-
// Log
|
|
222
|
-
logger_1.logger.error("Database
|
|
278
|
+
// Log structured error details and rethrow
|
|
279
|
+
logger_1.logger.error("Database createMany operation failed", {
|
|
280
|
+
operation: 'createManySystemAlert',
|
|
281
|
+
model: 'SystemAlert',
|
|
282
|
+
error: String(error),
|
|
283
|
+
isRetryable: isConnectionError,
|
|
284
|
+
});
|
|
223
285
|
throw error;
|
|
224
286
|
}
|
|
225
287
|
}
|
|
@@ -234,7 +296,7 @@ exports.SystemAlert = {
|
|
|
234
296
|
* @returns The updated SystemAlert or null.
|
|
235
297
|
*/
|
|
236
298
|
async update(props, globalClient) {
|
|
237
|
-
var _a, _b, _c, _d, _e;
|
|
299
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
238
300
|
// Maximum number of retries for database connection issues
|
|
239
301
|
const MAX_RETRIES = 3;
|
|
240
302
|
let retryCount = 0;
|
|
@@ -355,21 +417,55 @@ exports.SystemAlert = {
|
|
|
355
417
|
}
|
|
356
418
|
catch (error) {
|
|
357
419
|
lastError = error;
|
|
420
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
421
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
422
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
423
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
424
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
425
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
426
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
427
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
428
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
429
|
+
if (isConstraintViolation) {
|
|
430
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
431
|
+
logger_1.logger.error("Non-retryable constraint violation in updateOneSystemAlert", {
|
|
432
|
+
operation: 'updateOneSystemAlert',
|
|
433
|
+
model: 'SystemAlert',
|
|
434
|
+
error: String(error),
|
|
435
|
+
recordId: props.id,
|
|
436
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
437
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
438
|
+
isRetryable: false,
|
|
439
|
+
});
|
|
440
|
+
throw error;
|
|
441
|
+
}
|
|
358
442
|
// Check if this is a database connection error that we should retry
|
|
359
|
-
const isConnectionError = ((
|
|
360
|
-
((
|
|
361
|
-
((
|
|
362
|
-
((
|
|
363
|
-
(error.networkError && ((
|
|
443
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
444
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
445
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
446
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
447
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
364
448
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
365
449
|
retryCount++;
|
|
366
450
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
367
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
451
|
+
logger_1.logger.warn("Database connection error in updateOneSystemAlert, retrying...", {
|
|
452
|
+
operation: 'updateOneSystemAlert',
|
|
453
|
+
model: 'SystemAlert',
|
|
454
|
+
attempt: retryCount,
|
|
455
|
+
maxRetries: MAX_RETRIES,
|
|
456
|
+
recordId: props.id,
|
|
457
|
+
});
|
|
368
458
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
369
459
|
continue;
|
|
370
460
|
}
|
|
371
|
-
// Log
|
|
372
|
-
logger_1.logger.error("Database
|
|
461
|
+
// Log structured error details and rethrow
|
|
462
|
+
logger_1.logger.error("Database update operation failed", {
|
|
463
|
+
operation: 'updateOneSystemAlert',
|
|
464
|
+
model: 'SystemAlert',
|
|
465
|
+
error: String(error),
|
|
466
|
+
recordId: props.id,
|
|
467
|
+
isRetryable: isConnectionError,
|
|
468
|
+
});
|
|
373
469
|
throw error;
|
|
374
470
|
}
|
|
375
471
|
}
|
|
@@ -384,7 +480,7 @@ exports.SystemAlert = {
|
|
|
384
480
|
* @returns The updated SystemAlert or null.
|
|
385
481
|
*/
|
|
386
482
|
async upsert(props, globalClient) {
|
|
387
|
-
var _a, _b, _c, _d, _e;
|
|
483
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
388
484
|
// Maximum number of retries for database connection issues
|
|
389
485
|
const MAX_RETRIES = 3;
|
|
390
486
|
let retryCount = 0;
|
|
@@ -518,21 +614,55 @@ exports.SystemAlert = {
|
|
|
518
614
|
}
|
|
519
615
|
catch (error) {
|
|
520
616
|
lastError = error;
|
|
617
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
618
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
619
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
620
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
621
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
622
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
623
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
624
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
625
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
626
|
+
if (isConstraintViolation) {
|
|
627
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
628
|
+
logger_1.logger.error("Non-retryable constraint violation in upsertOneSystemAlert", {
|
|
629
|
+
operation: 'upsertOneSystemAlert',
|
|
630
|
+
model: 'SystemAlert',
|
|
631
|
+
error: String(error),
|
|
632
|
+
recordId: props.id,
|
|
633
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
634
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
635
|
+
isRetryable: false,
|
|
636
|
+
});
|
|
637
|
+
throw error;
|
|
638
|
+
}
|
|
521
639
|
// Check if this is a database connection error that we should retry
|
|
522
|
-
const isConnectionError = ((
|
|
523
|
-
((
|
|
524
|
-
((
|
|
525
|
-
((
|
|
526
|
-
(error.networkError && ((
|
|
640
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
641
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
642
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
643
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
644
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
527
645
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
528
646
|
retryCount++;
|
|
529
647
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
530
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
648
|
+
logger_1.logger.warn("Database connection error in upsertOneSystemAlert, retrying...", {
|
|
649
|
+
operation: 'upsertOneSystemAlert',
|
|
650
|
+
model: 'SystemAlert',
|
|
651
|
+
attempt: retryCount,
|
|
652
|
+
maxRetries: MAX_RETRIES,
|
|
653
|
+
recordId: props.id,
|
|
654
|
+
});
|
|
531
655
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
532
656
|
continue;
|
|
533
657
|
}
|
|
534
|
-
// Log
|
|
535
|
-
logger_1.logger.error("Database
|
|
658
|
+
// Log structured error details and rethrow
|
|
659
|
+
logger_1.logger.error("Database upsert operation failed", {
|
|
660
|
+
operation: 'upsertOneSystemAlert',
|
|
661
|
+
model: 'SystemAlert',
|
|
662
|
+
error: String(error),
|
|
663
|
+
recordId: props.id,
|
|
664
|
+
isRetryable: isConnectionError,
|
|
665
|
+
});
|
|
536
666
|
throw error;
|
|
537
667
|
}
|
|
538
668
|
}
|
|
@@ -547,7 +677,7 @@ exports.SystemAlert = {
|
|
|
547
677
|
* @returns The count of created records or null.
|
|
548
678
|
*/
|
|
549
679
|
async updateMany(props, globalClient) {
|
|
550
|
-
var _a, _b, _c, _d, _e;
|
|
680
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
551
681
|
// Maximum number of retries for database connection issues
|
|
552
682
|
const MAX_RETRIES = 3;
|
|
553
683
|
let retryCount = 0;
|
|
@@ -668,21 +798,52 @@ exports.SystemAlert = {
|
|
|
668
798
|
}
|
|
669
799
|
catch (error) {
|
|
670
800
|
lastError = error;
|
|
801
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
802
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
803
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
804
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
805
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
806
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
807
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
808
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('P2002')) ||
|
|
809
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2003'));
|
|
810
|
+
if (isConstraintViolation) {
|
|
811
|
+
const constraintMatch = (_j = error.message) === null || _j === void 0 ? void 0 : _j.match(/constraint\s+"([^"]+)"/);
|
|
812
|
+
logger_1.logger.error("Non-retryable constraint violation in updateManySystemAlert", {
|
|
813
|
+
operation: 'updateManySystemAlert',
|
|
814
|
+
model: 'SystemAlert',
|
|
815
|
+
error: String(error),
|
|
816
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
817
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
818
|
+
isRetryable: false,
|
|
819
|
+
});
|
|
820
|
+
throw error;
|
|
821
|
+
}
|
|
671
822
|
// Check if this is a database connection error that we should retry
|
|
672
|
-
const isConnectionError = ((
|
|
673
|
-
((
|
|
674
|
-
((
|
|
675
|
-
((
|
|
676
|
-
(error.networkError && ((
|
|
823
|
+
const isConnectionError = ((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('Server has closed the connection')) ||
|
|
824
|
+
((_l = error.message) === null || _l === void 0 ? void 0 : _l.includes('Cannot reach database server')) ||
|
|
825
|
+
((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Connection timed out')) ||
|
|
826
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
827
|
+
(error.networkError && ((_p = error.networkError.message) === null || _p === void 0 ? void 0 : _p.includes('Failed to fetch')));
|
|
677
828
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
678
829
|
retryCount++;
|
|
679
830
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
680
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
831
|
+
logger_1.logger.warn("Database connection error in updateManySystemAlert, retrying...", {
|
|
832
|
+
operation: 'updateManySystemAlert',
|
|
833
|
+
model: 'SystemAlert',
|
|
834
|
+
attempt: retryCount,
|
|
835
|
+
maxRetries: MAX_RETRIES,
|
|
836
|
+
});
|
|
681
837
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
682
838
|
continue;
|
|
683
839
|
}
|
|
684
|
-
// Log
|
|
685
|
-
logger_1.logger.error("Database
|
|
840
|
+
// Log structured error details and rethrow
|
|
841
|
+
logger_1.logger.error("Database updateMany operation failed", {
|
|
842
|
+
operation: 'updateManySystemAlert',
|
|
843
|
+
model: 'SystemAlert',
|
|
844
|
+
error: String(error),
|
|
845
|
+
isRetryable: isConnectionError,
|
|
846
|
+
});
|
|
686
847
|
throw error;
|
|
687
848
|
}
|
|
688
849
|
}
|
|
@@ -697,7 +858,7 @@ exports.SystemAlert = {
|
|
|
697
858
|
* @returns The deleted SystemAlert or null.
|
|
698
859
|
*/
|
|
699
860
|
async delete(props, globalClient) {
|
|
700
|
-
var _a, _b, _c, _d, _e;
|
|
861
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
701
862
|
// Maximum number of retries for database connection issues
|
|
702
863
|
const MAX_RETRIES = 3;
|
|
703
864
|
let retryCount = 0;
|
|
@@ -741,21 +902,58 @@ exports.SystemAlert = {
|
|
|
741
902
|
}
|
|
742
903
|
catch (error) {
|
|
743
904
|
lastError = error;
|
|
905
|
+
// Check for constraint violations FIRST - these are NEVER retryable
|
|
906
|
+
// (e.g., foreign key constraints preventing deletion)
|
|
907
|
+
const isConstraintViolation = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('violates check constraint')) ||
|
|
908
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('violates unique constraint')) ||
|
|
909
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('violates foreign key constraint')) ||
|
|
910
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('unique constraint')) ||
|
|
911
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('23514')) ||
|
|
912
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('23505')) ||
|
|
913
|
+
((_g = error.message) === null || _g === void 0 ? void 0 : _g.includes('23503')) ||
|
|
914
|
+
((_h = error.message) === null || _h === void 0 ? void 0 : _h.includes('P2002')) ||
|
|
915
|
+
((_j = error.message) === null || _j === void 0 ? void 0 : _j.includes('P2003')) ||
|
|
916
|
+
((_k = error.message) === null || _k === void 0 ? void 0 : _k.includes('P2014'));
|
|
917
|
+
if (isConstraintViolation) {
|
|
918
|
+
const constraintMatch = (_l = error.message) === null || _l === void 0 ? void 0 : _l.match(/constraint\s+"([^"]+)"/);
|
|
919
|
+
logger_1.logger.error("Non-retryable constraint violation in deleteOneSystemAlert", {
|
|
920
|
+
operation: 'deleteOneSystemAlert',
|
|
921
|
+
model: 'SystemAlert',
|
|
922
|
+
error: String(error),
|
|
923
|
+
recordId: props.id,
|
|
924
|
+
constraintName: constraintMatch ? constraintMatch[1] : undefined,
|
|
925
|
+
errorCategory: 'CONSTRAINT_VIOLATION',
|
|
926
|
+
isRetryable: false,
|
|
927
|
+
});
|
|
928
|
+
throw error;
|
|
929
|
+
}
|
|
744
930
|
// Check if this is a database connection error that we should retry
|
|
745
|
-
const isConnectionError = ((
|
|
746
|
-
((
|
|
747
|
-
((
|
|
748
|
-
((
|
|
749
|
-
(error.networkError && ((
|
|
931
|
+
const isConnectionError = ((_m = error.message) === null || _m === void 0 ? void 0 : _m.includes('Server has closed the connection')) ||
|
|
932
|
+
((_o = error.message) === null || _o === void 0 ? void 0 : _o.includes('Cannot reach database server')) ||
|
|
933
|
+
((_p = error.message) === null || _p === void 0 ? void 0 : _p.includes('Connection timed out')) ||
|
|
934
|
+
((_q = error.message) === null || _q === void 0 ? void 0 : _q.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
|
935
|
+
(error.networkError && ((_r = error.networkError.message) === null || _r === void 0 ? void 0 : _r.includes('Failed to fetch')));
|
|
750
936
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
751
937
|
retryCount++;
|
|
752
938
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
753
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
939
|
+
logger_1.logger.warn("Database connection error in deleteOneSystemAlert, retrying...", {
|
|
940
|
+
operation: 'deleteOneSystemAlert',
|
|
941
|
+
model: 'SystemAlert',
|
|
942
|
+
attempt: retryCount,
|
|
943
|
+
maxRetries: MAX_RETRIES,
|
|
944
|
+
recordId: props.id,
|
|
945
|
+
});
|
|
754
946
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
755
947
|
continue;
|
|
756
948
|
}
|
|
757
|
-
// Log
|
|
758
|
-
logger_1.logger.error("Database
|
|
949
|
+
// Log structured error details and rethrow
|
|
950
|
+
logger_1.logger.error("Database delete operation failed", {
|
|
951
|
+
operation: 'deleteOneSystemAlert',
|
|
952
|
+
model: 'SystemAlert',
|
|
953
|
+
error: String(error),
|
|
954
|
+
recordId: props.id,
|
|
955
|
+
isRetryable: isConnectionError,
|
|
956
|
+
});
|
|
759
957
|
throw error;
|
|
760
958
|
}
|
|
761
959
|
}
|
|
@@ -828,12 +1026,22 @@ exports.SystemAlert = {
|
|
|
828
1026
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
829
1027
|
retryCount++;
|
|
830
1028
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
831
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
1029
|
+
logger_1.logger.warn("Database connection error in getSystemAlert, retrying...", {
|
|
1030
|
+
operation: 'getSystemAlert',
|
|
1031
|
+
model: 'SystemAlert',
|
|
1032
|
+
attempt: retryCount,
|
|
1033
|
+
maxRetries: MAX_RETRIES,
|
|
1034
|
+
});
|
|
832
1035
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
833
1036
|
continue;
|
|
834
1037
|
}
|
|
835
|
-
// Log
|
|
836
|
-
logger_1.logger.error("Database
|
|
1038
|
+
// Log structured error details and rethrow
|
|
1039
|
+
logger_1.logger.error("Database get operation failed", {
|
|
1040
|
+
operation: 'getSystemAlert',
|
|
1041
|
+
model: 'SystemAlert',
|
|
1042
|
+
error: String(error),
|
|
1043
|
+
isRetryable: isConnectionError,
|
|
1044
|
+
});
|
|
837
1045
|
throw error;
|
|
838
1046
|
}
|
|
839
1047
|
}
|
|
@@ -891,12 +1099,22 @@ exports.SystemAlert = {
|
|
|
891
1099
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
892
1100
|
retryCount++;
|
|
893
1101
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
894
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
1102
|
+
logger_1.logger.warn("Database connection error in getAllSystemAlert, retrying...", {
|
|
1103
|
+
operation: 'getAllSystemAlert',
|
|
1104
|
+
model: 'SystemAlert',
|
|
1105
|
+
attempt: retryCount,
|
|
1106
|
+
maxRetries: MAX_RETRIES,
|
|
1107
|
+
});
|
|
895
1108
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
896
1109
|
continue;
|
|
897
1110
|
}
|
|
898
|
-
// Log
|
|
899
|
-
logger_1.logger.error("Database
|
|
1111
|
+
// Log structured error details and rethrow
|
|
1112
|
+
logger_1.logger.error("Database getAll operation failed", {
|
|
1113
|
+
operation: 'getAllSystemAlert',
|
|
1114
|
+
model: 'SystemAlert',
|
|
1115
|
+
error: String(error),
|
|
1116
|
+
isRetryable: isConnectionError,
|
|
1117
|
+
});
|
|
900
1118
|
throw error;
|
|
901
1119
|
}
|
|
902
1120
|
}
|
|
@@ -976,12 +1194,22 @@ exports.SystemAlert = {
|
|
|
976
1194
|
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
|
977
1195
|
retryCount++;
|
|
978
1196
|
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
|
979
|
-
logger_1.logger.warn("Database connection error, retrying..."
|
|
1197
|
+
logger_1.logger.warn("Database connection error in findManySystemAlert, retrying...", {
|
|
1198
|
+
operation: 'findManySystemAlert',
|
|
1199
|
+
model: 'SystemAlert',
|
|
1200
|
+
attempt: retryCount,
|
|
1201
|
+
maxRetries: MAX_RETRIES,
|
|
1202
|
+
});
|
|
980
1203
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
981
1204
|
continue;
|
|
982
1205
|
}
|
|
983
|
-
// Log
|
|
984
|
-
logger_1.logger.error("Database
|
|
1206
|
+
// Log structured error details and rethrow
|
|
1207
|
+
logger_1.logger.error("Database findMany operation failed", {
|
|
1208
|
+
operation: 'findManySystemAlert',
|
|
1209
|
+
model: 'SystemAlert',
|
|
1210
|
+
error: String(error),
|
|
1211
|
+
isRetryable: isConnectionError,
|
|
1212
|
+
});
|
|
985
1213
|
throw error;
|
|
986
1214
|
}
|
|
987
1215
|
}
|