@develit-services/bank 0.3.43 → 0.3.45

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 (37) hide show
  1. package/dist/database/schema.cjs +4 -4
  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 +4 -4
  6. package/dist/export/worker.cjs +166 -183
  7. package/dist/export/worker.d.cts +43 -22
  8. package/dist/export/worker.d.mts +43 -22
  9. package/dist/export/worker.d.ts +43 -22
  10. package/dist/export/worker.mjs +126 -143
  11. package/dist/export/workflows.cjs +214 -18
  12. package/dist/export/workflows.mjs +207 -12
  13. package/dist/export/wrangler.d.cts +1 -2
  14. package/dist/export/wrangler.d.mts +1 -2
  15. package/dist/export/wrangler.d.ts +1 -2
  16. package/dist/shared/{bank.YiArmBW2.mjs → bank.B1Gpn3ht.mjs} +12 -174
  17. package/dist/shared/{bank.xrXNjWCo.d.cts → bank.BEL1HIxZ.d.cts} +21 -1
  18. package/dist/shared/{bank.xrXNjWCo.d.mts → bank.BEL1HIxZ.d.mts} +21 -1
  19. package/dist/shared/{bank.xrXNjWCo.d.ts → bank.BEL1HIxZ.d.ts} +21 -1
  20. package/dist/shared/bank.BUEmFxS8.mjs +174 -0
  21. package/dist/shared/{bank.CLF9wee9.cjs → bank.CPYfE-Ei.cjs} +12 -199
  22. package/dist/shared/bank.CpwLFudl.cjs +198 -0
  23. package/dist/shared/bank.D-3fzX63.mjs +170 -0
  24. package/dist/shared/bank.D0a-MZon.cjs +184 -0
  25. package/dist/shared/{bank.BchnXQDL.d.cts → bank.Dh_H_5rC.d.cts} +0 -1
  26. package/dist/shared/{bank.BchnXQDL.d.mts → bank.Dh_H_5rC.d.mts} +0 -1
  27. package/dist/shared/{bank.BchnXQDL.d.ts → bank.Dh_H_5rC.d.ts} +0 -1
  28. package/dist/types.cjs +14 -14
  29. package/dist/types.d.cts +9 -9
  30. package/dist/types.d.mts +9 -9
  31. package/dist/types.d.ts +9 -9
  32. package/dist/types.mjs +5 -5
  33. package/package.json +1 -1
  34. package/dist/shared/bank.CNtiZSem.mjs +0 -9
  35. package/dist/shared/bank.CUU0Daxj.mjs +0 -391
  36. package/dist/shared/bank.ChffLgyT.cjs +0 -401
  37. package/dist/shared/bank.DfE0M5H3.cjs +0 -11
@@ -1,19 +1,18 @@
1
1
  import { WorkflowEntrypoint } from 'cloudflare:workers';
2
2
  import { NonRetryableError } from 'cloudflare:workflows';
3
3
  import { drizzle } from 'drizzle-orm/d1';
4
- import { t as tables } from '../shared/bank.YiArmBW2.mjs';
5
- import { asNonEmpty } from '@develit-io/backend-sdk';
6
- import { g as getAccountByIdQuery, i as importAesKey, a as getCredentialsByAccountId, b as initiateConnector, c as createPaymentCommand } from '../shared/bank.CUU0Daxj.mjs';
7
- export { B as BankProcessBatch } from '../shared/bank.CUU0Daxj.mjs';
4
+ import { t as tables } from '../shared/bank.B1Gpn3ht.mjs';
5
+ import { asNonEmpty, first } from '@develit-io/backend-sdk';
6
+ import { g as getAccountByIdQuery, i as importAesKey, a as getCredentialsByAccountId, b as initiateConnector, c as createPaymentCommand, d as getBatchByIdQuery, e as checksum, u as upsertBatchCommand } from '../shared/bank.BUEmFxS8.mjs';
8
7
  import { eq } from 'drizzle-orm';
9
- import 'drizzle-orm/sqlite-core';
10
8
  import 'date-fns';
11
- import 'jose';
12
- import '@develit-io/general-codes';
13
- import 'drizzle-zod';
9
+ import '../shared/bank.D-3fzX63.mjs';
10
+ import 'drizzle-orm/sqlite-core';
14
11
  import 'drizzle-orm/relations';
