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