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