@develit-services/bank 5.6.0 → 5.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/base.cjs CHANGED
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  const backendSdk = require('@develit-io/backend-sdk');
4
- const paymentDirection = require('./shared/bank.B31L1QD_.cjs');
4
+ const paymentDirection = require('./shared/bank.B1Xa5U2u.cjs');
5
5
  const drizzleOrm = require('drizzle-orm');
6
6
  const cloudflare_workers = require('cloudflare:workers');
7
7
  const d1 = require('drizzle-orm/d1');
8
8
  require('jose');
9
- const bank = require('./shared/bank.BzWZ0Pvi.cjs');
9
+ const bank = require('./shared/bank.BcAwr2OG.cjs');
10
10
  const zod = require('zod');
11
11
  const database_schema = require('./shared/bank.9Yw4KHyl.cjs');
12
12
  const generalCodes = require('@develit-io/general-codes');
@@ -735,6 +735,11 @@ const getAccountBalanceInputSchema = zod.z.object({
735
735
  accountId: zod.z.string().uuid()
736
736
  });
737
737
 
738
+ const closePaymentRequestInputSchema = zod.z.object({
739
+ paymentRequestId: zod.z.string(),
740
+ statusReason: zod.z.string().optional()
741
+ });
742
+
738
743
  var __defProp = Object.defineProperty;
