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.
Files changed (110) hide show
  1. package/Account.cjs +2543 -2265
  2. package/Account.d.ts +19 -2
  3. package/Action.cjs +1116 -838
  4. package/Action.d.ts +19 -2
  5. package/Alert.cjs +2626 -2348
  6. package/Alert.d.ts +19 -2
  7. package/Allocation.cjs +2578 -2300
  8. package/Allocation.d.ts +19 -2
  9. package/AlpacaAccount.cjs +2383 -2105
  10. package/AlpacaAccount.d.ts +19 -2
  11. package/Asset.cjs +1813 -1535
  12. package/Asset.d.ts +19 -2
  13. package/Authenticator.cjs +2568 -2290
  14. package/Authenticator.d.ts +19 -2
  15. package/Customer.cjs +2495 -2217
  16. package/Customer.d.ts +19 -2
  17. package/EconomicEvent.cjs +645 -367
  18. package/EconomicEvent.d.ts +19 -2
  19. package/MarketSentiment.cjs +618 -340
  20. package/MarketSentiment.d.ts +19 -2
  21. package/NewsArticle.cjs +1933 -1655
  22. package/NewsArticle.d.ts +19 -2
  23. package/NewsArticleAssetSentiment.cjs +1842 -1564
  24. package/NewsArticleAssetSentiment.d.ts +19 -2
  25. package/ScheduledOptionOrder.cjs +594 -316
  26. package/ScheduledOptionOrder.d.ts +19 -2
  27. package/Session.cjs +2570 -2292
  28. package/Session.d.ts +19 -2
  29. package/Trade.cjs +1073 -795
  30. package/Trade.d.ts +19 -2
  31. package/User.cjs +2288 -2010
  32. package/User.d.ts +19 -2
  33. package/VerificationToken.cjs +606 -328
  34. package/VerificationToken.d.ts +19 -2
  35. package/esm/Account.d.ts +19 -2
  36. package/esm/Account.d.ts.map +1 -1
  37. package/esm/Account.js.map +1 -1
  38. package/esm/Account.mjs +2534 -2263
  39. package/esm/Action.d.ts +19 -2
  40. package/esm/Action.d.ts.map +1 -1
  41. package/esm/Action.js.map +1 -1
  42. package/esm/Action.mjs +1107 -836
  43. package/esm/Alert.d.ts +19 -2
  44. package/esm/Alert.d.ts.map +1 -1
  45. package/esm/Alert.js.map +1 -1
  46. package/esm/Alert.mjs +2617 -2346
  47. package/esm/Allocation.d.ts +19 -2
  48. package/esm/Allocation.d.ts.map +1 -1
  49. package/esm/Allocation.js.map +1 -1
  50. package/esm/Allocation.mjs +2569 -2298
  51. package/esm/AlpacaAccount.d.ts +19 -2
  52. package/esm/AlpacaAccount.d.ts.map +1 -1
  53. package/esm/AlpacaAccount.js.map +1 -1
  54. package/esm/AlpacaAccount.mjs +2374 -2103
  55. package/esm/Asset.d.ts +19 -2
  56. package/esm/Asset.d.ts.map +1 -1
  57. package/esm/Asset.js.map +1 -1
  58. package/esm/Asset.mjs +1804 -1533
  59. package/esm/Authenticator.d.ts +19 -2
  60. package/esm/Authenticator.d.ts.map +1 -1
  61. package/esm/Authenticator.js.map +1 -1
  62. package/esm/Authenticator.mjs +2559 -2288
  63. package/esm/Customer.d.ts +19 -2
  64. package/esm/Customer.d.ts.map +1 -1
  65. package/esm/Customer.js.map +1 -1
  66. package/esm/Customer.mjs +2486 -2215
  67. package/esm/EconomicEvent.d.ts +19 -2
  68. package/esm/EconomicEvent.d.ts.map +1 -1
  69. package/esm/EconomicEvent.js.map +1 -1
  70. package/esm/EconomicEvent.mjs +636 -365
  71. package/esm/MarketSentiment.d.ts +19 -2
  72. package/esm/MarketSentiment.d.ts.map +1 -1
  73. package/esm/MarketSentiment.js.map +1 -1
  74. package/esm/MarketSentiment.mjs +609 -338
  75. package/esm/NewsArticle.d.ts +19 -2
  76. package/esm/NewsArticle.d.ts.map +1 -1
  77. package/esm/NewsArticle.js.map +1 -1
  78. package/esm/NewsArticle.mjs +1924 -1653
  79. package/esm/NewsArticleAssetSentiment.d.ts +19 -2
  80. package/esm/NewsArticleAssetSentiment.d.ts.map +1 -1
  81. package/esm/NewsArticleAssetSentiment.js.map +1 -1
  82. package/esm/NewsArticleAssetSentiment.mjs +1833 -1562
  83. package/esm/ScheduledOptionOrder.d.ts +19 -2
  84. package/esm/ScheduledOptionOrder.d.ts.map +1 -1
  85. package/esm/ScheduledOptionOrder.js.map +1 -1
  86. package/esm/ScheduledOptionOrder.mjs +585 -314
  87. package/esm/Session.d.ts +19 -2
  88. package/esm/Session.d.ts.map +1 -1
  89. package/esm/Session.js.map +1 -1
  90. package/esm/Session.mjs +2561 -2290
  91. package/esm/Trade.d.ts +19 -2
  92. package/esm/Trade.d.ts.map +1 -1
  93. package/esm/Trade.js.map +1 -1
  94. package/esm/Trade.mjs +1064 -793
  95. package/esm/User.d.ts +19 -2
  96. package/esm/User.d.ts.map +1 -1
  97. package/esm/User.js.map +1 -1
  98. package/esm/User.mjs +2279 -2008
  99. package/esm/VerificationToken.d.ts +19 -2
  100. package/esm/VerificationToken.d.ts.map +1 -1
  101. package/esm/VerificationToken.js.map +1 -1
  102. package/esm/VerificationToken.mjs +597 -326
  103. package/esm/prismaClient.d.ts +4 -5
  104. package/esm/prismaClient.d.ts.map +1 -1
  105. package/esm/prismaClient.js.map +1 -1
  106. package/esm/prismaClient.mjs +13 -11
  107. package/package.json +1 -1
  108. package/prismaClient.cjs +13 -11
  109. package/prismaClient.d.ts +4 -5
  110. package/server.cjs +37 -5
