@develit-services/bank 4.2.0 → 4.2.2

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 (32) hide show
  1. package/dist/database/schema.d.cts +1 -1
  2. package/dist/database/schema.d.mts +1 -1
  3. package/dist/database/schema.d.ts +1 -1
  4. package/dist/export/worker.cjs +121 -19
  5. package/dist/export/worker.d.cts +14 -14
  6. package/dist/export/worker.d.mts +14 -14
  7. package/dist/export/worker.d.ts +14 -14
  8. package/dist/export/worker.mjs +121 -19
  9. package/dist/export/workflows.cjs +2 -2
  10. package/dist/export/workflows.mjs +2 -2
  11. package/dist/export/wrangler.d.cts +2 -1
  12. package/dist/export/wrangler.d.mts +2 -1
  13. package/dist/export/wrangler.d.ts +2 -1
  14. package/dist/shared/{bank.BOI0GA-f.d.cts → bank.BCqBwSKC.d.cts} +23 -6
  15. package/dist/shared/{bank.BOI0GA-f.d.mts → bank.BCqBwSKC.d.mts} +23 -6
  16. package/dist/shared/{bank.BOI0GA-f.d.ts → bank.BCqBwSKC.d.ts} +23 -6
  17. package/dist/shared/{bank.qcrBpYcu.mjs → bank.BELDXSDV.mjs} +1 -1
  18. package/dist/shared/{bank.CL02VO9K.mjs → bank.BOMobxtA.mjs} +21 -14
  19. package/dist/shared/{bank.DDmes7Gx.d.ts → bank.BmX_IG66.d.ts} +1 -1
  20. package/dist/shared/{bank.DUd_XvqB.d.cts → bank.BnCJmT6k.d.mts} +1 -1
  21. package/dist/shared/{bank.Cfu7ZqyP.cjs → bank.CioJeFzf.cjs} +1 -1
  22. package/dist/shared/{bank.C2QV_SMx.cjs → bank.DiJmJkDt.cjs} +20 -12
  23. package/dist/shared/{bank.Dq24vYU7.d.cts → bank.DyZBd2qL.d.cts} +1 -0
  24. package/dist/shared/{bank.Dq24vYU7.d.mts → bank.DyZBd2qL.d.mts} +1 -0
  25. package/dist/shared/{bank.Dq24vYU7.d.ts → bank.DyZBd2qL.d.ts} +1 -0
  26. package/dist/shared/{bank.CT-uUhZB.d.mts → bank.mHFTrKBv.d.cts} +1 -1
  27. package/dist/types.cjs +2 -1
  28. package/dist/types.d.cts +5 -5
  29. package/dist/types.d.mts +5 -5
  30. package/dist/types.d.ts +5 -5
  31. package/dist/types.mjs +1 -1
  32. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import { bankAccountMetadataSchema, structuredAddressSchema, uuidv4, first, buildMultiFilterConditions as buildMultiFilterConditions$1, workflowInstanceStatusSchema, develitWorker, createInternalError, action, service } from '@develit-io/backend-sdk';
2
- import { B as tables, g as accountInsertSchema, G as relations, H as initiateConnector, o as isProcessedStatus, p as isTerminalStatus, J as getNonTerminalPaymentRequestsQuery, x as toIncomingPayment, j as assignAccount, u as toBatchedPayment, y as toPaymentRequestInsert, a as FinbricksClient, F as FINBRICKS_ENDPOINTS } from '../shared/bank.CL02VO9K.mjs';
2
+ import { G as tables, g as accountInsertSchema, H as relations, J as initiateConnector, o as isProcessedStatus, p as isTerminalStatus, L as getNonTerminalPaymentRequestsQuery, x as toIncomingPayment, j as assignAccount, u as toBatchedPayment, y as toPaymentRequestInsert, a as FinbricksClient, F as FINBRICKS_ENDPOINTS } from '../shared/bank.BOMobxtA.mjs';
3
3
  import { eq, sql, and, like, asc, desc, inArray, gte, lte, isNull, count } from 'drizzle-orm';
4
4
  import { WorkerEntrypoint } from 'cloudflare:workers';
5
5
  import { drizzle } from 'drizzle-orm/d1';
