@develit-services/bank 0.0.2 → 0.0.3

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,10 +1,11 @@
1
- import { b as CurrencyCode, c as BankCode, d as CountryCode, I as IBankConnector, a as ConnectorKey, A as AuthInput, e as IncomingPaymentMessage, P as PaymentPreparedInsertType, f as InitiatedBatch, g as InitiatedPayment, C as ConfigBankAccount, S as SyncLog, h as BatchMetadata, i as Currency } from '../shared/bank.D-DeJSGN.js';
2
- export { n as BANK_CODES, k as BATCH_STATUES, k as BATCH_STATUSES, l as BatchStatus, v as COUNTRY_CODES, m as CURRENCY_CODES, O as OutgoingPaymentMessage, t as PAYMENT_DIRECTIONS, r as PAYMENT_STATUSES, o as PAYMENT_TYPES, u as PaymentDirection, j as PaymentFailedInsertType, s as PaymentStatus, q as PaymentType, p as paymentInitializedInsertType } from '../shared/bank.D-DeJSGN.js';
3
- import { t as tables, a as PaymentInsertType } from '../shared/bank.CBNQZ5Pd.js';
4
- export { b as BatchInsertType, B as BatchSelectType, P as PaymentSelectType, p as paymentInsertTypeZod } from '../shared/bank.CBNQZ5Pd.js';
1
+ import { b as CurrencyCode, c as BankCode, d as CountryCode, I as IBankConnector, a as ConnectorKey, A as AuthInput, e as IncomingPaymentMessage, P as PaymentPreparedInsertType, f as InitiatedBatch, g as InitiatedPayment, C as ConfigBankAccount, S as SyncLog, h as BatchMetadata, i as Currency } from './shared/bank.DqT4zUJn.mjs';
2
+ export { k as BATCH_STATUES, k as BATCH_STATUSES, l as BatchStatus, t as COUNTRY_CODES, O as OutgoingPaymentMessage, r as PAYMENT_DIRECTIONS, o as PAYMENT_STATUSES, m as PAYMENT_TYPES, s as PaymentDirection, j as PaymentFailedInsertType, q as PaymentStatus, n as PaymentType, p as paymentInitializedInsertType } from './shared/bank.DqT4zUJn.mjs';
3
+ import { t as tables, a as PaymentInsertType } from './shared/bank.dxpKOn1t.mjs';
4
+ export { b as BatchInsertType, B as BatchSelectType, P as PaymentSelectType, p as paymentInsertTypeZod } from './shared/bank.dxpKOn1t.mjs';
5
5
  import { Environment } from '@develit-io/backend-sdk';
6
6
  import { DrizzleD1Database } from 'drizzle-orm/d1';
7
- export { b as BankServiceEnv, a as BankServiceEnvironmentConfig, B as BankServiceWranglerConfig } from '../shared/bank.DxGqqFhD.js';
7
+ export { b as BankServiceEnv, a as BankServiceEnvironmentConfig, B as BankServiceWranglerConfig } from './shared/bank.DxGqqFhD.mjs';
8
+ export { BANK_CODES, CURRENCY_CODES } from '@develit-io/general-codes';
8
9
  import 'drizzle-orm/sqlite-core';
9
10
  import 'drizzle-orm';
10
11
  import 'zod';
