@develit-services/bank 0.3.46 → 0.3.48

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.CpwLFudl.cjs');
3
+ const database_schema = require('../shared/bank.BfBw79Y1.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.BEL1HIxZ.cjs';
1
+ export { a9 as account, aa as accountCredentials, a5 as batch, a8 as ott, a6 as payment, a7 as paymentRelations } from '../shared/bank.CG0gMBFx.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.BEL1HIxZ.mjs';
1
+ export { a9 as account, aa as accountCredentials, a5 as batch, a8 as ott, a6 as payment, a7 as paymentRelations } from '../shared/bank.CG0gMBFx.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.BEL1HIxZ.js';
1
+ export { a9 as account, aa as accountCredentials, a5 as batch, a8 as ott, a6 as payment, a7 as paymentRelations } from '../shared/bank.CG0gMBFx.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.D-3fzX63.mjs';
1
+ export { t as account, u as accountCredentials, n as batch, r as ott, p as payment, q as paymentRelations } from '../shared/bank.m2X4FSvr.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.CPYfE-Ei.cjs');
6
+ const drizzle = require('../shared/bank.DXj5tpXa.cjs');
7
7
  const zod = require('zod');
8
- const database_schema = require('../shared/bank.CpwLFudl.cjs');
8
+ const database_schema = require('../shared/bank.BfBw79Y1.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.D0a-MZon.cjs');
14
+ const encryption = require('../shared/bank.CwRMB9Ek.cjs');
15
15
  require('drizzle-orm/sqlite-core');
16
16
  require('drizzle-orm/relations');
17
17
  require('drizzle-zod');
@@ -93,6 +93,27 @@ const deletePaymentsByAccountCommand = (db, { accountId }) => {
93
93
  };
94
94
  };
95
95
 
96
+ const getAccountBatchCountsQuery = async (db, { accountId }) => {
97
+ const result = await db.select({
98
+ totalCount: drizzleOrm.sql`COUNT(*)`.as("totalCount"),
99
+ openCount: drizzleOrm.sql`SUM(CASE WHEN ${drizzle.tables.batch.status} = 'OPEN' THEN 1 ELSE 0 END)`.as(
100
+ "openCount"
101
+ ),
102
+ readyToSignCount: drizzleOrm.sql`SUM(CASE WHEN ${drizzle.tables.batch.status} = 'READY_TO_SIGN' THEN 1 ELSE 0 END)`.as(
103
+ "readyToSignCount"
104
+ ),
105
+ failedCount: drizzleOrm.sql`SUM(CASE WHEN ${drizzle.tables.batch.status} = 'FAILED' THEN 1 ELSE 0 END)`.as(
106
+ "failedCount"
107
+ )
108
+ }).from(drizzle.tables.batch).where(drizzleOrm.eq(drizzle.tables.batch.accountId, accountId)).then(backendSdk.first);
109
+ return result || {
110
+ totalCount: 0,
111
+ openCount: 0,
112
+ readyToSignCount: 0,
113
+ failedCount: 0
114
+ };
115
+ };
116
+
96
117
  const getAccountByIbanQuery = async (db, { iban }) => {
97
118
  return await db.select().from(drizzle.tables.account).where(drizzleOrm.eq(drizzle.tables.account.iban, iban)).get();
98
119
  };
@@ -385,6 +406,13 @@ const updateAccountInputSchema = zod.z.object({
385
406
  account: database_schema.accountInsertSchema
386
407
  });
387
408
 
409
+ const getBankAccountsInputSchema = zod.z.object({
410
+ includes: zod.z.object({
411
+ workflow: zod.z.boolean().optional(),
412
+ batchCounts: zod.z.boolean().optional()
413
+ }).optional()
414
+ });
415
+
388
416
  const disconnectAccountInputSchema = zod.z.object({
389
417
  accountId: zod.z.uuid()
390
418
  });
@@ -981,32 +1009,41 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
981
1009
  }
982
1010
  );
983
1011
  }
