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