@develit-services/bank 0.8.20 → 1.1.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.
Files changed (37) hide show
  1. package/README.md +33 -0
  2. package/dist/database/schema.cjs +1 -1
  3. package/dist/database/schema.d.cts +2 -1
  4. package/dist/database/schema.d.mts +2 -1
  5. package/dist/database/schema.d.ts +2 -1
  6. package/dist/database/schema.mjs +1 -1
  7. package/dist/export/worker.cjs +6 -6
  8. package/dist/export/worker.d.cts +2083 -939
  9. package/dist/export/worker.d.mts +2083 -939
  10. package/dist/export/worker.d.ts +2083 -939
  11. package/dist/export/worker.mjs +7 -7
  12. package/dist/export/workflows.cjs +5 -5
  13. package/dist/export/workflows.mjs +5 -5
  14. package/dist/export/wrangler.d.cts +2 -1
  15. package/dist/export/wrangler.d.mts +2 -1
  16. package/dist/export/wrangler.d.ts +2 -1
  17. package/dist/shared/{bank.jRGa7MKk.d.mts → bank.5WIfKLgm.d.ts} +890 -17
  18. package/dist/shared/{bank.o95cOH_P.cjs → bank.B5nOIsGC.cjs} +10 -4
  19. package/dist/shared/{bank.BOY6AI1t.d.cts → bank.BECp1kh0.d.cts} +1789 -1627
  20. package/dist/shared/{bank.BOY6AI1t.d.mts → bank.BECp1kh0.d.mts} +1789 -1627
  21. package/dist/shared/{bank.BOY6AI1t.d.ts → bank.BECp1kh0.d.ts} +1789 -1627
  22. package/dist/shared/{bank.DWsHTK_n.cjs → bank.BMLgGhBY.cjs} +44 -8
  23. package/dist/shared/{bank.DMjtitKo.d.cts → bank.CVJosema.d.cts} +1 -0
  24. package/dist/shared/{bank.DMjtitKo.d.mts → bank.CVJosema.d.mts} +1 -0
  25. package/dist/shared/{bank.DMjtitKo.d.ts → bank.CVJosema.d.ts} +1 -0
  26. package/dist/shared/{bank.DfTdMAi9.d.ts → bank.CX7-ohgB.d.mts} +890 -17
  27. package/dist/shared/{bank.ESTBT4J6.mjs → bank.DMsXwzJn.mjs} +11 -5
  28. package/dist/shared/{bank.Cwg6oHMM.mjs → bank.DTnA4eC9.mjs} +44 -8
  29. package/dist/shared/{bank.vGCuP898.cjs → bank.f7ykgYdD.cjs} +7 -3
  30. package/dist/shared/{bank.CPLR0Ul7.mjs → bank.rcoRRywt.mjs} +7 -3
  31. package/dist/shared/{bank.Bo01T_MM.d.cts → bank.yUQZ6PWV.d.cts} +890 -17
  32. package/dist/types.cjs +2 -2
  33. package/dist/types.d.cts +13 -8
  34. package/dist/types.d.mts +13 -8
  35. package/dist/types.d.ts +13 -8
  36. package/dist/types.mjs +2 -2
  37. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { bankAccount, base } from '@develit-io/backend-sdk';
1
+ import { bankAccount, base, structuredAddressSchema } from '@develit-io/backend-sdk';
2
2
  import { sqliteTable, text, integer, unique, real, index } from 'drizzle-orm/sqlite-core';
3
3
  import 'date-fns';
4
4
  import 'jose';
@@ -123,9 +123,15 @@ const account = sqliteTable(
123
123
  (t) => [unique().on(t.iban)]
124
124
  );
125
125
 
126
- const accountInsertSchema = createInsertSchema(account);
127
- const accountUpdateSchema = createUpdateSchema(account);
128
- const accountSelectSchema = createSelectSchema(account);
126
+ const accountInsertSchema = createInsertSchema(account).extend({
127
+ address: structuredAddressSchema.nullable().optional()
128
+ });
129
+ const accountUpdateSchema = createUpdateSchema(account).extend({
130
+ address: structuredAddressSchema.nullable().optional()
131
+ });
132
+ const accountSelectSchema = createSelectSchema(account).extend({
133
+ address: structuredAddressSchema.nullable().optional()
134
+ });
129
135
 
