@develit-services/bank 0.3.54 → 0.3.55

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,4 +1,4 @@
1
- export { a9 as account, aa as accountCredentials, a5 as batch, a8 as ott, a6 as payment, a7 as paymentRelations } from '../shared/bank.DHQNmyQt.cjs';
1
+ export { a9 as account, aa as accountCredentials, a5 as batch, a8 as ott, a6 as payment, a7 as paymentRelations } from '../shared/bank.B9ZliW26.cjs';
2
2
  import 'zod';
3
3
  import 'drizzle-zod';
4
4
  import 'drizzle-orm/sqlite-core';
@@ -1,4 +1,4 @@
1
- export { a9 as account, aa as accountCredentials, a5 as batch, a8 as ott, a6 as payment, a7 as paymentRelations } from '../shared/bank.DHQNmyQt.mjs';
1
+ export { a9 as account, aa as accountCredentials, a5 as batch, a8 as ott, a6 as payment, a7 as paymentRelations } from '../shared/bank.B9ZliW26.mjs';
2
2
  import 'zod';
3
3
  import 'drizzle-zod';
4
4
  import 'drizzle-orm/sqlite-core';
@@ -1,4 +1,4 @@
1
- export { a9 as account, aa as accountCredentials, a5 as batch, a8 as ott, a6 as payment, a7 as paymentRelations } from '../shared/bank.DHQNmyQt.js';
1
+ export { a9 as account, aa as accountCredentials, a5 as batch, a8 as ott, a6 as payment, a7 as paymentRelations } from '../shared/bank.B9ZliW26.js';
2
2
  import 'zod';
3
3
  import 'drizzle-zod';
4
4
  import 'drizzle-orm/sqlite-core';
@@ -3,7 +3,7 @@
3
3
  const backendSdk = require('@develit-io/backend-sdk');
4
4
  const cloudflare_workers = require('cloudflare:workers');
5
5
  const d1 = require('drizzle-orm/d1');
6
- const drizzle = require('../shared/bank.C7CHJWIm.cjs');
6
+ const drizzle = require('../shared/bank.CW-0OIFF.cjs');
7
7
  const zod = require('zod');
8
8
  const database_schema = require('../shared/bank.DoHc7geB.cjs');
9
9
  const generalCodes = require('@develit-io/general-codes');
@@ -11,7 +11,7 @@ require('date-fns');
11
11
  const drizzleOrm = require('drizzle-orm');
12
12
  require('jose');
13
13
  require('node:crypto');
14
- const encryption = require('../shared/bank.sb-eNrid.cjs');
14
+ const encryption = require('../shared/bank.CTHp1cWX.cjs');
15
15
  require('drizzle-orm/sqlite-core');
16
16
  require('drizzle-orm/relations');
17
17
  require('drizzle-zod');