12
+ import '@develit-io/general-codes';
13
+ import 'jose';
15
14
  import 'node:crypto';
16
- import '../shared/bank.CNtiZSem.mjs';
15
+ import 'drizzle-zod';
17
16
 
18
17
  const updateAccountLastSyncCommand = (db, {
19
18
  lastSyncAt,
@@ -29,7 +28,7 @@ const updateAccountLastSyncCommand = (db, {
29
28
  };
30
29
  };
31
30
 
32
- function pushToQueue(queue, message) {
31
+ function pushToQueue$1(queue, message) {
33
32
  if (!Array.isArray(message)) return queue.send(message, { contentType: "v8" });
34
33
  return queue.sendBatch(
35
34
  message.map((m) => ({
@@ -143,7 +142,7 @@ class BankSyncAccountPayments extends WorkflowEntrypoint {
143
142
  await db.batch(
144
143
  asNonEmpty([updateLastSyncCommand, ...createCommands])
145
144
  );
146
- await pushToQueue(
145
+ await pushToQueue$1(
147
146
  this.env.QUEUE_BUS_QUEUE,
148
147
  eventsToEmit
149
148
  );
@@ -163,4 +162,200 @@ class BankSyncAccountPayments extends WorkflowEntrypoint {
163
162
  }
164
163
  }
165
164
 
166
- export { BankSyncAccountPayments };
165
+ function pushToQueue(queue, message) {
166
+ if (!Array.isArray(message)) return queue.send(message, { contentType: "v8" });
167
+ return queue.sendBatch(
168
+ message.map((m) => ({
169
+ body: m,
170
+ contentType: "v8"
171
+ }))
172
+ );
173
+ }
174
+ class BankProcessBatch extends WorkflowEntrypoint {
175
+ async run(event, step) {
176
+ const { batchId } = event.payload;
177
+ const db = drizzle(this.env.BANK_D1, { schema: tables });
178
+ const batch = await step.do("load batch", async () => {
179
+ const batch2 = await getBatchByIdQuery(db, { batchId });
180
+ if (!batch2) {
181
+ throw new NonRetryableError(`Batch not found`);
182
+ }
183
+ if (batch2.status === "SIGNED")
184
+ throw new NonRetryableError(`Batch already signed`);
185
+ return batch2;
186
+ });
187
+ await step.do("lock batch", async () => {
188
+ const paymentsChecksum = checksum(batch.payments);
189
+ if (batch.paymentsChecksum && batch.paymentsChecksum !== paymentsChecksum)
190
+ throw new NonRetryableError(
191
+ `Batch payments have been modified externally, manual review needed`
192
+ );
193
+ if (batch.status === "FAILED")
194
+ throw new NonRetryableError(
195
+ `Batch is in FAILED status and cannot be processed, manual review needed`
196
+ );
197
+ if (batch.status === "OPEN" || batch.status === "FULL") {
198
+ const updatedBatch = await upsertBatchCommand(db, {
199
+ batch: {
200
+ ...batch,
201
+ status: "PROCESSING",
202
+ paymentsChecksum
203
+ }
204
+ }).command.execute().then(first);
205
+ return { status: updatedBatch.status };
206
+ }
207
+ return { status: batch.status };
208
+ });
209
+ const preparedPayments = await step.do(
210
+ "prepare payments",
211
+ {
212
+ retries: { limit: 5, delay: 2e3, backoff: "constant" },
213
+ timeout: "30 seconds"
214
+ },
215
+ async () => {
216
+ const account = await getAccountByIdQuery(db, {
217
+ accountId: batch.accountId
218
+ });
219
+ if (!account) {
220
+ throw new NonRetryableError(`Account not found: ${batch.accountId}`);
221
+ }
222
+ const encryptionKey = await importAesKey(this.env.ENCRYPTION_KEY);
223
+ const credentials = await getCredentialsByAccountId(db, encryptionKey, {
224
+ accountId: account.id
225
+ });
226
+ if (!credentials) {
227
+ throw new NonRetryableError(
228
+ `No credentials found for account: ${account.id}`
229
+ );
230
+ }
231
+ if (credentials.expiresAt < /* @__PURE__ */ new Date()) {
232
+ throw new NonRetryableError(
233
+ `Credentials have expired for account: ${account.id}`
234
+ );
235
+ }
236
+ const connector = initiateConnector({
237
+ env: this.env,
238
+ bank: account.connectorKey,
239
+ connectedAccounts: [
240
+ {
241
+ ...account,
242
+ iban: account.iban,
243
+ token: credentials.value
244
+ }
245
+ ]
246
+ });
247
+ const preparedPayments2 = [];
248
+ for (const payment of batch.payments) {
249
+ const prepared = await connector.preparePayment(payment);
250
+ if (prepared) {
251
+ preparedPayments2.push(prepared);
252
+ }
253
+ }
254
+ return preparedPayments2;
255
+ }
256
+ );
257
+ const batchResult = await step.do(
258
+ "initiate batch from payments",
259
+ {
260
+ retries: { limit: 5, delay: 2e3, backoff: "constant" },
261
+ timeout: "30 seconds"
262
+ },
263
+ async () => {
264
+ if (batch.batchPaymentInitiatedAt) {
265
+ return {
266
+ authorizationUrls: batch.authorizationUrls,
267
+ initializedPayments: preparedPayments.map((p) => ({
268
+ ...p,
269
+ status: "INITIALIZED"
270
+ })),
271
+ metadata: batch.metadata
272
+ };
273
+ }
274
+ const account = await getAccountByIdQuery(db, {
275
+ accountId: batch.accountId
276
+ });
277
+ if (!account) {
278
+ throw new NonRetryableError(`Account not found: ${batch.accountId}`);
279
+ }
280
+ const encryptionKey = await importAesKey(this.env.ENCRYPTION_KEY);
281
+ const credentials = await getCredentialsByAccountId(db, encryptionKey, {
282
+ accountId: account.id
283
+ });
284
+ if (!credentials) {
285
+ throw new NonRetryableError(
286
+ `No credentials found for account: ${account.id}`
287
+ );
288
+ }
289
+ if (credentials.expiresAt < /* @__PURE__ */ new Date()) {
290
+ throw new NonRetryableError(
291
+ `Credentials have expired for account: ${account.id}`
292
+ );
293
+ }
294
+ const connector = initiateConnector({
295
+ env: this.env,
296
+ bank: account.connectorKey,
297
+ connectedAccounts: [
298
+ {
299
+ ...account,
300
+ iban: account.iban,
301
+ token: credentials.value
302
+ }
303
+ ]
304
+ });
305
+ const result = await connector.initiateBatchFromPayments({
306
+ batchId: batch.id,
307
+ payments: preparedPayments
308
+ });
309
+ const {
310
+ authorizationUrls,
311
+ payments: initializedPayments,
312
+ metadata
313
+ } = result;
314
+ if (!authorizationUrls || authorizationUrls.length === 0) {
315
+ throw new Error("Failed to retrieve authorization URLs");
316
+ }
317
+ return {
318
+ authorizationUrls,
319
+ initializedPayments,
320
+ metadata
321
+ };
322
+ }
323
+ );
324
+ await step.do("update batch and payments to initialized", async () => {
325
+ const upsertBatch = upsertBatchCommand(db, {
326
+ batch: {
327
+ ...batch,
328
+ authorizationUrls: batchResult.authorizationUrls,
329
+ metadata: batchResult.metadata,
330
+ status: "READY_TO_SIGN",
331
+ batchPaymentInitiatedAt: /* @__PURE__ */ new Date()
332
+ }
333
+ }).command;
334
+ await upsertBatch.execute();
335
+ return {
336
+ status: "READY_TO_SIGN",
337
+ paymentsInitialized: batchResult.initializedPayments.length
338
+ };
339
+ });
340
+ await step.do("enqueue authorization email", async () => {
341
+ await pushToQueue(this.env.NOTIFICATIONS_QUEUE, {
342
+ type: "email",
343
+ payload: {
344
+ email: {
345
+ to: [this.env.BANK_AUTH_RECIPIENT],
346
+ subject: "Payment Authorization",
347
+ text: Array.isArray(batchResult.authorizationUrls) ? batchResult.authorizationUrls[0] || "No Authorization URL" : batchResult.authorizationUrls || "No Authorization URL"
348
+ }
349
+ },
350
+ metadata: {
351
+ initiator: {
352
+ service: "bank"
353
+ }
354
+ }
355
+ });
356
+ return { emailSent: true };
357
+ });
358
+ }
359
+ }
360
+
361
+ export { BankProcessBatch, BankSyncAccountPayments };
@@ -1,4 +1,4 @@
1
- import { B as BankServiceWranglerConfig } from '../shared/bank.BchnXQDL.cjs';
1
+ import { B as BankServiceWranglerConfig } from '../shared/bank.Dh_H_5rC.cjs';
2
2
 
3
3
  declare function defineBankServiceWrangler(config: BankServiceWranglerConfig): {
4
4
  vars: {
@@ -6,7 +6,6 @@ declare function defineBankServiceWrangler(config: BankServiceWranglerConfig): {
6
6
  ERSTE_AUTH_URI: "https://webapi.developers.erstegroup.com/api/csas/sandbox/v1/sandbox-idp";
7
7
  ERSTE_PAYMENTS_URI: "https://webapi.developers.erstegroup.com/api/csas/public/sandbox/v1/payments";
8
8
  ERSTE_ACCOUNTS_URI: "https://webapi.developers.erstegroup.com/api/csas/public/sandbox/v3/accounts";
9
- ERSTE_FETCH_INTERVAL: 300;
10
9
  FINBRICKS_BASE_URI: "https://api.sandbox.finbricks.com";
11
10
  FINBRICKS_MERCHANT_ID: string;
12
11
  CRON_BATCH_STATUSES: string;
@@ -1,4 +1,4 @@
1
- import { B as BankServiceWranglerConfig } from '../shared/bank.BchnXQDL.mjs';
1
+ import { B as BankServiceWranglerConfig } from '../shared/bank.Dh_H_5rC.mjs';
2
2
 
3
3
  declare function defineBankServiceWrangler(config: BankServiceWranglerConfig): {
4
4
  vars: {
@@ -6,7 +6,6 @@ declare function defineBankServiceWrangler(config: BankServiceWranglerConfig): {
6
6
  ERSTE_AUTH_URI: "https://webapi.developers.erstegroup.com/api/csas/sandbox/v1/sandbox-idp";
7
7
  ERSTE_PAYMENTS_URI: "https://webapi.developers.erstegroup.com/api/csas/public/sandbox/v1/payments";
8
8
  ERSTE_ACCOUNTS_URI: "https://webapi.developers.erstegroup.com/api/csas/public/sandbox/v3/accounts";
9
- ERSTE_FETCH_INTERVAL: 300;
10
9
  FINBRICKS_BASE_URI: "https://api.sandbox.finbricks.com";
11
10
  FINBRICKS_MERCHANT_ID: string;
12
11
  CRON_BATCH_STATUSES: string;
@@ -1,4 +1,4 @@
1
- import { B as BankServiceWranglerConfig } from '../shared/bank.BchnXQDL.js';
1
+ import { B as BankServiceWranglerConfig } from '../shared/bank.Dh_H_5rC.js';
2
2
 
3
3
  declare function defineBankServiceWrangler(config: BankServiceWranglerConfig): {
4
4
  vars: {
@@ -6,7 +6,6 @@ declare function defineBankServiceWrangler(config: BankServiceWranglerConfig): {
6
6
  ERSTE_AUTH_URI: "https://webapi.developers.erstegroup.com/api/csas/sandbox/v1/sandbox-idp";
7
7
  ERSTE_PAYMENTS_URI: "https://webapi.developers.erstegroup.com/api/csas/public/sandbox/v1/payments";
8
8
  ERSTE_ACCOUNTS_URI: "https://webapi.developers.erstegroup.com/api/csas/public/sandbox/v3/accounts";
9
- ERSTE_FETCH_INTERVAL: 300;
10
9
  FINBRICKS_BASE_URI: "https://api.sandbox.finbricks.com";
11
10
  FINBRICKS_MERCHANT_ID: string;
12
11
  CRON_BATCH_STATUSES: string;
@@ -1,11 +1,9 @@
1
- import { uuidv4, useResult, createInternalError, bankAccount, base } from '@develit-io/backend-sdk';
2
- import { sqliteTable, text, integer, unique, real } from 'drizzle-orm/sqlite-core';
1
+ import { uuidv4, useResult, createInternalError } from '@develit-io/backend-sdk';
3
2
  import { format, parseISO } from 'date-fns';
3
+ import { s as schema } from './bank.D-3fzX63.mjs';
4
4
  import { and, eq } from 'drizzle-orm';
5
5
  import { importPKCS8, SignJWT } from 'jose';
6
- import { COUNTRY_CODES_2, BANK_CODES } from '@develit-io/general-codes';
7
- import { createInsertSchema, createUpdateSchema, createSelectSchema } from 'drizzle-zod';
8
- import { relations } from 'drizzle-orm/relations';
6
+ import '@develit-io/general-codes';
9
7
  import 'node:crypto';
10
8
 
11
9
  class IBankConnector {
@@ -259,9 +257,6 @@ class FinbricksConnector extends IBankConnector {
259
257
  );
260
258
  this.connectedAccounts = connectedAccounts;
261
259
  }
262
- static {
263
- this.FETCH_INTERVAL = 60 * 60 * 5;
264
- }
265
260
  async getAuthUri({ ott }) {
266
261
  const clientId = uuidv4();
267
262
  const body = {
@@ -444,9 +439,9 @@ class FinbricksConnector extends IBankConnector {
444
439
  };
445
440
  }
446
441
  async initiateBatchFromPayments({
442
+ batchId,
447
443
  payments
448
444
  }) {
449
- const batchId = uuidv4();
450
445
  const authorizedClient = this.connectedAccounts.find(
451
446
  (acc) => acc.iban === payments[0].debtorIban
452
447
  );
@@ -736,9 +731,6 @@ class ErsteConnector extends IBankConnector {
736
731
  initiateSEPAPayment(payment) {
737
732
  throw new Error("Method not implemented.");
738
733
  }
739
- static {
740
- this.FETCH_INTERVAL = 60 * 60 * 5;
741
- }
742
734
  async getAuthUri({ ott }) {
743
735
  const params = new URLSearchParams({
744
736
  redirect_uri: `${this.REDIRECT_URI}?&ott=${ott}`,
@@ -856,10 +848,10 @@ class ErsteConnector extends IBankConnector {
856
848
  };
857
849
  }
858
850
  async initiateBatchFromPayments({
851
+ batchId,
859
852
  payments
860
853
  }) {
861
854
  const allRefIds = payments.map((payment) => payment.bankRefId);
862
- const batchId = uuidv4();
863
855
  if (allRefIds.length === 0) {
864
856
  throw createInternalError(null, {
865
857
  message: "No valid payments to include in batch",
@@ -1028,9 +1020,6 @@ class MockConnector extends IBankConnector {
1028
1020
  initiateSEPAPayment(payment) {
1029
1021
  throw new Error("Method not implemented.");
1030
1022
  }
1031
- static {
1032
- this.FETCH_INTERVAL = 60 * 60 * 5;
1033
- }
1034
1023
  async authenticate() {
1035
1024
  return "";
1036
1025
  }
@@ -1074,6 +1063,7 @@ class MockConnector extends IBankConnector {
1074
1063
  };
1075
1064
  }
1076
1065
  async initiateBatchFromPayments({
1066
+ batchId,
1077
1067
  payments
1078
1068
  }) {
1079
1069
  return {
@@ -1112,164 +1102,12 @@ class MockConnector extends IBankConnector {
1112
1102
  }
1113
1103
  }
1114
1104
 
1115
- const PAYMENT_TYPES = ["SEPA", "SWIFT", "DOMESTIC", "UNKNOWN"];
1116
- const CHARGE_BEARERS = ["SHA", "OUR", "BEN"];
1117
- const INSTRUCTION_PRIORITIES = ["NORM", "HIGH", "INST"];
1118
- const PAYMENT_STATUSES = [
1119
- "PREPARED",
1120
- "INITIALIZED",
1121
- "FAILED",
1122
- "PENDING",
1123
- "COMPLETED",
1124
- "CREATED"
1125
- ];
1126
- const PAYMENT_DIRECTIONS = ["INCOMING", "OUTGOING"];
1127
- const BATCH_STATUSES = [
1128
- "OPEN",
1129
- "FULL",
1130
- "PROCESSING",
1131
- "READY_TO_SIGN",
1132
- "SIGNED",
1133
- "SIGNATURE_FAILED",
1134
- "FAILED"
1135
- ];
1136
- const ACCOUNT_STATUSES = ["AUTHORIZED", "DISABLED", "EXPIRED"];
1137
- const COUNTRY_CODES = COUNTRY_CODES_2;
1138
-
1139
- const CONNECTOR_KEYS = [
1140
- "ERSTE",
1141
- "FINBRICKS",
1142
- "MOCK",
1143
- "CREDITAS",
1144
- "MOCK_COBS",
1145
- "FIO",
1146
- "MONETA"
1147
- ];
1148
- const CREDENTIALS_TYPES = [
1149
- "AUTH_TOKEN",
1150
- "REFRESH_TOKEN",
1151
- "CLIENT_ID",
1152
- "API_KEY"
1153
- ];
1154
- const TOKEN_TYPES = ["ACCOUNT_AUTHORIZATION"];
1155
-
1156
- const account = sqliteTable(
1157
- "account",
1158
- {
1159
- ...base,
1160
- ...bankAccount,
1161
- number: text("number").notNull(),
1162
- name: text("name"),
1163
- iban: text("iban").notNull(),
1164
- bankCode: text("bank_code", { enum: BANK_CODES }).notNull(),
1165
- connectorKey: text("connector_key", {
1166
- enum: CONNECTOR_KEYS
1167
- }).$type().notNull(),
1168
- status: text("status", { enum: ACCOUNT_STATUSES }).$type().notNull(),
1169
- bankRefId: text("bank_ref_id").notNull(),
1170
- batchSizeLimit: integer("batch_size_limit").notNull().default(50),
1171
- syncIntervalS: integer("sync_interval_s").notNull().default(600),
1172
- lastSyncAt: integer("last_sync_at", { mode: "timestamp_ms" }),
1173
- lastSyncMetadata: text("last_sync_metadata", {
1174
- mode: "json"
1175
- }).$type()
1176
- },
1177
- (t) => [unique().on(t.iban)]
1178
- );
1179
-
1180
- const accountInsertSchema = createInsertSchema(account);
1181
- const accountUpdateSchema = createUpdateSchema(account);
1182
- const accountSelectSchema = createSelectSchema(account);
1183
-
1184
- const accountCredentials = sqliteTable("account_credentials", {
1185
- ...base,
1186
- accountId: text("account_id").references(() => account.id).notNull(),
1187
- connectorKey: text("connector_key", {
1188
- enum: CONNECTOR_KEYS
1189
- }).$type().notNull(),
1190
- type: text("type", {
1191
- enum: CREDENTIALS_TYPES
1192
- }).$type().notNull(),
1193
- value: text("value").notNull(),
1194
- expiresAt: integer("expires_at", { mode: "timestamp_ms" }).notNull()
1195
- });
1196
-
1197
- const accountCredentialsInsertSchema = createInsertSchema(accountCredentials);
1198
- const accountCredentialsUpdateSchema = createUpdateSchema(accountCredentials);
1199
- const accountCredentialsSelectSchema = createSelectSchema(accountCredentials);
1200
-
1201
- const ott = sqliteTable("ott", {
1202
- ...base,
1203
- oneTimeToken: text("one_time_token").notNull(),
1204
- refId: text("ref_id").notNull(),
1205
- tokenType: text("token_type", { enum: TOKEN_TYPES }).$type().notNull(),
1206
- expiresAt: integer("expires_at", { mode: "timestamp_ms" }).notNull()
1207
- });
1208
-
1209
- const ottInsertSchema = createInsertSchema(ott);
1210
- const ottUpdateSchema = createUpdateSchema(ott);
1211
- const ottSelectSchema = createSelectSchema(ott);
1212
-
1213
- const batch = sqliteTable("batch", {
1214
- ...base,
1215
- batchPaymentInitiatedAt: integer("batch_payment_initiated_at", {
1216
- mode: "timestamp_ms"
1217
- }),
1218
- authorizationUrls: text("authorization_urls", { mode: "json" }).$type(),
1219
- accountId: text("account_id").references(() => account.id),
1220
- status: text("status", { enum: BATCH_STATUSES }).$type(),
1221
- payments: text("payments", { mode: "json" }).$type().notNull(),
1222
- metadata: text("metadata", { mode: "json" }).$type(),
1223
- paymentsChecksum: text("payments_checksum")
1224
- });
1225
-
1226
- const payment = sqliteTable(
1227
- "payment",
1228
- {
1229
- ...base,
1230
- correlationId: text("correlation_id").notNull(),
1231
- refId: text("ref_id"),
1232
- bankRefId: text("bank_ref_id").notNull(),
1233
- accountId: text("account_id").references(() => account.id).notNull(),
1234
- connectorKey: text("connector_key", { enum: CONNECTOR_KEYS }).$type().notNull(),
1235
- amount: real("amount").notNull(),
1236
- direction: text("direction").$type().notNull(),
1237
- paymentType: text("payment_type").$type().notNull(),
1238
- currency: text("currency").$type().notNull(),
1239
- status: text("status").$type().notNull(),
1240
- statusReason: text("status_reason"),
1241
- batchId: text("bank_execution_batch_id"),
1242
- initiatedAt: integer("initiated_at", {
1243
- mode: "timestamp_ms"
1244
- }),
1245
- vs: text("vs"),
1246
- ss: text("ss"),
1247
- ks: text("ks"),
1248
- message: text("message"),
1249
- processedAt: integer("processed_at", {
1250
- mode: "timestamp_ms"
1251
- }),
1252
- creditor: text("creditor", { mode: "json" }).$type().notNull(),
1253
- creditorIban: text("creditor_iban"),
1254
- debtor: text("debtor", { mode: "json" }).$type().notNull(),
1255
- debtorIban: text("debtor_iban")
1256
- },
1257
- (t) => [unique().on(t.connectorKey, t.bankRefId)]
1258
- );
1259
- const paymentRelations = relations(payment, ({ one }) => ({
1260
- batch: one(batch, { fields: [payment.batchId], references: [batch.id] })
1261
- }));
1262
-
1263
- const schema = {
1264
- __proto__: null,
1265
- account: account,
1266
- accountCredentials: accountCredentials,
1267
- batch: batch,
1268
- ott: ott,
1269
- payment: payment,
1270
- paymentRelations: paymentRelations
1271
- };
1105
+ class MockCobsConnector extends FinbricksConnector {
1106
+ constructor(config) {
1107
+ super("MOCK_COBS", config);
1108
+ }
1109
+ }
1272
1110
 
1273
1111
  const tables = schema;
1274
1112
 
1275
- export { ACCOUNT_STATUSES as A, BATCH_STATUSES as B, CHARGE_BEARERS as C, ErsteConnector as E, FinbricksConnector as F, IBankConnector as I, MockConnector as M, PAYMENT_TYPES as P, TOKEN_TYPES as T, FinbricksClient as a, FINBRICKS_ENDPOINTS as b, INSTRUCTION_PRIORITIES as c, PAYMENT_STATUSES as d, PAYMENT_DIRECTIONS as e, COUNTRY_CODES as f, CONNECTOR_KEYS as g, CREDENTIALS_TYPES as h, accountInsertSchema as i, accountUpdateSchema as j, accountSelectSchema as k, accountCredentialsInsertSchema as l, accountCredentialsUpdateSchema as m, accountCredentialsSelectSchema as n, ottInsertSchema as o, ottUpdateSchema as p, ottSelectSchema as q, batch as r, signFinbricksJws as s, tables as t, useFinbricksFetch as u, payment as v, paymentRelations as w, ott as x, account as y, accountCredentials as z };
1113
+ export { ErsteConnector as E, FinbricksConnector as F, IBankConnector as I, MockConnector as M, MockCobsConnector as a, FinbricksClient as b, FINBRICKS_ENDPOINTS as c, signFinbricksJws as s, tables as t, useFinbricksFetch as u };
@@ -86,6 +86,25 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
86
86
  length: number | undefined;
87
87
  $type: "OPEN" | "FULL" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED" | "FAILED";
88
88
  }>;
89
+ statusReason: drizzle_orm_sqlite_core.SQLiteColumn<{
90
+ name: "status_reason";
91
+ tableName: "batch";
92
+ dataType: "string";
93
+ columnType: "SQLiteText";
94
+ data: string;
95
+ driverParam: string;
96
+ notNull: false;
97
+ hasDefault: false;
98
+ isPrimaryKey: false;
99
+ isAutoincrement: false;
100
+ hasRuntimeDefault: false;
101
+ enumValues: [string, ...string[]];
102
+ baseColumn: never;
103
+ identity: undefined;
104
+ generated: undefined;
105
+ }, {}, {
106
+ length: number | undefined;
107
+ }>;
89
108
  payments: drizzle_orm_sqlite_core.SQLiteColumn<{
90
109
  name: "payments";
91
110
  tableName: "batch";
@@ -1655,7 +1674,8 @@ declare abstract class IBankConnector {
1655
1674
  }>;
1656
1675
  abstract listAccounts(): Promise<AccountInsertType[]>;
1657
1676
  abstract preparePayment(payment: IncomingPaymentMessage): Promise<PaymentPreparedInsertType>;
1658
- abstract initiateBatchFromPayments({ payments, }: {
1677
+ abstract initiateBatchFromPayments({ batchId, payments, }: {
1678
+ batchId: string;
1659
1679
  payments: PaymentPreparedInsertType[];
1660
1680
  }): Promise<InitiatedBatch>;
1661
1681
  abstract initiateSEPAPayment(payment: IncomingPaymentMessage): Promise<InitiatedPayment>;
@@ -86,6 +86,25 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
86
86
  length: number | undefined;
87
87
  $type: "OPEN" | "FULL" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED" | "FAILED";
88
88
  }>;
89
+ statusReason: drizzle_orm_sqlite_core.SQLiteColumn<{
90
+ name: "status_reason";
91
+ tableName: "batch";
92
+ dataType: "string";
93
+ columnType: "SQLiteText";
94
+ data: string;
95
+ driverParam: string;
96
+ notNull: false;
97
+ hasDefault: false;
98
+ isPrimaryKey: false;
99
+ isAutoincrement: false;
100
+ hasRuntimeDefault: false;
101
+ enumValues: [string, ...string[]];
102
+ baseColumn: never;
103
+ identity: undefined;
104
+ generated: undefined;
105
+ }, {}, {
106
+ length: number | undefined;
107
+ }>;
89
108
  payments: drizzle_orm_sqlite_core.SQLiteColumn<{
90
109
  name: "payments";
91
110
  tableName: "batch";
@@ -1655,7 +1674,8 @@ declare abstract class IBankConnector {
1655
1674
  }>;
1656
1675
  abstract listAccounts(): Promise<AccountInsertType[]>;
1657
1676
  abstract preparePayment(payment: IncomingPaymentMessage): Promise<PaymentPreparedInsertType>;
1658
- abstract initiateBatchFromPayments({ payments, }: {
1677
+ abstract initiateBatchFromPayments({ batchId, payments, }: {
1678
+ batchId: string;
1659
1679
  payments: PaymentPreparedInsertType[];
1660
1680
  }): Promise<InitiatedBatch>;
1661
1681
  abstract initiateSEPAPayment(payment: IncomingPaymentMessage): Promise<InitiatedPayment>;
@@ -86,6 +86,25 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
86
86
  length: number | undefined;
87
87
  $type: "OPEN" | "FULL" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED" | "FAILED";
88
88
  }>;
89
+ statusReason: drizzle_orm_sqlite_core.SQLiteColumn<{
90
+ name: "status_reason";
91
+ tableName: "batch";
92
+ dataType: "string";
93
+ columnType: "SQLiteText";
94
+ data: string;
95
+ driverParam: string;
96
+ notNull: false;
97
+ hasDefault: false;
98
+ isPrimaryKey: false;
99
+ isAutoincrement: false;
100
+ hasRuntimeDefault: false;
101
+ enumValues: [string, ...string[]];
102
+ baseColumn: never;
103
+ identity: undefined;
104
+ generated: undefined;
105
+ }, {}, {
106
+ length: number | undefined;
107
+ }>;
89
108
  payments: drizzle_orm_sqlite_core.SQLiteColumn<{
90
109
  name: "payments";
91
110
  tableName: "batch";
@@ -1655,7 +1674,8 @@ declare abstract class IBankConnector {
1655
1674
  }>;
1656
1675
  abstract listAccounts(): Promise<AccountInsertType[]>;
1657
1676
  abstract preparePayment(payment: IncomingPaymentMessage): Promise<PaymentPreparedInsertType>;
1658
- abstract initiateBatchFromPayments({ payments, }: {
1677
+ abstract initiateBatchFromPayments({ batchId, payments, }: {
1678
+ batchId: string;
1659
1679
  payments: PaymentPreparedInsertType[];
1660
1680
  }): Promise<InitiatedBatch>;
1661
1681
  abstract initiateSEPAPayment(payment: IncomingPaymentMessage): Promise<InitiatedPayment>;