@develit-services/bank 0.3.54 → 0.3.56

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,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const database_schema = require('../shared/bank.DoHc7geB.cjs');
3
+ const database_schema = require('../shared/bank.BnDb4liE.cjs');
4
4
  require('@develit-io/backend-sdk');
5
5
  require('drizzle-orm/sqlite-core');
6
6
  require('date-fns');
@@ -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 { aa as account, ab as accountCredentials, a6 as batch, a9 as ott, a7 as payment, a8 as paymentRelations } from '../shared/bank.Clkw7jCx.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 { aa as account, ab as accountCredentials, a6 as batch, a9 as ott, a7 as payment, a8 as paymentRelations } from '../shared/bank.Clkw7jCx.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 { aa as account, ab as accountCredentials, a6 as batch, a9 as ott, a7 as payment, a8 as paymentRelations } from '../shared/bank.Clkw7jCx.js';
2
2
  import 'zod';
3
3
  import 'drizzle-zod';
4
4
  import 'drizzle-orm/sqlite-core';
@@ -1,4 +1,4 @@
1
- export { t as account, u as accountCredentials, n as batch, r as ott, p as payment, q as paymentRelations } from '../shared/bank.C1bHZDjr.mjs';
1
+ export { t as account, u as accountCredentials, n as batch, r as ott, p as payment, q as paymentRelations } from '../shared/bank.BPxg79Tw.mjs';
2
2
  import '@develit-io/backend-sdk';
3
3
  import 'drizzle-orm/sqlite-core';
4
4
  import 'date-fns';
@@ -3,15 +3,15 @@
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.BdlPpN78.cjs');
7
7
  const zod = require('zod');
8
- const database_schema = require('../shared/bank.DoHc7geB.cjs');
8
+ const database_schema = require('../shared/bank.BnDb4liE.cjs');
9
9
  const generalCodes = require('@develit-io/general-codes');
10
10
  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.BfxCyEqX.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,
@@ -876,19 +874,28 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
876
874
  const { credentials, accounts } = await connector.authorizeAccount({
877
875
  urlParams
878
876
  });
879
- console.log("Bank connector initiated");
880
877
  const alreadyExistingAccounts = (await this._getAccounts()).filter(
881
878
  (acc) => acc.connectorKey === ottRow.refId && accounts.map((item) => item.iban).includes(acc.iban)
882
879
  );
883
- const upsertAccounts = accounts.map(
884
- (acc) => upsertAccountCommand(this.db, {
880
+ const upsertAccounts = accounts.map((acc) => {
881
+ const existingAccount = alreadyExistingAccounts.find(
882
+ (existing) => existing.iban === acc.iban
883
+ );
884
+ const base = { ...acc };
885
+ const existingPart = existingAccount ? {
886
+ id: existingAccount.id,
887
+ lastSyncAt: existingAccount.lastSyncAt
888
+ } : {
889
+ lastSyncAt: lastSyncAt ?? /* @__PURE__ */ new Date(),
890
+ syncIntervalS
891
+ };
892
+ return upsertAccountCommand(this.db, {
885
893
  account: {
886
- ...acc,
887
- syncIntervalS,
888
- lastSyncAt
894
+ ...base,
895
+ ...existingPart
889
896
  }
890
- }).command
891
- );
897
+ }).command;
898
+ });
892
899
  const deleteCredentials = alreadyExistingAccounts.map(
893
900
  (acc) => deleteAccountCredentialsCommand(this.db, {
894
901
  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 BatchPayment, c as BatchMetadata } from '../shared/bank.Clkw7jCx.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';
@@ -2521,7 +2521,7 @@ declare class BankServiceBase extends BankServiceBase_base {
2521
2521
  authorizationUrls: string[] | null;
2522
2522
  statusReason: string | null;
2523
2523
  statusResponse: object | null;
2524
- payments: PaymentInsertType[];
2524
+ payments: BatchPayment[];
2525
2525
  metadata: BatchMetadata | null;
2526
2526
  paymentsChecksum: string | null;
2527
2527
  }[] | undefined>>;
@@ -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 BatchPayment, c as BatchMetadata } from '../shared/bank.Clkw7jCx.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';
@@ -2521,7 +2521,7 @@ declare class BankServiceBase extends BankServiceBase_base {
2521
2521
  authorizationUrls: string[] | null;
2522
2522
  statusReason: string | null;
2523
2523
  statusResponse: object | null;
2524
- payments: PaymentInsertType[];
2524
+ payments: BatchPayment[];
2525
2525
  metadata: BatchMetadata | null;
2526
2526
  paymentsChecksum: string | null;
2527
2527
  }[] | undefined>>;
@@ -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 BatchPayment, c as BatchMetadata } from '../shared/bank.Clkw7jCx.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';
@@ -2521,7 +2521,7 @@ declare class BankServiceBase extends BankServiceBase_base {
2521
2521
  authorizationUrls: string[] | null;
2522
2522
  statusReason: string | null;
2523
2523
  statusResponse: object | null;
2524
- payments: PaymentInsertType[];
2524
+ payments: BatchPayment[];
2525
2525
  metadata: BatchMetadata | null;
2526
2526
  paymentsChecksum: string | null;
2527
2527
  }[] | undefined>>;
@@ -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,15 +1,15 @@
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.BiOcvKnQ.mjs';
5
5
  import { z } from 'zod';
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';
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.BPxg79Tw.mjs';
7
7
  import { CURRENCY_CODES } from '@develit-io/general-codes';
