@develit-services/bank 2.4.0 → 3.0.1

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 (38) hide show
  1. package/dist/database/schema.cjs +1 -10
  2. package/dist/database/schema.d.cts +4 -4
  3. package/dist/database/schema.d.mts +4 -4
  4. package/dist/database/schema.d.ts +4 -4
  5. package/dist/database/schema.mjs +1 -8
  6. package/dist/export/worker.cjs +137 -137
  7. package/dist/export/worker.d.cts +119 -455
  8. package/dist/export/worker.d.mts +119 -455
  9. package/dist/export/worker.d.ts +119 -455
  10. package/dist/export/worker.mjs +40 -40
  11. package/dist/export/workflows.cjs +30 -24
  12. package/dist/export/workflows.mjs +19 -13
  13. package/dist/export/wrangler.cjs +3 -11
  14. package/dist/export/wrangler.d.cts +1 -1
  15. package/dist/export/wrangler.d.mts +1 -1
  16. package/dist/export/wrangler.d.ts +1 -1
  17. package/dist/export/wrangler.mjs +3 -11
  18. package/dist/shared/{bank.c1sHv5v_.cjs → bank.1DaJXkX5.cjs} +200 -460
  19. package/dist/shared/{bank.Bs0isbAY.d.ts → bank.2M66Yx-J.d.ts} +9 -9
  20. package/dist/shared/bank.9Yw4KHyl.cjs +275 -0
  21. package/dist/shared/{bank.BI2OxQsM.d.mts → bank.BUgy8rcb.d.mts} +9 -9
  22. package/dist/shared/bank.BzDNLxB_.mjs +254 -0
  23. package/dist/shared/{bank.B0I6H6AT.cjs → bank.C3FUz-p6.cjs} +17 -16
  24. package/dist/shared/{bank.Ca0iWjhb.d.cts → bank.CVPVkitI.d.cts} +9 -9
  25. package/dist/shared/{bank.IlVbIEuM.mjs → bank.Cwbl-Mjn.mjs} +193 -433
  26. package/dist/shared/{bank.BJ_vbyUT.d.ts → bank.DR02_AJ7.d.cts} +1225 -3788
  27. package/dist/shared/{bank.BJ_vbyUT.d.cts → bank.DR02_AJ7.d.mts} +1225 -3788
  28. package/dist/shared/{bank.BJ_vbyUT.d.mts → bank.DR02_AJ7.d.ts} +1225 -3788
  29. package/dist/shared/{bank.fZkUcrn9.mjs → bank.lJOMYeVw.mjs} +2 -1
  30. package/dist/types.cjs +38 -38
  31. package/dist/types.d.cts +61 -454
  32. package/dist/types.d.mts +61 -454
  33. package/dist/types.d.ts +61 -454
  34. package/dist/types.mjs +4 -4
  35. package/package.json +5 -5
  36. package/dist/shared/{bank.Bz4DIxJL.d.cts → bank.C6sLje8B.d.cts} +3 -3
  37. package/dist/shared/{bank.Bz4DIxJL.d.mts → bank.C6sLje8B.d.mts} +3 -3
  38. package/dist/shared/{bank.Bz4DIxJL.d.ts → bank.C6sLje8B.d.ts} +3 -3
@@ -1,13 +1,191 @@
1
- import { uuidv4, createInternalError, useResult, bankAccount, base, structuredAddressSchema } from '@develit-io/backend-sdk';
2
- import { sqliteTable, text, integer, unique, real, index } from 'drizzle-orm/sqlite-core';
1
+ import { uuidv4, createInternalError, useResult, structuredAddressSchema } from '@develit-io/backend-sdk';
3
2
  import { format, parseISO } from 'date-fns';
4
3
  import { importPKCS8, SignJWT } from 'jose';
5
4
  import { z } from 'zod';
6
- import { COUNTRY_CODES_2, CURRENCY_CODES, BANK_CODES } from '@develit-io/general-codes';
7
- import { relations } from 'drizzle-orm/relations';
8
- import { and, not, inArray, isNull } from 'drizzle-orm';
5
+ import { CURRENCY_CODES } from '@develit-io/general-codes';
6
+ import { s as schema, e as PAYMENT_REQUEST_STATUSES, h as account, i as accountCredentials, o as ott } from './bank.BzDNLxB_.mjs';
7
+ import { defineRelations, and, not, inArray, isNull } from 'drizzle-orm';
8
+ import { createInsertSchema, createUpdateSchema, createSelectSchema } from 'drizzle-orm/zod';
9
9
  import 'node:crypto';