130
136
  const accountCredentials = sqliteTable("account_credentials", {
131
137
  ...base,
@@ -218,7 +224,7 @@ const payment = sqliteTable(
218
224
  debtorIban: text("debtor_iban")
219
225
  },
220
226
  (t) => [
221
- unique().on(t.connectorKey, t.bankRefId),
227
+ unique().on(t.connectorKey, t.accountId, t.bankRefId),
222
228
  index("payment_account_id_idx").on(t.accountId),
223
229
  index("payment_account_id_status_idx").on(t.accountId, t.status),
224
230
  index("payment_account_id_created_at_idx").on(t.accountId, t.createdAt),
@@ -1,7 +1,7 @@
1
1
  import { uuidv4, createInternalError, useResult } from '@develit-io/backend-sdk';
2
2
  import { format, parseISO } from 'date-fns';
3
3
  import { CURRENCY_CODES } from '@develit-io/general-codes';
4
- import './bank.ESTBT4J6.mjs';
4
+ import './bank.DMsXwzJn.mjs';
5
5
  import 'drizzle-orm';
6
6
  import { importPKCS8, SignJWT } from 'jose';
7
7
  import 'node:crypto';
@@ -478,7 +478,7 @@ const mapFinbricksTransactionToPayment = (tx, account) => {
478
478
  correlationId: uuidv4(),
479
479
  connectorKey: account.connectorKey,
480
480
  accountId: account.id,
481
- bankRefId: tx.fbxReference,
481
+ bankRefId: tx.fbxReference ?? tx.entryReference,
482
482
  amount: tx.amount?.value || 0,
483
483
  currency: tx.amount?.currency || "CZK",
484
484
  paymentType: detectPaymentType(tx, isIncoming),
@@ -496,7 +496,14 @@ const mapFinbricksTransactionToPayment = (tx, account) => {
496
496
  )[0] : account.number || void 0,
497
497
  bankCode: isIncoming ? account.bankCode || void 0 : related?.creditorAccount?.identification?.other?.identification ? related.creditorAccount.identification.other.identification.split(
498
498
  "/"
499
- )[1] : account.bankCode || void 0
499
+ )[1] : account.bankCode || void 0,
500
+ address: related?.creditor?.postalAddress ? {
501
+ streetName: related.creditor.postalAddress.streetName,
502
+ buildingNumber: related.creditor.postalAddress.buildingNumber,
503
+ city: related.creditor.postalAddress.townName,
504
+ postalCode: related.creditor.postalAddress.postCode,
505
+ countryCode: related.creditor.postalAddress.country
506
+ } : void 0
500
507
  },
501
508
  debtor: {
502
509
  holderName: related?.debtorAccount?.name || related?.debtor?.name || "Unknown",
@@ -506,7 +513,14 @@ const mapFinbricksTransactionToPayment = (tx, account) => {
506
513
  )[0] : account.number || void 0 : account.number || void 0,
507
514
  bankCode: isIncoming ? related?.debtorAccount?.identification?.other?.identification ? related.debtorAccount.identification.other.identification.split(
508
515
  "/"
509
- )[1] : account.bankCode || void 0 : account.bankCode || void 0
516
+ )[1] : account.bankCode || void 0 : account.bankCode || void 0,
517
+ address: related?.debtor?.postalAddress ? {
518
+ streetName: related.debtor.postalAddress.streetName,
519
+ buildingNumber: related.debtor.postalAddress.buildingNumber,
520
+ city: related.debtor.postalAddress.townName,
521
+ postalCode: related.debtor.postalAddress.postCode,
522
+ countryCode: related.debtor.postalAddress.country
523
+ } : void 0
510
524
  },
511
525
  direction: isIncoming ? "INCOMING" : "OUTGOING"
512
526
  };
@@ -520,6 +534,15 @@ function autoVariableSymbol(paymentId) {
520
534
  }
521
535
  return String(Math.abs(hash) % 1e10).padStart(10, "0");
522
536
  }
