@develit-services/bank 0.3.53 → 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');
@@ -283,7 +283,8 @@ const authorizeAccountInputSchema = zod.z.object({
283
283
  ott: zod.z.string(),
284
284
  urlParams: zod.z.string(),
285
285
  syncIntervalS: zod.z.number().int().positive().optional(),
286
- startSync: zod.z.boolean().optional()
286
+ startSync: zod.z.boolean().optional(),
287
+ lastSyncAt: zod.z.date().optional()
287
288
  });
288
289
 
289
290
  const simulateDepositInputSchema = zod.z.object({
@@ -678,8 +679,6 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
678
679
  (payment) => {
679
680
  return {
680
681
  id: backendSdk.uuidv4(),
681
- bankRefId: backendSdk.uuidv4(),
682
- //TODO(kleinpetr): we won't create payment here (only via sync script)
683
682
  correlationId: payment.correlationId,
684
683
  refId: payment.refId,
685
684
  amount: payment.amount,
@@ -851,7 +850,7 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
851
850
  return this.handleAction(
852
851
  { data: input, schema: authorizeAccountInputSchema },
853
852
  { successMessage: "Erste code saved." },
854
- async ({ ott, urlParams, syncIntervalS, startSync }) => {
853
+ async ({ ott, urlParams, syncIntervalS, startSync, lastSyncAt }) => {
855
854
  const ottRow = await getOttQuery(this.db, {
856
855
  ott
857
856
  });
@@ -879,11 +878,26 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
879
878
  const alreadyExistingAccounts = (await this._getAccounts()).filter(
880
879
  (acc) => acc.connectorKey === ottRow.refId && accounts.map((item) => item.iban).includes(acc.iban)
881
880
  );
882
- const upsertAccounts = accounts.map(
883
- (acc) => upsertAccountCommand(this.db, {
884
- account: syncIntervalS ? { ...acc, syncIntervalS } : acc
885
- }).command
886
- );
881
+ const upsertAccounts = accounts.map((acc) => {
882
+ const existingAccount = alreadyExistingAccounts.find(
883
+ (existing) => existing.iban === acc.iban
884
+ );
885
+ return upsertAccountCommand(this.db, {
886
+ account: {
887
+ ...acc,
888
+ syncIntervalS,
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
+ }
898
+ }
899
+ }).command;
900
+ });
887
901
  const deleteCredentials = alreadyExistingAccounts.map(
888
902
  (acc) => deleteAccountCredentialsCommand(this.db, {
889
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';
@@ -774,6 +774,7 @@ declare const authorizeAccountInputSchema: z.ZodObject<{
774
774
  urlParams: z.ZodString;
775
775
  syncIntervalS: z.ZodOptional<z.ZodNumber>;
776
776
  startSync: z.ZodOptional<z.ZodBoolean>;
777
+ lastSyncAt: z.ZodOptional<z.ZodDate>;
777
778
  }, z.core.$strip>;
778
779
  interface AuthorizeAccountInput extends z.infer<typeof authorizeAccountInputSchema> {
779
780
  }
@@ -2529,6 +2530,23 @@ declare class BankServiceBase extends BankServiceBase_base {
2529
2530
  processBatchRestart(input: ProcessBatchRestartInput): Promise<IRPCResponse<ProcessBatchRestartOutput>>;
2530
2531
  queue(b: MessageBatch<SendPaymentInput>): Promise<void>;
2531
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
+ */
2532
2550
  authorizeAccount(input: AuthorizeAccountInput): Promise<IRPCResponse<AuthorizeAccountOutput>>;
2533
2551
  simulateDeposit(input: SimulateDepositInput): Promise<IRPCResponse<SimulateDepositOutput>>;
2534
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';
@@ -774,6 +774,7 @@ declare const authorizeAccountInputSchema: z.ZodObject<{
774
774
  urlParams: z.ZodString;
775
775
  syncIntervalS: z.ZodOptional<z.ZodNumber>;
776
776
  startSync: z.ZodOptional<z.ZodBoolean>;
777
+ lastSyncAt: z.ZodOptional<z.ZodDate>;
777
778
  }, z.core.$strip>;
778
779
  interface AuthorizeAccountInput extends z.infer<typeof authorizeAccountInputSchema> {
779
780
  }
@@ -2529,6 +2530,23 @@ declare class BankServiceBase extends BankServiceBase_base {
2529
2530
  processBatchRestart(input: ProcessBatchRestartInput): Promise<IRPCResponse<ProcessBatchRestartOutput>>;
2530
2531
  queue(b: MessageBatch<SendPaymentInput>): Promise<void>;
2531
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
+ */
2532
2550
  authorizeAccount(input: AuthorizeAccountInput): Promise<IRPCResponse<AuthorizeAccountOutput>>;
2533
2551
  simulateDeposit(input: SimulateDepositInput): Promise<IRPCResponse<SimulateDepositOutput>>;
2534
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';
@@ -774,6 +774,7 @@ declare const authorizeAccountInputSchema: z.ZodObject<{
774
774
  urlParams: z.ZodString;
775
775
  syncIntervalS: z.ZodOptional<z.ZodNumber>;
776
776
  startSync: z.ZodOptional<z.ZodBoolean>;
777
+ lastSyncAt: z.ZodOptional<z.ZodDate>;
777
778
  }, z.core.$strip>;
778
779
  interface AuthorizeAccountInput extends z.infer<typeof authorizeAccountInputSchema> {
779
780
  }
@@ -2529,6 +2530,23 @@ declare class BankServiceBase extends BankServiceBase_base {
2529
2530
  processBatchRestart(input: ProcessBatchRestartInput): Promise<IRPCResponse<ProcessBatchRestartOutput>>;
2530
2531
  queue(b: MessageBatch<SendPaymentInput>): Promise<void>;
2531
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
+ */
2532
2550
  authorizeAccount(input: AuthorizeAccountInput): Promise<IRPCResponse<AuthorizeAccountOutput>>;
2533
2551
  simulateDeposit(input: SimulateDepositInput): Promise<IRPCResponse<SimulateDepositOutput>>;
2534
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';
@@ -281,7 +281,8 @@ const authorizeAccountInputSchema = z.object({
281
281
  ott: z.string(),
282
282
  urlParams: z.string(),
283
283
  syncIntervalS: z.number().int().positive().optional(),
284
- startSync: z.boolean().optional()
284
+ startSync: z.boolean().optional(),
285
+ lastSyncAt: z.date().optional()
285
286
  });
286
287
 
287
288
  const simulateDepositInputSchema = z.object({
@@ -676,8 +677,6 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
676
677
  (payment) => {
677
678
  return {
678
679
  id: uuidv4(),
679
- bankRefId: uuidv4(),
680
- //TODO(kleinpetr): we won't create payment here (only via sync script)
681
680
  correlationId: payment.correlationId,
682
681
  refId: payment.refId,
683
682
  amount: payment.amount,
@@ -849,7 +848,7 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
849
848
  return this.handleAction(
850
849
  { data: input, schema: authorizeAccountInputSchema },
851
850
  { successMessage: "Erste code saved." },
852
- async ({ ott, urlParams, syncIntervalS, startSync }) => {
851
+ async ({ ott, urlParams, syncIntervalS, startSync, lastSyncAt }) => {
853
852
  const ottRow = await getOttQuery(this.db, {
854
853
  ott
855
854
  });
@@ -877,11 +876,26 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
877
876
  const alreadyExistingAccounts = (await this._getAccounts()).filter(
878
877
  (acc) => acc.connectorKey === ottRow.refId && accounts.map((item) => item.iban).includes(acc.iban)
879
878
  );
880
- const upsertAccounts = accounts.map(
881
- (acc) => upsertAccountCommand(this.db, {
882
- account: syncIntervalS ? { ...acc, syncIntervalS } : acc
883
- }).command
884
- );
879
+ const upsertAccounts = accounts.map((acc) => {
880
+ const existingAccount = alreadyExistingAccounts.find(
881
+ (existing) => existing.iban === acc.iban
882
+ );
883
+ return upsertAccountCommand(this.db, {
884
+ account: {
885
+ ...acc,
886
+ syncIntervalS,
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
+ }
896
+ }
897
+ }).command;
898
+ });
885
899
  const deleteCredentials = alreadyExistingAccounts.map(
886
900
  (acc) => deleteAccountCredentialsCommand(this.db, {
887
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.53",
3
+ "version": "0.3.55",
4
4
  "author": "Develit.io s.r.o.",
5
5
  "type": "module",
6
6
  "exports": {