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.
Files changed (122) hide show
  1. package/Account.cjs +2670 -2264
  2. package/Account.d.ts +19 -2
  3. package/Action.cjs +1195 -839
  4. package/Action.d.ts +19 -2
  5. package/Alert.cjs +2651 -2347
  6. package/Alert.d.ts +19 -2
  7. package/Allocation.cjs +2631 -2304
  8. package/Allocation.d.ts +19 -2
  9. package/AlpacaAccount.cjs +2654 -2104
  10. package/AlpacaAccount.d.ts +19 -2
  11. package/Asset.cjs +2611 -1544
  12. package/Asset.d.ts +19 -2
  13. package/Authenticator.cjs +2603 -2290
  14. package/Authenticator.d.ts +19 -2
  15. package/Customer.cjs +2506 -2220
  16. package/Customer.d.ts +19 -2
  17. package/EconomicEvent.cjs +708 -367
  18. package/EconomicEvent.d.ts +19 -2
  19. package/MarketSentiment.cjs +691 -340
  20. package/MarketSentiment.d.ts +19 -2
  21. package/NewsArticle.cjs +2114 -1655
  22. package/NewsArticle.d.ts +19 -2
  23. package/NewsArticleAssetSentiment.cjs +1873 -1564
  24. package/NewsArticleAssetSentiment.d.ts +19 -2
  25. package/ScheduledOptionOrder.cjs +607 -316
  26. package/ScheduledOptionOrder.d.ts +19 -2
  27. package/Session.cjs +2592 -2294
  28. package/Session.d.ts +19 -2
  29. package/Trade.cjs +1261 -795
  30. package/Trade.d.ts +19 -2
  31. package/User.cjs +2432 -2013
  32. package/User.d.ts +19 -2
  33. package/VerificationToken.cjs +637 -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 +2661 -2262
  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 +1186 -837
  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 +2642 -2345
  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 +2622 -2302
  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 +2645 -2102
  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 +2602 -1542
  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 +2594 -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 +2497 -2218
  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 +699 -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 +682 -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 +2105 -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 +1864 -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 +598 -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 +2583 -2292
  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 +1252 -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 +2423 -2011
  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 +628 -326
  103. package/esm/generated/typegraphql-prisma/enhance.js.map +1 -1
  104. package/esm/generated/typegraphql-prisma/enhance.mjs +1 -1
  105. package/esm/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.d.ts +1 -1
  106. package/esm/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.d.ts.map +1 -1
  107. package/esm/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.js.map +1 -1
  108. package/esm/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.mjs +7 -7
  109. package/esm/prismaClient.d.ts +4 -5
  110. package/esm/prismaClient.d.ts.map +1 -1
  111. package/esm/prismaClient.js.map +1 -1
  112. package/esm/prismaClient.mjs +13 -11
  113. package/generated/typegraphql-prisma/enhance.cjs +1 -1
  114. package/generated/typegraphql-prisma/enhance.js.map +1 -1
  115. package/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.cjs +6 -6
  116. package/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.d.ts +1 -1
  117. package/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.d.ts.map +1 -1
  118. package/generated/typegraphql-prisma/resolvers/inputs/AccountWhereUniqueInput.js.map +1 -1
  119. package/package.json +1 -1
  120. package/prismaClient.cjs +13 -11
  121. package/prismaClient.d.ts +4 -5
  122. package/server.cjs +37 -5
@@ -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
- 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
+ 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
- catch (error) {
153
- console.error('Error in updateOneScheduledOptionOrder:', error);
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
- 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;
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
- else {
203
- return null;
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
- catch (error) {
207
- console.error('Error in upsertOneScheduledOptionOrder:', error);
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
- 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;
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
- else {
256
- return null;
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
- catch (error) {
260
- console.error('Error in updateManyScheduledOptionOrder:', error);
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
- * @param props - Properties to update.
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
- 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,
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
- 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;
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
- else {
298
- return null;
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
- catch (error) {
302
- console.error('Error in deleteOneScheduledOptionOrder:', error);
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
- * @param props - Properties to update.
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
- 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;
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
- else {
344
- console.error('Error in getScheduledOptionOrder:', error);
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
- 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;
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
- else {
380
- console.error('Error in getScheduledOptionOrder:', error);
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
- 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;
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
- else {
421
- return [];
422
- }
423
- }
424
- catch (error) {
425
- if (error instanceof ApolloError && error.message === 'No ScheduledOptionOrder found') {
426
- return null;
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
- else {
429
- console.error('Error in getScheduledOptionOrder:', error);
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