adaptic-backend 1.0.340 → 1.0.342
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 +2670 -2264
- package/Account.d.ts +19 -2
- package/Action.cjs +1195 -839
- package/Action.d.ts +19 -2
- package/Alert.cjs +2651 -2347
- package/Alert.d.ts +19 -2
- package/Allocation.cjs +2631 -2304
- package/Allocation.d.ts +19 -2
- package/AlpacaAccount.cjs +2654 -2104
- package/AlpacaAccount.d.ts +19 -2
- package/Asset.cjs +2611 -1544
- package/Asset.d.ts +19 -2
- package/Authenticator.cjs +2603 -2290
- package/Authenticator.d.ts +19 -2
- package/Customer.cjs +2506 -2220
- package/Customer.d.ts +19 -2
- package/EconomicEvent.cjs +708 -367
- package/EconomicEvent.d.ts +19 -2
- package/MarketSentiment.cjs +691 -340
- package/MarketSentiment.d.ts +19 -2
- package/NewsArticle.cjs +2114 -1655
- package/NewsArticle.d.ts +19 -2
- package/NewsArticleAssetSentiment.cjs +1873 -1564
- package/NewsArticleAssetSentiment.d.ts +19 -2
- package/ScheduledOptionOrder.cjs +607 -316
- package/ScheduledOptionOrder.d.ts +19 -2
- package/Session.cjs +2592 -2294
- package/Session.d.ts +19 -2
- package/Trade.cjs +1261 -795
- package/Trade.d.ts +19 -2
- package/User.cjs +2432 -2013
- package/User.d.ts +19 -2
- package/VerificationToken.cjs +637 -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 +2661 -2262
- 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 +1186 -837
- 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 +2642 -2345
- 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 +2622 -2302
- 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 +2645 -2102
- 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 +2602 -1542
- 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 +2594 -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 +2497 -2218
- 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 +699 -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 +682 -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 +2105 -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 +1864 -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 +598 -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 +2583 -2292
- 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 +1252 -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 +2423 -2011
- 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 +628 -326
- package/esm/generated/typegraphql-prisma/enhance.js.map +1 -1
- package/esm/generated/typegraphql-prisma/enhance.mjs +1 -1
- package/esm/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.d.ts +1 -1
- package/esm/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.d.ts.map +1 -1
- package/esm/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.js.map +1 -1
- package/esm/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.mjs +7 -7
- 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/generated/typegraphql-prisma/enhance.cjs +1 -1
- package/generated/typegraphql-prisma/enhance.js.map +1 -1
- package/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.cjs +6 -6
- package/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.d.ts +1 -1
- package/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.d.ts.map +1 -1
- package/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.js.map +1 -1
- 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,707 @@ 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
|
+
status: props.status !== undefined ? {
|
205
|
+
equals: props.status
|
206
|
+
} : undefined,
|
207
|
+
},
|
208
|
+
data: {
|
209
|
+
id: props.id !== undefined ? {
|
210
|
+
set: props.id
|
211
|
+
} : undefined,
|
212
|
+
payload: props.payload !== undefined ? {
|
213
|
+
set: props.payload
|
214
|
+
} : undefined,
|
215
|
+
status: props.status !== undefined ? {
|
216
|
+
set: props.status
|
217
|
+
} : undefined,
|
218
|
+
},
|
219
|
+
};
|
220
|
+
const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
|
221
|
+
const response = await client.mutate({
|
222
|
+
mutation: UPDATE_ONE_SCHEDULEDOPTIONORDER,
|
223
|
+
variables: filteredVariables,
|
224
|
+
// Don't cache mutations, but ensure we're using the freshest context
|
225
|
+
fetchPolicy: 'no-cache'
|
226
|
+
});
|
227
|
+
if (response.errors && response.errors.length > 0)
|
228
|
+
throw new Error(response.errors[0].message);
|
229
|
+
if (response && response.data && response.data.updateOneScheduledOptionOrder) {
|
230
|
+
return response.data.updateOneScheduledOptionOrder;
|
231
|
+
}
|
232
|
+
else {
|
233
|
+
return null;
|
234
|
+
}
|
235
|
+
}
|
236
|
+
catch (error) {
|
237
|
+
lastError = error;
|
238
|
+
// Check if this is a database connection error that we should retry
|
239
|
+
const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
|
240
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
|
241
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
|
242
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
243
|
+
(error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
|
244
|
+
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
245
|
+
retryCount++;
|
246
|
+
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
247
|
+
console.warn("Database connection error, retrying...");
|
248
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
249
|
+
continue;
|
250
|
+
}
|
251
|
+
// Log the error and rethrow
|
252
|
+
console.error("Database error occurred:", error);
|
253
|
+
throw error;
|
150
254
|
}
|
151
255
|
}
|
152
|
-
|
153
|
-
|
154
|
-
throw error;
|
155
|
-
}
|
256
|
+
// If we exhausted retries, throw the last error
|
257
|
+
throw lastError;
|
156
258
|
},
|
157
259
|
/**
|
158
260
|
* Upsert a single ScheduledOptionOrder record.
|
261
|
+
* Enhanced with connection resilience against Prisma connection errors.
|
159
262
|
* @param props - Properties to update.
|
160
263
|
* @param globalClient - Apollo Client instance.
|
161
264
|
* @returns The updated ScheduledOptionOrder or null.
|
162
265
|
*/
|
163
266
|
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;
|
267
|
+
var _a, _b, _c, _d, _e;
|
268
|
+
// Maximum number of retries for database connection issues
|
269
|
+
const MAX_RETRIES = 3;
|
270
|
+
let retryCount = 0;
|
271
|
+
let lastError = null;
|
272
|
+
// Retry loop to handle potential database connection issues
|
273
|
+
while (retryCount < MAX_RETRIES) {
|
274
|
+
try {
|
275
|
+
const [modules, client] = await Promise.all([
|
276
|
+
(0, client_1.getApolloModules)(),
|
277
|
+
globalClient
|
278
|
+
? Promise.resolve(globalClient)
|
279
|
+
: client_1.client
|
280
|
+
]);
|
281
|
+
const { gql, ApolloError } = modules;
|
282
|
+
const UPSERT_ONE_SCHEDULEDOPTIONORDER = gql `
|
283
|
+
mutation upsertOneScheduledOptionOrder($where: ScheduledOptionOrderWhereUniqueInput!, $create: ScheduledOptionOrderCreateInput!, $update: ScheduledOptionOrderUpdateInput!) {
|
284
|
+
upsertOneScheduledOptionOrder(where: $where, create: $create, update: $update) {
|
285
|
+
${selectionSet}
|
201
286
|
}
|
202
|
-
|
203
|
-
|
287
|
+
}`;
|
288
|
+
const variables = {
|
289
|
+
where: {
|
290
|
+
id: props.id !== undefined ? props.id : undefined,
|
291
|
+
status: props.status !== undefined ? {
|
292
|
+
equals: props.status
|
293
|
+
} : undefined,
|
294
|
+
},
|
295
|
+
create: {
|
296
|
+
payload: props.payload !== undefined ? props.payload : undefined,
|
297
|
+
status: props.status !== undefined ? props.status : undefined,
|
298
|
+
},
|
299
|
+
update: {
|
300
|
+
payload: props.payload !== undefined ? {
|
301
|
+
set: props.payload
|
302
|
+
} : undefined,
|
303
|
+
status: props.status !== undefined ? {
|
304
|
+
set: props.status
|
305
|
+
} : undefined,
|
306
|
+
},
|
307
|
+
};
|
308
|
+
const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
|
309
|
+
const response = await client.mutate({
|
310
|
+
mutation: UPSERT_ONE_SCHEDULEDOPTIONORDER,
|
311
|
+
variables: filteredVariables,
|
312
|
+
// Don't cache mutations, but ensure we're using the freshest context
|
313
|
+
fetchPolicy: 'no-cache'
|
314
|
+
});
|
315
|
+
if (response.errors && response.errors.length > 0)
|
316
|
+
throw new Error(response.errors[0].message);
|
317
|
+
if (response && response.data && response.data.upsertOneScheduledOptionOrder) {
|
318
|
+
return response.data.upsertOneScheduledOptionOrder;
|
319
|
+
}
|
320
|
+
else {
|
321
|
+
return null;
|
322
|
+
}
|
323
|
+
}
|
324
|
+
catch (error) {
|
325
|
+
lastError = error;
|
326
|
+
// Check if this is a database connection error that we should retry
|
327
|
+
const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
|
328
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
|
329
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
|
330
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
331
|
+
(error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
|
332
|
+
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
333
|
+
retryCount++;
|
334
|
+
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
335
|
+
console.warn("Database connection error, retrying...");
|
336
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
337
|
+
continue;
|
338
|
+
}
|
339
|
+
// Log the error and rethrow
|
340
|
+
console.error("Database error occurred:", error);
|
341
|
+
throw error;
|
204
342
|
}
|
205
343
|
}
|
206
|
-
|
207
|
-
|
208
|
-
throw error;
|
209
|
-
}
|
344
|
+
// If we exhausted retries, throw the last error
|
345
|
+
throw lastError;
|
210
346
|
},
|
211
347
|
/**
|
212
348
|
* Update multiple ScheduledOptionOrder records.
|
349
|
+
* Enhanced with connection resilience against Prisma connection errors.
|
213
350
|
* @param props - Array of ScheduledOptionOrder objects for the updated records.
|
214
351
|
* @param globalClient - Apollo Client instance.
|
215
352
|
* @returns The count of created records or null.
|
216
353
|
*/
|
217
354
|
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;
|
355
|
+
var _a, _b, _c, _d, _e;
|
356
|
+
// Maximum number of retries for database connection issues
|
357
|
+
const MAX_RETRIES = 3;
|
358
|
+
let retryCount = 0;
|
359
|
+
let lastError = null;
|
360
|
+
// Retry loop to handle potential database connection issues
|
361
|
+
while (retryCount < MAX_RETRIES) {
|
362
|
+
try {
|
363
|
+
const [modules, client] = await Promise.all([
|
364
|
+
(0, client_1.getApolloModules)(),
|
365
|
+
globalClient
|
366
|
+
? Promise.resolve(globalClient)
|
367
|
+
: client_1.client
|
368
|
+
]);
|
369
|
+
const { gql, ApolloError } = modules;
|
370
|
+
const UPDATE_MANY_SCHEDULEDOPTIONORDER = gql `
|
371
|
+
mutation updateManyScheduledOptionOrder($data: [ScheduledOptionOrderCreateManyInput!]!) {
|
372
|
+
updateManyScheduledOptionOrder(data: $data) {
|
373
|
+
count
|
254
374
|
}
|
255
|
-
|
256
|
-
|
375
|
+
}`;
|
376
|
+
const variables = props.map(prop => ({
|
377
|
+
where: {
|
378
|
+
id: prop.id !== undefined ? prop.id : undefined,
|
379
|
+
status: prop.status !== undefined ? {
|
380
|
+
equals: prop.status
|
381
|
+
} : undefined,
|
382
|
+
},
|
383
|
+
data: {
|
384
|
+
id: prop.id !== undefined ? {
|
385
|
+
set: prop.id
|
386
|
+
} : undefined,
|
387
|
+
payload: prop.payload !== undefined ? {
|
388
|
+
set: prop.payload
|
389
|
+
} : undefined,
|
390
|
+
status: prop.status !== undefined ? {
|
391
|
+
set: prop.status
|
392
|
+
} : undefined,
|
393
|
+
},
|
394
|
+
}));
|
395
|
+
const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
|
396
|
+
const response = await client.mutate({
|
397
|
+
mutation: UPDATE_MANY_SCHEDULEDOPTIONORDER,
|
398
|
+
variables: filteredVariables,
|
399
|
+
// Don't cache mutations, but ensure we're using the freshest context
|
400
|
+
fetchPolicy: 'no-cache'
|
401
|
+
});
|
402
|
+
if (response.errors && response.errors.length > 0)
|
403
|
+
throw new Error(response.errors[0].message);
|
404
|
+
if (response && response.data && response.data.updateManyScheduledOptionOrder) {
|
405
|
+
return response.data.updateManyScheduledOptionOrder;
|
406
|
+
}
|
407
|
+
else {
|
408
|
+
return null;
|
409
|
+
}
|
410
|
+
}
|
411
|
+
catch (error) {
|
412
|
+
lastError = error;
|
413
|
+
// Check if this is a database connection error that we should retry
|
414
|
+
const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
|
415
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
|
416
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
|
417
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
418
|
+
(error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
|
419
|
+
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
420
|
+
retryCount++;
|
421
|
+
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
422
|
+
console.warn("Database connection error, retrying...");
|
423
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
424
|
+
continue;
|
425
|
+
}
|
426
|
+
// Log the error and rethrow
|
427
|
+
console.error("Database error occurred:", error);
|
428
|
+
throw error;
|
257
429
|
}
|
258
430
|
}
|
259
|
-
|
260
|
-
|
261
|
-
throw error;
|
262
|
-
}
|
431
|
+
// If we exhausted retries, throw the last error
|
432
|
+
throw lastError;
|
263
433
|
},
|
264
434
|
/**
|
265
435
|
* Delete a single ScheduledOptionOrder record.
|
266
|
-
*
|
436
|
+
* Enhanced with connection resilience against Prisma connection errors.
|
437
|
+
* @param props - Properties to identify the record to delete.
|
267
438
|
* @param globalClient - Apollo Client instance.
|
268
439
|
* @returns The deleted ScheduledOptionOrder or null.
|
269
440
|
*/
|
270
441
|
async delete(props, globalClient) {
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
442
|
+
var _a, _b, _c, _d, _e;
|
443
|
+
// Maximum number of retries for database connection issues
|
444
|
+
const MAX_RETRIES = 3;
|
445
|
+
let retryCount = 0;
|
446
|
+
let lastError = null;
|
447
|
+
// Retry loop to handle potential database connection issues
|
448
|
+
while (retryCount < MAX_RETRIES) {
|
449
|
+
try {
|
450
|
+
const [modules, client] = await Promise.all([
|
451
|
+
(0, client_1.getApolloModules)(),
|
452
|
+
globalClient
|
453
|
+
? Promise.resolve(globalClient)
|
454
|
+
: client_1.client
|
455
|
+
]);
|
456
|
+
const { gql, ApolloError } = modules;
|
457
|
+
const DELETE_ONE_SCHEDULEDOPTIONORDER = gql `
|
458
|
+
mutation deleteOneScheduledOptionOrder($where: ScheduledOptionOrderWhereUniqueInput!) {
|
459
|
+
deleteOneScheduledOptionOrder(where: $where) {
|
460
|
+
id
|
287
461
|
}
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
462
|
+
}`;
|
463
|
+
const variables = {
|
464
|
+
where: {
|
465
|
+
id: props.id ? props.id : undefined,
|
466
|
+
}
|
467
|
+
};
|
468
|
+
const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
|
469
|
+
const response = await client.mutate({
|
470
|
+
mutation: DELETE_ONE_SCHEDULEDOPTIONORDER,
|
471
|
+
variables: filteredVariables,
|
472
|
+
// Don't cache mutations, but ensure we're using the freshest context
|
473
|
+
fetchPolicy: 'no-cache'
|
474
|
+
});
|
475
|
+
if (response.errors && response.errors.length > 0)
|
476
|
+
throw new Error(response.errors[0].message);
|
477
|
+
if (response && response.data && response.data.deleteOneScheduledOptionOrder) {
|
478
|
+
return response.data.deleteOneScheduledOptionOrder;
|
479
|
+
}
|
480
|
+
else {
|
481
|
+
return null;
|
482
|
+
}
|
296
483
|
}
|
297
|
-
|
298
|
-
|
484
|
+
catch (error) {
|
485
|
+
lastError = error;
|
486
|
+
// Check if this is a database connection error that we should retry
|
487
|
+
const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
|
488
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
|
489
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
|
490
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
491
|
+
(error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
|
492
|
+
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
493
|
+
retryCount++;
|
494
|
+
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
495
|
+
console.warn("Database connection error, retrying...");
|
496
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
497
|
+
continue;
|
498
|
+
}
|
499
|
+
// Log the error and rethrow
|
500
|
+
console.error("Database error occurred:", error);
|
501
|
+
throw error;
|
299
502
|
}
|
300
503
|
}
|
301
|
-
|
302
|
-
|
303
|
-
throw error;
|
304
|
-
}
|
504
|
+
// If we exhausted retries, throw the last error
|
505
|
+
throw lastError;
|
305
506
|
},
|
306
507
|
/**
|
307
508
|
* Retrieve a single ScheduledOptionOrder record by ID.
|
308
|
-
*
|
509
|
+
* Enhanced with connection resilience against Prisma connection errors.
|
510
|
+
* @param props - Properties to identify the record.
|
309
511
|
* @param globalClient - Apollo Client instance.
|
512
|
+
* @param whereInput - Optional custom where input.
|
310
513
|
* @returns The retrieved ScheduledOptionOrder or null.
|
311
514
|
*/
|
312
515
|
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
|
-
|
516
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
517
|
+
// Maximum number of retries for database connection issues
|
518
|
+
const MAX_RETRIES = 3;
|
519
|
+
let retryCount = 0;
|
520
|
+
let lastError = null;
|
521
|
+
// Retry loop to handle potential database connection issues
|
522
|
+
while (retryCount < MAX_RETRIES) {
|
523
|
+
try {
|
524
|
+
const [modules, client] = await Promise.all([
|
525
|
+
(0, client_1.getApolloModules)(),
|
526
|
+
globalClient
|
527
|
+
? Promise.resolve(globalClient)
|
528
|
+
: client_1.client
|
529
|
+
]);
|
530
|
+
const { gql, ApolloError } = modules;
|
531
|
+
const GET_SCHEDULEDOPTIONORDER = gql `
|
532
|
+
query getScheduledOptionOrder($where: ScheduledOptionOrderWhereUniqueInput!) {
|
533
|
+
getScheduledOptionOrder(where: $where) {
|
534
|
+
${selectionSet}
|
535
|
+
}
|
536
|
+
}`;
|
537
|
+
const variables = {
|
538
|
+
where: whereInput ? whereInput : {
|
539
|
+
id: props.id !== undefined ? props.id : undefined,
|
540
|
+
status: props.status !== undefined ? {
|
541
|
+
equals: props.status
|
542
|
+
} : undefined,
|
543
|
+
},
|
544
|
+
};
|
545
|
+
const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
|
546
|
+
const response = await client.query({
|
547
|
+
query: GET_SCHEDULEDOPTIONORDER,
|
548
|
+
variables: filteredVariables,
|
549
|
+
fetchPolicy: 'network-only', // Force network request to avoid stale cache
|
550
|
+
});
|
551
|
+
if (response.errors && response.errors.length > 0)
|
552
|
+
throw new Error(response.errors[0].message);
|
553
|
+
return (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.getScheduledOptionOrder) !== null && _b !== void 0 ? _b : null;
|
342
554
|
}
|
343
|
-
|
344
|
-
|
555
|
+
catch (error) {
|
556
|
+
lastError = error;
|
557
|
+
// Check if this is a "No record found" error - this is an expected condition, not a failure
|
558
|
+
if (error.message === 'No ScheduledOptionOrder found') {
|
559
|
+
return null;
|
560
|
+
}
|
561
|
+
// Check if this is a database connection error that we should retry
|
562
|
+
const isConnectionError = ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Server has closed the connection')) ||
|
563
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Cannot reach database server')) ||
|
564
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('Connection timed out')) ||
|
565
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
566
|
+
(error.networkError && ((_g = error.networkError.message) === null || _g === void 0 ? void 0 : _g.includes('Failed to fetch')));
|
567
|
+
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
568
|
+
retryCount++;
|
569
|
+
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
570
|
+
console.warn("Database connection error, retrying...");
|
571
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
572
|
+
continue;
|
573
|
+
}
|
574
|
+
// Log the error and rethrow
|
575
|
+
console.error("Database error occurred:", error);
|
345
576
|
throw error;
|
346
577
|
}
|
347
578
|
}
|
579
|
+
// If we exhausted retries, throw the last error
|
580
|
+
throw lastError;
|
348
581
|
},
|
349
582
|
/**
|
350
583
|
* Retrieve all ScheduledOptionOrders records.
|
584
|
+
* Enhanced with connection resilience against Prisma connection errors.
|
351
585
|
* @param globalClient - Apollo Client instance.
|
352
586
|
* @returns An array of ScheduledOptionOrder records or null.
|
353
587
|
*/
|
354
588
|
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;
|
589
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
590
|
+
// Maximum number of retries for database connection issues
|
591
|
+
const MAX_RETRIES = 3;
|
592
|
+
let retryCount = 0;
|
593
|
+
let lastError = null;
|
594
|
+
// Retry loop to handle potential database connection issues
|
595
|
+
while (retryCount < MAX_RETRIES) {
|
596
|
+
try {
|
597
|
+
const [modules, client] = await Promise.all([
|
598
|
+
(0, client_1.getApolloModules)(),
|
599
|
+
globalClient
|
600
|
+
? Promise.resolve(globalClient)
|
601
|
+
: client_1.client
|
602
|
+
]);
|
603
|
+
const { gql, ApolloError } = modules;
|
604
|
+
const GET_ALL_SCHEDULEDOPTIONORDER = gql `
|
605
|
+
query getAllScheduledOptionOrder {
|
606
|
+
scheduledOptionOrders {
|
607
|
+
${selectionSet}
|
378
608
|
}
|
379
|
-
|
380
|
-
|
609
|
+
}`;
|
610
|
+
const response = await client.query({
|
611
|
+
query: GET_ALL_SCHEDULEDOPTIONORDER,
|
612
|
+
fetchPolicy: 'network-only', // Force network request to avoid stale cache
|
613
|
+
});
|
614
|
+
if (response.errors && response.errors.length > 0)
|
615
|
+
throw new Error(response.errors[0].message);
|
616
|
+
return (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.scheduledOptionOrders) !== null && _b !== void 0 ? _b : null;
|
617
|
+
}
|
618
|
+
catch (error) {
|
619
|
+
lastError = error;
|
620
|
+
// Check if this is a "No record found" error - this is an expected condition, not a failure
|
621
|
+
if (error.message === 'No ScheduledOptionOrder found') {
|
622
|
+
return null;
|
623
|
+
}
|
624
|
+
// Check if this is a database connection error that we should retry
|
625
|
+
const isConnectionError = ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Server has closed the connection')) ||
|
626
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Cannot reach database server')) ||
|
627
|
+
((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('Connection timed out')) ||
|
628
|
+
((_f = error.message) === null || _f === void 0 ? void 0 : _f.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
629
|
+
(error.networkError && ((_g = error.networkError.message) === null || _g === void 0 ? void 0 : _g.includes('Failed to fetch')));
|
630
|
+
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
631
|
+
retryCount++;
|
632
|
+
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
633
|
+
console.warn("Database connection error, retrying...");
|
634
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
635
|
+
continue;
|
636
|
+
}
|
637
|
+
// Log the error and rethrow
|
638
|
+
console.error("Database error occurred:", error);
|
381
639
|
throw error;
|
382
640
|
}
|
383
641
|
}
|
642
|
+
// If we exhausted retries, throw the last error
|
643
|
+
throw lastError;
|
384
644
|
},
|
385
645
|
/**
|
386
646
|
* Find multiple ScheduledOptionOrder records based on conditions.
|
647
|
+
* Enhanced with connection resilience against Prisma connection errors.
|
387
648
|
* @param props - Conditions to find records.
|
388
649
|
* @param globalClient - Apollo Client instance.
|
650
|
+
* @param whereInput - Optional custom where input.
|
389
651
|
* @returns An array of found ScheduledOptionOrder records or null.
|
390
652
|
*/
|
391
653
|
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;
|
654
|
+
var _a, _b, _c, _d, _e;
|
655
|
+
// Maximum number of retries for database connection issues
|
656
|
+
const MAX_RETRIES = 3;
|
657
|
+
let retryCount = 0;
|
658
|
+
let lastError = null;
|
659
|
+
// Retry loop to handle potential database connection issues
|
660
|
+
while (retryCount < MAX_RETRIES) {
|
661
|
+
try {
|
662
|
+
const [modules, client] = await Promise.all([
|
663
|
+
(0, client_1.getApolloModules)(),
|
664
|
+
globalClient
|
665
|
+
? Promise.resolve(globalClient)
|
666
|
+
: client_1.client
|
667
|
+
]);
|
668
|
+
const { gql, ApolloError } = modules;
|
669
|
+
const FIND_MANY_SCHEDULEDOPTIONORDER = gql `
|
670
|
+
query findManyScheduledOptionOrder($where: ScheduledOptionOrderWhereInput!) {
|
671
|
+
scheduledOptionOrders(where: $where) {
|
672
|
+
${selectionSet}
|
419
673
|
}
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
674
|
+
}`;
|
675
|
+
const variables = {
|
676
|
+
where: whereInput ? whereInput : {
|
677
|
+
id: props.id !== undefined ? props.id : undefined,
|
678
|
+
status: props.status !== undefined ? {
|
679
|
+
equals: props.status
|
680
|
+
} : undefined,
|
681
|
+
},
|
682
|
+
};
|
683
|
+
const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
|
684
|
+
const response = await client.query({
|
685
|
+
query: FIND_MANY_SCHEDULEDOPTIONORDER,
|
686
|
+
variables: filteredVariables,
|
687
|
+
fetchPolicy: 'network-only', // Force network request to avoid stale cache
|
688
|
+
});
|
689
|
+
if (response.errors && response.errors.length > 0)
|
690
|
+
throw new Error(response.errors[0].message);
|
691
|
+
if (response && response.data && response.data.scheduledoptionorders) {
|
692
|
+
return response.data.scheduledOptionOrders;
|
693
|
+
}
|
694
|
+
else {
|
695
|
+
return [];
|
696
|
+
}
|
427
697
|
}
|
428
|
-
|
429
|
-
|
698
|
+
catch (error) {
|
699
|
+
lastError = error;
|
700
|
+
// Check if this is a "No record found" error - this is an expected condition, not a failure
|
701
|
+
if (error.message === 'No ScheduledOptionOrder found') {
|
702
|
+
return null;
|
703
|
+
}
|
704
|
+
// Check if this is a database connection error that we should retry
|
705
|
+
const isConnectionError = ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('Server has closed the connection')) ||
|
706
|
+
((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('Cannot reach database server')) ||
|
707
|
+
((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('Connection timed out')) ||
|
708
|
+
((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('Accelerate')) || // Prisma Accelerate proxy errors
|
709
|
+
(error.networkError && ((_e = error.networkError.message) === null || _e === void 0 ? void 0 : _e.includes('Failed to fetch')));
|
710
|
+
if (isConnectionError && retryCount < MAX_RETRIES - 1) {
|
711
|
+
retryCount++;
|
712
|
+
const delay = Math.pow(2, retryCount) * 100; // Exponential backoff: 200ms, 400ms, 800ms
|
713
|
+
console.warn("Database connection error, retrying...");
|
714
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
715
|
+
continue;
|
716
|
+
}
|
717
|
+
// Log the error and rethrow
|
718
|
+
console.error("Database error occurred:", error);
|
430
719
|
throw error;
|
431
720
|
}
|
432
721
|
}
|
722
|
+
// If we exhausted retries, throw the last error
|
723
|
+
throw lastError;
|
433
724
|
}
|
434
725
|
};
|
435
726
|
//# sourceMappingURL=ScheduledOptionOrder.js.map
|