@@ -1,10 +1,11 @@
1
- import { b as CurrencyCode, c as BankCode, d as CountryCode, I as IBankConnector, a as ConnectorKey, A as AuthInput, e as IncomingPaymentMessage, P as PaymentPreparedInsertType, f as InitiatedBatch, g as InitiatedPayment, C as ConfigBankAccount, S as SyncLog, h as BatchMetadata, i as Currency } from '../shared/bank.DdbWdNgy.mjs';
2
- export { n as BANK_CODES, k as BATCH_STATUES, k as BATCH_STATUSES, l as BatchStatus, v as COUNTRY_CODES, m as CURRENCY_CODES, O as OutgoingPaymentMessage, t as PAYMENT_DIRECTIONS, r as PAYMENT_STATUSES, o as PAYMENT_TYPES, u as PaymentDirection, j as PaymentFailedInsertType, s as PaymentStatus, q as PaymentType, p as paymentInitializedInsertType } from '../shared/bank.DdbWdNgy.mjs';
3
- import { t as tables, a as PaymentInsertType } from '../shared/bank.CBNQZ5Pd.mjs';
4
- export { b as BatchInsertType, B as BatchSelectType, P as PaymentSelectType, p as paymentInsertTypeZod } from '../shared/bank.CBNQZ5Pd.mjs';
1
+ import { b as CurrencyCode, c as BankCode, d as CountryCode, I as IBankConnector, a as ConnectorKey, A as AuthInput, e as IncomingPaymentMessage, P as PaymentPreparedInsertType, f as InitiatedBatch, g as InitiatedPayment, C as ConfigBankAccount, S as SyncLog, h as BatchMetadata, i as Currency } from './shared/bank.B72_bFlr.js';
2
+ export { k as BATCH_STATUES, k as BATCH_STATUSES, l as BatchStatus, t as COUNTRY_CODES, O as OutgoingPaymentMessage, r as PAYMENT_DIRECTIONS, o as PAYMENT_STATUSES, m as PAYMENT_TYPES, s as PaymentDirection, j as PaymentFailedInsertType, q as PaymentStatus, n as PaymentType, p as paymentInitializedInsertType } from './shared/bank.B72_bFlr.js';
3
+ import { t as tables, a as PaymentInsertType } from './shared/bank.dxpKOn1t.js';
4
+ export { b as BatchInsertType, B as BatchSelectType, P as PaymentSelectType, p as paymentInsertTypeZod } from './shared/bank.dxpKOn1t.js';
5
5
  import { Environment } from '@develit-io/backend-sdk';
6
6
  import { DrizzleD1Database } from 'drizzle-orm/d1';
7
- export { b as BankServiceEnv, a as BankServiceEnvironmentConfig, B as BankServiceWranglerConfig } from '../shared/bank.DxGqqFhD.mjs';
7
+ export { b as BankServiceEnv, a as BankServiceEnvironmentConfig, B as BankServiceWranglerConfig } from './shared/bank.DxGqqFhD.js';
8
+ export { BANK_CODES, CURRENCY_CODES } from '@develit-io/general-codes';
8
9
  import 'drizzle-orm/sqlite-core';
9
10
  import 'drizzle-orm';
10
11
  import 'zod';
@@ -0,0 +1,10 @@
1
+ export { B as BATCH_STATUES, B as BATCH_STATUSES, C as COUNTRY_CODES, E as ErsteConnector, F as FinbricksConnector, I as IBankConnector, a as MockCobsConnector, M as MockConnector, c as PAYMENT_DIRECTIONS, b as PAYMENT_STATUSES, P as PAYMENT_TYPES, p as paymentInsertTypeZod } from './shared/bank.TOYdvcg7.mjs';
2
+ export { BANK_CODES, CURRENCY_CODES } from '@develit-io/general-codes';
3
+ import '@develit-io/backend-sdk';
4
+ import './shared/bank.BeH-ZCJJ.mjs';
5
+ import 'drizzle-orm/sqlite-core';
6
+ import 'drizzle-orm/relations';
7
+ import 'drizzle-orm';
8
+ import 'date-fns';
9
+ import 'jose';
10
+ import 'zod';
@@ -1,4 +1,4 @@
1
- export { c as batch, d as payment, e as paymentRelations } from '../../shared/bank.CBNQZ5Pd.js';
1
+ export { c as batch, d as payment, e as paymentRelations } from '../shared/bank.dxpKOn1t.mjs';
2
2
  import 'drizzle-orm/sqlite-core';
3
3
  import 'drizzle-orm';
4
4
  import 'zod';
@@ -1,4 +1,4 @@
1
- export { c as batch, d as payment, e as paymentRelations } from '../../shared/bank.CBNQZ5Pd.mjs';
1
+ export { c as batch, d as payment, e as paymentRelations } from '../shared/bank.dxpKOn1t.js';
2
2
  import 'drizzle-orm/sqlite-core';
