Skip to content

Commit bede211

Browse files
committed
Fix linter
1 parent f01f311 commit bede211

25 files changed

+300
-136
lines changed

.vscode/settings.json

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
{
2-
"editor.codeActionsOnSave": {
3-
"source.organizeImports.biome": "explicit"
4-
},
2+
"editor.defaultFormatter": "biomejs.biome",
53
"[javascript]": {
64
"editor.defaultFormatter": "biomejs.biome"
75
},
6+
"[typescript]": {
7+
"editor.defaultFormatter": "biomejs.biome"
8+
},
9+
"[typescriptreact]": {
10+
"editor.defaultFormatter": "biomejs.biome"
11+
},
12+
"editor.codeActionsOnSave": {
13+
"quickfix.biome": "explicit",
14+
"source.organizeImports.biome": "explicit"
15+
},
816
"editor.formatOnSave": true,
917
"typescript.enablePromptUseWorkspaceTsdk": true,
1018
"typescript.tsdk": "node_modules/typescript/lib",
@@ -15,5 +23,5 @@
1523
"terminal.integrated.localEchoStyle": "dim",
1624
"search.exclude": {
1725
"**/node_modules": true
18-
}
26+
}
1927
}

apps/engine/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const apiRoutes = app.use(
3030
cache({
3131
cacheName: "engine",
3232
cacheControl: "max-age=3600",
33-
})
33+
}),
3434
);
3535

3636
apiRoutes
@@ -48,7 +48,7 @@ apiRoutes.get(
4848
"/",
4949
swaggerUI({
5050
url: "/openapi",
51-
})
51+
}),
5252
);
5353

5454
app.doc("/openapi", {

apps/engine/src/providers/gocardless/gocardless-api.ts

+19-19
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export class GoCardLessApi {
6464
undefined,
6565
{
6666
refresh,
67-
}
67+
},
6868
);
6969

7070
await this.#kv.put(this.#accessTokenCacheKey, response.access, {
@@ -94,7 +94,7 @@ export class GoCardLessApi {
9494
{
9595
secret_id: this.#secretId,
9696
secret_key: this.#secretKey,
97-
}
97+
},
9898
);
9999

100100
await Promise.all([
@@ -110,26 +110,26 @@ export class GoCardLessApi {
110110
}
111111

112112
async getAccountBalance(
113-
accountId: string
113+
accountId: string,
114114
): Promise<
115115
GetAccountBalanceResponse["balances"][0]["balanceAmount"] | undefined
116116
> {
117117
const token = await this.#getAccessToken();
118118

119119
const { balances } = await this.#get<GetAccountBalanceResponse>(
120120
`/api/v2/accounts/${accountId}/balances/`,
121-
token
121+
token,
122122
);
123123

124124
const foundAccount = balances?.find(
125-
(account) => account.balanceType === "interimAvailable"
125+
(account) => account.balanceType === "interimAvailable",
126126
);
127127

128128
return foundAccount?.balanceAmount;
129129
}
130130

131131
async getInstitutions(
132-
params: GetInstitutionsRequest
132+
params: GetInstitutionsRequest,
133133
): Promise<GetInstitutionsResponse> {
134134
const { countryCode } = params;
135135
const cacheKey = `${this.#institutionsCacheKey}_${countryCode}`;
@@ -150,15 +150,15 @@ export class GoCardLessApi {
150150
params: {
151151
country: countryCode,
152152
},
153-
}
153+
},
154154
);
155155

156156
this.#kv?.put(cacheKey, JSON.stringify(response), {
157157
expirationTtl: this.#oneHour,
158158
});
159159

160160
return response.filter((insitution) =>
161-
insitution.countries.includes(countryCode)
161+
insitution.countries.includes(countryCode),
162162
);
163163
}
164164

@@ -176,7 +176,7 @@ export class GoCardLessApi {
176176
redirect,
177177
institution_id: institutionId,
178178
agreement,
179-
}
179+
},
180180
);
181181
}
182182

@@ -198,7 +198,7 @@ export class GoCardLessApi {
198198
access_scope: ["balances", "details", "transactions"],
199199
access_valid_for_days: this.#accessValidForDays,
200200
max_historical_days: maxHistoricalDays,
201-
}
201+
},
202202
);
203203
}
204204

