@develit-services/bank 5.2.2 → 5.3.1

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/base.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const backendSdk = require('@develit-io/backend-sdk');
4
- const bank = require('./shared/bank.R64Uwo7k.cjs');
4
+ const bank = require('./shared/bank.CV8QTlfT.cjs');
5
5
  const drizzleOrm = require('drizzle-orm');
6
6
  const cloudflare_workers = require('cloudflare:workers');
7
7
  const d1 = require('drizzle-orm/d1');
@@ -11,7 +11,7 @@ const database_schema = require('./shared/bank.9Yw4KHyl.cjs');
11
11
  const generalCodes = require('@develit-io/general-codes');
12
12
  require('date-fns');
13
13
  require('node:crypto');
14
- const credentialsResolver = require('./shared/bank.d0MTVrcR.cjs');
14
+ const credentialsResolver = require('./shared/bank.BeyJhLoh.cjs');
15
15
  require('drizzle-orm/zod');
16
16
  require('drizzle-orm/sqlite-core');
17
17
 
package/dist/base.d.cts CHANGED
@@ -2825,9 +2825,9 @@ declare const getPaymentsInputSchema: z.ZodObject<{
2825
2825
  limit: z.ZodNumber;
2826
2826
  sort: z.ZodObject<{
2827
2827
  column: z.ZodEnum<{
2828
- amount: "amount";
2829
2828
  createdAt: "createdAt";
2830
2829
  updatedAt: "updatedAt";
2830
+ amount: "amount";
2831
2831
  }>;
2832
2832
  direction: z.ZodEnum<{
2833
2833
  asc: "asc";
@@ -3875,9 +3875,9 @@ declare const getPaymentRequestsInputSchema: z.ZodObject<{
3875
3875
  limit: z.ZodNumber;
3876
3876
  sort: z.ZodObject<{
3877
3877
  column: z.ZodEnum<{
3878
- amount: "amount";
3879
3878
  createdAt: "createdAt";
3880
3879
  updatedAt: "updatedAt";
3880
+ amount: "amount";
3881
3881
  }>;
3882
3882
  direction: z.ZodEnum<{
3883
3883
  asc: "asc";
package/dist/base.d.mts CHANGED
@@ -2825,9 +2825,9 @@ declare const getPaymentsInputSchema: z.ZodObject<{
2825
2825
  limit: z.ZodNumber;
2826
2826
  sort: z.ZodObject<{
2827
2827
  column: z.ZodEnum<{
2828
- amount: "amount";
2829
2828
  createdAt: "createdAt";
2830
2829
  updatedAt: "updatedAt";
2830
+ amount: "amount";
2831
2831
  }>;
2832
2832
  direction: z.ZodEnum<{
2833
2833
  asc: "asc";
@@ -3875,9 +3875,9 @@ declare const getPaymentRequestsInputSchema: z.ZodObject<{
3875
3875
  limit: z.ZodNumber;
3876
3876
  sort: z.ZodObject<{
3877
3877
  column: z.ZodEnum<{
3878
- amount: "amount";
3879
3878
  createdAt: "createdAt";
3880
3879
  updatedAt: "updatedAt";
3880
+ amount: "amount";
3881
3881
  }>;
3882
3882
  direction: z.ZodEnum<{
3883
3883
  asc: "asc";
package/dist/base.d.ts CHANGED
@@ -2825,9 +2825,9 @@ declare const getPaymentsInputSchema: z.ZodObject<{
2825
2825
  limit: z.ZodNumber;
2826
2826
  sort: z.ZodObject<{
2827
2827
  column: z.ZodEnum<{
2828
- amount: "amount";
2829
2828
  createdAt: "createdAt";
2830
2829
  updatedAt: "updatedAt";
2830
+ amount: "amount";
2831
2831
  }>;
2832
2832
  direction: z.ZodEnum<{
2833
2833
  asc: "asc";
@@ -3875,9 +3875,9 @@ declare const getPaymentRequestsInputSchema: z.ZodObject<{
3875
3875
  limit: z.ZodNumber;
3876
3876
  sort: z.ZodObject<{
3877
3877
  column: z.ZodEnum<{
3878
- amount: "amount";
3879
3878
  createdAt: "createdAt";
3880
3879
  updatedAt: "updatedAt";
3880
+ amount: "amount";
3881
3881
  }>;
3882
3882
  direction: z.ZodEnum<{
3883
3883
  asc: "asc";
package/dist/base.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { uuidv4, first, buildMultiFilterConditions as buildMultiFilterConditions$1, bankAccountMetadataSchema, structuredAddressSchema, workflowInstanceStatusSchema, develitWorker, createInternalError, action, service } from '@develit-io/backend-sdk';
2
- import { G as tables, g as accountInsertSchema, H as relations, J as initiateConnector, o as isProcessedStatus, p as isTerminalStatus, L as getNonTerminalPaymentRequestsQuery, x as toIncomingPayment, N as calculateCzechIban, j as assignAccount, u as toBatchedPayment, y as toPaymentRequestInsert, a as FinbricksClient, F as FINBRICKS_ENDPOINTS } from './shared/bank.Cg2epnnD.mjs';
2
+ import { G as tables, g as accountInsertSchema, H as relations, J as initiateConnector, o as isProcessedStatus, p as isTerminalStatus, L as getNonTerminalPaymentRequestsQuery, x as toIncomingPayment, N as calculateCzechIban, j as assignAccount, u as toBatchedPayment, y as toPaymentRequestInsert, a as FinbricksClient, F as FINBRICKS_ENDPOINTS } from './shared/bank.DhMbV8-X.mjs';
3
3
  import { eq, sql, and, like, asc, desc, inArray, gte, lte, isNull, count } from 'drizzle-orm';
4
4
  import { WorkerEntrypoint } from 'cloudflare:workers';
5
5
  import { drizzle } from 'drizzle-orm/d1';
@@ -9,7 +9,7 @@ import { I as INSTRUCTION_PRIORITIES, C as CHARGE_BEARERS, g as PAYMENT_TYPES, b
9
9
  import { CURRENCY_CODES } from '@develit-io/general-codes';
10
10
  import 'date-fns';
11
11
  import 'node:crypto';
12
- import { h as encrypt, d as createCredentialsResolver, e as updatePaymentRequestStatusCommand, a as getPaymentRequestsByBatchIdQuery, g as getBatchByIdQuery, u as upsertBatchCommand, i as importAesKey, f as createPaymentCommand, b as getAccountByIdQuery } from './shared/bank.5RiBQTe0.mjs';
12
+ import { h as encrypt, d as createCredentialsResolver, e as updatePaymentRequestStatusCommand, a as getPaymentRequestsByBatchIdQuery, g as getBatchByIdQuery, u as upsertBatchCommand, i as importAesKey, f as createPaymentCommand, b as getAccountByIdQuery } from './shared/bank.CBmzxkLV.mjs';
13
13
  import 'drizzle-orm/zod';
14
14
  import 'drizzle-orm/sqlite-core';
15
15
 
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  const backendSdk = require('@develit-io/backend-sdk');
4
- const bank = require('../shared/bank.R64Uwo7k.cjs');
4
+ const bank = require('../shared/bank.CV8QTlfT.cjs');
5
5
  const batchLifecycle = require('../shared/bank.NF8bZBy0.cjs');
6
6
  const drizzleOrm = require('drizzle-orm');
7
- const credentialsResolver = require('../shared/bank.d0MTVrcR.cjs');
7
+ const credentialsResolver = require('../shared/bank.BeyJhLoh.cjs');
8
8
  const cloudflare_workers = require('cloudflare:workers');
9
9
  const cloudflare_workflows = require('cloudflare:workflows');
10
10
  const d1 = require('drizzle-orm/d1');
@@ -1,8 +1,8 @@
1
1
  import { first, uuidv4, asNonEmpty } from '@develit-io/backend-sdk';
2
- import { G as tables, H as relations, v as toBatchedPaymentFromPaymentRequest, z as toPreparedPayment, J as initiateConnector, m as isPaymentCompleted } from '../shared/bank.Cg2epnnD.mjs';
2
+ import { G as tables, H as relations, v as toBatchedPaymentFromPaymentRequest, z as toPreparedPayment, J as initiateConnector, m as isPaymentCompleted } from '../shared/bank.DhMbV8-X.mjs';
3
3
  import { i as isBatchAuthorized, b as isBatchFailed, d as isBatchProcessing } from '../shared/bank.XqSw509X.mjs';
4
4
  import { eq, and, inArray } from 'drizzle-orm';
5
- import { g as getBatchByIdQuery, a as getPaymentRequestsByBatchIdQuery, c as checksum, u as upsertBatchCommand, b as getAccountByIdQuery, d as createCredentialsResolver, e as updatePaymentRequestStatusCommand, f as createPaymentCommand } from '../shared/bank.5RiBQTe0.mjs';
5
+ import { g as getBatchByIdQuery, a as getPaymentRequestsByBatchIdQuery, c as checksum, u as upsertBatchCommand, b as getAccountByIdQuery, d as createCredentialsResolver, e as updatePaymentRequestStatusCommand, f as createPaymentCommand } from '../shared/bank.CBmzxkLV.mjs';
6
6
  import { WorkflowEntrypoint } from 'cloudflare:workers';
7
7
  import { NonRetryableError } from 'cloudflare:workflows';
8
8
  import { drizzle } from 'drizzle-orm/d1';
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const drizzleOrm = require('drizzle-orm');
4
- const bank = require('./bank.R64Uwo7k.cjs');
4
+ const bank = require('./bank.CV8QTlfT.cjs');
5
5
  const backendSdk = require('@develit-io/backend-sdk');
6
6
  require('./bank.9Yw4KHyl.cjs');
7
7
  require('date-fns');
@@ -1,5 +1,5 @@
1
1
  import { sql, and, eq, isNull } from 'drizzle-orm';
2
- import { G as tables } from './bank.Cg2epnnD.mjs';
2
+ import { G as tables } from './bank.DhMbV8-X.mjs';
3
3
  import { uuidv4 } from '@develit-io/backend-sdk';
4
4
  import './bank.BzDNLxB_.mjs';
5
5
  import 'date-fns';
@@ -332,6 +332,32 @@ function buildPaymentReference(symbols) {
332
332
  return parts.join("").slice(0, MAX_REFERENCE_LENGTH);
333
333
  }
334
334
 
335
+ const MAX_FIELD_LENGTH = 140;
336
+ const COUNTRY_NAMES = {
337
+ CZ: "\u010Cesk\xE1 republika",
338
+ SK: "Slovensko"
339
+ };
340
+ const stripDiacritics = (value) => value.normalize("NFD").replace(/\p{Diacritic}/gu, "");
341
+ function buildUltimateCreditor(creditor, options) {
342
+ const address = creditor.address;
343
+ const street = [address?.streetName, address?.buildingNumber].filter(Boolean).join(" ");
344
+ if (!creditor.holderName || !street) return void 0;
345
+ const cityLine = [address?.postalCode, address?.city].filter(Boolean).join(" ");
346
+ const countryCode = address?.countryCode ?? creditor.countryCode;
347
+ const country = countryCode ? COUNTRY_NAMES[countryCode] ?? countryCode : void 0;
348
+ const udt = `UDT: ${[creditor.holderName, street, cityLine, country].filter(Boolean).join("::")}`;
349
+ return options.stripDiacritics ? stripDiacritics(udt) : udt;
350
+ }
351
+ function composeWithUltimateCreditor(existing, creditor, options) {
352
+ const udt = buildUltimateCreditor(creditor, options);
353
+ if (!udt) return existing?.slice(0, MAX_FIELD_LENGTH) || void 0;
354
+ const prefix = existing?.trim();
355
+ if (!prefix) return udt.slice(0, MAX_FIELD_LENGTH);
356
+ const room = MAX_FIELD_LENGTH - udt.length - 2;
357
+ if (room <= 0) return udt.slice(0, MAX_FIELD_LENGTH);
358
+ return `${prefix.slice(0, room)}, ${udt}`;
359
+ }
360
+
335
361
  const SYMBOL_LIMITS = { vs: 10, ss: 10, ks: 4 };
336
362
  function assertSymbolLength(symbol, value) {
337
363
  const max = SYMBOL_LIMITS[symbol];
@@ -931,7 +957,9 @@ class FinbricksConnector extends IBankConnector {
931
957
  variableSymbol: p.vs ?? (p.ss ? void 0 : autoVariableSymbol(p.id)),
932
958
  specificSymbol: p.ss,
933
959
  constantSymbol: p.ks,
934
- description: p.message
960
+ description: this.PROVIDER === "CSOB" ? composeWithUltimateCreditor(p.message, p.creditor, {
961
+ stripDiacritics: p.currency !== "CZK"
962
+ }) : p.message
935
963
  // instructionPriority: 'NORM', todo(kleinpetr): pass payment priority
936
964
  }))
937
965
  }
@@ -976,7 +1004,10 @@ class FinbricksConnector extends IBankConnector {
976
1004
  ss: payment.ss,
977
1005
  ks: payment.ks
978
1006
  });
979
- const unstructured = [reference, payment.message?.trim()].filter(Boolean).join(" ").slice(0, 140) || void 0;
1007
+ const remittanceBase = [reference, payment.message?.trim()].filter(Boolean).join(" ") || void 0;
1008
+ const unstructured = this.PROVIDER === "CSOB" ? composeWithUltimateCreditor(remittanceBase, payment.creditor, {
1009
+ stripDiacritics: payment.currency !== "CZK"
1010
+ }) : remittanceBase?.slice(0, 140) || void 0;
980
1011
  const bankRefId = backendSdk.uuidv4();
981
1012
  const [response, error] = await backendSdk.useResult(
982
1013
  this.finbricks.request({
@@ -1039,7 +1070,12 @@ class FinbricksConnector extends IBankConnector {
1039
1070
  const clientId = await this.getClientId(debtorAccount.id);
1040
1071
  const creditorAddress = mapToFinbricksAddress(payment.creditor.address);
1041
1072
  const message = payment.message?.trim() ?? "";
1042
- const unstructured = message.length >= 3 ? message.slice(0, 140) : "Platba";
1073
+ const reference = buildPaymentReference({
1074
+ vs: payment.vs,
1075
+ ss: payment.ss,
1076
+ ks: payment.ks
1077
+ });
1078
+ const unstructured = (message.length >= 3 ? message : reference || "Platba").slice(0, 140);
1043
1079
  const bankRefId = backendSdk.uuidv4();
1044
1080
  const [response, error] = await backendSdk.useResult(
1045
1081
  this.finbricks.request({
@@ -1106,7 +1142,9 @@ class FinbricksConnector extends IBankConnector {
1106
1142
  debtorAccountIban: payment.debtor.iban,
1107
1143
  creditorAccountIban: payment.creditor.iban,
1108
1144
  creditorName: payment.creditor.holderName,
1109
- description: payment.message,
1145
+ description: this.PROVIDER === "CSOB" ? composeWithUltimateCreditor(payment.message, payment.creditor, {
1146
+ stripDiacritics: payment.currency !== "CZK"
1147
+ }) : payment.message,
1110
1148
  variableSymbol: payment.vs ?? (payment.ss ? void 0 : autoVariableSymbol(payment.id)),
1111
1149
  specificSymbol: payment.ss,
1112
1150
  constantSymbol: payment.ks,
@@ -330,6 +330,32 @@ function buildPaymentReference(symbols) {
330
330
  return parts.join("").slice(0, MAX_REFERENCE_LENGTH);
331
331
  }
332
332
 
333
+ const MAX_FIELD_LENGTH = 140;
334
+ const COUNTRY_NAMES = {
335
+ CZ: "\u010Cesk\xE1 republika",
336
+ SK: "Slovensko"
337
+ };
338
+ const stripDiacritics = (value) => value.normalize("NFD").replace(/\p{Diacritic}/gu, "");
339
+ function buildUltimateCreditor(creditor, options) {
340
+ const address = creditor.address;
341
+ const street = [address?.streetName, address?.buildingNumber].filter(Boolean).join(" ");
342
+ if (!creditor.holderName || !street) return void 0;
343
+ const cityLine = [address?.postalCode, address?.city].filter(Boolean).join(" ");
344
+ const countryCode = address?.countryCode ?? creditor.countryCode;
345
+ const country = countryCode ? COUNTRY_NAMES[countryCode] ?? countryCode : void 0;
346
+ const udt = `UDT: ${[creditor.holderName, street, cityLine, country].filter(Boolean).join("::")}`;
347
+ return options.stripDiacritics ? stripDiacritics(udt) : udt;
348
+ }
349
+ function composeWithUltimateCreditor(existing, creditor, options) {
350
+ const udt = buildUltimateCreditor(creditor, options);
351
+ if (!udt) return existing?.slice(0, MAX_FIELD_LENGTH) || void 0;
352
+ const prefix = existing?.trim();
353
+ if (!prefix) return udt.slice(0, MAX_FIELD_LENGTH);
354
+ const room = MAX_FIELD_LENGTH - udt.length - 2;
355
+ if (room <= 0) return udt.slice(0, MAX_FIELD_LENGTH);
356
+ return `${prefix.slice(0, room)}, ${udt}`;
357
+ }
358
+
333
359
  const SYMBOL_LIMITS = { vs: 10, ss: 10, ks: 4 };
334
360
  function assertSymbolLength(symbol, value) {
335
361
  const max = SYMBOL_LIMITS[symbol];
@@ -929,7 +955,9 @@ class FinbricksConnector extends IBankConnector {
929
955
  variableSymbol: p.vs ?? (p.ss ? void 0 : autoVariableSymbol(p.id)),
930
956
  specificSymbol: p.ss,
931
957
  constantSymbol: p.ks,
932
- description: p.message
958
+ description: this.PROVIDER === "CSOB" ? composeWithUltimateCreditor(p.message, p.creditor, {
959
+ stripDiacritics: p.currency !== "CZK"
960
+ }) : p.message
933
961
  // instructionPriority: 'NORM', todo(kleinpetr): pass payment priority
934
962
  }))
935
963
  }
@@ -974,7 +1002,10 @@ class FinbricksConnector extends IBankConnector {
974
1002
  ss: payment.ss,
975
1003
  ks: payment.ks
976
1004
  });
977
- const unstructured = [reference, payment.message?.trim()].filter(Boolean).join(" ").slice(0, 140) || void 0;
1005
+ const remittanceBase = [reference, payment.message?.trim()].filter(Boolean).join(" ") || void 0;
1006
+ const unstructured = this.PROVIDER === "CSOB" ? composeWithUltimateCreditor(remittanceBase, payment.creditor, {
1007
+ stripDiacritics: payment.currency !== "CZK"
1008
+ }) : remittanceBase?.slice(0, 140) || void 0;
978
1009
  const bankRefId = uuidv4();
979
1010
  const [response, error] = await useResult(
980
1011
  this.finbricks.request({
@@ -1037,7 +1068,12 @@ class FinbricksConnector extends IBankConnector {
1037
1068
  const clientId = await this.getClientId(debtorAccount.id);
1038
1069
  const creditorAddress = mapToFinbricksAddress(payment.creditor.address);
1039
1070
  const message = payment.message?.trim() ?? "";
1040
- const unstructured = message.length >= 3 ? message.slice(0, 140) : "Platba";
1071
+ const reference = buildPaymentReference({
1072
+ vs: payment.vs,
1073
+ ss: payment.ss,
1074
+ ks: payment.ks
1075
+ });
1076
+ const unstructured = (message.length >= 3 ? message : reference || "Platba").slice(0, 140);
1041
1077
  const bankRefId = uuidv4();
1042
1078
  const [response, error] = await useResult(
1043
1079
  this.finbricks.request({
@@ -1104,7 +1140,9 @@ class FinbricksConnector extends IBankConnector {
1104
1140
  debtorAccountIban: payment.debtor.iban,
1105
1141
  creditorAccountIban: payment.creditor.iban,
1106
1142
  creditorName: payment.creditor.holderName,
1107
- description: payment.message,
1143
+ description: this.PROVIDER === "CSOB" ? composeWithUltimateCreditor(payment.message, payment.creditor, {
1144
+ stripDiacritics: payment.currency !== "CZK"
1145
+ }) : payment.message,
1108
1146
  variableSymbol: payment.vs ?? (payment.ss ? void 0 : autoVariableSymbol(payment.id)),
1109
1147
  specificSymbol: payment.ss,
1110
1148
  constantSymbol: payment.ks,
package/dist/types.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const bank = require('./shared/bank.R64Uwo7k.cjs');
3
+ const bank = require('./shared/bank.CV8QTlfT.cjs');
4
4
  const database_schema = require('./shared/bank.9Yw4KHyl.cjs');
5
5
  const batchLifecycle = require('./shared/bank.NF8bZBy0.cjs');
6
6
  const generalCodes = require('@develit-io/general-codes');
package/dist/types.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { B as BASE_TERMINAL_STATUSES, C as CsobConnector, D as DbuConnector, E as ErsteConnector, F as FINBRICKS_ENDPOINTS, a as FinbricksClient, b as FinbricksConnector, I as IBankConnector, K as KBConnector, M as MockCobsConnector, c as MockConnector, d as accountCredentialsInsertSchema, e as accountCredentialsSelectSchema, f as accountCredentialsUpdateSchema, g as accountInsertSchema, h as accountSelectSchema, i as accountUpdateSchema, j as assignAccount, k as dbuAccountConfigSchema, l as hasPaymentAccountAssigned, m as isPaymentCompleted, n as isPendingStatus, o as isProcessedStatus, p as isTerminalStatus, q as ottInsertSchema, r as ottSelectSchema, s as ottUpdateSchema, t as signFinbricksJws, u as toBatchedPayment, v as toBatchedPaymentFromPaymentRequest, w as toCompletedPayment, x as toIncomingPayment, y as toPaymentRequestInsert, z as toPreparedPayment, A as useFinbricksFetch } from './shared/bank.Cg2epnnD.mjs';
1
+ export { B as BASE_TERMINAL_STATUSES, C as CsobConnector, D as DbuConnector, E as ErsteConnector, F as FINBRICKS_ENDPOINTS, a as FinbricksClient, b as FinbricksConnector, I as IBankConnector, K as KBConnector, M as MockCobsConnector, c as MockConnector, d as accountCredentialsInsertSchema, e as accountCredentialsSelectSchema, f as accountCredentialsUpdateSchema, g as accountInsertSchema, h as accountSelectSchema, i as accountUpdateSchema, j as assignAccount, k as dbuAccountConfigSchema, l as hasPaymentAccountAssigned, m as isPaymentCompleted, n as isPendingStatus, o as isProcessedStatus, p as isTerminalStatus, q as ottInsertSchema, r as ottSelectSchema, s as ottUpdateSchema, t as signFinbricksJws, u as toBatchedPayment, v as toBatchedPaymentFromPaymentRequest, w as toCompletedPayment, x as toIncomingPayment, y as toPaymentRequestInsert, z as toPreparedPayment, A as useFinbricksFetch } from './shared/bank.DhMbV8-X.mjs';
2
2
  export { A as ACCOUNT_STATUSES, B as BATCH_MODES, a as BATCH_STATUES, a as BATCH_STATUSES, C as CHARGE_BEARERS, b as CONNECTOR_KEYS, c as COUNTRY_CODES, d as CREDENTIALS_TYPES, I as INSTRUCTION_PRIORITIES, P as PAYMENT_DIRECTIONS, e as PAYMENT_REQUEST_STATUSES, f as PAYMENT_STATUSES, g as PAYMENT_TYPES, T as TOKEN_TYPES } from './shared/bank.BzDNLxB_.mjs';
3
3
  export { i as isBatchAuthorized, a as isBatchCompleted, b as isBatchFailed, c as isBatchInitiated, d as isBatchProcessing, e as isBatchReadyToSign } from './shared/bank.XqSw509X.mjs';
4
4
  export { BANK_CODES, CURRENCY_CODES } from '@develit-io/general-codes';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@develit-services/bank",
3
- "version": "5.2.2",
3
+ "version": "5.3.1",
4
4
  "author": "Develit.io s.r.o.",
5
5
  "type": "module",
6
6
  "exports": {