@develit-services/bank 2.2.3 → 2.3.0

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.
@@ -1,10 +1,13 @@
1
- import { uuidv4, createInternalError, useResult } from '@develit-io/backend-sdk';
1
+ import { uuidv4, createInternalError, useResult, bankAccount, base, structuredAddressSchema } from '@develit-io/backend-sdk';
2
+ import { sqliteTable, text, integer, unique, real, index } from 'drizzle-orm/sqlite-core';
2
3
  import { format, parseISO } from 'date-fns';
3
- import { CURRENCY_CODES } from '@develit-io/general-codes';
4
- import './bank.C7MA33AX.mjs';
5
- import 'drizzle-orm';
6
4
  import { importPKCS8, SignJWT } from 'jose';
5
+ import { z } from 'zod';
6
+ import { COUNTRY_CODES_2, CURRENCY_CODES, BANK_CODES } from '@develit-io/general-codes';
7
+ import { relations } from 'drizzle-orm/relations';
8
+ import { and, not, inArray, isNull } from 'drizzle-orm';
7
9
  import 'node:crypto';
10
+ import { createInsertSchema, createUpdateSchema, createSelectSchema } from 'drizzle-zod';
8
11
 
9
12
  function toIncomingPayment(input) {
10
13
  return {
@@ -667,7 +670,8 @@ class FinbricksConnector extends IBankConnector {
667
670
  connectorKey: this.PROVIDER,
668
671
  currency: acc.currency,
669
672
  iban: acc.identification.iban,
670
- id: acc.id
673
+ id: acc.id,
674
+ config: null
671
675
  }))
672
676
  );
673
677
  return {
@@ -1074,6 +1078,40 @@ class CsobConnector extends FinbricksConnector {
1074
1078
  }
1075
1079
  }
1076
1080
 