@@ -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
- const [modules, client] = await Promise.all([
25
- (0, client_1.getApolloModules)(),
26
- globalClient
27
- ? Promise.resolve(globalClient)
28
- : client_1.client
29
- ]);
30
- const { gql, ApolloError } = modules;
31
- const CREATE_ONE_SCHEDULEDOPTIONORDER = gql `
32
- mutation createOneScheduledOptionOrder($data: ScheduledOptionOrderCreateInput!) {
33
- createOneScheduledOptionOrder(data: $data) {
34
- ${selectionSet}
35
- }
36
- }
37
- `;
38
- const variables = {
39
- data: {
40
- payload: props.payload !== undefined ? props.payload : undefined,
41
- status: props.status !== undefined ? props.status : undefined,
42
- },
43
- };
44
- const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
45
- try {
46
- const response = await client.mutate({ mutation: CREATE_ONE_SCHEDULEDOPTIONORDER, variables: filteredVariables });
47
- if (response.errors && response.errors.length > 0)
48
- throw new Error(response.errors[0].message);
49
- if (response && response.data && response.data.createOneScheduledOptionOrder) {
50
- return response.data.createOneScheduledOptionOrder;
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
- else {
53
- return null;
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
- catch (error) {
57
- console.error('Error in createOneScheduledOptionOrder:', error);
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
- const [modules, client] = await Promise.all([
69
- (0, client_1.getApolloModules)(),
70
- globalClient
71
- ? Promise.resolve(globalClient)
72
- : client_1.client
73
- ]);
74
- const { gql, ApolloError } = modules;
75
- const CREATE_MANY_SCHEDULEDOPTIONORDER = gql `
76
- mutation createManyScheduledOptionOrder($data: [ScheduledOptionOrderCreateManyInput!]!) {
77
- createManyScheduledOptionOrder(data: $data) {
78
- count
79
- }
80
- }`;
81
- const variables = {
82
- data: props.map(prop => ({
83
- payload: prop.payload !== undefined ? prop.payload : undefined,
84
- status: prop.status !== undefined ? prop.status : undefined,
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
- else {
96
- return null;
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
- catch (error) {
100
- console.error('Error in createManyScheduledOptionOrder:', error);
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
- const [modules, client] = await Promise.all([
112
- (0, client_1.getApolloModules)(),
113
- globalClient
114
- ? Promise.resolve(globalClient)
115
- : client_1.client
116
- ]);
117
- const { gql, ApolloError } = modules;
118
- const UPDATE_ONE_SCHEDULEDOPTIONORDER = gql `
119
- mutation updateOneScheduledOptionOrder($data: ScheduledOptionOrderUpdateInput!, $where: ScheduledOptionOrderWhereUniqueInput!) {
120
- updateOneScheduledOptionOrder(data: $data, where: $where) {
121
- ${selectionSet}
122
- }
123
- }`;
124
- const variables = {
125
- where: {
126
- id: props.id !== undefined ? props.id : undefined,
127
- },
128
- data: {
129
- id: props.id !== undefined ? {
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
- else {
149
- return null;
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
- catch (error) {
153
- console.error('Error in updateOneScheduledOptionOrder:', error);
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
- const [modules, client] = await Promise.all([
165
- (0, client_1.getApolloModules)(),
166
- globalClient
167
- ? Promise.resolve(globalClient)
168
- : client_1.client
169
- ]);
170
- const { gql, ApolloError } = modules;
171
- const UPSERT_ONE_SCHEDULEDOPTIONORDER = gql `
172
- mutation upsertOneScheduledOptionOrder($where: ScheduledOptionOrderWhereUniqueInput!, $create: ScheduledOptionOrderCreateInput!, $update: ScheduledOptionOrderUpdateInput!) {
173
- upsertOneScheduledOptionOrder(where: $where, create: $create, update: $update) {
174
- ${selectionSet}
175
- }
176
- }`;
177
- const variables = {
178
- where: {
179
- id: props.id !== undefined ? props.id : undefined,
180
- },
181
- create: {
182
- payload: props.payload !== undefined ? props.payload : undefined,
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
- else {
203
- return null;
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
- catch (error) {
207
- console.error('Error in upsertOneScheduledOptionOrder:', error);
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
- const [modules, client] = await Promise.all([
219
- (0, client_1.getApolloModules)(),
220
- globalClient
221
- ? Promise.resolve(globalClient)
222
- : client_1.client
223
- ]);
224
- const { gql, ApolloError } = modules;
225
- const UPDATE_MANY_SCHEDULEDOPTIONORDER = gql `
226
- mutation updateManyScheduledOptionOrder($data: [ScheduledOptionOrderCreateManyInput!]!) {
227
- updateManyScheduledOptionOrder(data: $data) {
228
- count
229
- }
230
- }`;
231
- const variables = props.map(prop => ({
232
- where: {
233
- id: prop.id !== undefined ? prop.id : undefined,
234
- },
235
- data: {
236
- id: prop.id !== undefined ? {
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
- else {
256
- return null;
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
- catch (error) {
260
- console.error('Error in updateManyScheduledOptionOrder:', error);
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
- * @param props - Properties to update.
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
- const [modules, client] = await Promise.all([
272
- (0, client_1.getApolloModules)(),
273
- globalClient
274
- ? Promise.resolve(globalClient)
275
- : client_1.client
276
- ]);
277
- const { gql, ApolloError } = modules;
278
- const DELETE_ONE_SCHEDULEDOPTIONORDER = gql `
279
- mutation deleteOneScheduledOptionOrder($where: ScheduledOptionOrderWhereUniqueInput!) {
280
- deleteOneScheduledOptionOrder(where: $where) {
281
- id
282
- }
283
- }`;
284
- const variables = {
285
- where: {
286
- id: props.id ? props.id : undefined,
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
- const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
290
- try {
291
- const response = await client.mutate({ mutation: DELETE_ONE_SCHEDULEDOPTIONORDER, variables: filteredVariables });
292
- if (response.errors && response.errors.length > 0)
293
- throw new Error(response.errors[0].message);
294
- if (response && response.data && response.data.deleteOneScheduledOptionOrder) {
295
- return response.data.deleteOneScheduledOptionOrder;
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
- else {
298
- return null;
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
- catch (error) {
302
- console.error('Error in deleteOneScheduledOptionOrder:', error);
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
- * @param props - Properties to update.
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
- const [modules, client] = await Promise.all([
315
- (0, client_1.getApolloModules)(),
316
- globalClient
317
- ? Promise.resolve(globalClient)
318
- : client_1.client
319
- ]);
320
- const { gql, ApolloError } = modules;
321
- const GET_SCHEDULEDOPTIONORDER = gql `
322
- query getScheduledOptionOrder($where: ScheduledOptionOrderWhereUniqueInput!) {
323
- getScheduledOptionOrder(where: $where) {
324
- ${selectionSet}
325
- }
326
- }`;
327
- const variables = {
328
- where: whereInput ? whereInput : {
329
- id: props.id !== undefined ? props.id : undefined,
330
- },
331
- };
332
- const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
333
- try {
334
- const response = await client.query({ query: GET_SCHEDULEDOPTIONORDER, variables: filteredVariables });
335
- if (response.errors && response.errors.length > 0)
336
- throw new Error(response.errors[0].message);
337
- return (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.getScheduledOptionOrder) !== null && _b !== void 0 ? _b : null;
338
- }
339
- catch (error) {
340
- if (error instanceof ApolloError && error.message === 'No ScheduledOptionOrder found') {
341
- return null;
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
- else {
344
- console.error('Error in getScheduledOptionOrder:', error);
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
- const [modules, client] = await Promise.all([
357
- (0, client_1.getApolloModules)(),
358
- globalClient
359
- ? Promise.resolve(globalClient)
360
- : client_1.client
361
- ]);
362
- const { gql, ApolloError } = modules;
363
- const GET_ALL_SCHEDULEDOPTIONORDER = gql `
364
- query getAllScheduledOptionOrder {
365
- scheduledOptionOrders {
366
- ${selectionSet}
367
- }
368
- }`;
369
- try {
370
- const response = await client.query({ query: GET_ALL_SCHEDULEDOPTIONORDER });
371
- if (response.errors && response.errors.length > 0)
372
- throw new Error(response.errors[0].message);
373
- return (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.scheduledOptionOrders) !== null && _b !== void 0 ? _b : null;
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
- else {
380
- console.error('Error in getScheduledOptionOrder:', error);
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
- const [modules, client] = await Promise.all([
393
- (0, client_1.getApolloModules)(),
394
- globalClient
395
- ? Promise.resolve(globalClient)
396
- : client_1.client
397
- ]);
398
- const { gql, ApolloError } = modules;
399
- const FIND_MANY_SCHEDULEDOPTIONORDER = gql `
400
- query findManyScheduledOptionOrder($where: ScheduledOptionOrderWhereInput!) {
401
- scheduledOptionOrders(where: $where) {
402
- ${selectionSet}
403
- }
404
- }`;
405
- const variables = {
406
- where: whereInput ? whereInput : {
407
- id: props.id !== undefined ? {
408
- equals: props.id
409
- } : undefined,
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
- else {
421
- return [];
422
- }
423
- }
424
- catch (error) {
425
- if (error instanceof ApolloError && error.message === 'No ScheduledOptionOrder found') {
426
- return null;
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
- else {
429
- console.error('Error in getScheduledOptionOrder:', error);
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