10
- import { createInsertSchema, createUpdateSchema, createSelectSchema } from 'drizzle-zod';
10
+
11
+ const relations = defineRelations(schema, (r) => ({
12
+ payment: {
13
+ batch: r.one.batch({
14
+ from: r.payment.batchId,
15
+ to: r.batch.id
16
+ })
17
+ },
18
+ paymentRequest: {
19
+ batch: r.one.batch({
20
+ from: r.paymentRequest.batchId,
21
+ to: r.batch.id
22
+ }),
23
+ account: r.one.account({
24
+ from: r.paymentRequest.accountId,
25
+ to: r.account.id
26
+ })
27
+ }
28
+ }));
29
+
30
+ const tables = schema;
31
+
32
+ async function signFinbricksJws({
33
+ privateKeyPem,
34
+ merchantId,
35
+ jwsData
36
+ }) {
37
+ const privateKey = await importPKCS8(privateKeyPem, "RS256");
38
+ const payload = JSON.stringify(jwsData);
39
+ const jws = await new SignJWT(JSON.parse(payload)).setProtectedHeader({
40
+ alg: "RS256",
41
+ kid: merchantId,
42
+ typ: "JWT"
43
+ }).sign(privateKey);
44
+ const [header, , signature] = jws.split(".");
45
+ return `${header}..${signature}`;
46
+ }
47
+
48
+ const useFinbricksFetch = async (config, init) => {
49
+ const {
50
+ baseUrl,
51
+ endpoint,
52
+ method = "GET",
53
+ merchantId,
54
+ privateKeyPem,
55
+ query,
56
+ body,
57
+ correlationId,
58
+ psuIp = "88.205.47.1",
59
+ psuAgent = "Develit/BankService"
60
+ } = config;
61
+ const url = new URL(`${baseUrl}${endpoint}`);
62
+ if (query) {
63
+ for (const [k, v] of Object.entries(query)) {
64
+ if (v !== void 0 && v !== null)
65
+ url.searchParams.append(k, v.toString());
66
+ }
67
+ }
68
+ const uriWithQuery = `${endpoint}${url.search ? `?${url.searchParams.toString()}` : ""}`;
69
+ const bodyString = body ? JSON.stringify(body) : "";
70
+ const jwsSignature = await signFinbricksJws({
71
+ privateKeyPem,
72
+ merchantId,
73
+ jwsData: {
74
+ uri: uriWithQuery,
75
+ body: bodyString
76
+ }
77
+ });
78
+ const headers = {
79
+ "Content-Type": "application/json",
80
+ "JWS-Signature": jwsSignature,
81
+ "PSU-IP-Address": psuIp,
82
+ "PSU-User-Agent": psuAgent,
83
+ ...init?.headers
84
+ };
85
+ if (correlationId) {
86
+ headers["Correlation-ID"] = correlationId;
87
+ }
88
+ console.log(
89
+ "[Finbricks] request",
90
+ JSON.stringify(
91
+ {
92
+ method,
93
+ url: url.toString(),
94
+ body: body ?? null
95
+ },
96
+ null,
97
+ 2
98
+ )
99
+ );
100
+ const res = await fetch(url.toString(), {
101
+ method,
102
+ headers,
103
+ body: method !== "GET" ? bodyString : void 0
104
+ });
105
+ if (!res.ok) {
106
+ const text = await res.text().catch(() => "unknown error");
107
+ console.error("[Finbricks] error response", {
108
+ status: res.status,
109
+ statusText: res.statusText,
110
+ url: url.toString(),
111
+ body: text
112
+ });
113
+ throw new Error(
114
+ `Finbricks API error: ${res.status} ${res.statusText} \u2013 ${text}`
115
+ );
116
+ }
117
+ const json = await res.json();
118
+ console.log(
119
+ "[Finbricks] response",
120
+ JSON.stringify(
121
+ {
122
+ status: res.status,
123
+ url: url.toString(),
124
+ body: json
125
+ },
126
+ null,
127
+ 2
128
+ )
129
+ );
130
+ return json;
131
+ };
132
+ class FinbricksClient {
133
+ constructor(baseUrl, merchantId, privateKeyPem, redirectUri) {
134
+ this.BASE_URL = baseUrl;
135
+ this.MERCHANT_ID = merchantId;
136
+ this.PRIVATE_KEY_PEM = privateKeyPem;
137
+ this.REDIRECT_URI = redirectUri;
138
+ }
139
+ async request(params) {
140
+ return useFinbricksFetch({
141
+ baseUrl: this.BASE_URL,
142
+ merchantId: this.MERCHANT_ID,
143
+ privateKeyPem: this.PRIVATE_KEY_PEM,
144
+ ...params
145
+ });
146
+ }
147
+ }
148
+
149
+ const FINBRICKS_ENDPOINTS = {
150
+ AUTHENTICATE_V2: "/v2/auth/authenticate",
151
+ AUTH_TOKEN_STATUS: "/auth/token",
152
+ AUTH_TOKEN_REVOKE: "/auth/revoke",
153
+ ACCOUNT_LIST: "/account/list",
154
+ ACCOUNT_BALANCE: "/account/balance",
155
+ ACCOUNT_TRANSACTIONS: "/account/transactions",
156
+ TRANSACTION_INIT: "/transaction/platform/init",
157
+ TRANSACTION_STATUS: "/transaction/platform/status",
158
+ TRANSACTION_SEPA_INIT: "/transaction/platform/sepa/init",
159
+ TRANSACTION_FOREIGN_INIT: "/transaction/platform/foreign/init",
160
+ TRANSACTION_BATCH_INIT: "/transaction/platform/batchPayment/init",
161
+ BATCH_STATUS: "/transaction/platform/batchPayment/status",
162
+ BANK_INFO: "/status/bankInfo"
163
+ };
164
+
165
+ const TERMINAL_STATUSES$1 = /* @__PURE__ */ new Set([
166
+ "SETTLED",
167
+ "REJECTED",
168
+ "CLOSED"
169
+ ]);
170
+ const PENDING_STATUSES = /* @__PURE__ */ new Set([
171
+ "OPENED",
172
+ "AUTHORIZED"
173
+ ]);
174
+ function isTerminalStatus(status) {
175
+ return TERMINAL_STATUSES$1.has(status);
176
+ }
177
+ function isPendingStatus(status) {
178
+ return PENDING_STATUSES.has(status);
179
+ }
180
+ function isProcessedStatus(status) {
181
+ return !isPendingStatus(status);
182
+ }
183
+ function hasPaymentAccountAssigned(payment) {
184
+ return "accountId" in payment && "connectorKey" in payment && payment.accountId !== void 0 && payment.connectorKey !== void 0;
185
+ }
186
+ function isPaymentCompleted(payment) {
187
+ return (payment.status === "COMPLETED" || payment.status === "BOOKED" || payment.status === "SETTLED" || payment.status === "REJECTED" || payment.status === "CLOSED") && "bankRefId" in payment && typeof payment.bankRefId === "string";
188
+ }
11
189
 
