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