Skip to content

Commit c5c308c

Browse files
committed
✨ Remove type errors
1 parent 692b938 commit c5c308c

File tree

107 files changed

+232
-2268
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+232
-2268
lines changed

Diff for: packages/api/scripts/oauthConnector.js

+2-24
Original file line numberDiff line numberDiff line change
@@ -167,18 +167,7 @@ private cService: ConnectionsStrategiesService,
167167
}
168168
return db_res;
169169
} catch (error) {
170-
throwTypedError(
171-
new ConnectionsError({
172-
name: 'HANDLE_OAUTH_CALLBACK_${verticalUpper}',
173-
message: \`${providerUpper}ConnectionService.handleCallback() call failed ---> \${format3rdPartyError(
174-
'${provider}',
175-
Action.oauthCallback,
176-
ActionType.POST,
177-
)}\`,
178-
cause: error,
179-
}),
180-
this.logger,
181-
);
170+
throw error;
182171
}
183172
}
184173
@@ -220,18 +209,7 @@ private cService: ConnectionsStrategiesService,
220209
});
221210
this.logger.log('OAuth credentials updated : ${provider} ');
222211
} catch (error) {
223-
throwTypedError(
224-
new ConnectionsError({
225-
name: 'HANDLE_OAUTH_REFRESH_${verticalUpper}',
226-
message: \`${providerUpper}ConnectionService.handleTokenRefresh() call failed ---> \${format3rdPartyError(
227-
'${provider}',
228-
Action.oauthCallback,
229-
ActionType.POST,
230-
)}\`,
231-
cause: error,
232-
}),
233-
this.logger,
234-
);
212+
throw error;
235213
}
236214
}
237215
}

Diff for: packages/api/src/@core/auth/auth.service.ts

+12-96
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,7 @@ export class AuthService {
2626
try {
2727
return await this.prisma.users.findMany();
2828
} catch (error) {
29-
throwTypedError(
30-
new AuthError({
31-
name: 'GET_USERS_ERROR',
32-
message: 'AuthService.getUsers() call failed',
33-
cause: error,
34-
}),
35-
this.logger,
36-
);
29+
throw error;
3730
}
3831
}
3932

@@ -51,14 +44,7 @@ export class AuthService {
5144

5245
return verifyUser;
5346
} catch (error) {
54-
throwTypedError(
55-
new AuthError({
56-
name: 'VERIFY_USER_ERROR',
57-
message: 'AuthService.verifyUser() call failed',
58-
cause: error,
59-
}),
60-
this.logger,
61-
);
47+
throw error;
6248
}
6349
}
6450

@@ -70,14 +56,7 @@ export class AuthService {
7056
},
7157
});
7258
} catch (error) {
73-
throwTypedError(
74-
new AuthError({
75-
name: 'GET_API_KEYS_ERROR',
76-
message: 'AuthService.getApiKeys() call failed',
77-
cause: error,
78-
}),
79-
this.logger,
80-
);
59+
throw error;
8160
}
8261
}
8362

@@ -96,14 +75,7 @@ export class AuthService {
9675

9776
return await this.createUser(user);
9877
} catch (error) {
99-
throwTypedError(
100-
new AuthError({
101-
name: 'REGISTER_USER_ERROR',
102-
message: 'AuthService.register() call failed',
103-
cause: error,
104-
}),
105-
this.logger,
106-
);
78+
throw error;
10779
}
10880
}
10981

@@ -128,14 +100,7 @@ export class AuthService {
128100
});
129101
return user_;
130102
} catch (error) {
131-
throwTypedError(
132-
new AuthError({
133-
name: 'CREATE_USER_ERROR',
134-
message: 'AuthService.createUser() call failed',
135-
cause: error,
136-
}),
137-
this.logger,
138-
);
103+
throw error;
139104
}
140105
}
141106

@@ -193,14 +158,7 @@ export class AuthService {
193158
}), // token used to generate api keys
194159
};
195160
} catch (error) {
196-
throwTypedError(
197-
new AuthError({
198-
name: 'LOGIN_USER_ERROR',
199-
message: 'AuthService.login() call failed',
200-
cause: error,
201-
}),
202-
this.logger,
203-
);
161+
throw error;
204162
}
205163
}
206164

@@ -225,29 +183,15 @@ export class AuthService {
225183
}),
226184
};
227185
} catch (error) {
228-
throwTypedError(
229-
new AuthError({
230-
name: 'REFRESH_ACCESS_TOKEN_ERROR',
231-
message: 'AuthService.refreshAccessToken() call failed',
232-
cause: error,
233-
}),
234-
this.logger,
235-
);
186+
throw error;
236187
}
237188
}
238189

239190
hashApiKey(apiKey: string): string {
240191
try {
241192
return crypto.createHash('sha256').update(apiKey).digest('hex');
242193
} catch (error) {
243-
throwTypedError(
244-
new AuthError({
245-
name: 'HASH_API_KEY_ERROR',
246-
message: 'AuthService.hashApiKey() call failed',
247-
cause: error,
248-
}),
249-
this.logger,
250-
);
194+
throw error;
251195
}
252196
}
253197

@@ -268,14 +212,7 @@ export class AuthService {
268212
}),
269213
};
270214
} catch (error) {
271-
throwTypedError(
272-
new AuthError({
273-
name: 'GENERATE_API_KEY_ERROR',
274-
message: 'AuthService.generateApiKey() call failed',
275-
cause: error,
276-
}),
277-
this.logger,
278-
);
215+
throw error;
279216
}
280217
}
281218

@@ -320,14 +257,7 @@ export class AuthService {
320257

321258
return { api_key: access_token, ...new_api_key };
322259
} catch (error) {
323-
throwTypedError(
324-
new AuthError({
325-
name: 'GENERATE_API_KEY_ERROR',
326-
message: 'AuthService.generateApiKeyForUser() call failed',
327-
cause: error,
328-
}),
329-
this.logger,
330-
);
260+
throw error;
331261
}
332262
}
333263

@@ -339,14 +269,7 @@ export class AuthService {
339269
},
340270
});
341271
} catch (error) {
342-
throwTypedError(
343-
new AuthError({
344-
name: 'DELETE_API_KEY_ERROR',
345-
message: 'AuthService.deleteApiKey() call failed',
346-
cause: error,
347-
}),
348-
this.logger,
349-
);
272+
throw error;
350273
}
351274
}
352275

@@ -381,14 +304,7 @@ export class AuthService {
381304
}
382305
return true;
383306
} catch (error) {
384-
throwTypedError(
385-
new AuthError({
386-
name: 'VALIDATE_API_KEY_ERROR',
387-
message: 'AuthService.validateApiKey() call failed',
388-
cause: error,
389-
}),
390-
this.logger,
391-
);
307+
throw error;
392308
}
393309
}
394310
}

Diff for: packages/api/src/@core/connections-strategies/connections-strategies.service.ts

+6-53
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,7 @@ export class ConnectionsStrategiesService {
5050
if (!res) return false;
5151
return res.status;
5252
} catch (error) {
53-
throwTypedError(
54-
new ConnectionStrategiesError({
55-
name: 'CUSTOM_CREDENTIALS_ERROR',
56-
message:
57-
'ConnectionsStrategiesService.isCustomCredentials() call failed',
58-
cause: error,
59-
}),
60-
this.logger,
61-
);
53+
throw error;
6254
}
6355
}
6456

@@ -119,15 +111,7 @@ export class ConnectionsStrategiesService {
119111

120112
return cs;
121113
} catch (error) {
122-
throwTypedError(
123-
new ConnectionStrategiesError({
124-
name: 'CREATE_CONNECTION_STRATEGY_ERROR',
125-
message:
126-
'ConnectionsStrategiesService.createConnectionStrategy() call failed',
127-
cause: error,
128-
}),
129-
this.logger,
130-
);
114+
throw error;
131115
}
132116
}
133117

@@ -151,14 +135,7 @@ export class ConnectionsStrategiesService {
151135

152136
return updatedCs;
153137
} catch (error) {
154-
throwTypedError(
155-
new ConnectionStrategiesError({
156-
name: 'TOGGLE_CONNECTION_STRATEGY_ERROR',
157-
message: 'ConnectionsStrategiesService.toggle() call failed',
158-
cause: error,
159-
}),
160-
this.logger,
161-
);
138+
throw error;
162139
}
163140
}
164141

@@ -380,15 +357,7 @@ export class ConnectionsStrategiesService {
380357
},
381358
});
382359
} catch (error) {
383-
throwTypedError(
384-
new ConnectionStrategiesError({
385-
name: 'GET_CONNECTION_STRATEGIES_BY_PROJECT_ERROR',
386-
message:
387-
'ConnectionsStrategiesService.getConnectionStrategiesForProject() call failed',
388-
cause: error,
389-
}),
390-
this.logger,
391-
);
360+
throw error;
392361
}
393362
}
394363

@@ -447,15 +416,7 @@ export class ConnectionsStrategiesService {
447416
}
448417
return cs;
449418
} catch (error) {
450-
throwTypedError(
451-
new ConnectionStrategiesError({
452-
name: 'UPDATE_CONNECTION_STRATEGY_ERROR',
453-
message:
454-
'ConnectionsStrategiesService.updateConnectionStrategy() call failed',
455-
cause: error,
456-
}),
457-
this.logger,
458-
);
419+
throw error;
459420
}
460421
}
461422

@@ -515,15 +476,7 @@ export class ConnectionsStrategiesService {
515476

516477
return deleteCS;
517478
} catch (error) {
518-
throwTypedError(
519-
new ConnectionStrategiesError({
520-
name: 'DELETE_CONNECTION_STRATEGY_ERROR',
521-
message:
522-
'ConnectionsStrategiesService.deleteConnectionStrategy() call failed',
523-
cause: error,
524-
}),
525-
this.logger,
526-
);
479+
throw error;
527480
}
528481
}
529482
}

Diff for: packages/api/src/@core/connections/@utils/index.ts

+1-8
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,7 @@ export class ConnectionUtils {
2828
remoteSource: res.provider_slug,
2929
};
3030
} catch (error) {
31-
throwTypedError(
32-
new ConnectionsError({
33-
name: 'GET_CONNECTION_FROM_CONNECTION_TOKEN_ERROR',
34-
message:
35-
'ConnectionUtils.getConnectionMetadataFromConnectionToken() call failed',
36-
cause: error,
37-
}),
38-
);
31+
throw error;
3932
}
4033
}
4134

Diff for: packages/api/src/@core/connections/accounting/services/accounting.connection.service.ts

+1-9
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,7 @@ export class AccountingConnectionsService {
9292
};
9393
const data = await service.handleTokenRefresh(refreshOpts);
9494
} catch (error) {
95-
throwTypedError(
96-
new ConnectionsError({
97-
name: 'HANDLE_OAUTH_REFRESH_ACCOUNTING',
98-
message:
99-
'AccountingConnectionsService.handleAccountingTokensRefresh() call failed',
100-
cause: error,
101-
}),
102-
this.logger,
103-
);
95+
throw error;
10496
}
10597
}
10698
}

0 commit comments

Comments
 (0)