12
190
  function toIncomingPayment(input) {
13
191
  return {
@@ -239,139 +417,6 @@ class IBankConnector {
239
417
  }
240
418
  }
241
419
 
242
- async function signFinbricksJws({
243
- privateKeyPem,
244
- merchantId,
245
- jwsData
246
- }) {
247
- const privateKey = await importPKCS8(privateKeyPem, "RS256");
248
- const payload = JSON.stringify(jwsData);
249
- const jws = await new SignJWT(JSON.parse(payload)).setProtectedHeader({
250
- alg: "RS256",
251
- kid: merchantId,
252
- typ: "JWT"
253
- }).sign(privateKey);
254
- const [header, , signature] = jws.split(".");
255
- return `${header}..${signature}`;
256
- }
257
-
258
- const useFinbricksFetch = async (config, init) => {
259
- const {
260
- baseUrl,
261
- endpoint,
262
- method = "GET",
263
- merchantId,
264
- privateKeyPem,
265
- query,
266
- body,
267
- correlationId,
268
- psuIp = "88.205.47.1",
269
- psuAgent = "Develit/BankService"
270
- } = config;
271
- const url = new URL(`${baseUrl}${endpoint}`);
272
- if (query) {
273
- for (const [k, v] of Object.entries(query)) {
274
- if (v !== void 0 && v !== null)
275
- url.searchParams.append(k, v.toString());
276
- }
277
- }
278
- const uriWithQuery = `${endpoint}${url.search ? `?${url.searchParams.toString()}` : ""}`;
279
- const bodyString = body ? JSON.stringify(body) : "";
280
- const jwsSignature = await signFinbricksJws({
281
- privateKeyPem,
282
- merchantId,
283
- jwsData: {
284
- uri: uriWithQuery,
285
- body: bodyString
286
- }
287
- });
288
- const headers = {
289
- "Content-Type": "application/json",
290
- "JWS-Signature": jwsSignature,
291
- "PSU-IP-Address": psuIp,
292
- "PSU-User-Agent": psuAgent,
293
- ...init?.headers
294
- };
295
- if (correlationId) {
296
- headers["Correlation-ID"] = correlationId;
297
- }
298
- console.log(
299
- "[Finbricks] request",
300
- JSON.stringify(
301
- {
302
- method,
303
- url: url.toString(),
304
- body: body ?? null
305
- },
306
- null,
307
- 2
308
- )
309
- );
310
- const res = await fetch(url.toString(), {
311
- method,
312
- headers,
313
- body: method !== "GET" ? bodyString : void 0
314
- });
315
- if (!res.ok) {
316
- const text = await res.text().catch(() => "unknown error");
317
- console.error("[Finbricks] error response", {
318
- status: res.status,
319
- statusText: res.statusText,
320
- url: url.toString(),
321
- body: text
322
- });
323
- throw new Error(
324
- `Finbricks API error: ${res.status} ${res.statusText} \u2013 ${text}`
325
- );
326
- }
327
- const json = await res.json();
328
- console.log(
329
- "[Finbricks] response",
330
- JSON.stringify(
331
- {
332
- status: res.status,
333
- url: url.toString(),
334
- body: json
335
- },
336
- null,
337
- 2
338
- )
339
- );
340
- return json;
341
- };
342
- class FinbricksClient {
343
- constructor(baseUrl, merchantId, privateKeyPem, redirectUri) {
344
- this.BASE_URL = baseUrl;
345
- this.MERCHANT_ID = merchantId;
346
- this.PRIVATE_KEY_PEM = privateKeyPem;
347
- this.REDIRECT_URI = redirectUri;
348
- }
349
- async request(params) {
350
- return useFinbricksFetch({
351
- baseUrl: this.BASE_URL,
352
- merchantId: this.MERCHANT_ID,
353
- privateKeyPem: this.PRIVATE_KEY_PEM,
354
- ...params
355
- });
356
- }
357
- }
358
-
359
- const FINBRICKS_ENDPOINTS = {
360
- AUTHENTICATE_V2: "/v2/auth/authenticate",
361
- AUTH_TOKEN_STATUS: "/auth/token",
362
- AUTH_TOKEN_REVOKE: "/auth/revoke",
363
- ACCOUNT_LIST: "/account/list",
364
- ACCOUNT_BALANCE: "/account/balance",
365
- ACCOUNT_TRANSACTIONS: "/account/transactions",
366
- TRANSACTION_INIT: "/transaction/platform/init",
367
- TRANSACTION_STATUS: "/transaction/platform/status",
368
- TRANSACTION_SEPA_INIT: "/transaction/platform/sepa/init",
369
- TRANSACTION_FOREIGN_INIT: "/transaction/platform/foreign/init",
370
- TRANSACTION_BATCH_INIT: "/transaction/platform/batchPayment/init",
371
- BATCH_STATUS: "/transaction/platform/batchPayment/status",
372
- BANK_INFO: "/status/bankInfo"
373
- };
374
-
375
420
  const mapFinbricksStatus = (status, hasBookingDate) => {
376
421
  switch (status) {
377
422
  case "BOOK":
@@ -916,7 +961,10 @@ class FinbricksConnector extends IBankConnector {
916
961
  },
917
962
  paymentIdentification: {
918
963
  merchantTransactionId: bankRefId,
919
- endToEndIdentification: this.buildEndToEndId(payment)
964
+ endToEndIdentification: this.buildEndToEndId({
965
+ ...payment,
966
+ id: payment.id
967
+ })
920
968
  },
921
969
  amount: payment.amount,
922
970
  debtor: {
@@ -1098,40 +1146,6 @@ class CsobConnector extends FinbricksConnector {
1098
1146
  }
1099
1147
  }
1100
1148
 
1101
- const PAYMENT_TYPES = ["SEPA", "SWIFT", "DOMESTIC", "UNKNOWN"];
1102
- const CHARGE_BEARERS = ["SHA", "OUR", "BEN"];
1103
- const INSTRUCTION_PRIORITIES = ["NORM", "HIGH", "INST"];
1104
- const PAYMENT_REQUEST_STATUSES = [
1105
- "OPENED",
1106
- "AUTHORIZED",
1107
- "COMPLETED",
1108
- "BOOKED",
1109
- "SETTLED",
1110
- "REJECTED",
1111
- "CLOSED"
1112
- ];
1113
- const PAYMENT_STATUSES = [
1114
- "PENDING",
1115
- "PROCESSING",
1116
- "BOOKED",
1117
- "CANCELLED",
1118
- "REJECTED",
1119
- "SCHEDULED",
1120
- "HOLD",
1121
- "INFO"
1122
- ];
1123
- const PAYMENT_DIRECTIONS = ["INCOMING", "OUTGOING"];
1124
- const BATCH_STATUSES = [
1125
- "PROCESSING",
1126
- "READY_TO_SIGN",
1127
- "AUTHORIZED",
1128
- "COMPLETED",
1129
- "FAILED"
1130
- ];
1131
- const BATCH_MODES = ["NATIVE", "SINGLE"];
1132
- const ACCOUNT_STATUSES = ["AUTHORIZED", "DISABLED", "EXPIRED"];
1133
- const COUNTRY_CODES = COUNTRY_CODES_2;
1134
-
1135
1149
  class AirBankConnector extends FinbricksConnector {
1136
1150
  constructor(config) {
1137
1151
  super("AIRBANK", config);
@@ -1966,31 +1980,6 @@ class DbuConnector extends IBankConnector {
1966
1980
  }
1967
1981
  }
1968
1982
 
1969
- const TERMINAL_STATUSES$1 = /* @__PURE__ */ new Set([
1970
- "SETTLED",
1971
- "REJECTED",
1972
- "CLOSED"
1973
- ]);
1974
- const PENDING_STATUSES = /* @__PURE__ */ new Set([
1975
- "OPENED",
1976
- "AUTHORIZED"
1977
- ]);
1978
- function isTerminalStatus(status) {
1979
- return TERMINAL_STATUSES$1.has(status);
1980
- }
1981
- function isPendingStatus(status) {
1982
- return PENDING_STATUSES.has(status);
1983
- }
1984
- function isProcessedStatus(status) {
1985
- return !isPendingStatus(status);
1986
- }
1987
- function hasPaymentAccountAssigned(payment) {
1988
- return "accountId" in payment && "connectorKey" in payment && payment.accountId !== void 0 && payment.connectorKey !== void 0;
1989
- }
1990
- function isPaymentCompleted(payment) {
1991
- return (payment.status === "COMPLETED" || payment.status === "BOOKED" || payment.status === "SETTLED" || payment.status === "REJECTED" || payment.status === "CLOSED") && "bankRefId" in payment && typeof payment.bankRefId === "string";
1992
- }
1993
-
1994
1983
  const TERMINAL_STATUSES = PAYMENT_REQUEST_STATUSES.filter(isTerminalStatus);
1995
1984
  const getNonTerminalPaymentRequestsQuery = (db) => db.select().from(tables.paymentRequest).where(
1996
1985
  and(
@@ -2108,7 +2097,10 @@ class ErsteConnector extends IBankConnector {
2108
2097
  }
2109
2098
  const paymentBody = {
2110
2099
  paymentIdentification: {
2111
- endToEndIdentification: this.buildEndToEndId(payment),
2100
+ endToEndIdentification: this.buildEndToEndId({
2101
+ ...payment,
2102
+ id: payment.id
2103
+ }),
2112
2104
  instructionIdentification: payment.id
2113
2105
  },
2114
2106
  paymentTypeInformation: { instructionPriority: "NORM" },
@@ -2413,57 +2405,6 @@ class MockConnector extends IBankConnector {
2413
2405
  }
2414
2406
  }
2415
2407
 
2416
- const CONNECTOR_KEYS = [
2417
- "ERSTE",
2418
- "FINBRICKS",
2419
- "MOCK",
2420
- "CREDITAS",
2421
- "MOCK_COBS",
2422
- "FIO",
2423
- "MONETA",
2424
- "DBU",
2425
- "CSAS",
2426
- "AIRBANK",
2427
- "KB",
2428
- "CSOB"
2429
- ];
2430
- const CREDENTIALS_TYPES = [
2431
- "AUTH_TOKEN",
2432
- "REFRESH_TOKEN",
2433
- "CLIENT_ID",
2434
- "API_KEY"
2435
- ];
2436
- const TOKEN_TYPES = ["ACCOUNT_AUTHORIZATION"];
2437
-
2438
- const account = sqliteTable(
2439
- "account",
2440
- {
2441
- ...base,
2442
- ...bankAccount,
2443
- // countryCode is temporary until bankAccount is update to include US country code
2444
- countryCode: text("country_code", { enum: COUNTRY_CODES }).$type().notNull(),
2445
- number: text("number").notNull(),
2446
- name: text("name"),
2447
- iban: text("iban").notNull(),
2448
- bankCode: text("bank_code", { enum: BANK_CODES }).notNull(),
2449
- connectorKey: text("connector_key", {
2450
- enum: CONNECTOR_KEYS
2451
- }).$type().notNull(),
2452
- status: text("status", { enum: ACCOUNT_STATUSES }).$type().notNull(),
2453
- bankRefId: text("bank_ref_id").notNull(),
2454
- batchSizeLimit: integer("batch_size_limit").notNull().default(50),
2455
- syncIntervalS: integer("sync_interval_s").notNull().default(600),
2456
- lastSyncAt: integer("last_sync_at", { mode: "timestamp_ms" }),
2457
- lastSyncMetadata: text("last_sync_metadata", {
2458
- mode: "json"
2459
- }).$type(),
2460
- connectorConfig: text("connector_config", {
2461
- mode: "json"
2462
- }).$type()
2463
- },
2464
- (t) => [unique().on(t.iban)]
2465
- );
2466
-
2467
2408
  const accountInsertSchema = createInsertSchema(account, {
2468
2409
  address: () => structuredAddressSchema.optional()
2469
2410
  });
@@ -2474,193 +2415,12 @@ const accountSelectSchema = createSelectSchema(account, {
2474
2415
  address: () => structuredAddressSchema.nullable()
2475
2416
  });
2476
2417
 
2477
- const accountCredentials = sqliteTable("account_credentials", {
2478
- ...base,
2479
- accountId: text("account_id").references(() => account.id, { onDelete: "restrict", onUpdate: "cascade" }).notNull(),
2480
- connectorKey: text("connector_key", {
2481
- enum: CONNECTOR_KEYS
2482
- }).$type().notNull(),
2483
- type: text("type", {
2484
- enum: CREDENTIALS_TYPES
2485
- }).$type().notNull(),
2486
- value: text("value").notNull(),
2487
- expiresAt: integer("expires_at", { mode: "timestamp_ms" }).notNull()
2488
- });
2489
-
2490
2418
  const accountCredentialsInsertSchema = createInsertSchema(accountCredentials);
2491
2419
  const accountCredentialsUpdateSchema = createUpdateSchema(accountCredentials);
2492
2420
  const accountCredentialsSelectSchema = createSelectSchema(accountCredentials);
2493
2421
 
2494
- const ott = sqliteTable("ott", {
2495
- ...base,
2496
- oneTimeToken: text("one_time_token").notNull(),
2497
- refId: text("ref_id").notNull(),
2498
- tokenType: text("token_type", { enum: TOKEN_TYPES }).$type().notNull(),
2499
- expiresAt: integer("expires_at", { mode: "timestamp_ms" }).notNull()
2500
- });
2501
-
2502
2422
  const ottInsertSchema = createInsertSchema(ott);
2503
2423
  const ottUpdateSchema = createUpdateSchema(ott);
2504
2424
  const ottSelectSchema = createSelectSchema(ott);
2505
2425
 
2506
- const batch = sqliteTable("batch", {
2507
- ...base,
2508
- batchPaymentInitiatedAt: integer("batch_payment_initiated_at", {
2509
- mode: "timestamp_ms"
2510
- }),
2511
- authorizationUrls: text("authorization_urls", { mode: "json" }).$type(),
2512
- accountId: text("account_id").references(() => account.id, {
2513
- onDelete: "restrict",
2514
- onUpdate: "cascade"
2515
- }),
2516
- status: text("status", { enum: BATCH_STATUSES }).$type(),
2517
- statusReason: text("status_reason"),
2518
- statusResponse: text("status_response", { mode: "json" }).$type(),
2519
- metadata: text("metadata", { mode: "json" }).$type(),
2520
- paymentType: text("payment_type", {
2521
- enum: PAYMENT_TYPES
2522
- }).$type(),
2523
- paymentsChecksum: text("payments_checksum"),
2524
- batchMode: text("batch_mode", { enum: BATCH_MODES }).$type()
2525
- });
2526
-
2527
- const payment = sqliteTable(
2528
- "payment",
2529
- {
2530
- ...base,
2531
- correlationId: text("correlation_id").notNull(),
2532
- refId: text("ref_id"),
2533
- bankRefId: text("bank_ref_id").notNull(),
2534
- accountId: text("account_id").references(() => account.id, {
2535
- onDelete: "restrict",
2536
- onUpdate: "cascade"
2537
- }).notNull(),
2538
- connectorKey: text("connector_key", { enum: CONNECTOR_KEYS }).$type().notNull(),
2539
- amount: real("amount").notNull(),
2540
- direction: text("direction").$type().notNull(),
2541
- paymentType: text("payment_type").$type().notNull(),
2542
- currency: text("currency").$type().notNull(),
2543
- status: text("status", { enum: PAYMENT_STATUSES }).$type().notNull(),
2544
- statusReason: text("status_reason"),
2545
- batchId: text("bank_execution_batch_id"),
2546
- initiatedAt: integer("initiated_at", {
2547
- mode: "timestamp_ms"
2548
- }),
2549
- vs: text("vs"),
2550
- ss: text("ss"),
2551
- ks: text("ks"),
2552
- message: text("message"),
2553
- chargeBearer: text("charge_bearer", {
2554
- enum: CHARGE_BEARERS
2555
- }).$type(),
2556
- instructionPriority: text("instruction_priority", {
2557
- enum: INSTRUCTION_PRIORITIES
2558
- }).$type(),
2559
- processedAt: integer("processed_at", {
2560
- mode: "timestamp_ms"
2561
- }),
2562
- creditor: text("creditor", { mode: "json" }).$type().notNull(),
2563
- creditorIban: text("creditor_iban"),
2564
- debtor: text("debtor", { mode: "json" }).$type().notNull(),
2565
- debtorIban: text("debtor_iban")
2566
- },
2567
- (t) => [
2568
- unique().on(t.connectorKey, t.accountId, t.bankRefId),
2569
- index("payment_account_id_idx").on(t.accountId),
2570
- index("payment_account_id_status_idx").on(t.accountId, t.status),
2571
- index("payment_account_id_created_at_idx").on(t.accountId, t.createdAt),
2572
- index("payment_created_at_idx").on(t.createdAt),
2573
- index("payment_direction_idx").on(t.direction),
2574
- index("payment_batch_id_idx").on(t.batchId),
2575
- index("payment_creditor_iban_idx").on(t.creditorIban),
2576
- index("payment_debtor_iban_idx").on(t.debtorIban)
2577
- ]
2578
- );
2579
- const paymentRelations = relations(payment, ({ one }) => ({
2580
- batch: one(batch, { fields: [payment.batchId], references: [batch.id] })
2581
- }));
2582
-
2583
- const paymentRequest = sqliteTable(
2584
- "payment_request",
2585
- {
2586
- ...base,
2587
- batchId: text("batch_id").references(() => batch.id, {
2588
- onDelete: "restrict",
2589
- onUpdate: "cascade"
2590
- }),
2591
- accountId: text("account_id").references(() => account.id, {
2592
- onDelete: "restrict",
2593
- onUpdate: "cascade"
2594
- }).notNull(),
2595
- correlationId: text("correlation_id").notNull(),
2596
- refId: text("ref_id"),
2597
- bankRefId: text("bank_ref_id"),
2598
- connectorKey: text("connector_key", { enum: CONNECTOR_KEYS }).$type().notNull(),
2599
- amount: real("amount").notNull(),
2600
- paymentType: text("payment_type", { enum: PAYMENT_TYPES }).$type().notNull(),
2601
- currency: text("currency").$type().notNull(),
2602
- status: text("status", { enum: PAYMENT_REQUEST_STATUSES }).$type().notNull(),
2603
- statusReason: text("status_reason"),
2604
- authorizationUrl: text("authorization_url"),
2605
- initiatedAt: integer("initiated_at", { mode: "timestamp_ms" }),
2606
- processedAt: integer("processed_at", { mode: "timestamp_ms" }),
2607
- vs: text("vs"),
2608
- ss: text("ss"),
2609
- ks: text("ks"),
2610
- message: text("message"),
2611
- chargeBearer: text("charge_bearer", {
2612
- enum: CHARGE_BEARERS
2613
- }).$type(),
2614
- instructionPriority: text("instruction_priority", {
2615
- enum: INSTRUCTION_PRIORITIES
2616
- }).$type(),
2617
- creditor: text("creditor", { mode: "json" }).$type().notNull(),
2618
- creditorIban: text("creditor_iban"),
2619
- debtor: text("debtor", { mode: "json" }).$type().notNull(),
2620
- debtorIban: text("debtor_iban"),
2621
- sendAsSinglePayment: integer("send_as_single_payment", {
2622
- mode: "boolean"
2623
- })
2624
- },
2625
- (t) => [
2626
- index("payment_request_batch_id_idx").on(t.batchId),
2627
- index("payment_request_account_id_idx").on(t.accountId),
2628
- index("payment_request_creditor_iban_idx").on(t.creditorIban),
2629
- index("payment_request_debtor_iban_idx").on(t.debtorIban),
2630
- index("payment_request_status_idx").on(t.status),
2631
- index("payment_request_created_at_idx").on(t.createdAt),
2632
- index("payment_request_account_status_idx").on(t.accountId, t.status),
2633
- index("payment_request_status_created_at_idx").on(t.status, t.createdAt),
2634
- index("payment_request_account_status_created_at_idx").on(
2635
- t.accountId,
2636
- t.status,
2637
- t.createdAt
2638
- )
2639
- ]
2640
- );
2641
- const paymentRequestRelations = relations(paymentRequest, ({ one }) => ({
2642
- batch: one(batch, {
2643
- fields: [paymentRequest.batchId],
2644
- references: [batch.id]
2645
- }),
2646
- account: one(account, {
2647
- fields: [paymentRequest.accountId],
2648
- references: [account.id]
2649
- })
2650
- }));
2651
-
2652
- const schema = {
2653
- __proto__: null,
2654
- account: account,
2655
- accountCredentials: accountCredentials,
2656
- batch: batch,
2657
- ott: ott,
2658
- payment: payment,
2659
- paymentRelations: paymentRelations,
2660
- paymentRequest: paymentRequest,
2661
- paymentRequestRelations: paymentRequestRelations
2662
- };
2663
-
2664
- const tables = schema;
2665
-
2666
- export { ott as $, ACCOUNT_STATUSES as A, BATCH_MODES as B, CHARGE_BEARERS as C, DbuConnector as D, ErsteConnector as E, FINBRICKS_ENDPOINTS as F, ottSelectSchema as G, ottUpdateSchema as H, IBankConnector as I, signFinbricksJws as J, KBConnector as K, toBatchedPayment as L, MockCobsConnector as M, toBatchedPaymentFromPaymentRequest as N, toCompletedPayment as O, PAYMENT_DIRECTIONS as P, toIncomingPayment as Q, toPaymentRequestInsert as R, toPreparedPayment as S, TOKEN_TYPES as T, useFinbricksFetch as U, tables as V, initiateConnector as W, getNonTerminalPaymentRequestsQuery as X, account as Y, accountCredentials as Z, batch as _, BATCH_STATUSES as a, payment as a0, paymentRelations as a1, paymentRequest as a2, paymentRequestRelations as a3, CONNECTOR_KEYS as b, COUNTRY_CODES as c, CREDENTIALS_TYPES as d, CsobConnector as e, FinbricksClient as f, FinbricksConnector as g, INSTRUCTION_PRIORITIES as h, MockConnector as i, PAYMENT_REQUEST_STATUSES as j, PAYMENT_STATUSES as k, PAYMENT_TYPES as l, accountCredentialsInsertSchema as m, accountCredentialsSelectSchema as n, accountCredentialsUpdateSchema as o, accountInsertSchema as p, accountSelectSchema as q, accountUpdateSchema as r, assignAccount as s, dbuAccountConfigSchema as t, hasPaymentAccountAssigned as u, isPaymentCompleted as v, isPendingStatus as w, isProcessedStatus as x, isTerminalStatus as y, ottInsertSchema as z };
2426
+ export { useFinbricksFetch as A, tables as B, CsobConnector as C, DbuConnector as D, ErsteConnector as E, FINBRICKS_ENDPOINTS as F, relations as G, initiateConnector as H, IBankConnector as I, getNonTerminalPaymentRequestsQuery as J, KBConnector as K, MockCobsConnector as M, FinbricksClient as a, FinbricksConnector as b, MockConnector as c, accountCredentialsInsertSchema as d, accountCredentialsSelectSchema as e, accountCredentialsUpdateSchema as f, accountInsertSchema as g, accountSelectSchema as h, accountUpdateSchema as i, assignAccount as j, dbuAccountConfigSchema as k, hasPaymentAccountAssigned as l, isPaymentCompleted as m, isPendingStatus as n, isProcessedStatus as o, isTerminalStatus as p, ottInsertSchema as q, ottSelectSchema as r, ottUpdateSchema as s, signFinbricksJws as t, toBatchedPayment as u, toBatchedPaymentFromPaymentRequest as v, toCompletedPayment as w, toIncomingPayment as x, toPaymentRequestInsert as y, toPreparedPayment as z };