@develit-services/bank 0.8.6 → 0.8.8

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 -1
  2. package/dist/database/schema.d.cts +1 -1
  3. package/dist/database/schema.d.mts +1 -1
  4. package/dist/database/schema.d.ts +1 -1
  5. package/dist/database/schema.mjs +1 -1
  6. package/dist/export/worker.cjs +550 -153
  7. package/dist/export/worker.d.cts +259 -47
  8. package/dist/export/worker.d.mts +259 -47
  9. package/dist/export/worker.d.ts +259 -47
  10. package/dist/export/worker.mjs +551 -154
  11. package/dist/export/workflows.cjs +95 -17
  12. package/dist/export/workflows.mjs +96 -18
  13. package/dist/export/wrangler.d.cts +2 -1
  14. package/dist/export/wrangler.d.mts +2 -1
  15. package/dist/export/wrangler.d.ts +2 -1
  16. package/dist/shared/{bank.BliD3oCT.d.ts → bank.B-NJB8GB.d.cts} +34 -10
  17. package/dist/shared/{bank.BliD3oCT.d.cts → bank.B-NJB8GB.d.mts} +34 -10
  18. package/dist/shared/{bank.BliD3oCT.d.mts → bank.B-NJB8GB.d.ts} +34 -10
  19. package/dist/shared/{bank.Cpy9PULF.mjs → bank.B5bZRvgq.mjs} +28 -5
  20. package/dist/shared/{bank.CQBfbG8u.d.cts → bank.BP_3WMIF.d.cts} +1 -0
  21. package/dist/shared/{bank.CQBfbG8u.d.mts → bank.BP_3WMIF.d.mts} +1 -0
  22. package/dist/shared/{bank.CQBfbG8u.d.ts → bank.BP_3WMIF.d.ts} +1 -0
  23. package/dist/shared/{bank.DDHrdFgy.mjs → bank.BoZtXQpG.mjs} +1 -1
  24. package/dist/shared/{bank.DRrBrAdI.mjs → bank.BtszLapg.mjs} +211 -43
  25. package/dist/shared/{bank.BoMDujsl.d.ts → bank.BzobShUU.d.cts} +17 -7
  26. package/dist/shared/{bank.C4VOdIx1.mjs → bank.C6jjS1Pl.mjs} +32 -4
  27. package/dist/shared/{bank.lbzMqyr3.d.cts → bank.CAVvvZZO.d.mts} +17 -7
  28. package/dist/shared/{bank.CQURey1E.cjs → bank.CtnsGHM8.cjs} +210 -43
  29. package/dist/shared/{bank.C-T1FQxg.cjs → bank.DJnDSYqE.cjs} +1 -1
  30. package/dist/shared/{bank.B6U8sUZn.d.mts → bank.DRTuKO8S.d.ts} +17 -7
  31. package/dist/shared/{bank.BOnP9p9Y.cjs → bank.DT6bg8k5.cjs} +28 -5
  32. package/dist/shared/{bank.SQ4Mmr8u.cjs → bank.JVlyPAAb.cjs} +32 -4
  33. package/dist/types.cjs +2 -3
  34. package/dist/types.d.cts +14 -18
  35. package/dist/types.d.mts +14 -18
  36. package/dist/types.d.ts +14 -18
  37. package/dist/types.mjs +2 -2
  38. package/package.json +2 -2
@@ -1,22 +1,22 @@
1
1
  'use strict';
2
2
 
3
3
  const backendSdk = require('@develit-io/backend-sdk');
4
- const drizzle = require('../shared/bank.BOnP9p9Y.cjs');
4
+ const drizzle = require('../shared/bank.DT6bg8k5.cjs');
5
5
  const batchLifecycle = require('../shared/bank.Bg3Pdwm4.cjs');
6
- const mock_connector = require('../shared/bank.CQURey1E.cjs');
6
+ const mock_connector = require('../shared/bank.CtnsGHM8.cjs');
7
7
  const drizzleOrm = require('drizzle-orm');
8
8
  const cloudflare_workers = require('cloudflare:workers');
9
9
  const cloudflare_workflows = require('cloudflare:workflows');
10
10
  const d1 = require('drizzle-orm/d1');
11
11
  require('node:crypto');
12
- require('../shared/bank.SQ4Mmr8u.cjs');
12
+ require('../shared/bank.JVlyPAAb.cjs');
13
13
  require('drizzle-orm/relations');
14
14
  require('drizzle-orm/sqlite-core');
15
15
  require('date-fns');
16
16
  require('jose');
17
17
  require('@develit-io/general-codes');
18
18
  require('drizzle-zod');
19
- require('../shared/bank.C-T1FQxg.cjs');
19
+ require('../shared/bank.DJnDSYqE.cjs');
20
20
 
21
21
  const updateAccountLastSyncCommand = (db, {
22
22
  lastSyncAt,
@@ -41,6 +41,23 @@ function pushToQueue$1(queue, message) {
41
41
  }))
42
42
  );
43
43
  }