8
8
  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.DbS9RyGZ.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,
@@ -874,19 +872,28 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
874
872
  const { credentials, accounts } = await connector.authorizeAccount({
875
873
  urlParams
876
874
  });
877
- console.log("Bank connector initiated");
878
875
  const alreadyExistingAccounts = (await this._getAccounts()).filter(
879
876
  (acc) => acc.connectorKey === ottRow.refId && accounts.map((item) => item.iban).includes(acc.iban)
880
877
  );
881
- const upsertAccounts = accounts.map(
882
- (acc) => upsertAccountCommand(this.db, {
878
+ const upsertAccounts = accounts.map((acc) => {
879
+ const existingAccount = alreadyExistingAccounts.find(
880
+ (existing) => existing.iban === acc.iban
881
+ );
882
+ const base = { ...acc };
883
+ const existingPart = existingAccount ? {
884
+ id: existingAccount.id,
885
+ lastSyncAt: existingAccount.lastSyncAt
886
+ } : {
887
+ lastSyncAt: lastSyncAt ?? /* @__PURE__ */ new Date(),
888
+ syncIntervalS
889
+ };
890
+ return upsertAccountCommand(this.db, {
883
891
  account: {
884
- ...acc,
885
- syncIntervalS,
886
- lastSyncAt
892
+ ...base,
893
+ ...existingPart
887
894
  }
888
- }).command
889
- );
895
+ }).command;
896
+ });
890
897
  const deleteCredentials = alreadyExistingAccounts.map(
891
898
  (acc) => deleteAccountCredentialsCommand(this.db, {
892
899
  accountId: acc.id
@@ -3,12 +3,12 @@
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.BdlPpN78.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.BfxCyEqX.cjs');
9
9
  const drizzleOrm = require('drizzle-orm');
10
10
  require('date-fns');
11
- require('../shared/bank.DoHc7geB.cjs');
11
+ require('../shared/bank.BnDb4liE.cjs');
12
12
  require('drizzle-orm/sqlite-core');
13
13
  require('drizzle-orm/relations');
14
14
  require('@develit-io/general-codes');
@@ -1,12 +1,12 @@
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.BiOcvKnQ.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.DbS9RyGZ.mjs';
7
7
  import { eq } from 'drizzle-orm';
8
8
  import 'date-fns';
9
- import '../shared/bank.C1bHZDjr.mjs';
9
+ import '../shared/bank.BPxg79Tw.mjs';
10
10
  import 'drizzle-orm/sqlite-core';
11
11
  import 'drizzle-orm/relations';
12
12
  import '@develit-io/general-codes';
@@ -78,7 +78,7 @@ const accountSelectSchema = createSelectSchema(account);
78
78
 
79
79
  const accountCredentials = sqliteTable("account_credentials", {
80
80
  ...base,
81
- accountId: text("account_id").references(() => account.id).notNull(),
81
+ accountId: text("account_id").references(() => account.id, { onDelete: "restrict", onUpdate: "cascade" }).notNull(),
82
82
  connectorKey: text("connector_key", {
83
83
  enum: CONNECTOR_KEYS
84
84
  }).$type().notNull(),
@@ -111,7 +111,10 @@ const batch = sqliteTable("batch", {
111
111
  mode: "timestamp_ms"
112
112
  }),
113
113
  authorizationUrls: text("authorization_urls", { mode: "json" }).$type(),
114
- accountId: text("account_id").references(() => account.id),
114
+ accountId: text("account_id").references(() => account.id, {
115
+ onDelete: "restrict",
116
+ onUpdate: "cascade"
117
+ }),
115
118
  status: text("status", { enum: BATCH_STATUSES }).$type(),
116
119
  statusReason: text("status_reason"),
117
120
  statusResponse: text("status_response", { mode: "json" }).$type(),
@@ -127,7 +130,10 @@ const payment = sqliteTable(
127
130
  correlationId: text("correlation_id").notNull(),
128
131
  refId: text("ref_id"),
129
132
  bankRefId: text("bank_ref_id").notNull(),
130
- accountId: text("account_id").references(() => account.id).notNull(),
133
+ accountId: text("account_id").references(() => account.id, {
134
+ onDelete: "restrict",
135
+ onUpdate: "cascade"
136
+ }).notNull(),
131
137
  connectorKey: text("connector_key", { enum: CONNECTOR_KEYS }).$type().notNull(),
132
138
  amount: real("amount").notNull(),
133
139
  direction: text("direction").$type().notNull(),
@@ -2,7 +2,7 @@
2
2
 
3
3
  const backendSdk = require('@develit-io/backend-sdk');
4
4
  const dateFns = require('date-fns');
5
- const database_schema = require('./bank.DoHc7geB.cjs');
5
+ const database_schema = require('./bank.BnDb4liE.cjs');
6
6
  const drizzleOrm = require('drizzle-orm');
7
7
  const jose = require('jose');
8
8
  require('@develit-io/general-codes');
@@ -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,
@@ -487,6 +486,7 @@ class FinbricksConnector extends IBankConnector {
487
486
  };
488
487
  }
489
488
  async initiateForeignPayment(payment) {
489
+ const bankRefId = backendSdk.uuidv4();
490
490
  const [response, error] = await backendSdk.useResult(
491
491
  this.finbricks.request({
492
492
  endpoint: FINBRICKS_ENDPOINTS.TRANSACTION_FOREIGN_INIT,
@@ -499,7 +499,7 @@ class FinbricksConnector extends IBankConnector {
499
499
  ).token
500
500
  },
501
501
  paymentIdentification: {
502
- merchantTransactionId: payment.bankRefId
502
+ merchantTransactionId: bankRefId
503
503
  },
504
504
  amount: {
505
505
  value: payment.amount,
@@ -537,6 +537,7 @@ class FinbricksConnector extends IBankConnector {
537
537
  authorizationUrl: response.redirectUrl,
538
538
  payment: {
539
539
  ...payment,
540
+ bankRefId,
540
541
  status: "INITIALIZED",
541
542
  accountId: this.connectedAccounts.find(
542
543
  (acc) => acc.iban === payment.debtorIban
@@ -546,6 +547,7 @@ class FinbricksConnector extends IBankConnector {
546
547
  };
547
548
  }
548
549
  async initiateSEPAPayment(payment) {
550
+ const bankRefId = backendSdk.uuidv4();
549
551
  const [response, error] = await backendSdk.useResult(
550
552
  this.finbricks.request({
551
553
  endpoint: FINBRICKS_ENDPOINTS.TRANSACTION_SEPA_INIT,
@@ -558,7 +560,7 @@ class FinbricksConnector extends IBankConnector {
558
560
  ).token
559
561
  },
560
562
  paymentIdentification: {
561
- merchantTransactionId: payment.bankRefId
563
+ merchantTransactionId: bankRefId
562
564
  },
563
565
  amount: payment.amount,
564
566
  debtor: {
@@ -585,6 +587,7 @@ class FinbricksConnector extends IBankConnector {
585
587
  authorizationUrl: response.redirectUrl,
586
588
  payment: {
587
589
  ...payment,
590
+ bankRefId,
588
591
  status: "INITIALIZED",
589
592
  accountId: this.connectedAccounts.find(
590
593
  (acc) => acc.iban === payment.debtorIban
@@ -828,8 +831,8 @@ class ErsteConnector extends IBankConnector {
828
831
  amount: {
829
832
  instructedAmount: { value: payment.amount, currency: payment.currency }
830
833
  },
831
- debtorAccount: { identification: { iban: payment.debtorIban } },
832
- creditorAccount: { identification: { iban: payment.creditorIban } },
834
+ debtorAccount: { identification: { iban: payment.debtor.iban } },
835
+ creditorAccount: { identification: { iban: payment.creditor.iban } },
833
836
  creditor: {
834
837
  name: payment.creditor.holderName
835
838
  }
@@ -851,11 +854,9 @@ class ErsteConnector extends IBankConnector {
851
854
  const erstePayment = await data.json();
852
855
  return {
853
856
  ...payment,
854
- id: backendSdk.uuidv4(),
855
- bankRefId: erstePayment.signInfo.signId,
856
- refId: payment.refId,
857
+ bankRefId: erstePayment.paymentIdentification.transactionIdentification,
857
858
  direction: "OUTGOING",
858
- paymentType: "DOMESTIC",
859
+ paymentType: payment.paymentType,
859
860
  status: "PREPARED",
860
861
  initiatedAt: /* @__PURE__ */ new Date(),
861
862
  accountId: this.connectedAccounts.find(
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
- const drizzle = require('./bank.C7CHJWIm.cjs');
3
+ const drizzle = require('./bank.BdlPpN78.cjs');
4
4
  const backendSdk = require('@develit-io/backend-sdk');
5
5
  const drizzleOrm = require('drizzle-orm');
6
6
  require('date-fns');
7
7
  require('jose');
8
8
  require('@develit-io/general-codes');
9
- require('./bank.DoHc7geB.cjs');
9
+ require('./bank.BnDb4liE.cjs');
10
10
  const node_crypto = require('node:crypto');
11
11
 
12
12
  const createPaymentCommand = (db, { payment }) => {
@@ -1,6 +1,6 @@
1
1
  import { uuidv4, useResult, createInternalError } from '@develit-io/backend-sdk';
2
2
  import { format, parseISO } from 'date-fns';
3
- import { s as schema } from './bank.C1bHZDjr.mjs';
3
+ import { s as schema } from './bank.BPxg79Tw.mjs';
4
4
  import { and, eq } from 'drizzle-orm';
5
5
  import { importPKCS8, SignJWT } from 'jose';
6
6
  import '@develit-io/general-codes';
@@ -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,
@@ -485,6 +484,7 @@ class FinbricksConnector extends IBankConnector {
485
484
  };
486
485
  }
487
486
  async initiateForeignPayment(payment) {
487
+ const bankRefId = uuidv4();
488
488
  const [response, error] = await useResult(
489
489
  this.finbricks.request({
490
490
  endpoint: FINBRICKS_ENDPOINTS.TRANSACTION_FOREIGN_INIT,
@@ -497,7 +497,7 @@ class FinbricksConnector extends IBankConnector {
497
497
  ).token
498
498
  },
499
499
  paymentIdentification: {
500
- merchantTransactionId: payment.bankRefId
500
+ merchantTransactionId: bankRefId
501
501
  },
502
502
  amount: {
503
503
  value: payment.amount,
@@ -535,6 +535,7 @@ class FinbricksConnector extends IBankConnector {
535
535
  authorizationUrl: response.redirectUrl,
536
536
  payment: {
537
537
  ...payment,
538
+ bankRefId,
538
539
  status: "INITIALIZED",
539
540
  accountId: this.connectedAccounts.find(
540
541
  (acc) => acc.iban === payment.debtorIban
@@ -544,6 +545,7 @@ class FinbricksConnector extends IBankConnector {
544
545
  };
545
546
  }
546
547
  async initiateSEPAPayment(payment) {
548
+ const bankRefId = uuidv4();
547
549
  const [response, error] = await useResult(
548
550
  this.finbricks.request({
549
551
  endpoint: FINBRICKS_ENDPOINTS.TRANSACTION_SEPA_INIT,
@@ -556,7 +558,7 @@ class FinbricksConnector extends IBankConnector {
556
558
  ).token
557
559
  },
558
560
  paymentIdentification: {
559
- merchantTransactionId: payment.bankRefId
561
+ merchantTransactionId: bankRefId
560
562
  },
561
563
  amount: payment.amount,
562
564
  debtor: {
@@ -583,6 +585,7 @@ class FinbricksConnector extends IBankConnector {
583
585
  authorizationUrl: response.redirectUrl,
584
586
  payment: {
585
587
  ...payment,
588
+ bankRefId,
586
589
  status: "INITIALIZED",
587
590
  accountId: this.connectedAccounts.find(
588
591
  (acc) => acc.iban === payment.debtorIban
@@ -826,8 +829,8 @@ class ErsteConnector extends IBankConnector {
826
829
  amount: {
827
830
  instructedAmount: { value: payment.amount, currency: payment.currency }
828
831
  },
829
- debtorAccount: { identification: { iban: payment.debtorIban } },
830
- creditorAccount: { identification: { iban: payment.creditorIban } },
832
+ debtorAccount: { identification: { iban: payment.debtor.iban } },
833
+ creditorAccount: { identification: { iban: payment.creditor.iban } },
831
834
  creditor: {
832
835
  name: payment.creditor.holderName
833
836
  }
@@ -849,11 +852,9 @@ class ErsteConnector extends IBankConnector {
849
852
  const erstePayment = await data.json();
850
853
  return {
851
854
  ...payment,
852
- id: uuidv4(),
853
- bankRefId: erstePayment.signInfo.signId,
854
- refId: payment.refId,
855
+ bankRefId: erstePayment.paymentIdentification.transactionIdentification,
855
856
  direction: "OUTGOING",
856
- paymentType: "DOMESTIC",
857
+ paymentType: payment.paymentType,
857
858
  status: "PREPARED",
858
859
  initiatedAt: /* @__PURE__ */ new Date(),
859
860
  accountId: this.connectedAccounts.find(
@@ -80,7 +80,7 @@ const accountSelectSchema = drizzleZod.createSelectSchema(account);
80
80
 
81
81
  const accountCredentials = sqliteCore.sqliteTable("account_credentials", {
82
82
  ...backendSdk.base,
83
- accountId: sqliteCore.text("account_id").references(() => account.id).notNull(),
83
+ accountId: sqliteCore.text("account_id").references(() => account.id, { onDelete: "restrict", onUpdate: "cascade" }).notNull(),
84
84
  connectorKey: sqliteCore.text("connector_key", {
85
85
  enum: CONNECTOR_KEYS
86
86
  }).$type().notNull(),
@@ -113,7 +113,10 @@ const batch = sqliteCore.sqliteTable("batch", {
113
113
  mode: "timestamp_ms"
114
114
  }),
115
115
  authorizationUrls: sqliteCore.text("authorization_urls", { mode: "json" }).$type(),
116
- accountId: sqliteCore.text("account_id").references(() => account.id),
116
+ accountId: sqliteCore.text("account_id").references(() => account.id, {
117
+ onDelete: "restrict",
118
+ onUpdate: "cascade"
119
+ }),
117
120
  status: sqliteCore.text("status", { enum: BATCH_STATUSES }).$type(),
118
121
  statusReason: sqliteCore.text("status_reason"),
119
122
  statusResponse: sqliteCore.text("status_response", { mode: "json" }).$type(),
@@ -129,7 +132,10 @@ const payment = sqliteCore.sqliteTable(
129
132
  correlationId: sqliteCore.text("correlation_id").notNull(),
130
133
  refId: sqliteCore.text("ref_id"),
131
134
  bankRefId: sqliteCore.text("bank_ref_id").notNull(),
132
- accountId: sqliteCore.text("account_id").references(() => account.id).notNull(),
135
+ accountId: sqliteCore.text("account_id").references(() => account.id, {
136
+ onDelete: "restrict",
137
+ onUpdate: "cascade"
138
+ }).notNull(),
133
139
  connectorKey: sqliteCore.text("connector_key", { enum: CONNECTOR_KEYS }).$type().notNull(),
134
140
  amount: sqliteCore.real("amount").notNull(),
135
141
  direction: sqliteCore.text("direction").$type().notNull(),
@@ -129,7 +129,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
129
129
  tableName: "batch";
130
130
  dataType: "json";
131
131
  columnType: "SQLiteTextJson";
132
- data: PaymentInsertType[];
132
+ data: BatchPayment[];
133
133
  driverParam: string;
134
134
  notNull: true;
135
135
  hasDefault: false;
@@ -141,7 +141,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
141
141
  identity: undefined;
142
142
  generated: undefined;
143
143
  }, {}, {
144
- $type: PaymentInsertType[];
144
+ $type: BatchPayment[];
145
145
  }>;
146
146
  metadata: drizzle_orm_sqlite_core.SQLiteColumn<{
147
147
  name: "metadata";
@@ -1731,8 +1731,9 @@ type ParsedBankPayment = {
1731
1731
  raw: object;
1732
1732
  parsed: PaymentInsertType;
1733
1733
  };
1734
+ type BatchPayment = Omit<PaymentInsertType, 'bankRefId'>;
1734
1735
 
1735
- type IncomingPaymentMessage = Omit<PaymentInsertType, 'accountId' | 'connectorKey'>;
1736
+ type IncomingPaymentMessage = Omit<PaymentInsertType, 'accountId' | 'connectorKey' | 'bankRefId'>;
1736
1737
  interface OutgoingPaymentMessage extends PaymentInsertType {
1737
1738
  }
1738
1739
 
@@ -3711,5 +3712,5 @@ type AccountCredentialsUpdateType = z.infer<typeof accountCredentialsInsertSchem
3711
3712
  type AccountCredentialsPatchType = z.infer<typeof accountCredentialsUpdateSchema>;
3712
3713
  type AccountCredentialsSelectType = z.infer<typeof accountCredentialsSelectSchema>;
3713
3714
 
3714
- export { accountCredentialsInsertSchema as $, INSTRUCTION_PRIORITIES as E, PAYMENT_STATUSES as G, PAYMENT_DIRECTIONS as H, IBankConnector as I, ACCOUNT_STATUSES as K, COUNTRY_CODES as N, CONNECTOR_KEYS as R, CREDENTIALS_TYPES as S, TOKEN_TYPES as U, accountInsertSchema as W, accountUpdateSchema as X, accountSelectSchema as Y, accountCredentialsUpdateSchema as a0, accountCredentialsSelectSchema as a1, batch as a5, payment as a6, paymentRelations as a7, ott as a8, account as a9, accountCredentials as aa, tables as t, BATCH_STATUSES as w, PAYMENT_TYPES as x, CHARGE_BEARERS as z };
3715
- export type { AccountSelectType as A, BatchSelectType as B, ConfigEnvironmentBank as C, ChargeBearer as D, InstructionPriority as F, PaymentDirection as J, LastSyncMetadata as L, AccountStatus as M, OutgoingPaymentMessage as O, PaymentSelectType as P, BankAccountWithLastSync as Q, CredentialsType as T, TokenType as V, AccountUpdateType as Z, AccountPatchType as _, ConnectorKey as a, AccountCredentialsUpdateType as a2, AccountCredentialsPatchType as a3, AccountCredentialsSelectType as a4, PaymentInsertType as b, BatchMetadata as c, IncomingPaymentMessage as d, InitiatedPayment as e, ConnectedAccount as f, AccountCredentialsInsertType as g, AccountInsertType as h, PaymentPreparedInsertType as i, InitiatedBatch as j, ParsedBankPayment as k, PaymentStatus as l, BatchStatus as m, CurrencyCode as n, BankCode as o, CountryCode as p, AuthInput as q, Currency as r, PaymentFailedInsertType as s, PaymentInitializedInsertType as u, BatchInsertType as v, PaymentType as y };
3715
+ export { CHARGE_BEARERS as D, INSTRUCTION_PRIORITIES as F, PAYMENT_STATUSES as H, IBankConnector as I, PAYMENT_DIRECTIONS as J, ACCOUNT_STATUSES as M, COUNTRY_CODES as Q, CONNECTOR_KEYS as S, CREDENTIALS_TYPES as T, TOKEN_TYPES as V, accountInsertSchema as X, accountUpdateSchema as Y, accountSelectSchema as Z, accountCredentialsInsertSchema as a0, accountCredentialsUpdateSchema as a1, accountCredentialsSelectSchema as a2, batch as a6, payment as a7, paymentRelations as a8, ott as a9, account as aa, accountCredentials as ab, tables as t, BATCH_STATUSES as x, PAYMENT_TYPES as y };
3716
+ export type { AccountPatchType as $, AccountSelectType as A, BatchSelectType as B, ConfigEnvironmentBank as C, ChargeBearer as E, InstructionPriority as G, PaymentDirection as K, LastSyncMetadata as L, AccountStatus as N, OutgoingPaymentMessage as O, PaymentSelectType as P, BankAccountWithLastSync as R, CredentialsType as U, TokenType as W, AccountUpdateType as _, ConnectorKey as a, AccountCredentialsUpdateType as a3, AccountCredentialsPatchType as a4, AccountCredentialsSelectType as a5, BatchPayment as b, BatchMetadata as c, IncomingPaymentMessage as d, InitiatedPayment as e, ConnectedAccount as f, AccountCredentialsInsertType as g, AccountInsertType as h, PaymentPreparedInsertType as i, InitiatedBatch as j, ParsedBankPayment as k, PaymentStatus as l, BatchStatus as m, CurrencyCode as n, BankCode as o, CountryCode as p, AuthInput as q, Currency as r, PaymentFailedInsertType as s, PaymentInitializedInsertType as u, PaymentInsertType as v, BatchInsertType as w, PaymentType as z };
@@ -129,7 +129,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
129
129
  tableName: "batch";
130
130
  dataType: "json";
131
131
  columnType: "SQLiteTextJson";
132
- data: PaymentInsertType[];
132
+ data: BatchPayment[];
133
133
  driverParam: string;
134
134
  notNull: true;
135
135
  hasDefault: false;
@@ -141,7 +141,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
141
141
  identity: undefined;
142
142
  generated: undefined;
143
143
  }, {}, {
144
- $type: PaymentInsertType[];
144
+ $type: BatchPayment[];
145
145
  }>;
146
146
  metadata: drizzle_orm_sqlite_core.SQLiteColumn<{
147
147
  name: "metadata";
@@ -1731,8 +1731,9 @@ type ParsedBankPayment = {
1731
1731
  raw: object;
1732
1732
  parsed: PaymentInsertType;
1733
1733
  };
1734
+ type BatchPayment = Omit<PaymentInsertType, 'bankRefId'>;
1734
1735
 
1735
- type IncomingPaymentMessage = Omit<PaymentInsertType, 'accountId' | 'connectorKey'>;
1736
+ type IncomingPaymentMessage = Omit<PaymentInsertType, 'accountId' | 'connectorKey' | 'bankRefId'>;
1736
1737
  interface OutgoingPaymentMessage extends PaymentInsertType {
1737
1738
  }
1738
1739
 
@@ -3711,5 +3712,5 @@ type AccountCredentialsUpdateType = z.infer<typeof accountCredentialsInsertSchem
3711
3712
  type AccountCredentialsPatchType = z.infer<typeof accountCredentialsUpdateSchema>;
3712
3713
  type AccountCredentialsSelectType = z.infer<typeof accountCredentialsSelectSchema>;
3713
3714
 
3714
- export { accountCredentialsInsertSchema as $, INSTRUCTION_PRIORITIES as E, PAYMENT_STATUSES as G, PAYMENT_DIRECTIONS as H, IBankConnector as I, ACCOUNT_STATUSES as K, COUNTRY_CODES as N, CONNECTOR_KEYS as R, CREDENTIALS_TYPES as S, TOKEN_TYPES as U, accountInsertSchema as W, accountUpdateSchema as X, accountSelectSchema as Y, accountCredentialsUpdateSchema as a0, accountCredentialsSelectSchema as a1, batch as a5, payment as a6, paymentRelations as a7, ott as a8, account as a9, accountCredentials as aa, tables as t, BATCH_STATUSES as w, PAYMENT_TYPES as x, CHARGE_BEARERS as z };
3715
- export type { AccountSelectType as A, BatchSelectType as B, ConfigEnvironmentBank as C, ChargeBearer as D, InstructionPriority as F, PaymentDirection as J, LastSyncMetadata as L, AccountStatus as M, OutgoingPaymentMessage as O, PaymentSelectType as P, BankAccountWithLastSync as Q, CredentialsType as T, TokenType as V, AccountUpdateType as Z, AccountPatchType as _, ConnectorKey as a, AccountCredentialsUpdateType as a2, AccountCredentialsPatchType as a3, AccountCredentialsSelectType as a4, PaymentInsertType as b, BatchMetadata as c, IncomingPaymentMessage as d, InitiatedPayment as e, ConnectedAccount as f, AccountCredentialsInsertType as g, AccountInsertType as h, PaymentPreparedInsertType as i, InitiatedBatch as j, ParsedBankPayment as k, PaymentStatus as l, BatchStatus as m, CurrencyCode as n, BankCode as o, CountryCode as p, AuthInput as q, Currency as r, PaymentFailedInsertType as s, PaymentInitializedInsertType as u, BatchInsertType as v, PaymentType as y };
3715
+ export { CHARGE_BEARERS as D, INSTRUCTION_PRIORITIES as F, PAYMENT_STATUSES as H, IBankConnector as I, PAYMENT_DIRECTIONS as J, ACCOUNT_STATUSES as M, COUNTRY_CODES as Q, CONNECTOR_KEYS as S, CREDENTIALS_TYPES as T, TOKEN_TYPES as V, accountInsertSchema as X, accountUpdateSchema as Y, accountSelectSchema as Z, accountCredentialsInsertSchema as a0, accountCredentialsUpdateSchema as a1, accountCredentialsSelectSchema as a2, batch as a6, payment as a7, paymentRelations as a8, ott as a9, account as aa, accountCredentials as ab, tables as t, BATCH_STATUSES as x, PAYMENT_TYPES as y };
3716
+ export type { AccountPatchType as $, AccountSelectType as A, BatchSelectType as B, ConfigEnvironmentBank as C, ChargeBearer as E, InstructionPriority as G, PaymentDirection as K, LastSyncMetadata as L, AccountStatus as N, OutgoingPaymentMessage as O, PaymentSelectType as P, BankAccountWithLastSync as R, CredentialsType as U, TokenType as W, AccountUpdateType as _, ConnectorKey as a, AccountCredentialsUpdateType as a3, AccountCredentialsPatchType as a4, AccountCredentialsSelectType as a5, BatchPayment as b, BatchMetadata as c, IncomingPaymentMessage as d, InitiatedPayment as e, ConnectedAccount as f, AccountCredentialsInsertType as g, AccountInsertType as h, PaymentPreparedInsertType as i, InitiatedBatch as j, ParsedBankPayment as k, PaymentStatus as l, BatchStatus as m, CurrencyCode as n, BankCode as o, CountryCode as p, AuthInput as q, Currency as r, PaymentFailedInsertType as s, PaymentInitializedInsertType as u, PaymentInsertType as v, BatchInsertType as w, PaymentType as z };
@@ -129,7 +129,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
129
129
  tableName: "batch";
130
130
  dataType: "json";
131
131
  columnType: "SQLiteTextJson";
132
- data: PaymentInsertType[];
132
+ data: BatchPayment[];
133
133
  driverParam: string;
134
134
  notNull: true;
135
135
  hasDefault: false;
@@ -141,7 +141,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
141
141
  identity: undefined;
142
142
  generated: undefined;
143
143
  }, {}, {
144
- $type: PaymentInsertType[];
144
+ $type: BatchPayment[];
145
145
  }>;
146
146
  metadata: drizzle_orm_sqlite_core.SQLiteColumn<{
147
147
  name: "metadata";
@@ -1731,8 +1731,9 @@ type ParsedBankPayment = {
1731
1731
  raw: object;
1732
1732
  parsed: PaymentInsertType;
1733
1733
  };
1734
+ type BatchPayment = Omit<PaymentInsertType, 'bankRefId'>;
1734
1735
 
1735
- type IncomingPaymentMessage = Omit<PaymentInsertType, 'accountId' | 'connectorKey'>;
1736
+ type IncomingPaymentMessage = Omit<PaymentInsertType, 'accountId' | 'connectorKey' | 'bankRefId'>;
1736
1737
  interface OutgoingPaymentMessage extends PaymentInsertType {
1737
1738
  }
1738
1739
 
@@ -3711,5 +3712,5 @@ type AccountCredentialsUpdateType = z.infer<typeof accountCredentialsInsertSchem
3711
3712
  type AccountCredentialsPatchType = z.infer<typeof accountCredentialsUpdateSchema>;
3712
3713
  type AccountCredentialsSelectType = z.infer<typeof accountCredentialsSelectSchema>;
3713
3714
 
3714
- export { accountCredentialsInsertSchema as $, INSTRUCTION_PRIORITIES as E, PAYMENT_STATUSES as G, PAYMENT_DIRECTIONS as H, IBankConnector as I, ACCOUNT_STATUSES as K, COUNTRY_CODES as N, CONNECTOR_KEYS as R, CREDENTIALS_TYPES as S, TOKEN_TYPES as U, accountInsertSchema as W, accountUpdateSchema as X, accountSelectSchema as Y, accountCredentialsUpdateSchema as a0, accountCredentialsSelectSchema as a1, batch as a5, payment as a6, paymentRelations as a7, ott as a8, account as a9, accountCredentials as aa, tables as t, BATCH_STATUSES as w, PAYMENT_TYPES as x, CHARGE_BEARERS as z };
3715
- export type { AccountSelectType as A, BatchSelectType as B, ConfigEnvironmentBank as C, ChargeBearer as D, InstructionPriority as F, PaymentDirection as J, LastSyncMetadata as L, AccountStatus as M, OutgoingPaymentMessage as O, PaymentSelectType as P, BankAccountWithLastSync as Q, CredentialsType as T, TokenType as V, AccountUpdateType as Z, AccountPatchType as _, ConnectorKey as a, AccountCredentialsUpdateType as a2, AccountCredentialsPatchType as a3, AccountCredentialsSelectType as a4, PaymentInsertType as b, BatchMetadata as c, IncomingPaymentMessage as d, InitiatedPayment as e, ConnectedAccount as f, AccountCredentialsInsertType as g, AccountInsertType as h, PaymentPreparedInsertType as i, InitiatedBatch as j, ParsedBankPayment as k, PaymentStatus as l, BatchStatus as m, CurrencyCode as n, BankCode as o, CountryCode as p, AuthInput as q, Currency as r, PaymentFailedInsertType as s, PaymentInitializedInsertType as u, BatchInsertType as v, PaymentType as y };
3715
+ export { CHARGE_BEARERS as D, INSTRUCTION_PRIORITIES as F, PAYMENT_STATUSES as H, IBankConnector as I, PAYMENT_DIRECTIONS as J, ACCOUNT_STATUSES as M, COUNTRY_CODES as Q, CONNECTOR_KEYS as S, CREDENTIALS_TYPES as T, TOKEN_TYPES as V, accountInsertSchema as X, accountUpdateSchema as Y, accountSelectSchema as Z, accountCredentialsInsertSchema as a0, accountCredentialsUpdateSchema as a1, accountCredentialsSelectSchema as a2, batch as a6, payment as a7, paymentRelations as a8, ott as a9, account as aa, accountCredentials as ab, tables as t, BATCH_STATUSES as x, PAYMENT_TYPES as y };
3716
+ export type { AccountPatchType as $, AccountSelectType as A, BatchSelectType as B, ConfigEnvironmentBank as C, ChargeBearer as E, InstructionPriority as G, PaymentDirection as K, LastSyncMetadata as L, AccountStatus as N, OutgoingPaymentMessage as O, PaymentSelectType as P, BankAccountWithLastSync as R, CredentialsType as U, TokenType as W, AccountUpdateType as _, ConnectorKey as a, AccountCredentialsUpdateType as a3, AccountCredentialsPatchType as a4, AccountCredentialsSelectType as a5, BatchPayment as b, BatchMetadata as c, IncomingPaymentMessage as d, InitiatedPayment as e, ConnectedAccount as f, AccountCredentialsInsertType as g, AccountInsertType as h, PaymentPreparedInsertType as i, InitiatedBatch as j, ParsedBankPayment as k, PaymentStatus as l, BatchStatus as m, CurrencyCode as n, BankCode as o, CountryCode as p, AuthInput as q, Currency as r, PaymentFailedInsertType as s, PaymentInitializedInsertType as u, PaymentInsertType as v, BatchInsertType as w, PaymentType as z };
@@ -1,10 +1,10 @@
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.BiOcvKnQ.mjs';
2
2
  import { uuidv4 } from '@develit-io/backend-sdk';
3
3
  import { eq } from 'drizzle-orm';
4
4
  import 'date-fns';
5
5
  import 'jose';
6
6
  import '@develit-io/general-codes';
7
- import './bank.C1bHZDjr.mjs';
7
+ import './bank.BPxg79Tw.mjs';
8
8
  import { createHash } from 'node:crypto';
9
9
 
10
10
  const createPaymentCommand = (db, { payment }) => {
package/dist/types.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const drizzle = require('./shared/bank.C7CHJWIm.cjs');
4
- const database_schema = require('./shared/bank.DoHc7geB.cjs');
3
+ const drizzle = require('./shared/bank.BdlPpN78.cjs');
4
+ const database_schema = require('./shared/bank.BnDb4liE.cjs');
5
5
  const generalCodes = require('@develit-io/general-codes');
6
6
  require('@develit-io/backend-sdk');
7
7
  require('date-fns');
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.Clkw7jCx.cjs';
2
+ export { M as ACCOUNT_STATUSES, a4 as AccountCredentialsPatchType, a5 as AccountCredentialsSelectType, a3 as AccountCredentialsUpdateType, $ as AccountPatchType, N as AccountStatus, _ as AccountUpdateType, x as BATCH_STATUES, x as BATCH_STATUSES, R as BankAccountWithLastSync, w as BatchInsertType, b as BatchPayment, B as BatchSelectType, D as CHARGE_BEARERS, S as CONNECTOR_KEYS, Q as COUNTRY_CODES, T as CREDENTIALS_TYPES, E as ChargeBearer, C as ConfigEnvironmentBank, U as CredentialsType, F as INSTRUCTION_PRIORITIES, G as InstructionPriority, L as LastSyncMetadata, O as OutgoingPaymentMessage, J as PAYMENT_DIRECTIONS, H as PAYMENT_STATUSES, y as PAYMENT_TYPES, K as PaymentDirection, s as PaymentFailedInsertType, u as PaymentInitializedInsertType, v as PaymentInsertType, z as PaymentType, V as TOKEN_TYPES, W as TokenType, a0 as accountCredentialsInsertSchema, a2 as accountCredentialsSelectSchema, a1 as accountCredentialsUpdateSchema, X as accountInsertSchema, Z as accountSelectSchema, Y as accountUpdateSchema } from './shared/bank.Clkw7jCx.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.Clkw7jCx.mjs';
2
+ export { M as ACCOUNT_STATUSES, a4 as AccountCredentialsPatchType, a5 as AccountCredentialsSelectType, a3 as AccountCredentialsUpdateType, $ as AccountPatchType, N as AccountStatus, _ as AccountUpdateType, x as BATCH_STATUES, x as BATCH_STATUSES, R as BankAccountWithLastSync, w as BatchInsertType, b as BatchPayment, B as BatchSelectType, D as CHARGE_BEARERS, S as CONNECTOR_KEYS, Q as COUNTRY_CODES, T as CREDENTIALS_TYPES, E as ChargeBearer, C as ConfigEnvironmentBank, U as CredentialsType, F as INSTRUCTION_PRIORITIES, G as InstructionPriority, L as LastSyncMetadata, O as OutgoingPaymentMessage, J as PAYMENT_DIRECTIONS, H as PAYMENT_STATUSES, y as PAYMENT_TYPES, K as PaymentDirection, s as PaymentFailedInsertType, u as PaymentInitializedInsertType, v as PaymentInsertType, z as PaymentType, V as TOKEN_TYPES, W as TokenType, a0 as accountCredentialsInsertSchema, a2 as accountCredentialsSelectSchema, a1 as accountCredentialsUpdateSchema, X as accountInsertSchema, Z as accountSelectSchema, Y as accountUpdateSchema } from './shared/bank.Clkw7jCx.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.Clkw7jCx.js';
2
+ export { M as ACCOUNT_STATUSES, a4 as AccountCredentialsPatchType, a5 as AccountCredentialsSelectType, a3 as AccountCredentialsUpdateType, $ as AccountPatchType, N as AccountStatus, _ as AccountUpdateType, x as BATCH_STATUES, x as BATCH_STATUSES, R as BankAccountWithLastSync, w as BatchInsertType, b as BatchPayment, B as BatchSelectType, D as CHARGE_BEARERS, S as CONNECTOR_KEYS, Q as COUNTRY_CODES, T as CREDENTIALS_TYPES, E as ChargeBearer, C as ConfigEnvironmentBank, U as CredentialsType, F as INSTRUCTION_PRIORITIES, G as InstructionPriority, L as LastSyncMetadata, O as OutgoingPaymentMessage, J as PAYMENT_DIRECTIONS, H as PAYMENT_STATUSES, y as PAYMENT_TYPES, K as PaymentDirection, s as PaymentFailedInsertType, u as PaymentInitializedInsertType, v as PaymentInsertType, z as PaymentType, V as TOKEN_TYPES, W as TokenType, a0 as accountCredentialsInsertSchema, a2 as accountCredentialsSelectSchema, a1 as accountCredentialsUpdateSchema, X as accountInsertSchema, Z as accountSelectSchema, Y as accountUpdateSchema } from './shared/bank.Clkw7jCx.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,5 +1,5 @@
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';
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';
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.BiOcvKnQ.mjs';
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.BPxg79Tw.mjs';
3
3
  export { BANK_CODES, CURRENCY_CODES } from '@develit-io/general-codes';
4
4
  import '@develit-io/backend-sdk';
5
5
  import 'date-fns';
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.56",
4
4
  "author": "Develit.io s.r.o.",
5
5
  "type": "module",
6
6
  "exports": {