537
+ function mapToFinbricksAddress(addr) {
538
+ if (!addr) return void 0;
539
+ return {
540
+ ...addr.streetName && { streetName: addr.streetName },
541
+ ...addr.buildingNumber && { buildingNumber: addr.buildingNumber },
542
+ ...addr.city && { town: addr.city },
543
+ ...addr.countryCode && { country: addr.countryCode }
544
+ };
545
+ }
523
546
  class FinbricksConnector extends IBankConnector {
524
547
  constructor(provider, {
525
548
  BASE_URI,
@@ -767,6 +790,7 @@ class FinbricksConnector extends IBankConnector {
767
790
  (acc) => acc.iban === payment.debtorIban
768
791
  );
769
792
  const clientId = await this.getClientId(debtorAccount.id);
793
+ const creditorAddress = mapToFinbricksAddress(payment.creditor.address);
770
794
  const bankRefId = uuidv4();
771
795
  const [response, error] = await useResult(
772
796
  this.finbricks.request({
@@ -798,7 +822,8 @@ class FinbricksConnector extends IBankConnector {
798
822
  type: "IBAN",
799
823
  value: payment.creditor.iban
800
824
  },
801
- creditorName: payment.creditor.holderName || ""
825
+ creditorName: payment.creditor.holderName || "",
826
+ ...creditorAddress && { postalAddress: creditorAddress }
802
827
  },
803
828
  callbackUrl: `${this.finbricks.REDIRECT_URI}?type=paymentRequest&paymentRequestId=${payment.id}`
804
829
  }
@@ -830,6 +855,7 @@ class FinbricksConnector extends IBankConnector {
830
855
  (acc) => acc.iban === payment.debtorIban
831
856
  );
832
857
  const clientId = await this.getClientId(debtorAccount.id);
858
+ const creditorAddress = mapToFinbricksAddress(payment.creditor.address);
833
859
  const bankRefId = uuidv4();
834
860
  const [response, error] = await useResult(
835
861
  this.finbricks.request({
@@ -852,7 +878,8 @@ class FinbricksConnector extends IBankConnector {
852
878
  },
853
879
  creditor: {
854
880
  creditorAccountIban: payment.creditor.iban,
855
- creditorName: payment.creditor.holderName
881
+ creditorName: payment.creditor.holderName,
882
+ ...creditorAddress && { postalAddress: creditorAddress }
856
883
  },
857
884
  callbackUrl: `${this.finbricks.REDIRECT_URI}?type=paymentRequest&paymentRequestId=${payment.id}`
858
885
  }
@@ -1212,6 +1239,7 @@ const initiateConnector = async ({
1212
1239
  return new DbuConnector({
1213
1240
  BASE_URL: env.DBUCS_BASE_URI,
1214
1241
  USERNAME: env.DBUCS_USERNAME,
1242
+ APPLICATION_CODE: env.DBUCS_APPLICATION_CODE,
1215
1243
  KV: env.BANK_KV,
1216
1244
  API: env.DBU_CBS_BACKOFFICE_DEV,
1217
1245
  REDIRECT_URI: env.REDIRECT_URI,
@@ -1271,6 +1299,7 @@ class DbuConnector extends IBankConnector {
1271
1299
  constructor({
1272
1300
  BASE_URL,
1273
1301
  USERNAME,
1302
+ APPLICATION_CODE,
1274
1303
  KV,
1275
1304
  API,
1276
1305
  REDIRECT_URI,
@@ -1282,6 +1311,7 @@ class DbuConnector extends IBankConnector {
1282
1311
  this.connectedAccounts = [];
1283
1312
  this.baseUrl = BASE_URL;
1284
1313
  this.username = USERNAME;
1314
+ this.applicationCode = APPLICATION_CODE;
1285
1315
  this.kv = KV;
1286
1316
  this.api = API;
1287
1317
  this.redirectUri = REDIRECT_URI;
@@ -1381,11 +1411,13 @@ class DbuConnector extends IBankConnector {
1381
1411
  number: transaction.accountNumberCredit,
1382
1412
  bankCode: transaction.bankCodeCredit,
1383
1413
  iban: creditorIban
1414
+ // Note: DBU API does not provide address data in transaction responses
1384
1415
  },
1385
1416
  debtor: {
1386
1417
  number: transaction.accountNumberDebit,
1387
1418
  bankCode: transaction.bankCodeDebit,
1388
1419
  iban: debtorIban
1420
+ // Note: DBU API does not provide address data in transaction responses
1389
1421
  },
1390
1422
  debtorIban
1391
1423
  };
@@ -1543,7 +1575,8 @@ class DbuConnector extends IBankConnector {
1543
1575
  specSymbol: payment.ss,
1544
1576
  constSymbol: payment.ks,
1545
1577
  uniqueExternalId: payment.id,
1546
- standardPaymentFallback: "N"
1578
+ standardPaymentFallback: "N",
1579
+ applicationCode: this.applicationCode
1547
1580
  };
1548
1581
  const response = await this.makeRequest(
1549
1582
  "/required-transactions/instant-payments",
@@ -1590,7 +1623,8 @@ class DbuConnector extends IBankConnector {
1590
1623
  specSymbol: payment.ss,
1591
1624
  constSymbol: payment.ks,
1592
1625
  uniqueExternalId: payment.id,
1593
- with4EyeApproval: "Y"
1626
+ with4EyeApproval: "Y",
1627
+ applicationCode: this.applicationCode
1594
1628
  };
1595
1629
  const response = await this.makeRequest(
1596
1630
  "/required-transactions",
@@ -2009,6 +2043,7 @@ class ErsteConnector extends IBankConnector {
2009
2043
  bankCode: payment.entryDetails.transactionDetails.relatedParties.debtorAccount?.identification.other?.identification ? payment.entryDetails.transactionDetails.relatedParties.debtorAccount.identification.other.identification.split(
2010
2044
  "/"
2011
2045
  )[1] : void 0
2046
+ // Note: Erste API does not provide postalAddress in transaction responses
2012
2047
  },
2013
2048
  creditor: {
2014
2049
  holderName: payment.entryDetails.transactionDetails.relatedParties.creditor?.name,
@@ -2019,6 +2054,7 @@ class ErsteConnector extends IBankConnector {
2019
2054
  bankCode: payment.entryDetails.transactionDetails.relatedParties.creditorAccount?.identification.other?.identification ? payment.entryDetails.transactionDetails.relatedParties.creditorAccount.identification.other.identification.split(
2020
2055
  "/"
2021
2056
  )[1] : void 0
2057
+ // Note: Erste API does not provide postalAddress in transaction responses
2022
2058
  },
2023
2059
  paymentType: "DOMESTIC",
2024
2060
  direction: "INCOMING",
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const drizzleOrm = require('drizzle-orm');
4
- const database_schema = require('./bank.o95cOH_P.cjs');
4
+ const database_schema = require('./bank.B5nOIsGC.cjs');
5
5
  const backendSdk = require('@develit-io/backend-sdk');
6
6
  require('date-fns');
7
7
  require('jose');
@@ -15,8 +15,12 @@ const createPaymentCommand = (db, { payment }) => {
15
15
  creditorIban: payment.creditor.iban,
16
16
  debtorIban: payment.debtor.iban
17
17
  }).onConflictDoUpdate({
18
- // Unique index: (connector_key, bank_ref_id)
19
- target: [database_schema.tables.payment.connectorKey, database_schema.tables.payment.bankRefId],
18
+ // Unique index: (connector_key, account_id, bank_ref_id)
19
+ target: [
20
+ database_schema.tables.payment.connectorKey,
21
+ database_schema.tables.payment.accountId,
22
+ database_schema.tables.payment.bankRefId
23
+ ],
20
24
  set: {
21
25
  status: drizzleOrm.sql`excluded.status`,
22
26
  statusReason: drizzleOrm.sql`excluded.status_reason`,
@@ -1,5 +1,5 @@
1
1
  import { sql, and, eq, isNull } from 'drizzle-orm';
2
- import { v as tables } from './bank.ESTBT4J6.mjs';
2
+ import { v as tables } from './bank.DMsXwzJn.mjs';
3
3
  import { uuidv4 } from '@develit-io/backend-sdk';
4
4
  import 'date-fns';
5
5
  import 'jose';
@@ -13,8 +13,12 @@ const createPaymentCommand = (db, { payment }) => {
13
13
  creditorIban: payment.creditor.iban,
14
14
  debtorIban: payment.debtor.iban
15
15
  }).onConflictDoUpdate({
16
- // Unique index: (connector_key, bank_ref_id)
17
- target: [tables.payment.connectorKey, tables.payment.bankRefId],
16
+ // Unique index: (connector_key, account_id, bank_ref_id)
17
+ target: [
18
+ tables.payment.connectorKey,
19
+ tables.payment.accountId,
20
+ tables.payment.bankRefId
21
+ ],
18
22
  set: {
19
23
  status: sql`excluded.status`,
20
24
  statusReason: sql`excluded.status_reason`,