739
744
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
740
745
  var __decorateClass = (decorators, target, key, kind) => {
@@ -752,6 +757,9 @@ exports.BankServiceBase = class BankServiceBase extends backendSdk.develitWorker
752
757
  // ── Unified status resolution ──────────────────────────────────────
753
758
  this.POLLING_TIMEOUT_MS = 14 * 24 * 60 * 60 * 1e3;
754
759
  // 14 days
760
+ // OPENED = authorization never completed; auth links are short-lived, so close much sooner
761
+ this.OPENED_TIMEOUT_MS = 48 * 60 * 60 * 1e3;
762
+ // 48 hours
755
763
  this.COMPLETED_POLLING_WINDOW_MS = 7 * 24 * 60 * 60 * 1e3;
756
764
  this.allowedProviders = config.allowedProviders;
757
765
  this.db = d1.drizzle(this.env.BANK_D1, { schema: paymentDirection.tables, relations: paymentDirection.relations });
@@ -1097,13 +1105,16 @@ exports.BankServiceBase = class BankServiceBase extends backendSdk.develitWorker
1097
1105
  console.log("[updatePaymentRequestStatuses] By connector", byConnector);
1098
1106
  const now = Date.now();
1099
1107
  const pollableIds = [];
1108
+ const closedEvents = [];
1100
1109
  for (const pr of nonTerminalPRs) {
1101
1110
  const status = pr.status;
1102
1111
  if (paymentDirection.isTerminalStatus(status, pr.connectorKey)) {
1103
1112
  continue;
1104
1113
  }
1105
1114
  if (status === "OPENED" || status === "AUTHORIZED") {
1106
- if (pr.createdAt != null && now - pr.createdAt.getTime() > this.POLLING_TIMEOUT_MS) {
1115
+ const timeoutMs = status === "OPENED" ? this.OPENED_TIMEOUT_MS : this.POLLING_TIMEOUT_MS;
1116
+ const statusReason = status === "OPENED" ? "Authorization not completed within 48 hours" : "Polling timeout: no final status received after 14 days";
1117
+ if (pr.createdAt != null && now - pr.createdAt.getTime() > timeoutMs) {
1107
1118
  console.warn(
1108
1119
  "[updatePaymentRequestStatuses] Closing PR due to timeout",
1109
1120
  {
@@ -1115,17 +1126,42 @@ exports.BankServiceBase = class BankServiceBase extends backendSdk.develitWorker
1115
1126
  age: `${Math.floor((now - pr.createdAt.getTime()) / (24 * 60 * 60 * 1e3))} days`
1116
1127
  }
1117
1128
  );
1129
+ const processedAt = /* @__PURE__ */ new Date();
1118
1130
  await bank.updatePaymentRequestStatusCommand(this.db, {
1119
1131
  id: pr.id,
1120
1132
  status: "CLOSED",
1121
- statusReason: "Polling timeout: no final status received after 14 days",
1122
- processedAt: /* @__PURE__ */ new Date()
1133
+ statusReason,
1134
+ processedAt
1123
1135
  }).command.execute();
1136
+ closedEvents.push(
1137
+ buildPaymentRequestEvent({
1138
+ ...pr,
1139
+ status: "CLOSED",
1140
+ statusReason,
1141
+ processedAt
1142
+ })
1143
+ );
1124
1144
  continue;
1125
1145
  }
1126
1146
  pollableIds.push(pr.id);
1127
1147
  }
1128
1148
  }
1149
+ if (closedEvents.length > 0) {
1150
+ try {
1151
+ await this.pushToQueue(
1152
+ this.env.QUEUE_BUS_QUEUE,
1153
+ closedEvents
1154
+ );
1155
+ } catch (err) {
1156
+ console.error(
1157
+ "[updatePaymentRequestStatuses] Failed to push timeout-close events to queue",
1158
+ {
1159
+ eventCount: closedEvents.length,
1160
+ error: err instanceof Error ? err.message : String(err)
1161
+ }
1162
+ );
1163
+ }
1164
+ }
1129
1165
  const result = await this._resolvePaymentRequestStatuses(pollableIds);
1130
1166
  const duration = Date.now() - startTime;
1131
1167
  console.log("[updatePaymentRequestStatuses] Completed", {
@@ -1218,6 +1254,18 @@ exports.BankServiceBase = class BankServiceBase extends backendSdk.develitWorker
1218
1254
  });
1219
1255
  const result = connector.parseAuthorizationCallback(callbackUrl);
1220
1256
  if (!result.success) {
1257
+ if (paymentRequestId) {
1258
+ try {
1259
+ await bank.updatePaymentRequestStatusCommand(this.db, {
1260
+ id: paymentRequestId,
1261
+ statusReason: `Authorization error: ${result.error}`
1262
+ }).command.execute();
1263
+ } catch (err) {
1264
+ this.logError({
1265
+ message: `[handleAuthorizationCallback] Failed to persist error reason for PR ${paymentRequestId}: ${err}`
1266
+ });
1267
+ }
1268
+ }
1221
1269
  return {
1222
1270
  paymentsUpdated: 0,
1223
1271
  batchId: null,
@@ -1246,6 +1294,87 @@ exports.BankServiceBase = class BankServiceBase extends backendSdk.develitWorker
1246
1294
  }
1247
1295
  );
1248
1296
  }
1297
+ async closePaymentRequest(input) {
1298
+ return this.handleAction(
1299
+ { data: input, schema: closePaymentRequestInputSchema },
1300
+ { successMessage: "Payment request closed" },
1301
+ async ({ paymentRequestId, statusReason }) => {
1302
+ const pr = await getPaymentRequestByIdQuery(this.db, {
1303
+ paymentRequestId
1304
+ });
1305
+ if (!pr) {
1306
+ throw backendSdk.createInternalError(null, {
1307
+ message: `Payment request ${paymentRequestId} not found`,
1308
+ code: "DB-B-011",
1309
+ status: 404
1310
+ });
1311
+ }
1312
+ if (pr.status !== "OPENED") {
1313
+ throw backendSdk.createInternalError(null, {
1314
+ message: `Only OPENED payment requests can be closed (current status: ${pr.status})`,
1315
+ code: "DB-B-012",
1316
+ status: 400
1317
+ });
1318
+ }
1319
+ let bankStatus = null;
1320
+ try {
1321
+ const connector = await this._initiateBankConnector({
1322
+ connectorKey: pr.connectorKey
1323
+ });
1324
+ bankStatus = await connector.getPaymentStatus({
1325
+ paymentId: pr.bankRefId ?? pr.id
1326
+ });
1327
+ } catch (err) {
1328
+ this.logError({
1329
+ message: `[closePaymentRequest] Status re-poll failed for PR ${pr.id}, closing anyway: ${err}`
1330
+ });
1331
+ }
1332
+ if (bankStatus && bankStatus !== "OPENED") {
1333
+ await this._resolvePaymentRequestStatuses([pr.id]);
1334
+ throw backendSdk.createInternalError(null, {
1335
+ message: `Payment request is no longer OPENED at the bank (current status: ${bankStatus})`,
1336
+ code: "DB-B-013",
1337
+ status: 409
1338
+ });
1339
+ }
1340
+ const processedAt = /* @__PURE__ */ new Date();
1341
+ const reason = statusReason ?? "Closed by operator";
1342
+ const updated = backendSdk.first(
1343
+ await bank.updatePaymentRequestStatusCommand(this.db, {
1344
+ id: pr.id,
1345
+ status: "CLOSED",
1346
+ statusReason: reason,
1347
+ processedAt
1348
+ }).command.execute()
1349
+ );
1350
+ try {
1351
+ await this.pushToQueue(
1352
+ this.env.QUEUE_BUS_QUEUE,
1353
+ [
1354
+ buildPaymentRequestEvent({
1355
+ ...pr,
1356
+ status: "CLOSED",
1357
+ statusReason: reason,
1358
+ processedAt
1359
+ })
1360
+ ]
1361
+ );
1362
+ } catch (err) {
1363
+ this.logError({
1364
+ message: `[closePaymentRequest] Failed to push close event for PR ${pr.id}: ${err}`
1365
+ });
1366
+ }
1367
+ return {
1368
+ paymentRequest: updated ?? {
1369
+ ...pr,
1370
+ status: "CLOSED",
1371
+ statusReason: reason,
1372
+ processedAt
1373
+ }
1374
+ };
1375
+ }
1376
+ );
1377
+ }
1249
1378
  async processBatch(input) {
1250
1379
  return this.handleAction(
1251
1380
  { data: input, schema: processBatchInputSchema },
@@ -2098,6 +2227,9 @@ __decorateClass([
2098
2227
  __decorateClass([
2099
2228
  backendSdk.action("handle-authorization-callback")
2100
2229
  ], exports.BankServiceBase.prototype, "handleAuthorizationCallback", 1);
2230
+ __decorateClass([
2231
+ backendSdk.action("close-payment-request")
2232
+ ], exports.BankServiceBase.prototype, "closePaymentRequest", 1);
2101
2233
  __decorateClass([
2102
2234
  backendSdk.action("process-batch")
2103
2235
  ], exports.BankServiceBase.prototype, "processBatch", 1);
package/dist/base.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { B as BatchSelectType, P as PaymentRequestSelectType, A as AccountSelectType, a as PaymentSelectType, L as LastSyncMetadata, C as ConnectorConfig, t as tables, b as ConnectorKey, c as ConfigEnvironmentBank, I as IBankConnector, d as PaymentType, e as CurrencyCode, H as HandleAuthorizationCallbackInput, f as HandleAuthorizationCallbackOutput } from './shared/bank.BrBu52ls.cjs';
2
- import { S as SendPaymentInput, a as SendPaymentOutput, b as SendPaymentSyncInput, c as SendPaymentSyncOutput, F as FinbricksSupportedBanksResponse } from './shared/bank.Dzk9ABBs.cjs';
1
+ import { B as BatchSelectType, P as PaymentRequestSelectType, A as AccountSelectType, a as PaymentSelectType, L as LastSyncMetadata, C as ConnectorConfig, t as tables, b as ConnectorKey, c as ConfigEnvironmentBank, I as IBankConnector, d as PaymentType, e as CurrencyCode, H as HandleAuthorizationCallbackInput, f as HandleAuthorizationCallbackOutput } from './shared/bank.DmZly4Hz.cjs';
2
+ import { S as SendPaymentInput, a as SendPaymentOutput, b as SendPaymentSyncInput, c as SendPaymentSyncOutput, F as FinbricksSupportedBanksResponse } from './shared/bank.Dyt5JZy1.cjs';
3
3
  import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
4
4
  import { WorkflowInstanceStatus, IRPCResponse } from '@develit-io/backend-sdk';
5
5
  import { WorkerEntrypoint } from 'cloudflare:workers';
@@ -2699,9 +2699,9 @@ declare const getBatchesInputSchema: z.ZodObject<{
2699
2699
  limit: z.ZodNumber;
2700
2700
  sort: z.ZodObject<{
2701
2701
  column: z.ZodEnum<{
2702
- batchPaymentInitiatedAt: "batchPaymentInitiatedAt";
2703
2702
  createdAt: "createdAt";
2704
2703
  updatedAt: "updatedAt";
2704
+ batchPaymentInitiatedAt: "batchPaymentInitiatedAt";
2705
2705
  }>;
2706
2706
  direction: z.ZodEnum<{
2707
2707
  asc: "asc";
@@ -2825,9 +2825,9 @@ declare const getPaymentsInputSchema: z.ZodObject<{
2825
2825
  limit: z.ZodNumber;
2826
2826
  sort: z.ZodObject<{
2827
2827
  column: z.ZodEnum<{
2828
+ amount: "amount";
2828
2829
  createdAt: "createdAt";
2829
2830
  updatedAt: "updatedAt";
2830
- amount: "amount";
2831
2831
  }>;
2832
2832
  direction: z.ZodEnum<{
2833
2833
  asc: "asc";
@@ -2958,8 +2958,8 @@ declare const getPaymentsInputSchema: z.ZodObject<{
2958
2958
  filterPaymentStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
2959
2959
  BOOKED: "BOOKED";
2960
2960
  REJECTED: "REJECTED";
2961
- PROCESSING: "PROCESSING";
2962
2961
  PENDING: "PENDING";
2962
+ PROCESSING: "PROCESSING";
2963
2963
  CANCELLED: "CANCELLED";
2964
2964
  SCHEDULED: "SCHEDULED";
2965
2965
  HOLD: "HOLD";
@@ -2967,8 +2967,8 @@ declare const getPaymentsInputSchema: z.ZodObject<{
2967
2967
  }>, z.ZodArray<z.ZodEnum<{
2968
2968
  BOOKED: "BOOKED";
2969
2969
  REJECTED: "REJECTED";
2970
- PROCESSING: "PROCESSING";
2971
2970
  PENDING: "PENDING";
2971
+ PROCESSING: "PROCESSING";
2972
2972
  CANCELLED: "CANCELLED";
2973
2973
  SCHEDULED: "SCHEDULED";
2974
2974
  HOLD: "HOLD";
@@ -3875,9 +3875,9 @@ declare const getPaymentRequestsInputSchema: z.ZodObject<{
3875
3875
  limit: z.ZodNumber;
3876
3876
  sort: z.ZodObject<{
3877
3877
  column: z.ZodEnum<{
3878
+ amount: "amount";
3878
3879
  createdAt: "createdAt";
3879
3880
  updatedAt: "updatedAt";
3880
- amount: "amount";
3881
3881
  }>;
3882
3882
  direction: z.ZodEnum<{
3883
3883
  asc: "asc";
@@ -3886,16 +3886,16 @@ declare const getPaymentRequestsInputSchema: z.ZodObject<{
3886
3886
  }, z.core.$strip>;
3887
3887
  filterAccountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodUUID, z.ZodArray<z.ZodUUID>]>>;
3888
3888
  filterStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
3889
- OPENED: "OPENED";
3890
3889
  AUTHORIZED: "AUTHORIZED";
3890
+ OPENED: "OPENED";
3891
3891
  COMPLETED: "COMPLETED";
3892
3892
  BOOKED: "BOOKED";
3893
3893
  SETTLED: "SETTLED";
3894
3894
  REJECTED: "REJECTED";
3895
3895
  CLOSED: "CLOSED";
3896
3896
  }>, z.ZodArray<z.ZodEnum<{
3897
- OPENED: "OPENED";
3898
3897
  AUTHORIZED: "AUTHORIZED";
3898
+ OPENED: "OPENED";
3899
3899
  COMPLETED: "COMPLETED";
3900
3900
  BOOKED: "BOOKED";
3901
3901
  SETTLED: "SETTLED";
@@ -4060,6 +4060,15 @@ type GetAccountBalanceOutput = {
4060
4060
  }>;
4061
4061
  };
4062
4062
 
4063
+ declare const closePaymentRequestInputSchema: z.ZodObject<{
4064
+ paymentRequestId: z.ZodString;
4065
+ statusReason: z.ZodOptional<z.ZodString>;
4066
+ }, z.core.$strip>;
4067
+ type ClosePaymentRequestInput = z.infer<typeof closePaymentRequestInputSchema>;
4068
+ type ClosePaymentRequestOutput = {
4069
+ paymentRequest: PaymentRequestSelectType;
4070
+ };
4071
+
4063
4072
  declare const BankServiceBase_base: (abstract new (ctx: ExecutionContext, env: BankEnv) => WorkerEntrypoint<BankEnv, {}>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
4064
4073
  declare class BankServiceBase extends BankServiceBase_base {
4065
4074
  readonly db: DrizzleD1Database<typeof tables>;
@@ -4161,6 +4170,7 @@ declare class BankServiceBase extends BankServiceBase_base {
4161
4170
  syncAccountTerminate(input: SyncAccountTerminateInput): Promise<IRPCResponse<SyncAccountTerminateOutput>>;
4162
4171
  syncAccounts(): Promise<IRPCResponse<never>>;
4163
4172
  private readonly POLLING_TIMEOUT_MS;
4173
+ private readonly OPENED_TIMEOUT_MS;
4164
4174
  private readonly COMPLETED_POLLING_WINDOW_MS;
4165
4175
  /**
4166
4176
  * Core status resolution logic. Polls connector for each PR and updates status.
@@ -4185,6 +4195,7 @@ declare class BankServiceBase extends BankServiceBase_base {
4185
4195
  scheduled(controller: ScheduledController): Promise<void>;
4186
4196
  private heartbeatSyncWorkflows;
4187
4197
  handleAuthorizationCallback(input: HandleAuthorizationCallbackInput): Promise<IRPCResponse<HandleAuthorizationCallbackOutput>>;
4198
+ closePaymentRequest(input: ClosePaymentRequestInput): Promise<IRPCResponse<ClosePaymentRequestOutput>>;
4188
4199
  processBatch(input: ProcessBatchInput): Promise<IRPCResponse<ProcessBatchOutput>>;
4189
4200
  processBatchStatus(input: ProcessBatchStatusInput): Promise<IRPCResponse<ProcessBatchStatusOutput>>;
4190
4201
  processBatchRestart(input: ProcessBatchRestartInput): Promise<IRPCResponse<ProcessBatchRestartOutput>>;
package/dist/base.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { B as BatchSelectType, P as PaymentRequestSelectType, A as AccountSelectType, a as PaymentSelectType, L as LastSyncMetadata, C as ConnectorConfig, t as tables, b as ConnectorKey, c as ConfigEnvironmentBank, I as IBankConnector, d as PaymentType, e as CurrencyCode, H as HandleAuthorizationCallbackInput, f as HandleAuthorizationCallbackOutput } from './shared/bank.BrBu52ls.mjs';
2
- import { S as SendPaymentInput, a as SendPaymentOutput, b as SendPaymentSyncInput, c as SendPaymentSyncOutput, F as FinbricksSupportedBanksResponse } from './shared/bank.o3KC69CF.mjs';
1
+ import { B as BatchSelectType, P as PaymentRequestSelectType, A as AccountSelectType, a as PaymentSelectType, L as LastSyncMetadata, C as ConnectorConfig, t as tables, b as ConnectorKey, c as ConfigEnvironmentBank, I as IBankConnector, d as PaymentType, e as CurrencyCode, H as HandleAuthorizationCallbackInput, f as HandleAuthorizationCallbackOutput } from './shared/bank.DmZly4Hz.mjs';
2
+ import { S as SendPaymentInput, a as SendPaymentOutput, b as SendPaymentSyncInput, c as SendPaymentSyncOutput, F as FinbricksSupportedBanksResponse } from './shared/bank.sVKKxDLm.mjs';
3
3
  import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
4
4
  import { WorkflowInstanceStatus, IRPCResponse } from '@develit-io/backend-sdk';
5
5
  import { WorkerEntrypoint } from 'cloudflare:workers';
@@ -2699,9 +2699,9 @@ declare const getBatchesInputSchema: z.ZodObject<{
2699
2699
  limit: z.ZodNumber;
2700
2700
  sort: z.ZodObject<{
2701
2701
  column: z.ZodEnum<{
2702
- batchPaymentInitiatedAt: "batchPaymentInitiatedAt";
2703
2702
  createdAt: "createdAt";
2704
2703
  updatedAt: "updatedAt";
2704
+ batchPaymentInitiatedAt: "batchPaymentInitiatedAt";
2705
2705
  }>;
2706
2706
  direction: z.ZodEnum<{
2707
2707
  asc: "asc";
@@ -2825,9 +2825,9 @@ declare const getPaymentsInputSchema: z.ZodObject<{
2825
2825
  limit: z.ZodNumber;
2826
2826
  sort: z.ZodObject<{
2827
2827
  column: z.ZodEnum<{
2828
+ amount: "amount";
2828
2829
  createdAt: "createdAt";
2829
2830
  updatedAt: "updatedAt";
2830
- amount: "amount";
2831
2831
  }>;
2832
2832
  direction: z.ZodEnum<{
2833
2833
  asc: "asc";
@@ -2958,8 +2958,8 @@ declare const getPaymentsInputSchema: z.ZodObject<{
2958
2958
  filterPaymentStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
2959
2959
  BOOKED: "BOOKED";
2960
2960
  REJECTED: "REJECTED";
2961
- PROCESSING: "PROCESSING";
2962
2961
  PENDING: "PENDING";
2962
+ PROCESSING: "PROCESSING";
2963
2963
  CANCELLED: "CANCELLED";
2964
2964
  SCHEDULED: "SCHEDULED";
2965
2965
  HOLD: "HOLD";
@@ -2967,8 +2967,8 @@ declare const getPaymentsInputSchema: z.ZodObject<{
2967
2967
  }>, z.ZodArray<z.ZodEnum<{
2968
2968
  BOOKED: "BOOKED";
2969
2969
  REJECTED: "REJECTED";
2970
- PROCESSING: "PROCESSING";
2971
2970
  PENDING: "PENDING";
2971
+ PROCESSING: "PROCESSING";
2972
2972
  CANCELLED: "CANCELLED";
2973
2973
  SCHEDULED: "SCHEDULED";
2974
2974
  HOLD: "HOLD";
@@ -3875,9 +3875,9 @@ declare const getPaymentRequestsInputSchema: z.ZodObject<{
3875
3875
  limit: z.ZodNumber;
3876
3876
  sort: z.ZodObject<{
3877
3877
  column: z.ZodEnum<{
3878
+ amount: "amount";
3878
3879
  createdAt: "createdAt";
3879
3880
  updatedAt: "updatedAt";
3880
- amount: "amount";
3881
3881
  }>;
3882
3882
  direction: z.ZodEnum<{
3883
3883
  asc: "asc";
@@ -3886,16 +3886,16 @@ declare const getPaymentRequestsInputSchema: z.ZodObject<{
3886
3886
  }, z.core.$strip>;
3887
3887
  filterAccountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodUUID, z.ZodArray<z.ZodUUID>]>>;
3888
3888
  filterStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
3889
- OPENED: "OPENED";
3890
3889
  AUTHORIZED: "AUTHORIZED";
3890
+ OPENED: "OPENED";
3891
3891
  COMPLETED: "COMPLETED";
3892
3892
  BOOKED: "BOOKED";
3893
3893
  SETTLED: "SETTLED";
3894
3894
  REJECTED: "REJECTED";
3895
3895
  CLOSED: "CLOSED";
3896
3896
  }>, z.ZodArray<z.ZodEnum<{
3897
- OPENED: "OPENED";
3898
3897
  AUTHORIZED: "AUTHORIZED";
3898
+ OPENED: "OPENED";
3899
3899
  COMPLETED: "COMPLETED";
3900
3900
  BOOKED: "BOOKED";
3901
3901
  SETTLED: "SETTLED";
@@ -4060,6 +4060,15 @@ type GetAccountBalanceOutput = {
4060
4060
  }>;
4061
4061
  };
4062
4062
 
4063
+ declare const closePaymentRequestInputSchema: z.ZodObject<{
4064
+ paymentRequestId: z.ZodString;
4065
+ statusReason: z.ZodOptional<z.ZodString>;
4066
+ }, z.core.$strip>;
4067
+ type ClosePaymentRequestInput = z.infer<typeof closePaymentRequestInputSchema>;
4068
+ type ClosePaymentRequestOutput = {
4069
+ paymentRequest: PaymentRequestSelectType;
4070
+ };
4071
+
4063
4072
  declare const BankServiceBase_base: (abstract new (ctx: ExecutionContext, env: BankEnv) => WorkerEntrypoint<BankEnv, {}>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
4064
4073
  declare class BankServiceBase extends BankServiceBase_base {
4065
4074
  readonly db: DrizzleD1Database<typeof tables>;
@@ -4161,6 +4170,7 @@ declare class BankServiceBase extends BankServiceBase_base {
4161
4170
  syncAccountTerminate(input: SyncAccountTerminateInput): Promise<IRPCResponse<SyncAccountTerminateOutput>>;
4162
4171
  syncAccounts(): Promise<IRPCResponse<never>>;
4163
4172
  private readonly POLLING_TIMEOUT_MS;
4173
+ private readonly OPENED_TIMEOUT_MS;
4164
4174
  private readonly COMPLETED_POLLING_WINDOW_MS;
4165
4175
  /**
4166
4176
  * Core status resolution logic. Polls connector for each PR and updates status.
@@ -4185,6 +4195,7 @@ declare class BankServiceBase extends BankServiceBase_base {
4185
4195
  scheduled(controller: ScheduledController): Promise<void>;
4186
4196
  private heartbeatSyncWorkflows;
4187
4197
  handleAuthorizationCallback(input: HandleAuthorizationCallbackInput): Promise<IRPCResponse<HandleAuthorizationCallbackOutput>>;
4198
+ closePaymentRequest(input: ClosePaymentRequestInput): Promise<IRPCResponse<ClosePaymentRequestOutput>>;
4188
4199
  processBatch(input: ProcessBatchInput): Promise<IRPCResponse<ProcessBatchOutput>>;
4189
4200
  processBatchStatus(input: ProcessBatchStatusInput): Promise<IRPCResponse<ProcessBatchStatusOutput>>;
4190
4201
  processBatchRestart(input: ProcessBatchRestartInput): Promise<IRPCResponse<ProcessBatchRestartOutput>>;
package/dist/base.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { B as BatchSelectType, P as PaymentRequestSelectType, A as AccountSelectType, a as PaymentSelectType, L as LastSyncMetadata, C as ConnectorConfig, t as tables, b as ConnectorKey, c as ConfigEnvironmentBank, I as IBankConnector, d as PaymentType, e as CurrencyCode, H as HandleAuthorizationCallbackInput, f as HandleAuthorizationCallbackOutput } from './shared/bank.BrBu52ls.js';
2
- import { S as SendPaymentInput, a as SendPaymentOutput, b as SendPaymentSyncInput, c as SendPaymentSyncOutput, F as FinbricksSupportedBanksResponse } from './shared/bank.Cfz0frnc.js';
1
+ import { B as BatchSelectType, P as PaymentRequestSelectType, A as AccountSelectType, a as PaymentSelectType, L as LastSyncMetadata, C as ConnectorConfig, t as tables, b as ConnectorKey, c as ConfigEnvironmentBank, I as IBankConnector, d as PaymentType, e as CurrencyCode, H as HandleAuthorizationCallbackInput, f as HandleAuthorizationCallbackOutput } from './shared/bank.DmZly4Hz.js';
2
+ import { S as SendPaymentInput, a as SendPaymentOutput, b as SendPaymentSyncInput, c as SendPaymentSyncOutput, F as FinbricksSupportedBanksResponse } from './shared/bank.0zYbe2ZB.js';
3
3
  import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
4
4
  import { WorkflowInstanceStatus, IRPCResponse } from '@develit-io/backend-sdk';
5
5
  import { WorkerEntrypoint } from 'cloudflare:workers';
@@ -2699,9 +2699,9 @@ declare const getBatchesInputSchema: z.ZodObject<{
2699
2699
  limit: z.ZodNumber;
2700
2700
  sort: z.ZodObject<{
2701
2701
  column: z.ZodEnum<{
2702
- batchPaymentInitiatedAt: "batchPaymentInitiatedAt";
2703
2702
  createdAt: "createdAt";
2704
2703
  updatedAt: "updatedAt";
2704
+ batchPaymentInitiatedAt: "batchPaymentInitiatedAt";
2705
2705
  }>;
2706
2706
  direction: z.ZodEnum<{
2707
2707
  asc: "asc";
@@ -2825,9 +2825,9 @@ declare const getPaymentsInputSchema: z.ZodObject<{
2825
2825
  limit: z.ZodNumber;
2826
2826
  sort: z.ZodObject<{
2827
2827
  column: z.ZodEnum<{
2828
+ amount: "amount";
2828
2829
  createdAt: "createdAt";
2829
2830
  updatedAt: "updatedAt";
2830
- amount: "amount";
2831
2831
  }>;
2832
2832
  direction: z.ZodEnum<{
2833
2833
  asc: "asc";
@@ -2958,8 +2958,8 @@ declare const getPaymentsInputSchema: z.ZodObject<{
2958
2958
  filterPaymentStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
2959
2959
  BOOKED: "BOOKED";
2960
2960
  REJECTED: "REJECTED";
2961
- PROCESSING: "PROCESSING";
2962
2961
  PENDING: "PENDING";
2962
+ PROCESSING: "PROCESSING";
2963
2963
  CANCELLED: "CANCELLED";
2964
2964
  SCHEDULED: "SCHEDULED";
2965
2965
  HOLD: "HOLD";
@@ -2967,8 +2967,8 @@ declare const getPaymentsInputSchema: z.ZodObject<{
2967
2967
  }>, z.ZodArray<z.ZodEnum<{
2968
2968
  BOOKED: "BOOKED";
2969
2969
  REJECTED: "REJECTED";
2970
- PROCESSING: "PROCESSING";
2971
2970
  PENDING: "PENDING";
2971
+ PROCESSING: "PROCESSING";
2972
2972
  CANCELLED: "CANCELLED";
2973
2973
  SCHEDULED: "SCHEDULED";
2974
2974
  HOLD: "HOLD";
@@ -3875,9 +3875,9 @@ declare const getPaymentRequestsInputSchema: z.ZodObject<{
3875
3875
  limit: z.ZodNumber;
3876
3876
  sort: z.ZodObject<{
3877
3877
  column: z.ZodEnum<{
3878
+ amount: "amount";
3878
3879
  createdAt: "createdAt";
3879
3880
  updatedAt: "updatedAt";
3880
- amount: "amount";
3881
3881
  }>;
3882
3882
  direction: z.ZodEnum<{
3883
3883
  asc: "asc";
@@ -3886,16 +3886,16 @@ declare const getPaymentRequestsInputSchema: z.ZodObject<{
3886
3886
  }, z.core.$strip>;
3887
3887
  filterAccountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodUUID, z.ZodArray<z.ZodUUID>]>>;
3888
3888
  filterStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
3889
- OPENED: "OPENED";
3890
3889
  AUTHORIZED: "AUTHORIZED";
3890
+ OPENED: "OPENED";
3891
3891
  COMPLETED: "COMPLETED";
3892
3892
  BOOKED: "BOOKED";
3893
3893
  SETTLED: "SETTLED";
3894
3894
  REJECTED: "REJECTED";
3895
3895
  CLOSED: "CLOSED";
3896
3896
  }>, z.ZodArray<z.ZodEnum<{
3897
- OPENED: "OPENED";
3898
3897
  AUTHORIZED: "AUTHORIZED";
3898
+ OPENED: "OPENED";
3899
3899
  COMPLETED: "COMPLETED";
3900
3900
  BOOKED: "BOOKED";
3901
3901
  SETTLED: "SETTLED";
@@ -4060,6 +4060,15 @@ type GetAccountBalanceOutput = {
4060
4060
  }>;
4061
4061
  };
4062
4062
 
4063
+ declare const closePaymentRequestInputSchema: z.ZodObject<{
4064
+ paymentRequestId: z.ZodString;
4065
+ statusReason: z.ZodOptional<z.ZodString>;
4066
+ }, z.core.$strip>;
4067
+ type ClosePaymentRequestInput = z.infer<typeof closePaymentRequestInputSchema>;
4068
+ type ClosePaymentRequestOutput = {
4069
+ paymentRequest: PaymentRequestSelectType;
4070
+ };
4071
+
4063
4072
  declare const BankServiceBase_base: (abstract new (ctx: ExecutionContext, env: BankEnv) => WorkerEntrypoint<BankEnv, {}>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
4064
4073
  declare class BankServiceBase extends BankServiceBase_base {
4065
4074
  readonly db: DrizzleD1Database<typeof tables>;
@@ -4161,6 +4170,7 @@ declare class BankServiceBase extends BankServiceBase_base {
4161
4170
  syncAccountTerminate(input: SyncAccountTerminateInput): Promise<IRPCResponse<SyncAccountTerminateOutput>>;
4162
4171
  syncAccounts(): Promise<IRPCResponse<never>>;
4163
4172
  private readonly POLLING_TIMEOUT_MS;
4173
+ private readonly OPENED_TIMEOUT_MS;
4164
4174
  private readonly COMPLETED_POLLING_WINDOW_MS;
4165
4175
  /**
4166
4176
  * Core status resolution logic. Polls connector for each PR and updates status.
@@ -4185,6 +4195,7 @@ declare class BankServiceBase extends BankServiceBase_base {
4185
4195
  scheduled(controller: ScheduledController): Promise<void>;
4186
4196
  private heartbeatSyncWorkflows;
4187
4197
  handleAuthorizationCallback(input: HandleAuthorizationCallbackInput): Promise<IRPCResponse<HandleAuthorizationCallbackOutput>>;
4198
+ closePaymentRequest(input: ClosePaymentRequestInput): Promise<IRPCResponse<ClosePaymentRequestOutput>>;
4188
4199
  processBatch(input: ProcessBatchInput): Promise<IRPCResponse<ProcessBatchOutput>>;
4189
4200
  processBatchStatus(input: ProcessBatchStatusInput): Promise<IRPCResponse<ProcessBatchStatusOutput>>;
4190
4201
  processBatchRestart(input: ProcessBatchRestartInput): Promise<IRPCResponse<ProcessBatchRestartOutput>>;
package/dist/base.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import { uuidv4, first, buildMultiFilterConditions as buildMultiFilterConditions$1, bankAccountMetadataSchema, structuredAddressSchema, workflowInstanceStatusSchema, develitWorker, createInternalError, action, service } from '@develit-io/backend-sdk';
2
- import { G as tables, g as accountInsertSchema, H as relations, o as isProcessedStatus, p as isTerminalStatus, L as getNonTerminalPaymentRequestsQuery, x as toIncomingPayment, N as calculateCzechIban, j as assignAccount, u as toBatchedPayment, y as toPaymentRequestInsert, a as FinbricksClient, F as FINBRICKS_ENDPOINTS } from './shared/bank.B10hoYtM.mjs';
2
+ import { G as tables, g as accountInsertSchema, H as relations, o as isProcessedStatus, p as isTerminalStatus, L as getNonTerminalPaymentRequestsQuery, x as toIncomingPayment, N as calculateCzechIban, j as assignAccount, u as toBatchedPayment, y as toPaymentRequestInsert, a as FinbricksClient, F as FINBRICKS_ENDPOINTS } from './shared/bank.DI_Q2OtU.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';
6
6
  import 'jose';
7
- import { h as encrypt, d as createCredentialsResolver, i as initiateConnector, e as updatePaymentRequestStatusCommand, a as getPaymentRequestsByBatchIdQuery, g as getBatchByIdQuery, u as upsertBatchCommand, j as importAesKey, f as createPaymentCommand, b as getAccountByIdQuery } from './shared/bank.Bl9eBE_A.mjs';
7
+ import { h as encrypt, d as createCredentialsResolver, i as initiateConnector, e as updatePaymentRequestStatusCommand, a as getPaymentRequestsByBatchIdQuery, g as getBatchByIdQuery, u as upsertBatchCommand, j as importAesKey, f as createPaymentCommand, b as getAccountByIdQuery } from './shared/bank.BTsBHRsn.mjs';
8
8
  import { z } from 'zod';
9
9
  import { I as INSTRUCTION_PRIORITIES, C as CHARGE_BEARERS, g as PAYMENT_TYPES, b as CONNECTOR_KEYS, a as BATCH_STATUSES, f as PAYMENT_STATUSES, P as PAYMENT_DIRECTIONS, e as PAYMENT_REQUEST_STATUSES } from './shared/bank.BzDNLxB_.mjs';
10
10
  import { CURRENCY_CODES } from '@develit-io/general-codes';
@@ -733,6 +733,11 @@ const getAccountBalanceInputSchema = z.object({
733
733
  accountId: z.string().uuid()
734
734
  });
735
735
 
736
+ const closePaymentRequestInputSchema = z.object({
737
+ paymentRequestId: z.string(),
738
+ statusReason: z.string().optional()
739
+ });
740
+
736
741
  var __defProp = Object.defineProperty;
737
742
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
738
743
  var __decorateClass = (decorators, target, key, kind) => {
@@ -750,6 +755,9 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
750
755
  // ── Unified status resolution ──────────────────────────────────────
751
756
  this.POLLING_TIMEOUT_MS = 14 * 24 * 60 * 60 * 1e3;
752
757
  // 14 days
758
+ // OPENED = authorization never completed; auth links are short-lived, so close much sooner
759
+ this.OPENED_TIMEOUT_MS = 48 * 60 * 60 * 1e3;
760
+ // 48 hours
753
761
  this.COMPLETED_POLLING_WINDOW_MS = 7 * 24 * 60 * 60 * 1e3;
754
762
  this.allowedProviders = config.allowedProviders;
755
763
  this.db = drizzle(this.env.BANK_D1, { schema: tables, relations });
@@ -1095,13 +1103,16 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
1095
1103
  console.log("[updatePaymentRequestStatuses] By connector", byConnector);
1096
1104
  const now = Date.now();
1097
1105
  const pollableIds = [];
1106
+ const closedEvents = [];
1098
1107
  for (const pr of nonTerminalPRs) {
1099
1108
  const status = pr.status;
1100
1109
  if (isTerminalStatus(status, pr.connectorKey)) {
1101
1110
  continue;
1102
1111
  }
1103
1112
  if (status === "OPENED" || status === "AUTHORIZED") {
1104
- if (pr.createdAt != null && now - pr.createdAt.getTime() > this.POLLING_TIMEOUT_MS) {
1113
+ const timeoutMs = status === "OPENED" ? this.OPENED_TIMEOUT_MS : this.POLLING_TIMEOUT_MS;
1114
+ const statusReason = status === "OPENED" ? "Authorization not completed within 48 hours" : "Polling timeout: no final status received after 14 days";
1115
+ if (pr.createdAt != null && now - pr.createdAt.getTime() > timeoutMs) {
1105
1116
  console.warn(
1106
1117
  "[updatePaymentRequestStatuses] Closing PR due to timeout",
1107
1118
  {
@@ -1113,17 +1124,42 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
1113
1124
  age: `${Math.floor((now - pr.createdAt.getTime()) / (24 * 60 * 60 * 1e3))} days`
1114
1125
  }
1115
1126
  );
1127
+ const processedAt = /* @__PURE__ */ new Date();
1116
1128
  await updatePaymentRequestStatusCommand(this.db, {
1117
1129
  id: pr.id,
1118
1130
  status: "CLOSED",
1119
- statusReason: "Polling timeout: no final status received after 14 days",
1120
- processedAt: /* @__PURE__ */ new Date()
1131
+ statusReason,
1132
+ processedAt
1121
1133
  }).command.execute();
1134
+ closedEvents.push(
1135
+ buildPaymentRequestEvent({
1136
+ ...pr,
1137
+ status: "CLOSED",
1138
+ statusReason,
1139
+ processedAt
1140
+ })
1141
+ );
1122
1142
  continue;
1123
1143
  }
1124
1144
  pollableIds.push(pr.id);
1125
1145
  }
1126
1146
  }
1147
+ if (closedEvents.length > 0) {
1148
+ try {
1149
+ await this.pushToQueue(
1150
+ this.env.QUEUE_BUS_QUEUE,
1151
+ closedEvents
1152
+ );
1153
+ } catch (err) {
1154
+ console.error(
1155
+ "[updatePaymentRequestStatuses] Failed to push timeout-close events to queue",
1156
+ {
1157
+ eventCount: closedEvents.length,
1158
+ error: err instanceof Error ? err.message : String(err)
1159
+ }
1160
+ );
1161
+ }
1162
+ }
1127
1163
  const result = await this._resolvePaymentRequestStatuses(pollableIds);
1128
1164
  const duration = Date.now() - startTime;
1129
1165
  console.log("[updatePaymentRequestStatuses] Completed", {
@@ -1216,6 +1252,18 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
1216
1252
  });
1217
1253
  const result = connector.parseAuthorizationCallback(callbackUrl);
1218
1254
  if (!result.success) {
1255
+ if (paymentRequestId) {
1256
+ try {
1257
+ await updatePaymentRequestStatusCommand(this.db, {
1258
+ id: paymentRequestId,
1259
+ statusReason: `Authorization error: ${result.error}`
1260
+ }).command.execute();
1261
+ } catch (err) {
1262
+ this.logError({
1263
+ message: `[handleAuthorizationCallback] Failed to persist error reason for PR ${paymentRequestId}: ${err}`
1264
+ });
1265
+ }
1266
+ }
1219
1267
  return {
1220
1268
  paymentsUpdated: 0,
1221
1269
  batchId: null,
@@ -1244,6 +1292,87 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
1244
1292
  }
1245
1293
  );
1246
1294
  }
1295
+ async closePaymentRequest(input) {
1296
+ return this.handleAction(
1297
+ { data: input, schema: closePaymentRequestInputSchema },
1298
+ { successMessage: "Payment request closed" },
1299
+ async ({ paymentRequestId, statusReason }) => {
1300
+ const pr = await getPaymentRequestByIdQuery(this.db, {
1301
+ paymentRequestId
1302
+ });
1303
+ if (!pr) {
1304
+ throw createInternalError(null, {
1305
+ message: `Payment request ${paymentRequestId} not found`,
1306
+ code: "DB-B-011",
1307
+ status: 404
1308
+ });
1309
+ }
1310
+ if (pr.status !== "OPENED") {
1311
+ throw createInternalError(null, {
1312
+ message: `Only OPENED payment requests can be closed (current status: ${pr.status})`,
1313
+ code: "DB-B-012",
1314
+ status: 400
1315
+ });
1316
+ }
1317
+ let bankStatus = null;
1318
+ try {
1319
+ const connector = await this._initiateBankConnector({
1320
+ connectorKey: pr.connectorKey
1321
+ });
1322
+ bankStatus = await connector.getPaymentStatus({
1323
+ paymentId: pr.bankRefId ?? pr.id
1324
+ });
1325
+ } catch (err) {
1326
+ this.logError({
1327
+ message: `[closePaymentRequest] Status re-poll failed for PR ${pr.id}, closing anyway: ${err}`
1328
+ });
1329
+ }
1330
+ if (bankStatus && bankStatus !== "OPENED") {
1331
+ await this._resolvePaymentRequestStatuses([pr.id]);
1332
+ throw createInternalError(null, {
1333
+ message: `Payment request is no longer OPENED at the bank (current status: ${bankStatus})`,
1334
+ code: "DB-B-013",
1335
+ status: 409
1336
+ });
1337
+ }
1338
+ const processedAt = /* @__PURE__ */ new Date();
1339
+ const reason = statusReason ?? "Closed by operator";
1340
+ const updated = first(
1341
+ await updatePaymentRequestStatusCommand(this.db, {
1342
+ id: pr.id,
1343
+ status: "CLOSED",
1344
+ statusReason: reason,
1345
+ processedAt
1346
+ }).command.execute()
1347
+ );
1348
+ try {
1349
+ await this.pushToQueue(
1350
+ this.env.QUEUE_BUS_QUEUE,
1351
+ [
1352
+ buildPaymentRequestEvent({
1353
+ ...pr,
1354
+ status: "CLOSED",
1355
+ statusReason: reason,
1356
+ processedAt
1357
+ })
1358
+ ]
1359
+ );
1360
+ } catch (err) {
1361
+ this.logError({
1362
+ message: `[closePaymentRequest] Failed to push close event for PR ${pr.id}: ${err}`
1363
+ });
1364
+ }
1365
+ return {
1366
+ paymentRequest: updated ?? {
1367
+ ...pr,
1368
+ status: "CLOSED",
1369
+ statusReason: reason,
1370
+ processedAt
1371
+ }
1372
+ };
1373
+ }
1374
+ );
1375
+ }
1247
1376
  async processBatch(input) {
1248
1377
  return this.handleAction(
1249
1378
  { data: input, schema: processBatchInputSchema },
@@ -2096,6 +2225,9 @@ __decorateClass([
2096
2225
  __decorateClass([
2097
2226
  action("handle-authorization-callback")
2098
2227
  ], BankServiceBase.prototype, "handleAuthorizationCallback", 1);
2228
+ __decorateClass([
2229
+ action("close-payment-request")
2230
+ ], BankServiceBase.prototype, "closePaymentRequest", 1);
2099
2231
  __decorateClass([
2100
2232
  action("process-batch")
2101
2233
  ], BankServiceBase.prototype, "processBatch", 1);
@@ -1,4 +1,4 @@
1
- export { aB as account, aC as accountCredentials, aD as batch, aE as ott, aF as payment, aG as paymentRequest } from '../shared/bank.BrBu52ls.cjs';
1
+ export { aB as account, aC as accountCredentials, aD as batch, aE as ott, aF as payment, aG as paymentRequest } from '../shared/bank.DmZly4Hz.cjs';
2
2
  import 'drizzle-orm/sqlite-core';
3
3
  import 'drizzle-orm';
4
4
  import '@develit-io/general-codes';
@@ -1,4 +1,4 @@
1
- export { aB as account, aC as accountCredentials, aD as batch, aE as ott, aF as payment, aG as paymentRequest } from '../shared/bank.BrBu52ls.mjs';
1
+ export { aB as account, aC as accountCredentials, aD as batch, aE as ott, aF as payment, aG as paymentRequest } from '../shared/bank.DmZly4Hz.mjs';
2
2
  import 'drizzle-orm/sqlite-core';
3
3
  import 'drizzle-orm';
4
4
  import '@develit-io/general-codes';
@@ -1,4 +1,4 @@
1
- export { aB as account, aC as accountCredentials, aD as batch, aE as ott, aF as payment, aG as paymentRequest } from '../shared/bank.BrBu52ls.js';
1
+ export { aB as account, aC as accountCredentials, aD as batch, aE as ott, aF as payment, aG as paymentRequest } from '../shared/bank.DmZly4Hz.js';
2
2
  import 'drizzle-orm/sqlite-core';
3
3
  import 'drizzle-orm';
4
4
  import '@develit-io/general-codes';
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  const backendSdk = require('@develit-io/backend-sdk');
4
- const paymentDirection = require('../shared/bank.B31L1QD_.cjs');
4
+ const paymentDirection = require('../shared/bank.B1Xa5U2u.cjs');
5
5
  const batchLifecycle = require('../shared/bank.NF8bZBy0.cjs');
6
6
  const drizzleOrm = require('drizzle-orm');
7
- const bank = require('../shared/bank.BzWZ0Pvi.cjs');
7
+ const bank = require('../shared/bank.BcAwr2OG.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 { G as tables, H as relations, v as toBatchedPaymentFromPaymentRequest, z as toPreparedPayment, m as isPaymentCompleted } from '../shared/bank.B10hoYtM.mjs';
2
+ import { G as tables, H as relations, v as toBatchedPaymentFromPaymentRequest, z as toPreparedPayment, m as isPaymentCompleted } from '../shared/bank.DI_Q2OtU.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, i as initiateConnector, e as updatePaymentRequestStatusCommand, f as createPaymentCommand } from '../shared/bank.Bl9eBE_A.mjs';
5
+ import { g as getBatchByIdQuery, a as getPaymentRequestsByBatchIdQuery, c as checksum, u as upsertBatchCommand, b as getAccountByIdQuery, d as createCredentialsResolver, i as initiateConnector, e as updatePaymentRequestStatusCommand, f as createPaymentCommand } from '../shared/bank.BTsBHRsn.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 { e as CurrencyCode, R as BankCode, a1 as CountryCode, P as PaymentRequestSelectType } from './bank.BrBu52ls.js';
1
+ import { e as CurrencyCode, R as BankCode, a1 as CountryCode, P as PaymentRequestSelectType } from './bank.DmZly4Hz.js';
2
2
  import { z } from 'zod';
3
3
 
4
4
  type ReferenceType = `${'VS' | 'SS' | 'KS'}:${number}`;
@@ -1210,7 +1210,12 @@ class FinbricksConnector extends IBankConnector {
1210
1210
  ss: payment.ss,
1211
1211
  ks: payment.ks
1212
1212
  });
1213
- const combined = [reference, message].filter(Boolean).join(" ");
1213
+ const udt = this.PROVIDER === "CSOB" ? buildUltimateCreditor(payment.creditor, {
1214
+ stripDiacritics: payment.currency !== "CZK"
1215
+ }) : void 0;
1216
+ const reserved = (reference ? reference.length + 1 : 0) + (udt ? udt.length + 2 : 0);
1217
+ const base = [message.slice(0, Math.max(0, 140 - reserved)), reference].filter(Boolean).join(" ");
1218
+ const combined = udt ? base ? `${base}, ${udt}` : udt : base;
1214
1219
  const unstructured = (combined.length >= 3 ? combined : "Platba").slice(
1215
1220
  0,
1216
1221
  140
@@ -2472,11 +2477,20 @@ class MockConnector extends IBankConnector {
2472
2477
  async getPaymentStatus(_) {
2473
2478
  return "SETTLED";
2474
2479
  }
2475
- parseAuthorizationCallback(_callbackUrl) {
2480
+ parseAuthorizationCallback(callbackUrl) {
2481
+ const params = new URL(callbackUrl).searchParams;
2482
+ const error = params.get("error");
2483
+ if (error) {
2484
+ return {
2485
+ success: false,
2486
+ error,
2487
+ code: params.get("code")
2488
+ };
2489
+ }
2476
2490
  return {
2477
2491
  success: true,
2478
2492
  type: "paymentRequest",
2479
- paymentRequestId: "mock-pr-id"
2493
+ paymentRequestId: params.get("paymentRequestId") ?? "mock-pr-id"
2480
2494
  };
2481
2495
  }
2482
2496
  }
@@ -1,5 +1,5 @@
1
1
  import { sql, and, eq, isNull } from 'drizzle-orm';
2
- import { G as tables, b as FinbricksConnector, J as buildEndToEndId, c as MockConnector, D as DbuConnector, C as CsobConnector, K as KBConnector, M as MockCobsConnector, E as ErsteConnector } from './bank.B10hoYtM.mjs';
2
+ import { G as tables, b as FinbricksConnector, J as buildEndToEndId, c as MockConnector, D as DbuConnector, C as CsobConnector, K as KBConnector, M as MockCobsConnector, E as ErsteConnector } from './bank.DI_Q2OtU.mjs';
3
3
  import { uuidv4 } from '@develit-io/backend-sdk';
4
4
  import './bank.BzDNLxB_.mjs';
5
5
  import 'date-fns';
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const drizzleOrm = require('drizzle-orm');
4
- const paymentDirection = require('./bank.B31L1QD_.cjs');
4
+ const paymentDirection = require('./bank.B1Xa5U2u.cjs');
5
5
  const backendSdk = require('@develit-io/backend-sdk');
6
6
  require('./bank.9Yw4KHyl.cjs');
7
7
  require('date-fns');
@@ -1208,7 +1208,12 @@ class FinbricksConnector extends IBankConnector {
1208
1208
  ss: payment.ss,
1209
1209
  ks: payment.ks
1210
1210
  });
1211
- const combined = [reference, message].filter(Boolean).join(" ");
1211
+ const udt = this.PROVIDER === "CSOB" ? buildUltimateCreditor(payment.creditor, {
1212
+ stripDiacritics: payment.currency !== "CZK"
1213
+ }) : void 0;
1214
+ const reserved = (reference ? reference.length + 1 : 0) + (udt ? udt.length + 2 : 0);
1215
+ const base = [message.slice(0, Math.max(0, 140 - reserved)), reference].filter(Boolean).join(" ");
1216
+ const combined = udt ? base ? `${base}, ${udt}` : udt : base;
1212
1217
  const unstructured = (combined.length >= 3 ? combined : "Platba").slice(
1213
1218
  0,
1214
1219
  140
@@ -2470,11 +2475,20 @@ class MockConnector extends IBankConnector {
2470
2475
  async getPaymentStatus(_) {
2471
2476
  return "SETTLED";
2472
2477
  }
2473
- parseAuthorizationCallback(_callbackUrl) {
2478
+ parseAuthorizationCallback(callbackUrl) {
2479
+ const params = new URL(callbackUrl).searchParams;
2480
+ const error = params.get("error");
2481
+ if (error) {
2482
+ return {
2483
+ success: false,
2484
+ error,
2485
+ code: params.get("code")
2486
+ };
2487
+ }
2474
2488
  return {
2475
2489
  success: true,
2476
2490
  type: "paymentRequest",
2477
- paymentRequestId: "mock-pr-id"
2491
+ paymentRequestId: params.get("paymentRequestId") ?? "mock-pr-id"
2478
2492
  };
2479
2493
  }
2480
2494
  }
@@ -3606,7 +3606,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
3606
3606
  name: string;
3607
3607
  tableName: "payment";
3608
3608
  dataType: "string enum";
3609
- data: "BOOKED" | "REJECTED" | "PROCESSING" | "PENDING" | "CANCELLED" | "SCHEDULED" | "HOLD" | "INFO";
3609
+ data: "BOOKED" | "REJECTED" | "PENDING" | "PROCESSING" | "CANCELLED" | "SCHEDULED" | "HOLD" | "INFO";
3610
3610
  driverParam: string;
3611
3611
  notNull: true;
3612
3612
  hasDefault: false;
@@ -4110,7 +4110,7 @@ declare const paymentRequest: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
4110
4110
  name: string;
4111
4111
  tableName: "payment_request";
4112
4112
  dataType: "string enum";
4113
- data: "OPENED" | "AUTHORIZED" | "COMPLETED" | "BOOKED" | "SETTLED" | "REJECTED" | "CLOSED";
4113
+ data: "AUTHORIZED" | "OPENED" | "COMPLETED" | "BOOKED" | "SETTLED" | "REJECTED" | "CLOSED";
4114
4114
  driverParam: string;
4115
4115
  notNull: true;
4116
4116
  hasDefault: false;
@@ -3606,7 +3606,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
3606
3606
  name: string;
3607
3607
  tableName: "payment";
3608
3608
  dataType: "string enum";
3609
- data: "BOOKED" | "REJECTED" | "PROCESSING" | "PENDING" | "CANCELLED" | "SCHEDULED" | "HOLD" | "INFO";
3609
+ data: "BOOKED" | "REJECTED" | "PENDING" | "PROCESSING" | "CANCELLED" | "SCHEDULED" | "HOLD" | "INFO";
3610
3610
  driverParam: string;
3611
3611
  notNull: true;
3612
3612
  hasDefault: false;
@@ -4110,7 +4110,7 @@ declare const paymentRequest: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
4110
4110
  name: string;
4111
4111
  tableName: "payment_request";
4112
4112
  dataType: "string enum";
4113
- data: "OPENED" | "AUTHORIZED" | "COMPLETED" | "BOOKED" | "SETTLED" | "REJECTED" | "CLOSED";
4113
+ data: "AUTHORIZED" | "OPENED" | "COMPLETED" | "BOOKED" | "SETTLED" | "REJECTED" | "CLOSED";
4114
4114
  driverParam: string;
4115
4115
  notNull: true;
4116
4116
  hasDefault: false;
@@ -3606,7 +3606,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
3606
3606
  name: string;
3607
3607
  tableName: "payment";
3608
3608
  dataType: "string enum";
3609
- data: "BOOKED" | "REJECTED" | "PROCESSING" | "PENDING" | "CANCELLED" | "SCHEDULED" | "HOLD" | "INFO";
3609
+ data: "BOOKED" | "REJECTED" | "PENDING" | "PROCESSING" | "CANCELLED" | "SCHEDULED" | "HOLD" | "INFO";
3610
3610
  driverParam: string;
3611
3611
  notNull: true;
3612
3612
  hasDefault: false;
@@ -4110,7 +4110,7 @@ declare const paymentRequest: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
4110
4110
  name: string;
4111
4111
  tableName: "payment_request";
4112
4112
  dataType: "string enum";
4113
- data: "OPENED" | "AUTHORIZED" | "COMPLETED" | "BOOKED" | "SETTLED" | "REJECTED" | "CLOSED";
4113
+ data: "AUTHORIZED" | "OPENED" | "COMPLETED" | "BOOKED" | "SETTLED" | "REJECTED" | "CLOSED";
4114
4114
  driverParam: string;
4115
4115
  notNull: true;
4116
4116
  hasDefault: false;
@@ -1,4 +1,4 @@
1
- import { e as CurrencyCode, R as BankCode, a1 as CountryCode, P as PaymentRequestSelectType } from './bank.BrBu52ls.mjs';
1
+ import { e as CurrencyCode, R as BankCode, a1 as CountryCode, P as PaymentRequestSelectType } from './bank.DmZly4Hz.cjs';
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, R as BankCode, a1 as CountryCode, P as PaymentRequestSelectType } from './bank.BrBu52ls.cjs';
1
+ import { e as CurrencyCode, R as BankCode, a1 as CountryCode, P as PaymentRequestSelectType } from './bank.DmZly4Hz.mjs';
2
2
  import { z } from 'zod';
3
3
 
4
4
  type ReferenceType = `${'VS' | 'SS' | 'KS'}:${number}`;
package/dist/types.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const paymentDirection = require('./shared/bank.B31L1QD_.cjs');
3
+ const paymentDirection = require('./shared/bank.B1Xa5U2u.cjs');
4
4
  const database_schema = require('./shared/bank.9Yw4KHyl.cjs');
5
5
  const batchLifecycle = require('./shared/bank.NF8bZBy0.cjs');
6
6
  const generalCodes = require('@develit-io/general-codes');
package/dist/types.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- import { I as IBankConnector, b as ConnectorKey, g as ConnectedAccount, d as PaymentType, h as CredentialsResolver, i as AccountCredentialsInsertType, j as AccountInsertType, k as BatchedPayment, l as InitiatedBatch, m as IncomingPayment, n as InitiatedPayment, A as AccountSelectType, o as ParsedBankPayment, p as PaymentRequestStatus, q as AuthorizationCallbackResult, r as BatchMetadata, s as Currency, a as PaymentSelectType, P as PaymentRequestSelectType, u as AccountAssignedPayment, v as PreparedPayment, w as CompletedPayment, x as PaymentRequestInsertType } from './shared/bank.BrBu52ls.cjs';
2
- export { y as ACCOUNT_STATUSES, z as AccountCredentialsPatchType, D as AccountCredentialsSelectType, E as AccountCredentialsUpdateType, F as AccountPatchType, G as AccountStatus, J as AccountUpdateType, K as AuthorizedBatch, M as BASE_TERMINAL_STATUSES, N as BATCH_MODES, O as BATCH_STATUES, O as BATCH_STATUSES, Q as BankAccountWithLastSync, R as BankCode, S as BatchInsertType, T as BatchLifecycle, U as BatchMode, V as BatchPayment, B as BatchSelectType, W as BatchStatus, X as CHARGE_BEARERS, Y as CONNECTOR_KEYS, Z as COUNTRY_CODES, _ as CREDENTIALS_TYPES, $ as ChargeBearer, a0 as CompletedBatch, c as ConfigEnvironmentBank, C as ConnectorConfig, a1 as CountryCode, a2 as CredentialsType, e as CurrencyCode, a3 as INSTRUCTION_PRIORITIES, a4 as InstructionPriority, L as LastSyncMetadata, a5 as PAYMENT_DIRECTIONS, a6 as PAYMENT_REQUEST_STATUSES, a7 as PAYMENT_STATUSES, a8 as PAYMENT_TYPES, a9 as PaymentDirection, aa as PaymentFailedInsertType, ab as PaymentInsertType, ac as PaymentLifecycle, ad as PaymentPreparedInsertType, ae as PaymentStatus, af as ProcessingBatch, ag as ReadyToSignBatch, ah as ResolvedCredentials, ai as TOKEN_TYPES, aj as TokenType, ak as accountCredentialsInsertSchema, al as accountCredentialsSelectSchema, am as accountCredentialsUpdateSchema, an as accountInsertSchema, ao as accountSelectSchema, ap as accountUpdateSchema, aq as hasPaymentAccountAssigned, ar as isBatchAuthorized, as as isBatchCompleted, at as isBatchFailed, au as isBatchInitiated, av as isBatchProcessing, aw as isBatchReadyToSign, ax as isPaymentCompleted, ay as isPendingStatus, az as isProcessedStatus, aA as isTerminalStatus } from './shared/bank.BrBu52ls.cjs';
3
- import { d as FinbricksAccount, R as ReferenceType, S as SendPaymentInput } from './shared/bank.Dzk9ABBs.cjs';
4
- export { e as FinbricksAccountTransactionsResponse, f as FinbricksAccountsListResponse, g as FinbricksAuthTokenResponse, h as FinbricksBatchResponse, i as FinbricksConnectAccountResponse, j as FinbricksPaymentResponse, k as FinbricksSupportedBank, F as FinbricksSupportedBanksResponse, b as SendPaymentSyncInput } from './shared/bank.Dzk9ABBs.cjs';
1
+ import { I as IBankConnector, b as ConnectorKey, g as ConnectedAccount, d as PaymentType, h as CredentialsResolver, i as AccountCredentialsInsertType, j as AccountInsertType, k as BatchedPayment, l as InitiatedBatch, m as IncomingPayment, n as InitiatedPayment, A as AccountSelectType, o as ParsedBankPayment, p as PaymentRequestStatus, q as AuthorizationCallbackResult, r as BatchMetadata, s as Currency, a as PaymentSelectType, P as PaymentRequestSelectType, u as AccountAssignedPayment, v as PreparedPayment, w as CompletedPayment, x as PaymentRequestInsertType } from './shared/bank.DmZly4Hz.cjs';
2
+ export { y as ACCOUNT_STATUSES, z as AccountCredentialsPatchType, D as AccountCredentialsSelectType, E as AccountCredentialsUpdateType, F as AccountPatchType, G as AccountStatus, J as AccountUpdateType, K as AuthorizedBatch, M as BASE_TERMINAL_STATUSES, N as BATCH_MODES, O as BATCH_STATUES, O as BATCH_STATUSES, Q as BankAccountWithLastSync, R as BankCode, S as BatchInsertType, T as BatchLifecycle, U as BatchMode, V as BatchPayment, B as BatchSelectType, W as BatchStatus, X as CHARGE_BEARERS, Y as CONNECTOR_KEYS, Z as COUNTRY_CODES, _ as CREDENTIALS_TYPES, $ as ChargeBearer, a0 as CompletedBatch, c as ConfigEnvironmentBank, C as ConnectorConfig, a1 as CountryCode, a2 as CredentialsType, e as CurrencyCode, a3 as INSTRUCTION_PRIORITIES, a4 as InstructionPriority, L as LastSyncMetadata, a5 as PAYMENT_DIRECTIONS, a6 as PAYMENT_REQUEST_STATUSES, a7 as PAYMENT_STATUSES, a8 as PAYMENT_TYPES, a9 as PaymentDirection, aa as PaymentFailedInsertType, ab as PaymentInsertType, ac as PaymentLifecycle, ad as PaymentPreparedInsertType, ae as PaymentStatus, af as ProcessingBatch, ag as ReadyToSignBatch, ah as ResolvedCredentials, ai as TOKEN_TYPES, aj as TokenType, ak as accountCredentialsInsertSchema, al as accountCredentialsSelectSchema, am as accountCredentialsUpdateSchema, an as accountInsertSchema, ao as accountSelectSchema, ap as accountUpdateSchema, aq as hasPaymentAccountAssigned, ar as isBatchAuthorized, as as isBatchCompleted, at as isBatchFailed, au as isBatchInitiated, av as isBatchProcessing, aw as isBatchReadyToSign, ax as isPaymentCompleted, ay as isPendingStatus, az as isProcessedStatus, aA as isTerminalStatus } from './shared/bank.DmZly4Hz.cjs';
3
+ import { d as FinbricksAccount, R as ReferenceType, S as SendPaymentInput } from './shared/bank.Dyt5JZy1.cjs';
4
+ export { e as FinbricksAccountTransactionsResponse, f as FinbricksAccountsListResponse, g as FinbricksAuthTokenResponse, h as FinbricksBatchResponse, i as FinbricksConnectAccountResponse, j as FinbricksPaymentResponse, k as FinbricksSupportedBank, F as FinbricksSupportedBanksResponse, b as SendPaymentSyncInput } from './shared/bank.Dyt5JZy1.cjs';
5
5
  import { z } from 'zod';
6
6
  import { BaseEvent } from '@develit-io/backend-sdk';
7
7
  import * as drizzle_orm_zod from 'drizzle-orm/zod';
@@ -571,7 +571,7 @@ declare class MockConnector extends IBankConnector {
571
571
  getPaymentStatus(_: {
572
572
  paymentId: string;
573
573
  }): Promise<PaymentRequestStatus>;
574
- parseAuthorizationCallback(_callbackUrl: string): AuthorizationCallbackResult;
574
+ parseAuthorizationCallback(callbackUrl: string): AuthorizationCallbackResult;
575
575
  }
576
576
 
577
577
  interface ErsteAuthenticationResponse {
package/dist/types.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { I as IBankConnector, b as ConnectorKey, g as ConnectedAccount, d as PaymentType, h as CredentialsResolver, i as AccountCredentialsInsertType, j as AccountInsertType, k as BatchedPayment, l as InitiatedBatch, m as IncomingPayment, n as InitiatedPayment, A as AccountSelectType, o as ParsedBankPayment, p as PaymentRequestStatus, q as AuthorizationCallbackResult, r as BatchMetadata, s as Currency, a as PaymentSelectType, P as PaymentRequestSelectType, u as AccountAssignedPayment, v as PreparedPayment, w as CompletedPayment, x as PaymentRequestInsertType } from './shared/bank.BrBu52ls.mjs';
2
- export { y as ACCOUNT_STATUSES, z as AccountCredentialsPatchType, D as AccountCredentialsSelectType, E as AccountCredentialsUpdateType, F as AccountPatchType, G as AccountStatus, J as AccountUpdateType, K as AuthorizedBatch, M as BASE_TERMINAL_STATUSES, N as BATCH_MODES, O as BATCH_STATUES, O as BATCH_STATUSES, Q as BankAccountWithLastSync, R as BankCode, S as BatchInsertType, T as BatchLifecycle, U as BatchMode, V as BatchPayment, B as BatchSelectType, W as BatchStatus, X as CHARGE_BEARERS, Y as CONNECTOR_KEYS, Z as COUNTRY_CODES, _ as CREDENTIALS_TYPES, $ as ChargeBearer, a0 as CompletedBatch, c as ConfigEnvironmentBank, C as ConnectorConfig, a1 as CountryCode, a2 as CredentialsType, e as CurrencyCode, a3 as INSTRUCTION_PRIORITIES, a4 as InstructionPriority, L as LastSyncMetadata, a5 as PAYMENT_DIRECTIONS, a6 as PAYMENT_REQUEST_STATUSES, a7 as PAYMENT_STATUSES, a8 as PAYMENT_TYPES, a9 as PaymentDirection, aa as PaymentFailedInsertType, ab as PaymentInsertType, ac as PaymentLifecycle, ad as PaymentPreparedInsertType, ae as PaymentStatus, af as ProcessingBatch, ag as ReadyToSignBatch, ah as ResolvedCredentials, ai as TOKEN_TYPES, aj as TokenType, ak as accountCredentialsInsertSchema, al as accountCredentialsSelectSchema, am as accountCredentialsUpdateSchema, an as accountInsertSchema, ao as accountSelectSchema, ap as accountUpdateSchema, aq as hasPaymentAccountAssigned, ar as isBatchAuthorized, as as isBatchCompleted, at as isBatchFailed, au as isBatchInitiated, av as isBatchProcessing, aw as isBatchReadyToSign, ax as isPaymentCompleted, ay as isPendingStatus, az as isProcessedStatus, aA as isTerminalStatus } from './shared/bank.BrBu52ls.mjs';
3
- import { d as FinbricksAccount, R as ReferenceType, S as SendPaymentInput } from './shared/bank.o3KC69CF.mjs';
4
- export { e as FinbricksAccountTransactionsResponse, f as FinbricksAccountsListResponse, g as FinbricksAuthTokenResponse, h as FinbricksBatchResponse, i as FinbricksConnectAccountResponse, j as FinbricksPaymentResponse, k as FinbricksSupportedBank, F as FinbricksSupportedBanksResponse, b as SendPaymentSyncInput } from './shared/bank.o3KC69CF.mjs';
1
+ import { I as IBankConnector, b as ConnectorKey, g as ConnectedAccount, d as PaymentType, h as CredentialsResolver, i as AccountCredentialsInsertType, j as AccountInsertType, k as BatchedPayment, l as InitiatedBatch, m as IncomingPayment, n as InitiatedPayment, A as AccountSelectType, o as ParsedBankPayment, p as PaymentRequestStatus, q as AuthorizationCallbackResult, r as BatchMetadata, s as Currency, a as PaymentSelectType, P as PaymentRequestSelectType, u as AccountAssignedPayment, v as PreparedPayment, w as CompletedPayment, x as PaymentRequestInsertType } from './shared/bank.DmZly4Hz.mjs';
2
+ export { y as ACCOUNT_STATUSES, z as AccountCredentialsPatchType, D as AccountCredentialsSelectType, E as AccountCredentialsUpdateType, F as AccountPatchType, G as AccountStatus, J as AccountUpdateType, K as AuthorizedBatch, M as BASE_TERMINAL_STATUSES, N as BATCH_MODES, O as BATCH_STATUES, O as BATCH_STATUSES, Q as BankAccountWithLastSync, R as BankCode, S as BatchInsertType, T as BatchLifecycle, U as BatchMode, V as BatchPayment, B as BatchSelectType, W as BatchStatus, X as CHARGE_BEARERS, Y as CONNECTOR_KEYS, Z as COUNTRY_CODES, _ as CREDENTIALS_TYPES, $ as ChargeBearer, a0 as CompletedBatch, c as ConfigEnvironmentBank, C as ConnectorConfig, a1 as CountryCode, a2 as CredentialsType, e as CurrencyCode, a3 as INSTRUCTION_PRIORITIES, a4 as InstructionPriority, L as LastSyncMetadata, a5 as PAYMENT_DIRECTIONS, a6 as PAYMENT_REQUEST_STATUSES, a7 as PAYMENT_STATUSES, a8 as PAYMENT_TYPES, a9 as PaymentDirection, aa as PaymentFailedInsertType, ab as PaymentInsertType, ac as PaymentLifecycle, ad as PaymentPreparedInsertType, ae as PaymentStatus, af as ProcessingBatch, ag as ReadyToSignBatch, ah as ResolvedCredentials, ai as TOKEN_TYPES, aj as TokenType, ak as accountCredentialsInsertSchema, al as accountCredentialsSelectSchema, am as accountCredentialsUpdateSchema, an as accountInsertSchema, ao as accountSelectSchema, ap as accountUpdateSchema, aq as hasPaymentAccountAssigned, ar as isBatchAuthorized, as as isBatchCompleted, at as isBatchFailed, au as isBatchInitiated, av as isBatchProcessing, aw as isBatchReadyToSign, ax as isPaymentCompleted, ay as isPendingStatus, az as isProcessedStatus, aA as isTerminalStatus } from './shared/bank.DmZly4Hz.mjs';
3
+ import { d as FinbricksAccount, R as ReferenceType, S as SendPaymentInput } from './shared/bank.sVKKxDLm.mjs';
4
+ export { e as FinbricksAccountTransactionsResponse, f as FinbricksAccountsListResponse, g as FinbricksAuthTokenResponse, h as FinbricksBatchResponse, i as FinbricksConnectAccountResponse, j as FinbricksPaymentResponse, k as FinbricksSupportedBank, F as FinbricksSupportedBanksResponse, b as SendPaymentSyncInput } from './shared/bank.sVKKxDLm.mjs';
5
5
  import { z } from 'zod';
6
6
  import { BaseEvent } from '@develit-io/backend-sdk';
7
7
  import * as drizzle_orm_zod from 'drizzle-orm/zod';
@@ -571,7 +571,7 @@ declare class MockConnector extends IBankConnector {
571
571
  getPaymentStatus(_: {
572
572
  paymentId: string;
573
573
  }): Promise<PaymentRequestStatus>;
574
- parseAuthorizationCallback(_callbackUrl: string): AuthorizationCallbackResult;
574
+ parseAuthorizationCallback(callbackUrl: string): AuthorizationCallbackResult;
575
575
  }
576
576
 
577
577
  interface ErsteAuthenticationResponse {
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { I as IBankConnector, b as ConnectorKey, g as ConnectedAccount, d as PaymentType, h as CredentialsResolver, i as AccountCredentialsInsertType, j as AccountInsertType, k as BatchedPayment, l as InitiatedBatch, m as IncomingPayment, n as InitiatedPayment, A as AccountSelectType, o as ParsedBankPayment, p as PaymentRequestStatus, q as AuthorizationCallbackResult, r as BatchMetadata, s as Currency, a as PaymentSelectType, P as PaymentRequestSelectType, u as AccountAssignedPayment, v as PreparedPayment, w as CompletedPayment, x as PaymentRequestInsertType } from './shared/bank.BrBu52ls.js';
2
- export { y as ACCOUNT_STATUSES, z as AccountCredentialsPatchType, D as AccountCredentialsSelectType, E as AccountCredentialsUpdateType, F as AccountPatchType, G as AccountStatus, J as AccountUpdateType, K as AuthorizedBatch, M as BASE_TERMINAL_STATUSES, N as BATCH_MODES, O as BATCH_STATUES, O as BATCH_STATUSES, Q as BankAccountWithLastSync, R as BankCode, S as BatchInsertType, T as BatchLifecycle, U as BatchMode, V as BatchPayment, B as BatchSelectType, W as BatchStatus, X as CHARGE_BEARERS, Y as CONNECTOR_KEYS, Z as COUNTRY_CODES, _ as CREDENTIALS_TYPES, $ as ChargeBearer, a0 as CompletedBatch, c as ConfigEnvironmentBank, C as ConnectorConfig, a1 as CountryCode, a2 as CredentialsType, e as CurrencyCode, a3 as INSTRUCTION_PRIORITIES, a4 as InstructionPriority, L as LastSyncMetadata, a5 as PAYMENT_DIRECTIONS, a6 as PAYMENT_REQUEST_STATUSES, a7 as PAYMENT_STATUSES, a8 as PAYMENT_TYPES, a9 as PaymentDirection, aa as PaymentFailedInsertType, ab as PaymentInsertType, ac as PaymentLifecycle, ad as PaymentPreparedInsertType, ae as PaymentStatus, af as ProcessingBatch, ag as ReadyToSignBatch, ah as ResolvedCredentials, ai as TOKEN_TYPES, aj as TokenType, ak as accountCredentialsInsertSchema, al as accountCredentialsSelectSchema, am as accountCredentialsUpdateSchema, an as accountInsertSchema, ao as accountSelectSchema, ap as accountUpdateSchema, aq as hasPaymentAccountAssigned, ar as isBatchAuthorized, as as isBatchCompleted, at as isBatchFailed, au as isBatchInitiated, av as isBatchProcessing, aw as isBatchReadyToSign, ax as isPaymentCompleted, ay as isPendingStatus, az as isProcessedStatus, aA as isTerminalStatus } from './shared/bank.BrBu52ls.js';
3
- import { d as FinbricksAccount, R as ReferenceType, S as SendPaymentInput } from './shared/bank.Cfz0frnc.js';
4
- export { e as FinbricksAccountTransactionsResponse, f as FinbricksAccountsListResponse, g as FinbricksAuthTokenResponse, h as FinbricksBatchResponse, i as FinbricksConnectAccountResponse, j as FinbricksPaymentResponse, k as FinbricksSupportedBank, F as FinbricksSupportedBanksResponse, b as SendPaymentSyncInput } from './shared/bank.Cfz0frnc.js';
1
+ import { I as IBankConnector, b as ConnectorKey, g as ConnectedAccount, d as PaymentType, h as CredentialsResolver, i as AccountCredentialsInsertType, j as AccountInsertType, k as BatchedPayment, l as InitiatedBatch, m as IncomingPayment, n as InitiatedPayment, A as AccountSelectType, o as ParsedBankPayment, p as PaymentRequestStatus, q as AuthorizationCallbackResult, r as BatchMetadata, s as Currency, a as PaymentSelectType, P as PaymentRequestSelectType, u as AccountAssignedPayment, v as PreparedPayment, w as CompletedPayment, x as PaymentRequestInsertType } from './shared/bank.DmZly4Hz.js';
2
+ export { y as ACCOUNT_STATUSES, z as AccountCredentialsPatchType, D as AccountCredentialsSelectType, E as AccountCredentialsUpdateType, F as AccountPatchType, G as AccountStatus, J as AccountUpdateType, K as AuthorizedBatch, M as BASE_TERMINAL_STATUSES, N as BATCH_MODES, O as BATCH_STATUES, O as BATCH_STATUSES, Q as BankAccountWithLastSync, R as BankCode, S as BatchInsertType, T as BatchLifecycle, U as BatchMode, V as BatchPayment, B as BatchSelectType, W as BatchStatus, X as CHARGE_BEARERS, Y as CONNECTOR_KEYS, Z as COUNTRY_CODES, _ as CREDENTIALS_TYPES, $ as ChargeBearer, a0 as CompletedBatch, c as ConfigEnvironmentBank, C as ConnectorConfig, a1 as CountryCode, a2 as CredentialsType, e as CurrencyCode, a3 as INSTRUCTION_PRIORITIES, a4 as InstructionPriority, L as LastSyncMetadata, a5 as PAYMENT_DIRECTIONS, a6 as PAYMENT_REQUEST_STATUSES, a7 as PAYMENT_STATUSES, a8 as PAYMENT_TYPES, a9 as PaymentDirection, aa as PaymentFailedInsertType, ab as PaymentInsertType, ac as PaymentLifecycle, ad as PaymentPreparedInsertType, ae as PaymentStatus, af as ProcessingBatch, ag as ReadyToSignBatch, ah as ResolvedCredentials, ai as TOKEN_TYPES, aj as TokenType, ak as accountCredentialsInsertSchema, al as accountCredentialsSelectSchema, am as accountCredentialsUpdateSchema, an as accountInsertSchema, ao as accountSelectSchema, ap as accountUpdateSchema, aq as hasPaymentAccountAssigned, ar as isBatchAuthorized, as as isBatchCompleted, at as isBatchFailed, au as isBatchInitiated, av as isBatchProcessing, aw as isBatchReadyToSign, ax as isPaymentCompleted, ay as isPendingStatus, az as isProcessedStatus, aA as isTerminalStatus } from './shared/bank.DmZly4Hz.js';
3
+ import { d as FinbricksAccount, R as ReferenceType, S as SendPaymentInput } from './shared/bank.0zYbe2ZB.js';
4
+ export { e as FinbricksAccountTransactionsResponse, f as FinbricksAccountsListResponse, g as FinbricksAuthTokenResponse, h as FinbricksBatchResponse, i as FinbricksConnectAccountResponse, j as FinbricksPaymentResponse, k as FinbricksSupportedBank, F as FinbricksSupportedBanksResponse, b as SendPaymentSyncInput } from './shared/bank.0zYbe2ZB.js';
5
5
  import { z } from 'zod';
6
6
  import { BaseEvent } from '@develit-io/backend-sdk';
7
7
  import * as drizzle_orm_zod from 'drizzle-orm/zod';
@@ -571,7 +571,7 @@ declare class MockConnector extends IBankConnector {
571
571
  getPaymentStatus(_: {
572
572
  paymentId: string;
573
573
  }): Promise<PaymentRequestStatus>;
574
- parseAuthorizationCallback(_callbackUrl: string): AuthorizationCallbackResult;
574
+ parseAuthorizationCallback(callbackUrl: string): AuthorizationCallbackResult;
575
575
  }
576
576
 
577
577
  interface ErsteAuthenticationResponse {
package/dist/types.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { B as BASE_TERMINAL_STATUSES, C as CsobConnector, D as DbuConnector, E as ErsteConnector, F as FINBRICKS_ENDPOINTS, a as FinbricksClient, b as FinbricksConnector, I as IBankConnector, K as KBConnector, M as MockCobsConnector, c as MockConnector, d as accountCredentialsInsertSchema, e as accountCredentialsSelectSchema, f as accountCredentialsUpdateSchema, g as accountInsertSchema, h as accountSelectSchema, i as accountUpdateSchema, j as assignAccount, k as dbuAccountConfigSchema, l as hasPaymentAccountAssigned, m as isPaymentCompleted, n as isPendingStatus, o as isProcessedStatus, p as isTerminalStatus, q as ottInsertSchema, r as ottSelectSchema, s as ottUpdateSchema, t as signFinbricksJws, u as toBatchedPayment, v as toBatchedPaymentFromPaymentRequest, w as toCompletedPayment, x as toIncomingPayment, y as toPaymentRequestInsert, z as toPreparedPayment, A as useFinbricksFetch } from './shared/bank.B10hoYtM.mjs';
1
+ export { B as BASE_TERMINAL_STATUSES, C as CsobConnector, D as DbuConnector, E as ErsteConnector, F as FINBRICKS_ENDPOINTS, a as FinbricksClient, b as FinbricksConnector, I as IBankConnector, K as KBConnector, M as MockCobsConnector, c as MockConnector, d as accountCredentialsInsertSchema, e as accountCredentialsSelectSchema, f as accountCredentialsUpdateSchema, g as accountInsertSchema, h as accountSelectSchema, i as accountUpdateSchema, j as assignAccount, k as dbuAccountConfigSchema, l as hasPaymentAccountAssigned, m as isPaymentCompleted, n as isPendingStatus, o as isProcessedStatus, p as isTerminalStatus, q as ottInsertSchema, r as ottSelectSchema, s as ottUpdateSchema, t as signFinbricksJws, u as toBatchedPayment, v as toBatchedPaymentFromPaymentRequest, w as toCompletedPayment, x as toIncomingPayment, y as toPaymentRequestInsert, z as toPreparedPayment, A as useFinbricksFetch } from './shared/bank.DI_Q2OtU.mjs';
2
2
  export { A as ACCOUNT_STATUSES, B as BATCH_MODES, a as BATCH_STATUES, a as BATCH_STATUSES, C as CHARGE_BEARERS, b as CONNECTOR_KEYS, c as COUNTRY_CODES, d as CREDENTIALS_TYPES, I as INSTRUCTION_PRIORITIES, P as PAYMENT_DIRECTIONS, e as PAYMENT_REQUEST_STATUSES, f as PAYMENT_STATUSES, g as PAYMENT_TYPES, T as TOKEN_TYPES } from './shared/bank.BzDNLxB_.mjs';
3
3
  export { i as isBatchAuthorized, a as isBatchCompleted, b as isBatchFailed, c as isBatchInitiated, d as isBatchProcessing, e as isBatchReadyToSign } from './shared/bank.XqSw509X.mjs';
4
4
  export { BANK_CODES, CURRENCY_CODES } from '@develit-io/general-codes';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@develit-services/bank",
3
- "version": "5.6.0",
3
+ "version": "5.7.0",
4
4
  "author": "Develit.io s.r.o.",
5
5
  "type": "module",
6
6
  "exports": {