3
3
  import 'drizzle-orm';
4
4
  import 'zod';
@@ -1,4 +1,4 @@
1
- export { b as batch, p as payment, a as paymentRelations } from '../../shared/bank.BeH-ZCJJ.mjs';
1
+ export { b as batch, p as payment, a as paymentRelations } from '../shared/bank.BeH-ZCJJ.mjs';
2
2
  import '@develit-io/backend-sdk';
3
3
  import 'drizzle-orm/sqlite-core';
4
4
  import 'drizzle-orm/relations';
@@ -1,12 +1,13 @@
1
1
  import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
2
2
  import { IRPCResponse } from '@develit-io/backend-sdk';
3
- import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as PaymentInsertType } from '../shared/bank.CBNQZ5Pd.mjs';
3
+ import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as PaymentInsertType } from '../shared/bank.dxpKOn1t.mjs';
4
4
  import { WorkerEntrypoint } from 'cloudflare:workers';
5
5
  import { DrizzleD1Database } from 'drizzle-orm/d1';
6
6
  import { z } from 'zod';
7
- import { I as IBankConnector, C as ConfigBankAccount, a as ConnectorKey, B as BankAccountWithLastSync } from '../shared/bank.DdbWdNgy.mjs';
7
+ import { I as IBankConnector, C as ConfigBankAccount, a as ConnectorKey, B as BankAccountWithLastSync } from '../shared/bank.DqT4zUJn.mjs';
8
8
  import 'drizzle-orm/sqlite-core';
9
9
  import 'drizzle-orm';
10
+ import '@develit-io/general-codes';
10
11
 