@@ -9,11 +9,10 @@ import { I as INSTRUCTION_PRIORITIES, C as CHARGE_BEARERS, g as PAYMENT_TYPES, b
9
9
  import { CURRENCY_CODES } from '@develit-io/general-codes';
10
10
  import 'date-fns';
11
11
  import 'node:crypto';
12
- import { h as encrypt, d as createCredentialsResolver, e as updatePaymentRequestStatusCommand, a as getPaymentRequestsByBatchIdQuery, g as getBatchByIdQuery, u as upsertBatchCommand, i as importAesKey, f as createPaymentCommand, b as getAccountByIdQuery } from '../shared/bank.qcrBpYcu.mjs';
12
+ import { h as encrypt, d as createCredentialsResolver, e as updatePaymentRequestStatusCommand, a as getPaymentRequestsByBatchIdQuery, g as getBatchByIdQuery, u as upsertBatchCommand, i as importAesKey, f as createPaymentCommand, b as getAccountByIdQuery } from '../shared/bank.BELDXSDV.mjs';
13
13
  import 'drizzle-orm/zod';
14
14
  import 'drizzle-orm/sqlite-core';
15
15
 
16
- const SYNC_WORKFLOW_HEARTBEAT_CRON = "0 */8 * * *";
17
16
  const DEAD_STATUSES = /* @__PURE__ */ new Set([
18
17
  "complete",
19
18
  "terminated",
@@ -814,6 +813,7 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
814
813
  const byConnector = Map.groupBy(allPRs, (pr) => pr.connectorKey);
815
814
  let processed = 0;
816
815
  let statusChanged = 0;
816
+ let skippedNoBankRefId = 0;
817
817
  const eventsToEmit = [];
818
818
  for (const [connectorKey, requests] of byConnector) {
819
819
  let connector;
@@ -826,10 +826,30 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
826
826
  continue;
827
827
  }
828
828
  for (const pr of requests) {
829
+ if (!pr.bankRefId && pr.connectorKey === "DBU") {
830
+ skippedNoBankRefId++;
831
+ console.warn(
832
+ "[_resolvePaymentRequestStatuses] Skipping DBU PR without bankRefId",
833
+ {
834
+ prId: pr.id,
835
+ status: pr.status,
836
+ connectorKey: pr.connectorKey,
837
+ createdAt: pr.createdAt
838
+ }
839
+ );
840
+ continue;
841
+ }
829
842
  try {
830
843
  const paymentId = pr.bankRefId ?? pr.id;
831
844
  const newStatus = await connector.getPaymentStatus({ paymentId });
832
845
  if (newStatus !== pr.status) {
846
+ console.log("[_resolvePaymentRequestStatuses] Status changed", {
847
+ prId: pr.id,
848
+ connectorKey: pr.connectorKey,
849
+ bankRefId: pr.bankRefId,
850
+ oldStatus: pr.status,
851
+ newStatus
852
+ });
833
853
  await updatePaymentRequestStatusCommand(this.db, {
834
854
  id: pr.id,
835
855
  status: newStatus,
@@ -842,17 +862,34 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
842
862
  }
843
863
  processed++;
844
864
  } catch (err) {
845
- this.logError({
846
- message: `Failed to resolve status for PR ${pr.id}: ${err}`
847
- });
865
+ console.error(
866
+ "[_resolvePaymentRequestStatuses] Failed to get payment status",
867
+ {
868
+ prId: pr.id,
869
+ connectorKey: pr.connectorKey,
870
+ status: pr.status,
871
+ bankRefId: pr.bankRefId,
872
+ error: err instanceof Error ? err.message : String(err)
873
+ }
874
+ );
848
875
  }
849
876
  }
850
877
  }
851
878
  if (eventsToEmit.length > 0) {
852
- await this.pushToQueue(
853
- this.env.QUEUE_BUS_QUEUE,
854
- eventsToEmit
855
- );
879
+ try {
880
+ await this.pushToQueue(
881
+ this.env.QUEUE_BUS_QUEUE,
882
+ eventsToEmit
883
+ );
884
+ } catch (err) {
885
+ console.error(
886
+ "[_resolvePaymentRequestStatuses] Failed to push events to queue",
887
+ {
888
+ eventCount: eventsToEmit.length,
889
+ error: err instanceof Error ? err.message : String(err)
890
+ }
891
+ );
892
+ }
856
893
  }
857
894
  const affectedBatchIds = [
858
895
  ...new Set(
@@ -860,7 +897,32 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
860
897
  )
861
898
  ];
862
899
  for (const batchId of affectedBatchIds) {
863
- await this._deriveBatchStatus(batchId);
900
+ try {
901
+ await this._deriveBatchStatus(batchId);
902
+ } catch (err) {
903
+ console.error(
904
+ "[_resolvePaymentRequestStatuses] Failed to derive batch status",
905
+ {
906
+ batchId,
907
+ error: err instanceof Error ? err.message : String(err)
908
+ }
909
+ );
910
+ }
911
+ }
912
+ console.log("[_resolvePaymentRequestStatuses] Summary", {
913
+ total: allPRs.length,
914
+ processed,
915
+ statusChanged,
916
+ skippedNoBankRefId
917
+ });
918
+ if (skippedNoBankRefId > 5) {
919
+ console.warn(
920
+ "[_resolvePaymentRequestStatuses] HIGH NUMBER of PRs without bankRefId",
921
+ {
922
+ count: skippedNoBankRefId,
923
+ note: "These PRs may be orphaned - payment sent but bankRefId not saved"
924
+ }
925
+ );
864
926
  }
865
927
  return { processed, statusChanged };
866
928
  }
@@ -875,8 +937,9 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
875
937
  if (!batch || batch.status === "COMPLETED" || batch.status === "FAILED")
876
938
  return;
877
939
  if (allPRs.length === 0) return;
940
+ const connectorKey = allPRs[0]?.connectorKey;
878
941
  const allTerminal = allPRs.every(
879
- (pr) => isTerminalStatus(pr.status)
942
+ (pr) => isTerminalStatus(pr.status, connectorKey)
880
943
  );
881
944
  const allAuthorizedOrHigher = allPRs.every((pr) => pr.status !== "OPENED");
882
945
  if (allTerminal) {
@@ -897,16 +960,49 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
897
960
  null,
898
961
  { successMessage: "Payment request statuses updated" },
899
962
  async () => {
963
+ const startTime = Date.now();
964
+ console.log("[updatePaymentRequestStatuses] Starting", {
965
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
966
+ });
900
967
  const nonTerminalPRs = await getNonTerminalPaymentRequestsQuery(this.db);
901
968
  if (nonTerminalPRs.length === 0) {
969
+ console.log(
970
+ "[updatePaymentRequestStatuses] No non-terminal PRs found",
971
+ {
972
+ duration: `${Date.now() - startTime}ms`
973
+ }
974
+ );
902
975
  return { processed: 0, statusChanged: 0 };
903
976
  }
977
+ const byConnector = nonTerminalPRs.reduce(
978
+ (acc, pr) => {
979
+ const key = pr.connectorKey || "unknown";
980
+ acc[key] = (acc[key] || 0) + 1;
981
+ return acc;
982
+ },
983
+ {}
984
+ );
985
+ console.log("[updatePaymentRequestStatuses] By connector", byConnector);
904
986
  const now = Date.now();
905
987
  const pollableIds = [];
906
988
  for (const pr of nonTerminalPRs) {
907
989
  const status = pr.status;
990
+ if (isTerminalStatus(status, pr.connectorKey)) {
991
+ continue;
992
+ }
908
993
  if (status === "OPENED" || status === "AUTHORIZED") {
909
994
  if (pr.createdAt != null && now - pr.createdAt.getTime() > this.POLLING_TIMEOUT_MS) {
995
+ console.warn(
996
+ "[updatePaymentRequestStatuses] Closing PR due to timeout",
997
+ {
998
+ prId: pr.id,
999
+ status: pr.status,
1000
+ connectorKey: pr.connectorKey,
1001
+ createdAt: pr.createdAt,
1002
+ bankRefId: pr.bankRefId,
1003
+ age: `${Math.floor((now - pr.createdAt.getTime()) / (24 * 60 * 60 * 1e3))} days`
1004
+ }
1005
+ );
910
1006
  await updatePaymentRequestStatusCommand(this.db, {
911
1007
  id: pr.id,
912
1008
  status: "CLOSED",
@@ -916,14 +1012,20 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
916
1012
  continue;
917
1013
  }
918
1014
  pollableIds.push(pr.id);
919
- } else if (status === "COMPLETED" || status === "BOOKED") {
920
- if (pr.processedAt != null && now - pr.processedAt.getTime() > this.COMPLETED_POLLING_WINDOW_MS) {
921
- continue;
922
- }
923
- pollableIds.push(pr.id);
924
1015
  }
925
1016
  }
926
- return this._resolvePaymentRequestStatuses(pollableIds);
1017
+ const result = await this._resolvePaymentRequestStatuses(pollableIds);
1018
+ const duration = Date.now() - startTime;
1019
+ console.log("[updatePaymentRequestStatuses] Completed", {
1020
+ duration: `${duration}ms`,
1021
+ metrics: {
1022
+ total: nonTerminalPRs.length,
1023
+ polled: pollableIds.length,
1024
+ processed: result.processed,
1025
+ statusChanged: result.statusChanged
1026
+ }
1027
+ });
1028
+ return result;
927
1029
  }
928
1030
  );
929
1031
  }
@@ -933,7 +1035,7 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
933
1035
  await this.updatePaymentRequestStatuses();
934
1036
  return;
935
1037
  }
936
- if (controller.cron === SYNC_WORKFLOW_HEARTBEAT_CRON) {
1038
+ if (controller.cron === this.env.CRON_SYNC_WORKFLOW_HEARTBEAT) {
937
1039
  console.log("Scheduled CRON sync workflow heartbeat");
938
1040
  await this.heartbeatSyncWorkflows();
939
1041
  }
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  const backendSdk = require('@develit-io/backend-sdk');
4
- const ott_zod = require('../shared/bank.C2QV_SMx.cjs');
4
+ const ott_zod = require('../shared/bank.DiJmJkDt.cjs');
5
5
  const batchLifecycle = require('../shared/bank.NF8bZBy0.cjs');
6
6
  const drizzleOrm = require('drizzle-orm');
7
- const credentialsResolver = require('../shared/bank.Cfu7ZqyP.cjs');
7
+ const credentialsResolver = require('../shared/bank.CioJeFzf.cjs');
8
8
  const cloudflare_workers = require('cloudflare:workers');
9
9
  const cloudflare_workflows = require('cloudflare:workflows');
10
10
  const d1 = require('drizzle-orm/d1');
@@ -1,8 +1,8 @@
1
1
  import { first, uuidv4, asNonEmpty } from '@develit-io/backend-sdk';
2
- import { B as tables, G as relations, v as toBatchedPaymentFromPaymentRequest, z as toPreparedPayment, H as initiateConnector, m as isPaymentCompleted } from '../shared/bank.CL02VO9K.mjs';
2
+ import { G as tables, H as relations, v as toBatchedPaymentFromPaymentRequest, z as toPreparedPayment, J as initiateConnector, m as isPaymentCompleted } from '../shared/bank.BOMobxtA.mjs';
3
3
  import { i as isBatchAuthorized, b as isBatchFailed, d as isBatchProcessing } from '../shared/bank.XqSw509X.mjs';
4
4
  import { eq, and, inArray } from 'drizzle-orm';
5
- import { 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.qcrBpYcu.mjs';
5
+ import { 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.BELDXSDV.mjs';
6
6
  import { WorkflowEntrypoint } from 'cloudflare:workers';
7
7
  import { NonRetryableError } from 'cloudflare:workflows';
8
8
  import { drizzle } from 'drizzle-orm/d1';
@@ -1,4 +1,4 @@
1
- import { B as BankServiceWranglerConfig } from '../shared/bank.Dq24vYU7.cjs';
1
+ import { B as BankServiceWranglerConfig } from '../shared/bank.DyZBd2qL.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_PAYMENT_STATUSES: string;
12
+ CRON_SYNC_WORKFLOW_HEARTBEAT: 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.Dq24vYU7.mjs';
1
+ import { B as BankServiceWranglerConfig } from '../shared/bank.DyZBd2qL.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_PAYMENT_STATUSES: string;
12
+ CRON_SYNC_WORKFLOW_HEARTBEAT: 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.Dq24vYU7.js';
1
+ import { B as BankServiceWranglerConfig } from '../shared/bank.DyZBd2qL.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_PAYMENT_STATUSES: string;
12
+ CRON_SYNC_WORKFLOW_HEARTBEAT: string;
12
13
  BANK_AUTH_RECIPIENT: string;
13
14
  DBUCS_BASE_URI: string;
14
15
  DBUCS_USERNAME: string;
@@ -1943,7 +1943,24 @@ type AccountSelectType = z.infer<typeof accountSelectSchema>;
1943
1943
  * 5. CompletedPayment - Fully processed (status: COMPLETED/BOOKED/SETTLED/REJECTED/CLOSED, has bankRefId)
1944
1944
  */
1945
1945
 
1946
- declare function isTerminalStatus(status: PaymentRequestStatus): boolean;
1946
+ /**
1947
+ * Base terminal statuses - apply to ALL connectors
1948
+ * Exported for use in database queries (connector-agnostic filtering)
1949
+ */
1950
+ declare const BASE_TERMINAL_STATUSES: ReadonlySet<PaymentRequestStatus>;
1951
+ /**
1952
+ * Check if status is terminal for given connector
1953
+ *
1954
+ * @param status - Payment request status to check
1955
+ * @param connectorKey - Optional connector key for connector-specific terminals
1956
+ * @returns true if status is terminal (no more polling needed)
1957
+ *
1958
+ * @example
1959
+ * isTerminalStatus('COMPLETED', 'DBU') // true - DBU-specific terminal
1960
+ * isTerminalStatus('COMPLETED', 'FINBRICKS') // false - not terminal for Finbricks
1961
+ * isTerminalStatus('SETTLED', 'DBU') // true - base terminal for all
1962
+ */
1963
+ declare function isTerminalStatus(status: PaymentRequestStatus, connectorKey?: string): boolean;
1947
1964
  declare function isPendingStatus(status: PaymentRequestStatus): boolean;
1948
1965
  declare function isProcessedStatus(status: PaymentRequestStatus): boolean;
1949
1966
  /**
@@ -2127,7 +2144,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2127
2144
  name: string;
2128
2145
  tableName: "batch";
2129
2146
  dataType: "string enum";
2130
- data: "AUTHORIZED" | "PROCESSING" | "READY_TO_SIGN" | "COMPLETED" | "FAILED";
2147
+ data: "AUTHORIZED" | "COMPLETED" | "PROCESSING" | "READY_TO_SIGN" | "FAILED";
2131
2148
  driverParam: string;
2132
2149
  notNull: false;
2133
2150
  hasDefault: false;
@@ -2398,7 +2415,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2398
2415
  name: string;
2399
2416
  tableName: "payment";
2400
2417
  dataType: "string enum";
2401
- data: "PROCESSING" | "PENDING" | "BOOKED" | "CANCELLED" | "REJECTED" | "SCHEDULED" | "HOLD" | "INFO";
2418
+ data: "BOOKED" | "REJECTED" | "PENDING" | "PROCESSING" | "CANCELLED" | "SCHEDULED" | "HOLD" | "INFO";
2402
2419
  driverParam: string;
2403
2420
  notNull: true;
2404
2421
  hasDefault: false;
@@ -2797,7 +2814,7 @@ declare const paymentRequest: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2797
2814
  name: string;
2798
2815
  tableName: "payment_request";
2799
2816
  dataType: "string enum";
2800
- data: "AUTHORIZED" | "COMPLETED" | "BOOKED" | "REJECTED" | "OPENED" | "SETTLED" | "CLOSED";
2817
+ data: "AUTHORIZED" | "OPENED" | "COMPLETED" | "BOOKED" | "SETTLED" | "REJECTED" | "CLOSED";
2801
2818
  driverParam: string;
2802
2819
  notNull: true;
2803
2820
  hasDefault: false;
@@ -3508,5 +3525,5 @@ type ParsedBankPayment = {
3508
3525
  */
3509
3526
  type BatchPayment = Omit<PaymentInsertType, 'bankRefId'>;
3510
3527
 
3511
- export { IBankConnector as I, BATCH_MODES as M, BATCH_STATUSES as N, CHARGE_BEARERS as W, CONNECTOR_KEYS as X, COUNTRY_CODES as Y, CREDENTIALS_TYPES as Z, INSTRUCTION_PRIORITIES as a2, PAYMENT_DIRECTIONS as a4, PAYMENT_REQUEST_STATUSES as a5, PAYMENT_STATUSES as a6, PAYMENT_TYPES as a7, account as aA, accountCredentials as aB, batch as aC, ott as aD, payment as aE, paymentRequest as aF, TOKEN_TYPES as ah, accountCredentialsInsertSchema as aj, accountCredentialsSelectSchema as ak, accountCredentialsUpdateSchema as al, accountInsertSchema as am, accountSelectSchema as an, accountUpdateSchema as ao, hasPaymentAccountAssigned as ap, isBatchAuthorized as aq, isBatchCompleted as ar, isBatchFailed as as, isBatchInitiated as at, isBatchProcessing as au, isBatchReadyToSign as av, isPaymentCompleted as aw, isPendingStatus as ax, isProcessedStatus as ay, isTerminalStatus as az, tables as t, ACCOUNT_STATUSES as y };
3512
- export type { CompletedBatch as $, AccountSelectType as A, BatchSelectType as B, ConnectorConfig as C, AccountCredentialsSelectType as D, AccountCredentialsUpdateType as E, AccountPatchType as F, AccountStatus as G, HandleAuthorizationCallbackInput as H, AccountUpdateType as J, AuthorizedBatch as K, LastSyncMetadata as L, BankAccountWithLastSync as O, PaymentRequestSelectType as P, BankCode as Q, BatchInsertType as R, BatchLifecycle as S, BatchMode as T, BatchPayment as U, BatchStatus as V, ChargeBearer as _, PaymentSelectType as a, CountryCode as a0, CredentialsType as a1, InstructionPriority as a3, PaymentDirection as a8, PaymentFailedInsertType as a9, PaymentInsertType as aa, PaymentLifecycle as ab, PaymentPreparedInsertType as ac, PaymentStatus as ad, ProcessingBatch as ae, ReadyToSignBatch as af, ResolvedCredentials as ag, TokenType as ai, ConfigEnvironmentBank as b, ConnectorKey as c, PaymentType as d, CurrencyCode as e, HandleAuthorizationCallbackOutput as f, ConnectedAccount as g, CredentialsResolver as h, AccountCredentialsInsertType as i, AccountInsertType as j, BatchedPayment as k, InitiatedBatch as l, IncomingPayment as m, InitiatedPayment as n, ParsedBankPayment as o, PaymentRequestStatus as p, AuthorizationCallbackResult as q, BatchMetadata as r, Currency as s, AccountAssignedPayment as u, PreparedPayment as v, CompletedPayment as w, PaymentRequestInsertType as x, AccountCredentialsPatchType as z };
3528
+ export { IBankConnector as I, BASE_TERMINAL_STATUSES as M, BATCH_MODES as N, BATCH_STATUSES as O, CHARGE_BEARERS as X, CONNECTOR_KEYS as Y, COUNTRY_CODES as Z, CREDENTIALS_TYPES as _, INSTRUCTION_PRIORITIES as a3, PAYMENT_DIRECTIONS as a5, PAYMENT_REQUEST_STATUSES as a6, PAYMENT_STATUSES as a7, PAYMENT_TYPES as a8, isTerminalStatus as aA, account as aB, accountCredentials as aC, batch as aD, ott as aE, payment as aF, paymentRequest as aG, TOKEN_TYPES as ai, accountCredentialsInsertSchema as ak, accountCredentialsSelectSchema as al, accountCredentialsUpdateSchema as am, accountInsertSchema as an, accountSelectSchema as ao, accountUpdateSchema as ap, hasPaymentAccountAssigned as aq, isBatchAuthorized as ar, isBatchCompleted as as, isBatchFailed as at, isBatchInitiated as au, isBatchProcessing as av, isBatchReadyToSign as aw, isPaymentCompleted as ax, isPendingStatus as ay, isProcessedStatus as az, tables as t, ACCOUNT_STATUSES as y };
3529
+ export type { ChargeBearer as $, AccountSelectType as A, BatchSelectType as B, ConnectorConfig as C, AccountCredentialsSelectType as D, AccountCredentialsUpdateType as E, AccountPatchType as F, AccountStatus as G, HandleAuthorizationCallbackInput as H, AccountUpdateType as J, AuthorizedBatch as K, LastSyncMetadata as L, PaymentRequestSelectType as P, BankAccountWithLastSync as Q, BankCode as R, BatchInsertType as S, BatchLifecycle as T, BatchMode as U, BatchPayment as V, BatchStatus as W, PaymentSelectType as a, CompletedBatch as a0, CountryCode as a1, CredentialsType as a2, InstructionPriority as a4, PaymentDirection as a9, PaymentFailedInsertType as aa, PaymentInsertType as ab, PaymentLifecycle as ac, PaymentPreparedInsertType as ad, PaymentStatus as ae, ProcessingBatch as af, ReadyToSignBatch as ag, ResolvedCredentials as ah, TokenType as aj, ConfigEnvironmentBank as b, ConnectorKey as c, PaymentType as d, CurrencyCode as e, HandleAuthorizationCallbackOutput as f, ConnectedAccount as g, CredentialsResolver as h, AccountCredentialsInsertType as i, AccountInsertType as j, BatchedPayment as k, InitiatedBatch as l, IncomingPayment as m, InitiatedPayment as n, ParsedBankPayment as o, PaymentRequestStatus as p, AuthorizationCallbackResult as q, BatchMetadata as r, Currency as s, AccountAssignedPayment as u, PreparedPayment as v, CompletedPayment as w, PaymentRequestInsertType as x, AccountCredentialsPatchType as z };
@@ -1943,7 +1943,24 @@ type AccountSelectType = z.infer<typeof accountSelectSchema>;
1943
1943
  * 5. CompletedPayment - Fully processed (status: COMPLETED/BOOKED/SETTLED/REJECTED/CLOSED, has bankRefId)
1944
1944
  */
1945
1945
 
1946
- declare function isTerminalStatus(status: PaymentRequestStatus): boolean;
1946
+ /**
1947
+ * Base terminal statuses - apply to ALL connectors
1948
+ * Exported for use in database queries (connector-agnostic filtering)
1949
+ */
1950
+ declare const BASE_TERMINAL_STATUSES: ReadonlySet<PaymentRequestStatus>;
1951
+ /**
1952
+ * Check if status is terminal for given connector
1953
+ *
1954
+ * @param status - Payment request status to check
1955
+ * @param connectorKey - Optional connector key for connector-specific terminals
1956
+ * @returns true if status is terminal (no more polling needed)
1957
+ *
1958
+ * @example
1959
+ * isTerminalStatus('COMPLETED', 'DBU') // true - DBU-specific terminal
1960
+ * isTerminalStatus('COMPLETED', 'FINBRICKS') // false - not terminal for Finbricks
1961
+ * isTerminalStatus('SETTLED', 'DBU') // true - base terminal for all
1962
+ */
1963
+ declare function isTerminalStatus(status: PaymentRequestStatus, connectorKey?: string): boolean;
1947
1964
  declare function isPendingStatus(status: PaymentRequestStatus): boolean;
1948
1965
  declare function isProcessedStatus(status: PaymentRequestStatus): boolean;
1949
1966
  /**
@@ -2127,7 +2144,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2127
2144
  name: string;
2128
2145
  tableName: "batch";
2129
2146
  dataType: "string enum";
2130
- data: "AUTHORIZED" | "PROCESSING" | "READY_TO_SIGN" | "COMPLETED" | "FAILED";
2147
+ data: "AUTHORIZED" | "COMPLETED" | "PROCESSING" | "READY_TO_SIGN" | "FAILED";
2131
2148
  driverParam: string;
2132
2149
  notNull: false;
2133
2150
  hasDefault: false;
@@ -2398,7 +2415,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2398
2415
  name: string;
2399
2416
  tableName: "payment";
2400
2417
  dataType: "string enum";
2401
- data: "PROCESSING" | "PENDING" | "BOOKED" | "CANCELLED" | "REJECTED" | "SCHEDULED" | "HOLD" | "INFO";
2418
+ data: "BOOKED" | "REJECTED" | "PENDING" | "PROCESSING" | "CANCELLED" | "SCHEDULED" | "HOLD" | "INFO";
2402
2419
  driverParam: string;
2403
2420
  notNull: true;
2404
2421
  hasDefault: false;
@@ -2797,7 +2814,7 @@ declare const paymentRequest: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2797
2814
  name: string;
2798
2815
  tableName: "payment_request";
2799
2816
  dataType: "string enum";
2800
- data: "AUTHORIZED" | "COMPLETED" | "BOOKED" | "REJECTED" | "OPENED" | "SETTLED" | "CLOSED";
2817
+ data: "AUTHORIZED" | "OPENED" | "COMPLETED" | "BOOKED" | "SETTLED" | "REJECTED" | "CLOSED";
2801
2818
  driverParam: string;
2802
2819
  notNull: true;
2803
2820
  hasDefault: false;
@@ -3508,5 +3525,5 @@ type ParsedBankPayment = {
3508
3525
  */
3509
3526
  type BatchPayment = Omit<PaymentInsertType, 'bankRefId'>;
3510
3527
 
3511
- export { IBankConnector as I, BATCH_MODES as M, BATCH_STATUSES as N, CHARGE_BEARERS as W, CONNECTOR_KEYS as X, COUNTRY_CODES as Y, CREDENTIALS_TYPES as Z, INSTRUCTION_PRIORITIES as a2, PAYMENT_DIRECTIONS as a4, PAYMENT_REQUEST_STATUSES as a5, PAYMENT_STATUSES as a6, PAYMENT_TYPES as a7, account as aA, accountCredentials as aB, batch as aC, ott as aD, payment as aE, paymentRequest as aF, TOKEN_TYPES as ah, accountCredentialsInsertSchema as aj, accountCredentialsSelectSchema as ak, accountCredentialsUpdateSchema as al, accountInsertSchema as am, accountSelectSchema as an, accountUpdateSchema as ao, hasPaymentAccountAssigned as ap, isBatchAuthorized as aq, isBatchCompleted as ar, isBatchFailed as as, isBatchInitiated as at, isBatchProcessing as au, isBatchReadyToSign as av, isPaymentCompleted as aw, isPendingStatus as ax, isProcessedStatus as ay, isTerminalStatus as az, tables as t, ACCOUNT_STATUSES as y };
3512
- export type { CompletedBatch as $, AccountSelectType as A, BatchSelectType as B, ConnectorConfig as C, AccountCredentialsSelectType as D, AccountCredentialsUpdateType as E, AccountPatchType as F, AccountStatus as G, HandleAuthorizationCallbackInput as H, AccountUpdateType as J, AuthorizedBatch as K, LastSyncMetadata as L, BankAccountWithLastSync as O, PaymentRequestSelectType as P, BankCode as Q, BatchInsertType as R, BatchLifecycle as S, BatchMode as T, BatchPayment as U, BatchStatus as V, ChargeBearer as _, PaymentSelectType as a, CountryCode as a0, CredentialsType as a1, InstructionPriority as a3, PaymentDirection as a8, PaymentFailedInsertType as a9, PaymentInsertType as aa, PaymentLifecycle as ab, PaymentPreparedInsertType as ac, PaymentStatus as ad, ProcessingBatch as ae, ReadyToSignBatch as af, ResolvedCredentials as ag, TokenType as ai, ConfigEnvironmentBank as b, ConnectorKey as c, PaymentType as d, CurrencyCode as e, HandleAuthorizationCallbackOutput as f, ConnectedAccount as g, CredentialsResolver as h, AccountCredentialsInsertType as i, AccountInsertType as j, BatchedPayment as k, InitiatedBatch as l, IncomingPayment as m, InitiatedPayment as n, ParsedBankPayment as o, PaymentRequestStatus as p, AuthorizationCallbackResult as q, BatchMetadata as r, Currency as s, AccountAssignedPayment as u, PreparedPayment as v, CompletedPayment as w, PaymentRequestInsertType as x, AccountCredentialsPatchType as z };
3528
+ export { IBankConnector as I, BASE_TERMINAL_STATUSES as M, BATCH_MODES as N, BATCH_STATUSES as O, CHARGE_BEARERS as X, CONNECTOR_KEYS as Y, COUNTRY_CODES as Z, CREDENTIALS_TYPES as _, INSTRUCTION_PRIORITIES as a3, PAYMENT_DIRECTIONS as a5, PAYMENT_REQUEST_STATUSES as a6, PAYMENT_STATUSES as a7, PAYMENT_TYPES as a8, isTerminalStatus as aA, account as aB, accountCredentials as aC, batch as aD, ott as aE, payment as aF, paymentRequest as aG, TOKEN_TYPES as ai, accountCredentialsInsertSchema as ak, accountCredentialsSelectSchema as al, accountCredentialsUpdateSchema as am, accountInsertSchema as an, accountSelectSchema as ao, accountUpdateSchema as ap, hasPaymentAccountAssigned as aq, isBatchAuthorized as ar, isBatchCompleted as as, isBatchFailed as at, isBatchInitiated as au, isBatchProcessing as av, isBatchReadyToSign as aw, isPaymentCompleted as ax, isPendingStatus as ay, isProcessedStatus as az, tables as t, ACCOUNT_STATUSES as y };
3529
+ export type { ChargeBearer as $, AccountSelectType as A, BatchSelectType as B, ConnectorConfig as C, AccountCredentialsSelectType as D, AccountCredentialsUpdateType as E, AccountPatchType as F, AccountStatus as G, HandleAuthorizationCallbackInput as H, AccountUpdateType as J, AuthorizedBatch as K, LastSyncMetadata as L, PaymentRequestSelectType as P, BankAccountWithLastSync as Q, BankCode as R, BatchInsertType as S, BatchLifecycle as T, BatchMode as U, BatchPayment as V, BatchStatus as W, PaymentSelectType as a, CompletedBatch as a0, CountryCode as a1, CredentialsType as a2, InstructionPriority as a4, PaymentDirection as a9, PaymentFailedInsertType as aa, PaymentInsertType as ab, PaymentLifecycle as ac, PaymentPreparedInsertType as ad, PaymentStatus as ae, ProcessingBatch as af, ReadyToSignBatch as ag, ResolvedCredentials as ah, TokenType as aj, ConfigEnvironmentBank as b, ConnectorKey as c, PaymentType as d, CurrencyCode as e, HandleAuthorizationCallbackOutput as f, ConnectedAccount as g, CredentialsResolver as h, AccountCredentialsInsertType as i, AccountInsertType as j, BatchedPayment as k, InitiatedBatch as l, IncomingPayment as m, InitiatedPayment as n, ParsedBankPayment as o, PaymentRequestStatus as p, AuthorizationCallbackResult as q, BatchMetadata as r, Currency as s, AccountAssignedPayment as u, PreparedPayment as v, CompletedPayment as w, PaymentRequestInsertType as x, AccountCredentialsPatchType as z };
@@ -1943,7 +1943,24 @@ type AccountSelectType = z.infer<typeof accountSelectSchema>;
1943
1943
  * 5. CompletedPayment - Fully processed (status: COMPLETED/BOOKED/SETTLED/REJECTED/CLOSED, has bankRefId)
1944
1944
  */
1945
1945
 
1946
- declare function isTerminalStatus(status: PaymentRequestStatus): boolean;
1946
+ /**
1947
+ * Base terminal statuses - apply to ALL connectors
1948
+ * Exported for use in database queries (connector-agnostic filtering)
1949
+ */
1950
+ declare const BASE_TERMINAL_STATUSES: ReadonlySet<PaymentRequestStatus>;
1951
+ /**
1952
+ * Check if status is terminal for given connector
1953
+ *
1954
+ * @param status - Payment request status to check
1955
+ * @param connectorKey - Optional connector key for connector-specific terminals
1956
+ * @returns true if status is terminal (no more polling needed)
1957
+ *
1958
+ * @example
1959
+ * isTerminalStatus('COMPLETED', 'DBU') // true - DBU-specific terminal
1960
+ * isTerminalStatus('COMPLETED', 'FINBRICKS') // false - not terminal for Finbricks
1961
+ * isTerminalStatus('SETTLED', 'DBU') // true - base terminal for all
1962
+ */
1963
+ declare function isTerminalStatus(status: PaymentRequestStatus, connectorKey?: string): boolean;
1947
1964
  declare function isPendingStatus(status: PaymentRequestStatus): boolean;
1948
1965
  declare function isProcessedStatus(status: PaymentRequestStatus): boolean;
1949
1966
  /**
@@ -2127,7 +2144,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2127
2144
  name: string;
2128
2145
  tableName: "batch";
2129
2146
  dataType: "string enum";
2130
- data: "AUTHORIZED" | "PROCESSING" | "READY_TO_SIGN" | "COMPLETED" | "FAILED";
2147
+ data: "AUTHORIZED" | "COMPLETED" | "PROCESSING" | "READY_TO_SIGN" | "FAILED";
2131
2148
  driverParam: string;
2132
2149
  notNull: false;
2133
2150
  hasDefault: false;
@@ -2398,7 +2415,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2398
2415
  name: string;
2399
2416
  tableName: "payment";
2400
2417
  dataType: "string enum";
2401
- data: "PROCESSING" | "PENDING" | "BOOKED" | "CANCELLED" | "REJECTED" | "SCHEDULED" | "HOLD" | "INFO";
2418
+ data: "BOOKED" | "REJECTED" | "PENDING" | "PROCESSING" | "CANCELLED" | "SCHEDULED" | "HOLD" | "INFO";
2402
2419
  driverParam: string;
2403
2420
  notNull: true;
2404
2421
  hasDefault: false;
@@ -2797,7 +2814,7 @@ declare const paymentRequest: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
2797
2814
  name: string;
2798
2815
  tableName: "payment_request";
2799
2816
  dataType: "string enum";
2800
- data: "AUTHORIZED" | "COMPLETED" | "BOOKED" | "REJECTED" | "OPENED" | "SETTLED" | "CLOSED";
2817
+ data: "AUTHORIZED" | "OPENED" | "COMPLETED" | "BOOKED" | "SETTLED" | "REJECTED" | "CLOSED";
2801
2818
  driverParam: string;
2802
2819
  notNull: true;
2803
2820
  hasDefault: false;
@@ -3508,5 +3525,5 @@ type ParsedBankPayment = {
3508
3525
  */
3509
3526
  type BatchPayment = Omit<PaymentInsertType, 'bankRefId'>;
3510
3527
 
3511
- export { IBankConnector as I, BATCH_MODES as M, BATCH_STATUSES as N, CHARGE_BEARERS as W, CONNECTOR_KEYS as X, COUNTRY_CODES as Y, CREDENTIALS_TYPES as Z, INSTRUCTION_PRIORITIES as a2, PAYMENT_DIRECTIONS as a4, PAYMENT_REQUEST_STATUSES as a5, PAYMENT_STATUSES as a6, PAYMENT_TYPES as a7, account as aA, accountCredentials as aB, batch as aC, ott as aD, payment as aE, paymentRequest as aF, TOKEN_TYPES as ah, accountCredentialsInsertSchema as aj, accountCredentialsSelectSchema as ak, accountCredentialsUpdateSchema as al, accountInsertSchema as am, accountSelectSchema as an, accountUpdateSchema as ao, hasPaymentAccountAssigned as ap, isBatchAuthorized as aq, isBatchCompleted as ar, isBatchFailed as as, isBatchInitiated as at, isBatchProcessing as au, isBatchReadyToSign as av, isPaymentCompleted as aw, isPendingStatus as ax, isProcessedStatus as ay, isTerminalStatus as az, tables as t, ACCOUNT_STATUSES as y };
3512
- export type { CompletedBatch as $, AccountSelectType as A, BatchSelectType as B, ConnectorConfig as C, AccountCredentialsSelectType as D, AccountCredentialsUpdateType as E, AccountPatchType as F, AccountStatus as G, HandleAuthorizationCallbackInput as H, AccountUpdateType as J, AuthorizedBatch as K, LastSyncMetadata as L, BankAccountWithLastSync as O, PaymentRequestSelectType as P, BankCode as Q, BatchInsertType as R, BatchLifecycle as S, BatchMode as T, BatchPayment as U, BatchStatus as V, ChargeBearer as _, PaymentSelectType as a, CountryCode as a0, CredentialsType as a1, InstructionPriority as a3, PaymentDirection as a8, PaymentFailedInsertType as a9, PaymentInsertType as aa, PaymentLifecycle as ab, PaymentPreparedInsertType as ac, PaymentStatus as ad, ProcessingBatch as ae, ReadyToSignBatch as af, ResolvedCredentials as ag, TokenType as ai, ConfigEnvironmentBank as b, ConnectorKey as c, PaymentType as d, CurrencyCode as e, HandleAuthorizationCallbackOutput as f, ConnectedAccount as g, CredentialsResolver as h, AccountCredentialsInsertType as i, AccountInsertType as j, BatchedPayment as k, InitiatedBatch as l, IncomingPayment as m, InitiatedPayment as n, ParsedBankPayment as o, PaymentRequestStatus as p, AuthorizationCallbackResult as q, BatchMetadata as r, Currency as s, AccountAssignedPayment as u, PreparedPayment as v, CompletedPayment as w, PaymentRequestInsertType as x, AccountCredentialsPatchType as z };
3528
+ export { IBankConnector as I, BASE_TERMINAL_STATUSES as M, BATCH_MODES as N, BATCH_STATUSES as O, CHARGE_BEARERS as X, CONNECTOR_KEYS as Y, COUNTRY_CODES as Z, CREDENTIALS_TYPES as _, INSTRUCTION_PRIORITIES as a3, PAYMENT_DIRECTIONS as a5, PAYMENT_REQUEST_STATUSES as a6, PAYMENT_STATUSES as a7, PAYMENT_TYPES as a8, isTerminalStatus as aA, account as aB, accountCredentials as aC, batch as aD, ott as aE, payment as aF, paymentRequest as aG, TOKEN_TYPES as ai, accountCredentialsInsertSchema as ak, accountCredentialsSelectSchema as al, accountCredentialsUpdateSchema as am, accountInsertSchema as an, accountSelectSchema as ao, accountUpdateSchema as ap, hasPaymentAccountAssigned as aq, isBatchAuthorized as ar, isBatchCompleted as as, isBatchFailed as at, isBatchInitiated as au, isBatchProcessing as av, isBatchReadyToSign as aw, isPaymentCompleted as ax, isPendingStatus as ay, isProcessedStatus as az, tables as t, ACCOUNT_STATUSES as y };
3529
+ export type { ChargeBearer as $, AccountSelectType as A, BatchSelectType as B, ConnectorConfig as C, AccountCredentialsSelectType as D, AccountCredentialsUpdateType as E, AccountPatchType as F, AccountStatus as G, HandleAuthorizationCallbackInput as H, AccountUpdateType as J, AuthorizedBatch as K, LastSyncMetadata as L, PaymentRequestSelectType as P, BankAccountWithLastSync as Q, BankCode as R, BatchInsertType as S, BatchLifecycle as T, BatchMode as U, BatchPayment as V, BatchStatus as W, PaymentSelectType as a, CompletedBatch as a0, CountryCode as a1, CredentialsType as a2, InstructionPriority as a4, PaymentDirection as a9, PaymentFailedInsertType as aa, PaymentInsertType as ab, PaymentLifecycle as ac, PaymentPreparedInsertType as ad, PaymentStatus as ae, ProcessingBatch as af, ReadyToSignBatch as ag, ResolvedCredentials as ah, TokenType as aj, ConfigEnvironmentBank as b, ConnectorKey as c, PaymentType as d, CurrencyCode as e, HandleAuthorizationCallbackOutput as f, ConnectedAccount as g, CredentialsResolver as h, AccountCredentialsInsertType as i, AccountInsertType as j, BatchedPayment as k, InitiatedBatch as l, IncomingPayment as m, InitiatedPayment as n, ParsedBankPayment as o, PaymentRequestStatus as p, AuthorizationCallbackResult as q, BatchMetadata as r, Currency as s, AccountAssignedPayment as u, PreparedPayment as v, CompletedPayment as w, PaymentRequestInsertType as x, AccountCredentialsPatchType as z };
@@ -1,5 +1,5 @@
1
1
  import { sql, and, eq, isNull } from 'drizzle-orm';
2
- import { B as tables } from './bank.CL02VO9K.mjs';
2
+ import { G as tables } from './bank.BOMobxtA.mjs';
3
3
  import { uuidv4 } from '@develit-io/backend-sdk';
4
4
  import './bank.BzDNLxB_.mjs';
5
5
  import 'date-fns';
@@ -3,7 +3,7 @@ import { format, parseISO } from 'date-fns';
3
3
  import { importPKCS8, SignJWT } from 'jose';
4
4
  import { z } from 'zod';
5
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';
6
+ import { s as schema, h as account, i as accountCredentials, o as ott } from './bank.BzDNLxB_.mjs';
7
7
  import { defineRelations, and, not, inArray, isNull } from 'drizzle-orm';
8
8
  import { createInsertSchema, createUpdateSchema, createSelectSchema } from 'drizzle-orm/zod';
9
9
  import 'node:crypto';
@@ -182,17 +182,24 @@ const FINBRICKS_ENDPOINTS = {
182
182
  BANK_INFO: "/status/bankInfo"
183
183
  };
184
184
 
185
- const TERMINAL_STATUSES$1 = /* @__PURE__ */ new Set([
186
- "SETTLED",
187
- "REJECTED",
188
- "CLOSED"
189
- ]);
185
+ const BASE_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["SETTLED", "REJECTED", "CLOSED"]);
186
+ const CONNECTOR_TERMINAL_STATUSES = {
187
+ DBU: /* @__PURE__ */ new Set(["COMPLETED", "BOOKED"])
188
+ // Finbricks: uses BASE only (polls until SETTLED)
189
+ // ERSTE: uses BASE only
190
+ };
190
191
  const PENDING_STATUSES = /* @__PURE__ */ new Set([
191
192
  "OPENED",
192
193
  "AUTHORIZED"
193
194
  ]);
194
- function isTerminalStatus(status) {
195
- return TERMINAL_STATUSES$1.has(status);
195
+ function isTerminalStatus(status, connectorKey) {
196
+ if (BASE_TERMINAL_STATUSES.has(status)) {
197
+ return true;
198
+ }
199
+ if (connectorKey && CONNECTOR_TERMINAL_STATUSES[connectorKey]) {
200
+ return CONNECTOR_TERMINAL_STATUSES[connectorKey].has(status);
201
+ }
202
+ return false;
196
203
  }
197
204
  function isPendingStatus(status) {
198
205
  return PENDING_STATUSES.has(status);
@@ -1630,10 +1637,10 @@ class DbuConnector extends IBankConnector {
1630
1637
  case "15":
1631
1638
  // RQT_STATUS_REJECTED
1632
1639
  case "33":
1633
- // RQT_STATUS_HD_CANCELLED
1634
- case "39":
1635
1640
  return "REJECTED";
1636
1641
  // AUTHORIZED - All other processing states
1642
+ // Note: RQT_STATUS_CNC_CLEARING (39) is NOT terminal per corebanking team (2026-05-12)
1643
+ // It's a request for cancellation from clearing, not a final state - falls through to default
1637
1644
  default:
1638
1645
  return "AUTHORIZED";
1639
1646
  }
@@ -1664,13 +1671,13 @@ class DbuConnector extends IBankConnector {
1664
1671
  case "14":
1665
1672
  // RQT_STATUS_EXPIRED
1666
1673
  case "33":
1667
- // RQT_STATUS_HD_CANCELLED
1668
- case "39":
1669
1674
  return "CANCELLED";
1670
1675
  // REJECTED - Explicitly rejected by bank
1671
1676
  case "15":
1672
1677
  return "REJECTED";
1673
1678
  // PENDING - All other processing states
1679
+ // Note: RQT_STATUS_CNC_CLEARING (39) is NOT terminal per corebanking team (2026-05-12)
1680
+ // It's a request for cancellation from clearing, not a final state - falls through to default
1674
1681
  default:
1675
1682
  return "PENDING";
1676
1683
  }
@@ -2002,7 +2009,7 @@ class DbuConnector extends IBankConnector {
2002
2009
  }
2003
2010
  }
2004
2011
 
2005
- const TERMINAL_STATUSES = PAYMENT_REQUEST_STATUSES.filter(isTerminalStatus);
2012
+ const TERMINAL_STATUSES = Array.from(BASE_TERMINAL_STATUSES);
2006
2013
  const getNonTerminalPaymentRequestsQuery = (db) => db.select().from(tables.paymentRequest).where(
2007
2014
  and(
2008
2015
  not(inArray(tables.paymentRequest.status, TERMINAL_STATUSES)),
@@ -2445,4 +2452,4 @@ const ottInsertSchema = createInsertSchema(ott);
2445
2452
  const ottUpdateSchema = createUpdateSchema(ott);
2446
2453
  const ottSelectSchema = createSelectSchema(ott);
2447
2454
 
2448
- 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 };
2455
+ export { useFinbricksFetch as A, BASE_TERMINAL_STATUSES as B, CsobConnector as C, DbuConnector as D, ErsteConnector as E, FINBRICKS_ENDPOINTS as F, tables as G, relations as H, IBankConnector as I, initiateConnector as J, KBConnector as K, getNonTerminalPaymentRequestsQuery as L, 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 };
@@ -1,4 +1,4 @@
1
- import { e as CurrencyCode, Q as BankCode, a0 as CountryCode, P as PaymentRequestSelectType } from './bank.BOI0GA-f.js';
1
+ import { e as CurrencyCode, R as BankCode, a1 as CountryCode, P as PaymentRequestSelectType } from './bank.BCqBwSKC.js';
2
2
  import { z } from 'zod';
3
3
 
4
4
  type ReferenceType = `${'VS' | 'SS' | 'KS'}:${number}`;
@@ -1,4 +1,4 @@
1
- import { e as CurrencyCode, Q as BankCode, a0 as CountryCode, P as PaymentRequestSelectType } from './bank.BOI0GA-f.cjs';
1
+ import { e as CurrencyCode, R as BankCode, a1 as CountryCode, P as PaymentRequestSelectType } from './bank.BCqBwSKC.mjs';
2
2
  import { z } from 'zod';
3
3
 
4
4
  type ReferenceType = `${'VS' | 'SS' | 'KS'}:${number}`;
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const drizzleOrm = require('drizzle-orm');
4
- const ott_zod = require('./bank.C2QV_SMx.cjs');
4
+ const ott_zod = require('./bank.DiJmJkDt.cjs');
5
5
  const backendSdk = require('@develit-io/backend-sdk');
6
6
  require('./bank.9Yw4KHyl.cjs');
7
7
  require('date-fns');