@@ -209,7 +209,7 @@ export class GoCardLessApi {
209209
this.#get<GetAccountResponse>(`/api/v2/accounts/${id}/`, token),
210210
this.#get<GetAccountDetailsResponse>(
211211
`/api/v2/accounts/${id}/details/`,
212-
token
212+
token,
213213
),
214214
]);
215215

@@ -235,10 +235,10 @@ export class GoCardLessApi {
235235
return {
236236
...accountDetails,
237237
institution: intitutions.find(
238-
(institution) => institution.id === accountDetails.institution_id
238+
(institution) => institution.id === accountDetails.institution_id,
239239
),
240240
};
241-
})
241+
}),
242242
);
243243
}
244244

@@ -259,7 +259,7 @@ export class GoCardLessApi {
259259
representation: "date",
260260
}),
261261
}
262-
: undefined
262+
: undefined,
263263
);
264264

265265
return response?.transactions?.booked;
@@ -276,7 +276,7 @@ export class GoCardLessApi {
276276

277277
return this.#get<GetRequisitionResponse>(
278278
`/api/v2/requisitions/${id}/`,
279-
token
279+
token,
280280
);
281281
}
282282

@@ -285,7 +285,7 @@ export class GoCardLessApi {
285285

286286
return this.#_delete<DeleteRequistionResponse>(
287287
`/api/v2/requisitions/${id}/`,
288-
token
288+
token,
289289
);
290290
}
291291

@@ -308,7 +308,7 @@ export class GoCardLessApi {
308308
path: string,
309309
token?: string,
310310
params?: Record<string, string>,
311-
config?: XiorRequestConfig
311+
config?: XiorRequestConfig,
312312
): Promise<TResponse> {
313313
const api = await this.#getApi(token);
314314

@@ -321,7 +321,7 @@ export class GoCardLessApi {
321321
path: string,
322322
token?: string,
323323
body?: unknown,
324-
config?: XiorRequestConfig
324+
config?: XiorRequestConfig,
325325
): Promise<TResponse> {
326326
const api = await this.#getApi(token);
327327
return api.post<TResponse>(path, body, config).then(({ data }) => data);
@@ -331,7 +331,7 @@ export class GoCardLessApi {
331331
path: string,
332332
token: string,
333333
params?: Record<string, string>,
334-
config?: XiorRequestConfig
334+
config?: XiorRequestConfig,
335335
): Promise<TResponse> {
336336
const api = await this.#getApi(token);
337337

apps/engine/src/providers/gocardless/gocardless-provider.ts

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Provider } from "../interface";
22
import type {
3+
DeleteAccountsRequest,
34
GetAccountBalanceRequest,
45
GetAccountsRequest,
56
GetInstitutionsRequest,
@@ -66,4 +67,12 @@ export class GoCardLessProvider implements Provider {
6667

6768
return response.map(transformInstitution);
6869
}
70+
71+
async deleteAccounts({ accountId }: DeleteAccountsRequest) {
72+
if (!accountId) {
73+
throw Error("Missing params");
74+
}
75+
76+
await this.#api.deleteRequisition(accountId);
77+
}
6978
}

apps/engine/src/providers/gocardless/transform.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Providers } from "@/common/schema";
12
import { capitalCase } from "change-case";
23
import type {
34
Account as BaseAccount,
@@ -105,17 +106,17 @@ const transformDescription = ({
105106
};
106107

107108
export const transformTransaction = (
108-
transaction: TransformTransaction
109+
transaction: TransformTransaction,
109110
): BaseTransaction => {
110111
const method = mapTransactionMethod(
111-
transaction?.proprietaryBankTransactionCode
112+
transaction?.proprietaryBankTransactionCode,
112113
);
113114

114115
let currencyExchange: { rate: number; currency: string } | undefined;
115116

116117
if (Array.isArray(transaction.currencyExchange)) {
117118
const rate = Number.parseFloat(
118-
transaction.currencyExchange.at(0)?.exchangeRate ?? ""
119+
transaction.currencyExchange.at(0)?.exchangeRate ?? "",
119120
);
120121

121122
if (rate) {
@@ -189,23 +190,23 @@ export const transformAccount = ({
189190
name: institution?.name,
190191
}
191192
: null,
192-
provider: "gocardless",
193+
provider: Providers.Enum.gocardless,
193194
enrollment_id: null,
194195
};
195196
};
196197

197198
export const transformAccountBalance = (
198-
account?: TransformAccountBalance
199+
account?: TransformAccountBalance,
199200
): BaseAccountBalance => ({
200201
currency: account?.currency || "EUR",
201202
amount: +(account?.amount ?? 0),
202203
});
203204

204205
export const transformInstitution = (
205-
insitution: Institution
206+
insitution: Institution,
206207
): TransformInstitution => ({
207208
id: insitution.id,
208209
name: insitution.name,
209210
logo: insitution.logo ?? null,
210-
provider: "gocardless",
211+
provider: Providers.Enum.gocardless,
211212
});

apps/engine/src/providers/gocardless/utils.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ test("Should return 90 days", () => {
66
getMaxHistoricalDays({
77
institutionId: "SWEDBANK_SWEDSESS",
88
transactionTotalDays: 720,
9-
})
9+
}),
1010
).toEqual(90);
1111
});
1212

@@ -15,6 +15,6 @@ test("Should return 720 days", () => {
1515
getMaxHistoricalDays({
1616
institutionId: "NOT_RESTRICTED",
1717
transactionTotalDays: 720,
18-
})
18+
}),
1919
).toEqual(720);
2020
});

