@develit-services/bank 0.0.28 → 0.0.30
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.
- package/dist/database/schema.cjs +10 -1
- package/dist/database/schema.d.cts +1 -1
- package/dist/database/schema.d.mts +1 -1
- package/dist/database/schema.d.ts +1 -1
- package/dist/database/schema.mjs +8 -1
- package/dist/export/worker.cjs +888 -575
- package/dist/export/worker.d.cts +210 -12
- package/dist/export/worker.d.mts +210 -12
- package/dist/export/worker.d.ts +210 -12
- package/dist/export/worker.mjs +859 -546
- package/dist/export/wrangler.cjs +1 -11
- package/dist/export/wrangler.d.cts +8 -9
- package/dist/export/wrangler.d.mts +8 -9
- package/dist/export/wrangler.d.ts +8 -9
- package/dist/export/wrangler.mjs +1 -11
- package/dist/shared/{bank.Cy_TcyKb.cjs → bank.BMRBXGF1.cjs} +347 -106
- package/dist/shared/{bank.CEZKAEiY.d.cts → bank.BchnXQDL.d.cts} +2 -2
- package/dist/shared/{bank.CEZKAEiY.d.mts → bank.BchnXQDL.d.mts} +2 -2
- package/dist/shared/{bank.CEZKAEiY.d.ts → bank.BchnXQDL.d.ts} +2 -2
- package/dist/shared/bank.CtUeOz8i.d.ts +1648 -0
- package/dist/shared/bank.D8o86NLF.d.mts +1648 -0
- package/dist/shared/bank.DUalSuEK.d.cts +1648 -0
- package/dist/shared/bank.DbNuuGvb.mjs +9 -0
- package/dist/shared/bank.DuY4d2y_.cjs +11 -0
- package/dist/shared/{bank.BuNG2S8h.d.cts → bank.Nf6oaNfB.d.cts} +547 -11
- package/dist/shared/{bank.BuNG2S8h.d.mts → bank.Nf6oaNfB.d.mts} +547 -11
- package/dist/shared/{bank.BuNG2S8h.d.ts → bank.Nf6oaNfB.d.ts} +547 -11
- package/dist/shared/{bank.DnDcNEvX.mjs → bank.YCUhOduX.mjs} +330 -107
- package/dist/types.cjs +32 -20
- package/dist/types.d.cts +496 -35
- package/dist/types.d.mts +496 -35
- package/dist/types.d.ts +496 -35
- package/dist/types.mjs +5 -4
- package/package.json +1 -1
- package/dist/shared/bank.BkLncGmL.d.ts +0 -122
- package/dist/shared/bank.C9jAvwna.mjs +0 -90
- package/dist/shared/bank.DWVLVMDa.d.mts +0 -122
- package/dist/shared/bank.DmypH3Au.d.cts +0 -122
- package/dist/shared/bank.P9gDUycr.cjs +0 -98
|
@@ -1,122 +0,0 @@
|
|
|
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.BuNG2S8h.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 BankAccountWithLastSync extends ConfigBankAccount {
|
|
29
|
-
lastSyncAt: SyncLog;
|
|
30
|
-
}
|
|
31
|
-
declare const CONNECTOR_KEYS: readonly ["ERSTE", "FINBRICKS", "MOCK", "CREDITAS", "MOCK_COBS", "FIO", "MONETA"];
|
|
32
|
-
type ConnectorKey = (typeof CONNECTOR_KEYS)[number];
|
|
33
|
-
declare const TOKEN_TYPES: readonly ["ACCOUNT_AUTHORIZATION"];
|
|
34
|
-
type TokenType = (typeof TOKEN_TYPES)[number];
|
|
35
|
-
interface ConfigBankAccount {
|
|
36
|
-
connectorKey: ConnectorKey;
|
|
37
|
-
id: string;
|
|
38
|
-
identification: {
|
|
39
|
-
number: string;
|
|
40
|
-
bankCode: BankCode;
|
|
41
|
-
iban: string;
|
|
42
|
-
holderName: string;
|
|
43
|
-
};
|
|
44
|
-
fallbackLastSync: Date;
|
|
45
|
-
currency: CurrencyCode;
|
|
46
|
-
production: boolean;
|
|
47
|
-
}
|
|
48
|
-
interface ConfigEnvironmentBankAccount {
|
|
49
|
-
stagingAccounts: ConfigBankAccount[];
|
|
50
|
-
productionAccounts: ConfigBankAccount[];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
interface SyncLog {
|
|
54
|
-
lastSyncedAt: Date;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
type WithStatus<T extends {
|
|
58
|
-
status: PaymentStatus;
|
|
59
|
-
}, S extends PaymentStatus> = Omit<T, 'status'> & {
|
|
60
|
-
status: S;
|
|
61
|
-
};
|
|
62
|
-
type PaymentFailedInsertType = WithStatus<PaymentInsertType, 'FAILED'>;
|
|
63
|
-
type PaymentPreparedInsertType = WithStatus<PaymentInsertType, 'PREPARED'>;
|
|
64
|
-
type paymentInitializedInsertType = WithStatus<PaymentInsertType, 'INITIALIZED'>;
|
|
65
|
-
type BatchMetadata = {
|
|
66
|
-
signHash: string;
|
|
67
|
-
signId: string;
|
|
68
|
-
};
|
|
69
|
-
type InitiatedPayment = {
|
|
70
|
-
authorizationUrl: string;
|
|
71
|
-
payment: paymentInitializedInsertType;
|
|
72
|
-
};
|
|
73
|
-
type InitiatedBatch = {
|
|
74
|
-
id: string;
|
|
75
|
-
authorizationUrls: string[];
|
|
76
|
-
payments: paymentInitializedInsertType[];
|
|
77
|
-
metadata?: BatchMetadata | null;
|
|
78
|
-
};
|
|
79
|
-
type AuthInput = {
|
|
80
|
-
token: string;
|
|
81
|
-
refreshToken?: string;
|
|
82
|
-
};
|
|
83
|
-
declare abstract class IBankConnector {
|
|
84
|
-
abstract connectorKey: ConnectorKey;
|
|
85
|
-
abstract kv: KVNamespace;
|
|
86
|
-
abstract authenticate(tokens?: {
|
|
87
|
-
refreshToken?: string;
|
|
88
|
-
}): Promise<string>;
|
|
89
|
-
abstract getAuthUri({ accountId, ott, }: {
|
|
90
|
-
accountId: string;
|
|
91
|
-
ott: string;
|
|
92
|
-
}): Promise<string>;
|
|
93
|
-
abstract authorizeAccount({ urlParams, }: {
|
|
94
|
-
urlParams: string;
|
|
95
|
-
}): Promise<boolean>;
|
|
96
|
-
abstract listAccounts(): Promise<[]>;
|
|
97
|
-
abstract preparePayment(payment: IncomingPaymentMessage): Promise<PaymentPreparedInsertType>;
|
|
98
|
-
abstract initiateBatchFromPayments({ payments, }: {
|
|
99
|
-
payments: PaymentPreparedInsertType[];
|
|
100
|
-
}): Promise<InitiatedBatch>;
|
|
101
|
-
abstract initiateSinglePayment(payment: PaymentPreparedInsertType): Promise<InitiatedPayment>;
|
|
102
|
-
abstract getAllAccountPayments({ account, lastSync, db, env, }: {
|
|
103
|
-
account: ConfigBankAccount;
|
|
104
|
-
lastSync: SyncLog;
|
|
105
|
-
db: DrizzleD1Database<typeof tables>;
|
|
106
|
-
env: Environment;
|
|
107
|
-
}): Promise<PaymentInsertType[]>;
|
|
108
|
-
abstract getPaymentStatus({ paymentId, }: {
|
|
109
|
-
paymentId: string;
|
|
110
|
-
}): Promise<PaymentStatus>;
|
|
111
|
-
abstract getBatchStatus({ batchId, }: {
|
|
112
|
-
batchId: string;
|
|
113
|
-
}): Promise<BatchStatus>;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
interface IncomingPaymentMessage extends PaymentInsertType {
|
|
117
|
-
}
|
|
118
|
-
interface OutgoingPaymentMessage extends PaymentInsertType {
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export { IBankConnector as I, TOKEN_TYPES as T, BATCH_STATUSES as n, PAYMENT_TYPES as o, PAYMENT_STATUSES as r, PAYMENT_DIRECTIONS as s, COUNTRY_CODES as u, CONNECTOR_KEYS as v };
|
|
122
|
-
export type { AuthInput as A, BankAccountWithLastSync as B, ConfigEnvironmentBankAccount as C, OutgoingPaymentMessage as O, PaymentPreparedInsertType as P, SyncLog as S, ConfigBankAccount as a, ConnectorKey as b, CurrencyCode as c, BankCode as d, CountryCode as e, IncomingPaymentMessage as f, InitiatedBatch as g, InitiatedPayment as h, PaymentStatus as i, BatchStatus as j, BatchMetadata as k, Currency as l, PaymentFailedInsertType as m, paymentInitializedInsertType as p, PaymentType as q, PaymentDirection as t, TokenType as w };
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { base } from '@develit-io/backend-sdk';
|
|
2
|
-
import { sqliteTable, text, integer, real } from 'drizzle-orm/sqlite-core';
|
|
3
|
-
import { relations } from 'drizzle-orm/relations';
|
|
4
|
-
|
|
5
|
-
const BATCH_STATUSES = [
|
|
6
|
-
"OPEN",
|
|
7
|
-
"WAITING_FOR_PROCESSING",
|
|
8
|
-
"PROCESSING",
|
|
9
|
-
"READY_TO_SIGN",
|
|
10
|
-
"PREPARED",
|
|
11
|
-
"COMPLETED",
|
|
12
|
-
"FAILED"
|
|
13
|
-
];
|
|
14
|
-
const batch = sqliteTable("batch", {
|
|
15
|
-
...base,
|
|
16
|
-
batchPaymentInitiatedAt: integer("batch_payment_initiated_at", {
|
|
17
|
-
mode: "timestamp_ms"
|
|
18
|
-
}),
|
|
19
|
-
authorizationUrls: text("authorization_urls", { mode: "json" }).$type(),
|
|
20
|
-
accountId: text("account_id"),
|
|
21
|
-
status: text("status", { enum: BATCH_STATUSES }).$type(),
|
|
22
|
-
payments: text("payments", { mode: "json" }).$type().notNull(),
|
|
23
|
-
metadata: text("metadata", { mode: "json" }).$type()
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const payment = sqliteTable("payment", {
|
|
27
|
-
...base,
|
|
28
|
-
refId: text("ref_id"),
|
|
29
|
-
bankRefId: text("bank_ref_id"),
|
|
30
|
-
amount: real("amount").notNull(),
|
|
31
|
-
direction: text("direction").$type().notNull(),
|
|
32
|
-
paymentType: text("payment_type").$type(),
|
|
33
|
-
currency: text("currency").$type().notNull(),
|
|
34
|
-
status: text("status").$type().notNull(),
|
|
35
|
-
statusReason: text("status_reason"),
|
|
36
|
-
batchId: text("bank_execution_batch_id"),
|
|
37
|
-
initiatedAt: integer("initiated_at", {
|
|
38
|
-
mode: "timestamp_ms"
|
|
39
|
-
}),
|
|
40
|
-
vs: text("vs"),
|
|
41
|
-
ss: text("ss"),
|
|
42
|
-
ks: text("ks"),
|
|
43
|
-
message: text("message"),
|
|
44
|
-
processedAt: integer("processed_at", {
|
|
45
|
-
mode: "timestamp_ms"
|
|
46
|
-
}),
|
|
47
|
-
creditorHolderName: text("creditor_holder_name").notNull(),
|
|
48
|
-
creditorAccountNumberWithBankCode: text(
|
|
49
|
-
"creditor_account_number_with_bank_code"
|
|
50
|
-
),
|
|
51
|
-
creditorIban: text("creditor_iban"),
|
|
52
|
-
debtorIban: text("debtor_iban"),
|
|
53
|
-
debtorHolderName: text("debtor_holder_name"),
|
|
54
|
-
debtorAccountNumberWithBankCode: text("debtor_account_number_with_bank_code")
|
|
55
|
-
});
|
|
56
|
-
const paymentRelations = relations(payment, ({ one }) => ({
|
|
57
|
-
batch: one(batch, { fields: [payment.batchId], references: [batch.id] })
|
|
58
|
-
}));
|
|
59
|
-
|
|
60
|
-
const CONNECTOR_KEYS = [
|
|
61
|
-
"ERSTE",
|
|
62
|
-
"FINBRICKS",
|
|
63
|
-
"MOCK",
|
|
64
|
-
"CREDITAS",
|
|
65
|
-
"MOCK_COBS",
|
|
66
|
-
"FIO",
|
|
67
|
-
"MONETA"
|
|
68
|
-
];
|
|
69
|
-
const TOKEN_TYPES = ["ACCOUNT_AUTHORIZATION"];
|
|
70
|
-
|
|
71
|
-
const ott = sqliteTable("ott", {
|
|
72
|
-
...base,
|
|
73
|
-
oneTimeToken: text("one_time_token").notNull(),
|
|
74
|
-
tokenType: text("token_type", { enum: TOKEN_TYPES }).$type().notNull(),
|
|
75
|
-
connectorKey: text("connector_key", {
|
|
76
|
-
enum: CONNECTOR_KEYS
|
|
77
|
-
}).$type().notNull(),
|
|
78
|
-
accountId: text("account_id").notNull(),
|
|
79
|
-
expiresAt: integer("expires_at", { mode: "timestamp_ms" }).notNull()
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
const schema = {
|
|
83
|
-
__proto__: null,
|
|
84
|
-
batch: batch,
|
|
85
|
-
ott: ott,
|
|
86
|
-
payment: payment,
|
|
87
|
-
paymentRelations: paymentRelations
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
export { CONNECTOR_KEYS as C, TOKEN_TYPES as T, paymentRelations as a, batch as b, ott as o, payment as p, schema as s };
|
|
@@ -1,122 +0,0 @@
|
|
|
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.BuNG2S8h.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 BankAccountWithLastSync extends ConfigBankAccount {
|
|
29
|
-
lastSyncAt: SyncLog;
|
|
30
|
-
}
|
|
31
|
-
declare const CONNECTOR_KEYS: readonly ["ERSTE", "FINBRICKS", "MOCK", "CREDITAS", "MOCK_COBS", "FIO", "MONETA"];
|
|
32
|
-
type ConnectorKey = (typeof CONNECTOR_KEYS)[number];
|
|
33
|
-
declare const TOKEN_TYPES: readonly ["ACCOUNT_AUTHORIZATION"];
|
|
34
|
-
type TokenType = (typeof TOKEN_TYPES)[number];
|
|
35
|
-
interface ConfigBankAccount {
|
|
36
|
-
connectorKey: ConnectorKey;
|
|
37
|
-
id: string;
|
|
38
|
-
identification: {
|
|
39
|
-
number: string;
|
|
40
|
-
bankCode: BankCode;
|
|
41
|
-
iban: string;
|
|
42
|
-
holderName: string;
|
|
43
|
-
};
|
|
44
|
-
fallbackLastSync: Date;
|
|
45
|
-
currency: CurrencyCode;
|
|
46
|
-
production: boolean;
|
|
47
|
-
}
|
|
48
|
-
interface ConfigEnvironmentBankAccount {
|
|
49
|
-
stagingAccounts: ConfigBankAccount[];
|
|
50
|
-
productionAccounts: ConfigBankAccount[];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
interface SyncLog {
|
|
54
|
-
lastSyncedAt: Date;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
type WithStatus<T extends {
|
|
58
|
-
status: PaymentStatus;
|
|
59
|
-
}, S extends PaymentStatus> = Omit<T, 'status'> & {
|
|
60
|
-
status: S;
|
|
61
|
-
};
|
|
62
|
-
type PaymentFailedInsertType = WithStatus<PaymentInsertType, 'FAILED'>;
|
|
63
|
-
type PaymentPreparedInsertType = WithStatus<PaymentInsertType, 'PREPARED'>;
|
|
64
|
-
type paymentInitializedInsertType = WithStatus<PaymentInsertType, 'INITIALIZED'>;
|
|
65
|
-
type BatchMetadata = {
|
|
66
|
-
signHash: string;
|
|
67
|
-
signId: string;
|
|
68
|
-
};
|
|
69
|
-
type InitiatedPayment = {
|
|
70
|
-
authorizationUrl: string;
|
|
71
|
-
payment: paymentInitializedInsertType;
|
|
72
|
-
};
|
|
73
|
-
type InitiatedBatch = {
|
|
74
|
-
id: string;
|
|
75
|
-
authorizationUrls: string[];
|
|
76
|
-
payments: paymentInitializedInsertType[];
|
|
77
|
-
metadata?: BatchMetadata | null;
|
|
78
|
-
};
|
|
79
|
-
type AuthInput = {
|
|
80
|
-
token: string;
|
|
81
|
-
refreshToken?: string;
|
|
82
|
-
};
|
|
83
|
-
declare abstract class IBankConnector {
|
|
84
|
-
abstract connectorKey: ConnectorKey;
|
|
85
|
-
abstract kv: KVNamespace;
|
|
86
|
-
abstract authenticate(tokens?: {
|
|
87
|
-
refreshToken?: string;
|
|
88
|
-
}): Promise<string>;
|
|
89
|
-
abstract getAuthUri({ accountId, ott, }: {
|
|
90
|
-
accountId: string;
|
|
91
|
-
ott: string;
|
|
92
|
-
}): Promise<string>;
|
|
93
|
-
abstract authorizeAccount({ urlParams, }: {
|
|
94
|
-
urlParams: string;
|
|
95
|
-
}): Promise<boolean>;
|
|
96
|
-
abstract listAccounts(): Promise<[]>;
|
|
97
|
-
abstract preparePayment(payment: IncomingPaymentMessage): Promise<PaymentPreparedInsertType>;
|
|
98
|
-
abstract initiateBatchFromPayments({ payments, }: {
|
|
99
|
-
payments: PaymentPreparedInsertType[];
|
|
100
|
-
}): Promise<InitiatedBatch>;
|
|
101
|
-
abstract initiateSinglePayment(payment: PaymentPreparedInsertType): Promise<InitiatedPayment>;
|
|
102
|
-
abstract getAllAccountPayments({ account, lastSync, db, env, }: {
|
|
103
|
-
account: ConfigBankAccount;
|
|
104
|
-
lastSync: SyncLog;
|
|
105
|
-
db: DrizzleD1Database<typeof tables>;
|
|
106
|
-
env: Environment;
|
|
107
|
-
}): Promise<PaymentInsertType[]>;
|
|
108
|
-
abstract getPaymentStatus({ paymentId, }: {
|
|
109
|
-
paymentId: string;
|
|
110
|
-
}): Promise<PaymentStatus>;
|
|
111
|
-
abstract getBatchStatus({ batchId, }: {
|
|
112
|
-
batchId: string;
|
|
113
|
-
}): Promise<BatchStatus>;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
interface IncomingPaymentMessage extends PaymentInsertType {
|
|
117
|
-
}
|
|
118
|
-
interface OutgoingPaymentMessage extends PaymentInsertType {
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export { IBankConnector as I, TOKEN_TYPES as T, BATCH_STATUSES as n, PAYMENT_TYPES as o, PAYMENT_STATUSES as r, PAYMENT_DIRECTIONS as s, COUNTRY_CODES as u, CONNECTOR_KEYS as v };
|
|
122
|
-
export type { AuthInput as A, BankAccountWithLastSync as B, ConfigEnvironmentBankAccount as C, OutgoingPaymentMessage as O, PaymentPreparedInsertType as P, SyncLog as S, ConfigBankAccount as a, ConnectorKey as b, CurrencyCode as c, BankCode as d, CountryCode as e, IncomingPaymentMessage as f, InitiatedBatch as g, InitiatedPayment as h, PaymentStatus as i, BatchStatus as j, BatchMetadata as k, Currency as l, PaymentFailedInsertType as m, paymentInitializedInsertType as p, PaymentType as q, PaymentDirection as t, TokenType as w };
|
|
@@ -1,122 +0,0 @@
|
|
|
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.BuNG2S8h.cjs';
|
|
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 BankAccountWithLastSync extends ConfigBankAccount {
|
|
29
|
-
lastSyncAt: SyncLog;
|
|
30
|
-
}
|
|
31
|
-
declare const CONNECTOR_KEYS: readonly ["ERSTE", "FINBRICKS", "MOCK", "CREDITAS", "MOCK_COBS", "FIO", "MONETA"];
|
|
32
|
-
type ConnectorKey = (typeof CONNECTOR_KEYS)[number];
|
|
33
|
-
declare const TOKEN_TYPES: readonly ["ACCOUNT_AUTHORIZATION"];
|
|
34
|
-
type TokenType = (typeof TOKEN_TYPES)[number];
|
|
35
|
-
interface ConfigBankAccount {
|
|
36
|
-
connectorKey: ConnectorKey;
|
|
37
|
-
id: string;
|
|
38
|
-
identification: {
|
|
39
|
-
number: string;
|
|
40
|
-
bankCode: BankCode;
|
|
41
|
-
iban: string;
|
|
42
|
-
holderName: string;
|
|
43
|
-
};
|
|
44
|
-
fallbackLastSync: Date;
|
|
45
|
-
currency: CurrencyCode;
|
|
46
|
-
production: boolean;
|
|
47
|
-
}
|
|
48
|
-
interface ConfigEnvironmentBankAccount {
|
|
49
|
-
stagingAccounts: ConfigBankAccount[];
|
|
50
|
-
productionAccounts: ConfigBankAccount[];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
interface SyncLog {
|
|
54
|
-
lastSyncedAt: Date;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
type WithStatus<T extends {
|
|
58
|
-
status: PaymentStatus;
|
|
59
|
-
}, S extends PaymentStatus> = Omit<T, 'status'> & {
|
|
60
|
-
status: S;
|
|
61
|
-
};
|
|
62
|
-
type PaymentFailedInsertType = WithStatus<PaymentInsertType, 'FAILED'>;
|
|
63
|
-
type PaymentPreparedInsertType = WithStatus<PaymentInsertType, 'PREPARED'>;
|
|
64
|
-
type paymentInitializedInsertType = WithStatus<PaymentInsertType, 'INITIALIZED'>;
|
|
65
|
-
type BatchMetadata = {
|
|
66
|
-
signHash: string;
|
|
67
|
-
signId: string;
|
|
68
|
-
};
|
|
69
|
-
type InitiatedPayment = {
|
|
70
|
-
authorizationUrl: string;
|
|
71
|
-
payment: paymentInitializedInsertType;
|
|
72
|
-
};
|
|
73
|
-
type InitiatedBatch = {
|
|
74
|
-
id: string;
|
|
75
|
-
authorizationUrls: string[];
|
|
76
|
-
payments: paymentInitializedInsertType[];
|
|
77
|
-
metadata?: BatchMetadata | null;
|
|
78
|
-
};
|
|
79
|
-
type AuthInput = {
|
|
80
|
-
token: string;
|
|
81
|
-
refreshToken?: string;
|
|
82
|
-
};
|
|
83
|
-
declare abstract class IBankConnector {
|
|
84
|
-
abstract connectorKey: ConnectorKey;
|
|
85
|
-
abstract kv: KVNamespace;
|
|
86
|
-
abstract authenticate(tokens?: {
|
|
87
|
-
refreshToken?: string;
|
|
88
|
-
}): Promise<string>;
|
|
89
|
-
abstract getAuthUri({ accountId, ott, }: {
|
|
90
|
-
accountId: string;
|
|
91
|
-
ott: string;
|
|
92
|
-
}): Promise<string>;
|
|
93
|
-
abstract authorizeAccount({ urlParams, }: {
|
|
94
|
-
urlParams: string;
|
|
95
|
-
}): Promise<boolean>;
|
|
96
|
-
abstract listAccounts(): Promise<[]>;
|
|
97
|
-
abstract preparePayment(payment: IncomingPaymentMessage): Promise<PaymentPreparedInsertType>;
|
|
98
|
-
abstract initiateBatchFromPayments({ payments, }: {
|
|
99
|
-
payments: PaymentPreparedInsertType[];
|
|
100
|
-
}): Promise<InitiatedBatch>;
|
|
101
|
-
abstract initiateSinglePayment(payment: PaymentPreparedInsertType): Promise<InitiatedPayment>;
|
|
102
|
-
abstract getAllAccountPayments({ account, lastSync, db, env, }: {
|
|
103
|
-
account: ConfigBankAccount;
|
|
104
|
-
lastSync: SyncLog;
|
|
105
|
-
db: DrizzleD1Database<typeof tables>;
|
|
106
|
-
env: Environment;
|
|
107
|
-
}): Promise<PaymentInsertType[]>;
|
|
108
|
-
abstract getPaymentStatus({ paymentId, }: {
|
|
109
|
-
paymentId: string;
|
|
110
|
-
}): Promise<PaymentStatus>;
|
|
111
|
-
abstract getBatchStatus({ batchId, }: {
|
|
112
|
-
batchId: string;
|
|
113
|
-
}): Promise<BatchStatus>;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
interface IncomingPaymentMessage extends PaymentInsertType {
|
|
117
|
-
}
|
|
118
|
-
interface OutgoingPaymentMessage extends PaymentInsertType {
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export { IBankConnector as I, TOKEN_TYPES as T, BATCH_STATUSES as n, PAYMENT_TYPES as o, PAYMENT_STATUSES as r, PAYMENT_DIRECTIONS as s, COUNTRY_CODES as u, CONNECTOR_KEYS as v };
|
|
122
|
-
export type { AuthInput as A, BankAccountWithLastSync as B, ConfigEnvironmentBankAccount as C, OutgoingPaymentMessage as O, PaymentPreparedInsertType as P, SyncLog as S, ConfigBankAccount as a, ConnectorKey as b, CurrencyCode as c, BankCode as d, CountryCode as e, IncomingPaymentMessage as f, InitiatedBatch as g, InitiatedPayment as h, PaymentStatus as i, BatchStatus as j, BatchMetadata as k, Currency as l, PaymentFailedInsertType as m, paymentInitializedInsertType as p, PaymentType as q, PaymentDirection as t, TokenType as w };
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const backendSdk = require('@develit-io/backend-sdk');
|
|
4
|
-
const sqliteCore = require('drizzle-orm/sqlite-core');
|
|
5
|
-
const relations = require('drizzle-orm/relations');
|
|
6
|
-
|
|
7
|
-
const BATCH_STATUSES = [
|
|
8
|
-
"OPEN",
|
|
9
|
-
"WAITING_FOR_PROCESSING",
|
|
10
|
-
"PROCESSING",
|
|
11
|
-
"READY_TO_SIGN",
|
|
12
|
-
"PREPARED",
|
|
13
|
-
"COMPLETED",
|
|
14
|
-
"FAILED"
|
|
15
|
-
];
|
|
16
|
-
const batch = sqliteCore.sqliteTable("batch", {
|
|
17
|
-
...backendSdk.base,
|
|
18
|
-
batchPaymentInitiatedAt: sqliteCore.integer("batch_payment_initiated_at", {
|
|
19
|
-
mode: "timestamp_ms"
|
|
20
|
-
}),
|
|
21
|
-
authorizationUrls: sqliteCore.text("authorization_urls", { mode: "json" }).$type(),
|
|
22
|
-
accountId: sqliteCore.text("account_id"),
|
|
23
|
-
status: sqliteCore.text("status", { enum: BATCH_STATUSES }).$type(),
|
|
24
|
-
payments: sqliteCore.text("payments", { mode: "json" }).$type().notNull(),
|
|
25
|
-
metadata: sqliteCore.text("metadata", { mode: "json" }).$type()
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const payment = sqliteCore.sqliteTable("payment", {
|
|
29
|
-
...backendSdk.base,
|
|
30
|
-
refId: sqliteCore.text("ref_id"),
|
|
31
|
-
bankRefId: sqliteCore.text("bank_ref_id"),
|
|
32
|
-
amount: sqliteCore.real("amount").notNull(),
|
|
33
|
-
direction: sqliteCore.text("direction").$type().notNull(),
|
|
34
|
-
paymentType: sqliteCore.text("payment_type").$type(),
|
|
35
|
-
currency: sqliteCore.text("currency").$type().notNull(),
|
|
36
|
-
status: sqliteCore.text("status").$type().notNull(),
|
|
37
|
-
statusReason: sqliteCore.text("status_reason"),
|
|
38
|
-
batchId: sqliteCore.text("bank_execution_batch_id"),
|
|
39
|
-
initiatedAt: sqliteCore.integer("initiated_at", {
|
|
40
|
-
mode: "timestamp_ms"
|
|
41
|
-
}),
|
|
42
|
-
vs: sqliteCore.text("vs"),
|
|
43
|
-
ss: sqliteCore.text("ss"),
|
|
44
|
-
ks: sqliteCore.text("ks"),
|
|
45
|
-
message: sqliteCore.text("message"),
|
|
46
|
-
processedAt: sqliteCore.integer("processed_at", {
|
|
47
|
-
mode: "timestamp_ms"
|
|
48
|
-
}),
|
|
49
|
-
creditorHolderName: sqliteCore.text("creditor_holder_name").notNull(),
|
|
50
|
-
creditorAccountNumberWithBankCode: sqliteCore.text(
|
|
51
|
-
"creditor_account_number_with_bank_code"
|
|
52
|
-
),
|
|
53
|
-
creditorIban: sqliteCore.text("creditor_iban"),
|
|
54
|
-
debtorIban: sqliteCore.text("debtor_iban"),
|
|
55
|
-
debtorHolderName: sqliteCore.text("debtor_holder_name"),
|
|
56
|
-
debtorAccountNumberWithBankCode: sqliteCore.text("debtor_account_number_with_bank_code")
|
|
57
|
-
});
|
|
58
|
-
const paymentRelations = relations.relations(payment, ({ one }) => ({
|
|
59
|
-
batch: one(batch, { fields: [payment.batchId], references: [batch.id] })
|
|
60
|
-
}));
|
|
61
|
-
|
|
62
|
-
const CONNECTOR_KEYS = [
|
|
63
|
-
"ERSTE",
|
|
64
|
-
"FINBRICKS",
|
|
65
|
-
"MOCK",
|
|
66
|
-
"CREDITAS",
|
|
67
|
-
"MOCK_COBS",
|
|
68
|
-
"FIO",
|
|
69
|
-
"MONETA"
|
|
70
|
-
];
|
|
71
|
-
const TOKEN_TYPES = ["ACCOUNT_AUTHORIZATION"];
|
|
72
|
-
|
|
73
|
-
const ott = sqliteCore.sqliteTable("ott", {
|
|
74
|
-
...backendSdk.base,
|
|
75
|
-
oneTimeToken: sqliteCore.text("one_time_token").notNull(),
|
|
76
|
-
tokenType: sqliteCore.text("token_type", { enum: TOKEN_TYPES }).$type().notNull(),
|
|
77
|
-
connectorKey: sqliteCore.text("connector_key", {
|
|
78
|
-
enum: CONNECTOR_KEYS
|
|
79
|
-
}).$type().notNull(),
|
|
80
|
-
accountId: sqliteCore.text("account_id").notNull(),
|
|
81
|
-
expiresAt: sqliteCore.integer("expires_at", { mode: "timestamp_ms" }).notNull()
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
const schema = {
|
|
85
|
-
__proto__: null,
|
|
86
|
-
batch: batch,
|
|
87
|
-
ott: ott,
|
|
88
|
-
payment: payment,
|
|
89
|
-
paymentRelations: paymentRelations
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
exports.CONNECTOR_KEYS = CONNECTOR_KEYS;
|
|
93
|
-
exports.TOKEN_TYPES = TOKEN_TYPES;
|
|
94
|
-
exports.batch = batch;
|
|
95
|
-
exports.ott = ott;
|
|
96
|
-
exports.payment = payment;
|
|
97
|
-
exports.paymentRelations = paymentRelations;
|
|
98
|
-
exports.schema = schema;
|