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