11
12
  declare const sendPaymentInputSchema: z.ZodObject<{
12
13
  refId: z.ZodString;
@@ -208,16 +209,16 @@ declare class BankServiceBase extends BankServiceBase_base {
208
209
  addPaymentsToBatch({ paymentsToBatch, }: {
209
210
  paymentsToBatch: SendPaymentInput[];
210
211
  }): Promise<IRPCResponse<{
212
+ status: "PREPARED" | "FAILED" | "COMPLETED" | "OPEN" | "WAITING_FOR_PROCESSING" | "PROCESSING" | "READY_TO_SIGN" | null;
213
+ id: string;
214
+ createdAt: Date | null;
215
+ updatedAt: Date | null;
216
+ deletedAt: Date | null;
211
217
  batchPaymentInitiatedAt: Date | null;
212
218
  authorizationUrls: string | string[] | null;
213
219
  accountId: string | null;
214
- status: "OPEN" | "WAITING_FOR_PROCESSING" | "PROCESSING" | "READY_TO_SIGN" | "PREPARED" | "COMPLETED" | "FAILED" | null;
215
220
  payments: PaymentInsertType[];
216
221
  metadata: object | null;
217
- id: string;
218
- createdAt: Date | null;
219
- updatedAt: Date | null;
220
- deletedAt: Date | null;
221
222
  }[] | undefined>>;
222
223
  processBatch({ batch, connectorKey, }: {
223
224
  batch: BatchSelectType;
@@ -1,12 +1,13 @@
1
1
  import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
2
2
  import { IRPCResponse } from '@develit-io/backend-sdk';
3
- import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as PaymentInsertType } from '../shared/bank.CBNQZ5Pd.js';
3
+ import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as PaymentInsertType } from '../shared/bank.dxpKOn1t.js';
4
4
  import { WorkerEntrypoint } from 'cloudflare:workers';
5
5
  import { DrizzleD1Database } from 'drizzle-orm/d1';
6
6
  import { z } from 'zod';
7
- import { I as IBankConnector, C as ConfigBankAccount, a as ConnectorKey, B as BankAccountWithLastSync } from '../shared/bank.D-DeJSGN.js';
7
+ import { I as IBankConnector, C as ConfigBankAccount, a as ConnectorKey, B as BankAccountWithLastSync } from '../shared/bank.B72_bFlr.js';
8
8
  import 'drizzle-orm/sqlite-core';
9
9
  import 'drizzle-orm';
10
+ import '@develit-io/general-codes';
10
11
 
11
12
  declare const sendPaymentInputSchema: z.ZodObject<{
12
13
  refId: z.ZodString;
@@ -208,16 +209,16 @@ declare class BankServiceBase extends BankServiceBase_base {
208
209
  addPaymentsToBatch({ paymentsToBatch, }: {
209
210
  paymentsToBatch: SendPaymentInput[];
210
211
  }): Promise<IRPCResponse<{
212
+ status: "PREPARED" | "FAILED" | "COMPLETED" | "OPEN" | "WAITING_FOR_PROCESSING" | "PROCESSING" | "READY_TO_SIGN" | null;
213
+ id: string;
214
+ createdAt: Date | null;
215
+ updatedAt: Date | null;
216
+ deletedAt: Date | null;
211
217
  batchPaymentInitiatedAt: Date | null;
212
218
  authorizationUrls: string | string[] | null;
213
219
  accountId: string | null;
214
- status: "OPEN" | "WAITING_FOR_PROCESSING" | "PROCESSING" | "READY_TO_SIGN" | "PREPARED" | "COMPLETED" | "FAILED" | null;
215
220
  payments: PaymentInsertType[];
216
221
  metadata: object | null;
217
- id: string;
218
- createdAt: Date | null;
219
- updatedAt: Date | null;
220
- deletedAt: Date | null;
221
222
  }[] | undefined>>;
222
223
  processBatch({ batch, connectorKey, }: {
223
224
  batch: BatchSelectType;
@@ -1,8 +1,9 @@
1
1
  import { uuidv4, useResult, createInternalError, develitWorker, first, RPCResponse, action } from '@develit-io/backend-sdk';
2
- import { C as CURRENCY_CODES, P as PAYMENT_TYPES, t as tables, F as FinbricksConnector, M as MockConnector, a as MockCobsConnector, E as ErsteConnector, g as getPaymentDirection } from '../shared/bank._EHVypLw.mjs';
2
+ import { P as PAYMENT_TYPES, t as tables, F as FinbricksConnector, M as MockConnector, a as MockCobsConnector, E as ErsteConnector, g as getPaymentDirection } from '../shared/bank.TOYdvcg7.mjs';
3
3
  import { WorkerEntrypoint } from 'cloudflare:workers';
4
4
  import { drizzle } from 'drizzle-orm/d1';
5
5
  import { z } from 'zod';
6
+ import { CURRENCY_CODES } from '@develit-io/general-codes';
6
7
  import { eq, and, inArray, desc, sql } from 'drizzle-orm';
7
8
  import superjson from 'superjson';
8
9
  import '../shared/bank.BeH-ZCJJ.mjs';
@@ -0,0 +1,98 @@
1
+ import { Environment } from '@develit-io/backend-sdk';
2
+ import { BANK_CODES, CURRENCY_CODES, CODES } from '@develit-io/general-codes';
3
+ import { a as PaymentInsertType, t as tables } from './bank.dxpKOn1t.js';
4
+ import { DrizzleD1Database } from 'drizzle-orm/d1';
5
+
6
+ declare const PAYMENT_TYPES: readonly ["SEPA", "SWIFT", "IFSC", "DOMESTIC"];
7
+ type PaymentType = (typeof PAYMENT_TYPES)[number];
8
+ declare const PAYMENT_STATUSES: readonly ["PREPARED", "INITIALIZED", "FAILED", "PENDING", "COMPLETED", "CREATED"];
9
+ type PaymentStatus = (typeof PAYMENT_STATUSES)[number];
10
+ declare const PAYMENT_DIRECTIONS: readonly ["INCOMING", "OUTGOING"];
11
+ type PaymentDirection = (typeof PAYMENT_DIRECTIONS)[number];
12
+
13
+ type CurrencyCode = (typeof CURRENCY_CODES)[number];
14
+ /**
15
+ * Batch status constants
16
+ */
17
+ declare const BATCH_STATUSES: readonly ["OPEN", "WAITING_FOR_PROCESSING", "PROCESSING", "READY_TO_SIGN", "PREPARED", "COMPLETED", "FAILED"];
18
+ /**
19
+ * Type definition for batch status
20
+ */
21
+ type BatchStatus = (typeof BATCH_STATUSES)[number];
22
+ type Currency = CODES.Currency;
23
+
24
+ type BankCode = (typeof BANK_CODES)[number];
25
+ declare const COUNTRY_CODES: ["AF" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BO" | "BQ" | "BA" | "BW" | "BR" | "IO" | "VG" | "BG" | "BF" | "BI" | "KH" | "CM" | "CA" | "CV" | "CF" | "TD" | "CL" | "CN" | "CO" | "KM" | "CK" | "CR" | "HR" | "CW" | "CY" | "CZ" | "CD" | "DK" | "DJ" | "DM" | "DO" | "TL" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FO" | "FJ" | "FI" | "FR" | "GF" | "PF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GR" | "GD" | "GP" | "GU" | "GT" | "GN" | "GW" | "GY" | "HT" | "HN" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IM" | "IL" | "IT" | "CI" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "XK" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LI" | "LT" | "LU" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MQ" | "MR" | "MU" | "MX" | "FM" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "NA" | "NP" | "NL" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "KP" | "NO" | "OM" | "PK" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PL" | "PT" | "PR" | "QA" | "CG" | "RE" | "RO" | "RU" | "RW" | "BL" | "KN" | "LC" | "MF" | "VC" | "WS" | "SM" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SO" | "ZA" | "KR" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SZ" | "SE" | "CH" | "TW" | "TJ" | "TZ" | "TH" | "TG" | "TO" | "TT" | "TN" | "TR" | "TM" | "UM" | "VI" | "UG" | "UA" | "AE" | "GB" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW", ...("AF" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BO" | "BQ" | "BA" | "BW" | "BR" | "IO" | "VG" | "BG" | "BF" | "BI" | "KH" | "CM" | "CA" | "CV" | "CF" | "TD" | "CL" | "CN" | "CO" | "KM" | "CK" | "CR" | "HR" | "CW" | "CY" | "CZ" | "CD" | "DK" | "DJ" | "DM" | "DO" | "TL" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FO" | "FJ" | "FI" | "FR" | "GF" | "PF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GR" | "GD" | "GP" | "GU" | "GT" | "GN" | "GW" | "GY" | "HT" | "HN" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IM" | "IL" | "IT" | "CI" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "XK" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LI" | "LT" | "LU" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MQ" | "MR" | "MU" | "MX" | "FM" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "NA" | "NP" | "NL" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "KP" | "NO" | "OM" | "PK" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PL" | "PT" | "PR" | "QA" | "CG" | "RE" | "RO" | "RU" | "RW" | "BL" | "KN" | "LC" | "MF" | "VC" | "WS" | "SM" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SO" | "ZA" | "KR" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SZ" | "SE" | "CH" | "TW" | "TJ" | "TZ" | "TH" | "TG" | "TO" | "TT" | "TN" | "TR" | "TM" | "UM" | "VI" | "UG" | "UA" | "AE" | "GB" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW")[]];
26
+ type CountryCode = (typeof COUNTRY_CODES)[number];
27
+
28
+ interface SyncLog {
29
+ lastSyncedAt: Date;
30
+ }
31
+
32
+ type ConnectorKey = 'ERSTE' | 'FINBRICKS' | 'MOCK' | 'CREDITAS' | 'MOCK_COBS' | 'FIO';
33
+ interface ConfigBankAccount {
34
+ connectorKey: ConnectorKey;
35
+ id: string;
36
+ identification: {
37
+ number: string;
38
+ bankCode: BankCode;
39
+ iban: string;
40
+ holderName: string;
41
+ };
42
+ fallbackLastSync: Date;
43
+ currency: CurrencyCode;
44
+ production: boolean;
45
+ }
46
+ interface BankAccountWithLastSync extends ConfigBankAccount {
47
+ lastSyncAt: SyncLog;
48
+ }
49
+
50
+ type WithStatus<T extends {
51
+ status: PaymentStatus;
52
+ }, S extends PaymentStatus> = Omit<T, 'status'> & {
53
+ status: S;
54
+ };
55
+ type PaymentFailedInsertType = WithStatus<PaymentInsertType, 'FAILED'>;
56
+ type PaymentPreparedInsertType = WithStatus<PaymentInsertType, 'PREPARED'>;
57
+ type paymentInitializedInsertType = WithStatus<PaymentInsertType, 'INITIALIZED'>;
58
+ type BatchMetadata = {
59
+ signHash: string;
60
+ signId: string;
61
+ };
62
+ type InitiatedPayment = {
63
+ authorizationUrl: string;
64
+ payment: paymentInitializedInsertType;
65
+ };
66
+ type InitiatedBatch = {
67
+ id: string;
68
+ authorizationUrls: string[];
69
+ payments: paymentInitializedInsertType[];
70
+ metadata?: BatchMetadata | null;
71
+ };
72
+ type AuthInput = {
73
+ token: string;
74
+ refreshToken?: string;
75
+ };
76
+ declare abstract class IBankConnector {
77
+ abstract connectorKey: ConnectorKey;
78
+ abstract authenticate(code: AuthInput): Promise<string>;
79
+ abstract preparePayment(payment: IncomingPaymentMessage): Promise<PaymentPreparedInsertType>;
80
+ abstract initiateBatchFromPayments({ payments, }: {
81
+ payments: PaymentPreparedInsertType[];
82
+ }): Promise<InitiatedBatch>;
83
+ abstract initiateSinglePayment(payment: PaymentPreparedInsertType): Promise<InitiatedPayment>;
84
+ abstract getAllAccountPayments({ account, lastSync, db, env, }: {
85
+ account: ConfigBankAccount;
86
+ lastSync: SyncLog;
87
+ db: DrizzleD1Database<typeof tables>;
88
+ env: Environment;
89
+ }): Promise<PaymentInsertType[]>;
90
+ }
91
+
92
+ interface IncomingPaymentMessage extends PaymentInsertType {
93
+ }
94
+ interface OutgoingPaymentMessage extends PaymentInsertType {
95
+ }
96
+
97
+ export { IBankConnector as I, BATCH_STATUSES as k, PAYMENT_TYPES as m, PAYMENT_STATUSES as o, PAYMENT_DIRECTIONS as r, COUNTRY_CODES as t };
98
+ export type { AuthInput as A, BankAccountWithLastSync as B, ConfigBankAccount as C, OutgoingPaymentMessage as O, PaymentPreparedInsertType as P, SyncLog as S, ConnectorKey as a, CurrencyCode as b, BankCode as c, CountryCode as d, IncomingPaymentMessage as e, InitiatedBatch as f, InitiatedPayment as g, BatchMetadata as h, Currency as i, PaymentFailedInsertType as j, BatchStatus as l, PaymentType as n, paymentInitializedInsertType as p, PaymentStatus as q, PaymentDirection as s };
@@ -0,0 +1,98 @@
1
+ import { Environment } from '@develit-io/backend-sdk';
2
+ import { BANK_CODES, CURRENCY_CODES, CODES } from '@develit-io/general-codes';
3
+ import { a as PaymentInsertType, t as tables } from './bank.dxpKOn1t.mjs';
4
+ import { DrizzleD1Database } from 'drizzle-orm/d1';
5
+
6
+ declare const PAYMENT_TYPES: readonly ["SEPA", "SWIFT", "IFSC", "DOMESTIC"];
7
+ type PaymentType = (typeof PAYMENT_TYPES)[number];
8
+ declare const PAYMENT_STATUSES: readonly ["PREPARED", "INITIALIZED", "FAILED", "PENDING", "COMPLETED", "CREATED"];
9
+ type PaymentStatus = (typeof PAYMENT_STATUSES)[number];
10
+ declare const PAYMENT_DIRECTIONS: readonly ["INCOMING", "OUTGOING"];
11
+ type PaymentDirection = (typeof PAYMENT_DIRECTIONS)[number];
12
+
13
+ type CurrencyCode = (typeof CURRENCY_CODES)[number];
14
+ /**
15
+ * Batch status constants
16
+ */
17
+ declare const BATCH_STATUSES: readonly ["OPEN", "WAITING_FOR_PROCESSING", "PROCESSING", "READY_TO_SIGN", "PREPARED", "COMPLETED", "FAILED"];
18
+ /**
19
+ * Type definition for batch status
20
+ */
21
+ type BatchStatus = (typeof BATCH_STATUSES)[number];
22
+ type Currency = CODES.Currency;
23
+
24
+ type BankCode = (typeof BANK_CODES)[number];
25
+ declare const COUNTRY_CODES: ["AF" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BO" | "BQ" | "BA" | "BW" | "BR" | "IO" | "VG" | "BG" | "BF" | "BI" | "KH" | "CM" | "CA" | "CV" | "CF" | "TD" | "CL" | "CN" | "CO" | "KM" | "CK" | "CR" | "HR" | "CW" | "CY" | "CZ" | "CD" | "DK" | "DJ" | "DM" | "DO" | "TL" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FO" | "FJ" | "FI" | "FR" | "GF" | "PF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GR" | "GD" | "GP" | "GU" | "GT" | "GN" | "GW" | "GY" | "HT" | "HN" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IM" | "IL" | "IT" | "CI" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "XK" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LI" | "LT" | "LU" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MQ" | "MR" | "MU" | "MX" | "FM" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "NA" | "NP" | "NL" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "KP" | "NO" | "OM" | "PK" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PL" | "PT" | "PR" | "QA" | "CG" | "RE" | "RO" | "RU" | "RW" | "BL" | "KN" | "LC" | "MF" | "VC" | "WS" | "SM" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SO" | "ZA" | "KR" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SZ" | "SE" | "CH" | "TW" | "TJ" | "TZ" | "TH" | "TG" | "TO" | "TT" | "TN" | "TR" | "TM" | "UM" | "VI" | "UG" | "UA" | "AE" | "GB" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW", ...("AF" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BO" | "BQ" | "BA" | "BW" | "BR" | "IO" | "VG" | "BG" | "BF" | "BI" | "KH" | "CM" | "CA" | "CV" | "CF" | "TD" | "CL" | "CN" | "CO" | "KM" | "CK" | "CR" | "HR" | "CW" | "CY" | "CZ" | "CD" | "DK" | "DJ" | "DM" | "DO" | "TL" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FO" | "FJ" | "FI" | "FR" | "GF" | "PF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GR" | "GD" | "GP" | "GU" | "GT" | "GN" | "GW" | "GY" | "HT" | "HN" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IM" | "IL" | "IT" | "CI" | "JM" | "JP" | "JE" | "JO" | "KZ" | "KE" | "KI" | "XK" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LI" | "LT" | "LU" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MQ" | "MR" | "MU" | "MX" | "FM" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "NA" | "NP" | "NL" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "KP" | "NO" | "OM" | "PK" | "PS" | "PA" | "PG" | "PY" | "PE" | "PH" | "PL" | "PT" | "PR" | "QA" | "CG" | "RE" | "RO" | "RU" | "RW" | "BL" | "KN" | "LC" | "MF" | "VC" | "WS" | "SM" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SX" | "SK" | "SI" | "SO" | "ZA" | "KR" | "SS" | "ES" | "LK" | "SD" | "SR" | "SJ" | "SZ" | "SE" | "CH" | "TW" | "TJ" | "TZ" | "TH" | "TG" | "TO" | "TT" | "TN" | "TR" | "TM" | "UM" | "VI" | "UG" | "UA" | "AE" | "GB" | "UZ" | "VU" | "VE" | "VN" | "WF" | "EH" | "YE" | "ZM" | "ZW")[]];
26
+ type CountryCode = (typeof COUNTRY_CODES)[number];
27
+
28
+ interface SyncLog {
29
+ lastSyncedAt: Date;
30
+ }
31
+
32
+ type ConnectorKey = 'ERSTE' | 'FINBRICKS' | 'MOCK' | 'CREDITAS' | 'MOCK_COBS' | 'FIO';
33
+ interface ConfigBankAccount {
34
+ connectorKey: ConnectorKey;
35
+ id: string;
36
+ identification: {
37
+ number: string;
38
+ bankCode: BankCode;
39
+ iban: string;
40
+ holderName: string;
41
+ };
42
+ fallbackLastSync: Date;
43
+ currency: CurrencyCode;
44
+ production: boolean;
45
+ }
46
+ interface BankAccountWithLastSync extends ConfigBankAccount {
47
+ lastSyncAt: SyncLog;
48
+ }
49
+
50
+ type WithStatus<T extends {
51
+ status: PaymentStatus;
52
+ }, S extends PaymentStatus> = Omit<T, 'status'> & {
53
+ status: S;
54
+ };
55
+ type PaymentFailedInsertType = WithStatus<PaymentInsertType, 'FAILED'>;
56
+ type PaymentPreparedInsertType = WithStatus<PaymentInsertType, 'PREPARED'>;
57
+ type paymentInitializedInsertType = WithStatus<PaymentInsertType, 'INITIALIZED'>;
58
+ type BatchMetadata = {
59
+ signHash: string;
60
+ signId: string;
61
+ };
62
+ type InitiatedPayment = {
63
+ authorizationUrl: string;
64
+ payment: paymentInitializedInsertType;
65
+ };
66
+ type InitiatedBatch = {
67
+ id: string;
68
+ authorizationUrls: string[];
69
+ payments: paymentInitializedInsertType[];
70
+ metadata?: BatchMetadata | null;
71
+ };
72
+ type AuthInput = {
73
+ token: string;
74
+ refreshToken?: string;
75
+ };
76
+ declare abstract class IBankConnector {
77
+ abstract connectorKey: ConnectorKey;
78
+ abstract authenticate(code: AuthInput): Promise<string>;
79
+ abstract preparePayment(payment: IncomingPaymentMessage): Promise<PaymentPreparedInsertType>;
80
+ abstract initiateBatchFromPayments({ payments, }: {
81
+ payments: PaymentPreparedInsertType[];
82
+ }): Promise<InitiatedBatch>;
83
+ abstract initiateSinglePayment(payment: PaymentPreparedInsertType): Promise<InitiatedPayment>;
84
+ abstract getAllAccountPayments({ account, lastSync, db, env, }: {
85
+ account: ConfigBankAccount;
86
+ lastSync: SyncLog;
87
+ db: DrizzleD1Database<typeof tables>;
88
+ env: Environment;
89
+ }): Promise<PaymentInsertType[]>;
90
+ }
91
+
92
+ interface IncomingPaymentMessage extends PaymentInsertType {
93
+ }
94
+ interface OutgoingPaymentMessage extends PaymentInsertType {
95
+ }
96
+
97
+ export { IBankConnector as I, BATCH_STATUSES as k, PAYMENT_TYPES as m, PAYMENT_STATUSES as o, PAYMENT_DIRECTIONS as r, COUNTRY_CODES as t };
98
+ export type { AuthInput as A, BankAccountWithLastSync as B, ConfigBankAccount as C, OutgoingPaymentMessage as O, PaymentPreparedInsertType as P, SyncLog as S, ConnectorKey as a, CurrencyCode as b, BankCode as c, CountryCode as d, IncomingPaymentMessage as e, InitiatedBatch as f, InitiatedPayment as g, BatchMetadata as h, Currency as i, PaymentFailedInsertType as j, BatchStatus as l, PaymentType as n, paymentInitializedInsertType as p, PaymentStatus as q, PaymentDirection as s };