@develit-services/bank 2.2.3 → 2.4.0

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.
Files changed (35) hide show
  1. package/dist/database/schema.cjs +2 -1
  2. package/dist/database/schema.d.cts +1 -1
  3. package/dist/database/schema.d.mts +1 -1
  4. package/dist/database/schema.d.ts +1 -1
  5. package/dist/database/schema.mjs +2 -1
  6. package/dist/export/worker.cjs +15 -15
  7. package/dist/export/worker.d.cts +23 -2
  8. package/dist/export/worker.d.mts +23 -2
  9. package/dist/export/worker.d.ts +23 -2
  10. package/dist/export/worker.mjs +4 -4
  11. package/dist/export/workflows.cjs +11 -9
  12. package/dist/export/workflows.mjs +7 -5
  13. package/dist/export/wrangler.cjs +4 -1
  14. package/dist/export/wrangler.d.cts +10 -2
  15. package/dist/export/wrangler.d.mts +10 -2
  16. package/dist/export/wrangler.d.ts +10 -2
  17. package/dist/export/wrangler.mjs +4 -1
  18. package/dist/shared/{bank.B0EWZbAs.cjs → bank.B0I6H6AT.cjs} +1 -1
  19. package/dist/shared/{bank.Cw3K7nIh.d.cts → bank.BI2OxQsM.d.mts} +1 -1
  20. package/dist/shared/{bank.COez_hEH.d.mts → bank.BJ_vbyUT.d.cts} +80 -2
  21. package/dist/shared/{bank.COez_hEH.d.ts → bank.BJ_vbyUT.d.mts} +80 -2
  22. package/dist/shared/{bank.COez_hEH.d.cts → bank.BJ_vbyUT.d.ts} +80 -2
  23. package/dist/shared/{bank.t019WQuV.d.mts → bank.Bs0isbAY.d.ts} +1 -1
  24. package/dist/shared/{bank.VB_ZSWGd.d.ts → bank.Ca0iWjhb.d.cts} +1 -1
  25. package/dist/shared/{bank.CmgGdN-q.mjs → bank.IlVbIEuM.mjs} +389 -31
  26. package/dist/shared/{bank.CQfKMyzc.cjs → bank.c1sHv5v_.cjs} +425 -29
  27. package/dist/shared/{bank.UBWdag5k.mjs → bank.fZkUcrn9.mjs} +1 -1
  28. package/dist/types.cjs +25 -24
  29. package/dist/types.d.cts +30 -8
  30. package/dist/types.d.mts +30 -8
  31. package/dist/types.d.ts +30 -8
  32. package/dist/types.mjs +5 -5
  33. package/package.json +1 -1
  34. package/dist/shared/bank.C7MA33AX.mjs +0 -325
  35. package/dist/shared/bank.CIWYI18z.cjs +0 -363
package/dist/types.d.cts CHANGED
@@ -1,12 +1,12 @@
1
- import { I as IBankConnector, b as ConnectorKey, f as ConnectedAccount, c as PaymentType, g as CredentialsResolver, h as AccountCredentialsInsertType, i as AccountInsertType, j as BatchedPayment, k as InitiatedBatch, l as IncomingPayment, m as InitiatedPayment, A as AccountSelectType, n as ParsedBankPayment, o as PaymentRequestStatus, p as AuthorizationCallbackResult, q as BatchMetadata, r as Currency, a as PaymentSelectType, P as PaymentRequestSelectType, s as AccountAssignedPayment, u as PreparedPayment, v as CompletedPayment, w as PaymentRequestInsertType } from './shared/bank.COez_hEH.cjs';
2
- export { x as ACCOUNT_STATUSES, y as AccountCredentialsPatchType, z as AccountCredentialsSelectType, D as AccountCredentialsUpdateType, E as AccountPatchType, F as AccountStatus, G as AccountUpdateType, J as AuthorizedBatch, K as BATCH_MODES, M as BATCH_STATUES, M as BATCH_STATUSES, N as BankAccountWithLastSync, O as BankCode, Q as BatchInsertType, R as BatchLifecycle, S as BatchMode, T as BatchPayment, B as BatchSelectType, U as BatchStatus, V as CHARGE_BEARERS, W as CONNECTOR_KEYS, X as COUNTRY_CODES, Y as CREDENTIALS_TYPES, Z as ChargeBearer, _ as CompletedBatch, C as ConfigEnvironmentBank, $ as CountryCode, a0 as CredentialsType, d as CurrencyCode, a1 as INSTRUCTION_PRIORITIES, a2 as InstructionPriority, L as LastSyncMetadata, a3 as PAYMENT_DIRECTIONS, a4 as PAYMENT_REQUEST_STATUSES, a5 as PAYMENT_STATUSES, a6 as PAYMENT_TYPES, a7 as PaymentDirection, a8 as PaymentFailedInsertType, a9 as PaymentInsertType, aa as PaymentLifecycle, ab as PaymentPreparedInsertType, ac as PaymentStatus, ad as ProcessingBatch, ae as ReadyToSignBatch, af as ResolvedCredentials, ag as TOKEN_TYPES, ah as TokenType, ai as accountCredentialsInsertSchema, aj as accountCredentialsSelectSchema, ak as accountCredentialsUpdateSchema, al as accountInsertSchema, am as accountSelectSchema, an as accountUpdateSchema, ao as hasPaymentAccountAssigned, ap as isBatchAuthorized, aq as isBatchCompleted, ar as isBatchFailed, as as isBatchInitiated, at as isBatchProcessing, au as isBatchReadyToSign, av as isPaymentCompleted, aw as isPendingStatus, ax as isProcessedStatus, ay as isTerminalStatus } from './shared/bank.COez_hEH.cjs';
3
- import { d as FinbricksAccount, R as ReferenceType, S as SendPaymentInput } from './shared/bank.Cw3K7nIh.cjs';
4
- export { e as FinbricksAccountTransactionsResponse, f as FinbricksAccountsListResponse, g as FinbricksAuthTokenResponse, h as FinbricksBatchResponse, i as FinbricksConnectAccountResponse, j as FinbricksPaymentResponse, k as FinbricksSupportedBank, F as FinbricksSupportedBanksResponse, b as SendPaymentSyncInput } from './shared/bank.Cw3K7nIh.cjs';
1
+ import { I as IBankConnector, c as ConnectorKey, g as ConnectedAccount, d as PaymentType, h as CredentialsResolver, i as AccountCredentialsInsertType, j as AccountInsertType, k as BatchedPayment, l as InitiatedBatch, m as IncomingPayment, n as InitiatedPayment, A as AccountSelectType, o as ParsedBankPayment, p as PaymentRequestStatus, q as AuthorizationCallbackResult, r as BatchMetadata, s as Currency, a as PaymentSelectType, P as PaymentRequestSelectType, u as AccountAssignedPayment, v as PreparedPayment, w as CompletedPayment, x as PaymentRequestInsertType } from './shared/bank.BJ_vbyUT.cjs';
2
+ export { y as ACCOUNT_STATUSES, z as AccountCredentialsPatchType, D as AccountCredentialsSelectType, E as AccountCredentialsUpdateType, F as AccountPatchType, G as AccountStatus, J as AccountUpdateType, K as AuthorizedBatch, M as BATCH_MODES, N as BATCH_STATUES, N as BATCH_STATUSES, O as BankAccountWithLastSync, Q as BankCode, R as BatchInsertType, S as BatchLifecycle, T as BatchMode, U as BatchPayment, B as BatchSelectType, V as BatchStatus, W as CHARGE_BEARERS, X as CONNECTOR_KEYS, Y as COUNTRY_CODES, Z as CREDENTIALS_TYPES, _ as ChargeBearer, $ as CompletedBatch, b as ConfigEnvironmentBank, C as ConnectorConfig, a0 as CountryCode, a1 as CredentialsType, e as CurrencyCode, a2 as INSTRUCTION_PRIORITIES, a3 as InstructionPriority, L as LastSyncMetadata, a4 as PAYMENT_DIRECTIONS, a5 as PAYMENT_REQUEST_STATUSES, a6 as PAYMENT_STATUSES, a7 as PAYMENT_TYPES, a8 as PaymentDirection, a9 as PaymentFailedInsertType, aa as PaymentInsertType, ab as PaymentLifecycle, ac as PaymentPreparedInsertType, ad as PaymentStatus, ae as ProcessingBatch, af as ReadyToSignBatch, ag as ResolvedCredentials, ah as TOKEN_TYPES, ai as TokenType, aj as accountCredentialsInsertSchema, ak as accountCredentialsSelectSchema, al as accountCredentialsUpdateSchema, am as accountInsertSchema, an as accountSelectSchema, ao as accountUpdateSchema, ap as hasPaymentAccountAssigned, aq as isBatchAuthorized, ar as isBatchCompleted, as as isBatchFailed, at as isBatchInitiated, au as isBatchProcessing, av as isBatchReadyToSign, aw as isPaymentCompleted, ax as isPendingStatus, ay as isProcessedStatus, az as isTerminalStatus } from './shared/bank.BJ_vbyUT.cjs';
3
+ import { d as FinbricksAccount, R as ReferenceType, S as SendPaymentInput } from './shared/bank.Ca0iWjhb.cjs';
4
+ export { e as FinbricksAccountTransactionsResponse, f as FinbricksAccountsListResponse, g as FinbricksAuthTokenResponse, h as FinbricksBatchResponse, i as FinbricksConnectAccountResponse, j as FinbricksPaymentResponse, k as FinbricksSupportedBank, F as FinbricksSupportedBanksResponse, b as SendPaymentSyncInput } from './shared/bank.Ca0iWjhb.cjs';
5
+ import { z } from 'zod';
5
6
  export { a as BankServiceEnv, b as BankServiceEnvironmentConfig, B as BankServiceWranglerConfig } from './shared/bank.Bz4DIxJL.cjs';