@@ -679,8 +679,6 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
679
679
  (payment) => {
680
680
  return {
681
681
  id: backendSdk.uuidv4(),
682
- bankRefId: backendSdk.uuidv4(),
683
- //TODO(kleinpetr): we won't create payment here (only via sync script)
684
682
  correlationId: payment.correlationId,
685
683
  refId: payment.refId,
686
684
  amount: payment.amount,
@@ -880,15 +878,26 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
880
878
  const alreadyExistingAccounts = (await this._getAccounts()).filter(
881
879
  (acc) => acc.connectorKey === ottRow.refId && accounts.map((item) => item.iban).includes(acc.iban)
882
880
  );
883
- const upsertAccounts = accounts.map(
884
- (acc) => upsertAccountCommand(this.db, {
881
+ const upsertAccounts = accounts.map((acc) => {
882
+ const existingAccount = alreadyExistingAccounts.find(
883
+ (existing) => existing.iban === acc.iban
884
+ );
885
+ return upsertAccountCommand(this.db, {
885
886
  account: {
886
887
  ...acc,
887
888
  syncIntervalS,
888
- lastSyncAt
889
+ // For existing accounts, preserve id and lastSyncAt
890
+ ...existingAccount && {
891
+ id: existingAccount.id,
892
+ lastSyncAt: existingAccount.lastSyncAt
893
+ },
894
+ // For new accounts, set lastSyncAt to provided value or now
895
+ ...!existingAccount && {
896
+ lastSyncAt: lastSyncAt ?? /* @__PURE__ */ new Date()
897
+ }
889
898
  }
890
- }).command
891
- );
899
+ }).command;
900
+ });
892
901
  const deleteCredentials = alreadyExistingAccounts.map(
893
902
  (acc) => deleteAccountCredentialsCommand(this.db, {
894
903
  accountId: acc.id
@@ -1,4 +1,4 @@
1
- import { A as AccountSelectType, P as PaymentSelectType, B as BatchSelectType, L as LastSyncMetadata, C as ConfigEnvironmentBank, t as tables, a as ConnectorKey, I as IBankConnector, b as PaymentInsertType, c as BatchMetadata } from '../shared/bank.DHQNmyQt.cjs';
1
+ import { A as AccountSelectType, P as PaymentSelectType, B as BatchSelectType, L as LastSyncMetadata, C as ConfigEnvironmentBank, t as tables, a as ConnectorKey, I as IBankConnector, b as PaymentInsertType, c as BatchMetadata } from '../shared/bank.B9ZliW26.cjs';
2
2
  import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
3
3
  import { WorkflowInstanceStatus, IRPCResponse } from '@develit-io/backend-sdk';
4
4
  import { DrizzleD1Database } from 'drizzle-orm/d1';
@@ -2530,6 +2530,23 @@ declare class BankServiceBase extends BankServiceBase_base {
2530
2530
  processBatchRestart(input: ProcessBatchRestartInput): Promise<IRPCResponse<ProcessBatchRestartOutput>>;
2531
2531
  queue(b: MessageBatch<SendPaymentInput>): Promise<void>;
2532
2532
  getAuthUri(input: GetAuthUriInput): Promise<IRPCResponse<GetAuthUriOutput>>;
2533
+ /**
2534
+ * Authorizes and connects a bank account using one-time token.
2535
+ *
2536
+ * @param input - Authorization input including ott, urlParams, syncIntervalS, startSync, and lastSyncAt
2537
+ *
2538
+ * @remarks
2539
+ * For new accounts:
2540
+ * - Creates new account with provided syncIntervalS
2541
+ * - Sets lastSyncAt to provided value or current time if not specified
2542
+ * - Starts sync workflow if startSync is true
2543
+ *
2544
+ * For existing accounts (matched by IBAN):
2545
+ * - Preserves existing id and lastSyncAt
2546
+ * - Ignores syncIntervalS parameter (keeps existing value)
2547
+ * - Ignores startSync parameter (no workflow is started)
2548
+ * - Updates credentials and other account data
2549
+ */
2533
2550
  authorizeAccount(input: AuthorizeAccountInput): Promise<IRPCResponse<AuthorizeAccountOutput>>;
2534
2551
  simulateDeposit(input: SimulateDepositInput): Promise<IRPCResponse<SimulateDepositOutput>>;
2535
2552
  sendPayment(input: SendPaymentInput): Promise<IRPCResponse<SendPaymentOutput>>;
@@ -1,4 +1,4 @@
1
- import { A as AccountSelectType, P as PaymentSelectType, B as BatchSelectType, L as LastSyncMetadata, C as ConfigEnvironmentBank, t as tables, a as ConnectorKey, I as IBankConnector, b as PaymentInsertType, c as BatchMetadata } from '../shared/bank.DHQNmyQt.mjs';
1
+ import { A as AccountSelectType, P as PaymentSelectType, B as BatchSelectType, L as LastSyncMetadata, C as ConfigEnvironmentBank, t as tables, a as ConnectorKey, I as IBankConnector, b as PaymentInsertType, c as BatchMetadata } from '../shared/bank.B9ZliW26.mjs';
2
2
  import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
3
3
  import { WorkflowInstanceStatus, IRPCResponse } from '@develit-io/backend-sdk';
4
4
  import { DrizzleD1Database } from 'drizzle-orm/d1';
@@ -2530,6 +2530,23 @@ declare class BankServiceBase extends BankServiceBase_base {
2530
2530
  processBatchRestart(input: ProcessBatchRestartInput): Promise<IRPCResponse<ProcessBatchRestartOutput>>;
2531
2531
  queue(b: MessageBatch<SendPaymentInput>): Promise<void>;
2532
2532
  getAuthUri(input: GetAuthUriInput): Promise<IRPCResponse<GetAuthUriOutput>>;
2533
+ /**
2534
+ * Authorizes and connects a bank account using one-time token.
2535
+ *
2536
+ * @param input - Authorization input including ott, urlParams, syncIntervalS, startSync, and lastSyncAt
2537
+ *
2538
+ * @remarks
2539
+ * For new accounts:
2540
+ * - Creates new account with provided syncIntervalS
2541
+ * - Sets lastSyncAt to provided value or current time if not specified
2542
+ * - Starts sync workflow if startSync is true
2543
+ *
2544
+ * For existing accounts (matched by IBAN):
2545
+ * - Preserves existing id and lastSyncAt
2546
+ * - Ignores syncIntervalS parameter (keeps existing value)
2547
+ * - Ignores startSync parameter (no workflow is started)
2548
+ * - Updates credentials and other account data
2549
+ */
2533
2550
  authorizeAccount(input: AuthorizeAccountInput): Promise<IRPCResponse<AuthorizeAccountOutput>>;
2534
2551
  simulateDeposit(input: SimulateDepositInput): Promise<IRPCResponse<SimulateDepositOutput>>;
2535
2552
  sendPayment(input: SendPaymentInput): Promise<IRPCResponse<SendPaymentOutput>>;
@@ -1,4 +1,4 @@
1
- import { A as AccountSelectType, P as PaymentSelectType, B as BatchSelectType, L as LastSyncMetadata, C as ConfigEnvironmentBank, t as tables, a as ConnectorKey, I as IBankConnector, b as PaymentInsertType, c as BatchMetadata } from '../shared/bank.DHQNmyQt.js';
1
+ import { A as AccountSelectType, P as PaymentSelectType, B as BatchSelectType, L as LastSyncMetadata, C as ConfigEnvironmentBank, t as tables, a as ConnectorKey, I as IBankConnector, b as PaymentInsertType, c as BatchMetadata } from '../shared/bank.B9ZliW26.js';
2
2
  import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
3
3
  import { WorkflowInstanceStatus, IRPCResponse } from '@develit-io/backend-sdk';
4
4
  import { DrizzleD1Database } from 'drizzle-orm/d1';
@@ -2530,6 +2530,23 @@ declare class BankServiceBase extends BankServiceBase_base {
2530
2530
  processBatchRestart(input: ProcessBatchRestartInput): Promise<IRPCResponse<ProcessBatchRestartOutput>>;
2531
2531
  queue(b: MessageBatch<SendPaymentInput>): Promise<void>;
2532
2532
  getAuthUri(input: GetAuthUriInput): Promise<IRPCResponse<GetAuthUriOutput>>;
2533
+ /**
2534
+ * Authorizes and connects a bank account using one-time token.
2535
+ *
2536
+ * @param input - Authorization input including ott, urlParams, syncIntervalS, startSync, and lastSyncAt
2537
+ *
2538
+ * @remarks
2539
+ * For new accounts:
2540
+ * - Creates new account with provided syncIntervalS
2541
+ * - Sets lastSyncAt to provided value or current time if not specified
2542
+ * - Starts sync workflow if startSync is true
2543
+ *
2544
+ * For existing accounts (matched by IBAN):
2545
+ * - Preserves existing id and lastSyncAt
2546
+ * - Ignores syncIntervalS parameter (keeps existing value)
2547
+ * - Ignores startSync parameter (no workflow is started)
2548
+ * - Updates credentials and other account data
2549
+ */
2533
2550
  authorizeAccount(input: AuthorizeAccountInput): Promise<IRPCResponse<AuthorizeAccountOutput>>;
2534
2551
  simulateDeposit(input: SimulateDepositInput): Promise<IRPCResponse<SimulateDepositOutput>>;
2535
2552
  sendPayment(input: SendPaymentInput): Promise<IRPCResponse<SendPaymentOutput>>;
@@ -1,7 +1,7 @@
1
1
  import { uuidv4, first, bankAccountMetadataSchema, workflowInstanceStatusSchema, develitWorker, createInternalError, action, service } from '@develit-io/backend-sdk';
2
2
  import { WorkerEntrypoint } from 'cloudflare:workers';
3
3
  import { drizzle } from 'drizzle-orm/d1';
4
- import { t as tables } from '../shared/bank.BjIZjQTE.mjs';
4
+ import { t as tables } from '../shared/bank.eDTSA4Gp.mjs';
5
5
  import { z } from 'zod';
6
6
  import { I as INSTRUCTION_PRIORITIES, C as CHARGE_BEARERS, P as PAYMENT_TYPES, d as CONNECTOR_KEYS, B as BATCH_STATUSES, a as PAYMENT_STATUSES, b as PAYMENT_DIRECTIONS, f as accountInsertSchema } from '../shared/bank.C1bHZDjr.mjs';
7
7
  import { CURRENCY_CODES } from '@develit-io/general-codes';
@@ -9,7 +9,7 @@ import 'date-fns';
9
9
  import { eq, sql, inArray, and, asc, desc, gte, lte } from 'drizzle-orm';
10
10
  import 'jose';
11
11
  import 'node:crypto';
12
- import { f as encrypt, i as importAesKey, a as getCredentialsByAccountId, b as initiateConnector, u as upsertBatchCommand, d as getBatchByIdQuery, c as createPaymentCommand, g as getAccountByIdQuery } from '../shared/bank.C8f14no5.mjs';
12
+ import { f as encrypt, i as importAesKey, a as getCredentialsByAccountId, b as initiateConnector, u as upsertBatchCommand, d as getBatchByIdQuery, c as createPaymentCommand, g as getAccountByIdQuery } from '../shared/bank.CdDZBwwf.mjs';
13
13
  import 'drizzle-orm/sqlite-core';
14
14
  import 'drizzle-orm/relations';
15
15
  import 'drizzle-zod';
@@ -677,8 +677,6 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
677
677
  (payment) => {
678
678
  return {
679
679
  id: uuidv4(),
680
- bankRefId: uuidv4(),
681
- //TODO(kleinpetr): we won't create payment here (only via sync script)
682
680
  correlationId: payment.correlationId,
683
681
  refId: payment.refId,
684
682
  amount: payment.amount,
@@ -878,15 +876,26 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
878
876
  const alreadyExistingAccounts = (await this._getAccounts()).filter(
879
877
  (acc) => acc.connectorKey === ottRow.refId && accounts.map((item) => item.iban).includes(acc.iban)
880
878
  );
881
- const upsertAccounts = accounts.map(
882
- (acc) => upsertAccountCommand(this.db, {
879
+ const upsertAccounts = accounts.map((acc) => {
880
+ const existingAccount = alreadyExistingAccounts.find(
881
+ (existing) => existing.iban === acc.iban
882
+ );
883
+ return upsertAccountCommand(this.db, {
883
884
  account: {
884
885
  ...acc,
885
886
  syncIntervalS,
886
- lastSyncAt
887
+ // For existing accounts, preserve id and lastSyncAt
888
+ ...existingAccount && {
889
+ id: existingAccount.id,
890
+ lastSyncAt: existingAccount.lastSyncAt
891
+ },
892
+ // For new accounts, set lastSyncAt to provided value or now
893
+ ...!existingAccount && {
894
+ lastSyncAt: lastSyncAt ?? /* @__PURE__ */ new Date()
895
+ }
887
896
  }
888
- }).command
889
- );
897
+ }).command;
898
+ });
890
899
  const deleteCredentials = alreadyExistingAccounts.map(
891
900
  (acc) => deleteAccountCredentialsCommand(this.db, {
892
901
  accountId: acc.id
@@ -3,9 +3,9 @@
3
3
  const cloudflare_workers = require('cloudflare:workers');
4
4
  const cloudflare_workflows = require('cloudflare:workflows');
5
5
  const d1 = require('drizzle-orm/d1');
6
- const drizzle = require('../shared/bank.C7CHJWIm.cjs');
6
+ const drizzle = require('../shared/bank.CW-0OIFF.cjs');
7
7
  const backendSdk = require('@develit-io/backend-sdk');
8
- const encryption = require('../shared/bank.sb-eNrid.cjs');
8
+ const encryption = require('../shared/bank.CTHp1cWX.cjs');
9
9
  const drizzleOrm = require('drizzle-orm');
10
10
  require('date-fns');
11
11
  require('../shared/bank.DoHc7geB.cjs');
@@ -1,9 +1,9 @@
1
1
  import { WorkflowEntrypoint } from 'cloudflare:workers';
2
2
  import { NonRetryableError } from 'cloudflare:workflows';
3
3
  import { drizzle } from 'drizzle-orm/d1';
4
- import { t as tables } from '../shared/bank.BjIZjQTE.mjs';
4
+ import { t as tables } from '../shared/bank.eDTSA4Gp.mjs';
5
5
  import { asNonEmpty, first } from '@develit-io/backend-sdk';
6
- import { g as getAccountByIdQuery, i as importAesKey, a as getCredentialsByAccountId, b as initiateConnector, c as createPaymentCommand, d as getBatchByIdQuery, e as checksum, u as upsertBatchCommand } from '../shared/bank.C8f14no5.mjs';
6
+ import { g as getAccountByIdQuery, i as importAesKey, a as getCredentialsByAccountId, b as initiateConnector, c as createPaymentCommand, d as getBatchByIdQuery, e as checksum, u as upsertBatchCommand } from '../shared/bank.CdDZBwwf.mjs';
7
7
  import { eq } from 'drizzle-orm';
8
8
  import 'date-fns';
9
9
  import '../shared/bank.C1bHZDjr.mjs';
@@ -1732,7 +1732,7 @@ type ParsedBankPayment = {
1732
1732
  parsed: PaymentInsertType;
1733
1733
  };
1734
1734
 
1735
- type IncomingPaymentMessage = Omit<PaymentInsertType, 'accountId' | 'connectorKey'>;
1735
+ type IncomingPaymentMessage = Omit<PaymentInsertType, 'accountId' | 'connectorKey' | 'bankRefId'>;
1736
1736
  interface OutgoingPaymentMessage extends PaymentInsertType {
1737
1737
  }
1738
1738
 
@@ -1732,7 +1732,7 @@ type ParsedBankPayment = {
1732
1732
  parsed: PaymentInsertType;
1733
1733
  };
1734
1734
 
1735
- type IncomingPaymentMessage = Omit<PaymentInsertType, 'accountId' | 'connectorKey'>;
1735
+ type IncomingPaymentMessage = Omit<PaymentInsertType, 'accountId' | 'connectorKey' | 'bankRefId'>;
1736
1736
  interface OutgoingPaymentMessage extends PaymentInsertType {
1737
1737
  }
1738
1738
 
@@ -1732,7 +1732,7 @@ type ParsedBankPayment = {
1732
1732
  parsed: PaymentInsertType;
1733
1733
  };
1734
1734
 
1735
- type IncomingPaymentMessage = Omit<PaymentInsertType, 'accountId' | 'connectorKey'>;
1735
+ type IncomingPaymentMessage = Omit<PaymentInsertType, 'accountId' | 'connectorKey' | 'bankRefId'>;
1736
1736
  interface OutgoingPaymentMessage extends PaymentInsertType {
1737
1737
  }
1738
1738
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const drizzle = require('./bank.C7CHJWIm.cjs');
3
+ const drizzle = require('./bank.CW-0OIFF.cjs');
4
4
  const backendSdk = require('@develit-io/backend-sdk');
5
5
  const drizzleOrm = require('drizzle-orm');
6
6
  require('date-fns');
@@ -189,8 +189,8 @@ const mapFinbricksAccountInsert = ({
189
189
  currency: account.currency,
190
190
  number: account.identification.accountNumber,
191
191
  bankCode: account.servicer.bankCode,
192
- // For now we are using CZE as fallback because finbricks does not provide country code 100% of the time
193
- countryCode: account.servicer.countryCode || "CZE",
192
+ // For now we are using CZ as fallback because finbricks does not provide country code 100% of the time (f.e FIO)
193
+ countryCode: account.servicer.countryCode || "CZ",
194
194
  holderName: account.ownersNames.join(", "),
195
195
  iban: account.identification.iban
196
196
  });
@@ -427,11 +427,10 @@ class FinbricksConnector extends IBankConnector {
427
427
  async preparePayment(payment) {
428
428
  return {
429
429
  ...payment,
430
- id: backendSdk.uuidv4(),
431
430
  bankRefId: backendSdk.uuidv4(),
432
431
  // merchantTransactionId
433
432
  direction: "OUTGOING",
434
- paymentType: "DOMESTIC",
433
+ paymentType: payment.paymentType,
435
434
  status: "PREPARED",
436
435
  initiatedAt: /* @__PURE__ */ new Date(),
437
436
  accountId: this.connectedAccounts.find(
@@ -445,11 +444,11 @@ class FinbricksConnector extends IBankConnector {
445
444
  payments
446
445
  }) {
447
446
  const authorizedClient = this.connectedAccounts.find(
448
- (acc) => acc.iban === payments[0].debtorIban
447
+ (acc) => acc.iban === payments[0].debtor.iban
449
448
  );
450
449
  if (!authorizedClient)
451
450
  throw backendSdk.createInternalError(null, {
452
- message: `Batch for unauthorized client with iban: ${payments[0].debtorIban}`
451
+ message: `Batch for unauthorized client with iban: ${payments[0].debtor.iban}`
453
452
  });
454
453
  const [response, error] = await backendSdk.useResult(
455
454
  this.finbricks.request({
@@ -458,14 +457,14 @@ class FinbricksConnector extends IBankConnector {
458
457
  body: {
459
458
  batchPaymentIdentification: {
460
459
  merchantId: this.finbricks.MERCHANT_ID,
461
- debtorAccountIban: payments[0].debtorIban,
460
+ debtorAccountIban: payments[0].debtor.iban,
462
461
  clientId: authorizedClient.token,
463
462
  callbackUrl: `${this.finbricks.REDIRECT_URI}?type=batch&batchId=${batchId}`,
464
463
  merchantBatchId: batchId
465
464
  },
466
465
  payments: payments.map((p) => ({
467
466
  merchantTransactionId: p.bankRefId,
468
- creditorAccountIban: p.creditorIban,
467
+ creditorAccountIban: p.creditor.iban,
469
468
  amount: p.amount,
470
469
  variableSymbol: p.vs,
471
470
  specificSymbol: p.ss,
@@ -828,8 +827,8 @@ class ErsteConnector extends IBankConnector {
828
827
  amount: {
829
828
  instructedAmount: { value: payment.amount, currency: payment.currency }
830
829
  },
831
- debtorAccount: { identification: { iban: payment.debtorIban } },
832
- creditorAccount: { identification: { iban: payment.creditorIban } },
830
+ debtorAccount: { identification: { iban: payment.debtor.iban } },
831
+ creditorAccount: { identification: { iban: payment.creditor.iban } },
833
832
  creditor: {
834
833
  name: payment.creditor.holderName
835
834
  }
@@ -851,11 +850,9 @@ class ErsteConnector extends IBankConnector {
851
850
  const erstePayment = await data.json();
852
851
  return {
853
852
  ...payment,
854
- id: backendSdk.uuidv4(),
855
- bankRefId: erstePayment.signInfo.signId,
856
- refId: payment.refId,
853
+ bankRefId: erstePayment.paymentIdentification.transactionIdentification,
857
854
  direction: "OUTGOING",
858
- paymentType: "DOMESTIC",
855
+ paymentType: payment.paymentType,
859
856
  status: "PREPARED",
860
857
  initiatedAt: /* @__PURE__ */ new Date(),
861
858
  accountId: this.connectedAccounts.find(
@@ -1,4 +1,4 @@
1
- import { t as tables, F as FinbricksConnector, M as MockConnector, a as MockCobsConnector, E as ErsteConnector } from './bank.BjIZjQTE.mjs';
1
+ import { t as tables, F as FinbricksConnector, M as MockConnector, a as MockCobsConnector, E as ErsteConnector } from './bank.eDTSA4Gp.mjs';
2
2
  import { uuidv4 } from '@develit-io/backend-sdk';
3
3
  import { eq } from 'drizzle-orm';
4
4
  import 'date-fns';
@@ -187,8 +187,8 @@ const mapFinbricksAccountInsert = ({
187
187
  currency: account.currency,
188
188
  number: account.identification.accountNumber,
189
189
  bankCode: account.servicer.bankCode,
190
- // For now we are using CZE as fallback because finbricks does not provide country code 100% of the time
191
- countryCode: account.servicer.countryCode || "CZE",
190
+ // For now we are using CZ as fallback because finbricks does not provide country code 100% of the time (f.e FIO)
191
+ countryCode: account.servicer.countryCode || "CZ",
192
192
  holderName: account.ownersNames.join(", "),
193
193
  iban: account.identification.iban
194
194
  });
@@ -425,11 +425,10 @@ class FinbricksConnector extends IBankConnector {
425
425
  async preparePayment(payment) {
426
426
  return {
427
427
  ...payment,
428
- id: uuidv4(),
429
428
  bankRefId: uuidv4(),
430
429
  // merchantTransactionId
431
430
  direction: "OUTGOING",
432
- paymentType: "DOMESTIC",
431
+ paymentType: payment.paymentType,
433
432
  status: "PREPARED",
434
433
  initiatedAt: /* @__PURE__ */ new Date(),
435
434
  accountId: this.connectedAccounts.find(
@@ -443,11 +442,11 @@ class FinbricksConnector extends IBankConnector {
443
442
  payments
444
443
  }) {
445
444
  const authorizedClient = this.connectedAccounts.find(
446
- (acc) => acc.iban === payments[0].debtorIban
445
+ (acc) => acc.iban === payments[0].debtor.iban
447
446
  );
448
447
  if (!authorizedClient)
449
448
  throw createInternalError(null, {
450
- message: `Batch for unauthorized client with iban: ${payments[0].debtorIban}`
449
+ message: `Batch for unauthorized client with iban: ${payments[0].debtor.iban}`
451
450
  });
452
451
  const [response, error] = await useResult(
453
452
  this.finbricks.request({
@@ -456,14 +455,14 @@ class FinbricksConnector extends IBankConnector {
456
455
  body: {
457
456
  batchPaymentIdentification: {
458
457
  merchantId: this.finbricks.MERCHANT_ID,
459
- debtorAccountIban: payments[0].debtorIban,
458
+ debtorAccountIban: payments[0].debtor.iban,
460
459
  clientId: authorizedClient.token,
461
460
  callbackUrl: `${this.finbricks.REDIRECT_URI}?type=batch&batchId=${batchId}`,
462
461
  merchantBatchId: batchId
463
462
  },
464
463
  payments: payments.map((p) => ({
465
464
  merchantTransactionId: p.bankRefId,
466
- creditorAccountIban: p.creditorIban,
465
+ creditorAccountIban: p.creditor.iban,
467
466
  amount: p.amount,
468
467
  variableSymbol: p.vs,
469
468
  specificSymbol: p.ss,
@@ -826,8 +825,8 @@ class ErsteConnector extends IBankConnector {
826
825
  amount: {
827
826
  instructedAmount: { value: payment.amount, currency: payment.currency }
828
827
  },
829
- debtorAccount: { identification: { iban: payment.debtorIban } },
830
- creditorAccount: { identification: { iban: payment.creditorIban } },
828
+ debtorAccount: { identification: { iban: payment.debtor.iban } },
829
+ creditorAccount: { identification: { iban: payment.creditor.iban } },
831
830
  creditor: {
832
831
  name: payment.creditor.holderName
833
832
  }
@@ -849,11 +848,9 @@ class ErsteConnector extends IBankConnector {
849
848
  const erstePayment = await data.json();
850
849
  return {
851
850
  ...payment,
852
- id: uuidv4(),
853
- bankRefId: erstePayment.signInfo.signId,
854
- refId: payment.refId,
851
+ bankRefId: erstePayment.paymentIdentification.transactionIdentification,
855
852
  direction: "OUTGOING",
856
- paymentType: "DOMESTIC",
853
+ paymentType: payment.paymentType,
857
854
  status: "PREPARED",
858
855
  initiatedAt: /* @__PURE__ */ new Date(),
859
856
  accountId: this.connectedAccounts.find(
package/dist/types.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const drizzle = require('./shared/bank.C7CHJWIm.cjs');
3
+ const drizzle = require('./shared/bank.CW-0OIFF.cjs');
4
4
  const database_schema = require('./shared/bank.DoHc7geB.cjs');
5
5
  const generalCodes = require('@develit-io/general-codes');
6
6
  require('@develit-io/backend-sdk');
package/dist/types.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as IBankConnector, d as IncomingPaymentMessage, e as InitiatedPayment, a as ConnectorKey, f as ConnectedAccount, g as AccountCredentialsInsertType, h as AccountInsertType, i as PaymentPreparedInsertType, j as InitiatedBatch, c as BatchMetadata, A as AccountSelectType, k as ParsedBankPayment, l as PaymentStatus, m as BatchStatus, n as CurrencyCode, o as BankCode, p as CountryCode, q as AuthInput, t as tables, r as Currency, P as PaymentSelectType } from './shared/bank.DHQNmyQt.cjs';
2
- export { K as ACCOUNT_STATUSES, a3 as AccountCredentialsPatchType, a4 as AccountCredentialsSelectType, a2 as AccountCredentialsUpdateType, _ as AccountPatchType, M as AccountStatus, Z as AccountUpdateType, w as BATCH_STATUES, w as BATCH_STATUSES, Q as BankAccountWithLastSync, v as BatchInsertType, B as BatchSelectType, z as CHARGE_BEARERS, R as CONNECTOR_KEYS, N as COUNTRY_CODES, S as CREDENTIALS_TYPES, D as ChargeBearer, C as ConfigEnvironmentBank, T as CredentialsType, E as INSTRUCTION_PRIORITIES, F as InstructionPriority, L as LastSyncMetadata, O as OutgoingPaymentMessage, H as PAYMENT_DIRECTIONS, G as PAYMENT_STATUSES, x as PAYMENT_TYPES, J as PaymentDirection, s as PaymentFailedInsertType, u as PaymentInitializedInsertType, b as PaymentInsertType, y as PaymentType, U as TOKEN_TYPES, V as TokenType, $ as accountCredentialsInsertSchema, a1 as accountCredentialsSelectSchema, a0 as accountCredentialsUpdateSchema, W as accountInsertSchema, Y as accountSelectSchema, X as accountUpdateSchema } from './shared/bank.DHQNmyQt.cjs';
1
+ import { I as IBankConnector, d as IncomingPaymentMessage, e as InitiatedPayment, a as ConnectorKey, f as ConnectedAccount, g as AccountCredentialsInsertType, h as AccountInsertType, i as PaymentPreparedInsertType, j as InitiatedBatch, c as BatchMetadata, A as AccountSelectType, k as ParsedBankPayment, l as PaymentStatus, m as BatchStatus, n as CurrencyCode, o as BankCode, p as CountryCode, q as AuthInput, t as tables, r as Currency, P as PaymentSelectType } from './shared/bank.B9ZliW26.cjs';
2
+ export { K as ACCOUNT_STATUSES, a3 as AccountCredentialsPatchType, a4 as AccountCredentialsSelectType, a2 as AccountCredentialsUpdateType, _ as AccountPatchType, M as AccountStatus, Z as AccountUpdateType, w as BATCH_STATUES, w as BATCH_STATUSES, Q as BankAccountWithLastSync, v as BatchInsertType, B as BatchSelectType, z as CHARGE_BEARERS, R as CONNECTOR_KEYS, N as COUNTRY_CODES, S as CREDENTIALS_TYPES, D as ChargeBearer, C as ConfigEnvironmentBank, T as CredentialsType, E as INSTRUCTION_PRIORITIES, F as InstructionPriority, L as LastSyncMetadata, O as OutgoingPaymentMessage, H as PAYMENT_DIRECTIONS, G as PAYMENT_STATUSES, x as PAYMENT_TYPES, J as PaymentDirection, s as PaymentFailedInsertType, u as PaymentInitializedInsertType, b as PaymentInsertType, y as PaymentType, U as TOKEN_TYPES, V as TokenType, $ as accountCredentialsInsertSchema, a1 as accountCredentialsSelectSchema, a0 as accountCredentialsUpdateSchema, W as accountInsertSchema, Y as accountSelectSchema, X as accountUpdateSchema } from './shared/bank.B9ZliW26.cjs';
3
3
  import { Environment, BaseEvent } from '@develit-io/backend-sdk';
4
4
  import { DrizzleD1Database } from 'drizzle-orm/d1';
5
5
  export { b as BankServiceEnv, a as BankServiceEnvironmentConfig, B as BankServiceWranglerConfig } from './shared/bank.Dh_H_5rC.cjs';
package/dist/types.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as IBankConnector, d as IncomingPaymentMessage, e as InitiatedPayment, a as ConnectorKey, f as ConnectedAccount, g as AccountCredentialsInsertType, h as AccountInsertType, i as PaymentPreparedInsertType, j as InitiatedBatch, c as BatchMetadata, A as AccountSelectType, k as ParsedBankPayment, l as PaymentStatus, m as BatchStatus, n as CurrencyCode, o as BankCode, p as CountryCode, q as AuthInput, t as tables, r as Currency, P as PaymentSelectType } from './shared/bank.DHQNmyQt.mjs';
2
- export { K as ACCOUNT_STATUSES, a3 as AccountCredentialsPatchType, a4 as AccountCredentialsSelectType, a2 as AccountCredentialsUpdateType, _ as AccountPatchType, M as AccountStatus, Z as AccountUpdateType, w as BATCH_STATUES, w as BATCH_STATUSES, Q as BankAccountWithLastSync, v as BatchInsertType, B as BatchSelectType, z as CHARGE_BEARERS, R as CONNECTOR_KEYS, N as COUNTRY_CODES, S as CREDENTIALS_TYPES, D as ChargeBearer, C as ConfigEnvironmentBank, T as CredentialsType, E as INSTRUCTION_PRIORITIES, F as InstructionPriority, L as LastSyncMetadata, O as OutgoingPaymentMessage, H as PAYMENT_DIRECTIONS, G as PAYMENT_STATUSES, x as PAYMENT_TYPES, J as PaymentDirection, s as PaymentFailedInsertType, u as PaymentInitializedInsertType, b as PaymentInsertType, y as PaymentType, U as TOKEN_TYPES, V as TokenType, $ as accountCredentialsInsertSchema, a1 as accountCredentialsSelectSchema, a0 as accountCredentialsUpdateSchema, W as accountInsertSchema, Y as accountSelectSchema, X as accountUpdateSchema } from './shared/bank.DHQNmyQt.mjs';
1
+ import { I as IBankConnector, d as IncomingPaymentMessage, e as InitiatedPayment, a as ConnectorKey, f as ConnectedAccount, g as AccountCredentialsInsertType, h as AccountInsertType, i as PaymentPreparedInsertType, j as InitiatedBatch, c as BatchMetadata, A as AccountSelectType, k as ParsedBankPayment, l as PaymentStatus, m as BatchStatus, n as CurrencyCode, o as BankCode, p as CountryCode, q as AuthInput, t as tables, r as Currency, P as PaymentSelectType } from './shared/bank.B9ZliW26.mjs';
2
+ export { K as ACCOUNT_STATUSES, a3 as AccountCredentialsPatchType, a4 as AccountCredentialsSelectType, a2 as AccountCredentialsUpdateType, _ as AccountPatchType, M as AccountStatus, Z as AccountUpdateType, w as BATCH_STATUES, w as BATCH_STATUSES, Q as BankAccountWithLastSync, v as BatchInsertType, B as BatchSelectType, z as CHARGE_BEARERS, R as CONNECTOR_KEYS, N as COUNTRY_CODES, S as CREDENTIALS_TYPES, D as ChargeBearer, C as ConfigEnvironmentBank, T as CredentialsType, E as INSTRUCTION_PRIORITIES, F as InstructionPriority, L as LastSyncMetadata, O as OutgoingPaymentMessage, H as PAYMENT_DIRECTIONS, G as PAYMENT_STATUSES, x as PAYMENT_TYPES, J as PaymentDirection, s as PaymentFailedInsertType, u as PaymentInitializedInsertType, b as PaymentInsertType, y as PaymentType, U as TOKEN_TYPES, V as TokenType, $ as accountCredentialsInsertSchema, a1 as accountCredentialsSelectSchema, a0 as accountCredentialsUpdateSchema, W as accountInsertSchema, Y as accountSelectSchema, X as accountUpdateSchema } from './shared/bank.B9ZliW26.mjs';
3
3
  import { Environment, BaseEvent } from '@develit-io/backend-sdk';
4
4
  import { DrizzleD1Database } from 'drizzle-orm/d1';
5
5
  export { b as BankServiceEnv, a as BankServiceEnvironmentConfig, B as BankServiceWranglerConfig } from './shared/bank.Dh_H_5rC.mjs';
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as IBankConnector, d as IncomingPaymentMessage, e as InitiatedPayment, a as ConnectorKey, f as ConnectedAccount, g as AccountCredentialsInsertType, h as AccountInsertType, i as PaymentPreparedInsertType, j as InitiatedBatch, c as BatchMetadata, A as AccountSelectType, k as ParsedBankPayment, l as PaymentStatus, m as BatchStatus, n as CurrencyCode, o as BankCode, p as CountryCode, q as AuthInput, t as tables, r as Currency, P as PaymentSelectType } from './shared/bank.DHQNmyQt.js';
2
- export { K as ACCOUNT_STATUSES, a3 as AccountCredentialsPatchType, a4 as AccountCredentialsSelectType, a2 as AccountCredentialsUpdateType, _ as AccountPatchType, M as AccountStatus, Z as AccountUpdateType, w as BATCH_STATUES, w as BATCH_STATUSES, Q as BankAccountWithLastSync, v as BatchInsertType, B as BatchSelectType, z as CHARGE_BEARERS, R as CONNECTOR_KEYS, N as COUNTRY_CODES, S as CREDENTIALS_TYPES, D as ChargeBearer, C as ConfigEnvironmentBank, T as CredentialsType, E as INSTRUCTION_PRIORITIES, F as InstructionPriority, L as LastSyncMetadata, O as OutgoingPaymentMessage, H as PAYMENT_DIRECTIONS, G as PAYMENT_STATUSES, x as PAYMENT_TYPES, J as PaymentDirection, s as PaymentFailedInsertType, u as PaymentInitializedInsertType, b as PaymentInsertType, y as PaymentType, U as TOKEN_TYPES, V as TokenType, $ as accountCredentialsInsertSchema, a1 as accountCredentialsSelectSchema, a0 as accountCredentialsUpdateSchema, W as accountInsertSchema, Y as accountSelectSchema, X as accountUpdateSchema } from './shared/bank.DHQNmyQt.js';
1
+ import { I as IBankConnector, d as IncomingPaymentMessage, e as InitiatedPayment, a as ConnectorKey, f as ConnectedAccount, g as AccountCredentialsInsertType, h as AccountInsertType, i as PaymentPreparedInsertType, j as InitiatedBatch, c as BatchMetadata, A as AccountSelectType, k as ParsedBankPayment, l as PaymentStatus, m as BatchStatus, n as CurrencyCode, o as BankCode, p as CountryCode, q as AuthInput, t as tables, r as Currency, P as PaymentSelectType } from './shared/bank.B9ZliW26.js';
2
+ export { K as ACCOUNT_STATUSES, a3 as AccountCredentialsPatchType, a4 as AccountCredentialsSelectType, a2 as AccountCredentialsUpdateType, _ as AccountPatchType, M as AccountStatus, Z as AccountUpdateType, w as BATCH_STATUES, w as BATCH_STATUSES, Q as BankAccountWithLastSync, v as BatchInsertType, B as BatchSelectType, z as CHARGE_BEARERS, R as CONNECTOR_KEYS, N as COUNTRY_CODES, S as CREDENTIALS_TYPES, D as ChargeBearer, C as ConfigEnvironmentBank, T as CredentialsType, E as INSTRUCTION_PRIORITIES, F as InstructionPriority, L as LastSyncMetadata, O as OutgoingPaymentMessage, H as PAYMENT_DIRECTIONS, G as PAYMENT_STATUSES, x as PAYMENT_TYPES, J as PaymentDirection, s as PaymentFailedInsertType, u as PaymentInitializedInsertType, b as PaymentInsertType, y as PaymentType, U as TOKEN_TYPES, V as TokenType, $ as accountCredentialsInsertSchema, a1 as accountCredentialsSelectSchema, a0 as accountCredentialsUpdateSchema, W as accountInsertSchema, Y as accountSelectSchema, X as accountUpdateSchema } from './shared/bank.B9ZliW26.js';
3
3
  import { Environment, BaseEvent } from '@develit-io/backend-sdk';
4
4
  import { DrizzleD1Database } from 'drizzle-orm/d1';
5
5
  export { b as BankServiceEnv, a as BankServiceEnvironmentConfig, B as BankServiceWranglerConfig } from './shared/bank.Dh_H_5rC.js';
package/dist/types.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { E as ErsteConnector, c as FINBRICKS_ENDPOINTS, b as FinbricksClient, F as FinbricksConnector, I as IBankConnector, a as MockCobsConnector, M as MockConnector, s as signFinbricksJws, u as useFinbricksFetch } from './shared/bank.BjIZjQTE.mjs';
1
+ export { E as ErsteConnector, c as FINBRICKS_ENDPOINTS, b as FinbricksClient, F as FinbricksConnector, I as IBankConnector, a as MockCobsConnector, M as MockConnector, s as signFinbricksJws, u as useFinbricksFetch } from './shared/bank.eDTSA4Gp.mjs';
2
2
  export { A as ACCOUNT_STATUSES, B as BATCH_STATUES, B as BATCH_STATUSES, C as CHARGE_BEARERS, d as CONNECTOR_KEYS, c as COUNTRY_CODES, e as CREDENTIALS_TYPES, I as INSTRUCTION_PRIORITIES, b as PAYMENT_DIRECTIONS, a as PAYMENT_STATUSES, P as PAYMENT_TYPES, T as TOKEN_TYPES, i as accountCredentialsInsertSchema, k as accountCredentialsSelectSchema, j as accountCredentialsUpdateSchema, f as accountInsertSchema, h as accountSelectSchema, g as accountUpdateSchema, o as ottInsertSchema, m as ottSelectSchema, l as ottUpdateSchema } from './shared/bank.C1bHZDjr.mjs';
3
3
  export { BANK_CODES, CURRENCY_CODES } from '@develit-io/general-codes';
4
4
  import '@develit-io/backend-sdk';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@develit-services/bank",
3
- "version": "0.3.54",
3
+ "version": "0.3.55",
4
4
  "author": "Develit.io s.r.o.",
5
5
  "type": "module",
6
6
  "exports": {