44
+ async function failBatchAndPayments(db, batch, paymentRequests, reason) {
45
+ const prCmds = paymentRequests.filter((p) => p.status !== "FAILED").map(
46
+ (p) => drizzle.updatePaymentRequestStatusCommand(db, {
47
+ id: p.id,
48
+ status: "FAILED",
49
+ statusReason: reason,
50
+ processedAt: /* @__PURE__ */ new Date()
51
+ }).command
52
+ );
53
+ const batchCmd = drizzle.upsertBatchCommand(db, {
54
+ batch: { ...batch, status: "FAILED" }
55
+ }).command;
56
+ const allCmds = [batchCmd, ...prCmds];
57
+ if (allCmds.length > 0) {
58
+ await db.batch(allCmds);
59
+ }
60
+ }
44
61
  class BankProcessBatch extends cloudflare_workers.WorkflowEntrypoint {
45
62
  async run(event, step) {
46
63
  const { batchId } = event.payload;
@@ -92,20 +109,27 @@ class BankProcessBatch extends cloudflare_workers.WorkflowEntrypoint {
92
109
  const batchedPayments = paymentRequests.map(
93
110
  mock_connector.toBatchedPaymentFromPaymentRequest
94
111
  );
95
- if (batch.batchPaymentInitiatedAt) {
112
+ const currentBatch = await drizzle.getBatchByIdQuery(db, { batchId });
113
+ if (currentBatch?.batchPaymentInitiatedAt) {
96
114
  return {
97
- authorizationUrls: batch.authorizationUrls,
115
+ authorizationUrls: currentBatch.authorizationUrls,
98
116
  preparedPayments: batchedPayments.map(
99
- (p) => mock_connector.toPreparedPayment(p, void 0, batch.batchPaymentInitiatedAt)
117
+ (p) => mock_connector.toPreparedPayment(
118
+ p,
119
+ void 0,
120
+ currentBatch.batchPaymentInitiatedAt
121
+ )
100
122
  ),
101
- metadata: batch.metadata
123
+ metadata: currentBatch.metadata
102
124
  };
103
125
  }
104
126
  const account = await drizzle.getAccountByIdQuery(db, {
105
127
  accountId: batch.accountId
106
128
  });
107
129
  if (!account) {
108
- throw new cloudflare_workflows.NonRetryableError(`Account not found: ${batch.accountId}`);
130
+ const msg = `Account not found: ${batch.accountId}`;
131
+ await failBatchAndPayments(db, batch, paymentRequests, msg);
132
+ throw new cloudflare_workflows.NonRetryableError(msg);
109
133
  }
110
134
  const resolveCredentials = await drizzle.createCredentialsResolver(db, this.env);
111
135
  const connector = await mock_connector.initiateConnector({
@@ -138,6 +162,7 @@ class BankProcessBatch extends cloudflare_workers.WorkflowEntrypoint {
138
162
  const message = err instanceof Error ? err.message : typeof err === "object" && err !== null && "message" in err ? String(err.message) : String(err);
139
163
  const status = typeof err === "object" && err !== null && "status" in err ? Number(err.status) : 0;
140
164
  if (status >= 400 && status < 500) {
165
+ await failBatchAndPayments(db, batch, paymentRequests, message);
141
166
  throw new cloudflare_workflows.NonRetryableError(message);
142
167
  }
143
168
  throw new Error(message);
@@ -148,7 +173,9 @@ class BankProcessBatch extends cloudflare_workers.WorkflowEntrypoint {
148
173
  metadata
149
174
  } = result;
150
175
  if (!authorizationUrls || authorizationUrls.length === 0) {
151
- throw new cloudflare_workflows.NonRetryableError("Failed to retrieve authorization URLs");
176
+ const msg = "Failed to retrieve authorization URLs";
177
+ await failBatchAndPayments(db, batch, paymentRequests, msg);
178
+ throw new cloudflare_workflows.NonRetryableError(msg);
152
179
  }
153
180
  return {
154
181
  authorizationUrls,
@@ -207,7 +234,7 @@ class BankProcessBatch extends cloudflare_workers.WorkflowEntrypoint {
207
234
  const updateBatchCommand = drizzle.upsertBatchCommand(db, {
208
235
  batch: {
209
236
  ...batch,
210
- status: "SIGNED",
237
+ status: "COMPLETED",
211
238
  authorizationUrls: batchResult.authorizationUrls,
212
239
  metadata: batchResult.metadata,
213
240
  batchPaymentInitiatedAt: /* @__PURE__ */ new Date()
@@ -330,11 +357,60 @@ class BankSyncAccountPayments extends cloudflare_workers.WorkflowEntrypoint {
330
357
  "process new payments and update lastSyncAt",
331
358
  async () => {
332
359
  const eventsToEmit = [];
333
- const createCommands = paymentsToInsert.map(
360
+ const bankRefIds = paymentsToInsert.map((p) => p.parsed.bankRefId).filter((id) => id != null);
361
+ const matchingRequests = bankRefIds.length > 0 ? await db.select().from(drizzle.tables.paymentRequest).where(
362
+ drizzleOrm.and(
363
+ drizzleOrm.inArray(drizzle.tables.paymentRequest.bankRefId, bankRefIds),
364
+ drizzleOrm.eq(drizzle.tables.paymentRequest.accountId, account.id),
365
+ drizzleOrm.eq(
366
+ drizzle.tables.paymentRequest.connectorKey,
367
+ account.connectorKey
368
+ )
369
+ )
370
+ ) : [];
371
+ const requestByBankRefId = Object.fromEntries(
372
+ matchingRequests.map((r) => [r.bankRefId, r])
373
+ );
374
+ const enrichedPayments = paymentsToInsert.map((p) => {
375
+ const req = p.parsed.bankRefId && requestByBankRefId[p.parsed.bankRefId] || null;
376
+ if (!req) return p;
377
+ return {
378
+ ...p,
379
+ parsed: {
380
+ ...p.parsed,
381
+ // queue-bus: transaction matching (DBU doesn't echo these in statements)
382
+ vs: p.parsed.vs ?? req.vs,
383
+ ss: p.parsed.ss ?? req.ss,
384
+ ks: p.parsed.ks ?? req.ks,
385
+ message: p.parsed.message ?? req.message,
386
+ // queue-bus: party creation
387
+ creditor: {
388
+ ...p.parsed.creditor,
389
+ holderName: p.parsed.creditor?.holderName ?? req.creditor?.holderName
390
+ },
391
+ debtor: {
392
+ ...p.parsed.debtor,
393
+ holderName: p.parsed.debtor?.holderName ?? req.debtor?.holderName
394
+ }
395
+ // NOT enriched: chargeBearer, instructionPriority, refId, batchId,
396
+ // createdAt, address, swiftBic — no downstream consumer in payment table
397
+ }
398
+ };
399
+ });
400
+ const createCommands = enrichedPayments.map(
334
401
  (p) => drizzle.createPaymentCommand(db, { payment: p.parsed }).command
335
402
  );
403
+ const prCompleteCommands = matchingRequests.filter(
404
+ (req) => req.status !== "COMPLETED" && req.status !== "FAILED"
405
+ ).map(
406
+ (req) => drizzle.updatePaymentRequestStatusCommand(db, {
407
+ id: req.id,
408
+ status: "COMPLETED",
409
+ processedAt: /* @__PURE__ */ new Date()
410
+ }).command
411
+ );
336
412
  eventsToEmit.push(
337
- ...paymentsToInsert.map((p) => ({
413
+ ...enrichedPayments.map((p) => ({
338
414
  eventType: "BANK_PAYMENT",
339
415
  eventSignal: "paymentCreated",
340
416
  bankPayment: p.parsed,
@@ -349,9 +425,7 @@ class BankSyncAccountPayments extends cloudflare_workers.WorkflowEntrypoint {
349
425
  payments: payments.length,
350
426
  paymentsToProcess: paymentsToProcess.length,
351
427
  paymentsInserted: paymentsToInsert.length,
352
- lastSyncBankRefIds: paymentsToProcess.map(
353
- (p) => p.parsed.bankRefId
354
- ),
428
+ lastSyncBankRefIds: paymentsToProcess.filter((p) => p.parsed.status === "COMPLETED").map((p) => p.parsed.bankRefId),
355
429
  lastSyncPayments: lastSyncBankRefIds.length,
356
430
  eventsEmitted: eventsToEmit.length
357
431
  };
@@ -362,7 +436,11 @@ class BankSyncAccountPayments extends cloudflare_workers.WorkflowEntrypoint {
362
436
  }).command;
363
437
  if (eventsToEmit.length) {
364
438
  await db.batch(
365
- backendSdk.asNonEmpty([updateLastSyncCommand, ...createCommands])
439
+ backendSdk.asNonEmpty([
440
+ updateLastSyncCommand,
441
+ ...createCommands,
442
+ ...prCompleteCommands
443
+ ])
366
444
  );
367
445
  await pushToQueue(
368
446
  this.env.QUEUE_BUS_QUEUE,
@@ -1,20 +1,20 @@
1
1
  import { first, uuidv4, asNonEmpty } from '@develit-io/backend-sdk';
2
- import { t as tables, g as getBatchByIdQuery, a as getPaymentRequestsByBatchIdQuery, c as checksum, u as upsertBatchCommand, b as getAccountByIdQuery, d as createCredentialsResolver, e as updatePaymentRequestStatusCommand, f as createPaymentCommand } from '../shared/bank.Cpy9PULF.mjs';
2
+ import { t as tables, g as getBatchByIdQuery, a as getPaymentRequestsByBatchIdQuery, c as checksum, u as upsertBatchCommand, b as getAccountByIdQuery, d as createCredentialsResolver, e as updatePaymentRequestStatusCommand, f as createPaymentCommand } from '../shared/bank.B5bZRvgq.mjs';
3
3
  import { f as isBatchSigned, a as isBatchFailed, c as isBatchOpen, g as isPaymentCompleted } from '../shared/bank.CbAwwIhZ.mjs';
4
- import { f as toBatchedPaymentFromPaymentRequest, j as toPreparedPayment, k as initiateConnector } from '../shared/bank.DRrBrAdI.mjs';
5
- import { eq } from 'drizzle-orm';
4
+ import { e as toBatchedPaymentFromPaymentRequest, i as toPreparedPayment, j as initiateConnector } from '../shared/bank.BtszLapg.mjs';
5
+ import { eq, and, inArray } from 'drizzle-orm';
6
6
  import { WorkflowEntrypoint } from 'cloudflare:workers';
7
7
  import { NonRetryableError } from 'cloudflare:workflows';
8
8
  import { drizzle } from 'drizzle-orm/d1';
9
9
  import 'node:crypto';
10
- import '../shared/bank.C4VOdIx1.mjs';
10
+ import '../shared/bank.C6jjS1Pl.mjs';
11
11
  import 'drizzle-orm/relations';
12
12
  import 'drizzle-orm/sqlite-core';
13
13
  import 'date-fns';
14
14
  import 'jose';
15
15
  import '@develit-io/general-codes';
16
16
  import 'drizzle-zod';
17
- import '../shared/bank.DDHrdFgy.mjs';
17
+ import '../shared/bank.BoZtXQpG.mjs';
18
18
 
19
19
  const updateAccountLastSyncCommand = (db, {
20
20
  lastSyncAt,
@@ -39,6 +39,23 @@ function pushToQueue$1(queue, message) {
39
39
  }))
40
40
  );
41
41
  }
42
+ async function failBatchAndPayments(db, batch, paymentRequests, reason) {
43
+ const prCmds = paymentRequests.filter((p) => p.status !== "FAILED").map(
44
+ (p) => updatePaymentRequestStatusCommand(db, {
45
+ id: p.id,
46
+ status: "FAILED",
47
+ statusReason: reason,
48
+ processedAt: /* @__PURE__ */ new Date()
49
+ }).command
50
+ );
51
+ const batchCmd = upsertBatchCommand(db, {
52
+ batch: { ...batch, status: "FAILED" }
53
+ }).command;
54
+ const allCmds = [batchCmd, ...prCmds];
55
+ if (allCmds.length > 0) {
56
+ await db.batch(allCmds);
57
+ }
58
+ }
42
59
  class BankProcessBatch extends WorkflowEntrypoint {
43
60
  async run(event, step) {
44
61
  const { batchId } = event.payload;
@@ -90,20 +107,27 @@ class BankProcessBatch extends WorkflowEntrypoint {
90
107
  const batchedPayments = paymentRequests.map(
91
108
  toBatchedPaymentFromPaymentRequest
92
109
  );
93
- if (batch.batchPaymentInitiatedAt) {
110
+ const currentBatch = await getBatchByIdQuery(db, { batchId });
111
+ if (currentBatch?.batchPaymentInitiatedAt) {
94
112
  return {
95
- authorizationUrls: batch.authorizationUrls,
113
+ authorizationUrls: currentBatch.authorizationUrls,
96
114
  preparedPayments: batchedPayments.map(
97
- (p) => toPreparedPayment(p, void 0, batch.batchPaymentInitiatedAt)
115
+ (p) => toPreparedPayment(
116
+ p,
117
+ void 0,
118
+ currentBatch.batchPaymentInitiatedAt
119
+ )
98
120
  ),
99
- metadata: batch.metadata
121
+ metadata: currentBatch.metadata
100
122
  };
101
123
  }
102
124
  const account = await getAccountByIdQuery(db, {
103
125
  accountId: batch.accountId
104
126
  });
105
127
  if (!account) {
106
- throw new NonRetryableError(`Account not found: ${batch.accountId}`);
128
+ const msg = `Account not found: ${batch.accountId}`;
129
+ await failBatchAndPayments(db, batch, paymentRequests, msg);
130
+ throw new NonRetryableError(msg);
107
131
  }
108
132
  const resolveCredentials = await createCredentialsResolver(db, this.env);
109
133
  const connector = await initiateConnector({
@@ -136,6 +160,7 @@ class BankProcessBatch extends WorkflowEntrypoint {
136
160
  const message = err instanceof Error ? err.message : typeof err === "object" && err !== null && "message" in err ? String(err.message) : String(err);
137
161
  const status = typeof err === "object" && err !== null && "status" in err ? Number(err.status) : 0;
138
162
  if (status >= 400 && status < 500) {
163
+ await failBatchAndPayments(db, batch, paymentRequests, message);
139
164
  throw new NonRetryableError(message);
140
165
  }
141
166
  throw new Error(message);
@@ -146,7 +171,9 @@ class BankProcessBatch extends WorkflowEntrypoint {
146
171
  metadata
147
172
  } = result;
148
173
  if (!authorizationUrls || authorizationUrls.length === 0) {
149
- throw new NonRetryableError("Failed to retrieve authorization URLs");
174
+ const msg = "Failed to retrieve authorization URLs";
175
+ await failBatchAndPayments(db, batch, paymentRequests, msg);
176
+ throw new NonRetryableError(msg);
150
177
  }
151
178
  return {
152
179
  authorizationUrls,
@@ -205,7 +232,7 @@ class BankProcessBatch extends WorkflowEntrypoint {
205
232
  const updateBatchCommand = upsertBatchCommand(db, {
206
233
  batch: {
207
234
  ...batch,
208
- status: "SIGNED",
235
+ status: "COMPLETED",
209
236
  authorizationUrls: batchResult.authorizationUrls,
210
237
  metadata: batchResult.metadata,
211
238
  batchPaymentInitiatedAt: /* @__PURE__ */ new Date()
@@ -328,11 +355,60 @@ class BankSyncAccountPayments extends WorkflowEntrypoint {
328
355
  "process new payments and update lastSyncAt",
329
356
  async () => {
330
357
  const eventsToEmit = [];
331
- const createCommands = paymentsToInsert.map(
358
+ const bankRefIds = paymentsToInsert.map((p) => p.parsed.bankRefId).filter((id) => id != null);
359
+ const matchingRequests = bankRefIds.length > 0 ? await db.select().from(tables.paymentRequest).where(
360
+ and(
361
+ inArray(tables.paymentRequest.bankRefId, bankRefIds),
362
+ eq(tables.paymentRequest.accountId, account.id),
363
+ eq(
364
+ tables.paymentRequest.connectorKey,
365
+ account.connectorKey
366
+ )
367
+ )
368
+ ) : [];
369
+ const requestByBankRefId = Object.fromEntries(
370
+ matchingRequests.map((r) => [r.bankRefId, r])
371
+ );
372
+ const enrichedPayments = paymentsToInsert.map((p) => {
373
+ const req = p.parsed.bankRefId && requestByBankRefId[p.parsed.bankRefId] || null;
374
+ if (!req) return p;
375
+ return {
376
+ ...p,
377
+ parsed: {
378
+ ...p.parsed,
379
+ // queue-bus: transaction matching (DBU doesn't echo these in statements)
380
+ vs: p.parsed.vs ?? req.vs,
381
+ ss: p.parsed.ss ?? req.ss,
382
+ ks: p.parsed.ks ?? req.ks,
383
+ message: p.parsed.message ?? req.message,
384
+ // queue-bus: party creation
385
+ creditor: {
386
+ ...p.parsed.creditor,
387
+ holderName: p.parsed.creditor?.holderName ?? req.creditor?.holderName
388
+ },
389
+ debtor: {
390
+ ...p.parsed.debtor,
391
+ holderName: p.parsed.debtor?.holderName ?? req.debtor?.holderName
392
+ }
393
+ // NOT enriched: chargeBearer, instructionPriority, refId, batchId,
394
+ // createdAt, address, swiftBic — no downstream consumer in payment table
395
+ }
396
+ };
397
+ });
398
+ const createCommands = enrichedPayments.map(
332
399
  (p) => createPaymentCommand(db, { payment: p.parsed }).command
333
400
  );
401
+ const prCompleteCommands = matchingRequests.filter(
402
+ (req) => req.status !== "COMPLETED" && req.status !== "FAILED"
403
+ ).map(
404
+ (req) => updatePaymentRequestStatusCommand(db, {
405
+ id: req.id,
406
+ status: "COMPLETED",
407
+ processedAt: /* @__PURE__ */ new Date()
408
+ }).command
409
+ );
334
410
  eventsToEmit.push(
335
- ...paymentsToInsert.map((p) => ({
411
+ ...enrichedPayments.map((p) => ({
336
412
  eventType: "BANK_PAYMENT",
337
413
  eventSignal: "paymentCreated",
338
414
  bankPayment: p.parsed,
@@ -347,9 +423,7 @@ class BankSyncAccountPayments extends WorkflowEntrypoint {
347
423
  payments: payments.length,
348
424
  paymentsToProcess: paymentsToProcess.length,
349
425
  paymentsInserted: paymentsToInsert.length,
350
- lastSyncBankRefIds: paymentsToProcess.map(
351
- (p) => p.parsed.bankRefId
352
- ),
426
+ lastSyncBankRefIds: paymentsToProcess.filter((p) => p.parsed.status === "COMPLETED").map((p) => p.parsed.bankRefId),
353
427
  lastSyncPayments: lastSyncBankRefIds.length,
354
428
  eventsEmitted: eventsToEmit.length
355
429
  };
@@ -360,7 +434,11 @@ class BankSyncAccountPayments extends WorkflowEntrypoint {
360
434
  }).command;
361
435
  if (eventsToEmit.length) {
362
436
  await db.batch(
363
- asNonEmpty([updateLastSyncCommand, ...createCommands])
437
+ asNonEmpty([
438
+ updateLastSyncCommand,
439
+ ...createCommands,
440
+ ...prCompleteCommands
441
+ ])
364
442
  );
365
443
  await pushToQueue(
366
444
  this.env.QUEUE_BUS_QUEUE,
@@ -1,4 +1,4 @@
1
- import { B as BankServiceWranglerConfig } from '../shared/bank.CQBfbG8u.cjs';
1
+ import { B as BankServiceWranglerConfig } from '../shared/bank.BP_3WMIF.cjs';
2
2
 
3
3
  declare function defineBankServiceWrangler(config: BankServiceWranglerConfig): {
4
4
  vars: {
@@ -9,6 +9,7 @@ declare function defineBankServiceWrangler(config: BankServiceWranglerConfig): {
9
9
  FINBRICKS_BASE_URI: "https://api.sandbox.finbricks.com";
10
10
  FINBRICKS_MERCHANT_ID: string;
11
11
  CRON_BATCH_STATUSES: string;
12
+ CRON_PAYMENT_STATUSES: string;
12
13
  BANK_AUTH_RECIPIENT: string;
13
14
  DBUCS_BASE_URI: string;
14
15
  DBUCS_USERNAME: string;
@@ -1,4 +1,4 @@
1
- import { B as BankServiceWranglerConfig } from '../shared/bank.CQBfbG8u.mjs';
1
+ import { B as BankServiceWranglerConfig } from '../shared/bank.BP_3WMIF.mjs';
2
2
 
3
3
  declare function defineBankServiceWrangler(config: BankServiceWranglerConfig): {
4
4
  vars: {
@@ -9,6 +9,7 @@ declare function defineBankServiceWrangler(config: BankServiceWranglerConfig): {
9
9
  FINBRICKS_BASE_URI: "https://api.sandbox.finbricks.com";
10
10
  FINBRICKS_MERCHANT_ID: string;
11
11
  CRON_BATCH_STATUSES: string;
12
+ CRON_PAYMENT_STATUSES: string;
12
13
  BANK_AUTH_RECIPIENT: string;
13
14
  DBUCS_BASE_URI: string;
14
15
  DBUCS_USERNAME: string;
@@ -1,4 +1,4 @@
1
- import { B as BankServiceWranglerConfig } from '../shared/bank.CQBfbG8u.js';
1
+ import { B as BankServiceWranglerConfig } from '../shared/bank.BP_3WMIF.js';
2
2
 
3
3
  declare function defineBankServiceWrangler(config: BankServiceWranglerConfig): {
4
4
  vars: {
@@ -9,6 +9,7 @@ declare function defineBankServiceWrangler(config: BankServiceWranglerConfig): {
9
9
  FINBRICKS_BASE_URI: "https://api.sandbox.finbricks.com";
10
10
  FINBRICKS_MERCHANT_ID: string;
11
11
  CRON_BATCH_STATUSES: string;
12
+ CRON_PAYMENT_STATUSES: string;
12
13
  BANK_AUTH_RECIPIENT: string;
13
14
  DBUCS_BASE_URI: string;
14
15
  DBUCS_USERNAME: string;
@@ -42,7 +42,7 @@ type CurrencyCode = (typeof CURRENCY_CODES)[number];
42
42
  /**
43
43
  * Batch status constants
44
44
  */
45
- declare const BATCH_STATUSES: readonly ["OPEN", "PROCESSING", "READY_TO_SIGN", "SIGNED", "SIGNATURE_FAILED", "FAILED"];
45
+ declare const BATCH_STATUSES: readonly ["OPEN", "PROCESSING", "READY_TO_SIGN", "SIGNED", "SIGNATURE_FAILED", "FAILED", "COMPLETED"];
46
46
  /**
47
47
  * Type definition for batch status
48
48
  */
@@ -90,6 +90,12 @@ type ConnectedAccount = {
90
90
  declare abstract class IBankConnector {
91
91
  /** Unique identifier for this bank connector (e.g., 'ERSTE', 'FINBRICKS', 'MOCK') */
92
92
  abstract connectorKey: ConnectorKey;
93
+ /**
94
+ * Lifecycle mode for payment status resolution:
95
+ * - 'batch': statuses are resolved via updateBatchStatuses (getBatchStatus polling)
96
+ * - 'per-payment': statuses are resolved via updatePaymentStatuses (getPaymentStatus polling per payment)
97
+ */
98
+ abstract readonly lifecycleMode: 'batch' | 'per-payment';
93
99
  /** List of bank accounts connected through this connector instance */
94
100
  abstract connectedAccounts: ConnectedAccount[];
95
101
  /** Optional resolver for loading credentials on demand */
@@ -102,6 +108,7 @@ declare abstract class IBankConnector {
102
108
  * @returns true if native batch API is supported, false if fallback to single payments is needed
103
109
  */
104
110
  abstract supportsBatch(paymentType: PaymentType): boolean;
111
+ supportsPaymentType(paymentType: PaymentType): boolean;
105
112
  /**
106
113
  * Generates authorization URI for connecting a new bank account.
107
114
  * @param ott - One-time token used to identify the authorization flow
@@ -2629,20 +2636,20 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2629
2636
  tableName: "batch";
2630
2637
  dataType: "string";
2631
2638
  columnType: "SQLiteText";
2632
- data: "SIGNED" | "FAILED" | "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "SIGNATURE_FAILED";
2639
+ data: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED" | "FAILED" | "COMPLETED";
2633
2640
  driverParam: string;
2634
2641
  notNull: false;
2635
2642
  hasDefault: false;
2636
2643
  isPrimaryKey: false;
2637
2644
  isAutoincrement: false;
2638
2645
  hasRuntimeDefault: false;
2639
- enumValues: ["OPEN", "PROCESSING", "READY_TO_SIGN", "SIGNED", "SIGNATURE_FAILED", "FAILED"];
2646
+ enumValues: ["OPEN", "PROCESSING", "READY_TO_SIGN", "SIGNED", "SIGNATURE_FAILED", "FAILED", "COMPLETED"];
2640
2647
  baseColumn: never;
2641
2648
  identity: undefined;
2642
2649
  generated: undefined;
2643
2650
  }, {}, {
2644
2651
  length: number | undefined;
2645
- $type: "SIGNED" | "FAILED" | "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "SIGNATURE_FAILED";
2652
+ $type: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED" | "FAILED" | "COMPLETED";
2646
2653
  }>;
2647
2654
  statusReason: drizzle_orm_sqlite_core.SQLiteColumn<{
2648
2655
  name: "status_reason";
@@ -3053,7 +3060,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
3053
3060
  tableName: "payment";
3054
3061
  dataType: "string";
3055
3062
  columnType: "SQLiteText";
3056
- data: "CREATED" | "PREPARED" | "SIGNED" | "PENDING" | "COMPLETED" | "FAILED";
3063
+ data: "SIGNED" | "FAILED" | "COMPLETED" | "CREATED" | "PREPARED" | "PENDING";
3057
3064
  driverParam: string;
3058
3065
  notNull: true;
3059
3066
  hasDefault: false;
@@ -3066,7 +3073,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
3066
3073
  generated: undefined;
3067
3074
  }, {}, {
3068
3075
  length: number | undefined;
3069
- $type: "CREATED" | "PREPARED" | "SIGNED" | "PENDING" | "COMPLETED" | "FAILED";
3076
+ $type: "SIGNED" | "FAILED" | "COMPLETED" | "CREATED" | "PREPARED" | "PENDING";
3070
3077
  }>;
3071
3078
  statusReason: drizzle_orm_sqlite_core.SQLiteColumn<{
3072
3079
  name: "status_reason";
@@ -3647,7 +3654,7 @@ declare const paymentRequest: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
3647
3654
  tableName: "payment_request";
3648
3655
  dataType: "string";
3649
3656
  columnType: "SQLiteText";
3650
- data: "CREATED" | "PREPARED" | "SIGNED" | "PENDING" | "COMPLETED" | "FAILED";
3657
+ data: "SIGNED" | "FAILED" | "COMPLETED" | "CREATED" | "PREPARED" | "PENDING";
3651
3658
  driverParam: string;
3652
3659
  notNull: true;
3653
3660
  hasDefault: false;
@@ -3660,7 +3667,7 @@ declare const paymentRequest: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
3660
3667
  generated: undefined;
3661
3668
  }, {}, {
3662
3669
  length: number | undefined;
3663
- $type: "CREATED" | "PREPARED" | "SIGNED" | "PENDING" | "COMPLETED" | "FAILED";
3670
+ $type: "SIGNED" | "FAILED" | "COMPLETED" | "CREATED" | "PREPARED" | "PENDING";
3664
3671
  }>;
3665
3672
  statusReason: drizzle_orm_sqlite_core.SQLiteColumn<{
3666
3673
  name: "status_reason";
@@ -3926,6 +3933,23 @@ declare const paymentRequest: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
3926
3933
  }, {}, {
3927
3934
  length: number | undefined;
3928
3935
  }>;
3936
+ sendAsSinglePayment: drizzle_orm_sqlite_core.SQLiteColumn<{
3937
+ name: "send_as_single_payment";
3938
+ tableName: "payment_request";
3939
+ dataType: "boolean";
3940
+ columnType: "SQLiteBoolean";
3941
+ data: boolean;
3942
+ driverParam: number;
3943
+ notNull: false;
3944
+ hasDefault: false;
3945
+ isPrimaryKey: false;
3946
+ isAutoincrement: false;
3947
+ hasRuntimeDefault: false;
3948
+ enumValues: undefined;
3949
+ baseColumn: never;
3950
+ identity: undefined;
3951
+ generated: undefined;
3952
+ }, {}, {}>;
3929
3953
  id: drizzle_orm_sqlite_core.SQLiteColumn<{
3930
3954
  name: "id";
3931
3955
  tableName: "payment_request";
@@ -5342,5 +5366,5 @@ declare function isBatchFailed(batch: {
5342
5366
  status?: string | null;
5343
5367
  }): batch is CompletedBatch;
5344
5368
 
5345
- export { PAYMENT_STATUSES as $, BATCH_STATUSES as F, IBankConnector as I, CHARGE_BEARERS as N, CONNECTOR_KEYS as O, COUNTRY_CODES as Q, CREDENTIALS_TYPES as R, INSTRUCTION_PRIORITIES as Y, PAYMENT_DIRECTIONS as _, PAYMENT_TYPES as a0, TOKEN_TYPES as aa, accountCredentialsInsertSchema as ac, accountCredentialsSelectSchema as ad, accountCredentialsUpdateSchema as ae, accountInsertSchema as af, accountSelectSchema as ag, accountUpdateSchema as ah, hasPaymentAccountAssigned as ai, isBatchCompleted as aj, isBatchFailed as ak, isBatchInitiated as al, isBatchOpen as am, isBatchProcessing as an, isBatchReadyToSign as ao, isBatchSigned as ap, isPaymentCompleted as aq, isPaymentPrepared as ar, account as as, accountCredentials as at, batch as au, ott as av, payment as aw, paymentRelations as ax, paymentRequest as ay, paymentRequestRelations as az, tables as t, ACCOUNT_STATUSES as v };
5346
- export type { AccountSelectType as A, BatchSelectType as B, ConfigEnvironmentBank as C, AccountStatus as D, AccountUpdateType as E, BankAccountWithLastSync as G, BankCode as H, BatchInsertType as J, BatchLifecycle as K, LastSyncMetadata as L, BatchPayment as M, PaymentSelectType as P, ChargeBearer as S, CompletedBatch as T, CountryCode as U, CreatedBatch as V, CredentialsType as W, CurrencyCode as X, InstructionPriority as Z, PaymentRequestSelectType as a, PaymentDirection as a1, PaymentFailedInsertType as a2, PaymentInsertType as a3, PaymentLifecycle as a4, PaymentPreparedInsertType as a5, ProcessingBatch as a6, ReadyToSignBatch as a7, ResolvedCredentials as a8, SignedBatch as a9, TokenType as ab, ConnectorKey as b, ConnectedAccount as c, CredentialsResolver as d, AccountCredentialsInsertType as e, AccountInsertType as f, BatchedPayment as g, InitiatedBatch as h, IncomingPayment as i, InitiatedPayment as j, ParsedBankPayment as k, PaymentStatus as l, BatchStatus as m, PaymentType as n, BatchMetadata as o, Currency as p, AccountAssignedPayment as q, PreparedPayment as r, CompletedPayment as s, PaymentRequestInsertType as u, AccountCredentialsPatchType as w, AccountCredentialsSelectType as x, AccountCredentialsUpdateType as y, AccountPatchType as z };
5369
+ export { PAYMENT_STATUSES as $, BATCH_STATUSES as G, IBankConnector as I, CHARGE_BEARERS as O, CONNECTOR_KEYS as Q, COUNTRY_CODES as R, CREDENTIALS_TYPES as S, INSTRUCTION_PRIORITIES as Y, PAYMENT_DIRECTIONS as _, PAYMENT_TYPES as a0, TOKEN_TYPES as aa, accountCredentialsInsertSchema as ac, accountCredentialsSelectSchema as ad, accountCredentialsUpdateSchema as ae, accountInsertSchema as af, accountSelectSchema as ag, accountUpdateSchema as ah, hasPaymentAccountAssigned as ai, isBatchCompleted as aj, isBatchFailed as ak, isBatchInitiated as al, isBatchOpen as am, isBatchProcessing as an, isBatchReadyToSign as ao, isBatchSigned as ap, isPaymentCompleted as aq, isPaymentPrepared as ar, account as as, accountCredentials as at, batch as au, ott as av, payment as aw, paymentRelations as ax, paymentRequest as ay, paymentRequestRelations as az, tables as t, ACCOUNT_STATUSES as w };
5370
+ export type { AccountSelectType as A, BatchSelectType as B, ConfigEnvironmentBank as C, AccountPatchType as D, AccountStatus as E, AccountUpdateType as F, BankAccountWithLastSync as H, BankCode as J, BatchInsertType as K, LastSyncMetadata as L, BatchLifecycle as M, BatchPayment as N, PaymentSelectType as P, ChargeBearer as T, CompletedBatch as U, CountryCode as V, CreatedBatch as W, CredentialsType as X, InstructionPriority as Z, PaymentRequestSelectType as a, PaymentDirection as a1, PaymentFailedInsertType as a2, PaymentInsertType as a3, PaymentLifecycle as a4, PaymentPreparedInsertType as a5, ProcessingBatch as a6, ReadyToSignBatch as a7, ResolvedCredentials as a8, SignedBatch as a9, TokenType as ab, ConnectorKey as b, PaymentType as c, CurrencyCode as d, ConnectedAccount as e, CredentialsResolver as f, AccountCredentialsInsertType as g, AccountInsertType as h, BatchedPayment as i, InitiatedBatch as j, IncomingPayment as k, InitiatedPayment as l, ParsedBankPayment as m, PaymentStatus as n, BatchStatus as o, BatchMetadata as p, Currency as q, AccountAssignedPayment as r, PreparedPayment as s, CompletedPayment as u, PaymentRequestInsertType as v, AccountCredentialsPatchType as x, AccountCredentialsSelectType as y, AccountCredentialsUpdateType as z };