apps/engine/src/providers/index.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { GoCardLessProvider } from "./gocardless/gocardless-provider";
44
import { PlaidProvider } from "./plaid/plaid-provider";
55
import { TellerProvider } from "./teller/teller-provider";
66
import type {
7+
DeleteAccountsRequest,
78
GetAccountBalanceRequest,
89
GetAccountsRequest,
910
GetHealthCheckResponse,
@@ -31,7 +32,7 @@ export class Provider {
3132
}
3233

3334
async getHealthCheck(
34-
params: Omit<ProviderParams, "provider">
35+
params: Omit<ProviderParams, "provider">,
3536
): Promise<GetHealthCheckResponse> {
3637
const teller = new TellerProvider(params);
3738
const plaid = new PlaidProvider(params);
@@ -64,7 +65,7 @@ export class Provider {
6465
async getTransactions(params: GetTransactionsRequest) {
6566
logger(
6667
"getTransactions:",
67-
`provider: ${this.#provider} id: ${params.accountId}`
68+
`provider: ${this.#provider} id: ${params.accountId}`,
6869
);
6970

7071
const data = await withRetry(() => this.#provider?.getTransactions(params));
@@ -91,11 +92,11 @@ export class Provider {
9192
async getAccountBalance(params: GetAccountBalanceRequest) {
9293
logger(
9394
"getAccountBalance:",
94-
`provider: ${this.#provider} id: ${params.accountId}`
95+
`provider: ${this.#provider} id: ${params.accountId}`,
9596
);
9697

9798
const data = await withRetry(() =>
98-
this.#provider?.getAccountBalance(params)
99+
this.#provider?.getAccountBalance(params),
99100
);
100101

101102
if (data) {
@@ -116,4 +117,10 @@ export class Provider {
116117

117118
return [];
118119
}
120+
121+
async deleteAccounts(params: DeleteAccountsRequest) {
122+
logger("delete:", `provider: ${this.#provider}`);
123+
124+
return withRetry(() => this.#provider?.deleteAccounts(params));
125+
}
119126
}

apps/engine/src/providers/interface.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type {
2+
DeleteAccountsRequest,
23
GetAccountBalanceRequest,
34
GetAccountBalanceResponse,
45
GetAccountsRequest,
@@ -11,14 +12,15 @@ import type {
1112

1213
export interface Provider {
1314
getTransactions: (
14-
params: GetTransactionsRequest
15+
params: GetTransactionsRequest,
1516
) => Promise<GetTransactionsResponse>;
1617
getAccounts: (params: GetAccountsRequest) => Promise<GetAccountsResponse>;
1718
getAccountBalance: (
18-
params: GetAccountBalanceRequest
19+
params: GetAccountBalanceRequest,
1920
) => Promise<GetAccountBalanceResponse>;
2021
getInstitutions: (
21-
params: GetInstitutionsRequest
22+
params: GetInstitutionsRequest,
2223
) => Promise<GetInstitutionsResponse>;
2324
getHealthCheck: () => Promise<boolean>;
25+
deleteAccounts: (params: DeleteAccountsRequest) => void;
2426
}

0 commit comments

Comments
 (0)