984
- async getBankAccounts() {
1012
+ async getBankAccounts(input) {
985
1013
  return this.handleAction(
986
- null,
1014
+ { data: input, schema: getBankAccountsInputSchema },
987
1015
  { successMessage: "Bank accounts retrieved successfully" },
988
- async () => {
1016
+ async ({ includes }) => {
989
1017
  const accounts = await this._getAccounts();
990
- const accountsWithWorkflows = await Promise.all(
1018
+ const includeWorkflow = includes?.workflow ?? true;
1019
+ const includeBatchCounts = includes?.batchCounts ?? false;
1020
+ const accountsWithOptionalFields = await Promise.all(
991
1021
  accounts.map(async (a) => {
992
- let status;
993
- try {
994
- const instance = await this.env.SYNC_ACCOUNT_PAYMENTS_WORKFLOW.get(a.id);
995
- status = await instance.status();
996
- } catch (_) {
997
- status = null;
998
- }
999
- return {
1000
- ...a,
1001
- workflow: status ? {
1022
+ const result = { ...a };
1023
+ if (includeWorkflow) {
1024
+ let status;
1025
+ try {
1026
+ const instance = await this.env.SYNC_ACCOUNT_PAYMENTS_WORKFLOW.get(a.id);
1027
+ status = await instance.status();
1028
+ } catch (_) {
1029
+ status = null;
1030
+ }
1031
+ result.workflow = status ? {
1002
1032
  instanceId: a.id,
1003
1033
  details: status
1004
- } : null
1005
- };
1034
+ } : null;
1035
+ }
1036
+ if (includeBatchCounts) {
1037
+ const batchCounts = await getAccountBatchCountsQuery(this.db, {
1038
+ accountId: a.id
1039
+ });
1040
+ result.batches = batchCounts;
1041
+ }
1042
+ return result;
1006
1043
  })
1007
1044
  );
1008
1045
  return {
1009
- accounts: accountsWithWorkflows,
1046
+ accounts: accountsWithOptionalFields,
1010
1047
  totalCount: accounts.length
1011
1048
  };
1012
1049
  }
@@ -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.BEL1HIxZ.cjs';
1
+ import { A as AccountSelectType, P as PaymentSelectType, B as BatchSelectType, L as LastSyncMetadata, C as ConfigEnvironmentBank, t as tables, a as ConnectorKey, I as IBankConnector, b as PaymentInsertType, c as BatchMetadata } from '../shared/bank.CG0gMBFx.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';
@@ -1531,21 +1531,19 @@ declare const getBatchesInputSchema: z.ZodObject<{
1531
1531
  }, z.core.$strip>;
1532
1532
  filterBatchAccountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodUUID, z.ZodArray<z.ZodUUID>]>>;
1533
1533
  filterBatchStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
1534
+ FAILED: "FAILED";
1534
1535
  OPEN: "OPEN";
1535
- FULL: "FULL";
1536
1536
  PROCESSING: "PROCESSING";
1537
1537
  READY_TO_SIGN: "READY_TO_SIGN";
1538
1538
  SIGNED: "SIGNED";
1539
1539
  SIGNATURE_FAILED: "SIGNATURE_FAILED";
1540
- FAILED: "FAILED";
1541
1540
  }>, z.ZodArray<z.ZodEnum<{
1541
+ FAILED: "FAILED";
1542
1542
  OPEN: "OPEN";
1543
- FULL: "FULL";
1544
1543
  PROCESSING: "PROCESSING";
1545
1544
  READY_TO_SIGN: "READY_TO_SIGN";
1546
1545
  SIGNED: "SIGNED";
1547
1546
  SIGNATURE_FAILED: "SIGNATURE_FAILED";
1548
- FAILED: "FAILED";
1549
1547
  }>>]>>;
1550
1548
  }, z.core.$strip>;
1551
1549
  type GetBatchesInput = z.input<typeof getBatchesInputSchema>;
@@ -1790,16 +1788,16 @@ declare const getPaymentsInputSchema: z.ZodObject<{
1790
1788
  filterPaymentDateFrom: z.ZodOptional<z.ZodDate>;
1791
1789
  filterPaymentDateTo: z.ZodOptional<z.ZodDate>;
1792
1790
  filterPaymentStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
1793
- FAILED: "FAILED";
1794
1791
  PREPARED: "PREPARED";
1795
1792
  INITIALIZED: "INITIALIZED";
1793
+ FAILED: "FAILED";
1796
1794
  PENDING: "PENDING";
1797
1795
  COMPLETED: "COMPLETED";
1798
1796
  CREATED: "CREATED";
1799
1797
  }>, z.ZodArray<z.ZodEnum<{
1800
- FAILED: "FAILED";
1801
1798
  PREPARED: "PREPARED";
1802
1799
  INITIALIZED: "INITIALIZED";
1800
+ FAILED: "FAILED";
1803
1801
  PENDING: "PENDING";
1804
1802
  COMPLETED: "COMPLETED";
1805
1803
  CREATED: "CREATED";
@@ -2396,14 +2394,29 @@ declare const updateAccountInputSchema: z.ZodObject<{
2396
2394
  type UpdateAccountInput = z.infer<typeof updateAccountInputSchema>;
2397
2395
  type UpdateAccountOutput = AccountSelectType;
2398
2396
 
2399
- type AccountWithWorkflow = AccountSelectType & {
2400
- workflow: {
2401
- instanceId: string;
2402
- details: WorkflowInstanceStatus;
2403
- } | null;
2397
+ declare const getBankAccountsInputSchema: z.ZodObject<{
2398
+ includes: z.ZodOptional<z.ZodObject<{
2399
+ workflow: z.ZodOptional<z.ZodBoolean>;
2400
+ batchCounts: z.ZodOptional<z.ZodBoolean>;
2401
+ }, z.core.$strip>>;
2402
+ }, z.core.$strip>;
2403
+ type GetBankAccountsInput = z.infer<typeof getBankAccountsInputSchema>;
2404
+ type WorkflowInfo = {
2405
+ instanceId: string;
2406
+ details: WorkflowInstanceStatus;
2407
+ } | null;
2408
+ type BatchCounts = {
2409
+ totalCount: number;
2410
+ openCount: number;
2411
+ readyToSignCount: number;
2412
+ failedCount: number;
2413
+ };
2414
+ type AccountWithOptionalFields = AccountSelectType & {
2415
+ workflow?: WorkflowInfo;
2416
+ batches?: BatchCounts;
2404
2417
  };
2405
- type GetAccountsOutput = {
2406
- accounts: AccountWithWorkflow[];
2418
+ type GetBankAccountsOutput = {
2419
+ accounts: AccountWithOptionalFields[];
2407
2420
  totalCount: number;
2408
2421
  };
2409
2422
 
@@ -2499,14 +2512,14 @@ declare class BankServiceBase extends BankServiceBase_base {
2499
2512
  addPaymentsToBatch({ paymentsToBatch, }: {
2500
2513
  paymentsToBatch: SendPaymentInput[];
2501
2514
  }): Promise<IRPCResponse<{
2502
- status: "OPEN" | "FULL" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED" | "FAILED" | null;
2503
2515
  id: string;
2504
2516
  createdAt: Date | null;
2505
2517
  updatedAt: Date | null;
2506
2518
  deletedAt: Date | null;
2507
- accountId: string | null;
2508
2519
  batchPaymentInitiatedAt: Date | null;
2509
2520
  authorizationUrls: string[] | null;
2521
+ status: "FAILED" | "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED" | null;
2522
+ accountId: string | null;
2510
2523
  statusReason: string | null;
2511
2524
  payments: PaymentInsertType[];
2512
2525
  metadata: BatchMetadata | null;
@@ -2520,7 +2533,7 @@ declare class BankServiceBase extends BankServiceBase_base {
2520
2533
  authorizeAccount(input: AuthorizeAccountInput): Promise<IRPCResponse<AuthorizeAccountOutput>>;
2521
2534
  simulateDeposit(input: SimulateDepositInput): Promise<IRPCResponse<SimulateDepositOutput>>;
2522
2535
  sendPayment(input: SendPaymentInput): Promise<IRPCResponse<SendPaymentOutput>>;
2523
- getBankAccounts(): Promise<IRPCResponse<GetAccountsOutput>>;
2536
+ getBankAccounts(input: GetBankAccountsInput): Promise<IRPCResponse<GetBankAccountsOutput>>;
2524
2537
  updateAccount(input: UpdateAccountInput): Promise<IRPCResponse<UpdateAccountOutput>>;
2525
2538
  disconnectAccount(input: DisconnectAccountInput): Promise<IRPCResponse<DisconnectAccountOutput>>;
2526
2539
  getBatches(input: GetBatchesInput): Promise<IRPCResponse<GetBatchesOutput>>;
@@ -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.BEL1HIxZ.mjs';
1
+ import { A as AccountSelectType, P as PaymentSelectType, B as BatchSelectType, L as LastSyncMetadata, C as ConfigEnvironmentBank, t as tables, a as ConnectorKey, I as IBankConnector, b as PaymentInsertType, c as BatchMetadata } from '../shared/bank.CG0gMBFx.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';
@@ -1531,21 +1531,19 @@ declare const getBatchesInputSchema: z.ZodObject<{
1531
1531
  }, z.core.$strip>;
1532
1532
  filterBatchAccountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodUUID, z.ZodArray<z.ZodUUID>]>>;
1533
1533
  filterBatchStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
1534
+ FAILED: "FAILED";
1534
1535
  OPEN: "OPEN";
1535
- FULL: "FULL";
1536
1536
  PROCESSING: "PROCESSING";
1537
1537
  READY_TO_SIGN: "READY_TO_SIGN";
1538
1538
  SIGNED: "SIGNED";
1539
1539
  SIGNATURE_FAILED: "SIGNATURE_FAILED";
1540
- FAILED: "FAILED";
1541
1540
  }>, z.ZodArray<z.ZodEnum<{
1541
+ FAILED: "FAILED";
1542
1542
  OPEN: "OPEN";
1543
- FULL: "FULL";
1544
1543
  PROCESSING: "PROCESSING";
1545
1544
  READY_TO_SIGN: "READY_TO_SIGN";
1546
1545
  SIGNED: "SIGNED";
1547
1546
  SIGNATURE_FAILED: "SIGNATURE_FAILED";
1548
- FAILED: "FAILED";
1549
1547
  }>>]>>;
1550
1548
  }, z.core.$strip>;
1551
1549
  type GetBatchesInput = z.input<typeof getBatchesInputSchema>;
@@ -1790,16 +1788,16 @@ declare const getPaymentsInputSchema: z.ZodObject<{
1790
1788
  filterPaymentDateFrom: z.ZodOptional<z.ZodDate>;
1791
1789
  filterPaymentDateTo: z.ZodOptional<z.ZodDate>;
1792
1790
  filterPaymentStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
1793
- FAILED: "FAILED";
1794
1791
  PREPARED: "PREPARED";
1795
1792
  INITIALIZED: "INITIALIZED";
1793
+ FAILED: "FAILED";
1796
1794
  PENDING: "PENDING";
1797
1795
  COMPLETED: "COMPLETED";
1798
1796
  CREATED: "CREATED";
1799
1797
  }>, z.ZodArray<z.ZodEnum<{
1800
- FAILED: "FAILED";
1801
1798
  PREPARED: "PREPARED";
1802
1799
  INITIALIZED: "INITIALIZED";
1800
+ FAILED: "FAILED";
1803
1801
  PENDING: "PENDING";
1804
1802
  COMPLETED: "COMPLETED";
1805
1803
  CREATED: "CREATED";
@@ -2396,14 +2394,29 @@ declare const updateAccountInputSchema: z.ZodObject<{
2396
2394
  type UpdateAccountInput = z.infer<typeof updateAccountInputSchema>;
2397
2395
  type UpdateAccountOutput = AccountSelectType;
2398
2396
 
2399
- type AccountWithWorkflow = AccountSelectType & {
2400
- workflow: {
2401
- instanceId: string;
2402
- details: WorkflowInstanceStatus;
2403
- } | null;
2397
+ declare const getBankAccountsInputSchema: z.ZodObject<{
2398
+ includes: z.ZodOptional<z.ZodObject<{
2399
+ workflow: z.ZodOptional<z.ZodBoolean>;
2400
+ batchCounts: z.ZodOptional<z.ZodBoolean>;
2401
+ }, z.core.$strip>>;
2402
+ }, z.core.$strip>;
2403
+ type GetBankAccountsInput = z.infer<typeof getBankAccountsInputSchema>;
2404
+ type WorkflowInfo = {
2405
+ instanceId: string;
2406
+ details: WorkflowInstanceStatus;
2407
+ } | null;
2408
+ type BatchCounts = {
2409
+ totalCount: number;
2410
+ openCount: number;
2411
+ readyToSignCount: number;
2412
+ failedCount: number;
2413
+ };
2414
+ type AccountWithOptionalFields = AccountSelectType & {
2415
+ workflow?: WorkflowInfo;
2416
+ batches?: BatchCounts;
2404
2417
  };
2405
- type GetAccountsOutput = {
2406
- accounts: AccountWithWorkflow[];
2418
+ type GetBankAccountsOutput = {
2419
+ accounts: AccountWithOptionalFields[];
2407
2420
  totalCount: number;
2408
2421
  };
2409
2422
 
@@ -2499,14 +2512,14 @@ declare class BankServiceBase extends BankServiceBase_base {
2499
2512
  addPaymentsToBatch({ paymentsToBatch, }: {
2500
2513
  paymentsToBatch: SendPaymentInput[];
2501
2514
  }): Promise<IRPCResponse<{
2502
- status: "OPEN" | "FULL" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED" | "FAILED" | null;
2503
2515
  id: string;
2504
2516
  createdAt: Date | null;
2505
2517
  updatedAt: Date | null;
2506
2518
  deletedAt: Date | null;
2507
- accountId: string | null;
2508
2519
  batchPaymentInitiatedAt: Date | null;
2509
2520
  authorizationUrls: string[] | null;
2521
+ status: "FAILED" | "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED" | null;
2522
+ accountId: string | null;
2510
2523
  statusReason: string | null;
2511
2524
  payments: PaymentInsertType[];
2512
2525
  metadata: BatchMetadata | null;
@@ -2520,7 +2533,7 @@ declare class BankServiceBase extends BankServiceBase_base {
2520
2533
  authorizeAccount(input: AuthorizeAccountInput): Promise<IRPCResponse<AuthorizeAccountOutput>>;
2521
2534
  simulateDeposit(input: SimulateDepositInput): Promise<IRPCResponse<SimulateDepositOutput>>;
2522
2535
  sendPayment(input: SendPaymentInput): Promise<IRPCResponse<SendPaymentOutput>>;
2523
- getBankAccounts(): Promise<IRPCResponse<GetAccountsOutput>>;
2536
+ getBankAccounts(input: GetBankAccountsInput): Promise<IRPCResponse<GetBankAccountsOutput>>;
2524
2537
  updateAccount(input: UpdateAccountInput): Promise<IRPCResponse<UpdateAccountOutput>>;
2525
2538
  disconnectAccount(input: DisconnectAccountInput): Promise<IRPCResponse<DisconnectAccountOutput>>;
2526
2539
  getBatches(input: GetBatchesInput): Promise<IRPCResponse<GetBatchesOutput>>;
@@ -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.BEL1HIxZ.js';
1
+ import { A as AccountSelectType, P as PaymentSelectType, B as BatchSelectType, L as LastSyncMetadata, C as ConfigEnvironmentBank, t as tables, a as ConnectorKey, I as IBankConnector, b as PaymentInsertType, c as BatchMetadata } from '../shared/bank.CG0gMBFx.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';
@@ -1531,21 +1531,19 @@ declare const getBatchesInputSchema: z.ZodObject<{
1531
1531
  }, z.core.$strip>;
1532
1532
  filterBatchAccountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodUUID, z.ZodArray<z.ZodUUID>]>>;
1533
1533
  filterBatchStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
1534
+ FAILED: "FAILED";
1534
1535
  OPEN: "OPEN";
1535
- FULL: "FULL";
1536
1536
  PROCESSING: "PROCESSING";
1537
1537
  READY_TO_SIGN: "READY_TO_SIGN";
1538
1538
  SIGNED: "SIGNED";
1539
1539
  SIGNATURE_FAILED: "SIGNATURE_FAILED";
1540
- FAILED: "FAILED";
1541
1540
  }>, z.ZodArray<z.ZodEnum<{
1541
+ FAILED: "FAILED";
1542
1542
  OPEN: "OPEN";
1543
- FULL: "FULL";
1544
1543
  PROCESSING: "PROCESSING";
1545
1544
  READY_TO_SIGN: "READY_TO_SIGN";
1546
1545
  SIGNED: "SIGNED";
1547
1546
  SIGNATURE_FAILED: "SIGNATURE_FAILED";
1548
- FAILED: "FAILED";
1549
1547
  }>>]>>;
1550
1548
  }, z.core.$strip>;
1551
1549
  type GetBatchesInput = z.input<typeof getBatchesInputSchema>;
@@ -1790,16 +1788,16 @@ declare const getPaymentsInputSchema: z.ZodObject<{
1790
1788
  filterPaymentDateFrom: z.ZodOptional<z.ZodDate>;
1791
1789
  filterPaymentDateTo: z.ZodOptional<z.ZodDate>;
1792
1790
  filterPaymentStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
1793
- FAILED: "FAILED";
1794
1791
  PREPARED: "PREPARED";
1795
1792
  INITIALIZED: "INITIALIZED";
1793
+ FAILED: "FAILED";
1796
1794
  PENDING: "PENDING";
1797
1795
  COMPLETED: "COMPLETED";
1798
1796
  CREATED: "CREATED";
1799
1797
  }>, z.ZodArray<z.ZodEnum<{
1800
- FAILED: "FAILED";
1801
1798
  PREPARED: "PREPARED";
1802
1799
  INITIALIZED: "INITIALIZED";
1800
+ FAILED: "FAILED";
1803
1801
  PENDING: "PENDING";
1804
1802
  COMPLETED: "COMPLETED";
1805
1803
  CREATED: "CREATED";
@@ -2396,14 +2394,29 @@ declare const updateAccountInputSchema: z.ZodObject<{
2396
2394
  type UpdateAccountInput = z.infer<typeof updateAccountInputSchema>;
2397
2395
  type UpdateAccountOutput = AccountSelectType;
2398
2396
 
2399
- type AccountWithWorkflow = AccountSelectType & {
2400
- workflow: {
2401
- instanceId: string;
2402
- details: WorkflowInstanceStatus;
2403
- } | null;
2397
+ declare const getBankAccountsInputSchema: z.ZodObject<{
2398
+ includes: z.ZodOptional<z.ZodObject<{
2399
+ workflow: z.ZodOptional<z.ZodBoolean>;
2400
+ batchCounts: z.ZodOptional<z.ZodBoolean>;
2401
+ }, z.core.$strip>>;
2402
+ }, z.core.$strip>;
2403
+ type GetBankAccountsInput = z.infer<typeof getBankAccountsInputSchema>;
2404
+ type WorkflowInfo = {
2405
+ instanceId: string;
2406
+ details: WorkflowInstanceStatus;
2407
+ } | null;
2408
+ type BatchCounts = {
2409
+ totalCount: number;
2410
+ openCount: number;
2411
+ readyToSignCount: number;
2412
+ failedCount: number;
2413
+ };
2414
+ type AccountWithOptionalFields = AccountSelectType & {
2415
+ workflow?: WorkflowInfo;
2416
+ batches?: BatchCounts;
2404
2417
  };
2405
- type GetAccountsOutput = {
2406
- accounts: AccountWithWorkflow[];
2418
+ type GetBankAccountsOutput = {
2419
+ accounts: AccountWithOptionalFields[];
2407
2420
  totalCount: number;
2408
2421
  };
2409
2422
 
@@ -2499,14 +2512,14 @@ declare class BankServiceBase extends BankServiceBase_base {
2499
2512
  addPaymentsToBatch({ paymentsToBatch, }: {
2500
2513
  paymentsToBatch: SendPaymentInput[];
2501
2514
  }): Promise<IRPCResponse<{
2502
- status: "OPEN" | "FULL" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED" | "FAILED" | null;
2503
2515
  id: string;
2504
2516
  createdAt: Date | null;
2505
2517
  updatedAt: Date | null;
2506
2518
  deletedAt: Date | null;
2507
- accountId: string | null;
2508
2519
  batchPaymentInitiatedAt: Date | null;
2509
2520
  authorizationUrls: string[] | null;
2521
+ status: "FAILED" | "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED" | null;
2522
+ accountId: string | null;
2510
2523
  statusReason: string | null;
2511
2524
  payments: PaymentInsertType[];
2512
2525
  metadata: BatchMetadata | null;
@@ -2520,7 +2533,7 @@ declare class BankServiceBase extends BankServiceBase_base {
2520
2533
  authorizeAccount(input: AuthorizeAccountInput): Promise<IRPCResponse<AuthorizeAccountOutput>>;
2521
2534
  simulateDeposit(input: SimulateDepositInput): Promise<IRPCResponse<SimulateDepositOutput>>;
2522
2535
  sendPayment(input: SendPaymentInput): Promise<IRPCResponse<SendPaymentOutput>>;
2523
- getBankAccounts(): Promise<IRPCResponse<GetAccountsOutput>>;
2536
+ getBankAccounts(input: GetBankAccountsInput): Promise<IRPCResponse<GetBankAccountsOutput>>;
2524
2537
  updateAccount(input: UpdateAccountInput): Promise<IRPCResponse<UpdateAccountOutput>>;
2525
2538
  disconnectAccount(input: DisconnectAccountInput): Promise<IRPCResponse<DisconnectAccountOutput>>;
2526
2539
  getBatches(input: GetBatchesInput): Promise<IRPCResponse<GetBatchesOutput>>;
@@ -1,15 +1,15 @@
1
- import { uuidv4, bankAccountMetadataSchema, workflowInstanceStatusSchema, develitWorker, createInternalError, first, action, service } from '@develit-io/backend-sdk';
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.B1Gpn3ht.mjs';
4
+ import { t as tables } from '../shared/bank.D7JSg_d9.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.D-3fzX63.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.m2X4FSvr.mjs';
7
7
  import { CURRENCY_CODES } from '@develit-io/general-codes';
8
8
  import 'date-fns';
9
- import { eq, inArray, and, sql, asc, desc, gte, lte } from 'drizzle-orm';
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.BUEmFxS8.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.DYJuicD-.mjs';
13
13
  import 'drizzle-orm/sqlite-core';
14
14
  import 'drizzle-orm/relations';
15
15
  import 'drizzle-zod';
@@ -91,6 +91,27 @@ const deletePaymentsByAccountCommand = (db, { accountId }) => {
91
91
  };
92
92
  };
93
93
 
94
+ const getAccountBatchCountsQuery = async (db, { accountId }) => {
95
+ const result = await db.select({
96
+ totalCount: sql`COUNT(*)`.as("totalCount"),
97
+ openCount: sql`SUM(CASE WHEN ${tables.batch.status} = 'OPEN' THEN 1 ELSE 0 END)`.as(
98
+ "openCount"
99
+ ),
100
+ readyToSignCount: sql`SUM(CASE WHEN ${tables.batch.status} = 'READY_TO_SIGN' THEN 1 ELSE 0 END)`.as(
101
+ "readyToSignCount"
102
+ ),
103
+ failedCount: sql`SUM(CASE WHEN ${tables.batch.status} = 'FAILED' THEN 1 ELSE 0 END)`.as(
104
+ "failedCount"
105
+ )
106
+ }).from(tables.batch).where(eq(tables.batch.accountId, accountId)).then(first);
107
+ return result || {
108
+ totalCount: 0,
109
+ openCount: 0,
110
+ readyToSignCount: 0,
111
+ failedCount: 0
112
+ };
113
+ };
114
+
94
115
  const getAccountByIbanQuery = async (db, { iban }) => {
95
116
  return await db.select().from(tables.account).where(eq(tables.account.iban, iban)).get();
96
117
  };
@@ -383,6 +404,13 @@ const updateAccountInputSchema = z.object({
383
404
  account: accountInsertSchema
384
405
  });
385
406
 
407
+ const getBankAccountsInputSchema = z.object({
408
+ includes: z.object({
409
+ workflow: z.boolean().optional(),
410
+ batchCounts: z.boolean().optional()
411
+ }).optional()
412
+ });
413
+
386
414
  const disconnectAccountInputSchema = z.object({
387
415
  accountId: z.uuid()
388
416
  });
@@ -979,32 +1007,41 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
979
1007
  }
980
1008
  );
981
1009
  }
982
- async getBankAccounts() {
1010
+ async getBankAccounts(input) {
983
1011
  return this.handleAction(
984
- null,
1012
+ { data: input, schema: getBankAccountsInputSchema },
985
1013
  { successMessage: "Bank accounts retrieved successfully" },
986
- async () => {
1014
+ async ({ includes }) => {
987
1015
  const accounts = await this._getAccounts();
988
- const accountsWithWorkflows = await Promise.all(
1016
+ const includeWorkflow = includes?.workflow ?? true;
1017
+ const includeBatchCounts = includes?.batchCounts ?? false;
1018
+ const accountsWithOptionalFields = await Promise.all(
989
1019
  accounts.map(async (a) => {
990
- let status;
991
- try {
992
- const instance = await this.env.SYNC_ACCOUNT_PAYMENTS_WORKFLOW.get(a.id);
993
- status = await instance.status();
994
- } catch (_) {
995
- status = null;
996
- }
997
- return {
998
- ...a,
999
- workflow: status ? {
1020
+ const result = { ...a };
1021
+ if (includeWorkflow) {
1022
+ let status;
1023
+ try {
1024
+ const instance = await this.env.SYNC_ACCOUNT_PAYMENTS_WORKFLOW.get(a.id);
1025
+ status = await instance.status();
1026
+ } catch (_) {
1027
+ status = null;
1028
+ }
1029
+ result.workflow = status ? {
1000
1030
  instanceId: a.id,
1001
1031
  details: status
1002
- } : null
1003
- };
1032
+ } : null;
1033
+ }
1034
+ if (includeBatchCounts) {
1035
+ const batchCounts = await getAccountBatchCountsQuery(this.db, {
1036
+ accountId: a.id
1037
+ });
1038
+ result.batches = batchCounts;
1039
+ }
1040
+ return result;
1004
1041
  })
1005
1042
  );
1006
1043
  return {
1007
- accounts: accountsWithWorkflows,
1044
+ accounts: accountsWithOptionalFields,
1008
1045
  totalCount: accounts.length
1009
1046
  };
1010
1047
  }
@@ -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.CPYfE-Ei.cjs');
6
+ const drizzle = require('../shared/bank.DXj5tpXa.cjs');
7
7
  const backendSdk = require('@develit-io/backend-sdk');
8
- const encryption = require('../shared/bank.D0a-MZon.cjs');
8
+ const encryption = require('../shared/bank.CwRMB9Ek.cjs');
9
9
  const drizzleOrm = require('drizzle-orm');
10
10
  require('date-fns');
11
- require('../shared/bank.CpwLFudl.cjs');
11
+ require('../shared/bank.BfBw79Y1.cjs');
12
12
  require('drizzle-orm/sqlite-core');
13
13
  require('drizzle-orm/relations');
14
14
  require('@develit-io/general-codes');
@@ -196,7 +196,7 @@ class BankProcessBatch extends cloudflare_workers.WorkflowEntrypoint {
196
196
  throw new cloudflare_workflows.NonRetryableError(
197
197
  `Batch is in FAILED status and cannot be processed, manual review needed`
198
198
  );
199
- if (batch.status === "OPEN" || batch.status === "FULL") {
199
+ if (batch.status === "OPEN") {
200
200
  const updatedBatch = await encryption.upsertBatchCommand(db, {
201
201
  batch: {
202
202
  ...batch,
@@ -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.B1Gpn3ht.mjs';
4
+ import { t as tables } from '../shared/bank.D7JSg_d9.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.BUEmFxS8.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.DYJuicD-.mjs';
7
7
  import { eq } from 'drizzle-orm';
8
8
  import 'date-fns';
9
- import '../shared/bank.D-3fzX63.mjs';
9
+ import '../shared/bank.m2X4FSvr.mjs';
10
10
  import 'drizzle-orm/sqlite-core';
11
11
  import 'drizzle-orm/relations';
12
12
  import '@develit-io/general-codes';
@@ -194,7 +194,7 @@ class BankProcessBatch extends WorkflowEntrypoint {
194
194
  throw new NonRetryableError(
195
195
  `Batch is in FAILED status and cannot be processed, manual review needed`
196
196
  );
197
- if (batch.status === "OPEN" || batch.status === "FULL") {
197
+ if (batch.status === "OPEN") {
198
198
  const updatedBatch = await upsertBatchCommand(db, {
199
199
  batch: {
200
200
  ...batch,
@@ -24,7 +24,6 @@ const PAYMENT_STATUSES = [
24
24
  const PAYMENT_DIRECTIONS = ["INCOMING", "OUTGOING"];
25
25
  const BATCH_STATUSES = [
26
26
  "OPEN",
27
- "FULL",
28
27
  "PROCESSING",
29
28
  "READY_TO_SIGN",
30
29
  "SIGNED",
@@ -71,20 +71,20 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
71
71
  tableName: "batch";
72
72
  dataType: "string";
73
73
  columnType: "SQLiteText";
74
- data: "OPEN" | "FULL" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED" | "FAILED";
74
+ data: "FAILED" | "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED";
75
75
  driverParam: string;
76
76
  notNull: false;
77
77
  hasDefault: false;
78
78
  isPrimaryKey: false;
79
79
  isAutoincrement: false;
80
80
  hasRuntimeDefault: false;
81
- enumValues: ["OPEN", "FULL", "PROCESSING", "READY_TO_SIGN", "SIGNED", "SIGNATURE_FAILED", "FAILED"];
81
+ enumValues: ["OPEN", "PROCESSING", "READY_TO_SIGN", "SIGNED", "SIGNATURE_FAILED", "FAILED"];
82
82
  baseColumn: never;
83
83
  identity: undefined;
84
84
  generated: undefined;
85
85
  }, {}, {
86
86
  length: number | undefined;
87
- $type: "OPEN" | "FULL" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED" | "FAILED";
87
+ $type: "FAILED" | "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED";
88
88
  }>;
89
89
  statusReason: drizzle_orm_sqlite_core.SQLiteColumn<{
90
90
  name: "status_reason";
@@ -418,7 +418,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
418
418
  tableName: "payment";
419
419
  dataType: "string";
420
420
  columnType: "SQLiteText";
421
- data: "FAILED" | "PREPARED" | "INITIALIZED" | "PENDING" | "COMPLETED" | "CREATED";
421
+ data: "PREPARED" | "INITIALIZED" | "FAILED" | "PENDING" | "COMPLETED" | "CREATED";
422
422
  driverParam: string;
423
423
  notNull: true;
424
424
  hasDefault: false;
@@ -431,7 +431,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
431
431
  generated: undefined;
432
432
  }, {}, {
433
433
  length: number | undefined;
434
- $type: "FAILED" | "PREPARED" | "INITIALIZED" | "PENDING" | "COMPLETED" | "CREATED";
434
+ $type: "PREPARED" | "INITIALIZED" | "FAILED" | "PENDING" | "COMPLETED" | "CREATED";
435
435
  }>;
436
436
  statusReason: drizzle_orm_sqlite_core.SQLiteColumn<{
437
437
  name: "status_reason";
@@ -1607,7 +1607,7 @@ type CurrencyCode = (typeof CURRENCY_CODES)[number];
1607
1607
  /**
1608
1608
  * Batch status constants
1609
1609
  */
1610
- declare const BATCH_STATUSES: readonly ["OPEN", "FULL", "PROCESSING", "READY_TO_SIGN", "SIGNED", "SIGNATURE_FAILED", "FAILED"];
1610
+ declare const BATCH_STATUSES: readonly ["OPEN", "PROCESSING", "READY_TO_SIGN", "SIGNED", "SIGNATURE_FAILED", "FAILED"];
1611
1611
  /**
1612
1612
  * Type definition for batch status
1613
1613
  */
@@ -71,20 +71,20 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
71
71
  tableName: "batch";
72
72
  dataType: "string";
73
73
  columnType: "SQLiteText";
74
- data: "OPEN" | "FULL" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED" | "FAILED";
74
+ data: "FAILED" | "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED";
75
75
  driverParam: string;
76
76
  notNull: false;
77
77
  hasDefault: false;
78
78
  isPrimaryKey: false;
79
79
  isAutoincrement: false;
80
80
  hasRuntimeDefault: false;
81
- enumValues: ["OPEN", "FULL", "PROCESSING", "READY_TO_SIGN", "SIGNED", "SIGNATURE_FAILED", "FAILED"];
81
+ enumValues: ["OPEN", "PROCESSING", "READY_TO_SIGN", "SIGNED", "SIGNATURE_FAILED", "FAILED"];
82
82
  baseColumn: never;
83
83
  identity: undefined;
84
84
  generated: undefined;
85
85
  }, {}, {
86
86
  length: number | undefined;
87
- $type: "OPEN" | "FULL" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED" | "FAILED";
87
+ $type: "FAILED" | "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED";
88
88
  }>;
89
89
  statusReason: drizzle_orm_sqlite_core.SQLiteColumn<{
90
90
  name: "status_reason";
@@ -418,7 +418,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
418
418
  tableName: "payment";
419
419
  dataType: "string";
420
420
  columnType: "SQLiteText";
421
- data: "FAILED" | "PREPARED" | "INITIALIZED" | "PENDING" | "COMPLETED" | "CREATED";
421
+ data: "PREPARED" | "INITIALIZED" | "FAILED" | "PENDING" | "COMPLETED" | "CREATED";
422
422
  driverParam: string;
423
423
  notNull: true;
424
424
  hasDefault: false;
@@ -431,7 +431,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
431
431
  generated: undefined;
432
432
  }, {}, {
433
433
  length: number | undefined;
434
- $type: "FAILED" | "PREPARED" | "INITIALIZED" | "PENDING" | "COMPLETED" | "CREATED";
434
+ $type: "PREPARED" | "INITIALIZED" | "FAILED" | "PENDING" | "COMPLETED" | "CREATED";
435
435
  }>;
436
436
  statusReason: drizzle_orm_sqlite_core.SQLiteColumn<{
437
437
  name: "status_reason";
@@ -1607,7 +1607,7 @@ type CurrencyCode = (typeof CURRENCY_CODES)[number];
1607
1607
  /**
1608
1608
  * Batch status constants
1609
1609
  */
1610
- declare const BATCH_STATUSES: readonly ["OPEN", "FULL", "PROCESSING", "READY_TO_SIGN", "SIGNED", "SIGNATURE_FAILED", "FAILED"];
1610
+ declare const BATCH_STATUSES: readonly ["OPEN", "PROCESSING", "READY_TO_SIGN", "SIGNED", "SIGNATURE_FAILED", "FAILED"];
1611
1611
  /**
1612
1612
  * Type definition for batch status
1613
1613
  */
@@ -71,20 +71,20 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
71
71
  tableName: "batch";
72
72
  dataType: "string";
73
73
  columnType: "SQLiteText";
74
- data: "OPEN" | "FULL" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED" | "FAILED";
74
+ data: "FAILED" | "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED";
75
75
  driverParam: string;
76
76
  notNull: false;
77
77
  hasDefault: false;
78
78
  isPrimaryKey: false;
79
79
  isAutoincrement: false;
80
80
  hasRuntimeDefault: false;
81
- enumValues: ["OPEN", "FULL", "PROCESSING", "READY_TO_SIGN", "SIGNED", "SIGNATURE_FAILED", "FAILED"];
81
+ enumValues: ["OPEN", "PROCESSING", "READY_TO_SIGN", "SIGNED", "SIGNATURE_FAILED", "FAILED"];
82
82
  baseColumn: never;
83
83
  identity: undefined;
84
84
  generated: undefined;
85
85
  }, {}, {
86
86
  length: number | undefined;
87
- $type: "OPEN" | "FULL" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED" | "FAILED";
87
+ $type: "FAILED" | "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED";
88
88
  }>;
89
89
  statusReason: drizzle_orm_sqlite_core.SQLiteColumn<{
90
90
  name: "status_reason";
@@ -418,7 +418,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
418
418
  tableName: "payment";
419
419
  dataType: "string";
420
420
  columnType: "SQLiteText";
421
- data: "FAILED" | "PREPARED" | "INITIALIZED" | "PENDING" | "COMPLETED" | "CREATED";
421
+ data: "PREPARED" | "INITIALIZED" | "FAILED" | "PENDING" | "COMPLETED" | "CREATED";
422
422
  driverParam: string;
423
423
  notNull: true;
424
424
  hasDefault: false;
@@ -431,7 +431,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
431
431
  generated: undefined;
432
432
  }, {}, {
433
433
  length: number | undefined;
434
- $type: "FAILED" | "PREPARED" | "INITIALIZED" | "PENDING" | "COMPLETED" | "CREATED";
434
+ $type: "PREPARED" | "INITIALIZED" | "FAILED" | "PENDING" | "COMPLETED" | "CREATED";
435
435
  }>;
436
436
  statusReason: drizzle_orm_sqlite_core.SQLiteColumn<{
437
437
  name: "status_reason";
@@ -1607,7 +1607,7 @@ type CurrencyCode = (typeof CURRENCY_CODES)[number];
1607
1607
  /**
1608
1608
  * Batch status constants
1609
1609
  */
1610
- declare const BATCH_STATUSES: readonly ["OPEN", "FULL", "PROCESSING", "READY_TO_SIGN", "SIGNED", "SIGNATURE_FAILED", "FAILED"];
1610
+ declare const BATCH_STATUSES: readonly ["OPEN", "PROCESSING", "READY_TO_SIGN", "SIGNED", "SIGNATURE_FAILED", "FAILED"];
1611
1611
  /**
1612
1612
  * Type definition for batch status
1613
1613
  */
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
- const drizzle = require('./bank.CPYfE-Ei.cjs');
3
+ const drizzle = require('./bank.DXj5tpXa.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.CpwLFudl.cjs');
9
+ require('./bank.BfBw79Y1.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.D-3fzX63.mjs';
3
+ import { s as schema } from './bank.m2X4FSvr.mjs';
4
4
  import { and, eq } from 'drizzle-orm';
5
5
  import { importPKCS8, SignJWT } from 'jose';
6
6
  import '@develit-io/general-codes';
@@ -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.CpwLFudl.cjs');
5
+ const database_schema = require('./bank.BfBw79Y1.cjs');
6
6
  const drizzleOrm = require('drizzle-orm');
7
7
  const jose = require('jose');
8
8
  require('@develit-io/general-codes');
@@ -1,10 +1,10 @@
1
- import { t as tables, F as FinbricksConnector, M as MockConnector, a as MockCobsConnector, E as ErsteConnector } from './bank.B1Gpn3ht.mjs';
1
+ import { t as tables, F as FinbricksConnector, M as MockConnector, a as MockCobsConnector, E as ErsteConnector } from './bank.D7JSg_d9.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.D-3fzX63.mjs';
7
+ import './bank.m2X4FSvr.mjs';
8
8
  import { createHash } from 'node:crypto';
9
9
 
10
10
  const createPaymentCommand = (db, { payment }) => {
@@ -22,7 +22,6 @@ const PAYMENT_STATUSES = [
22
22
  const PAYMENT_DIRECTIONS = ["INCOMING", "OUTGOING"];
23
23
  const BATCH_STATUSES = [
24
24
  "OPEN",
25
- "FULL",
26
25
  "PROCESSING",
27
26
  "READY_TO_SIGN",
28
27
  "SIGNED",
package/dist/types.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const drizzle = require('./shared/bank.CPYfE-Ei.cjs');
4
- const database_schema = require('./shared/bank.CpwLFudl.cjs');
3
+ const drizzle = require('./shared/bank.DXj5tpXa.cjs');
4
+ const database_schema = require('./shared/bank.BfBw79Y1.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.BEL1HIxZ.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.BEL1HIxZ.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.CG0gMBFx.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.CG0gMBFx.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.BEL1HIxZ.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.BEL1HIxZ.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.CG0gMBFx.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.CG0gMBFx.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.BEL1HIxZ.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.BEL1HIxZ.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.CG0gMBFx.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.CG0gMBFx.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.B1Gpn3ht.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.D-3fzX63.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.D7JSg_d9.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.m2X4FSvr.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.46",
3
+ "version": "0.3.48",
4
4
  "author": "Develit.io s.r.o.",
5
5
  "type": "module",
6
6
  "exports": {