adaptic-backend 1.0.340 → 1.0.341
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/Account.cjs +2543 -2265
- package/Account.d.ts +19 -2
- package/Action.cjs +1116 -838
- package/Action.d.ts +19 -2
- package/Alert.cjs +2626 -2348
- package/Alert.d.ts +19 -2
- package/Allocation.cjs +2578 -2300
- package/Allocation.d.ts +19 -2
- package/AlpacaAccount.cjs +2383 -2105
- package/AlpacaAccount.d.ts +19 -2
- package/Asset.cjs +1813 -1535
- package/Asset.d.ts +19 -2
- package/Authenticator.cjs +2568 -2290
- package/Authenticator.d.ts +19 -2
- package/Customer.cjs +2495 -2217
- package/Customer.d.ts +19 -2
- package/EconomicEvent.cjs +645 -367
- package/EconomicEvent.d.ts +19 -2
- package/MarketSentiment.cjs +618 -340
- package/MarketSentiment.d.ts +19 -2
- package/NewsArticle.cjs +1933 -1655
- package/NewsArticle.d.ts +19 -2
- package/NewsArticleAssetSentiment.cjs +1842 -1564
- package/NewsArticleAssetSentiment.d.ts +19 -2
- package/ScheduledOptionOrder.cjs +594 -316
- package/ScheduledOptionOrder.d.ts +19 -2
- package/Session.cjs +2570 -2292
- package/Session.d.ts +19 -2
- package/Trade.cjs +1073 -795
- package/Trade.d.ts +19 -2
- package/User.cjs +2288 -2010
- package/User.d.ts +19 -2
- package/VerificationToken.cjs +606 -328
- package/VerificationToken.d.ts +19 -2
- package/esm/Account.d.ts +19 -2
- package/esm/Account.d.ts.map +1 -1
- package/esm/Account.js.map +1 -1
- package/esm/Account.mjs +2534 -2263
- package/esm/Action.d.ts +19 -2
- package/esm/Action.d.ts.map +1 -1
- package/esm/Action.js.map +1 -1
- package/esm/Action.mjs +1107 -836
- package/esm/Alert.d.ts +19 -2
- package/esm/Alert.d.ts.map +1 -1
- package/esm/Alert.js.map +1 -1
- package/esm/Alert.mjs +2617 -2346
- package/esm/Allocation.d.ts +19 -2
- package/esm/Allocation.d.ts.map +1 -1
- package/esm/Allocation.js.map +1 -1
- package/esm/Allocation.mjs +2569 -2298
- package/esm/AlpacaAccount.d.ts +19 -2
- package/esm/AlpacaAccount.d.ts.map +1 -1
- package/esm/AlpacaAccount.js.map +1 -1
- package/esm/AlpacaAccount.mjs +2374 -2103
- package/esm/Asset.d.ts +19 -2
- package/esm/Asset.d.ts.map +1 -1
- package/esm/Asset.js.map +1 -1
- package/esm/Asset.mjs +1804 -1533
- package/esm/Authenticator.d.ts +19 -2
- package/esm/Authenticator.d.ts.map +1 -1
- package/esm/Authenticator.js.map +1 -1
- package/esm/Authenticator.mjs +2559 -2288
- package/esm/Customer.d.ts +19 -2
- package/esm/Customer.d.ts.map +1 -1
- package/esm/Customer.js.map +1 -1
- package/esm/Customer.mjs +2486 -2215
- package/esm/EconomicEvent.d.ts +19 -2
- package/esm/EconomicEvent.d.ts.map +1 -1
- package/esm/EconomicEvent.js.map +1 -1
- package/esm/EconomicEvent.mjs +636 -365
- package/esm/MarketSentiment.d.ts +19 -2
- package/esm/MarketSentiment.d.ts.map +1 -1
- package/esm/MarketSentiment.js.map +1 -1
- package/esm/MarketSentiment.mjs +609 -338
- package/esm/NewsArticle.d.ts +19 -2
- package/esm/NewsArticle.d.ts.map +1 -1
- package/esm/NewsArticle.js.map +1 -1
- package/esm/NewsArticle.mjs +1924 -1653
- package/esm/NewsArticleAssetSentiment.d.ts +19 -2
- package/esm/NewsArticleAssetSentiment.d.ts.map +1 -1
- package/esm/NewsArticleAssetSentiment.js.map +1 -1
- package/esm/NewsArticleAssetSentiment.mjs +1833 -1562
- package/esm/ScheduledOptionOrder.d.ts +19 -2
- package/esm/ScheduledOptionOrder.d.ts.map +1 -1
- package/esm/ScheduledOptionOrder.js.map +1 -1
- package/esm/ScheduledOptionOrder.mjs +585 -314
- package/esm/Session.d.ts +19 -2
- package/esm/Session.d.ts.map +1 -1
- package/esm/Session.js.map +1 -1
- package/esm/Session.mjs +2561 -2290
- package/esm/Trade.d.ts +19 -2
- package/esm/Trade.d.ts.map +1 -1
- package/esm/Trade.js.map +1 -1
- package/esm/Trade.mjs +1064 -793
- package/esm/User.d.ts +19 -2
- package/esm/User.d.ts.map +1 -1
- package/esm/User.js.map +1 -1
- package/esm/User.mjs +2279 -2008
- package/esm/VerificationToken.d.ts +19 -2
- package/esm/VerificationToken.d.ts.map +1 -1
- package/esm/VerificationToken.js.map +1 -1
- package/esm/VerificationToken.mjs +597 -326
- package/esm/prismaClient.d.ts +4 -5
- package/esm/prismaClient.d.ts.map +1 -1
- package/esm/prismaClient.js.map +1 -1
- package/esm/prismaClient.mjs +13 -11
- package/package.json +1 -1
- package/prismaClient.cjs +13 -11
- package/prismaClient.d.ts +4 -5
- package/server.cjs +37 -5
package/ScheduledOptionOrder.cjs
CHANGED
@@ -20,416 +20,694 @@ exports.ScheduledOptionOrder = {
|
|
20
20
|
* @param client - Apollo Client instance.
|
21
21
|
* @returns The created ScheduledOptionOrder or null.
|
22
22
|
*/
|
23
|
+
/**
|
24
|
+
* Create a new ScheduledOptionOrder record.
|
25
|
+
* Enhanced with connection resilience against Prisma connection errors.
|
26
|
+
* @param props - Properties for the new record.
|
27
|
+
* @param globalClient - Apollo Client instance.
|
28
|
+
* @returns The created ScheduledOptionOrder or null.
|
29
|
+
*/
|
23
30
|
async create(props, globalClient) {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
31
|
+
var _a, _b, _c, _d, _e;
|
32
|
+
// Maximum number of retries for database connection issues
|
33
|
+
const MAX_RETRIES = 3;
|
34
|
+
let retryCount = 0;
|
35
|
+
let lastError = null;
|
36
|
+
// Retry loop to handle potential database connection issues
|
37
|
+
while (retryCount < MAX_RETRIES) {
|
38
|
+
try {
|
39
|
+
const [modules, client] = await Promise.all([
|
40
|
+
(0, client_1.getApolloModules)(),
|
41
|
+
globalClient
|
42
|
+
? Promise.resolve(globalClient)
|
43
|
+
: client_1.client
|
44
|
+
]);
|
45
|
+
const { gql, ApolloError } = modules;
|
46
|
+
const CREATE_ONE_SCHEDULEDOPTIONORDER = gql `
|
47
|
+
mutation createOneScheduledOptionOrder($data: ScheduledOptionOrderCreateInput!) {
|
48
|
+
createOneScheduledOptionOrder(data: $data) {
|
49
|
+
${selectionSet}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
`;
|
53
|
+
const variables = {
|
54
|
+
data: {
|
55
|
+
payload: props.payload !== undefined ? props.payload : undefined,
|
56
|
+
status: props.status !== undefined ? props.status : undefined,
|
57
|
+
},
|
58
|
+
};
|
59
|
+
const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
|
60
|
+
const response = await client.mutate({
|
61
|
+
mutation: CREATE_ONE_SCHEDULEDOPTIONORDER,
|
62
|
+
variables: filteredVariables,
|
63
|
+
// Don't cache mutations, but ensure we're using the freshest context
|
64
|
+
fetchPolicy: 'no-cache'
|
65
|
+
});
|
66
|
+
if (response.errors && response.errors.length > 0)
|
67
|
+
throw new Error(response.errors[0].message);
|
68
|
+
if (response && response.data && response.data.createOneScheduledOptionOrder) {
|
69
|
+
return response.data.createOneScheduledOptionOrder;
|
70
|
+
}
|
71
|
+
else {
|
72
|
+
return null;
|
73
|
+
}
|
51
74
|
}
|
52
|
-
|
53
|
-
|
75
|
+
catch (error) {
|
76
|
+
lastError = error;
|
77
|
+
// Check if this is a database connection error that we should retry
|
78
|
+
const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
|
79
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
|
80
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
|
81
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
82
|
+
(error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
|
83
|
+
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
84
|
+
retryCount++;
|
85
|
+
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
86
|
+
console.warn("Database connection error, retrying...");
|
87
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
88
|
+
continue;
|
89
|
+
}
|
90
|
+
// Log the error and rethrow
|
91
|
+
console.error("Database error occurred:", error);
|
92
|
+
throw error;
|
54
93
|
}
|
55
94
|
}
|
56
|
-
|
57
|
-
|
58
|
-
throw error;
|
59
|
-
}
|
95
|
+
// If we exhausted retries, throw the last error
|
96
|
+
throw lastError;
|
60
97
|
},
|
61
98
|
/**
|
62
99
|
* Create multiple ScheduledOptionOrder records.
|
100
|
+
* Enhanced with connection resilience against Prisma connection errors.
|
63
101
|
* @param props - Array of ScheduledOptionOrder objects for the new records.
|
64
102
|
* @param globalClient - Apollo Client instance.
|
65
103
|
* @returns The count of created records or null.
|
66
104
|
*/
|
67
105
|
async createMany(props, globalClient) {
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
|
88
|
-
try {
|
89
|
-
const response = await client.mutate({ mutation: CREATE_MANY_SCHEDULEDOPTIONORDER, variables: filteredVariables });
|
90
|
-
if (response.errors && response.errors.length > 0)
|
91
|
-
throw new Error(response.errors[0].message);
|
92
|
-
if (response && response.data && response.data.createManyScheduledOptionOrder) {
|
93
|
-
return response.data.createManyScheduledOptionOrder;
|
106
|
+
var _a, _b, _c, _d, _e;
|
107
|
+
// Maximum number of retries for database connection issues
|
108
|
+
const MAX_RETRIES = 3;
|
109
|
+
let retryCount = 0;
|
110
|
+
let lastError = null;
|
111
|
+
// Retry loop to handle potential database connection issues
|
112
|
+
while (retryCount < MAX_RETRIES) {
|
113
|
+
try {
|
114
|
+
const [modules, client] = await Promise.all([
|
115
|
+
(0, client_1.getApolloModules)(),
|
116
|
+
globalClient
|
117
|
+
? Promise.resolve(globalClient)
|
118
|
+
: client_1.client
|
119
|
+
]);
|
120
|
+
const { gql, ApolloError } = modules;
|
121
|
+
const CREATE_MANY_SCHEDULEDOPTIONORDER = gql `
|
122
|
+
mutation createManyScheduledOptionOrder($data: [ScheduledOptionOrderCreateManyInput!]!) {
|
123
|
+
createManyScheduledOptionOrder(data: $data) {
|
124
|
+
count
|
94
125
|
}
|
95
|
-
|
96
|
-
|
126
|
+
}`;
|
127
|
+
const variables = {
|
128
|
+
data: props.map(prop => ({
|
129
|
+
payload: prop.payload !== undefined ? prop.payload : undefined,
|
130
|
+
status: prop.status !== undefined ? prop.status : undefined,
|
131
|
+
})),
|
132
|
+
};
|
133
|
+
const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
|
134
|
+
const response = await client.mutate({
|
135
|
+
mutation: CREATE_MANY_SCHEDULEDOPTIONORDER,
|
136
|
+
variables: filteredVariables,
|
137
|
+
// Don't cache mutations, but ensure we're using the freshest context
|
138
|
+
fetchPolicy: 'no-cache'
|
139
|
+
});
|
140
|
+
if (response.errors && response.errors.length > 0)
|
141
|
+
throw new Error(response.errors[0].message);
|
142
|
+
if (response && response.data && response.data.createManyScheduledOptionOrder) {
|
143
|
+
return response.data.createManyScheduledOptionOrder;
|
144
|
+
}
|
145
|
+
else {
|
146
|
+
return null;
|
147
|
+
}
|
148
|
+
}
|
149
|
+
catch (error) {
|
150
|
+
lastError = error;
|
151
|
+
// Check if this is a database connection error that we should retry
|
152
|
+
const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
|
153
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
|
154
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
|
155
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
156
|
+
(error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
|
157
|
+
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
158
|
+
retryCount++;
|
159
|
+
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
160
|
+
console.warn("Database connection error, retrying...");
|
161
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
162
|
+
continue;
|
163
|
+
}
|
164
|
+
// Log the error and rethrow
|
165
|
+
console.error("Database error occurred:", error);
|
166
|
+
throw error;
|
97
167
|
}
|
98
168
|
}
|
99
|
-
|
100
|
-
|
101
|
-
throw error;
|
102
|
-
}
|
169
|
+
// If we exhausted retries, throw the last error
|
170
|
+
throw lastError;
|
103
171
|
},
|
104
172
|
/**
|
105
173
|
* Update a single ScheduledOptionOrder record.
|
174
|
+
* Enhanced with connection resilience against Prisma connection errors.
|
106
175
|
* @param props - Properties to update.
|
107
176
|
* @param globalClient - Apollo Client instance.
|
108
177
|
* @returns The updated ScheduledOptionOrder or null.
|
109
178
|
*/
|
110
179
|
async update(props, globalClient) {
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
data: {
|
129
|
-
|
130
|
-
set: props.id
|
131
|
-
} : undefined,
|
132
|
-
payload: props.payload !== undefined ? {
|
133
|
-
set: props.payload
|
134
|
-
} : undefined,
|
135
|
-
status: props.status !== undefined ? {
|
136
|
-
set: props.status
|
137
|
-
} : undefined,
|
138
|
-
},
|
139
|
-
};
|
140
|
-
const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
|
141
|
-
try {
|
142
|
-
const response = await client.mutate({ mutation: UPDATE_ONE_SCHEDULEDOPTIONORDER, variables: filteredVariables });
|
143
|
-
if (response.errors && response.errors.length > 0)
|
144
|
-
throw new Error(response.errors[0].message);
|
145
|
-
if (response && response.data && response.data.updateOneScheduledOptionOrder) {
|
146
|
-
return response.data.updateOneScheduledOptionOrder;
|
180
|
+
var _a, _b, _c, _d, _e;
|
181
|
+
// Maximum number of retries for database connection issues
|
182
|
+
const MAX_RETRIES = 3;
|
183
|
+
let retryCount = 0;
|
184
|
+
let lastError = null;
|
185
|
+
// Retry loop to handle potential database connection issues
|
186
|
+
while (retryCount < MAX_RETRIES) {
|
187
|
+
try {
|
188
|
+
const [modules, client] = await Promise.all([
|
189
|
+
(0, client_1.getApolloModules)(),
|
190
|
+
globalClient
|
191
|
+
? Promise.resolve(globalClient)
|
192
|
+
: client_1.client
|
193
|
+
]);
|
194
|
+
const { gql, ApolloError } = modules;
|
195
|
+
const UPDATE_ONE_SCHEDULEDOPTIONORDER = gql `
|
196
|
+
mutation updateOneScheduledOptionOrder($data: ScheduledOptionOrderUpdateInput!, $where: ScheduledOptionOrderWhereUniqueInput!) {
|
197
|
+
updateOneScheduledOptionOrder(data: $data, where: $where) {
|
198
|
+
${selectionSet}
|
147
199
|
}
|
148
|
-
|
149
|
-
|
200
|
+
}`;
|
201
|
+
const variables = {
|
202
|
+
where: {
|
203
|
+
id: props.id !== undefined ? props.id : undefined,
|
204
|
+
},
|
205
|
+
data: {
|
206
|
+
id: props.id !== undefined ? {
|
207
|
+
set: props.id
|
208
|
+
} : undefined,
|
209
|
+
payload: props.payload !== undefined ? {
|
210
|
+
set: props.payload
|
211
|
+
} : undefined,
|
212
|
+
status: props.status !== undefined ? {
|
213
|
+
set: props.status
|
214
|
+
} : undefined,
|
215
|
+
},
|
216
|
+
};
|
217
|
+
const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
|
218
|
+
const response = await client.mutate({
|
219
|
+
mutation: UPDATE_ONE_SCHEDULEDOPTIONORDER,
|
220
|
+
variables: filteredVariables,
|
221
|
+
// Don't cache mutations, but ensure we're using the freshest context
|
222
|
+
fetchPolicy: 'no-cache'
|
223
|
+
});
|
224
|
+
if (response.errors && response.errors.length > 0)
|
225
|
+
throw new Error(response.errors[0].message);
|
226
|
+
if (response && response.data && response.data.updateOneScheduledOptionOrder) {
|
227
|
+
return response.data.updateOneScheduledOptionOrder;
|
228
|
+
}
|
229
|
+
else {
|
230
|
+
return null;
|
231
|
+
}
|
232
|
+
}
|
233
|
+
catch (error) {
|
234
|
+
lastError = error;
|
235
|
+
// Check if this is a database connection error that we should retry
|
236
|
+
const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
|
237
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
|
238
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
|
239
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
240
|
+
(error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
|
241
|
+
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
242
|
+
retryCount++;
|
243
|
+
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
244
|
+
console.warn("Database connection error, retrying...");
|
245
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
246
|
+
continue;
|
247
|
+
}
|
248
|
+
// Log the error and rethrow
|
249
|
+
console.error("Database error occurred:", error);
|
250
|
+
throw error;
|
150
251
|
}
|
151
252
|
}
|
152
|
-
|
153
|
-
|
154
|
-
throw error;
|
155
|
-
}
|
253
|
+
// If we exhausted retries, throw the last error
|
254
|
+
throw lastError;
|
156
255
|
},
|
157
256
|
/**
|
158
257
|
* Upsert a single ScheduledOptionOrder record.
|
258
|
+
* Enhanced with connection resilience against Prisma connection errors.
|
159
259
|
* @param props - Properties to update.
|
160
260
|
* @param globalClient - Apollo Client instance.
|
161
261
|
* @returns The updated ScheduledOptionOrder or null.
|
162
262
|
*/
|
163
263
|
async upsert(props, globalClient) {
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
create: {
|
182
|
-
|
183
|
-
status: props.status !== undefined ? props.status : undefined,
|
184
|
-
},
|
185
|
-
update: {
|
186
|
-
payload: props.payload !== undefined ? {
|
187
|
-
set: props.payload
|
188
|
-
} : undefined,
|
189
|
-
status: props.status !== undefined ? {
|
190
|
-
set: props.status
|
191
|
-
} : undefined,
|
192
|
-
},
|
193
|
-
};
|
194
|
-
const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
|
195
|
-
try {
|
196
|
-
const response = await client.mutate({ mutation: UPSERT_ONE_SCHEDULEDOPTIONORDER, variables: filteredVariables });
|
197
|
-
if (response.errors && response.errors.length > 0)
|
198
|
-
throw new Error(response.errors[0].message);
|
199
|
-
if (response && response.data && response.data.upsertOneScheduledOptionOrder) {
|
200
|
-
return response.data.upsertOneScheduledOptionOrder;
|
264
|
+
var _a, _b, _c, _d, _e;
|
265
|
+
// Maximum number of retries for database connection issues
|
266
|
+
const MAX_RETRIES = 3;
|
267
|
+
let retryCount = 0;
|
268
|
+
let lastError = null;
|
269
|
+
// Retry loop to handle potential database connection issues
|
270
|
+
while (retryCount < MAX_RETRIES) {
|
271
|
+
try {
|
272
|
+
const [modules, client] = await Promise.all([
|
273
|
+
(0, client_1.getApolloModules)(),
|
274
|
+
globalClient
|
275
|
+
? Promise.resolve(globalClient)
|
276
|
+
: client_1.client
|
277
|
+
]);
|
278
|
+
const { gql, ApolloError } = modules;
|
279
|
+
const UPSERT_ONE_SCHEDULEDOPTIONORDER = gql `
|
280
|
+
mutation upsertOneScheduledOptionOrder($where: ScheduledOptionOrderWhereUniqueInput!, $create: ScheduledOptionOrderCreateInput!, $update: ScheduledOptionOrderUpdateInput!) {
|
281
|
+
upsertOneScheduledOptionOrder(where: $where, create: $create, update: $update) {
|
282
|
+
${selectionSet}
|
201
283
|
}
|
202
|
-
|
203
|
-
|
284
|
+
}`;
|
285
|
+
const variables = {
|
286
|
+
where: {
|
287
|
+
id: props.id !== undefined ? props.id : undefined,
|
288
|
+
},
|
289
|
+
create: {
|
290
|
+
payload: props.payload !== undefined ? props.payload : undefined,
|
291
|
+
status: props.status !== undefined ? props.status : undefined,
|
292
|
+
},
|
293
|
+
update: {
|
294
|
+
payload: props.payload !== undefined ? {
|
295
|
+
set: props.payload
|
296
|
+
} : undefined,
|
297
|
+
status: props.status !== undefined ? {
|
298
|
+
set: props.status
|
299
|
+
} : undefined,
|
300
|
+
},
|
301
|
+
};
|
302
|
+
const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
|
303
|
+
const response = await client.mutate({
|
304
|
+
mutation: UPSERT_ONE_SCHEDULEDOPTIONORDER,
|
305
|
+
variables: filteredVariables,
|
306
|
+
// Don't cache mutations, but ensure we're using the freshest context
|
307
|
+
fetchPolicy: 'no-cache'
|
308
|
+
});
|
309
|
+
if (response.errors && response.errors.length > 0)
|
310
|
+
throw new Error(response.errors[0].message);
|
311
|
+
if (response && response.data && response.data.upsertOneScheduledOptionOrder) {
|
312
|
+
return response.data.upsertOneScheduledOptionOrder;
|
313
|
+
}
|
314
|
+
else {
|
315
|
+
return null;
|
316
|
+
}
|
317
|
+
}
|
318
|
+
catch (error) {
|
319
|
+
lastError = error;
|
320
|
+
// Check if this is a database connection error that we should retry
|
321
|
+
const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
|
322
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
|
323
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
|
324
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
325
|
+
(error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
|
326
|
+
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
327
|
+
retryCount++;
|
328
|
+
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
329
|
+
console.warn("Database connection error, retrying...");
|
330
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
331
|
+
continue;
|
332
|
+
}
|
333
|
+
// Log the error and rethrow
|
334
|
+
console.error("Database error occurred:", error);
|
335
|
+
throw error;
|
204
336
|
}
|
205
337
|
}
|
206
|
-
|
207
|
-
|
208
|
-
throw error;
|
209
|
-
}
|
338
|
+
// If we exhausted retries, throw the last error
|
339
|
+
throw lastError;
|
210
340
|
},
|
211
341
|
/**
|
212
342
|
* Update multiple ScheduledOptionOrder records.
|
343
|
+
* Enhanced with connection resilience against Prisma connection errors.
|
213
344
|
* @param props - Array of ScheduledOptionOrder objects for the updated records.
|
214
345
|
* @param globalClient - Apollo Client instance.
|
215
346
|
* @returns The count of created records or null.
|
216
347
|
*/
|
217
348
|
async updateMany(props, globalClient) {
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
data: {
|
236
|
-
|
237
|
-
set: prop.id
|
238
|
-
} : undefined,
|
239
|
-
payload: prop.payload !== undefined ? {
|
240
|
-
set: prop.payload
|
241
|
-
} : undefined,
|
242
|
-
status: prop.status !== undefined ? {
|
243
|
-
set: prop.status
|
244
|
-
} : undefined,
|
245
|
-
},
|
246
|
-
}));
|
247
|
-
const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
|
248
|
-
try {
|
249
|
-
const response = await client.mutate({ mutation: UPDATE_MANY_SCHEDULEDOPTIONORDER, variables: filteredVariables });
|
250
|
-
if (response.errors && response.errors.length > 0)
|
251
|
-
throw new Error(response.errors[0].message);
|
252
|
-
if (response && response.data && response.data.updateManyScheduledOptionOrder) {
|
253
|
-
return response.data.updateManyScheduledOptionOrder;
|
349
|
+
var _a, _b, _c, _d, _e;
|
350
|
+
// Maximum number of retries for database connection issues
|
351
|
+
const MAX_RETRIES = 3;
|
352
|
+
let retryCount = 0;
|
353
|
+
let lastError = null;
|
354
|
+
// Retry loop to handle potential database connection issues
|
355
|
+
while (retryCount < MAX_RETRIES) {
|
356
|
+
try {
|
357
|
+
const [modules, client] = await Promise.all([
|
358
|
+
(0, client_1.getApolloModules)(),
|
359
|
+
globalClient
|
360
|
+
? Promise.resolve(globalClient)
|
361
|
+
: client_1.client
|
362
|
+
]);
|
363
|
+
const { gql, ApolloError } = modules;
|
364
|
+
const UPDATE_MANY_SCHEDULEDOPTIONORDER = gql `
|
365
|
+
mutation updateManyScheduledOptionOrder($data: [ScheduledOptionOrderCreateManyInput!]!) {
|
366
|
+
updateManyScheduledOptionOrder(data: $data) {
|
367
|
+
count
|
254
368
|
}
|
255
|
-
|
256
|
-
|
369
|
+
}`;
|
370
|
+
const variables = props.map(prop => ({
|
371
|
+
where: {
|
372
|
+
id: prop.id !== undefined ? prop.id : undefined,
|
373
|
+
},
|
374
|
+
data: {
|
375
|
+
id: prop.id !== undefined ? {
|
376
|
+
set: prop.id
|
377
|
+
} : undefined,
|
378
|
+
payload: prop.payload !== undefined ? {
|
379
|
+
set: prop.payload
|
380
|
+
} : undefined,
|
381
|
+
status: prop.status !== undefined ? {
|
382
|
+
set: prop.status
|
383
|
+
} : undefined,
|
384
|
+
},
|
385
|
+
}));
|
386
|
+
const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
|
387
|
+
const response = await client.mutate({
|
388
|
+
mutation: UPDATE_MANY_SCHEDULEDOPTIONORDER,
|
389
|
+
variables: filteredVariables,
|
390
|
+
// Don't cache mutations, but ensure we're using the freshest context
|
391
|
+
fetchPolicy: 'no-cache'
|
392
|
+
});
|
393
|
+
if (response.errors && response.errors.length > 0)
|
394
|
+
throw new Error(response.errors[0].message);
|
395
|
+
if (response && response.data && response.data.updateManyScheduledOptionOrder) {
|
396
|
+
return response.data.updateManyScheduledOptionOrder;
|
397
|
+
}
|
398
|
+
else {
|
399
|
+
return null;
|
400
|
+
}
|
401
|
+
}
|
402
|
+
catch (error) {
|
403
|
+
lastError = error;
|
404
|
+
// Check if this is a database connection error that we should retry
|
405
|
+
const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
|
406
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
|
407
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
|
408
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
409
|
+
(error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
|
410
|
+
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
411
|
+
retryCount++;
|
412
|
+
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
413
|
+
console.warn("Database connection error, retrying...");
|
414
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
415
|
+
continue;
|
416
|
+
}
|
417
|
+
// Log the error and rethrow
|
418
|
+
console.error("Database error occurred:", error);
|
419
|
+
throw error;
|
257
420
|
}
|
258
421
|
}
|
259
|
-
|
260
|
-
|
261
|
-
throw error;
|
262
|
-
}
|
422
|
+
// If we exhausted retries, throw the last error
|
423
|
+
throw lastError;
|
263
424
|
},
|
264
425
|
/**
|
265
426
|
* Delete a single ScheduledOptionOrder record.
|
266
|
-
*
|
427
|
+
* Enhanced with connection resilience against Prisma connection errors.
|
428
|
+
* @param props - Properties to identify the record to delete.
|
267
429
|
* @param globalClient - Apollo Client instance.
|
268
430
|
* @returns The deleted ScheduledOptionOrder or null.
|
269
431
|
*/
|
270
432
|
async delete(props, globalClient) {
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
433
|
+
var _a, _b, _c, _d, _e;
|
434
|
+
// Maximum number of retries for database connection issues
|
435
|
+
const MAX_RETRIES = 3;
|
436
|
+
let retryCount = 0;
|
437
|
+
let lastError = null;
|
438
|
+
// Retry loop to handle potential database connection issues
|
439
|
+
while (retryCount < MAX_RETRIES) {
|
440
|
+
try {
|
441
|
+
const [modules, client] = await Promise.all([
|
442
|
+
(0, client_1.getApolloModules)(),
|
443
|
+
globalClient
|
444
|
+
? Promise.resolve(globalClient)
|
445
|
+
: client_1.client
|
446
|
+
]);
|
447
|
+
const { gql, ApolloError } = modules;
|
448
|
+
const DELETE_ONE_SCHEDULEDOPTIONORDER = gql `
|
449
|
+
mutation deleteOneScheduledOptionOrder($where: ScheduledOptionOrderWhereUniqueInput!) {
|
450
|
+
deleteOneScheduledOptionOrder(where: $where) {
|
451
|
+
id
|
287
452
|
}
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
453
|
+
}`;
|
454
|
+
const variables = {
|
455
|
+
where: {
|
456
|
+
id: props.id ? props.id : undefined,
|
457
|
+
}
|
458
|
+
};
|
459
|
+
const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
|
460
|
+
const response = await client.mutate({
|
461
|
+
mutation: DELETE_ONE_SCHEDULEDOPTIONORDER,
|
462
|
+
variables: filteredVariables,
|
463
|
+
// Don't cache mutations, but ensure we're using the freshest context
|
464
|
+
fetchPolicy: 'no-cache'
|
465
|
+
});
|
466
|
+
if (response.errors && response.errors.length > 0)
|
467
|
+
throw new Error(response.errors[0].message);
|
468
|
+
if (response && response.data && response.data.deleteOneScheduledOptionOrder) {
|
469
|
+
return response.data.deleteOneScheduledOptionOrder;
|
470
|
+
}
|
471
|
+
else {
|
472
|
+
return null;
|
473
|
+
}
|
296
474
|
}
|
297
|
-
|
298
|
-
|
475
|
+
catch (error) {
|
476
|
+
lastError = error;
|
477
|
+
// Check if this is a database connection error that we should retry
|
478
|
+
const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
|
479
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
|
480
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
|
481
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
482
|
+
(error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
|
483
|
+
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
484
|
+
retryCount++;
|
485
|
+
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
486
|
+
console.warn("Database connection error, retrying...");
|
487
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
488
|
+
continue;
|
489
|
+
}
|
490
|
+
// Log the error and rethrow
|
491
|
+
console.error("Database error occurred:", error);
|
492
|
+
throw error;
|
299
493
|
}
|
300
494
|
}
|
301
|
-
|
302
|
-
|
303
|
-
throw error;
|
304
|
-
}
|
495
|
+
// If we exhausted retries, throw the last error
|
496
|
+
throw lastError;
|
305
497
|
},
|
306
498
|
/**
|
307
499
|
* Retrieve a single ScheduledOptionOrder record by ID.
|
308
|
-
*
|
500
|
+
* Enhanced with connection resilience against Prisma connection errors.
|
501
|
+
* @param props - Properties to identify the record.
|
309
502
|
* @param globalClient - Apollo Client instance.
|
503
|
+
* @param whereInput - Optional custom where input.
|
310
504
|
* @returns The retrieved ScheduledOptionOrder or null.
|
311
505
|
*/
|
312
506
|
async get(props, globalClient, whereInput) {
|
313
|
-
var _a, _b;
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
507
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
508
|
+
// Maximum number of retries for database connection issues
|
509
|
+
const MAX_RETRIES = 3;
|
510
|
+
let retryCount = 0;
|
511
|
+
let lastError = null;
|
512
|
+
// Retry loop to handle potential database connection issues
|
513
|
+
while (retryCount < MAX_RETRIES) {
|
514
|
+
try {
|
515
|
+
const [modules, client] = await Promise.all([
|
516
|
+
(0, client_1.getApolloModules)(),
|
517
|
+
globalClient
|
518
|
+
? Promise.resolve(globalClient)
|
519
|
+
: client_1.client
|
520
|
+
]);
|
521
|
+
const { gql, ApolloError } = modules;
|
522
|
+
const GET_SCHEDULEDOPTIONORDER = gql `
|
523
|
+
query getScheduledOptionOrder($where: ScheduledOptionOrderWhereUniqueInput!) {
|
524
|
+
getScheduledOptionOrder(where: $where) {
|
525
|
+
${selectionSet}
|
526
|
+
}
|
527
|
+
}`;
|
528
|
+
const variables = {
|
529
|
+
where: whereInput ? whereInput : {
|
530
|
+
id: props.id !== undefined ? props.id : undefined,
|
531
|
+
},
|
532
|
+
};
|
533
|
+
const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
|
534
|
+
const response = await client.query({
|
535
|
+
query: GET_SCHEDULEDOPTIONORDER,
|
536
|
+
variables: filteredVariables,
|
537
|
+
fetchPolicy: 'network-only', // Force network request to avoid stale cache
|
538
|
+
});
|
539
|
+
if (response.errors && response.errors.length > 0)
|
540
|
+
throw new Error(response.errors[0].message);
|
541
|
+
return (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.getScheduledOptionOrder) !== null && _b !== void 0 ? _b : null;
|
342
542
|
}
|
343
|
-
|
344
|
-
|
543
|
+
catch (error) {
|
544
|
+
lastError = error;
|
545
|
+
// Check if this is a "No record found" error - this is an expected condition, not a failure
|
546
|
+
if (error.message === 'No ScheduledOptionOrder found') {
|
547
|
+
return null;
|
548
|
+
}
|
549
|
+
// Check if this is a database connection error that we should retry
|
550
|
+
const isConnectionError = ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Server has closed the connection')) ||
|
551
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Cannot reach database server')) ||
|
552
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('Connection timed out')) ||
|
553
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
554
|
+
(error.networkError && ((_g = error.networkError.message) === null || _g === void 0 ? void 0 : _g.includes('Failed to fetch')));
|
555
|
+
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
556
|
+
retryCount++;
|
557
|
+
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
558
|
+
console.warn("Database connection error, retrying...");
|
559
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
560
|
+
continue;
|
561
|
+
}
|
562
|
+
// Log the error and rethrow
|
563
|
+
console.error("Database error occurred:", error);
|
345
564
|
throw error;
|
346
565
|
}
|
347
566
|
}
|
567
|
+
// If we exhausted retries, throw the last error
|
568
|
+
throw lastError;
|
348
569
|
},
|
349
570
|
/**
|
350
571
|
* Retrieve all ScheduledOptionOrders records.
|
572
|
+
* Enhanced with connection resilience against Prisma connection errors.
|
351
573
|
* @param globalClient - Apollo Client instance.
|
352
574
|
* @returns An array of ScheduledOptionOrder records or null.
|
353
575
|
*/
|
354
576
|
async getAll(globalClient) {
|
355
|
-
var _a, _b;
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
}
|
375
|
-
catch (error) {
|
376
|
-
if (error instanceof ApolloError && error.message === 'No ScheduledOptionOrder found') {
|
377
|
-
return null;
|
577
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
578
|
+
// Maximum number of retries for database connection issues
|
579
|
+
const MAX_RETRIES = 3;
|
580
|
+
let retryCount = 0;
|
581
|
+
let lastError = null;
|
582
|
+
// Retry loop to handle potential database connection issues
|
583
|
+
while (retryCount < MAX_RETRIES) {
|
584
|
+
try {
|
585
|
+
const [modules, client] = await Promise.all([
|
586
|
+
(0, client_1.getApolloModules)(),
|
587
|
+
globalClient
|
588
|
+
? Promise.resolve(globalClient)
|
589
|
+
: client_1.client
|
590
|
+
]);
|
591
|
+
const { gql, ApolloError } = modules;
|
592
|
+
const GET_ALL_SCHEDULEDOPTIONORDER = gql `
|
593
|
+
query getAllScheduledOptionOrder {
|
594
|
+
scheduledOptionOrders {
|
595
|
+
${selectionSet}
|
378
596
|
}
|
379
|
-
|
380
|
-
|
597
|
+
}`;
|
598
|
+
const response = await client.query({
|
599
|
+
query: GET_ALL_SCHEDULEDOPTIONORDER,
|
600
|
+
fetchPolicy: 'network-only', // Force network request to avoid stale cache
|
601
|
+
});
|
602
|
+
if (response.errors && response.errors.length > 0)
|
603
|
+
throw new Error(response.errors[0].message);
|
604
|
+
return (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.scheduledOptionOrders) !== null && _b !== void 0 ? _b : null;
|
605
|
+
}
|
606
|
+
catch (error) {
|
607
|
+
lastError = error;
|
608
|
+
// Check if this is a "No record found" error - this is an expected condition, not a failure
|
609
|
+
if (error.message === 'No ScheduledOptionOrder found') {
|
610
|
+
return null;
|
611
|
+
}
|
612
|
+
// Check if this is a database connection error that we should retry
|
613
|
+
const isConnectionError = ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Server has closed the connection')) ||
|
614
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Cannot reach database server')) ||
|
615
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('Connection timed out')) ||
|
616
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
617
|
+
(error.networkError && ((_g = error.networkError.message) === null || _g === void 0 ? void 0 : _g.includes('Failed to fetch')));
|
618
|
+
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
619
|
+
retryCount++;
|
620
|
+
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
621
|
+
console.warn("Database connection error, retrying...");
|
622
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
623
|
+
continue;
|
624
|
+
}
|
625
|
+
// Log the error and rethrow
|
626
|
+
console.error("Database error occurred:", error);
|
381
627
|
throw error;
|
382
628
|
}
|
383
629
|
}
|
630
|
+
// If we exhausted retries, throw the last error
|
631
|
+
throw lastError;
|
384
632
|
},
|
385
633
|
/**
|
386
634
|
* Find multiple ScheduledOptionOrder records based on conditions.
|
635
|
+
* Enhanced with connection resilience against Prisma connection errors.
|
387
636
|
* @param props - Conditions to find records.
|
388
637
|
* @param globalClient - Apollo Client instance.
|
638
|
+
* @param whereInput - Optional custom where input.
|
389
639
|
* @returns An array of found ScheduledOptionOrder records or null.
|
390
640
|
*/
|
391
641
|
async findMany(props, globalClient, whereInput) {
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
};
|
412
|
-
const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
|
413
|
-
try {
|
414
|
-
const response = await client.query({ query: FIND_MANY_SCHEDULEDOPTIONORDER, variables: filteredVariables });
|
415
|
-
if (response.errors && response.errors.length > 0)
|
416
|
-
throw new Error(response.errors[0].message);
|
417
|
-
if (response && response.data && response.data.scheduledoptionorders) {
|
418
|
-
return response.data.scheduledOptionOrders;
|
642
|
+
var _a, _b, _c, _d, _e;
|
643
|
+
// Maximum number of retries for database connection issues
|
644
|
+
const MAX_RETRIES = 3;
|
645
|
+
let retryCount = 0;
|
646
|
+
let lastError = null;
|
647
|
+
// Retry loop to handle potential database connection issues
|
648
|
+
while (retryCount < MAX_RETRIES) {
|
649
|
+
try {
|
650
|
+
const [modules, client] = await Promise.all([
|
651
|
+
(0, client_1.getApolloModules)(),
|
652
|
+
globalClient
|
653
|
+
? Promise.resolve(globalClient)
|
654
|
+
: client_1.client
|
655
|
+
]);
|
656
|
+
const { gql, ApolloError } = modules;
|
657
|
+
const FIND_MANY_SCHEDULEDOPTIONORDER = gql `
|
658
|
+
query findManyScheduledOptionOrder($where: ScheduledOptionOrderWhereInput!) {
|
659
|
+
scheduledOptionOrders(where: $where) {
|
660
|
+
${selectionSet}
|
419
661
|
}
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
662
|
+
}`;
|
663
|
+
const variables = {
|
664
|
+
where: whereInput ? whereInput : {
|
665
|
+
id: props.id !== undefined ? {
|
666
|
+
equals: props.id
|
667
|
+
} : undefined,
|
668
|
+
},
|
669
|
+
};
|
670
|
+
const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
|
671
|
+
const response = await client.query({
|
672
|
+
query: FIND_MANY_SCHEDULEDOPTIONORDER,
|
673
|
+
variables: filteredVariables,
|
674
|
+
fetchPolicy: 'network-only', // Force network request to avoid stale cache
|
675
|
+
});
|
676
|
+
if (response.errors && response.errors.length > 0)
|
677
|
+
throw new Error(response.errors[0].message);
|
678
|
+
if (response && response.data && response.data.scheduledoptionorders) {
|
679
|
+
return response.data.scheduledOptionOrders;
|
680
|
+
}
|
681
|
+
else {
|
682
|
+
return [];
|
683
|
+
}
|
427
684
|
}
|
428
|
-
|
429
|
-
|
685
|
+
catch (error) {
|
686
|
+
lastError = error;
|
687
|
+
// Check if this is a "No record found" error - this is an expected condition, not a failure
|
688
|
+
if (error.message === 'No ScheduledOptionOrder found') {
|
689
|
+
return null;
|
690
|
+
}
|
691
|
+
// Check if this is a database connection error that we should retry
|
692
|
+
const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
|
693
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
|
694
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
|
695
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
696
|
+
(error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
|
697
|
+
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
698
|
+
retryCount++;
|
699
|
+
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
700
|
+
console.warn("Database connection error, retrying...");
|
701
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
702
|
+
continue;
|
703
|
+
}
|
704
|
+
// Log the error and rethrow
|
705
|
+
console.error("Database error occurred:", error);
|
430
706
|
throw error;
|
431
707
|
}
|
432
708
|
}
|
709
|
+
// If we exhausted retries, throw the last error
|
710
|
+
throw lastError;
|
433
711
|
}
|
434
712
|
};
|
435
713
|
//# sourceMappingURL=ScheduledOptionOrder.js.map
|