1081
+ const PAYMENT_TYPES = ["SEPA", "SWIFT", "DOMESTIC", "UNKNOWN"];
1082
+ const CHARGE_BEARERS = ["SHA", "OUR", "BEN"];
1083
+ const INSTRUCTION_PRIORITIES = ["NORM", "HIGH", "INST"];
1084
+ const PAYMENT_REQUEST_STATUSES = [
1085
+ "OPENED",
1086
+ "AUTHORIZED",
1087
+ "COMPLETED",
1088
+ "BOOKED",
1089
+ "SETTLED",
1090
+ "REJECTED",
1091
+ "CLOSED"
1092
+ ];
1093
+ const PAYMENT_STATUSES = [
1094
+ "PENDING",
1095
+ "PROCESSING",
1096
+ "BOOKED",
1097
+ "CANCELLED",
1098
+ "REJECTED",
1099
+ "SCHEDULED",
1100
+ "HOLD",
1101
+ "INFO"
1102
+ ];
1103
+ const PAYMENT_DIRECTIONS = ["INCOMING", "OUTGOING"];
1104
+ const BATCH_STATUSES = [
1105
+ "PROCESSING",
1106
+ "READY_TO_SIGN",
1107
+ "AUTHORIZED",
1108
+ "COMPLETED",
1109
+ "FAILED"
1110
+ ];
1111
+ const BATCH_MODES = ["NATIVE", "SINGLE"];
1112
+ const ACCOUNT_STATUSES = ["AUTHORIZED", "DISABLED", "EXPIRED"];
1113
+ const COUNTRY_CODES = COUNTRY_CODES_2;
1114
+
1077
1115
  class AirBankConnector extends FinbricksConnector {
1078
1116
  constructor(config) {
1079
1117
  super("AIRBANK", config);
@@ -1332,6 +1370,14 @@ const calculateCzechIban = (accountNumber, bankCode) => {
1332
1370
  return `CZ${checkDigits}${basicIban}`;
1333
1371
  };
1334
1372
 
1373
+ const dbuAccountConfigSchema = z.object({
1374
+ with4EyeApproval: z.enum(["Y", "N"]).default("Y"),
1375
+ channelCode: z.string().default("WWW"),
1376
+ actionTypeCode: z.string().default("TRANSFER"),
1377
+ transactionTypeCode: z.string().default("TRANSFER"),
1378
+ partialRealization: z.enum(["Y", "N"]).default("N"),
1379
+ forceRealization: z.enum(["Y", "N"]).default("N")
1380
+ });
1335
1381
  class DbuConnector extends IBankConnector {
1336
1382
  constructor({
1337
1383
  BASE_URL,
@@ -1353,7 +1399,10 @@ class DbuConnector extends IBankConnector {
1353
1399
  this.api = API;
1354
1400
  this.redirectUri = REDIRECT_URI;
1355
1401
  this.txAuthUri = TX_AUTH_URI;
1356
- this.connectedAccounts = connectedAccounts;
1402
+ this.connectedAccounts = connectedAccounts.map((acc) => ({
1403
+ ...acc,
1404
+ config: dbuAccountConfigSchema.parse(acc.config ?? {})
1405
+ }));
1357
1406
  this.sessionId = uuidv4();
1358
1407
  this.allowedPostEndpoints = [
1359
1408
  "/required-transactions",
@@ -1608,7 +1657,7 @@ class DbuConnector extends IBankConnector {
1608
1657
  return [];
1609
1658
  }
1610
1659
  // ── Single payment methods ──────────────────────────────────────────
1611
- resolveIdAccountDebit(payment) {
1660
+ resolveAccount(payment) {
1612
1661
  const account = this.connectedAccounts.find(
1613
1662
  (acc) => acc.id === payment.accountId
1614
1663
  );
@@ -1618,7 +1667,10 @@ class DbuConnector extends IBankConnector {
1618
1667
  code: "DBU_ACCOUNT_NOT_FOUND"
1619
1668
  });
1620
1669
  }
1621
- return Number(account.bankRefId);
1670
+ return account;
1671
+ }
1672
+ resolveIdAccountDebit(payment) {
1673
+ return Number(this.resolveAccount(payment).bankRefId);
1622
1674
  }
1623
1675
  resolveAccountDetails(account) {
1624
1676
  if (account.number && account.bankCode) {
@@ -1635,13 +1687,15 @@ class DbuConnector extends IBankConnector {
1635
1687
  }
1636
1688
  async initiateInstantPayment(payment) {
1637
1689
  const creditor = this.resolveAccountDetails(payment.creditor);
1690
+ const debtorAccount = this.resolveAccount(payment);
1691
+ const cfg = debtorAccount.config;
1638
1692
  const body = {
1639
1693
  accountNumberCredit: creditor.number,
1640
- idAccountDebit: this.resolveIdAccountDebit(payment),
1694
+ idAccountDebit: Number(debtorAccount.bankRefId),
1641
1695
  bankCodeCredit: creditor.bankCode,
1642
1696
  amount: payment.amount,
1643
1697
  currencyCode: "CZK",
1644
- channelCode: "WWW",
1698
+ channelCode: cfg.channelCode,
1645
1699
  textMessage: payment.message,
1646
1700
  varSymbol: payment.vs,
1647
1701
  specSymbol: payment.ss,
@@ -1675,6 +1729,7 @@ class DbuConnector extends IBankConnector {
1675
1729
  }
1676
1730
  const debtor = this.resolveAccountDetails(payment.debtor);
1677
1731
  const creditor = this.resolveAccountDetails(payment.creditor);
1732
+ const cfg = this.resolveAccount(payment).config;
1678
1733
  const body = {
1679
1734
  accountNumberDebit: debtor.number,
1680
1735
  accountNumberCredit: creditor.number,
@@ -1682,20 +1737,20 @@ class DbuConnector extends IBankConnector {
1682
1737
  bankCodeCredit: creditor.bankCode,
1683
1738
  amount: payment.amount,
1684
1739
  currencyCode: "CZK",
1685
- actionTypeCode: "TRANSFER",
1686
- channelCode: "WWW",
1740
+ actionTypeCode: cfg.actionTypeCode,
1741
+ channelCode: cfg.channelCode,
1687
1742
  textMessage: payment.message,
1688
- transactionTypeCode: "TRANSFER",
1743
+ transactionTypeCode: cfg.transactionTypeCode,
1689
1744
  validFrom: format(/* @__PURE__ */ new Date(), "yyyy-MM-dd"),
1690
1745
  validTo: null,
1691
1746
  subEntity: "DOMESTIC",
1692
- partialRealization: "N",
1693
- forceRealization: "N",
1747
+ partialRealization: cfg.partialRealization,
1748
+ forceRealization: cfg.forceRealization,
1694
1749
  varSymbol: payment.vs,
1695
1750
  specSymbol: payment.ss,
1696
1751
  constSymbol: payment.ks,
1697
1752
  uniqueExternalId: payment.id,
1698
- with4EyeApproval: "Y",
1753
+ with4EyeApproval: cfg.with4EyeApproval,
1699
1754
  applicationCode: this.applicationCode
1700
1755
  };
1701
1756
  const response = await this.makeRequest(
@@ -1891,6 +1946,39 @@ class DbuConnector extends IBankConnector {
1891
1946
  }
1892
1947
  }
1893
1948
 
1949
+ const TERMINAL_STATUSES$1 = /* @__PURE__ */ new Set([
1950
+ "SETTLED",
1951
+ "REJECTED",
1952
+ "CLOSED"
1953
+ ]);
1954
+ const PENDING_STATUSES = /* @__PURE__ */ new Set([
1955
+ "OPENED",
1956
+ "AUTHORIZED"
1957
+ ]);
1958
+ function isTerminalStatus(status) {
1959
+ return TERMINAL_STATUSES$1.has(status);
1960
+ }
1961
+ function isPendingStatus(status) {
1962
+ return PENDING_STATUSES.has(status);
1963
+ }
1964
+ function isProcessedStatus(status) {
1965
+ return !isPendingStatus(status);
1966
+ }
1967
+ function hasPaymentAccountAssigned(payment) {
1968
+ return "accountId" in payment && "connectorKey" in payment && payment.accountId !== void 0 && payment.connectorKey !== void 0;
1969
+ }
1970
+ function isPaymentCompleted(payment) {
1971
+ return (payment.status === "COMPLETED" || payment.status === "BOOKED" || payment.status === "SETTLED" || payment.status === "REJECTED" || payment.status === "CLOSED") && "bankRefId" in payment && typeof payment.bankRefId === "string";
1972
+ }
1973
+
1974
+ const TERMINAL_STATUSES = PAYMENT_REQUEST_STATUSES.filter(isTerminalStatus);
1975
+ const getNonTerminalPaymentRequestsQuery = (db) => db.select().from(tables.paymentRequest).where(
1976
+ and(
1977
+ not(inArray(tables.paymentRequest.status, TERMINAL_STATUSES)),
1978
+ isNull(tables.paymentRequest.deletedAt)
1979
+ )
1980
+ );
1981
+
1894
1982
  class ErsteConnector extends IBankConnector {
1895
1983
  constructor(config) {
1896
1984
  super();
@@ -2305,4 +2393,254 @@ class MockConnector extends IBankConnector {
2305
2393
  }
2306
2394
  }
2307
2395
 
2308
- export { CsobConnector as C, DbuConnector as D, ErsteConnector as E, FINBRICKS_ENDPOINTS as F, IBankConnector as I, KBConnector as K, MockCobsConnector as M, FinbricksClient as a, FinbricksConnector as b, MockConnector as c, assignAccount as d, toBatchedPaymentFromPaymentRequest as e, toCompletedPayment as f, toIncomingPayment as g, toPaymentRequestInsert as h, toPreparedPayment as i, initiateConnector as j, signFinbricksJws as s, toBatchedPayment as t, useFinbricksFetch as u };
2396
+ const CONNECTOR_KEYS = [
2397
+ "ERSTE",
2398
+ "FINBRICKS",
2399
+ "MOCK",
2400
+ "CREDITAS",
2401
+ "MOCK_COBS",
2402
+ "FIO",
2403
+ "MONETA",
2404
+ "DBU",
2405
+ "CSAS",
2406
+ "AIRBANK",
2407
+ "KB",
2408
+ "CSOB"
2409
+ ];
2410
+ const CREDENTIALS_TYPES = [
2411
+ "AUTH_TOKEN",
2412
+ "REFRESH_TOKEN",
2413
+ "CLIENT_ID",
2414
+ "API_KEY"
2415
+ ];
2416
+ const TOKEN_TYPES = ["ACCOUNT_AUTHORIZATION"];
2417
+
2418
+ const account = sqliteTable(
2419
+ "account",
2420
+ {
2421
+ ...base,
2422
+ ...bankAccount,
2423
+ // countryCode is temporary until bankAccount is update to include US country code
2424
+ countryCode: text("country_code", { enum: COUNTRY_CODES }).$type().notNull(),
2425
+ number: text("number").notNull(),
2426
+ name: text("name"),
2427
+ iban: text("iban").notNull(),
2428
+ bankCode: text("bank_code", { enum: BANK_CODES }).notNull(),
2429
+ connectorKey: text("connector_key", {
2430
+ enum: CONNECTOR_KEYS
2431
+ }).$type().notNull(),
2432
+ status: text("status", { enum: ACCOUNT_STATUSES }).$type().notNull(),
2433
+ bankRefId: text("bank_ref_id").notNull(),
2434
+ batchSizeLimit: integer("batch_size_limit").notNull().default(50),
2435
+ syncIntervalS: integer("sync_interval_s").notNull().default(600),
2436
+ lastSyncAt: integer("last_sync_at", { mode: "timestamp_ms" }),
2437
+ lastSyncMetadata: text("last_sync_metadata", {
2438
+ mode: "json"
2439
+ }).$type(),
2440
+ connectorConfig: text("connector_config", {
2441
+ mode: "json"
2442
+ }).$type()
2443
+ },
2444
+ (t) => [unique().on(t.iban)]
2445
+ );
2446
+
2447
+ const accountInsertSchema = createInsertSchema(account, {
2448
+ address: () => structuredAddressSchema.optional()
2449
+ });
2450
+ const accountUpdateSchema = createUpdateSchema(account, {
2451
+ address: () => structuredAddressSchema.optional()
2452
+ });
2453
+ const accountSelectSchema = createSelectSchema(account, {
2454
+ address: () => structuredAddressSchema.nullable()
2455
+ });
2456
+
2457
+ const accountCredentials = sqliteTable("account_credentials", {
2458
+ ...base,
2459
+ accountId: text("account_id").references(() => account.id, { onDelete: "restrict", onUpdate: "cascade" }).notNull(),
2460
+ connectorKey: text("connector_key", {
2461
+ enum: CONNECTOR_KEYS
2462
+ }).$type().notNull(),
2463
+ type: text("type", {
2464
+ enum: CREDENTIALS_TYPES
2465
+ }).$type().notNull(),
2466
+ value: text("value").notNull(),
2467
+ expiresAt: integer("expires_at", { mode: "timestamp_ms" }).notNull()
2468
+ });
2469
+
2470
+ const accountCredentialsInsertSchema = createInsertSchema(accountCredentials);
2471
+ const accountCredentialsUpdateSchema = createUpdateSchema(accountCredentials);
2472
+ const accountCredentialsSelectSchema = createSelectSchema(accountCredentials);
2473
+
2474
+ const ott = sqliteTable("ott", {
2475
+ ...base,
2476
+ oneTimeToken: text("one_time_token").notNull(),
2477
+ refId: text("ref_id").notNull(),
2478
+ tokenType: text("token_type", { enum: TOKEN_TYPES }).$type().notNull(),
2479
+ expiresAt: integer("expires_at", { mode: "timestamp_ms" }).notNull()
2480
+ });
2481
+
2482
+ const ottInsertSchema = createInsertSchema(ott);
2483
+ const ottUpdateSchema = createUpdateSchema(ott);
2484
+ const ottSelectSchema = createSelectSchema(ott);
2485
+
2486
+ const batch = sqliteTable("batch", {
2487
+ ...base,
2488
+ batchPaymentInitiatedAt: integer("batch_payment_initiated_at", {
2489
+ mode: "timestamp_ms"
2490
+ }),
2491
+ authorizationUrls: text("authorization_urls", { mode: "json" }).$type(),
2492
+ accountId: text("account_id").references(() => account.id, {
2493
+ onDelete: "restrict",
2494
+ onUpdate: "cascade"
2495
+ }),
2496
+ status: text("status", { enum: BATCH_STATUSES }).$type(),
2497
+ statusReason: text("status_reason"),
2498
+ statusResponse: text("status_response", { mode: "json" }).$type(),
2499
+ metadata: text("metadata", { mode: "json" }).$type(),
2500
+ paymentType: text("payment_type", {
2501
+ enum: PAYMENT_TYPES
2502
+ }).$type(),
2503
+ paymentsChecksum: text("payments_checksum"),
2504
+ batchMode: text("batch_mode", { enum: BATCH_MODES }).$type()
2505
+ });
2506
+
2507
+ const payment = sqliteTable(
2508
+ "payment",
2509
+ {
2510
+ ...base,
2511
+ correlationId: text("correlation_id").notNull(),
2512
+ refId: text("ref_id"),
2513
+ bankRefId: text("bank_ref_id").notNull(),
2514
+ accountId: text("account_id").references(() => account.id, {
2515
+ onDelete: "restrict",
2516
+ onUpdate: "cascade"
2517
+ }).notNull(),
2518
+ connectorKey: text("connector_key", { enum: CONNECTOR_KEYS }).$type().notNull(),
2519
+ amount: real("amount").notNull(),
2520
+ direction: text("direction").$type().notNull(),
2521
+ paymentType: text("payment_type").$type().notNull(),
2522
+ currency: text("currency").$type().notNull(),
2523
+ status: text("status", { enum: PAYMENT_STATUSES }).$type().notNull(),
2524
+ statusReason: text("status_reason"),
2525
+ batchId: text("bank_execution_batch_id"),
2526
+ initiatedAt: integer("initiated_at", {
2527
+ mode: "timestamp_ms"
2528
+ }),
2529
+ vs: text("vs"),
2530
+ ss: text("ss"),
2531
+ ks: text("ks"),
2532
+ message: text("message"),
2533
+ chargeBearer: text("charge_bearer", {
2534
+ enum: CHARGE_BEARERS
2535
+ }).$type(),
2536
+ instructionPriority: text("instruction_priority", {
2537
+ enum: INSTRUCTION_PRIORITIES
2538
+ }).$type(),
2539
+ processedAt: integer("processed_at", {
2540
+ mode: "timestamp_ms"
2541
+ }),
2542
+ creditor: text("creditor", { mode: "json" }).$type().notNull(),
2543
+ creditorIban: text("creditor_iban"),
2544
+ debtor: text("debtor", { mode: "json" }).$type().notNull(),
2545
+ debtorIban: text("debtor_iban")
2546
+ },
2547
+ (t) => [
2548
+ unique().on(t.connectorKey, t.accountId, t.bankRefId),
2549
+ index("payment_account_id_idx").on(t.accountId),
2550
+ index("payment_account_id_status_idx").on(t.accountId, t.status),
2551
+ index("payment_account_id_created_at_idx").on(t.accountId, t.createdAt),
2552
+ index("payment_created_at_idx").on(t.createdAt),
2553
+ index("payment_direction_idx").on(t.direction),
2554
+ index("payment_batch_id_idx").on(t.batchId),
2555
+ index("payment_creditor_iban_idx").on(t.creditorIban),
2556
+ index("payment_debtor_iban_idx").on(t.debtorIban)
2557
+ ]
2558
+ );
2559
+ const paymentRelations = relations(payment, ({ one }) => ({
2560
+ batch: one(batch, { fields: [payment.batchId], references: [batch.id] })
2561
+ }));
2562
+
2563
+ const paymentRequest = sqliteTable(
2564
+ "payment_request",
2565
+ {
2566
+ ...base,
2567
+ batchId: text("batch_id").references(() => batch.id, {
2568
+ onDelete: "restrict",
2569
+ onUpdate: "cascade"
2570
+ }),
2571
+ accountId: text("account_id").references(() => account.id, {
2572
+ onDelete: "restrict",
2573
+ onUpdate: "cascade"
2574
+ }).notNull(),
2575
+ correlationId: text("correlation_id").notNull(),
2576
+ refId: text("ref_id"),
2577
+ bankRefId: text("bank_ref_id"),
2578
+ connectorKey: text("connector_key", { enum: CONNECTOR_KEYS }).$type().notNull(),
2579
+ amount: real("amount").notNull(),
2580
+ paymentType: text("payment_type", { enum: PAYMENT_TYPES }).$type().notNull(),
2581
+ currency: text("currency").$type().notNull(),
2582
+ status: text("status", { enum: PAYMENT_REQUEST_STATUSES }).$type().notNull(),
2583
+ statusReason: text("status_reason"),
2584
+ authorizationUrl: text("authorization_url"),
2585
+ initiatedAt: integer("initiated_at", { mode: "timestamp_ms" }),
2586
+ processedAt: integer("processed_at", { mode: "timestamp_ms" }),
2587
+ vs: text("vs"),
2588
+ ss: text("ss"),
2589
+ ks: text("ks"),
2590
+ message: text("message"),
2591
+ chargeBearer: text("charge_bearer", {
2592
+ enum: CHARGE_BEARERS
2593
+ }).$type(),
2594
+ instructionPriority: text("instruction_priority", {
2595
+ enum: INSTRUCTION_PRIORITIES
2596
+ }).$type(),
2597
+ creditor: text("creditor", { mode: "json" }).$type().notNull(),
2598
+ creditorIban: text("creditor_iban"),
2599
+ debtor: text("debtor", { mode: "json" }).$type().notNull(),
2600
+ debtorIban: text("debtor_iban"),
2601
+ sendAsSinglePayment: integer("send_as_single_payment", {
2602
+ mode: "boolean"
2603
+ })
2604
+ },
2605
+ (t) => [
2606
+ index("payment_request_batch_id_idx").on(t.batchId),
2607
+ index("payment_request_account_id_idx").on(t.accountId),
2608
+ index("payment_request_creditor_iban_idx").on(t.creditorIban),
2609
+ index("payment_request_debtor_iban_idx").on(t.debtorIban),
2610
+ index("payment_request_status_idx").on(t.status),
2611
+ index("payment_request_created_at_idx").on(t.createdAt),
2612
+ index("payment_request_account_status_idx").on(t.accountId, t.status),
2613
+ index("payment_request_status_created_at_idx").on(t.status, t.createdAt),
2614
+ index("payment_request_account_status_created_at_idx").on(
2615
+ t.accountId,
2616
+ t.status,
2617
+ t.createdAt
2618
+ )
2619
+ ]
2620
+ );
2621
+ const paymentRequestRelations = relations(paymentRequest, ({ one }) => ({
2622
+ batch: one(batch, {
2623
+ fields: [paymentRequest.batchId],
2624
+ references: [batch.id]
2625
+ }),
2626
+ account: one(account, {
2627
+ fields: [paymentRequest.accountId],
2628
+ references: [account.id]
2629
+ })
2630
+ }));
2631
+
2632
+ const schema = {
2633
+ __proto__: null,
2634
+ account: account,
2635
+ accountCredentials: accountCredentials,
2636
+ batch: batch,
2637
+ ott: ott,
2638
+ payment: payment,
2639
+ paymentRelations: paymentRelations,
2640
+ paymentRequest: paymentRequest,
2641
+ paymentRequestRelations: paymentRequestRelations
2642
+ };
2643
+
2644
+ const tables = schema;
2645
+
2646
+ export { ott as $, ACCOUNT_STATUSES as A, BATCH_MODES as B, CHARGE_BEARERS as C, DbuConnector as D, ErsteConnector as E, FINBRICKS_ENDPOINTS as F, ottSelectSchema as G, ottUpdateSchema as H, IBankConnector as I, signFinbricksJws as J, KBConnector as K, toBatchedPayment as L, MockCobsConnector as M, toBatchedPaymentFromPaymentRequest as N, toCompletedPayment as O, PAYMENT_DIRECTIONS as P, toIncomingPayment as Q, toPaymentRequestInsert as R, toPreparedPayment as S, TOKEN_TYPES as T, useFinbricksFetch as U, tables as V, initiateConnector as W, getNonTerminalPaymentRequestsQuery as X, account as Y, accountCredentials as Z, batch as _, BATCH_STATUSES as a, payment as a0, paymentRelations as a1, paymentRequest as a2, paymentRequestRelations as a3, CONNECTOR_KEYS as b, COUNTRY_CODES as c, CREDENTIALS_TYPES as d, CsobConnector as e, FinbricksClient as f, FinbricksConnector as g, INSTRUCTION_PRIORITIES as h, MockConnector as i, PAYMENT_REQUEST_STATUSES as j, PAYMENT_STATUSES as k, PAYMENT_TYPES as l, accountCredentialsInsertSchema as m, accountCredentialsSelectSchema as n, accountCredentialsUpdateSchema as o, accountInsertSchema as p, accountSelectSchema as q, accountUpdateSchema as r, assignAccount as s, dbuAccountConfigSchema as t, hasPaymentAccountAssigned as u, isPaymentCompleted as v, isPendingStatus as w, isProcessedStatus as x, isTerminalStatus as y, ottInsertSchema as z };
package/dist/types.cjs CHANGED
@@ -1,39 +1,20 @@
1
1
  'use strict';
2
2
 
3
- const mock_connector = require('./shared/bank.CQfKMyzc.cjs');
4
- const database_schema = require('./shared/bank.CIWYI18z.cjs');
3
+ const database_schema = require('./shared/bank.avgw-IRO.cjs');
5
4
  const batchLifecycle = require('./shared/bank.NF8bZBy0.cjs');
6
5
  const generalCodes = require('@develit-io/general-codes');
7
6
  require('@develit-io/backend-sdk');
7
+ require('drizzle-orm/sqlite-core');
8
8
  require('date-fns');
9
- require('drizzle-orm');
10
9
  require('jose');
11
- require('node:crypto');
12
- require('drizzle-orm/sqlite-core');
10
+ require('zod');
13
11
  require('drizzle-orm/relations');
12
+ require('drizzle-orm');
13
+ require('node:crypto');
14
14
  require('drizzle-zod');
15
15
 
16
16
 
17
17
 
18
- exports.CsobConnector = mock_connector.CsobConnector;
19
- exports.DbuConnector = mock_connector.DbuConnector;
20
- exports.ErsteConnector = mock_connector.ErsteConnector;
21
- exports.FINBRICKS_ENDPOINTS = mock_connector.FINBRICKS_ENDPOINTS;
22
- exports.FinbricksClient = mock_connector.FinbricksClient;
23
- exports.FinbricksConnector = mock_connector.FinbricksConnector;
24
- exports.IBankConnector = mock_connector.IBankConnector;
25
- exports.KBConnector = mock_connector.KBConnector;
26
- exports.MockCobsConnector = mock_connector.MockCobsConnector;
27
- exports.MockConnector = mock_connector.MockConnector;
28
- exports.assignAccount = mock_connector.assignAccount;
29
- exports.signFinbricksJws = mock_connector.signFinbricksJws;
30
- exports.toBatchedPayment = mock_connector.toBatchedPayment;
31
- exports.toBatchedPaymentFromPaymentRequest = mock_connector.toBatchedPaymentFromPaymentRequest;
32
- exports.toCompletedPayment = mock_connector.toCompletedPayment;
33
- exports.toIncomingPayment = mock_connector.toIncomingPayment;
34
- exports.toPaymentRequestInsert = mock_connector.toPaymentRequestInsert;
35
- exports.toPreparedPayment = mock_connector.toPreparedPayment;
36
- exports.useFinbricksFetch = mock_connector.useFinbricksFetch;
37
18
  exports.ACCOUNT_STATUSES = database_schema.ACCOUNT_STATUSES;
38
19
  exports.BATCH_MODES = database_schema.BATCH_MODES;
39
20
  exports.BATCH_STATUES = database_schema.BATCH_STATUSES;
@@ -42,7 +23,17 @@ exports.CHARGE_BEARERS = database_schema.CHARGE_BEARERS;
42
23
  exports.CONNECTOR_KEYS = database_schema.CONNECTOR_KEYS;
43
24
  exports.COUNTRY_CODES = database_schema.COUNTRY_CODES;
44
25
  exports.CREDENTIALS_TYPES = database_schema.CREDENTIALS_TYPES;
26
+ exports.CsobConnector = database_schema.CsobConnector;
27
+ exports.DbuConnector = database_schema.DbuConnector;
28
+ exports.ErsteConnector = database_schema.ErsteConnector;
29
+ exports.FINBRICKS_ENDPOINTS = database_schema.FINBRICKS_ENDPOINTS;
30
+ exports.FinbricksClient = database_schema.FinbricksClient;
31
+ exports.FinbricksConnector = database_schema.FinbricksConnector;
32
+ exports.IBankConnector = database_schema.IBankConnector;
45
33
  exports.INSTRUCTION_PRIORITIES = database_schema.INSTRUCTION_PRIORITIES;
34
+ exports.KBConnector = database_schema.KBConnector;
35
+ exports.MockCobsConnector = database_schema.MockCobsConnector;
36
+ exports.MockConnector = database_schema.MockConnector;
46
37
  exports.PAYMENT_DIRECTIONS = database_schema.PAYMENT_DIRECTIONS;
47
38
  exports.PAYMENT_REQUEST_STATUSES = database_schema.PAYMENT_REQUEST_STATUSES;
48
39
  exports.PAYMENT_STATUSES = database_schema.PAYMENT_STATUSES;
@@ -54,6 +45,8 @@ exports.accountCredentialsUpdateSchema = database_schema.accountCredentialsUpdat
54
45
  exports.accountInsertSchema = database_schema.accountInsertSchema;
55
46
  exports.accountSelectSchema = database_schema.accountSelectSchema;
56
47
  exports.accountUpdateSchema = database_schema.accountUpdateSchema;
48
+ exports.assignAccount = database_schema.assignAccount;
49
+ exports.dbuAccountConfigSchema = database_schema.dbuAccountConfigSchema;
57
50
  exports.hasPaymentAccountAssigned = database_schema.hasPaymentAccountAssigned;
58
51
  exports.isPaymentCompleted = database_schema.isPaymentCompleted;
59
52
  exports.isPendingStatus = database_schema.isPendingStatus;
@@ -62,6 +55,14 @@ exports.isTerminalStatus = database_schema.isTerminalStatus;
62
55
  exports.ottInsertSchema = database_schema.ottInsertSchema;
63
56
  exports.ottSelectSchema = database_schema.ottSelectSchema;
64
57
  exports.ottUpdateSchema = database_schema.ottUpdateSchema;
58
+ exports.signFinbricksJws = database_schema.signFinbricksJws;
59
+ exports.toBatchedPayment = database_schema.toBatchedPayment;
60
+ exports.toBatchedPaymentFromPaymentRequest = database_schema.toBatchedPaymentFromPaymentRequest;
61
+ exports.toCompletedPayment = database_schema.toCompletedPayment;
62
+ exports.toIncomingPayment = database_schema.toIncomingPayment;
63
+ exports.toPaymentRequestInsert = database_schema.toPaymentRequestInsert;
64
+ exports.toPreparedPayment = database_schema.toPreparedPayment;
65
+ exports.useFinbricksFetch = database_schema.useFinbricksFetch;
65
66
  exports.isBatchAuthorized = batchLifecycle.isBatchAuthorized;
66
67
  exports.isBatchCompleted = batchLifecycle.isBatchCompleted;
67
68
  exports.isBatchFailed = batchLifecycle.isBatchFailed;
package/dist/types.d.cts CHANGED
@@ -1,12 +1,12 @@
1
- import { I as IBankConnector, b as ConnectorKey, f as ConnectedAccount, c as PaymentType, g as CredentialsResolver, h as AccountCredentialsInsertType, i as AccountInsertType, j as BatchedPayment, k as InitiatedBatch, l as IncomingPayment, m as InitiatedPayment, A as AccountSelectType, n as ParsedBankPayment, o as PaymentRequestStatus, p as AuthorizationCallbackResult, q as BatchMetadata, r as Currency, a as PaymentSelectType, P as PaymentRequestSelectType, s as AccountAssignedPayment, u as PreparedPayment, v as CompletedPayment, w as PaymentRequestInsertType } from './shared/bank.COez_hEH.cjs';
2
- export { x as ACCOUNT_STATUSES, y as AccountCredentialsPatchType, z as AccountCredentialsSelectType, D as AccountCredentialsUpdateType, E as AccountPatchType, F as AccountStatus, G as AccountUpdateType, J as AuthorizedBatch, K as BATCH_MODES, M as BATCH_STATUES, M as BATCH_STATUSES, N as BankAccountWithLastSync, O as BankCode, Q as BatchInsertType, R as BatchLifecycle, S as BatchMode, T as BatchPayment, B as BatchSelectType, U as BatchStatus, V as CHARGE_BEARERS, W as CONNECTOR_KEYS, X as COUNTRY_CODES, Y as CREDENTIALS_TYPES, Z as ChargeBearer, _ as CompletedBatch, C as ConfigEnvironmentBank, $ as CountryCode, a0 as CredentialsType, d as CurrencyCode, a1 as INSTRUCTION_PRIORITIES, a2 as InstructionPriority, L as LastSyncMetadata, a3 as PAYMENT_DIRECTIONS, a4 as PAYMENT_REQUEST_STATUSES, a5 as PAYMENT_STATUSES, a6 as PAYMENT_TYPES, a7 as PaymentDirection, a8 as PaymentFailedInsertType, a9 as PaymentInsertType, aa as PaymentLifecycle, ab as PaymentPreparedInsertType, ac as PaymentStatus, ad as ProcessingBatch, ae as ReadyToSignBatch, af as ResolvedCredentials, ag as TOKEN_TYPES, ah as TokenType, ai as accountCredentialsInsertSchema, aj as accountCredentialsSelectSchema, ak as accountCredentialsUpdateSchema, al as accountInsertSchema, am as accountSelectSchema, an as accountUpdateSchema, ao as hasPaymentAccountAssigned, ap as isBatchAuthorized, aq as isBatchCompleted, ar as isBatchFailed, as as isBatchInitiated, at as isBatchProcessing, au as isBatchReadyToSign, av as isPaymentCompleted, aw as isPendingStatus, ax as isProcessedStatus, ay as isTerminalStatus } from './shared/bank.COez_hEH.cjs';
3
- import { d as FinbricksAccount, R as ReferenceType, S as SendPaymentInput } from './shared/bank.Cw3K7nIh.cjs';
4
- export { e as FinbricksAccountTransactionsResponse, f as FinbricksAccountsListResponse, g as FinbricksAuthTokenResponse, h as FinbricksBatchResponse, i as FinbricksConnectAccountResponse, j as FinbricksPaymentResponse, k as FinbricksSupportedBank, F as FinbricksSupportedBanksResponse, b as SendPaymentSyncInput } from './shared/bank.Cw3K7nIh.cjs';
1
+ import { I as IBankConnector, c as ConnectorKey, g as ConnectedAccount, d as PaymentType, h as CredentialsResolver, i as AccountCredentialsInsertType, j as AccountInsertType, k as BatchedPayment, l as InitiatedBatch, m as IncomingPayment, n as InitiatedPayment, A as AccountSelectType, o as ParsedBankPayment, p as PaymentRequestStatus, q as AuthorizationCallbackResult, r as BatchMetadata, s as Currency, a as PaymentSelectType, P as PaymentRequestSelectType, u as AccountAssignedPayment, v as PreparedPayment, w as CompletedPayment, x as PaymentRequestInsertType } from './shared/bank.CC4p6Jf-.cjs';
2
+ export { y as ACCOUNT_STATUSES, z as AccountCredentialsPatchType, D as AccountCredentialsSelectType, E as AccountCredentialsUpdateType, F as AccountPatchType, G as AccountStatus, J as AccountUpdateType, K as AuthorizedBatch, M as BATCH_MODES, N as BATCH_STATUES, N as BATCH_STATUSES, O as BankAccountWithLastSync, Q as BankCode, R as BatchInsertType, S as BatchLifecycle, T as BatchMode, U as BatchPayment, B as BatchSelectType, V as BatchStatus, W as CHARGE_BEARERS, X as CONNECTOR_KEYS, Y as COUNTRY_CODES, Z as CREDENTIALS_TYPES, _ as ChargeBearer, $ as CompletedBatch, b as ConfigEnvironmentBank, C as ConnectorConfig, a0 as CountryCode, a1 as CredentialsType, e as CurrencyCode, a2 as INSTRUCTION_PRIORITIES, a3 as InstructionPriority, L as LastSyncMetadata, a4 as PAYMENT_DIRECTIONS, a5 as PAYMENT_REQUEST_STATUSES, a6 as PAYMENT_STATUSES, a7 as PAYMENT_TYPES, a8 as PaymentDirection, a9 as PaymentFailedInsertType, aa as PaymentInsertType, ab as PaymentLifecycle, ac as PaymentPreparedInsertType, ad as PaymentStatus, ae as ProcessingBatch, af as ReadyToSignBatch, ag as ResolvedCredentials, ah as TOKEN_TYPES, ai as TokenType, aj as accountCredentialsInsertSchema, ak as accountCredentialsSelectSchema, al as accountCredentialsUpdateSchema, am as accountInsertSchema, an as accountSelectSchema, ao as accountUpdateSchema, ap as hasPaymentAccountAssigned, aq as isBatchAuthorized, ar as isBatchCompleted, as as isBatchFailed, at as isBatchInitiated, au as isBatchProcessing, av as isBatchReadyToSign, aw as isPaymentCompleted, ax as isPendingStatus, ay as isProcessedStatus, az as isTerminalStatus } from './shared/bank.CC4p6Jf-.cjs';
3
+ import { d as FinbricksAccount, R as ReferenceType, S as SendPaymentInput } from './shared/bank.CxAHQOwW.cjs';
4
+ export { e as FinbricksAccountTransactionsResponse, f as FinbricksAccountsListResponse, g as FinbricksAuthTokenResponse, h as FinbricksBatchResponse, i as FinbricksConnectAccountResponse, j as FinbricksPaymentResponse, k as FinbricksSupportedBank, F as FinbricksSupportedBanksResponse, b as SendPaymentSyncInput } from './shared/bank.CxAHQOwW.cjs';
5
+ import { z } from 'zod';
5
6
  export { a as BankServiceEnv, b as BankServiceEnvironmentConfig, B as BankServiceWranglerConfig } from './shared/bank.Bz4DIxJL.cjs';
6
7
  import { BaseEvent } from '@develit-io/backend-sdk';
7
8
  import * as drizzle_zod from 'drizzle-zod';
8
9
  import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
9
- import { z } from 'zod';
10
10
  export { BANK_CODES, CURRENCY_CODES } from '@develit-io/general-codes';
11
11
  import 'drizzle-orm';
12
12
  import 'zod/v4/core';
@@ -301,6 +301,27 @@ declare class CsobConnector extends FinbricksConnector {
301
301
  supportsBatch(paymentType: PaymentType): boolean;
302
302
  }
303
303
 
304
+ declare const dbuAccountConfigSchema: z.ZodObject<{
305
+ with4EyeApproval: z.ZodDefault<z.ZodEnum<{
306
+ Y: "Y";
307
+ N: "N";
308
+ }>>;
309
+ channelCode: z.ZodDefault<z.ZodString>;
310
+ actionTypeCode: z.ZodDefault<z.ZodString>;
311
+ transactionTypeCode: z.ZodDefault<z.ZodString>;
312
+ partialRealization: z.ZodDefault<z.ZodEnum<{
313
+ Y: "Y";
314
+ N: "N";
315
+ }>>;
316
+ forceRealization: z.ZodDefault<z.ZodEnum<{
317
+ Y: "Y";
318
+ N: "N";
319
+ }>>;
320
+ }, z.core.$strip>;
321
+ type DbuAccountConfig = z.infer<typeof dbuAccountConfigSchema>;
322
+ type DbuConnectedAccount = Omit<ConnectedAccount, 'config'> & {
323
+ config: DbuAccountConfig;
324
+ };
304
325
  interface DbuConnectorConfig {
305
326
  BASE_URL: string;
306
327
  USERNAME: string;
@@ -313,7 +334,7 @@ interface DbuConnectorConfig {
313
334
  }
314
335
  declare class DbuConnector extends IBankConnector {
315
336
  connectorKey: ConnectorKey;
316
- connectedAccounts: ConnectedAccount[];
337
+ connectedAccounts: DbuConnectedAccount[];
317
338
  readonly kv: KVNamespace;
318
339
  readonly api: Fetcher;
319
340
  private readonly baseUrl;
@@ -340,6 +361,7 @@ declare class DbuConnector extends IBankConnector {
340
361
  accounts: AccountInsertType[];
341
362
  }>;
342
363
  listAccounts(): Promise<AccountInsertType[]>;
364
+ private resolveAccount;
343
365
  private resolveIdAccountDebit;
344
366
  private resolveAccountDetails;
345
367
  private initiateInstantPayment;
@@ -1340,5 +1362,5 @@ declare function toCompletedPayment(payment: PreparedPayment, status: 'SETTLED'
1340
1362
  declare function toPaymentRequestInsert(payment: AccountAssignedPayment, batchId: string | null): PaymentRequestInsertType;
1341
1363
  declare function toBatchedPaymentFromPaymentRequest(sp: PaymentRequestSelectType): BatchedPayment;
1342
1364
 
1343
- export { AccountAssignedPayment, AccountCredentialsInsertType, AccountInsertType, AccountSelectType, BatchMetadata, BatchedPayment, CompletedPayment, ConnectedAccount, ConnectorKey, CredentialsResolver, CsobConnector, Currency, DbuConnector, ErsteConnector, FINBRICKS_ENDPOINTS, FinbricksAccount, FinbricksClient, FinbricksConnector, IBankConnector, IncomingPayment, IncomingPayment as IncomingPaymentMessage, InitiatedBatch, InitiatedPayment, KBConnector, MockCobsConnector, MockConnector, ParsedBankPayment, PaymentRequestInsertType, PaymentRequestSelectType, PaymentRequestStatus, PaymentSelectType, PaymentType, PreparedPayment, SendPaymentInput, assignAccount, ottInsertSchema, ottSelectSchema, ottUpdateSchema, signFinbricksJws, toBatchedPayment, toBatchedPaymentFromPaymentRequest, toCompletedPayment, toIncomingPayment, toPaymentRequestInsert, toPreparedPayment, useFinbricksFetch };
1344
- export type { BankPaymentEvent, BankPaymentRequestEvent, DbuConnectorConfig, ErsteAuthenticationResponse, ErsteBatchPaymentInitiationResponse, ErsteIncomingPaymentResponse, ErsteObtainAuthorizationURLResponse, ErstePaymentInitiationResponse, FinbricksBatchBody, FinbricksBatchStatus, FinbricksConnectAccountBody, FinbricksConnectorConfig, FinbricksEndpoint, FinbricksEndpointPath, FinbricksFetchConfig, FinbricksForeignPaymentBody, FinbricksGetBatchStatusBody, FinbricksGetBatchStatusResponse, FinbricksGetTransactionStatusResponse, FinbricksJWSData, FinbricksPaymentBody, FinbricksProvider, FinbricksRequestInit, FinbricksSupportedBanksQuery, FinbricksTransactionStatus, OneTimeTokenInsertType, OneTimeTokenPatchType, OneTimeTokenSelectType, OneTimeTokenUpdateType };
1365
+ export { AccountAssignedPayment, AccountCredentialsInsertType, AccountInsertType, AccountSelectType, BatchMetadata, BatchedPayment, CompletedPayment, ConnectedAccount, ConnectorKey, CredentialsResolver, CsobConnector, Currency, DbuConnector, ErsteConnector, FINBRICKS_ENDPOINTS, FinbricksAccount, FinbricksClient, FinbricksConnector, IBankConnector, IncomingPayment, IncomingPayment as IncomingPaymentMessage, InitiatedBatch, InitiatedPayment, KBConnector, MockCobsConnector, MockConnector, ParsedBankPayment, PaymentRequestInsertType, PaymentRequestSelectType, PaymentRequestStatus, PaymentSelectType, PaymentType, PreparedPayment, SendPaymentInput, assignAccount, dbuAccountConfigSchema, ottInsertSchema, ottSelectSchema, ottUpdateSchema, signFinbricksJws, toBatchedPayment, toBatchedPaymentFromPaymentRequest, toCompletedPayment, toIncomingPayment, toPaymentRequestInsert, toPreparedPayment, useFinbricksFetch };
1366
+ export type { BankPaymentEvent, BankPaymentRequestEvent, DbuAccountConfig, DbuConnectorConfig, ErsteAuthenticationResponse, ErsteBatchPaymentInitiationResponse, ErsteIncomingPaymentResponse, ErsteObtainAuthorizationURLResponse, ErstePaymentInitiationResponse, FinbricksBatchBody, FinbricksBatchStatus, FinbricksConnectAccountBody, FinbricksConnectorConfig, FinbricksEndpoint, FinbricksEndpointPath, FinbricksFetchConfig, FinbricksForeignPaymentBody, FinbricksGetBatchStatusBody, FinbricksGetBatchStatusResponse, FinbricksGetTransactionStatusResponse, FinbricksJWSData, FinbricksPaymentBody, FinbricksProvider, FinbricksRequestInit, FinbricksSupportedBanksQuery, FinbricksTransactionStatus, OneTimeTokenInsertType, OneTimeTokenPatchType, OneTimeTokenSelectType, OneTimeTokenUpdateType };