@develit-services/bank 0.0.34 → 0.0.37

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.D4BlThGx.cjs');
3
+ const database_schema = require('../shared/bank.BCFCsGc4.cjs');
4
4
  require('@develit-io/backend-sdk');
5
5
  require('drizzle-orm/sqlite-core');
6
6
  require('drizzle-orm');
@@ -1,4 +1,4 @@
1
- export { y as account, z as accountCredentials, r as batch, x as ott, v as payment, w as paymentRelations } from '../shared/bank.ClfukJ-T.mjs';
1
+ export { y as account, z as accountCredentials, r as batch, x as ott, v as payment, w as paymentRelations } from '../shared/bank.ClhW343d.mjs';
2
2
  import '@develit-io/backend-sdk';
3
3
  import 'drizzle-orm/sqlite-core';
4
4
  import 'drizzle-orm';
@@ -5,12 +5,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const backendSdk = require('@develit-io/backend-sdk');
6
6
  const cloudflare_workers = require('cloudflare:workers');
7
7
  const d1 = require('drizzle-orm/d1');
8
- const database_schema = require('../shared/bank.D4BlThGx.cjs');
8
+ const database_schema = require('../shared/bank.BCFCsGc4.cjs');
9
9
  require('jose');
10
10
  const generalCodes = require('@develit-io/general-codes');
11
11
  const zod = require('zod');
12
12
  const drizzleOrm = require('drizzle-orm');
13
- const mockCobs_connector = require('../shared/bank.BVW0vOQS.cjs');
13
+ const mockCobs_connector = require('../shared/bank.mZ26nAqL.cjs');
14
14
  require('drizzle-orm/sqlite-core');
15
15
  require('drizzle-zod');
16
16
  require('date-fns');
@@ -233,14 +233,13 @@ const getCredentialsByAccountId = async (db, { accountId }) => {
233
233
  return cred;
234
234
  };
235
235
 
236
- const getOpenBatchByAccountIdQuery = async (db, { accountId }) => {
237
- const batch = await db.select().from(database_schema.tables.batch).where(
236
+ const getAccountOpenBatchesQuery = async (db, { accountId }) => {
237
+ return await db.select().from(database_schema.tables.batch).where(
238
238
  drizzleOrm.and(
239
239
  drizzleOrm.eq(database_schema.tables.batch.accountId, accountId),
240
240
  drizzleOrm.eq(database_schema.tables.batch.status, "OPEN")
241
241
  )
242
- ).limit(1).get();
243
- return batch;
242
+ );
244
243
  };
245
244
 
246
245
  const getOttQuery = async (db, { ott }) => {
@@ -637,35 +636,40 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
637
636
  }
638
637
  );
639
638
  }