6
7
  import { BaseEvent } from '@develit-io/backend-sdk';
7
8
  import * as drizzle_zod from 'drizzle-zod';
8
9
  import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
9
- import { z } from 'zod';
10
10
  export { BANK_CODES, CURRENCY_CODES } from '@develit-io/general-codes';
11
11
  import 'drizzle-orm';
12
12
  import 'zod/v4/core';
@@ -301,6 +301,27 @@ declare class CsobConnector extends FinbricksConnector {
301
301
  supportsBatch(paymentType: PaymentType): boolean;
302
302
  }
303
303
 
304
+ declare const dbuAccountConfigSchema: z.ZodObject<{
305
+ with4EyeApproval: z.ZodDefault<z.ZodEnum<{
306
+ Y: "Y";
307
+ N: "N";
308
+ }>>;
309
+ channelCode: z.ZodDefault<z.ZodString>;
310
+ actionTypeCode: z.ZodDefault<z.ZodString>;
311
+ transactionTypeCode: z.ZodDefault<z.ZodString>;
312
+ partialRealization: z.ZodDefault<z.ZodEnum<{
313
+ Y: "Y";
314
+ N: "N";
315
+ }>>;
316
+ forceRealization: z.ZodDefault<z.ZodEnum<{
317
+ Y: "Y";
318
+ N: "N";
319
+ }>>;
320
+ }, z.core.$strip>;
321
+ type DbuAccountConfig = z.infer<typeof dbuAccountConfigSchema>;
322
+ type DbuConnectedAccount = Omit<ConnectedAccount, 'config'> & {
323
+ config: DbuAccountConfig;
324
+ };
304
325
  interface DbuConnectorConfig {
305
326
  BASE_URL: string;
306
327
  USERNAME: string;
@@ -313,7 +334,7 @@ interface DbuConnectorConfig {
313
334
  }
314
335
  declare class DbuConnector extends IBankConnector {
315
336
  connectorKey: ConnectorKey;
316
- connectedAccounts: ConnectedAccount[];
337
+ connectedAccounts: DbuConnectedAccount[];
317
338
  readonly kv: KVNamespace;
318
339
  readonly api: Fetcher;
319
340
  private readonly baseUrl;
@@ -340,6 +361,7 @@ declare class DbuConnector extends IBankConnector {
340
361
  accounts: AccountInsertType[];
341
362
  }>;
342
363
  listAccounts(): Promise<AccountInsertType[]>;
364
+ private resolveAccount;
343
365
  private resolveIdAccountDebit;
344
366
  private resolveAccountDetails;
345
367
  private initiateInstantPayment;
@@ -1340,5 +1362,5 @@ declare function toCompletedPayment(payment: PreparedPayment, status: 'SETTLED'
1340
1362
  declare function toPaymentRequestInsert(payment: AccountAssignedPayment, batchId: string | null): PaymentRequestInsertType;
1341
1363
  declare function toBatchedPaymentFromPaymentRequest(sp: PaymentRequestSelectType): BatchedPayment;
1342
1364
 
1343
- export { AccountAssignedPayment, AccountCredentialsInsertType, AccountInsertType, AccountSelectType, BatchMetadata, BatchedPayment, CompletedPayment, ConnectedAccount, ConnectorKey, CredentialsResolver, CsobConnector, Currency, DbuConnector, ErsteConnector, FINBRICKS_ENDPOINTS, FinbricksAccount, FinbricksClient, FinbricksConnector, IBankConnector, IncomingPayment, IncomingPayment as IncomingPaymentMessage, InitiatedBatch, InitiatedPayment, KBConnector, MockCobsConnector, MockConnector, ParsedBankPayment, PaymentRequestInsertType, PaymentRequestSelectType, PaymentRequestStatus, PaymentSelectType, PaymentType, PreparedPayment, SendPaymentInput, assignAccount, ottInsertSchema, ottSelectSchema, ottUpdateSchema, signFinbricksJws, toBatchedPayment, toBatchedPaymentFromPaymentRequest, toCompletedPayment, toIncomingPayment, toPaymentRequestInsert, toPreparedPayment, useFinbricksFetch };
1344
- export type { BankPaymentEvent, BankPaymentRequestEvent, DbuConnectorConfig, ErsteAuthenticationResponse, ErsteBatchPaymentInitiationResponse, ErsteIncomingPaymentResponse, ErsteObtainAuthorizationURLResponse, ErstePaymentInitiationResponse, FinbricksBatchBody, FinbricksBatchStatus, FinbricksConnectAccountBody, FinbricksConnectorConfig, FinbricksEndpoint, FinbricksEndpointPath, FinbricksFetchConfig, FinbricksForeignPaymentBody, FinbricksGetBatchStatusBody, FinbricksGetBatchStatusResponse, FinbricksGetTransactionStatusResponse, FinbricksJWSData, FinbricksPaymentBody, FinbricksProvider, FinbricksRequestInit, FinbricksSupportedBanksQuery, FinbricksTransactionStatus, OneTimeTokenInsertType, OneTimeTokenPatchType, OneTimeTokenSelectType, OneTimeTokenUpdateType };
1365
+ export { AccountAssignedPayment, AccountCredentialsInsertType, AccountInsertType, AccountSelectType, BatchMetadata, BatchedPayment, CompletedPayment, ConnectedAccount, ConnectorKey, CredentialsResolver, CsobConnector, Currency, DbuConnector, ErsteConnector, FINBRICKS_ENDPOINTS, FinbricksAccount, FinbricksClient, FinbricksConnector, IBankConnector, IncomingPayment, IncomingPayment as IncomingPaymentMessage, InitiatedBatch, InitiatedPayment, KBConnector, MockCobsConnector, MockConnector, ParsedBankPayment, PaymentRequestInsertType, PaymentRequestSelectType, PaymentRequestStatus, PaymentSelectType, PaymentType, PreparedPayment, SendPaymentInput, assignAccount, dbuAccountConfigSchema, ottInsertSchema, ottSelectSchema, ottUpdateSchema, signFinbricksJws, toBatchedPayment, toBatchedPaymentFromPaymentRequest, toCompletedPayment, toIncomingPayment, toPaymentRequestInsert, toPreparedPayment, useFinbricksFetch };
1366
+ export type { BankPaymentEvent, BankPaymentRequestEvent, DbuAccountConfig, DbuConnectorConfig, ErsteAuthenticationResponse, ErsteBatchPaymentInitiationResponse, ErsteIncomingPaymentResponse, ErsteObtainAuthorizationURLResponse, ErstePaymentInitiationResponse, FinbricksBatchBody, FinbricksBatchStatus, FinbricksConnectAccountBody, FinbricksConnectorConfig, FinbricksEndpoint, FinbricksEndpointPath, FinbricksFetchConfig, FinbricksForeignPaymentBody, FinbricksGetBatchStatusBody, FinbricksGetBatchStatusResponse, FinbricksGetTransactionStatusResponse, FinbricksJWSData, FinbricksPaymentBody, FinbricksProvider, FinbricksRequestInit, FinbricksSupportedBanksQuery, FinbricksTransactionStatus, OneTimeTokenInsertType, OneTimeTokenPatchType, OneTimeTokenSelectType, OneTimeTokenUpdateType };
package/dist/types.d.mts CHANGED
@@ -1,12 +1,12 @@
1
- import { I as IBankConnector, b as ConnectorKey, f as ConnectedAccount, c as PaymentType, g as CredentialsResolver, h as AccountCredentialsInsertType, i as AccountInsertType, j as BatchedPayment, k as InitiatedBatch, l as IncomingPayment, m as InitiatedPayment, A as AccountSelectType, n as ParsedBankPayment, o as PaymentRequestStatus, p as AuthorizationCallbackResult, q as BatchMetadata, r as Currency, a as PaymentSelectType, P as PaymentRequestSelectType, s as AccountAssignedPayment, u as PreparedPayment, v as CompletedPayment, w as PaymentRequestInsertType } from './shared/bank.COez_hEH.mjs';
2
- export { x as ACCOUNT_STATUSES, y as AccountCredentialsPatchType, z as AccountCredentialsSelectType, D as AccountCredentialsUpdateType, E as AccountPatchType, F as AccountStatus, G as AccountUpdateType, J as AuthorizedBatch, K as BATCH_MODES, M as BATCH_STATUES, M as BATCH_STATUSES, N as BankAccountWithLastSync, O as BankCode, Q as BatchInsertType, R as BatchLifecycle, S as BatchMode, T as BatchPayment, B as BatchSelectType, U as BatchStatus, V as CHARGE_BEARERS, W as CONNECTOR_KEYS, X as COUNTRY_CODES, Y as CREDENTIALS_TYPES, Z as ChargeBearer, _ as CompletedBatch, C as ConfigEnvironmentBank, $ as CountryCode, a0 as CredentialsType, d as CurrencyCode, a1 as INSTRUCTION_PRIORITIES, a2 as InstructionPriority, L as LastSyncMetadata, a3 as PAYMENT_DIRECTIONS, a4 as PAYMENT_REQUEST_STATUSES, a5 as PAYMENT_STATUSES, a6 as PAYMENT_TYPES, a7 as PaymentDirection, a8 as PaymentFailedInsertType, a9 as PaymentInsertType, aa as PaymentLifecycle, ab as PaymentPreparedInsertType, ac as PaymentStatus, ad as ProcessingBatch, ae as ReadyToSignBatch, af as ResolvedCredentials, ag as TOKEN_TYPES, ah as TokenType, ai as accountCredentialsInsertSchema, aj as accountCredentialsSelectSchema, ak as accountCredentialsUpdateSchema, al as accountInsertSchema, am as accountSelectSchema, an as accountUpdateSchema, ao as hasPaymentAccountAssigned, ap as isBatchAuthorized, aq as isBatchCompleted, ar as isBatchFailed, as as isBatchInitiated, at as isBatchProcessing, au as isBatchReadyToSign, av as isPaymentCompleted, aw as isPendingStatus, ax as isProcessedStatus, ay as isTerminalStatus } from './shared/bank.COez_hEH.mjs';
3
- import { d as FinbricksAccount, R as ReferenceType, S as SendPaymentInput } from './shared/bank.t019WQuV.mjs';
4
- export { e as FinbricksAccountTransactionsResponse, f as FinbricksAccountsListResponse, g as FinbricksAuthTokenResponse, h as FinbricksBatchResponse, i as FinbricksConnectAccountResponse, j as FinbricksPaymentResponse, k as FinbricksSupportedBank, F as FinbricksSupportedBanksResponse, b as SendPaymentSyncInput } from './shared/bank.t019WQuV.mjs';
1
+ import { I as IBankConnector, c as ConnectorKey, g as ConnectedAccount, d as PaymentType, h as CredentialsResolver, i as AccountCredentialsInsertType, j as AccountInsertType, k as BatchedPayment, l as InitiatedBatch, m as IncomingPayment, n as InitiatedPayment, A as AccountSelectType, o as ParsedBankPayment, p as PaymentRequestStatus, q as AuthorizationCallbackResult, r as BatchMetadata, s as Currency, a as PaymentSelectType, P as PaymentRequestSelectType, u as AccountAssignedPayment, v as PreparedPayment, w as CompletedPayment, x as PaymentRequestInsertType } from './shared/bank.BJ_vbyUT.mjs';
2
+ export { y as ACCOUNT_STATUSES, z as AccountCredentialsPatchType, D as AccountCredentialsSelectType, E as AccountCredentialsUpdateType, F as AccountPatchType, G as AccountStatus, J as AccountUpdateType, K as AuthorizedBatch, M as BATCH_MODES, N as BATCH_STATUES, N as BATCH_STATUSES, O as BankAccountWithLastSync, Q as BankCode, R as BatchInsertType, S as BatchLifecycle, T as BatchMode, U as BatchPayment, B as BatchSelectType, V as BatchStatus, W as CHARGE_BEARERS, X as CONNECTOR_KEYS, Y as COUNTRY_CODES, Z as CREDENTIALS_TYPES, _ as ChargeBearer, $ as CompletedBatch, b as ConfigEnvironmentBank, C as ConnectorConfig, a0 as CountryCode, a1 as CredentialsType, e as CurrencyCode, a2 as INSTRUCTION_PRIORITIES, a3 as InstructionPriority, L as LastSyncMetadata, a4 as PAYMENT_DIRECTIONS, a5 as PAYMENT_REQUEST_STATUSES, a6 as PAYMENT_STATUSES, a7 as PAYMENT_TYPES, a8 as PaymentDirection, a9 as PaymentFailedInsertType, aa as PaymentInsertType, ab as PaymentLifecycle, ac as PaymentPreparedInsertType, ad as PaymentStatus, ae as ProcessingBatch, af as ReadyToSignBatch, ag as ResolvedCredentials, ah as TOKEN_TYPES, ai as TokenType, aj as accountCredentialsInsertSchema, ak as accountCredentialsSelectSchema, al as accountCredentialsUpdateSchema, am as accountInsertSchema, an as accountSelectSchema, ao as accountUpdateSchema, ap as hasPaymentAccountAssigned, aq as isBatchAuthorized, ar as isBatchCompleted, as as isBatchFailed, at as isBatchInitiated, au as isBatchProcessing, av as isBatchReadyToSign, aw as isPaymentCompleted, ax as isPendingStatus, ay as isProcessedStatus, az as isTerminalStatus } from './shared/bank.BJ_vbyUT.mjs';
3
+ import { d as FinbricksAccount, R as ReferenceType, S as SendPaymentInput } from './shared/bank.BI2OxQsM.mjs';
4
+ export { e as FinbricksAccountTransactionsResponse, f as FinbricksAccountsListResponse, g as FinbricksAuthTokenResponse, h as FinbricksBatchResponse, i as FinbricksConnectAccountResponse, j as FinbricksPaymentResponse, k as FinbricksSupportedBank, F as FinbricksSupportedBanksResponse, b as SendPaymentSyncInput } from './shared/bank.BI2OxQsM.mjs';
5
+ import { z } from 'zod';
5
6
  export { a as BankServiceEnv, b as BankServiceEnvironmentConfig, B as BankServiceWranglerConfig } from './shared/bank.Bz4DIxJL.mjs';
6
7
  import { BaseEvent } from '@develit-io/backend-sdk';
7
8
  import * as drizzle_zod from 'drizzle-zod';
8
9
  import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
9
- import { z } from 'zod';
10
10
  export { BANK_CODES, CURRENCY_CODES } from '@develit-io/general-codes';
11
11
  import 'drizzle-orm';
12
12
  import 'zod/v4/core';
@@ -301,6 +301,27 @@ declare class CsobConnector extends FinbricksConnector {
301
301
  supportsBatch(paymentType: PaymentType): boolean;
302
302
  }
303
303
 
304
+ declare const dbuAccountConfigSchema: z.ZodObject<{
305
+ with4EyeApproval: z.ZodDefault<z.ZodEnum<{
306
+ Y: "Y";
307
+ N: "N";
308
+ }>>;
309
+ channelCode: z.ZodDefault<z.ZodString>;
310
+ actionTypeCode: z.ZodDefault<z.ZodString>;
311
+ transactionTypeCode: z.ZodDefault<z.ZodString>;
312
+ partialRealization: z.ZodDefault<z.ZodEnum<{
313
+ Y: "Y";
314
+ N: "N";
315
+ }>>;
316
+ forceRealization: z.ZodDefault<z.ZodEnum<{
317
+ Y: "Y";
318
+ N: "N";
319
+ }>>;
320
+ }, z.core.$strip>;
321
+ type DbuAccountConfig = z.infer<typeof dbuAccountConfigSchema>;
322
+ type DbuConnectedAccount = Omit<ConnectedAccount, 'config'> & {
323
+ config: DbuAccountConfig;
324
+ };
304
325
  interface DbuConnectorConfig {
305
326
  BASE_URL: string;
306
327
  USERNAME: string;
@@ -313,7 +334,7 @@ interface DbuConnectorConfig {
313
334
  }
314
335
  declare class DbuConnector extends IBankConnector {
315
336
  connectorKey: ConnectorKey;
316
- connectedAccounts: ConnectedAccount[];
337
+ connectedAccounts: DbuConnectedAccount[];
317
338
  readonly kv: KVNamespace;
318
339
  readonly api: Fetcher;
319
340
  private readonly baseUrl;
@@ -340,6 +361,7 @@ declare class DbuConnector extends IBankConnector {
340
361
  accounts: AccountInsertType[];
341
362
  }>;
342
363
  listAccounts(): Promise<AccountInsertType[]>;
364
+ private resolveAccount;
343
365
  private resolveIdAccountDebit;
344
366
  private resolveAccountDetails;
345
367
  private initiateInstantPayment;
@@ -1340,5 +1362,5 @@ declare function toCompletedPayment(payment: PreparedPayment, status: 'SETTLED'
1340
1362
  declare function toPaymentRequestInsert(payment: AccountAssignedPayment, batchId: string | null): PaymentRequestInsertType;
1341
1363
  declare function toBatchedPaymentFromPaymentRequest(sp: PaymentRequestSelectType): BatchedPayment;
1342
1364
 
1343
- export { AccountAssignedPayment, AccountCredentialsInsertType, AccountInsertType, AccountSelectType, BatchMetadata, BatchedPayment, CompletedPayment, ConnectedAccount, ConnectorKey, CredentialsResolver, CsobConnector, Currency, DbuConnector, ErsteConnector, FINBRICKS_ENDPOINTS, FinbricksAccount, FinbricksClient, FinbricksConnector, IBankConnector, IncomingPayment, IncomingPayment as IncomingPaymentMessage, InitiatedBatch, InitiatedPayment, KBConnector, MockCobsConnector, MockConnector, ParsedBankPayment, PaymentRequestInsertType, PaymentRequestSelectType, PaymentRequestStatus, PaymentSelectType, PaymentType, PreparedPayment, SendPaymentInput, assignAccount, ottInsertSchema, ottSelectSchema, ottUpdateSchema, signFinbricksJws, toBatchedPayment, toBatchedPaymentFromPaymentRequest, toCompletedPayment, toIncomingPayment, toPaymentRequestInsert, toPreparedPayment, useFinbricksFetch };
1344
- export type { BankPaymentEvent, BankPaymentRequestEvent, DbuConnectorConfig, ErsteAuthenticationResponse, ErsteBatchPaymentInitiationResponse, ErsteIncomingPaymentResponse, ErsteObtainAuthorizationURLResponse, ErstePaymentInitiationResponse, FinbricksBatchBody, FinbricksBatchStatus, FinbricksConnectAccountBody, FinbricksConnectorConfig, FinbricksEndpoint, FinbricksEndpointPath, FinbricksFetchConfig, FinbricksForeignPaymentBody, FinbricksGetBatchStatusBody, FinbricksGetBatchStatusResponse, FinbricksGetTransactionStatusResponse, FinbricksJWSData, FinbricksPaymentBody, FinbricksProvider, FinbricksRequestInit, FinbricksSupportedBanksQuery, FinbricksTransactionStatus, OneTimeTokenInsertType, OneTimeTokenPatchType, OneTimeTokenSelectType, OneTimeTokenUpdateType };
1365
+ export { AccountAssignedPayment, AccountCredentialsInsertType, AccountInsertType, AccountSelectType, BatchMetadata, BatchedPayment, CompletedPayment, ConnectedAccount, ConnectorKey, CredentialsResolver, CsobConnector, Currency, DbuConnector, ErsteConnector, FINBRICKS_ENDPOINTS, FinbricksAccount, FinbricksClient, FinbricksConnector, IBankConnector, IncomingPayment, IncomingPayment as IncomingPaymentMessage, InitiatedBatch, InitiatedPayment, KBConnector, MockCobsConnector, MockConnector, ParsedBankPayment, PaymentRequestInsertType, PaymentRequestSelectType, PaymentRequestStatus, PaymentSelectType, PaymentType, PreparedPayment, SendPaymentInput, assignAccount, dbuAccountConfigSchema, ottInsertSchema, ottSelectSchema, ottUpdateSchema, signFinbricksJws, toBatchedPayment, toBatchedPaymentFromPaymentRequest, toCompletedPayment, toIncomingPayment, toPaymentRequestInsert, toPreparedPayment, useFinbricksFetch };
1366
+ export type { BankPaymentEvent, BankPaymentRequestEvent, DbuAccountConfig, DbuConnectorConfig, ErsteAuthenticationResponse, ErsteBatchPaymentInitiationResponse, ErsteIncomingPaymentResponse, ErsteObtainAuthorizationURLResponse, ErstePaymentInitiationResponse, FinbricksBatchBody, FinbricksBatchStatus, FinbricksConnectAccountBody, FinbricksConnectorConfig, FinbricksEndpoint, FinbricksEndpointPath, FinbricksFetchConfig, FinbricksForeignPaymentBody, FinbricksGetBatchStatusBody, FinbricksGetBatchStatusResponse, FinbricksGetTransactionStatusResponse, FinbricksJWSData, FinbricksPaymentBody, FinbricksProvider, FinbricksRequestInit, FinbricksSupportedBanksQuery, FinbricksTransactionStatus, OneTimeTokenInsertType, OneTimeTokenPatchType, OneTimeTokenSelectType, OneTimeTokenUpdateType };
package/dist/types.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { I as IBankConnector, b as ConnectorKey, f as ConnectedAccount, c as PaymentType, g as CredentialsResolver, h as AccountCredentialsInsertType, i as AccountInsertType, j as BatchedPayment, k as InitiatedBatch, l as IncomingPayment, m as InitiatedPayment, A as AccountSelectType, n as ParsedBankPayment, o as PaymentRequestStatus, p as AuthorizationCallbackResult, q as BatchMetadata, r as Currency, a as PaymentSelectType, P as PaymentRequestSelectType, s as AccountAssignedPayment, u as PreparedPayment, v as CompletedPayment, w as PaymentRequestInsertType } from './shared/bank.COez_hEH.js';
2
- export { x as ACCOUNT_STATUSES, y as AccountCredentialsPatchType, z as AccountCredentialsSelectType, D as AccountCredentialsUpdateType, E as AccountPatchType, F as AccountStatus, G as AccountUpdateType, J as AuthorizedBatch, K as BATCH_MODES, M as BATCH_STATUES, M as BATCH_STATUSES, N as BankAccountWithLastSync, O as BankCode, Q as BatchInsertType, R as BatchLifecycle, S as BatchMode, T as BatchPayment, B as BatchSelectType, U as BatchStatus, V as CHARGE_BEARERS, W as CONNECTOR_KEYS, X as COUNTRY_CODES, Y as CREDENTIALS_TYPES, Z as ChargeBearer, _ as CompletedBatch, C as ConfigEnvironmentBank, $ as CountryCode, a0 as CredentialsType, d as CurrencyCode, a1 as INSTRUCTION_PRIORITIES, a2 as InstructionPriority, L as LastSyncMetadata, a3 as PAYMENT_DIRECTIONS, a4 as PAYMENT_REQUEST_STATUSES, a5 as PAYMENT_STATUSES, a6 as PAYMENT_TYPES, a7 as PaymentDirection, a8 as PaymentFailedInsertType, a9 as PaymentInsertType, aa as PaymentLifecycle, ab as PaymentPreparedInsertType, ac as PaymentStatus, ad as ProcessingBatch, ae as ReadyToSignBatch, af as ResolvedCredentials, ag as TOKEN_TYPES, ah as TokenType, ai as accountCredentialsInsertSchema, aj as accountCredentialsSelectSchema, ak as accountCredentialsUpdateSchema, al as accountInsertSchema, am as accountSelectSchema, an as accountUpdateSchema, ao as hasPaymentAccountAssigned, ap as isBatchAuthorized, aq as isBatchCompleted, ar as isBatchFailed, as as isBatchInitiated, at as isBatchProcessing, au as isBatchReadyToSign, av as isPaymentCompleted, aw as isPendingStatus, ax as isProcessedStatus, ay as isTerminalStatus } from './shared/bank.COez_hEH.js';
3
- import { d as FinbricksAccount, R as ReferenceType, S as SendPaymentInput } from './shared/bank.VB_ZSWGd.js';
4
- export { e as FinbricksAccountTransactionsResponse, f as FinbricksAccountsListResponse, g as FinbricksAuthTokenResponse, h as FinbricksBatchResponse, i as FinbricksConnectAccountResponse, j as FinbricksPaymentResponse, k as FinbricksSupportedBank, F as FinbricksSupportedBanksResponse, b as SendPaymentSyncInput } from './shared/bank.VB_ZSWGd.js';
1
+ import { I as IBankConnector, c as ConnectorKey, g as ConnectedAccount, d as PaymentType, h as CredentialsResolver, i as AccountCredentialsInsertType, j as AccountInsertType, k as BatchedPayment, l as InitiatedBatch, m as IncomingPayment, n as InitiatedPayment, A as AccountSelectType, o as ParsedBankPayment, p as PaymentRequestStatus, q as AuthorizationCallbackResult, r as BatchMetadata, s as Currency, a as PaymentSelectType, P as PaymentRequestSelectType, u as AccountAssignedPayment, v as PreparedPayment, w as CompletedPayment, x as PaymentRequestInsertType } from './shared/bank.BJ_vbyUT.js';
2
+ export { y as ACCOUNT_STATUSES, z as AccountCredentialsPatchType, D as AccountCredentialsSelectType, E as AccountCredentialsUpdateType, F as AccountPatchType, G as AccountStatus, J as AccountUpdateType, K as AuthorizedBatch, M as BATCH_MODES, N as BATCH_STATUES, N as BATCH_STATUSES, O as BankAccountWithLastSync, Q as BankCode, R as BatchInsertType, S as BatchLifecycle, T as BatchMode, U as BatchPayment, B as BatchSelectType, V as BatchStatus, W as CHARGE_BEARERS, X as CONNECTOR_KEYS, Y as COUNTRY_CODES, Z as CREDENTIALS_TYPES, _ as ChargeBearer, $ as CompletedBatch, b as ConfigEnvironmentBank, C as ConnectorConfig, a0 as CountryCode, a1 as CredentialsType, e as CurrencyCode, a2 as INSTRUCTION_PRIORITIES, a3 as InstructionPriority, L as LastSyncMetadata, a4 as PAYMENT_DIRECTIONS, a5 as PAYMENT_REQUEST_STATUSES, a6 as PAYMENT_STATUSES, a7 as PAYMENT_TYPES, a8 as PaymentDirection, a9 as PaymentFailedInsertType, aa as PaymentInsertType, ab as PaymentLifecycle, ac as PaymentPreparedInsertType, ad as PaymentStatus, ae as ProcessingBatch, af as ReadyToSignBatch, ag as ResolvedCredentials, ah as TOKEN_TYPES, ai as TokenType, aj as accountCredentialsInsertSchema, ak as accountCredentialsSelectSchema, al as accountCredentialsUpdateSchema, am as accountInsertSchema, an as accountSelectSchema, ao as accountUpdateSchema, ap as hasPaymentAccountAssigned, aq as isBatchAuthorized, ar as isBatchCompleted, as as isBatchFailed, at as isBatchInitiated, au as isBatchProcessing, av as isBatchReadyToSign, aw as isPaymentCompleted, ax as isPendingStatus, ay as isProcessedStatus, az as isTerminalStatus } from './shared/bank.BJ_vbyUT.js';
3
+ import { d as FinbricksAccount, R as ReferenceType, S as SendPaymentInput } from './shared/bank.Bs0isbAY.js';
4
+ export { e as FinbricksAccountTransactionsResponse, f as FinbricksAccountsListResponse, g as FinbricksAuthTokenResponse, h as FinbricksBatchResponse, i as FinbricksConnectAccountResponse, j as FinbricksPaymentResponse, k as FinbricksSupportedBank, F as FinbricksSupportedBanksResponse, b as SendPaymentSyncInput } from './shared/bank.Bs0isbAY.js';
5
+ import { z } from 'zod';
5
6
  export { a as BankServiceEnv, b as BankServiceEnvironmentConfig, B as BankServiceWranglerConfig } from './shared/bank.Bz4DIxJL.js';
6
7
  import { BaseEvent } from '@develit-io/backend-sdk';
7
8
  import * as drizzle_zod from 'drizzle-zod';
8
9
  import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
9
- import { z } from 'zod';
10
10
  export { BANK_CODES, CURRENCY_CODES } from '@develit-io/general-codes';
11
11
  import 'drizzle-orm';
12
12
  import 'zod/v4/core';
@@ -301,6 +301,27 @@ declare class CsobConnector extends FinbricksConnector {
301
301
  supportsBatch(paymentType: PaymentType): boolean;
302
302
  }
303
303
 
304
+ declare const dbuAccountConfigSchema: z.ZodObject<{
305
+ with4EyeApproval: z.ZodDefault<z.ZodEnum<{
306
+ Y: "Y";
307
+ N: "N";
308
+ }>>;
309
+ channelCode: z.ZodDefault<z.ZodString>;
310
+ actionTypeCode: z.ZodDefault<z.ZodString>;
311
+ transactionTypeCode: z.ZodDefault<z.ZodString>;
312
+ partialRealization: z.ZodDefault<z.ZodEnum<{
313
+ Y: "Y";
314
+ N: "N";
315
+ }>>;
316
+ forceRealization: z.ZodDefault<z.ZodEnum<{
317
+ Y: "Y";
318
+ N: "N";
319
+ }>>;
320
+ }, z.core.$strip>;
321
+ type DbuAccountConfig = z.infer<typeof dbuAccountConfigSchema>;
322
+ type DbuConnectedAccount = Omit<ConnectedAccount, 'config'> & {
323
+ config: DbuAccountConfig;
324
+ };
304
325
  interface DbuConnectorConfig {
305
326
  BASE_URL: string;
306
327
  USERNAME: string;
@@ -313,7 +334,7 @@ interface DbuConnectorConfig {
313
334
  }
314
335
  declare class DbuConnector extends IBankConnector {
315
336
  connectorKey: ConnectorKey;
316
- connectedAccounts: ConnectedAccount[];
337
+ connectedAccounts: DbuConnectedAccount[];
317
338
  readonly kv: KVNamespace;
318
339
  readonly api: Fetcher;
319
340
  private readonly baseUrl;
@@ -340,6 +361,7 @@ declare class DbuConnector extends IBankConnector {
340
361
  accounts: AccountInsertType[];
341
362
  }>;
342
363
  listAccounts(): Promise<AccountInsertType[]>;
364
+ private resolveAccount;
343
365
  private resolveIdAccountDebit;
344
366
  private resolveAccountDetails;
345
367
  private initiateInstantPayment;
@@ -1340,5 +1362,5 @@ declare function toCompletedPayment(payment: PreparedPayment, status: 'SETTLED'
1340
1362
  declare function toPaymentRequestInsert(payment: AccountAssignedPayment, batchId: string | null): PaymentRequestInsertType;
1341
1363
  declare function toBatchedPaymentFromPaymentRequest(sp: PaymentRequestSelectType): BatchedPayment;
1342
1364
 
1343
- export { AccountAssignedPayment, AccountCredentialsInsertType, AccountInsertType, AccountSelectType, BatchMetadata, BatchedPayment, CompletedPayment, ConnectedAccount, ConnectorKey, CredentialsResolver, CsobConnector, Currency, DbuConnector, ErsteConnector, FINBRICKS_ENDPOINTS, FinbricksAccount, FinbricksClient, FinbricksConnector, IBankConnector, IncomingPayment, IncomingPayment as IncomingPaymentMessage, InitiatedBatch, InitiatedPayment, KBConnector, MockCobsConnector, MockConnector, ParsedBankPayment, PaymentRequestInsertType, PaymentRequestSelectType, PaymentRequestStatus, PaymentSelectType, PaymentType, PreparedPayment, SendPaymentInput, assignAccount, ottInsertSchema, ottSelectSchema, ottUpdateSchema, signFinbricksJws, toBatchedPayment, toBatchedPaymentFromPaymentRequest, toCompletedPayment, toIncomingPayment, toPaymentRequestInsert, toPreparedPayment, useFinbricksFetch };
1344
- export type { BankPaymentEvent, BankPaymentRequestEvent, DbuConnectorConfig, ErsteAuthenticationResponse, ErsteBatchPaymentInitiationResponse, ErsteIncomingPaymentResponse, ErsteObtainAuthorizationURLResponse, ErstePaymentInitiationResponse, FinbricksBatchBody, FinbricksBatchStatus, FinbricksConnectAccountBody, FinbricksConnectorConfig, FinbricksEndpoint, FinbricksEndpointPath, FinbricksFetchConfig, FinbricksForeignPaymentBody, FinbricksGetBatchStatusBody, FinbricksGetBatchStatusResponse, FinbricksGetTransactionStatusResponse, FinbricksJWSData, FinbricksPaymentBody, FinbricksProvider, FinbricksRequestInit, FinbricksSupportedBanksQuery, FinbricksTransactionStatus, OneTimeTokenInsertType, OneTimeTokenPatchType, OneTimeTokenSelectType, OneTimeTokenUpdateType };
1365
+ export { AccountAssignedPayment, AccountCredentialsInsertType, AccountInsertType, AccountSelectType, BatchMetadata, BatchedPayment, CompletedPayment, ConnectedAccount, ConnectorKey, CredentialsResolver, CsobConnector, Currency, DbuConnector, ErsteConnector, FINBRICKS_ENDPOINTS, FinbricksAccount, FinbricksClient, FinbricksConnector, IBankConnector, IncomingPayment, IncomingPayment as IncomingPaymentMessage, InitiatedBatch, InitiatedPayment, KBConnector, MockCobsConnector, MockConnector, ParsedBankPayment, PaymentRequestInsertType, PaymentRequestSelectType, PaymentRequestStatus, PaymentSelectType, PaymentType, PreparedPayment, SendPaymentInput, assignAccount, dbuAccountConfigSchema, ottInsertSchema, ottSelectSchema, ottUpdateSchema, signFinbricksJws, toBatchedPayment, toBatchedPaymentFromPaymentRequest, toCompletedPayment, toIncomingPayment, toPaymentRequestInsert, toPreparedPayment, useFinbricksFetch };
1366
+ export type { BankPaymentEvent, BankPaymentRequestEvent, DbuAccountConfig, DbuConnectorConfig, ErsteAuthenticationResponse, ErsteBatchPaymentInitiationResponse, ErsteIncomingPaymentResponse, ErsteObtainAuthorizationURLResponse, ErstePaymentInitiationResponse, FinbricksBatchBody, FinbricksBatchStatus, FinbricksConnectAccountBody, FinbricksConnectorConfig, FinbricksEndpoint, FinbricksEndpointPath, FinbricksFetchConfig, FinbricksForeignPaymentBody, FinbricksGetBatchStatusBody, FinbricksGetBatchStatusResponse, FinbricksGetTransactionStatusResponse, FinbricksJWSData, FinbricksPaymentBody, FinbricksProvider, FinbricksRequestInit, FinbricksSupportedBanksQuery, FinbricksTransactionStatus, OneTimeTokenInsertType, OneTimeTokenPatchType, OneTimeTokenSelectType, OneTimeTokenUpdateType };
package/dist/types.mjs CHANGED
@@ -1,12 +1,12 @@
1
- export { C as CsobConnector, D as DbuConnector, E as ErsteConnector, F as FINBRICKS_ENDPOINTS, a as FinbricksClient, b as FinbricksConnector, I as IBankConnector, K as KBConnector, M as MockCobsConnector, c as MockConnector, d as assignAccount, s as signFinbricksJws, t as toBatchedPayment, e as toBatchedPaymentFromPaymentRequest, f as toCompletedPayment, g as toIncomingPayment, h as toPaymentRequestInsert, i as toPreparedPayment, u as useFinbricksFetch } from './shared/bank.CmgGdN-q.mjs';
2
- export { A as ACCOUNT_STATUSES, B as BATCH_MODES, a as BATCH_STATUES, a as BATCH_STATUSES, C as CHARGE_BEARERS, b as CONNECTOR_KEYS, c as COUNTRY_CODES, d as CREDENTIALS_TYPES, I as INSTRUCTION_PRIORITIES, P as PAYMENT_DIRECTIONS, e as PAYMENT_REQUEST_STATUSES, f as PAYMENT_STATUSES, g as PAYMENT_TYPES, T as TOKEN_TYPES, h as accountCredentialsInsertSchema, i as accountCredentialsSelectSchema, j as accountCredentialsUpdateSchema, k as accountInsertSchema, l as accountSelectSchema, m as accountUpdateSchema, n as hasPaymentAccountAssigned, o as isPaymentCompleted, p as isPendingStatus, q as isProcessedStatus, r as isTerminalStatus, s as ottInsertSchema, t as ottSelectSchema, u as ottUpdateSchema } from './shared/bank.C7MA33AX.mjs';
1
+ export { A as ACCOUNT_STATUSES, B as BATCH_MODES, a as BATCH_STATUES, a as BATCH_STATUSES, C as CHARGE_BEARERS, b as CONNECTOR_KEYS, c as COUNTRY_CODES, d as CREDENTIALS_TYPES, e as CsobConnector, D as DbuConnector, E as ErsteConnector, F as FINBRICKS_ENDPOINTS, f as FinbricksClient, g as FinbricksConnector, I as IBankConnector, h as INSTRUCTION_PRIORITIES, K as KBConnector, M as MockCobsConnector, i as MockConnector, P as PAYMENT_DIRECTIONS, j as PAYMENT_REQUEST_STATUSES, k as PAYMENT_STATUSES, l as PAYMENT_TYPES, T as TOKEN_TYPES, m as accountCredentialsInsertSchema, n as accountCredentialsSelectSchema, o as accountCredentialsUpdateSchema, p as accountInsertSchema, q as accountSelectSchema, r as accountUpdateSchema, s as assignAccount, t as dbuAccountConfigSchema, u as hasPaymentAccountAssigned, v as isPaymentCompleted, w as isPendingStatus, x as isProcessedStatus, y as isTerminalStatus, z as ottInsertSchema, G as ottSelectSchema, H as ottUpdateSchema, J as signFinbricksJws, L as toBatchedPayment, N as toBatchedPaymentFromPaymentRequest, O as toCompletedPayment, Q as toIncomingPayment, R as toPaymentRequestInsert, S as toPreparedPayment, U as useFinbricksFetch } from './shared/bank.IlVbIEuM.mjs';
3
2
  export { i as isBatchAuthorized, a as isBatchCompleted, b as isBatchFailed, c as isBatchInitiated, d as isBatchProcessing, e as isBatchReadyToSign } from './shared/bank.XqSw509X.mjs';
4
3
  export { BANK_CODES, CURRENCY_CODES } from '@develit-io/general-codes';
5
4
  import '@develit-io/backend-sdk';
5
+ import 'drizzle-orm/sqlite-core';
6
6
  import 'date-fns';
7
- import 'drizzle-orm';
8
7
  import 'jose';
9
- import 'node:crypto';
10
- import 'drizzle-orm/sqlite-core';
8
+ import 'zod';
11
9
  import 'drizzle-orm/relations';
10
+ import 'drizzle-orm';
11
+ import 'node:crypto';
12
12
  import 'drizzle-zod';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@develit-services/bank",
3
- "version": "2.2.3",
3
+ "version": "2.4.0",
4
4
  "author": "Develit.io s.r.o.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,325 +0,0 @@
1
- import { bankAccount, base, structuredAddressSchema } from '@develit-io/backend-sdk';
2
- import { sqliteTable, text, integer, unique, real, index } from 'drizzle-orm/sqlite-core';
3
- import 'date-fns';
4
- import 'jose';
5
- import { COUNTRY_CODES_2, BANK_CODES } from '@develit-io/general-codes';
6
- import { relations } from 'drizzle-orm/relations';
7
- import { and, not, inArray, isNull } from 'drizzle-orm';
8
- import 'node:crypto';
9
- import { createInsertSchema, createUpdateSchema, createSelectSchema } from 'drizzle-zod';
10
-
11
- const PAYMENT_TYPES = ["SEPA", "SWIFT", "DOMESTIC", "UNKNOWN"];
12
- const CHARGE_BEARERS = ["SHA", "OUR", "BEN"];
13
- const INSTRUCTION_PRIORITIES = ["NORM", "HIGH", "INST"];
14
- const PAYMENT_REQUEST_STATUSES = [
15
- "OPENED",
16
- "AUTHORIZED",
17
- "COMPLETED",
18
- "BOOKED",
19
- "SETTLED",
20
- "REJECTED",
21
- "CLOSED"
22
- ];
23
- const PAYMENT_STATUSES = [
24
- "PENDING",
25
- "PROCESSING",
26
- "BOOKED",
27
- "CANCELLED",
28
- "REJECTED",
29
- "SCHEDULED",
30
- "HOLD",
31
- "INFO"
32
- ];
33
- const PAYMENT_DIRECTIONS = ["INCOMING", "OUTGOING"];
34
- const BATCH_STATUSES = [
35
- "PROCESSING",
36
- "READY_TO_SIGN",
37
- "AUTHORIZED",
38
- "COMPLETED",
39
- "FAILED"
40
- ];
41
- const BATCH_MODES = ["NATIVE", "SINGLE"];
42
- const ACCOUNT_STATUSES = ["AUTHORIZED", "DISABLED", "EXPIRED"];
43
- const COUNTRY_CODES = COUNTRY_CODES_2;
44
-
45
- const TERMINAL_STATUSES$1 = /* @__PURE__ */ new Set([
46
- "SETTLED",
47
- "REJECTED",
48
- "CLOSED"
49
- ]);
50
- const PENDING_STATUSES = /* @__PURE__ */ new Set([
51
- "OPENED",
52
- "AUTHORIZED"
53
- ]);
54
- function isTerminalStatus(status) {
55
- return TERMINAL_STATUSES$1.has(status);
56
- }
57
- function isPendingStatus(status) {
58
- return PENDING_STATUSES.has(status);
59
- }
60
- function isProcessedStatus(status) {
61
- return !isPendingStatus(status);
62
- }
63
- function hasPaymentAccountAssigned(payment) {
64
- return "accountId" in payment && "connectorKey" in payment && payment.accountId !== void 0 && payment.connectorKey !== void 0;
65
- }
66
- function isPaymentCompleted(payment) {
67
- return (payment.status === "COMPLETED" || payment.status === "BOOKED" || payment.status === "SETTLED" || payment.status === "REJECTED" || payment.status === "CLOSED") && "bankRefId" in payment && typeof payment.bankRefId === "string";
68
- }
69
-
70
- const TERMINAL_STATUSES = PAYMENT_REQUEST_STATUSES.filter(isTerminalStatus);
71
- const getNonTerminalPaymentRequestsQuery = (db) => db.select().from(tables.paymentRequest).where(
72
- and(
73
- not(inArray(tables.paymentRequest.status, TERMINAL_STATUSES)),
74
- isNull(tables.paymentRequest.deletedAt)
75
- )
76
- );
77
-
78
- const CONNECTOR_KEYS = [
79
- "ERSTE",
80
- "FINBRICKS",
81
- "MOCK",
82
- "CREDITAS",
83
- "MOCK_COBS",
84
- "FIO",
85
- "MONETA",
86
- "DBU",
87
- "CSAS",
88
- "AIRBANK",
89
- "KB",
90
- "CSOB"
91
- ];
92
- const CREDENTIALS_TYPES = [
93
- "AUTH_TOKEN",
94
- "REFRESH_TOKEN",
95
- "CLIENT_ID",
96
- "API_KEY"
97
- ];
98
- const TOKEN_TYPES = ["ACCOUNT_AUTHORIZATION"];
99
-
100
- const account = sqliteTable(
101
- "account",
102
- {
103
- ...base,
104
- ...bankAccount,
105
- // countryCode is temporary until bankAccount is update to include US country code
106
- countryCode: text("country_code", { enum: COUNTRY_CODES }).$type().notNull(),
107
- number: text("number").notNull(),
108
- name: text("name"),
109
- iban: text("iban").notNull(),
110
- bankCode: text("bank_code", { enum: BANK_CODES }).notNull(),
111
- connectorKey: text("connector_key", {
112
- enum: CONNECTOR_KEYS
113
- }).$type().notNull(),
114
- status: text("status", { enum: ACCOUNT_STATUSES }).$type().notNull(),
115
- bankRefId: text("bank_ref_id").notNull(),
116
- batchSizeLimit: integer("batch_size_limit").notNull().default(50),
117
- syncIntervalS: integer("sync_interval_s").notNull().default(600),
118
- lastSyncAt: integer("last_sync_at", { mode: "timestamp_ms" }),
119
- lastSyncMetadata: text("last_sync_metadata", {
120
- mode: "json"
121
- }).$type()
122
- },
123
- (t) => [unique().on(t.iban)]
124
- );
125
-
126
- const accountInsertSchema = createInsertSchema(account, {
127
- address: () => structuredAddressSchema.optional()
128
- });
129
- const accountUpdateSchema = createUpdateSchema(account, {
130
- address: () => structuredAddressSchema.optional()
131
- });
132
- const accountSelectSchema = createSelectSchema(account, {
133
- address: () => structuredAddressSchema.nullable()
134
- });
135
-
136
- const accountCredentials = sqliteTable("account_credentials", {
137
- ...base,
138
- accountId: text("account_id").references(() => account.id, { onDelete: "restrict", onUpdate: "cascade" }).notNull(),
139
- connectorKey: text("connector_key", {
140
- enum: CONNECTOR_KEYS
141
- }).$type().notNull(),
142
- type: text("type", {
143
- enum: CREDENTIALS_TYPES
144
- }).$type().notNull(),
145
- value: text("value").notNull(),
146
- expiresAt: integer("expires_at", { mode: "timestamp_ms" }).notNull()
147
- });
148
-
149
- const accountCredentialsInsertSchema = createInsertSchema(accountCredentials);
150
- const accountCredentialsUpdateSchema = createUpdateSchema(accountCredentials);
151
- const accountCredentialsSelectSchema = createSelectSchema(accountCredentials);
152
-
153
- const ott = sqliteTable("ott", {
154
- ...base,
155
- oneTimeToken: text("one_time_token").notNull(),
156
- refId: text("ref_id").notNull(),
157
- tokenType: text("token_type", { enum: TOKEN_TYPES }).$type().notNull(),
158
- expiresAt: integer("expires_at", { mode: "timestamp_ms" }).notNull()
159
- });
160
-
161
- const ottInsertSchema = createInsertSchema(ott);
162
- const ottUpdateSchema = createUpdateSchema(ott);
163
- const ottSelectSchema = createSelectSchema(ott);
164
-
165
- const batch = sqliteTable("batch", {
166
- ...base,
167
- batchPaymentInitiatedAt: integer("batch_payment_initiated_at", {
168
- mode: "timestamp_ms"
169
- }),
170
- authorizationUrls: text("authorization_urls", { mode: "json" }).$type(),
171
- accountId: text("account_id").references(() => account.id, {
172
- onDelete: "restrict",
173
- onUpdate: "cascade"
174
- }),
175
- status: text("status", { enum: BATCH_STATUSES }).$type(),
176
- statusReason: text("status_reason"),
177
- statusResponse: text("status_response", { mode: "json" }).$type(),
178
- metadata: text("metadata", { mode: "json" }).$type(),
179
- paymentType: text("payment_type", {
180
- enum: PAYMENT_TYPES
181
- }).$type(),
182
- paymentsChecksum: text("payments_checksum"),
183
- batchMode: text("batch_mode", { enum: BATCH_MODES }).$type()
184
- });
185
-
186
- const payment = sqliteTable(
187
- "payment",
188
- {
189
- ...base,
190
- correlationId: text("correlation_id").notNull(),
191
- refId: text("ref_id"),
192
- bankRefId: text("bank_ref_id").notNull(),
193
- accountId: text("account_id").references(() => account.id, {
194
- onDelete: "restrict",
195
- onUpdate: "cascade"
196
- }).notNull(),
197
- connectorKey: text("connector_key", { enum: CONNECTOR_KEYS }).$type().notNull(),
198
- amount: real("amount").notNull(),
199
- direction: text("direction").$type().notNull(),
200
- paymentType: text("payment_type").$type().notNull(),
201
- currency: text("currency").$type().notNull(),
202
- status: text("status", { enum: PAYMENT_STATUSES }).$type().notNull(),
203
- statusReason: text("status_reason"),
204
- batchId: text("bank_execution_batch_id"),
205
- initiatedAt: integer("initiated_at", {
206
- mode: "timestamp_ms"
207
- }),
208
- vs: text("vs"),
209
- ss: text("ss"),
210
- ks: text("ks"),
211
- message: text("message"),
212
- chargeBearer: text("charge_bearer", {
213
- enum: CHARGE_BEARERS
214
- }).$type(),
215
- instructionPriority: text("instruction_priority", {
216
- enum: INSTRUCTION_PRIORITIES
217
- }).$type(),
218
- processedAt: integer("processed_at", {
219
- mode: "timestamp_ms"
220
- }),
221
- creditor: text("creditor", { mode: "json" }).$type().notNull(),
222
- creditorIban: text("creditor_iban"),
223
- debtor: text("debtor", { mode: "json" }).$type().notNull(),
224
- debtorIban: text("debtor_iban")
225
- },
226
- (t) => [
227
- unique().on(t.connectorKey, t.accountId, t.bankRefId),
228
- index("payment_account_id_idx").on(t.accountId),
229
- index("payment_account_id_status_idx").on(t.accountId, t.status),
230
- index("payment_account_id_created_at_idx").on(t.accountId, t.createdAt),
231
- index("payment_created_at_idx").on(t.createdAt),
232
- index("payment_direction_idx").on(t.direction),
233
- index("payment_batch_id_idx").on(t.batchId),
234
- index("payment_creditor_iban_idx").on(t.creditorIban),
235
- index("payment_debtor_iban_idx").on(t.debtorIban)
236
- ]
237
- );
238
- const paymentRelations = relations(payment, ({ one }) => ({
239
- batch: one(batch, { fields: [payment.batchId], references: [batch.id] })
240
- }));
241
-
242
- const paymentRequest = sqliteTable(
243
- "payment_request",
244
- {
245
- ...base,
246
- batchId: text("batch_id").references(() => batch.id, {
247
- onDelete: "restrict",
248
- onUpdate: "cascade"
249
- }),
250
- accountId: text("account_id").references(() => account.id, {
251
- onDelete: "restrict",
252
- onUpdate: "cascade"
253
- }).notNull(),
254
- correlationId: text("correlation_id").notNull(),
255
- refId: text("ref_id"),
256
- bankRefId: text("bank_ref_id"),
257
- connectorKey: text("connector_key", { enum: CONNECTOR_KEYS }).$type().notNull(),
258
- amount: real("amount").notNull(),
259
- paymentType: text("payment_type", { enum: PAYMENT_TYPES }).$type().notNull(),
260
- currency: text("currency").$type().notNull(),
261
- status: text("status", { enum: PAYMENT_REQUEST_STATUSES }).$type().notNull(),
262
- statusReason: text("status_reason"),
263
- authorizationUrl: text("authorization_url"),
264
- initiatedAt: integer("initiated_at", { mode: "timestamp_ms" }),
265
- processedAt: integer("processed_at", { mode: "timestamp_ms" }),
266
- vs: text("vs"),
267
- ss: text("ss"),
268
- ks: text("ks"),
269
- message: text("message"),
270
- chargeBearer: text("charge_bearer", {
271
- enum: CHARGE_BEARERS
272
- }).$type(),
273
- instructionPriority: text("instruction_priority", {
274
- enum: INSTRUCTION_PRIORITIES
275
- }).$type(),
276
- creditor: text("creditor", { mode: "json" }).$type().notNull(),
277
- creditorIban: text("creditor_iban"),
278
- debtor: text("debtor", { mode: "json" }).$type().notNull(),
279
- debtorIban: text("debtor_iban"),
280
- sendAsSinglePayment: integer("send_as_single_payment", {
281
- mode: "boolean"
282
- })
283
- },
284
- (t) => [
285
- index("payment_request_batch_id_idx").on(t.batchId),
286
- index("payment_request_account_id_idx").on(t.accountId),
287
- index("payment_request_creditor_iban_idx").on(t.creditorIban),
288
- index("payment_request_debtor_iban_idx").on(t.debtorIban),
289
- index("payment_request_status_idx").on(t.status),
290
- index("payment_request_created_at_idx").on(t.createdAt),
291
- index("payment_request_account_status_idx").on(t.accountId, t.status),
292
- index("payment_request_status_created_at_idx").on(t.status, t.createdAt),
293
- index("payment_request_account_status_created_at_idx").on(
294
- t.accountId,
295
- t.status,
296
- t.createdAt
297
- )
298
- ]
299
- );
300
- const paymentRequestRelations = relations(paymentRequest, ({ one }) => ({
301
- batch: one(batch, {
302
- fields: [paymentRequest.batchId],
303
- references: [batch.id]
304
- }),
305
- account: one(account, {
306
- fields: [paymentRequest.accountId],
307
- references: [account.id]
308
- })
309
- }));
310
-
311
- const schema = {
312
- __proto__: null,
313
- account: account,
314
- accountCredentials: accountCredentials,
315
- batch: batch,
316
- ott: ott,
317
- payment: payment,
318
- paymentRelations: paymentRelations,
319
- paymentRequest: paymentRequest,
320
- paymentRequestRelations: paymentRequestRelations
321
- };
322
-
323
- const tables = schema;
324
-
325
- export { ACCOUNT_STATUSES as A, BATCH_MODES as B, CHARGE_BEARERS as C, ott as D, payment as E, paymentRelations as F, paymentRequest as G, paymentRequestRelations as H, INSTRUCTION_PRIORITIES as I, PAYMENT_DIRECTIONS as P, TOKEN_TYPES as T, BATCH_STATUSES as a, CONNECTOR_KEYS as b, COUNTRY_CODES as c, CREDENTIALS_TYPES as d, PAYMENT_REQUEST_STATUSES as e, PAYMENT_STATUSES as f, PAYMENT_TYPES as g, accountCredentialsInsertSchema as h, accountCredentialsSelectSchema as i, accountCredentialsUpdateSchema as j, accountInsertSchema as k, accountSelectSchema as l, accountUpdateSchema as m, hasPaymentAccountAssigned as n, isPaymentCompleted as o, isPendingStatus as p, isProcessedStatus as q, isTerminalStatus as r, ottInsertSchema as s, ottSelectSchema as t, ottUpdateSchema as u, tables as v, getNonTerminalPaymentRequestsQuery as w, account as x, accountCredentials as y, batch as z };