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