639
+ batchLimit(connectorKey) {
640
+ return 50;
641
+ }
640
642
  async addPaymentsToBatch({
641
643
  paymentsToBatch
642
644
  }) {
643
645
  return this.handleAction(null, {}, async () => {
644
646
  this.logInput({ paymentsToBatch });
645
647
  const mappedPayments = paymentsToBatch.map(
646
- (payment) => ({
647
- id: backendSdk.uuidv4(),
648
- accountId: "",
649
- refId: payment.refId,
650
- connectorKey: "MOCK",
651
- amount: payment.amount,
652
- direction: "OUTGOING",
653
- paymentType: payment.paymentType,
654
- currency: payment.currency,
655
- status: "CREATED",
656
- initiatedAt: /* @__PURE__ */ new Date(),
657
- processedAt: null,
658
- vs: payment.vs || null,
659
- ss: payment.ss || null,
660
- ks: payment.ks || null,
661
- message: payment.message || null,
662
- creditorHolderName: payment.creditorHolderName,
663
- creditorAccountNumberWithBankCode: payment.creditorAccountNumberWithBankCode,
664
- creditorIban: payment.creditorIban,
665
- debtorHolderName: payment.debtorHolderName,
666
- debtorAccountNumberWithBankCode: payment.debtorAccountNumberWithBankCode,
667
- debtorIban: payment.debtorIban
668
- })
648
+ (payment) => {
649
+ return {
650
+ id: backendSdk.uuidv4(),
651
+ accountId: "",
652
+ refId: payment.refId,
653
+ connectorKey: "MOCK",
654
+ amount: payment.amount,
655
+ direction: "OUTGOING",
656
+ paymentType: payment.paymentType,
657
+ currency: payment.currency,
658
+ status: "CREATED",
659
+ initiatedAt: /* @__PURE__ */ new Date(),
660
+ processedAt: null,
661
+ vs: payment.vs || null,
662
+ ss: payment.ss || null,
663
+ ks: payment.ks || null,
664
+ message: payment.message || null,
665
+ creditorHolderName: payment.creditorHolderName,
666
+ creditorAccountNumberWithBankCode: payment.creditorAccountNumberWithBankCode,
667
+ creditorIban: payment.creditorIban,
668
+ debtorHolderName: payment.debtorHolderName,
669
+ debtorAccountNumberWithBankCode: payment.debtorAccountNumberWithBankCode,
670
+ debtorIban: payment.debtorIban
671
+ };
672
+ }
669
673
  );
670
674
  const { supportedPayments, unsupportedPayments } = seperateSupportedPayments(
671
675
  mappedPayments,
@@ -710,22 +714,19 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
710
714
  this.log({
711
715
  message: `\u{1F4B0} Processing ${newPayments.length} payments for account (${acc.iban}, ${acc.currency})`
712
716
  });
713
- const existingBatch = await getOpenBatchByAccountIdQuery(this.db, {
717
+ const openBatches = await getAccountOpenBatchesQuery(this.db, {
714
718
  accountId: acc.id
715
719
  });
716
- if (existingBatch) {
717
- this.log({
718
- message: `\u{1F504} Found existing OPEN batch for account ${acc.id}, merging ${existingBatch.payments.length} existing + ${newPayments.length} new payments`
719
- });
720
- } else {
721
- this.log({
722
- message: `\u2728 Creating new batch for account ${acc.id} with ${newPayments.length} payments`
723
- });
724
- }
720
+ const availableBatch = openBatches.find(
721
+ (batch) => batch.payments.length >= this.batchLimit(acc.connectorKey)
722
+ );
723
+ this.log({
724
+ message: availableBatch ? `\u{1F504} Found existing OPEN batches for account ${acc.id}, merging ${availableBatch.payments.length} existing + ${newPayments.length} new payments` : `\u2728 Creating new batch for account ${acc.id} with ${newPayments.length} payments`
725
+ });
725
726
  const { command } = upsertBatchCommand(this.db, {
726
- batch: existingBatch ? {
727
- ...existingBatch,
728
- payments: [...existingBatch.payments, ...newPayments]
727
+ batch: availableBatch ? {
728
+ ...availableBatch,
729
+ payments: [...availableBatch.payments, ...newPayments]
729
730
  } : {
730
731
  id: backendSdk.uuidv4(),
731
732
  authorizationUrls: [],
@@ -3,7 +3,7 @@ import { IRPCResponse } from '@develit-io/backend-sdk';
3
3
  import { WorkerEntrypoint } from 'cloudflare:workers';
4
4
  import { DrizzleD1Database } from 'drizzle-orm/d1';
5
5
  import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as PaymentInsertType } from '../shared/bank.e_XSg9KV.cjs';
6
- import { A as AccountSelectType, C as ConfigEnvironmentBank, I as IBankConnector, a as ConnectorKey } from '../shared/bank._5C74-4K.cjs';
6
+ import { A as AccountSelectType, C as ConfigEnvironmentBank, I as IBankConnector, a as ConnectorKey } from '../shared/bank.CELgdPJI.cjs';
7
7
  import { z } from 'zod';
8
8
  import 'drizzle-orm/sqlite-core';
9
9
  import 'drizzle-orm';
@@ -225,9 +225,9 @@ declare const getBatchesInputSchema: z.ZodObject<{
225
225
  limit: z.ZodNumber;
226
226
  sort: z.ZodObject<{
227
227
  column: z.ZodEnum<{
228
+ batchPaymentInitiatedAt: "batchPaymentInitiatedAt";
228
229
  createdAt: "createdAt";
229
230
  updatedAt: "updatedAt";
230
- batchPaymentInitiatedAt: "batchPaymentInitiatedAt";
231
231
  }>;
232
232
  direction: z.ZodEnum<{
233
233
  asc: "asc";
@@ -475,17 +475,18 @@ declare class BankServiceBase extends BankServiceBase_base {
475
475
  scheduled(controller: ScheduledController): Promise<void>;
476
476
  updateBatchStatuses(): Promise<void>;
477
477
  initiateBankConnector(input: initiateConnectorInput): Promise<initiateConnectorOutput>;
478
+ batchLimit(connectorKey: ConnectorKey): number;
478
479
  addPaymentsToBatch({ paymentsToBatch, }: {
479
480
  paymentsToBatch: SendPaymentInput[];
480
481
  }): Promise<IRPCResponse<{
482
+ batchPaymentInitiatedAt: Date | null;
483
+ authorizationUrls: string | string[] | null;
481
484
  status: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED" | null;
482
485
  id: string;
483
486
  createdAt: Date | null;
484
487
  updatedAt: Date | null;
485
488
  deletedAt: Date | null;
486
489
  accountId: string | null;
487
- batchPaymentInitiatedAt: Date | null;
488
- authorizationUrls: string | string[] | null;
489
490
  payments: PaymentInsertType[];
490
491
  metadata: object | null;
491
492
  }[] | undefined>>;
@@ -3,7 +3,7 @@ import { IRPCResponse } from '@develit-io/backend-sdk';
3
3
  import { WorkerEntrypoint } from 'cloudflare:workers';
4
4
  import { DrizzleD1Database } from 'drizzle-orm/d1';
5
5
  import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as PaymentInsertType } from '../shared/bank.e_XSg9KV.mjs';
6
- import { A as AccountSelectType, C as ConfigEnvironmentBank, I as IBankConnector, a as ConnectorKey } from '../shared/bank.-qiBc98X.mjs';
6
+ import { A as AccountSelectType, C as ConfigEnvironmentBank, I as IBankConnector, a as ConnectorKey } from '../shared/bank.BmcSkaZh.mjs';
7
7
  import { z } from 'zod';
8
8
  import 'drizzle-orm/sqlite-core';
9
9
  import 'drizzle-orm';
@@ -225,9 +225,9 @@ declare const getBatchesInputSchema: z.ZodObject<{
225
225
  limit: z.ZodNumber;
226
226
  sort: z.ZodObject<{
227
227
  column: z.ZodEnum<{
228
+ batchPaymentInitiatedAt: "batchPaymentInitiatedAt";
228
229
  createdAt: "createdAt";
229
230
  updatedAt: "updatedAt";
230
- batchPaymentInitiatedAt: "batchPaymentInitiatedAt";
231
231
  }>;
232
232
  direction: z.ZodEnum<{
233
233
  asc: "asc";
@@ -475,17 +475,18 @@ declare class BankServiceBase extends BankServiceBase_base {
475
475
  scheduled(controller: ScheduledController): Promise<void>;
476
476
  updateBatchStatuses(): Promise<void>;
477
477
  initiateBankConnector(input: initiateConnectorInput): Promise<initiateConnectorOutput>;
478
+ batchLimit(connectorKey: ConnectorKey): number;
478
479
  addPaymentsToBatch({ paymentsToBatch, }: {
479
480
  paymentsToBatch: SendPaymentInput[];
480
481
  }): Promise<IRPCResponse<{
482
+ batchPaymentInitiatedAt: Date | null;
483
+ authorizationUrls: string | string[] | null;
481
484
  status: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED" | null;
482
485
  id: string;
483
486
  createdAt: Date | null;
484
487
  updatedAt: Date | null;
485
488
  deletedAt: Date | null;
486
489
  accountId: string | null;
487
- batchPaymentInitiatedAt: Date | null;
488
- authorizationUrls: string | string[] | null;
489
490
  payments: PaymentInsertType[];
490
491
  metadata: object | null;
491
492
  }[] | undefined>>;
@@ -3,7 +3,7 @@ import { IRPCResponse } from '@develit-io/backend-sdk';
3
3
  import { WorkerEntrypoint } from 'cloudflare:workers';
4
4
  import { DrizzleD1Database } from 'drizzle-orm/d1';
5
5
  import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as PaymentInsertType } from '../shared/bank.e_XSg9KV.js';
6
- import { A as AccountSelectType, C as ConfigEnvironmentBank, I as IBankConnector, a as ConnectorKey } from '../shared/bank.BRiDHyNf.js';
6
+ import { A as AccountSelectType, C as ConfigEnvironmentBank, I as IBankConnector, a as ConnectorKey } from '../shared/bank.C_BFyEi4.js';
7
7
  import { z } from 'zod';
8
8
  import 'drizzle-orm/sqlite-core';
9
9
  import 'drizzle-orm';
@@ -225,9 +225,9 @@ declare const getBatchesInputSchema: z.ZodObject<{
225
225
  limit: z.ZodNumber;
226
226
  sort: z.ZodObject<{
227
227
  column: z.ZodEnum<{
228
+ batchPaymentInitiatedAt: "batchPaymentInitiatedAt";
228
229
  createdAt: "createdAt";
229
230
  updatedAt: "updatedAt";
230
- batchPaymentInitiatedAt: "batchPaymentInitiatedAt";
231
231
  }>;
232
232
  direction: z.ZodEnum<{
233
233
  asc: "asc";
@@ -475,17 +475,18 @@ declare class BankServiceBase extends BankServiceBase_base {
475
475
  scheduled(controller: ScheduledController): Promise<void>;
476
476
  updateBatchStatuses(): Promise<void>;
477
477
  initiateBankConnector(input: initiateConnectorInput): Promise<initiateConnectorOutput>;
478
+ batchLimit(connectorKey: ConnectorKey): number;
478
479
  addPaymentsToBatch({ paymentsToBatch, }: {
479
480
  paymentsToBatch: SendPaymentInput[];
480
481
  }): Promise<IRPCResponse<{
482
+ batchPaymentInitiatedAt: Date | null;
483
+ authorizationUrls: string | string[] | null;
481
484
  status: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED" | null;
482
485
  id: string;
483
486
  createdAt: Date | null;
484
487
  updatedAt: Date | null;
485
488
  deletedAt: Date | null;
486
489
  accountId: string | null;
487
- batchPaymentInitiatedAt: Date | null;
488
- authorizationUrls: string | string[] | null;
489
490
  payments: PaymentInsertType[];
490
491
  metadata: object | null;
491
492
  }[] | undefined>>;
@@ -1,12 +1,12 @@
1
1
  import { uuidv4, develitWorker, createInternalError, first, RPCResponse, 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, F as FinbricksConnector, M as MockConnector, E as ErsteConnector, P as PAYMENT_TYPES, e as CONNECTOR_KEYS, B as BATCH_STATUSES, c as PAYMENT_STATUSES, d as PAYMENT_DIRECTIONS, q as getPaymentDirection } from '../shared/bank.ClfukJ-T.mjs';
4
+ import { t as tables, F as FinbricksConnector, M as MockConnector, E as ErsteConnector, P as PAYMENT_TYPES, e as CONNECTOR_KEYS, B as BATCH_STATUSES, c as PAYMENT_STATUSES, d as PAYMENT_DIRECTIONS, q as getPaymentDirection } from '../shared/bank.ClhW343d.mjs';
5
5
  import 'jose';
6
6
  import { CURRENCY_CODES } from '@develit-io/general-codes';
7
7
  import { z } from 'zod';
8
8
  import { eq, inArray, and, sql, asc, desc, gte, lte } from 'drizzle-orm';
9
- import { M as MockCobsConnector } from '../shared/bank.De_ddIjl.mjs';
9
+ import { M as MockCobsConnector } from '../shared/bank.UaH89pIW.mjs';
10
10
  import 'drizzle-orm/sqlite-core';
11
11
  import 'drizzle-zod';
12
12
  import 'date-fns';
@@ -229,14 +229,13 @@ const getCredentialsByAccountId = async (db, { accountId }) => {
229
229
  return cred;
230
230
  };
231
231
 
232
- const getOpenBatchByAccountIdQuery = async (db, { accountId }) => {
233
- const batch = await db.select().from(tables.batch).where(
232
+ const getAccountOpenBatchesQuery = async (db, { accountId }) => {
233
+ return await db.select().from(tables.batch).where(
234
234
  and(
235
235
  eq(tables.batch.accountId, accountId),
236
236
  eq(tables.batch.status, "OPEN")
237
237
  )
238
- ).limit(1).get();
239
- return batch;
238
+ );
240
239
  };
241
240
 
242
241
  const getOttQuery = async (db, { ott }) => {
@@ -633,35 +632,40 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
633
632
  }
634
633
  );
635
634
  }
635
+ batchLimit(connectorKey) {
636
+ return 50;
637
+ }
636
638
  async addPaymentsToBatch({
637
639
  paymentsToBatch
638
640
  }) {
639
641
  return this.handleAction(null, {}, async () => {
640
642
  this.logInput({ paymentsToBatch });
641
643
  const mappedPayments = paymentsToBatch.map(
642
- (payment) => ({
643
- id: uuidv4(),
644
- accountId: "",
645
- refId: payment.refId,
646
- connectorKey: "MOCK",
647
- amount: payment.amount,
648
- direction: "OUTGOING",
649
- paymentType: payment.paymentType,
650
- currency: payment.currency,
651
- status: "CREATED",
652
- initiatedAt: /* @__PURE__ */ new Date(),
653
- processedAt: null,
654
- vs: payment.vs || null,
655
- ss: payment.ss || null,
656
- ks: payment.ks || null,
657
- message: payment.message || null,
658
- creditorHolderName: payment.creditorHolderName,
659
- creditorAccountNumberWithBankCode: payment.creditorAccountNumberWithBankCode,
660
- creditorIban: payment.creditorIban,
661
- debtorHolderName: payment.debtorHolderName,
662
- debtorAccountNumberWithBankCode: payment.debtorAccountNumberWithBankCode,
663
- debtorIban: payment.debtorIban
664
- })
644
+ (payment) => {
645
+ return {
646
+ id: uuidv4(),
647
+ accountId: "",
648
+ refId: payment.refId,
649
+ connectorKey: "MOCK",
650
+ amount: payment.amount,
651
+ direction: "OUTGOING",
652
+ paymentType: payment.paymentType,
653
+ currency: payment.currency,
654
+ status: "CREATED",
655
+ initiatedAt: /* @__PURE__ */ new Date(),
656
+ processedAt: null,
657
+ vs: payment.vs || null,
658
+ ss: payment.ss || null,
659
+ ks: payment.ks || null,
660
+ message: payment.message || null,
661
+ creditorHolderName: payment.creditorHolderName,
662
+ creditorAccountNumberWithBankCode: payment.creditorAccountNumberWithBankCode,
663
+ creditorIban: payment.creditorIban,
664
+ debtorHolderName: payment.debtorHolderName,
665
+ debtorAccountNumberWithBankCode: payment.debtorAccountNumberWithBankCode,
666
+ debtorIban: payment.debtorIban
667
+ };
668
+ }
665
669
  );
666
670
  const { supportedPayments, unsupportedPayments } = seperateSupportedPayments(
667
671
  mappedPayments,
@@ -706,22 +710,19 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
706
710
  this.log({
707
711
  message: `\u{1F4B0} Processing ${newPayments.length} payments for account (${acc.iban}, ${acc.currency})`
708
712
  });
709
- const existingBatch = await getOpenBatchByAccountIdQuery(this.db, {
713
+ const openBatches = await getAccountOpenBatchesQuery(this.db, {
710
714
  accountId: acc.id
711
715
  });
712
- if (existingBatch) {
713
- this.log({
714
- message: `\u{1F504} Found existing OPEN batch for account ${acc.id}, merging ${existingBatch.payments.length} existing + ${newPayments.length} new payments`
715
- });
716
- } else {
717
- this.log({
718
- message: `\u2728 Creating new batch for account ${acc.id} with ${newPayments.length} payments`
719
- });
720
- }
716
+ const availableBatch = openBatches.find(
717
+ (batch) => batch.payments.length >= this.batchLimit(acc.connectorKey)
718
+ );
719
+ this.log({
720
+ message: availableBatch ? `\u{1F504} Found existing OPEN batches for account ${acc.id}, merging ${availableBatch.payments.length} existing + ${newPayments.length} new payments` : `\u2728 Creating new batch for account ${acc.id} with ${newPayments.length} payments`
721
+ });
721
722
  const { command } = upsertBatchCommand(this.db, {
722
- batch: existingBatch ? {
723
- ...existingBatch,
724
- payments: [...existingBatch.payments, ...newPayments]
723
+ batch: availableBatch ? {
724
+ ...availableBatch,
725
+ payments: [...availableBatch.payments, ...newPayments]
725
726
  } : {
726
727
  id: uuidv4(),
727
728
  authorizationUrls: [],
@@ -421,7 +421,11 @@ class FinbricksConnector extends IBankConnector {
421
421
  direction: "OUTGOING",
422
422
  paymentType: "DOMESTIC",
423
423
  status: "PREPARED",
424
- initiatedAt: /* @__PURE__ */ new Date()
424
+ initiatedAt: /* @__PURE__ */ new Date(),
425
+ accountId: this.connectedAccounts.find(
426
+ (acc) => acc.iban === payment.debtorIban
427
+ ).id,
428
+ connectorKey: this.PROVIDER
425
429
  };
426
430
  }
427
431
  async initiateBatchFromPayments({
@@ -504,7 +508,14 @@ class FinbricksConnector extends IBankConnector {
504
508
  }
505
509
  return {
506
510
  authorizationUrl: response.redirectUrl,
507
- payment: { ...payment, status: "INITIALIZED" }
511
+ payment: {
512
+ ...payment,
513
+ status: "INITIALIZED",
514
+ accountId: this.connectedAccounts.find(
515
+ (acc) => acc.iban === payment.debtorIban
516
+ ).id,
517
+ connectorKey: this.PROVIDER
518
+ }
508
519
  };
509
520
  }
510
521
  async initiateSinglePayment(payment) {
@@ -761,7 +772,11 @@ class ErsteConnector extends IBankConnector {
761
772
  direction: "OUTGOING",
762
773
  paymentType: "DOMESTIC",
763
774
  status: "PREPARED",
764
- initiatedAt: /* @__PURE__ */ new Date()
775
+ initiatedAt: /* @__PURE__ */ new Date(),
776
+ accountId: this.connectedAccounts.find(
777
+ (acc) => acc.iban === payment.debtorIban
778
+ ).id,
779
+ connectorKey: "ERSTE"
765
780
  };
766
781
  }
767
782
  async initiateBatchFromPayments({
@@ -946,7 +961,11 @@ class MockConnector extends IBankConnector {
946
961
  direction: "OUTGOING",
947
962
  paymentType: "DOMESTIC",
948
963
  status: "PREPARED",
949
- initiatedAt: /* @__PURE__ */ new Date()
964
+ initiatedAt: /* @__PURE__ */ new Date(),
965
+ accountId: this.connectedAccounts.find(
966
+ (acc) => acc.iban === payment.debtorIban
967
+ ).id,
968
+ connectorKey: "MOCK"
950
969
  };
951
970
  }
952
971
  async initiateSinglePayment(payment) {
@@ -964,10 +983,12 @@ class MockConnector extends IBankConnector {
964
983
  return {
965
984
  id: backendSdk.uuidv4(),
966
985
  authorizationUrls: ["http://mock.com"],
967
- payments: payments.map((payment) => ({
968
- ...payment,
969
- status: "INITIALIZED"
970
- }))
986
+ payments: payments.map(
987
+ (payment) => ({
988
+ ...payment,
989
+ status: "INITIALIZED"
990
+ })
991
+ )
971
992
  };
972
993
  }
973
994
  async getAllAccountPayments({
@@ -115,8 +115,7 @@ declare abstract class IBankConnector {
115
115
  }): Promise<BatchStatus>;
116
116
  }
117
117
 
118
- interface IncomingPaymentMessage extends PaymentInsertType {
119
- }
118
+ type IncomingPaymentMessage = Omit<PaymentInsertType, 'accountId' | 'connectorKey'>;
120
119
  interface OutgoingPaymentMessage extends PaymentInsertType {
121
120
  }
122
121
 
@@ -115,8 +115,7 @@ declare abstract class IBankConnector {
115
115
  }): Promise<BatchStatus>;
116
116
  }
117
117
 
118
- interface IncomingPaymentMessage extends PaymentInsertType {
119
- }
118
+ type IncomingPaymentMessage = Omit<PaymentInsertType, 'accountId' | 'connectorKey'>;
120
119
  interface OutgoingPaymentMessage extends PaymentInsertType {
121
120
  }
122
121
 
@@ -115,8 +115,7 @@ declare abstract class IBankConnector {
115
115
  }): Promise<BatchStatus>;
116
116
  }
117
117
 
118
- interface IncomingPaymentMessage extends PaymentInsertType {
119
- }
118
+ type IncomingPaymentMessage = Omit<PaymentInsertType, 'accountId' | 'connectorKey'>;
120
119
  interface OutgoingPaymentMessage extends PaymentInsertType {
121
120
  }
122
121
 
@@ -419,7 +419,11 @@ class FinbricksConnector extends IBankConnector {
419
419
  direction: "OUTGOING",
420
420
  paymentType: "DOMESTIC",
421
421
  status: "PREPARED",
422
- initiatedAt: /* @__PURE__ */ new Date()
422
+ initiatedAt: /* @__PURE__ */ new Date(),
423
+ accountId: this.connectedAccounts.find(
424
+ (acc) => acc.iban === payment.debtorIban
425
+ ).id,
426
+ connectorKey: this.PROVIDER
423
427
  };
424
428
  }
425
429
  async initiateBatchFromPayments({
@@ -502,7 +506,14 @@ class FinbricksConnector extends IBankConnector {
502
506
  }
503
507
  return {
504
508
  authorizationUrl: response.redirectUrl,
505
- payment: { ...payment, status: "INITIALIZED" }
509
+ payment: {
510
+ ...payment,
511
+ status: "INITIALIZED",
512
+ accountId: this.connectedAccounts.find(
513
+ (acc) => acc.iban === payment.debtorIban
514
+ ).id,
515
+ connectorKey: this.PROVIDER
516
+ }
506
517
  };
507
518
  }
508
519
  async initiateSinglePayment(payment) {
@@ -759,7 +770,11 @@ class ErsteConnector extends IBankConnector {
759
770
  direction: "OUTGOING",
760
771
  paymentType: "DOMESTIC",
761
772
  status: "PREPARED",
762
- initiatedAt: /* @__PURE__ */ new Date()
773
+ initiatedAt: /* @__PURE__ */ new Date(),
774
+ accountId: this.connectedAccounts.find(
775
+ (acc) => acc.iban === payment.debtorIban
776
+ ).id,
777
+ connectorKey: "ERSTE"
763
778
  };
764
779
  }
765
780
  async initiateBatchFromPayments({
@@ -944,7 +959,11 @@ class MockConnector extends IBankConnector {
944
959
  direction: "OUTGOING",
945
960
  paymentType: "DOMESTIC",
946
961
  status: "PREPARED",
947
- initiatedAt: /* @__PURE__ */ new Date()
962
+ initiatedAt: /* @__PURE__ */ new Date(),
963
+ accountId: this.connectedAccounts.find(
964
+ (acc) => acc.iban === payment.debtorIban
965
+ ).id,
966
+ connectorKey: "MOCK"
948
967
  };
949
968
  }
950
969
  async initiateSinglePayment(payment) {
@@ -962,10 +981,12 @@ class MockConnector extends IBankConnector {
962
981
  return {
963
982
  id: uuidv4(),
964
983
  authorizationUrls: ["http://mock.com"],
965
- payments: payments.map((payment) => ({
966
- ...payment,
967
- status: "INITIALIZED"
968
- }))
984
+ payments: payments.map(
985
+ (payment) => ({
986
+ ...payment,
987
+ status: "INITIALIZED"
988
+ })
989
+ )
969
990
  };
970
991
  }
971
992
  async getAllAccountPayments({
@@ -1,4 +1,4 @@
1
- import { F as FinbricksConnector } from './bank.ClfukJ-T.mjs';
1
+ import { F as FinbricksConnector } from './bank.ClhW343d.mjs';
2
2
 
3
3
  class MockCobsConnector extends FinbricksConnector {
4
4
  constructor(config) {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const database_schema = require('./bank.D4BlThGx.cjs');
3
+ const database_schema = require('./bank.BCFCsGc4.cjs');
4
4
 
5
5
  class MockCobsConnector extends database_schema.FinbricksConnector {
6
6
  constructor(config) {
package/dist/types.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const database_schema = require('./shared/bank.D4BlThGx.cjs');
4
- const mockCobs_connector = require('./shared/bank.BVW0vOQS.cjs');
3
+ const database_schema = require('./shared/bank.BCFCsGc4.cjs');
4
+ const mockCobs_connector = require('./shared/bank.mZ26nAqL.cjs');
5
5
  const generalCodes = require('@develit-io/general-codes');
6
6
  require('@develit-io/backend-sdk');
7
7
  require('drizzle-orm/sqlite-core');
package/dist/types.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as IBankConnector, b as IncomingPaymentMessage, c as InitiatedPayment, a as ConnectorKey, d as ConnectedAccount, e as AccountCredentialsInsertType, f as AccountInsertType, P as PaymentPreparedInsertType, g as InitiatedBatch, B as BatchMetadata, A as AccountSelectType, h as PaymentStatus, i as BatchStatus, j as CurrencyCode, k as BankCode, l as CountryCode, m as AuthInput, n as Currency } from './shared/bank._5C74-4K.cjs';
2
- export { w as ACCOUNT_STATUSES, U as AccountCredentialsPatchType, V as AccountCredentialsSelectType, S as AccountCredentialsUpdateType, M as AccountPatchType, x as AccountStatus, L as AccountUpdateType, q as BATCH_STATUES, q as BATCH_STATUSES, z as BankAccountWithLastSync, D as CONNECTOR_KEYS, y as COUNTRY_CODES, E as CREDENTIALS_TYPES, C as ConfigEnvironmentBank, F as CredentialsType, O as OutgoingPaymentMessage, u as PAYMENT_DIRECTIONS, t as PAYMENT_STATUSES, r as PAYMENT_TYPES, v as PaymentDirection, o as PaymentFailedInsertType, s as PaymentType, T as TOKEN_TYPES, G as TokenType, N as accountCredentialsInsertSchema, R as accountCredentialsSelectSchema, Q as accountCredentialsUpdateSchema, H as accountInsertSchema, K as accountSelectSchema, J as accountUpdateSchema, p as paymentInitializedInsertType } from './shared/bank._5C74-4K.cjs';
1
+ import { I as IBankConnector, b as IncomingPaymentMessage, c as InitiatedPayment, a as ConnectorKey, d as ConnectedAccount, e as AccountCredentialsInsertType, f as AccountInsertType, P as PaymentPreparedInsertType, g as InitiatedBatch, B as BatchMetadata, A as AccountSelectType, h as PaymentStatus, i as BatchStatus, j as CurrencyCode, k as BankCode, l as CountryCode, m as AuthInput, n as Currency } from './shared/bank.CELgdPJI.cjs';
2
+ export { w as ACCOUNT_STATUSES, U as AccountCredentialsPatchType, V as AccountCredentialsSelectType, S as AccountCredentialsUpdateType, M as AccountPatchType, x as AccountStatus, L as AccountUpdateType, q as BATCH_STATUES, q as BATCH_STATUSES, z as BankAccountWithLastSync, D as CONNECTOR_KEYS, y as COUNTRY_CODES, E as CREDENTIALS_TYPES, C as ConfigEnvironmentBank, F as CredentialsType, O as OutgoingPaymentMessage, u as PAYMENT_DIRECTIONS, t as PAYMENT_STATUSES, r as PAYMENT_TYPES, v as PaymentDirection, o as PaymentFailedInsertType, s as PaymentType, T as TOKEN_TYPES, G as TokenType, N as accountCredentialsInsertSchema, R as accountCredentialsSelectSchema, Q as accountCredentialsUpdateSchema, H as accountInsertSchema, K as accountSelectSchema, J as accountUpdateSchema, p as paymentInitializedInsertType } from './shared/bank.CELgdPJI.cjs';
3
3
  import { a as PaymentInsertType, t as tables, P as PaymentSelectType } from './shared/bank.e_XSg9KV.cjs';
4
4
  export { b as BatchInsertType, B as BatchSelectType, p as paymentInsertTypeZod } from './shared/bank.e_XSg9KV.cjs';
5
5
  import { Environment, BaseEvent } from '@develit-io/backend-sdk';
package/dist/types.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as IBankConnector, b as IncomingPaymentMessage, c as InitiatedPayment, a as ConnectorKey, d as ConnectedAccount, e as AccountCredentialsInsertType, f as AccountInsertType, P as PaymentPreparedInsertType, g as InitiatedBatch, B as BatchMetadata, A as AccountSelectType, h as PaymentStatus, i as BatchStatus, j as CurrencyCode, k as BankCode, l as CountryCode, m as AuthInput, n as Currency } from './shared/bank.-qiBc98X.mjs';
2
- export { w as ACCOUNT_STATUSES, U as AccountCredentialsPatchType, V as AccountCredentialsSelectType, S as AccountCredentialsUpdateType, M as AccountPatchType, x as AccountStatus, L as AccountUpdateType, q as BATCH_STATUES, q as BATCH_STATUSES, z as BankAccountWithLastSync, D as CONNECTOR_KEYS, y as COUNTRY_CODES, E as CREDENTIALS_TYPES, C as ConfigEnvironmentBank, F as CredentialsType, O as OutgoingPaymentMessage, u as PAYMENT_DIRECTIONS, t as PAYMENT_STATUSES, r as PAYMENT_TYPES, v as PaymentDirection, o as PaymentFailedInsertType, s as PaymentType, T as TOKEN_TYPES, G as TokenType, N as accountCredentialsInsertSchema, R as accountCredentialsSelectSchema, Q as accountCredentialsUpdateSchema, H as accountInsertSchema, K as accountSelectSchema, J as accountUpdateSchema, p as paymentInitializedInsertType } from './shared/bank.-qiBc98X.mjs';
1
+ import { I as IBankConnector, b as IncomingPaymentMessage, c as InitiatedPayment, a as ConnectorKey, d as ConnectedAccount, e as AccountCredentialsInsertType, f as AccountInsertType, P as PaymentPreparedInsertType, g as InitiatedBatch, B as BatchMetadata, A as AccountSelectType, h as PaymentStatus, i as BatchStatus, j as CurrencyCode, k as BankCode, l as CountryCode, m as AuthInput, n as Currency } from './shared/bank.BmcSkaZh.mjs';
2
+ export { w as ACCOUNT_STATUSES, U as AccountCredentialsPatchType, V as AccountCredentialsSelectType, S as AccountCredentialsUpdateType, M as AccountPatchType, x as AccountStatus, L as AccountUpdateType, q as BATCH_STATUES, q as BATCH_STATUSES, z as BankAccountWithLastSync, D as CONNECTOR_KEYS, y as COUNTRY_CODES, E as CREDENTIALS_TYPES, C as ConfigEnvironmentBank, F as CredentialsType, O as OutgoingPaymentMessage, u as PAYMENT_DIRECTIONS, t as PAYMENT_STATUSES, r as PAYMENT_TYPES, v as PaymentDirection, o as PaymentFailedInsertType, s as PaymentType, T as TOKEN_TYPES, G as TokenType, N as accountCredentialsInsertSchema, R as accountCredentialsSelectSchema, Q as accountCredentialsUpdateSchema, H as accountInsertSchema, K as accountSelectSchema, J as accountUpdateSchema, p as paymentInitializedInsertType } from './shared/bank.BmcSkaZh.mjs';
3
3
  import { a as PaymentInsertType, t as tables, P as PaymentSelectType } from './shared/bank.e_XSg9KV.mjs';
4
4
  export { b as BatchInsertType, B as BatchSelectType, p as paymentInsertTypeZod } from './shared/bank.e_XSg9KV.mjs';
5
5
  import { Environment, BaseEvent } from '@develit-io/backend-sdk';
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as IBankConnector, b as IncomingPaymentMessage, c as InitiatedPayment, a as ConnectorKey, d as ConnectedAccount, e as AccountCredentialsInsertType, f as AccountInsertType, P as PaymentPreparedInsertType, g as InitiatedBatch, B as BatchMetadata, A as AccountSelectType, h as PaymentStatus, i as BatchStatus, j as CurrencyCode, k as BankCode, l as CountryCode, m as AuthInput, n as Currency } from './shared/bank.BRiDHyNf.js';
2
- export { w as ACCOUNT_STATUSES, U as AccountCredentialsPatchType, V as AccountCredentialsSelectType, S as AccountCredentialsUpdateType, M as AccountPatchType, x as AccountStatus, L as AccountUpdateType, q as BATCH_STATUES, q as BATCH_STATUSES, z as BankAccountWithLastSync, D as CONNECTOR_KEYS, y as COUNTRY_CODES, E as CREDENTIALS_TYPES, C as ConfigEnvironmentBank, F as CredentialsType, O as OutgoingPaymentMessage, u as PAYMENT_DIRECTIONS, t as PAYMENT_STATUSES, r as PAYMENT_TYPES, v as PaymentDirection, o as PaymentFailedInsertType, s as PaymentType, T as TOKEN_TYPES, G as TokenType, N as accountCredentialsInsertSchema, R as accountCredentialsSelectSchema, Q as accountCredentialsUpdateSchema, H as accountInsertSchema, K as accountSelectSchema, J as accountUpdateSchema, p as paymentInitializedInsertType } from './shared/bank.BRiDHyNf.js';
1
+ import { I as IBankConnector, b as IncomingPaymentMessage, c as InitiatedPayment, a as ConnectorKey, d as ConnectedAccount, e as AccountCredentialsInsertType, f as AccountInsertType, P as PaymentPreparedInsertType, g as InitiatedBatch, B as BatchMetadata, A as AccountSelectType, h as PaymentStatus, i as BatchStatus, j as CurrencyCode, k as BankCode, l as CountryCode, m as AuthInput, n as Currency } from './shared/bank.C_BFyEi4.js';
2
+ export { w as ACCOUNT_STATUSES, U as AccountCredentialsPatchType, V as AccountCredentialsSelectType, S as AccountCredentialsUpdateType, M as AccountPatchType, x as AccountStatus, L as AccountUpdateType, q as BATCH_STATUES, q as BATCH_STATUSES, z as BankAccountWithLastSync, D as CONNECTOR_KEYS, y as COUNTRY_CODES, E as CREDENTIALS_TYPES, C as ConfigEnvironmentBank, F as CredentialsType, O as OutgoingPaymentMessage, u as PAYMENT_DIRECTIONS, t as PAYMENT_STATUSES, r as PAYMENT_TYPES, v as PaymentDirection, o as PaymentFailedInsertType, s as PaymentType, T as TOKEN_TYPES, G as TokenType, N as accountCredentialsInsertSchema, R as accountCredentialsSelectSchema, Q as accountCredentialsUpdateSchema, H as accountInsertSchema, K as accountSelectSchema, J as accountUpdateSchema, p as paymentInitializedInsertType } from './shared/bank.C_BFyEi4.js';
3
3
  import { a as PaymentInsertType, t as tables, P as PaymentSelectType } from './shared/bank.e_XSg9KV.js';
4
4
  export { b as BatchInsertType, B as BatchSelectType, p as paymentInsertTypeZod } from './shared/bank.e_XSg9KV.js';
5
5
  import { Environment, BaseEvent } from '@develit-io/backend-sdk';
package/dist/types.mjs CHANGED
@@ -1,5 +1,5 @@
1
- export { A as ACCOUNT_STATUSES, B as BATCH_STATUES, B as BATCH_STATUSES, e as CONNECTOR_KEYS, C as COUNTRY_CODES, f as CREDENTIALS_TYPES, E as ErsteConnector, b as FINBRICKS_ENDPOINTS, a as FinbricksClient, F as FinbricksConnector, I as IBankConnector, M as MockConnector, d as PAYMENT_DIRECTIONS, c as PAYMENT_STATUSES, P as PAYMENT_TYPES, T as TOKEN_TYPES, j as accountCredentialsInsertSchema, l as accountCredentialsSelectSchema, k as accountCredentialsUpdateSchema, g as accountInsertSchema, i as accountSelectSchema, h as accountUpdateSchema, o as ottInsertSchema, n as ottSelectSchema, m as ottUpdateSchema, p as paymentInsertTypeZod, s as signFinbricksJws, u as useFinbricksFetch } from './shared/bank.ClfukJ-T.mjs';
2
- export { M as MockCobsConnector } from './shared/bank.De_ddIjl.mjs';
1
+ export { A as ACCOUNT_STATUSES, B as BATCH_STATUES, B as BATCH_STATUSES, e as CONNECTOR_KEYS, C as COUNTRY_CODES, f as CREDENTIALS_TYPES, E as ErsteConnector, b as FINBRICKS_ENDPOINTS, a as FinbricksClient, F as FinbricksConnector, I as IBankConnector, M as MockConnector, d as PAYMENT_DIRECTIONS, c as PAYMENT_STATUSES, P as PAYMENT_TYPES, T as TOKEN_TYPES, j as accountCredentialsInsertSchema, l as accountCredentialsSelectSchema, k as accountCredentialsUpdateSchema, g as accountInsertSchema, i as accountSelectSchema, h as accountUpdateSchema, o as ottInsertSchema, n as ottSelectSchema, m as ottUpdateSchema, p as paymentInsertTypeZod, s as signFinbricksJws, u as useFinbricksFetch } from './shared/bank.ClhW343d.mjs';
2
+ export { M as MockCobsConnector } from './shared/bank.UaH89pIW.mjs';
3
3
  export { BANK_CODES, CURRENCY_CODES } from '@develit-io/general-codes';
4
4
  import '@develit-io/backend-sdk';
5
5
  import 'drizzle-orm/sqlite-core';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@develit-services/bank",
3
- "version": "0.0.34",
3
+ "version": "0.0.37",
4
4
  "author": "Develit.io s.r.o.",
5
5
  "type": "module",
6
6
  "exports": {