@develit-services/bank 0.0.29 → 0.0.30
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/dist/database/schema.cjs +1 -1
- package/dist/database/schema.d.cts +1 -1
- package/dist/database/schema.d.mts +1 -1
- package/dist/database/schema.d.ts +1 -1
- package/dist/database/schema.mjs +1 -1
- package/dist/export/worker.cjs +130 -4
- package/dist/export/worker.d.cts +161 -3
- package/dist/export/worker.d.mts +161 -3
- package/dist/export/worker.d.ts +161 -3
- package/dist/export/worker.mjs +131 -5
- package/dist/export/wrangler.cjs +1 -11
- package/dist/export/wrangler.d.cts +7 -7
- package/dist/export/wrangler.d.mts +7 -7
- package/dist/export/wrangler.d.ts +7 -7
- package/dist/export/wrangler.mjs +1 -11
- package/dist/shared/{bank.DXzEZPsO.cjs → bank.BMRBXGF1.cjs} +2 -1
- package/dist/shared/{bank.CWt0unt2.d.cts → bank.CtUeOz8i.d.ts} +1 -1
- package/dist/shared/{bank.DS18_iuS.d.mts → bank.D8o86NLF.d.mts} +1 -1
- package/dist/shared/{bank.By8Vh0l5.d.ts → bank.DUalSuEK.d.cts} +1 -1
- package/dist/shared/{bank.5CiXtVIb.mjs → bank.DbNuuGvb.mjs} +1 -1
- package/dist/shared/{bank.BeJh7l2V.cjs → bank.DuY4d2y_.cjs} +1 -1
- package/dist/shared/{bank.07oMM145.d.cts → bank.Nf6oaNfB.d.cts} +19 -0
- package/dist/shared/{bank.07oMM145.d.mts → bank.Nf6oaNfB.d.mts} +19 -0
- package/dist/shared/{bank.07oMM145.d.ts → bank.Nf6oaNfB.d.ts} +19 -0
- package/dist/shared/{bank.Ce4ZEpjD.mjs → bank.YCUhOduX.mjs} +2 -1
- package/dist/types.cjs +2 -2
- package/dist/types.d.cts +4 -4
- package/dist/types.d.mts +4 -4
- package/dist/types.d.ts +4 -4
- package/dist/types.mjs +2 -2
- package/package.json +1 -1
package/dist/export/worker.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
|
|
2
2
|
import { IRPCResponse } from '@develit-io/backend-sdk';
|
|
3
|
-
import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as PaymentInsertType } from '../shared/bank.
|
|
3
|
+
import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as PaymentInsertType } from '../shared/bank.Nf6oaNfB.js';
|
|
4
4
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
5
5
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
import { A as AccountSelectType, C as ConfigEnvironmentBank, I as IBankConnector, a as ConnectorKey, B as BankAccountWithLastSync } from '../shared/bank.
|
|
7
|
+
import { A as AccountSelectType, C as ConfigEnvironmentBank, I as IBankConnector, a as ConnectorKey, B as BankAccountWithLastSync } from '../shared/bank.CtUeOz8i.js';
|
|
8
8
|
import 'drizzle-orm/sqlite-core';
|
|
9
9
|
import 'drizzle-orm';
|
|
10
10
|
import '@develit-io/general-codes';
|
|
@@ -246,6 +246,162 @@ declare const processBatchInputSchema: z.ZodObject<{
|
|
|
246
246
|
interface ProcessBatchInput extends z.infer<typeof processBatchInputSchema> {
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
+
declare const getPaymentsInputSchema: z.ZodObject<{
|
|
250
|
+
page: z.ZodNumber;
|
|
251
|
+
limit: z.ZodNumber;
|
|
252
|
+
sort: z.ZodObject<{
|
|
253
|
+
column: z.ZodEnum<{
|
|
254
|
+
amount: "amount";
|
|
255
|
+
createdAt: "createdAt";
|
|
256
|
+
updatedAt: "updatedAt";
|
|
257
|
+
}>;
|
|
258
|
+
direction: z.ZodEnum<{
|
|
259
|
+
asc: "asc";
|
|
260
|
+
desc: "desc";
|
|
261
|
+
}>;
|
|
262
|
+
}, z.core.$strip>;
|
|
263
|
+
filterPaymentAccountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodUUID, z.ZodArray<z.ZodUUID>]>>;
|
|
264
|
+
filterPaymentAmount: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodArray<z.ZodNumber>]>>;
|
|
265
|
+
filterPaymentCurrency: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
266
|
+
CZK: "CZK";
|
|
267
|
+
EUR: "EUR";
|
|
268
|
+
USD: "USD";
|
|
269
|
+
PLN: "PLN";
|
|
270
|
+
RON: "RON";
|
|
271
|
+
GBP: "GBP";
|
|
272
|
+
RUB: "RUB";
|
|
273
|
+
HUF: "HUF";
|
|
274
|
+
CHF: "CHF";
|
|
275
|
+
DKK: "DKK";
|
|
276
|
+
SEK: "SEK";
|
|
277
|
+
HRK: "HRK";
|
|
278
|
+
NOK: "NOK";
|
|
279
|
+
BGN: "BGN";
|
|
280
|
+
TRY: "TRY";
|
|
281
|
+
AUD: "AUD";
|
|
282
|
+
CAD: "CAD";
|
|
283
|
+
JPY: "JPY";
|
|
284
|
+
CNY: "CNY";
|
|
285
|
+
INR: "INR";
|
|
286
|
+
BRL: "BRL";
|
|
287
|
+
MXN: "MXN";
|
|
288
|
+
ZAR: "ZAR";
|
|
289
|
+
SGD: "SGD";
|
|
290
|
+
HKD: "HKD";
|
|
291
|
+
KRW: "KRW";
|
|
292
|
+
MYR: "MYR";
|
|
293
|
+
THB: "THB";
|
|
294
|
+
IDR: "IDR";
|
|
295
|
+
PHP: "PHP";
|
|
296
|
+
AED: "AED";
|
|
297
|
+
SAR: "SAR";
|
|
298
|
+
ILS: "ILS";
|
|
299
|
+
EGP: "EGP";
|
|
300
|
+
NGN: "NGN";
|
|
301
|
+
PKR: "PKR";
|
|
302
|
+
COP: "COP";
|
|
303
|
+
CLP: "CLP";
|
|
304
|
+
PEN: "PEN";
|
|
305
|
+
VND: "VND";
|
|
306
|
+
KZT: "KZT";
|
|
307
|
+
UAH: "UAH";
|
|
308
|
+
BTC: "BTC";
|
|
309
|
+
ETH: "ETH";
|
|
310
|
+
ADA: "ADA";
|
|
311
|
+
DOT: "DOT";
|
|
312
|
+
ATOM: "ATOM";
|
|
313
|
+
XRP: "XRP";
|
|
314
|
+
LTC: "LTC";
|
|
315
|
+
SOL: "SOL";
|
|
316
|
+
DOGE: "DOGE";
|
|
317
|
+
MATIC: "MATIC";
|
|
318
|
+
AVAX: "AVAX";
|
|
319
|
+
}>, z.ZodArray<z.ZodEnum<{
|
|
320
|
+
CZK: "CZK";
|
|
321
|
+
EUR: "EUR";
|
|
322
|
+
USD: "USD";
|
|
323
|
+
PLN: "PLN";
|
|
324
|
+
RON: "RON";
|
|
325
|
+
GBP: "GBP";
|
|
326
|
+
RUB: "RUB";
|
|
327
|
+
HUF: "HUF";
|
|
328
|
+
CHF: "CHF";
|
|
329
|
+
DKK: "DKK";
|
|
330
|
+
SEK: "SEK";
|
|
331
|
+
HRK: "HRK";
|
|
332
|
+
NOK: "NOK";
|
|
333
|
+
BGN: "BGN";
|
|
334
|
+
TRY: "TRY";
|
|
335
|
+
AUD: "AUD";
|
|
336
|
+
CAD: "CAD";
|
|
337
|
+
JPY: "JPY";
|
|
338
|
+
CNY: "CNY";
|
|
339
|
+
INR: "INR";
|
|
340
|
+
BRL: "BRL";
|
|
341
|
+
MXN: "MXN";
|
|
342
|
+
ZAR: "ZAR";
|
|
343
|
+
SGD: "SGD";
|
|
344
|
+
HKD: "HKD";
|
|
345
|
+
KRW: "KRW";
|
|
346
|
+
MYR: "MYR";
|
|
347
|
+
THB: "THB";
|
|
348
|
+
IDR: "IDR";
|
|
349
|
+
PHP: "PHP";
|
|
350
|
+
AED: "AED";
|
|
351
|
+
SAR: "SAR";
|
|
352
|
+
ILS: "ILS";
|
|
353
|
+
EGP: "EGP";
|
|
354
|
+
NGN: "NGN";
|
|
355
|
+
PKR: "PKR";
|
|
356
|
+
COP: "COP";
|
|
357
|
+
CLP: "CLP";
|
|
358
|
+
PEN: "PEN";
|
|
359
|
+
VND: "VND";
|
|
360
|
+
KZT: "KZT";
|
|
361
|
+
UAH: "UAH";
|
|
362
|
+
BTC: "BTC";
|
|
363
|
+
ETH: "ETH";
|
|
364
|
+
ADA: "ADA";
|
|
365
|
+
DOT: "DOT";
|
|
366
|
+
ATOM: "ATOM";
|
|
367
|
+
XRP: "XRP";
|
|
368
|
+
LTC: "LTC";
|
|
369
|
+
SOL: "SOL";
|
|
370
|
+
DOGE: "DOGE";
|
|
371
|
+
MATIC: "MATIC";
|
|
372
|
+
AVAX: "AVAX";
|
|
373
|
+
}>>]>>;
|
|
374
|
+
filterPaymentyDirection: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
375
|
+
INCOMING: "INCOMING";
|
|
376
|
+
OUTGOING: "OUTGOING";
|
|
377
|
+
}>, z.ZodArray<z.ZodEnum<{
|
|
378
|
+
INCOMING: "INCOMING";
|
|
379
|
+
OUTGOING: "OUTGOING";
|
|
380
|
+
}>>]>>;
|
|
381
|
+
filterPaymentDateFrom: z.ZodOptional<z.ZodDate>;
|
|
382
|
+
filterPaymentDateTo: z.ZodOptional<z.ZodDate>;
|
|
383
|
+
filterPaymentStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
384
|
+
PREPARED: "PREPARED";
|
|
385
|
+
INITIALIZED: "INITIALIZED";
|
|
386
|
+
FAILED: "FAILED";
|
|
387
|
+
PENDING: "PENDING";
|
|
388
|
+
COMPLETED: "COMPLETED";
|
|
389
|
+
CREATED: "CREATED";
|
|
390
|
+
}>, z.ZodArray<z.ZodEnum<{
|
|
391
|
+
PREPARED: "PREPARED";
|
|
392
|
+
INITIALIZED: "INITIALIZED";
|
|
393
|
+
FAILED: "FAILED";
|
|
394
|
+
PENDING: "PENDING";
|
|
395
|
+
COMPLETED: "COMPLETED";
|
|
396
|
+
CREATED: "CREATED";
|
|
397
|
+
}>>]>>;
|
|
398
|
+
}, z.core.$strip>;
|
|
399
|
+
type GetPaymentsInput = z.input<typeof getPaymentsInputSchema>;
|
|
400
|
+
type GetPaymentsOutput = {
|
|
401
|
+
payments: PaymentSelectType[];
|
|
402
|
+
totalCount: number;
|
|
403
|
+
};
|
|
404
|
+
|
|
249
405
|
declare const BankServiceBase_base: (abstract new (ctx: ExecutionContext, env: BankEnv) => WorkerEntrypoint<BankEnv, {}>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
|
|
250
406
|
declare class BankServiceBase extends BankServiceBase_base {
|
|
251
407
|
readonly db: DrizzleD1Database<typeof tables>;
|
|
@@ -254,6 +410,7 @@ declare class BankServiceBase extends BankServiceBase_base {
|
|
|
254
410
|
constructor(ctx: ExecutionContext, env: BankEnv, config: ConfigEnvironmentBank);
|
|
255
411
|
getAllowedProviders(): ConnectorKey[];
|
|
256
412
|
getAccounts(): Promise<{
|
|
413
|
+
expiresAt: Date | undefined;
|
|
257
414
|
connectorKey: "ERSTE" | "FINBRICKS" | "MOCK" | "CREDITAS" | "MOCK_COBS" | "FIO" | "MONETA";
|
|
258
415
|
status: "AUTHORIZED" | "DISABLED" | "EXPIRED";
|
|
259
416
|
sync: boolean;
|
|
@@ -273,6 +430,7 @@ declare class BankServiceBase extends BankServiceBase_base {
|
|
|
273
430
|
updatedAt: Date | null;
|
|
274
431
|
deletedAt: Date | null;
|
|
275
432
|
}[]>;
|
|
433
|
+
getPayments(input: GetPaymentsInput): Promise<IRPCResponse<GetPaymentsOutput>>;
|
|
276
434
|
accountFetchInterval(connectorKey: ConnectorKey): number;
|
|
277
435
|
syncAccounts(): Promise<IRPCResponse<void>>;
|
|
278
436
|
scheduled(controller: ScheduledController): Promise<void>;
|
|
@@ -286,9 +444,9 @@ declare class BankServiceBase extends BankServiceBase_base {
|
|
|
286
444
|
createdAt: Date | null;
|
|
287
445
|
updatedAt: Date | null;
|
|
288
446
|
deletedAt: Date | null;
|
|
447
|
+
accountId: string | null;
|
|
289
448
|
batchPaymentInitiatedAt: Date | null;
|
|
290
449
|
authorizationUrls: string | string[] | null;
|
|
291
|
-
accountId: string | null;
|
|
292
450
|
payments: PaymentInsertType[];
|
|
293
451
|
metadata: object | null;
|
|
294
452
|
}[] | undefined>>;
|
package/dist/export/worker.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { uuidv4, useResult, createInternalError, develitWorker, first, RPCResponse, action, service } from '@develit-io/backend-sdk';
|
|
2
|
-
import { t as tables, F as FinbricksConnector, M as MockConnector, E as ErsteConnector, P as PAYMENT_TYPES, e as CONNECTOR_KEYS, q as getPaymentDirection } from '../shared/bank.
|
|
2
|
+
import { t as tables, F as FinbricksConnector, M as MockConnector, E as ErsteConnector, P as PAYMENT_TYPES, e as CONNECTOR_KEYS, c as PAYMENT_STATUSES, d as PAYMENT_DIRECTIONS, q as getPaymentDirection } from '../shared/bank.YCUhOduX.mjs';
|
|
3
3
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
4
4
|
import { drizzle } from 'drizzle-orm/d1';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { CURRENCY_CODES } from '@develit-io/general-codes';
|
|
7
7
|
import 'jose';
|
|
8
|
-
import { eq, and, inArray, desc,
|
|
9
|
-
import { M as MockCobsConnector } from '../shared/bank.
|
|
8
|
+
import { eq, and, inArray, sql, asc, desc, gte, lte } from 'drizzle-orm';
|
|
9
|
+
import { M as MockCobsConnector } from '../shared/bank.DbNuuGvb.mjs';
|
|
10
10
|
import superjson from 'superjson';
|
|
11
11
|
import 'drizzle-zod';
|
|
12
12
|
import 'drizzle-orm/sqlite-core';
|
|
@@ -141,6 +141,83 @@ const getAccountByIbanQuery = async (db, { iban }) => {
|
|
|
141
141
|
return await db.select().from(tables.account).where(eq(tables.account.iban, iban)).get();
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
+
const getAllAccountsQuery = async (db) => {
|
|
145
|
+
const accountsWithExpiration = await db.select().from(tables.account).leftJoin(
|
|
146
|
+
tables.accountCredentials,
|
|
147
|
+
eq(tables.accountCredentials.accountId, tables.account.id)
|
|
148
|
+
);
|
|
149
|
+
return accountsWithExpiration.map(({ account, account_credentials }) => {
|
|
150
|
+
return {
|
|
151
|
+
...account,
|
|
152
|
+
expiresAt: account_credentials?.expiresAt
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const buildMultiFilterConditions = (column, value) => {
|
|
158
|
+
if (value === void 0) return void 0;
|
|
159
|
+
if (Array.isArray(value)) {
|
|
160
|
+
return value.length > 0 ? inArray(column, value) : void 0;
|
|
161
|
+
}
|
|
162
|
+
return eq(column, value);
|
|
163
|
+
};
|
|
164
|
+
const buildRangeFilterConditions = (column, minValue, maxValue) => {
|
|
165
|
+
const conditions = [];
|
|
166
|
+
if (minValue !== void 0) {
|
|
167
|
+
conditions.push(gte(column, minValue));
|
|
168
|
+
}
|
|
169
|
+
if (maxValue !== void 0) {
|
|
170
|
+
conditions.push(lte(column, maxValue));
|
|
171
|
+
}
|
|
172
|
+
if (conditions.length === 0) return void 0;
|
|
173
|
+
if (conditions.length === 1) return conditions[0];
|
|
174
|
+
return and(...conditions);
|
|
175
|
+
};
|
|
176
|
+
const resolveColumn = (table, column, fallback = "updatedAt") => {
|
|
177
|
+
const key = column && column in table ? column : fallback;
|
|
178
|
+
return table[key];
|
|
179
|
+
};
|
|
180
|
+
const getPaymentsWithPaginationQuery = async (db, {
|
|
181
|
+
limit,
|
|
182
|
+
page,
|
|
183
|
+
sort,
|
|
184
|
+
filterPaymentAccountId,
|
|
185
|
+
filterPaymentAmount,
|
|
186
|
+
filterPaymentCurrency,
|
|
187
|
+
filterPaymentDateFrom,
|
|
188
|
+
filterPaymentDateTo,
|
|
189
|
+
filterPaymentStatus,
|
|
190
|
+
filterPaymentyDirection
|
|
191
|
+
}) => {
|
|
192
|
+
const whereConditions = and(
|
|
193
|
+
buildMultiFilterConditions(
|
|
194
|
+
tables.payment.accountId,
|
|
195
|
+
filterPaymentAccountId
|
|
196
|
+
),
|
|
197
|
+
buildMultiFilterConditions(tables.payment.amount, filterPaymentAmount),
|
|
198
|
+
buildMultiFilterConditions(tables.payment.currency, filterPaymentCurrency),
|
|
199
|
+
buildRangeFilterConditions(
|
|
200
|
+
tables.payment.createdAt,
|
|
201
|
+
filterPaymentDateFrom,
|
|
202
|
+
filterPaymentDateTo
|
|
203
|
+
),
|
|
204
|
+
buildMultiFilterConditions(tables.payment.status, filterPaymentStatus),
|
|
205
|
+
buildMultiFilterConditions(
|
|
206
|
+
tables.payment.direction,
|
|
207
|
+
filterPaymentyDirection
|
|
208
|
+
)
|
|
209
|
+
);
|
|
210
|
+
const sortColumn = resolveColumn(tables.payment, sort.column);
|
|
211
|
+
const [{ totalCount }] = await db.select({
|
|
212
|
+
totalCount: sql`count(*)`
|
|
213
|
+
}).from(tables.payment).where(whereConditions);
|
|
214
|
+
const payments = await db.select().from(tables.payment).where(whereConditions).limit(limit).offset((page - 1) * limit).orderBy(sort.direction === "asc" ? asc(sortColumn) : desc(sortColumn));
|
|
215
|
+
return {
|
|
216
|
+
payments,
|
|
217
|
+
totalCount
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
|
|
144
221
|
class CreditasConnector extends FinbricksConnector {
|
|
145
222
|
constructor(config) {
|
|
146
223
|
super("CREDITAS", config);
|
|
@@ -323,6 +400,31 @@ const processBatchInputSchema = z.object({
|
|
|
323
400
|
batch: z.custom()
|
|
324
401
|
});
|
|
325
402
|
|
|
403
|
+
const ALLOWED_PAYMENT_FILTERS = {
|
|
404
|
+
ACCOUNT_ID: "filterPaymentAccountId",
|
|
405
|
+
AMOUNT: "filterPaymentAmount",
|
|
406
|
+
CURRENCY: "filterPaymentCurrency",
|
|
407
|
+
DIRECTION: "filterPaymentyDirection",
|
|
408
|
+
FROM: "filterPaymentDateFrom",
|
|
409
|
+
TO: "filterPaymentDateTo",
|
|
410
|
+
STATUS: "filterPaymentStatus"
|
|
411
|
+
};
|
|
412
|
+
const getPaymentsInputSchema = z.object({
|
|
413
|
+
page: z.number().positive(),
|
|
414
|
+
limit: z.number().positive(),
|
|
415
|
+
sort: z.object({
|
|
416
|
+
column: z.enum(["createdAt", "updatedAt", "amount"]),
|
|
417
|
+
direction: z.enum(["asc", "desc"])
|
|
418
|
+
}),
|
|
419
|
+
[ALLOWED_PAYMENT_FILTERS.ACCOUNT_ID]: z.union([z.uuid(), z.uuid().array()]).optional(),
|
|
420
|
+
[ALLOWED_PAYMENT_FILTERS.AMOUNT]: z.union([z.number(), z.number().array()]).optional(),
|
|
421
|
+
[ALLOWED_PAYMENT_FILTERS.CURRENCY]: z.union([z.enum(CURRENCY_CODES), z.enum(CURRENCY_CODES).array()]).optional(),
|
|
422
|
+
[ALLOWED_PAYMENT_FILTERS.DIRECTION]: z.union([z.enum(PAYMENT_DIRECTIONS), z.enum(PAYMENT_DIRECTIONS).array()]).optional(),
|
|
423
|
+
[ALLOWED_PAYMENT_FILTERS.FROM]: z.date().optional(),
|
|
424
|
+
[ALLOWED_PAYMENT_FILTERS.TO]: z.date().optional(),
|
|
425
|
+
[ALLOWED_PAYMENT_FILTERS.STATUS]: z.union([z.enum(PAYMENT_STATUSES), z.enum(PAYMENT_STATUSES).array()]).optional()
|
|
426
|
+
});
|
|
427
|
+
|
|
326
428
|
var __defProp = Object.defineProperty;
|
|
327
429
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
328
430
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
@@ -344,7 +446,16 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
344
446
|
return this.allowedProviders;
|
|
345
447
|
}
|
|
346
448
|
async getAccounts() {
|
|
347
|
-
return await this.db
|
|
449
|
+
return await getAllAccountsQuery(this.db);
|
|
450
|
+
}
|
|
451
|
+
async getPayments(input) {
|
|
452
|
+
return this.handleAction(
|
|
453
|
+
{ data: input, schema: getPaymentsInputSchema },
|
|
454
|
+
{ successMessage: "Payments fetched successfully" },
|
|
455
|
+
async (pagination) => {
|
|
456
|
+
return await getPaymentsWithPaginationQuery(this.db, pagination);
|
|
457
|
+
}
|
|
458
|
+
);
|
|
348
459
|
}
|
|
349
460
|
accountFetchInterval(connectorKey) {
|
|
350
461
|
switch (connectorKey) {
|
|
@@ -500,6 +611,7 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
500
611
|
const mappedPayments = paymentsToBatch.map(
|
|
501
612
|
(payment) => ({
|
|
502
613
|
id: uuidv4(),
|
|
614
|
+
accountId: "",
|
|
503
615
|
refId: payment.refId,
|
|
504
616
|
connectorKey: "MOCK",
|
|
505
617
|
amount: payment.amount,
|
|
@@ -555,7 +667,8 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
555
667
|
(payment) => payment.debtorIban === acc.iban && payment.currency === acc.currency
|
|
556
668
|
).map((payment) => ({
|
|
557
669
|
...payment,
|
|
558
|
-
connectorKey: acc.connectorKey
|
|
670
|
+
connectorKey: acc.connectorKey,
|
|
671
|
+
accountId: acc.id
|
|
559
672
|
}));
|
|
560
673
|
if (newPayments.length === 0) {
|
|
561
674
|
continue;
|
|
@@ -914,10 +1027,20 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
914
1027
|
debtorHolderName,
|
|
915
1028
|
connectorKey
|
|
916
1029
|
}) => {
|
|
1030
|
+
const account = await getAccountByIbanQuery(this.db, {
|
|
1031
|
+
iban: creditorIban
|
|
1032
|
+
});
|
|
1033
|
+
if (!account)
|
|
1034
|
+
throw createInternalError(null, {
|
|
1035
|
+
message: "Unsupported account",
|
|
1036
|
+
code: "UNSUPPORTED_ACCOUNT",
|
|
1037
|
+
status: 422
|
|
1038
|
+
});
|
|
917
1039
|
const payment = {
|
|
918
1040
|
id: uuidv4(),
|
|
919
1041
|
amount,
|
|
920
1042
|
connectorKey,
|
|
1043
|
+
accountId: account.id,
|
|
921
1044
|
direction: "INCOMING",
|
|
922
1045
|
paymentType: "DOMESTIC",
|
|
923
1046
|
currency,
|
|
@@ -1009,6 +1132,9 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
1009
1132
|
);
|
|
1010
1133
|
}
|
|
1011
1134
|
};
|
|
1135
|
+
__decorateClass([
|
|
1136
|
+
action("get-payments")
|
|
1137
|
+
], BankServiceBase.prototype, "getPayments", 1);
|
|
1012
1138
|
__decorateClass([
|
|
1013
1139
|
action("synchronize-accounts")
|
|
1014
1140
|
], BankServiceBase.prototype, "syncAccounts", 1);
|
package/dist/export/wrangler.cjs
CHANGED
|
@@ -17,17 +17,7 @@ function defineBankServiceWrangler(config) {
|
|
|
17
17
|
ERSTE_CLIENT_ID: "[SECRET]",
|
|
18
18
|
// Variables
|
|
19
19
|
...envs.local.vars,
|
|
20
|
-
ENVIRONMENT: "localhost"
|
|
21
|
-
REDIRECT_URI: "http://localhost:8080/api/v1/bank/authorize-account",
|
|
22
|
-
ERSTE_AUTH_URI: "https://webapi.developers.erstegroup.com/api/csas/sandbox/v1/sandbox-idp",
|
|
23
|
-
ERSTE_PAYMENTS_URI: "https://webapi.developers.erstegroup.com/api/csas/public/sandbox/v1/payments",
|
|
24
|
-
ERSTE_ACCOUNTS_URI: "https://webapi.developers.erstegroup.com/api/csas/public/sandbox/v3/accounts",
|
|
25
|
-
ERSTE_FETCH_INTERVAL: 300,
|
|
26
|
-
FINBRICKS_BASE_URI: "https://api.sandbox.finbricks.com",
|
|
27
|
-
FINBRICKS_MERCHANT_ID: "10435c82-84b4-4efa-b5bf-ae6cd723e653",
|
|
28
|
-
CRON_PAYMENTS_PROCESSING: "* * * * *",
|
|
29
|
-
CRON_BATCH_STATUSES: "* * * * *",
|
|
30
|
-
BANK_AUTH_RECIPIENT: "petr@develit.io"
|
|
20
|
+
ENVIRONMENT: "localhost"
|
|
31
21
|
},
|
|
32
22
|
triggers: envs.local.triggers,
|
|
33
23
|
kv_namespaces: [
|
|
@@ -3,16 +3,16 @@ import { B as BankServiceWranglerConfig } from '../shared/bank.BchnXQDL.cjs';
|
|
|
3
3
|
declare function defineBankServiceWrangler(config: BankServiceWranglerConfig): {
|
|
4
4
|
vars: {
|
|
5
5
|
ENVIRONMENT: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
FINBRICKS_BASE_URI: string;
|
|
6
|
+
ERSTE_AUTH_URI: "https://webapi.developers.erstegroup.com/api/csas/sandbox/v1/sandbox-idp";
|
|
7
|
+
ERSTE_PAYMENTS_URI: "https://webapi.developers.erstegroup.com/api/csas/public/sandbox/v1/payments";
|
|
8
|
+
ERSTE_ACCOUNTS_URI: "https://webapi.developers.erstegroup.com/api/csas/public/sandbox/v3/accounts";
|
|
9
|
+
ERSTE_FETCH_INTERVAL: 300;
|
|
10
|
+
FINBRICKS_BASE_URI: "https://api.sandbox.finbricks.com";
|
|
12
11
|
FINBRICKS_MERCHANT_ID: string;
|
|
13
|
-
CRON_PAYMENTS_PROCESSING: string;
|
|
14
12
|
CRON_BATCH_STATUSES: string;
|
|
13
|
+
CRON_PAYMENTS_PROCESSING: string;
|
|
15
14
|
BANK_AUTH_RECIPIENT: string;
|
|
15
|
+
REDIRECT_URI: string;
|
|
16
16
|
FINBRICKS_PRIVATE_KEY_PEM: string;
|
|
17
17
|
ERSTE_API_KEY: string;
|
|
18
18
|
ERSTE_CLIENT_SECRET: string;
|
|
@@ -3,16 +3,16 @@ import { B as BankServiceWranglerConfig } from '../shared/bank.BchnXQDL.mjs';
|
|
|
3
3
|
declare function defineBankServiceWrangler(config: BankServiceWranglerConfig): {
|
|
4
4
|
vars: {
|
|
5
5
|
ENVIRONMENT: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
FINBRICKS_BASE_URI: string;
|
|
6
|
+
ERSTE_AUTH_URI: "https://webapi.developers.erstegroup.com/api/csas/sandbox/v1/sandbox-idp";
|
|
7
|
+
ERSTE_PAYMENTS_URI: "https://webapi.developers.erstegroup.com/api/csas/public/sandbox/v1/payments";
|
|
8
|
+
ERSTE_ACCOUNTS_URI: "https://webapi.developers.erstegroup.com/api/csas/public/sandbox/v3/accounts";
|
|
9
|
+
ERSTE_FETCH_INTERVAL: 300;
|
|
10
|
+
FINBRICKS_BASE_URI: "https://api.sandbox.finbricks.com";
|
|
12
11
|
FINBRICKS_MERCHANT_ID: string;
|
|
13
|
-
CRON_PAYMENTS_PROCESSING: string;
|
|
14
12
|
CRON_BATCH_STATUSES: string;
|
|
13
|
+
CRON_PAYMENTS_PROCESSING: string;
|
|
15
14
|
BANK_AUTH_RECIPIENT: string;
|
|
15
|
+
REDIRECT_URI: string;
|
|
16
16
|
FINBRICKS_PRIVATE_KEY_PEM: string;
|
|
17
17
|
ERSTE_API_KEY: string;
|
|
18
18
|
ERSTE_CLIENT_SECRET: string;
|
|
@@ -3,16 +3,16 @@ import { B as BankServiceWranglerConfig } from '../shared/bank.BchnXQDL.js';
|
|
|
3
3
|
declare function defineBankServiceWrangler(config: BankServiceWranglerConfig): {
|
|
4
4
|
vars: {
|
|
5
5
|
ENVIRONMENT: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
FINBRICKS_BASE_URI: string;
|
|
6
|
+
ERSTE_AUTH_URI: "https://webapi.developers.erstegroup.com/api/csas/sandbox/v1/sandbox-idp";
|
|
7
|
+
ERSTE_PAYMENTS_URI: "https://webapi.developers.erstegroup.com/api/csas/public/sandbox/v1/payments";
|
|
8
|
+
ERSTE_ACCOUNTS_URI: "https://webapi.developers.erstegroup.com/api/csas/public/sandbox/v3/accounts";
|
|
9
|
+
ERSTE_FETCH_INTERVAL: 300;
|
|
10
|
+
FINBRICKS_BASE_URI: "https://api.sandbox.finbricks.com";
|
|
12
11
|
FINBRICKS_MERCHANT_ID: string;
|
|
13
|
-
CRON_PAYMENTS_PROCESSING: string;
|
|
14
12
|
CRON_BATCH_STATUSES: string;
|
|
13
|
+
CRON_PAYMENTS_PROCESSING: string;
|
|
15
14
|
BANK_AUTH_RECIPIENT: string;
|
|
15
|
+
REDIRECT_URI: string;
|
|
16
16
|
FINBRICKS_PRIVATE_KEY_PEM: string;
|
|
17
17
|
ERSTE_API_KEY: string;
|
|
18
18
|
ERSTE_CLIENT_SECRET: string;
|
package/dist/export/wrangler.mjs
CHANGED
|
@@ -15,17 +15,7 @@ function defineBankServiceWrangler(config) {
|
|
|
15
15
|
ERSTE_CLIENT_ID: "[SECRET]",
|
|
16
16
|
// Variables
|
|
17
17
|
...envs.local.vars,
|
|
18
|
-
ENVIRONMENT: "localhost"
|
|
19
|
-
REDIRECT_URI: "http://localhost:8080/api/v1/bank/authorize-account",
|
|
20
|
-
ERSTE_AUTH_URI: "https://webapi.developers.erstegroup.com/api/csas/sandbox/v1/sandbox-idp",
|
|
21
|
-
ERSTE_PAYMENTS_URI: "https://webapi.developers.erstegroup.com/api/csas/public/sandbox/v1/payments",
|
|
22
|
-
ERSTE_ACCOUNTS_URI: "https://webapi.developers.erstegroup.com/api/csas/public/sandbox/v3/accounts",
|
|
23
|
-
ERSTE_FETCH_INTERVAL: 300,
|
|
24
|
-
FINBRICKS_BASE_URI: "https://api.sandbox.finbricks.com",
|
|
25
|
-
FINBRICKS_MERCHANT_ID: "10435c82-84b4-4efa-b5bf-ae6cd723e653",
|
|
26
|
-
CRON_PAYMENTS_PROCESSING: "* * * * *",
|
|
27
|
-
CRON_BATCH_STATUSES: "* * * * *",
|
|
28
|
-
BANK_AUTH_RECIPIENT: "petr@develit.io"
|
|
18
|
+
ENVIRONMENT: "localhost"
|
|
29
19
|
},
|
|
30
20
|
triggers: envs.local.triggers,
|
|
31
21
|
kv_namespaces: [
|
|
@@ -1067,7 +1067,7 @@ const accountSelectSchema = drizzleZod.createSelectSchema(account);
|
|
|
1067
1067
|
|
|
1068
1068
|
const accountCredentials = sqliteCore.sqliteTable("account_credentials", {
|
|
1069
1069
|
...backendSdk.base,
|
|
1070
|
-
accountId: sqliteCore.text("account_id").notNull(),
|
|
1070
|
+
accountId: sqliteCore.text("account_id").references(() => account.id).notNull(),
|
|
1071
1071
|
connectorKey: sqliteCore.text("connector_key", {
|
|
1072
1072
|
enum: CONNECTOR_KEYS
|
|
1073
1073
|
}).$type().notNull(),
|
|
@@ -1110,6 +1110,7 @@ const payment = sqliteCore.sqliteTable("payment", {
|
|
|
1110
1110
|
...backendSdk.base,
|
|
1111
1111
|
refId: sqliteCore.text("ref_id"),
|
|
1112
1112
|
bankRefId: sqliteCore.text("bank_ref_id"),
|
|
1113
|
+
accountId: sqliteCore.text("account_id").references(() => account.id).notNull(),
|
|
1113
1114
|
connectorKey: sqliteCore.text("connector_key", { enum: CONNECTOR_KEYS }).$type().notNull(),
|
|
1114
1115
|
amount: sqliteCore.real("amount").notNull(),
|
|
1115
1116
|
direction: sqliteCore.text("direction").$type().notNull(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Environment } from '@develit-io/backend-sdk';
|
|
2
2
|
import { CURRENCY_CODES, BANK_CODES, CODES } from '@develit-io/general-codes';
|
|
3
|
-
import { a as PaymentInsertType, t as tables } from './bank.
|
|
3
|
+
import { a as PaymentInsertType, t as tables } from './bank.Nf6oaNfB.js';
|
|
4
4
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import * as drizzle_zod from 'drizzle-zod';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Environment } from '@develit-io/backend-sdk';
|
|
2
2
|
import { CURRENCY_CODES, BANK_CODES, CODES } from '@develit-io/general-codes';
|
|
3
|
-
import { a as PaymentInsertType, t as tables } from './bank.
|
|
3
|
+
import { a as PaymentInsertType, t as tables } from './bank.Nf6oaNfB.mjs';
|
|
4
4
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import * as drizzle_zod from 'drizzle-zod';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Environment } from '@develit-io/backend-sdk';
|
|
2
2
|
import { CURRENCY_CODES, BANK_CODES, CODES } from '@develit-io/general-codes';
|
|
3
|
-
import { a as PaymentInsertType, t as tables } from './bank.
|
|
3
|
+
import { a as PaymentInsertType, t as tables } from './bank.Nf6oaNfB.cjs';
|
|
4
4
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import * as drizzle_zod from 'drizzle-zod';
|
|
@@ -334,6 +334,25 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
334
334
|
}, {}, {
|
|
335
335
|
length: number | undefined;
|
|
336
336
|
}>;
|
|
337
|
+
accountId: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
338
|
+
name: "account_id";
|
|
339
|
+
tableName: "payment";
|
|
340
|
+
dataType: "string";
|
|
341
|
+
columnType: "SQLiteText";
|
|
342
|
+
data: string;
|
|
343
|
+
driverParam: string;
|
|
344
|
+
notNull: true;
|
|
345
|
+
hasDefault: false;
|
|
346
|
+
isPrimaryKey: false;
|
|
347
|
+
isAutoincrement: false;
|
|
348
|
+
hasRuntimeDefault: false;
|
|
349
|
+
enumValues: [string, ...string[]];
|
|
350
|
+
baseColumn: never;
|
|
351
|
+
identity: undefined;
|
|
352
|
+
generated: undefined;
|
|
353
|
+
}, {}, {
|
|
354
|
+
length: number | undefined;
|
|
355
|
+
}>;
|
|
337
356
|
connectorKey: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
338
357
|
name: "connector_key";
|
|
339
358
|
tableName: "payment";
|
|
@@ -334,6 +334,25 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
334
334
|
}, {}, {
|
|
335
335
|
length: number | undefined;
|
|
336
336
|
}>;
|
|
337
|
+
accountId: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
338
|
+
name: "account_id";
|
|
339
|
+
tableName: "payment";
|
|
340
|
+
dataType: "string";
|
|
341
|
+
columnType: "SQLiteText";
|
|
342
|
+
data: string;
|
|
343
|
+
driverParam: string;
|
|
344
|
+
notNull: true;
|
|
345
|
+
hasDefault: false;
|
|
346
|
+
isPrimaryKey: false;
|
|
347
|
+
isAutoincrement: false;
|
|
348
|
+
hasRuntimeDefault: false;
|
|
349
|
+
enumValues: [string, ...string[]];
|
|
350
|
+
baseColumn: never;
|
|
351
|
+
identity: undefined;
|
|
352
|
+
generated: undefined;
|
|
353
|
+
}, {}, {
|
|
354
|
+
length: number | undefined;
|
|
355
|
+
}>;
|
|
337
356
|
connectorKey: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
338
357
|
name: "connector_key";
|
|
339
358
|
tableName: "payment";
|
|
@@ -334,6 +334,25 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
334
334
|
}, {}, {
|
|
335
335
|
length: number | undefined;
|
|
336
336
|
}>;
|
|
337
|
+
accountId: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
338
|
+
name: "account_id";
|
|
339
|
+
tableName: "payment";
|
|
340
|
+
dataType: "string";
|
|
341
|
+
columnType: "SQLiteText";
|
|
342
|
+
data: string;
|
|
343
|
+
driverParam: string;
|
|
344
|
+
notNull: true;
|
|
345
|
+
hasDefault: false;
|
|
346
|
+
isPrimaryKey: false;
|
|
347
|
+
isAutoincrement: false;
|
|
348
|
+
hasRuntimeDefault: false;
|
|
349
|
+
enumValues: [string, ...string[]];
|
|
350
|
+
baseColumn: never;
|
|
351
|
+
identity: undefined;
|
|
352
|
+
generated: undefined;
|
|
353
|
+
}, {}, {
|
|
354
|
+
length: number | undefined;
|
|
355
|
+
}>;
|
|
337
356
|
connectorKey: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
338
357
|
name: "connector_key";
|
|
339
358
|
tableName: "payment";
|