@develit-services/bank 5.9.2 → 6.0.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 +14 -70
- package/dist/base.d.cts +15 -15
- package/dist/base.d.mts +15 -15
- package/dist/base.d.ts +15 -15
- package/dist/base.mjs +7 -63
- package/dist/database/schema.d.cts +1 -1
- package/dist/database/schema.d.mts +1 -1
- package/dist/database/schema.d.ts +1 -1
- package/dist/export/workflows.cjs +19 -10
- package/dist/export/workflows.d.cts +0 -1
- package/dist/export/workflows.d.mts +0 -1
- package/dist/export/workflows.d.ts +0 -1
- package/dist/export/workflows.mjs +19 -10
- package/dist/service.d.cts +0 -1
- package/dist/service.d.mts +0 -1
- package/dist/service.d.ts +0 -1
- package/dist/shared/{bank.DhMeQgpB.d.ts → bank.-8YAJoxw.d.ts} +1 -1
- package/dist/shared/{bank.D3w3JIsQ.d.ts → bank.CgiEbvJu.d.cts} +3 -3
- package/dist/shared/{bank.D3w3JIsQ.d.cts → bank.CgiEbvJu.d.mts} +3 -3
- package/dist/shared/{bank.D3w3JIsQ.d.mts → bank.CgiEbvJu.d.ts} +3 -3
- package/dist/shared/{bank.CDB7SWNr.d.mts → bank.D19D3a9C.d.mts} +1 -1
- package/dist/shared/{bank.DAjqsBQN.mjs → bank.D9DoIABz.mjs} +33 -13
- package/dist/shared/{bank.DBTtRCcf.cjs → bank.DQZxSHKV.cjs} +38 -14
- package/dist/shared/{bank.CggHtT3y.d.cts → bank.DZyrkXc_.d.cts} +1 -1
- package/dist/types.d.cts +4 -4
- package/dist/types.d.mts +4 -4
- package/dist/types.d.ts +4 -4
- package/package.json +1 -1
package/dist/base.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const backendSdk = require('@develit-io/backend-sdk');
|
|
4
4
|
const paymentDirection = require('./shared/bank.BsWBG0gb.cjs');
|
|
5
|
-
const bank = require('./shared/bank.
|
|
5
|
+
const bank = require('./shared/bank.DQZxSHKV.cjs');
|
|
6
6
|
const drizzleOrm = require('drizzle-orm');
|
|
7
7
|
const cloudflare_workers = require('cloudflare:workers');
|
|
8
8
|
const d1 = require('drizzle-orm/d1');
|
|
@@ -107,72 +107,31 @@ async function heartbeatSyncWorkflows({
|
|
|
107
107
|
);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
const DISPATCH_RECOVERY_WINDOW_MS = 5 * 60 * 1e3;
|
|
111
|
-
function buildDispatchInstanceId(accountId, nowMs, recoveryWindowMs = DISPATCH_RECOVERY_WINDOW_MS) {
|
|
112
|
-
return `${accountId}-${Math.floor(nowMs / recoveryWindowMs)}`;
|
|
113
|
-
}
|
|
114
|
-
function buildDispatchCreateOptions(instanceId, accountId, maxIterations) {
|
|
115
|
-
return {
|
|
116
|
-
id: instanceId,
|
|
117
|
-
// Omitted (not undefined) when unresolved: the workflow treats a missing
|
|
118
|
-
// budget as unbounded — degraded but syncing.
|
|
119
|
-
params: maxIterations == null ? { accountId } : { accountId, maxIterations },
|
|
120
|
-
// Dispatch mints ~24 instances per account per day and step outputs carry
|
|
121
|
-
// bank payloads — the default 30-day retention would pile up billable
|
|
122
|
-
// storage for state nobody reads after success.
|
|
123
|
-
retention: {
|
|
124
|
-
successRetention: "1 day",
|
|
125
|
-
errorRetention: "7 days"
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
function isAlreadyExists(err) {
|
|
130
|
-
return /already exists/i.test(extractMessage(err));
|
|
131
|
-
}
|
|
132
|
-
function isInstanceNotFound(err) {
|
|
133
|
-
return /instance.*not.?found|not.?found.*instance/i.test(extractMessage(err));
|
|
134
|
-
}
|
|
135
|
-
function extractMessage(err) {
|
|
136
|
-
return err instanceof Error ? err.message : typeof err === "object" && err !== null && "message" in err ? String(err.message) : "";
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const DEFAULT_MIN_GRACE_MS = 3 * 60 * 1e3;
|
|
140
110
|
async function dispatchSyncWorkflows({
|
|
141
111
|
entities,
|
|
142
112
|
createInstance,
|
|
143
113
|
logger,
|
|
144
114
|
now = Date.now,
|
|
145
|
-
|
|
146
|
-
recoveryWindowMs = DISPATCH_RECOVERY_WINDOW_MS
|
|
115
|
+
recoveryWindowMs = bank.DISPATCH_RECOVERY_WINDOW_MS
|
|
147
116
|
}) {
|
|
148
117
|
const at = now();
|
|
149
118
|
await Promise.all(
|
|
150
119
|
entities.map(async (entity) => {
|
|
151
120
|
const { id, lastSyncAt } = entity;
|
|
152
|
-
|
|
153
|
-
if (staleness == null) {
|
|
121
|
+
if (!lastSyncAt) {
|
|
154
122
|
logger.warn("sync-workflow.dispatch.sync-age-unknown", { id });
|
|
155
123
|
return;
|
|
156
124
|
}
|
|
157
|
-
|
|
158
|
-
const instanceId = buildDispatchInstanceId(id, at, recoveryWindowMs);
|
|
125
|
+
const instanceId = bank.buildDispatchInstanceId(id, at, recoveryWindowMs);
|
|
159
126
|
try {
|
|
160
127
|
await createInstance(instanceId, id);
|
|
161
128
|
logger.info("sync-workflow.dispatch.created", {
|
|
162
129
|
id,
|
|
163
130
|
instanceId,
|
|
164
|
-
lastSyncAt: lastSyncAt
|
|
165
|
-
staleForS: Math.round(staleness.staleForMs / 1e3),
|
|
166
|
-
thresholdS: Math.round(staleness.thresholdMs / 1e3)
|
|
131
|
+
lastSyncAt: lastSyncAt.toISOString()
|
|
167
132
|
});
|
|
168
133
|
} catch (err) {
|
|
169
|
-
if (isAlreadyExists(err))
|
|
170
|
-
logger.info("sync-workflow.dispatch.already-running", {
|
|
171
|
-
id,
|
|
172
|
-
instanceId
|
|
173
|
-
});
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
134
|
+
if (bank.isAlreadyExists(err)) return;
|
|
176
135
|
logger.error("sync-workflow.dispatch.failed", {
|
|
177
136
|
id,
|
|
178
137
|
instanceId,
|
|
@@ -1033,17 +992,14 @@ exports.BankServiceBase = class BankServiceBase extends backendSdk.develitWorker
|
|
|
1033
992
|
this.env.SYNC_DISPATCH_ACCOUNT_IDS,
|
|
1034
993
|
this.env.CRON_SYNC_WORKFLOW_DISPATCH
|
|
1035
994
|
)) {
|
|
1036
|
-
const instanceId = buildDispatchInstanceId(accountId, Date.now());
|
|
1037
|
-
const maxIterations = bank.parseIterationBudgetParam(
|
|
1038
|
-
this.env.SYNC_WORKFLOW_MAX_ITERATIONS
|
|
1039
|
-
);
|
|
995
|
+
const instanceId = bank.buildDispatchInstanceId(accountId, Date.now());
|
|
1040
996
|
let instance2;
|
|
1041
997
|
try {
|
|
1042
998
|
instance2 = await this.env.SYNC_ACCOUNT_PAYMENTS_WORKFLOW.create(
|
|
1043
|
-
buildDispatchCreateOptions(instanceId, accountId
|
|
999
|
+
bank.buildDispatchCreateOptions(instanceId, accountId)
|
|
1044
1000
|
);
|
|
1045
1001
|
} catch (err) {
|
|
1046
|
-
if (!isAlreadyExists(err)) throw err;
|
|
1002
|
+
if (!bank.isAlreadyExists(err)) throw err;
|
|
1047
1003
|
instance2 = await this.env.SYNC_ACCOUNT_PAYMENTS_WORKFLOW.get(instanceId);
|
|
1048
1004
|
}
|
|
1049
1005
|
return {
|
|
@@ -1088,17 +1044,14 @@ exports.BankServiceBase = class BankServiceBase extends backendSdk.develitWorker
|
|
|
1088
1044
|
this.env.SYNC_DISPATCH_ACCOUNT_IDS,
|
|
1089
1045
|
this.env.CRON_SYNC_WORKFLOW_DISPATCH
|
|
1090
1046
|
)) {
|
|
1091
|
-
const instanceId = buildDispatchInstanceId(accountId, Date.now());
|
|
1092
|
-
const maxIterations = bank.parseIterationBudgetParam(
|
|
1093
|
-
this.env.SYNC_WORKFLOW_MAX_ITERATIONS
|
|
1094
|
-
);
|
|
1047
|
+
const instanceId = bank.buildDispatchInstanceId(accountId, Date.now());
|
|
1095
1048
|
let instance2;
|
|
1096
1049
|
try {
|
|
1097
1050
|
instance2 = await this.env.SYNC_ACCOUNT_PAYMENTS_WORKFLOW.create(
|
|
1098
|
-
buildDispatchCreateOptions(instanceId, accountId
|
|
1051
|
+
bank.buildDispatchCreateOptions(instanceId, accountId)
|
|
1099
1052
|
);
|
|
1100
1053
|
} catch (err) {
|
|
1101
|
-
if (!isAlreadyExists(err)) throw err;
|
|
1054
|
+
if (!bank.isAlreadyExists(err)) throw err;
|
|
1102
1055
|
instance2 = await this.env.SYNC_ACCOUNT_PAYMENTS_WORKFLOW.get(instanceId);
|
|
1103
1056
|
await instance2.restart();
|
|
1104
1057
|
}
|
|
@@ -1113,7 +1066,7 @@ exports.BankServiceBase = class BankServiceBase extends backendSdk.develitWorker
|
|
|
1113
1066
|
await existing.restart();
|
|
1114
1067
|
instance = existing;
|
|
1115
1068
|
} catch (err) {
|
|
1116
|
-
if (!isInstanceNotFound(err)) throw err;
|
|
1069
|
+
if (!bank.isInstanceNotFound(err)) throw err;
|
|
1117
1070
|
}
|
|
1118
1071
|
if (!instance) {
|
|
1119
1072
|
instance = await this.env.SYNC_ACCOUNT_PAYMENTS_WORKFLOW.create({
|
|
@@ -1458,19 +1411,10 @@ exports.BankServiceBase = class BankServiceBase extends backendSdk.develitWorker
|
|
|
1458
1411
|
const selection = this.env.SYNC_DISPATCH_ACCOUNT_IDS;
|
|
1459
1412
|
if (!selection?.trim()) return;
|
|
1460
1413
|
const accounts = await getSyncCandidateAccountsQuery(this.db);
|
|
1461
|
-
const maxIterations = bank.parseIterationBudgetParam(
|
|
1462
|
-
this.env.SYNC_WORKFLOW_MAX_ITERATIONS
|
|
1463
|
-
);
|
|
1464
|
-
if (maxIterations == null) {
|
|
1465
|
-
syncEventConsoleLogger.error(
|
|
1466
|
-
"sync-workflow.dispatch.invalid-max-iterations",
|
|
1467
|
-
{ value: this.env.SYNC_WORKFLOW_MAX_ITERATIONS }
|
|
1468
|
-
);
|
|
1469
|
-
}
|
|
1470
1414
|
await dispatchSyncWorkflows({
|
|
1471
1415
|
entities: accounts.filter((a) => isDispatchEnabled(a.id, selection)),
|
|
1472
1416
|
createInstance: (instanceId, accountId) => this.env.SYNC_ACCOUNT_PAYMENTS_WORKFLOW.create(
|
|
1473
|
-
buildDispatchCreateOptions(instanceId, accountId
|
|
1417
|
+
bank.buildDispatchCreateOptions(instanceId, accountId)
|
|
1474
1418
|
),
|
|
1475
1419
|
logger: syncEventConsoleLogger
|
|
1476
1420
|
});
|
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.
|
|
2
|
-
import { S as SendPaymentInput, a as SendPaymentOutput, b as SendPaymentSyncInput, c as SendPaymentSyncOutput, F as FinbricksSupportedBanksResponse } from './shared/bank.
|
|
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.CgiEbvJu.cjs';
|
|
2
|
+
import { S as SendPaymentInput, a as SendPaymentOutput, b as SendPaymentSyncInput, c as SendPaymentSyncOutput, F as FinbricksSupportedBanksResponse } from './shared/bank.DZyrkXc_.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";
|
|
@@ -2711,15 +2711,15 @@ declare const getBatchesInputSchema: z.ZodObject<{
|
|
|
2711
2711
|
filterBatchAccountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodUUID, z.ZodArray<z.ZodUUID>]>>;
|
|
2712
2712
|
filterBatchStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
2713
2713
|
AUTHORIZED: "AUTHORIZED";
|
|
2714
|
+
COMPLETED: "COMPLETED";
|
|
2714
2715
|
PROCESSING: "PROCESSING";
|
|
2715
2716
|
READY_TO_SIGN: "READY_TO_SIGN";
|
|
2716
|
-
COMPLETED: "COMPLETED";
|
|
2717
2717
|
FAILED: "FAILED";
|
|
2718
2718
|
}>, z.ZodArray<z.ZodEnum<{
|
|
2719
2719
|
AUTHORIZED: "AUTHORIZED";
|
|
2720
|
+
COMPLETED: "COMPLETED";
|
|
2720
2721
|
PROCESSING: "PROCESSING";
|
|
2721
2722
|
READY_TO_SIGN: "READY_TO_SIGN";
|
|
2722
|
-
COMPLETED: "COMPLETED";
|
|
2723
2723
|
FAILED: "FAILED";
|
|
2724
2724
|
}>>]>>;
|
|
2725
2725
|
}, z.core.$strip>;
|
|
@@ -2956,20 +2956,20 @@ declare const getPaymentsInputSchema: z.ZodObject<{
|
|
|
2956
2956
|
filterPaymentDateFrom: z.ZodOptional<z.ZodDate>;
|
|
2957
2957
|
filterPaymentDateTo: z.ZodOptional<z.ZodDate>;
|
|
2958
2958
|
filterPaymentStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
2959
|
-
PROCESSING: "PROCESSING";
|
|
2960
|
-
PENDING: "PENDING";
|
|
2961
2959
|
BOOKED: "BOOKED";
|
|
2962
|
-
CANCELLED: "CANCELLED";
|
|
2963
2960
|
REJECTED: "REJECTED";
|
|
2961
|
+
PENDING: "PENDING";
|
|
2962
|
+
PROCESSING: "PROCESSING";
|
|
2963
|
+
CANCELLED: "CANCELLED";
|
|
2964
2964
|
SCHEDULED: "SCHEDULED";
|
|
2965
2965
|
HOLD: "HOLD";
|
|
2966
2966
|
INFO: "INFO";
|
|
2967
2967
|
}>, z.ZodArray<z.ZodEnum<{
|
|
2968
|
-
PROCESSING: "PROCESSING";
|
|
2969
|
-
PENDING: "PENDING";
|
|
2970
2968
|
BOOKED: "BOOKED";
|
|
2971
|
-
CANCELLED: "CANCELLED";
|
|
2972
2969
|
REJECTED: "REJECTED";
|
|
2970
|
+
PENDING: "PENDING";
|
|
2971
|
+
PROCESSING: "PROCESSING";
|
|
2972
|
+
CANCELLED: "CANCELLED";
|
|
2973
2973
|
SCHEDULED: "SCHEDULED";
|
|
2974
2974
|
HOLD: "HOLD";
|
|
2975
2975
|
INFO: "INFO";
|
|
@@ -3903,20 +3903,20 @@ declare const getPaymentRequestsInputSchema: z.ZodObject<{
|
|
|
3903
3903
|
}, z.core.$strip>;
|
|
3904
3904
|
filterAccountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodUUID, z.ZodArray<z.ZodUUID>]>>;
|
|
3905
3905
|
filterStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
3906
|
+
OPENED: "OPENED";
|
|
3906
3907
|
AUTHORIZED: "AUTHORIZED";
|
|
3907
3908
|
COMPLETED: "COMPLETED";
|
|
3908
3909
|
BOOKED: "BOOKED";
|
|
3909
|
-
REJECTED: "REJECTED";
|
|
3910
|
-
OPENED: "OPENED";
|
|
3911
3910
|
SETTLED: "SETTLED";
|
|
3911
|
+
REJECTED: "REJECTED";
|
|
3912
3912
|
CLOSED: "CLOSED";
|
|
3913
3913
|
}>, z.ZodArray<z.ZodEnum<{
|
|
3914
|
+
OPENED: "OPENED";
|
|
3914
3915
|
AUTHORIZED: "AUTHORIZED";
|
|
3915
3916
|
COMPLETED: "COMPLETED";
|
|
3916
3917
|
BOOKED: "BOOKED";
|
|
3917
|
-
REJECTED: "REJECTED";
|
|
3918
|
-
OPENED: "OPENED";
|
|
3919
3918
|
SETTLED: "SETTLED";
|
|
3919
|
+
REJECTED: "REJECTED";
|
|
3920
3920
|
CLOSED: "CLOSED";
|
|
3921
3921
|
}>>]>>;
|
|
3922
3922
|
filterPaymentType: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
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.
|
|
2
|
-
import { S as SendPaymentInput, a as SendPaymentOutput, b as SendPaymentSyncInput, c as SendPaymentSyncOutput, F as FinbricksSupportedBanksResponse } from './shared/bank.
|
|
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.CgiEbvJu.mjs';
|
|
2
|
+
import { S as SendPaymentInput, a as SendPaymentOutput, b as SendPaymentSyncInput, c as SendPaymentSyncOutput, F as FinbricksSupportedBanksResponse } from './shared/bank.D19D3a9C.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";
|
|
@@ -2711,15 +2711,15 @@ declare const getBatchesInputSchema: z.ZodObject<{
|
|
|
2711
2711
|
filterBatchAccountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodUUID, z.ZodArray<z.ZodUUID>]>>;
|
|
2712
2712
|
filterBatchStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
2713
2713
|
AUTHORIZED: "AUTHORIZED";
|
|
2714
|
+
COMPLETED: "COMPLETED";
|
|
2714
2715
|
PROCESSING: "PROCESSING";
|
|
2715
2716
|
READY_TO_SIGN: "READY_TO_SIGN";
|
|
2716
|
-
COMPLETED: "COMPLETED";
|
|
2717
2717
|
FAILED: "FAILED";
|
|
2718
2718
|
}>, z.ZodArray<z.ZodEnum<{
|
|
2719
2719
|
AUTHORIZED: "AUTHORIZED";
|
|
2720
|
+
COMPLETED: "COMPLETED";
|
|
2720
2721
|
PROCESSING: "PROCESSING";
|
|
2721
2722
|
READY_TO_SIGN: "READY_TO_SIGN";
|
|
2722
|
-
COMPLETED: "COMPLETED";
|
|
2723
2723
|
FAILED: "FAILED";
|
|
2724
2724
|
}>>]>>;
|
|
2725
2725
|
}, z.core.$strip>;
|
|
@@ -2956,20 +2956,20 @@ declare const getPaymentsInputSchema: z.ZodObject<{
|
|
|
2956
2956
|
filterPaymentDateFrom: z.ZodOptional<z.ZodDate>;
|
|
2957
2957
|
filterPaymentDateTo: z.ZodOptional<z.ZodDate>;
|
|
2958
2958
|
filterPaymentStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
2959
|
-
PROCESSING: "PROCESSING";
|
|
2960
|
-
PENDING: "PENDING";
|
|
2961
2959
|
BOOKED: "BOOKED";
|
|
2962
|
-
CANCELLED: "CANCELLED";
|
|
2963
2960
|
REJECTED: "REJECTED";
|
|
2961
|
+
PENDING: "PENDING";
|
|
2962
|
+
PROCESSING: "PROCESSING";
|
|
2963
|
+
CANCELLED: "CANCELLED";
|
|
2964
2964
|
SCHEDULED: "SCHEDULED";
|
|
2965
2965
|
HOLD: "HOLD";
|
|
2966
2966
|
INFO: "INFO";
|
|
2967
2967
|
}>, z.ZodArray<z.ZodEnum<{
|
|
2968
|
-
PROCESSING: "PROCESSING";
|
|
2969
|
-
PENDING: "PENDING";
|
|
2970
2968
|
BOOKED: "BOOKED";
|
|
2971
|
-
CANCELLED: "CANCELLED";
|
|
2972
2969
|
REJECTED: "REJECTED";
|
|
2970
|
+
PENDING: "PENDING";
|
|
2971
|
+
PROCESSING: "PROCESSING";
|
|
2972
|
+
CANCELLED: "CANCELLED";
|
|
2973
2973
|
SCHEDULED: "SCHEDULED";
|
|
2974
2974
|
HOLD: "HOLD";
|
|
2975
2975
|
INFO: "INFO";
|
|
@@ -3903,20 +3903,20 @@ declare const getPaymentRequestsInputSchema: z.ZodObject<{
|
|
|
3903
3903
|
}, z.core.$strip>;
|
|
3904
3904
|
filterAccountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodUUID, z.ZodArray<z.ZodUUID>]>>;
|
|
3905
3905
|
filterStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
3906
|
+
OPENED: "OPENED";
|
|
3906
3907
|
AUTHORIZED: "AUTHORIZED";
|
|
3907
3908
|
COMPLETED: "COMPLETED";
|
|
3908
3909
|
BOOKED: "BOOKED";
|
|
3909
|
-
REJECTED: "REJECTED";
|
|
3910
|
-
OPENED: "OPENED";
|
|
3911
3910
|
SETTLED: "SETTLED";
|
|
3911
|
+
REJECTED: "REJECTED";
|
|
3912
3912
|
CLOSED: "CLOSED";
|
|
3913
3913
|
}>, z.ZodArray<z.ZodEnum<{
|
|
3914
|
+
OPENED: "OPENED";
|
|
3914
3915
|
AUTHORIZED: "AUTHORIZED";
|
|
3915
3916
|
COMPLETED: "COMPLETED";
|
|
3916
3917
|
BOOKED: "BOOKED";
|
|
3917
|
-
REJECTED: "REJECTED";
|
|
3918
|
-
OPENED: "OPENED";
|
|
3919
3918
|
SETTLED: "SETTLED";
|
|
3919
|
+
REJECTED: "REJECTED";
|
|
3920
3920
|
CLOSED: "CLOSED";
|
|
3921
3921
|
}>>]>>;
|
|
3922
3922
|
filterPaymentType: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
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.
|
|
2
|
-
import { S as SendPaymentInput, a as SendPaymentOutput, b as SendPaymentSyncInput, c as SendPaymentSyncOutput, F as FinbricksSupportedBanksResponse } from './shared/bank.
|
|
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.CgiEbvJu.js';
|
|
2
|
+
import { S as SendPaymentInput, a as SendPaymentOutput, b as SendPaymentSyncInput, c as SendPaymentSyncOutput, F as FinbricksSupportedBanksResponse } from './shared/bank.-8YAJoxw.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";
|
|
@@ -2711,15 +2711,15 @@ declare const getBatchesInputSchema: z.ZodObject<{
|
|
|
2711
2711
|
filterBatchAccountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodUUID, z.ZodArray<z.ZodUUID>]>>;
|
|
2712
2712
|
filterBatchStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
2713
2713
|
AUTHORIZED: "AUTHORIZED";
|
|
2714
|
+
COMPLETED: "COMPLETED";
|
|
2714
2715
|
PROCESSING: "PROCESSING";
|
|
2715
2716
|
READY_TO_SIGN: "READY_TO_SIGN";
|
|
2716
|
-
COMPLETED: "COMPLETED";
|
|
2717
2717
|
FAILED: "FAILED";
|
|
2718
2718
|
}>, z.ZodArray<z.ZodEnum<{
|
|
2719
2719
|
AUTHORIZED: "AUTHORIZED";
|
|
2720
|
+
COMPLETED: "COMPLETED";
|
|
2720
2721
|
PROCESSING: "PROCESSING";
|
|
2721
2722
|
READY_TO_SIGN: "READY_TO_SIGN";
|
|
2722
|
-
COMPLETED: "COMPLETED";
|
|
2723
2723
|
FAILED: "FAILED";
|
|
2724
2724
|
}>>]>>;
|
|
2725
2725
|
}, z.core.$strip>;
|
|
@@ -2956,20 +2956,20 @@ declare const getPaymentsInputSchema: z.ZodObject<{
|
|
|
2956
2956
|
filterPaymentDateFrom: z.ZodOptional<z.ZodDate>;
|
|
2957
2957
|
filterPaymentDateTo: z.ZodOptional<z.ZodDate>;
|
|
2958
2958
|
filterPaymentStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
2959
|
-
PROCESSING: "PROCESSING";
|
|
2960
|
-
PENDING: "PENDING";
|
|
2961
2959
|
BOOKED: "BOOKED";
|
|
2962
|
-
CANCELLED: "CANCELLED";
|
|
2963
2960
|
REJECTED: "REJECTED";
|
|
2961
|
+
PENDING: "PENDING";
|
|
2962
|
+
PROCESSING: "PROCESSING";
|
|
2963
|
+
CANCELLED: "CANCELLED";
|
|
2964
2964
|
SCHEDULED: "SCHEDULED";
|
|
2965
2965
|
HOLD: "HOLD";
|
|
2966
2966
|
INFO: "INFO";
|
|
2967
2967
|
}>, z.ZodArray<z.ZodEnum<{
|
|
2968
|
-
PROCESSING: "PROCESSING";
|
|
2969
|
-
PENDING: "PENDING";
|
|
2970
2968
|
BOOKED: "BOOKED";
|
|
2971
|
-
CANCELLED: "CANCELLED";
|
|
2972
2969
|
REJECTED: "REJECTED";
|
|
2970
|
+
PENDING: "PENDING";
|
|
2971
|
+
PROCESSING: "PROCESSING";
|
|
2972
|
+
CANCELLED: "CANCELLED";
|
|
2973
2973
|
SCHEDULED: "SCHEDULED";
|
|
2974
2974
|
HOLD: "HOLD";
|
|
2975
2975
|
INFO: "INFO";
|
|
@@ -3903,20 +3903,20 @@ declare const getPaymentRequestsInputSchema: z.ZodObject<{
|
|
|
3903
3903
|
}, z.core.$strip>;
|
|
3904
3904
|
filterAccountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodUUID, z.ZodArray<z.ZodUUID>]>>;
|
|
3905
3905
|
filterStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
3906
|
+
OPENED: "OPENED";
|
|
3906
3907
|
AUTHORIZED: "AUTHORIZED";
|
|
3907
3908
|
COMPLETED: "COMPLETED";
|
|
3908
3909
|
BOOKED: "BOOKED";
|
|
3909
|
-
REJECTED: "REJECTED";
|
|
3910
|
-
OPENED: "OPENED";
|
|
3911
3910
|
SETTLED: "SETTLED";
|
|
3911
|
+
REJECTED: "REJECTED";
|
|
3912
3912
|
CLOSED: "CLOSED";
|
|
3913
3913
|
}>, z.ZodArray<z.ZodEnum<{
|
|
3914
|
+
OPENED: "OPENED";
|
|
3914
3915
|
AUTHORIZED: "AUTHORIZED";
|
|
3915
3916
|
COMPLETED: "COMPLETED";
|
|
3916
3917
|
BOOKED: "BOOKED";
|
|
3917
|
-
REJECTED: "REJECTED";
|
|
3918
|
-
OPENED: "OPENED";
|
|
3919
3918
|
SETTLED: "SETTLED";
|
|
3919
|
+
REJECTED: "REJECTED";
|
|
3920
3920
|
CLOSED: "CLOSED";
|
|
3921
3921
|
}>>]>>;
|
|
3922
3922
|
filterPaymentType: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
package/dist/base.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { uuidv4, first, buildMultiFilterConditions as buildMultiFilterConditions$1, bankAccountMetadataSchema, structuredAddressSchema, workflowInstanceStatusSchema, develitWorker, createInternalError, action, service } from '@develit-io/backend-sdk';
|
|
2
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.kz-PKVi5.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { k as isAlreadyExists, D as DISPATCH_RECOVERY_WINDOW_MS, l as buildDispatchInstanceId, m as encrypt, d as createCredentialsResolver, i as initiateConnector, n as buildDispatchCreateOptions, o as isInstanceNotFound, e as updatePaymentRequestStatusCommand, a as getPaymentRequestsByBatchIdQuery, g as getBatchByIdQuery, u as upsertBatchCommand, b as getAccountByIdQuery, r as resolveCurrentSyncInstanceId, p as importAesKey, j as createPaymentCommand } from './shared/bank.D9DoIABz.mjs';
|
|
4
4
|
import { eq, sql, and, like, asc, desc, inArray, gte, lte, isNull, count } from 'drizzle-orm';
|
|
5
5
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
6
6
|
import { drizzle } from 'drizzle-orm/d1';
|
|
@@ -105,72 +105,31 @@ async function heartbeatSyncWorkflows({
|
|
|
105
105
|
);
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
const DISPATCH_RECOVERY_WINDOW_MS = 5 * 60 * 1e3;
|
|
109
|
-
function buildDispatchInstanceId(accountId, nowMs, recoveryWindowMs = DISPATCH_RECOVERY_WINDOW_MS) {
|
|
110
|
-
return `${accountId}-${Math.floor(nowMs / recoveryWindowMs)}`;
|
|
111
|
-
}
|
|
112
|
-
function buildDispatchCreateOptions(instanceId, accountId, maxIterations) {
|
|
113
|
-
return {
|
|
114
|
-
id: instanceId,
|
|
115
|
-
// Omitted (not undefined) when unresolved: the workflow treats a missing
|
|
116
|
-
// budget as unbounded — degraded but syncing.
|
|
117
|
-
params: maxIterations == null ? { accountId } : { accountId, maxIterations },
|
|
118
|
-
// Dispatch mints ~24 instances per account per day and step outputs carry
|
|
119
|
-
// bank payloads — the default 30-day retention would pile up billable
|
|
120
|
-
// storage for state nobody reads after success.
|
|
121
|
-
retention: {
|
|
122
|
-
successRetention: "1 day",
|
|
123
|
-
errorRetention: "7 days"
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
function isAlreadyExists(err) {
|
|
128
|
-
return /already exists/i.test(extractMessage(err));
|
|
129
|
-
}
|
|
130
|
-
function isInstanceNotFound(err) {
|
|
131
|
-
return /instance.*not.?found|not.?found.*instance/i.test(extractMessage(err));
|
|
132
|
-
}
|
|
133
|
-
function extractMessage(err) {
|
|
134
|
-
return err instanceof Error ? err.message : typeof err === "object" && err !== null && "message" in err ? String(err.message) : "";
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const DEFAULT_MIN_GRACE_MS = 3 * 60 * 1e3;
|
|
138
108
|
async function dispatchSyncWorkflows({
|
|
139
109
|
entities,
|
|
140
110
|
createInstance,
|
|
141
111
|
logger,
|
|
142
112
|
now = Date.now,
|
|
143
|
-
minGraceMs = DEFAULT_MIN_GRACE_MS,
|
|
144
113
|
recoveryWindowMs = DISPATCH_RECOVERY_WINDOW_MS
|
|
145
114
|
}) {
|
|
146
115
|
const at = now();
|
|
147
116
|
await Promise.all(
|
|
148
117
|
entities.map(async (entity) => {
|
|
149
118
|
const { id, lastSyncAt } = entity;
|
|
150
|
-
|
|
151
|
-
if (staleness == null) {
|
|
119
|
+
if (!lastSyncAt) {
|
|
152
120
|
logger.warn("sync-workflow.dispatch.sync-age-unknown", { id });
|
|
153
121
|
return;
|
|
154
122
|
}
|
|
155
|
-
if (staleness.staleForMs <= staleness.thresholdMs) return;
|
|
156
123
|
const instanceId = buildDispatchInstanceId(id, at, recoveryWindowMs);
|
|
157
124
|
try {
|
|
158
125
|
await createInstance(instanceId, id);
|
|
159
126
|
logger.info("sync-workflow.dispatch.created", {
|
|
160
127
|
id,
|
|
161
128
|
instanceId,
|
|
162
|
-
lastSyncAt: lastSyncAt
|
|
163
|
-
staleForS: Math.round(staleness.staleForMs / 1e3),
|
|
164
|
-
thresholdS: Math.round(staleness.thresholdMs / 1e3)
|
|
129
|
+
lastSyncAt: lastSyncAt.toISOString()
|
|
165
130
|
});
|
|
166
131
|
} catch (err) {
|
|
167
|
-
if (isAlreadyExists(err))
|
|
168
|
-
logger.info("sync-workflow.dispatch.already-running", {
|
|
169
|
-
id,
|
|
170
|
-
instanceId
|
|
171
|
-
});
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
132
|
+
if (isAlreadyExists(err)) return;
|
|
174
133
|
logger.error("sync-workflow.dispatch.failed", {
|
|
175
134
|
id,
|
|
176
135
|
instanceId,
|
|
@@ -1032,13 +991,10 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
1032
991
|
this.env.CRON_SYNC_WORKFLOW_DISPATCH
|
|
1033
992
|
)) {
|
|
1034
993
|
const instanceId = buildDispatchInstanceId(accountId, Date.now());
|
|
1035
|
-
const maxIterations = parseIterationBudgetParam(
|
|
1036
|
-
this.env.SYNC_WORKFLOW_MAX_ITERATIONS
|
|
1037
|
-
);
|
|
1038
994
|
let instance2;
|
|
1039
995
|
try {
|
|
1040
996
|
instance2 = await this.env.SYNC_ACCOUNT_PAYMENTS_WORKFLOW.create(
|
|
1041
|
-
buildDispatchCreateOptions(instanceId, accountId
|
|
997
|
+
buildDispatchCreateOptions(instanceId, accountId)
|
|
1042
998
|
);
|
|
1043
999
|
} catch (err) {
|
|
1044
1000
|
if (!isAlreadyExists(err)) throw err;
|
|
@@ -1087,13 +1043,10 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
1087
1043
|
this.env.CRON_SYNC_WORKFLOW_DISPATCH
|
|
1088
1044
|
)) {
|
|
1089
1045
|
const instanceId = buildDispatchInstanceId(accountId, Date.now());
|
|
1090
|
-
const maxIterations = parseIterationBudgetParam(
|
|
1091
|
-
this.env.SYNC_WORKFLOW_MAX_ITERATIONS
|
|
1092
|
-
);
|
|
1093
1046
|
let instance2;
|
|
1094
1047
|
try {
|
|
1095
1048
|
instance2 = await this.env.SYNC_ACCOUNT_PAYMENTS_WORKFLOW.create(
|
|
1096
|
-
buildDispatchCreateOptions(instanceId, accountId
|
|
1049
|
+
buildDispatchCreateOptions(instanceId, accountId)
|
|
1097
1050
|
);
|
|
1098
1051
|
} catch (err) {
|
|
1099
1052
|
if (!isAlreadyExists(err)) throw err;
|
|
@@ -1456,19 +1409,10 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
1456
1409
|
const selection = this.env.SYNC_DISPATCH_ACCOUNT_IDS;
|
|
1457
1410
|
if (!selection?.trim()) return;
|
|
1458
1411
|
const accounts = await getSyncCandidateAccountsQuery(this.db);
|
|
1459
|
-
const maxIterations = parseIterationBudgetParam(
|
|
1460
|
-
this.env.SYNC_WORKFLOW_MAX_ITERATIONS
|
|
1461
|
-
);
|
|
1462
|
-
if (maxIterations == null) {
|
|
1463
|
-
syncEventConsoleLogger.error(
|
|
1464
|
-
"sync-workflow.dispatch.invalid-max-iterations",
|
|
1465
|
-
{ value: this.env.SYNC_WORKFLOW_MAX_ITERATIONS }
|
|
1466
|
-
);
|
|
1467
|
-
}
|
|
1468
1412
|
await dispatchSyncWorkflows({
|
|
1469
1413
|
entities: accounts.filter((a) => isDispatchEnabled(a.id, selection)),
|
|
1470
1414
|
createInstance: (instanceId, accountId) => this.env.SYNC_ACCOUNT_PAYMENTS_WORKFLOW.create(
|
|
1471
|
-
buildDispatchCreateOptions(instanceId, accountId
|
|
1415
|
+
buildDispatchCreateOptions(instanceId, accountId)
|
|
1472
1416
|
),
|
|
1473
1417
|
logger: syncEventConsoleLogger
|
|
1474
1418
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { aC as account, aD as accountCredentials, aE as batch, aF as ott, aG as payment, aH as paymentRequest } from '../shared/bank.
|
|
1
|
+
export { aC as account, aD as accountCredentials, aE as batch, aF as ott, aG as payment, aH as paymentRequest } from '../shared/bank.CgiEbvJu.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 { aC as account, aD as accountCredentials, aE as batch, aF as ott, aG as payment, aH as paymentRequest } from '../shared/bank.
|
|
1
|
+
export { aC as account, aD as accountCredentials, aE as batch, aF as ott, aG as payment, aH as paymentRequest } from '../shared/bank.CgiEbvJu.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 { aC as account, aD as accountCredentials, aE as batch, aF as ott, aG as payment, aH as paymentRequest } from '../shared/bank.
|
|
1
|
+
export { aC as account, aD as accountCredentials, aE as batch, aF as ott, aG as payment, aH as paymentRequest } from '../shared/bank.CgiEbvJu.js';
|
|
2
2
|
import 'drizzle-orm/sqlite-core';
|
|
3
3
|
import 'drizzle-orm';
|
|
4
4
|
import '@develit-io/general-codes';
|
|
@@ -4,7 +4,7 @@ const backendSdk = require('@develit-io/backend-sdk');
|
|
|
4
4
|
const paymentDirection = require('../shared/bank.BsWBG0gb.cjs');
|
|
5
5
|
const batchLifecycle = require('../shared/bank.NF8bZBy0.cjs');
|
|
6
6
|
const drizzleOrm = require('drizzle-orm');
|
|
7
|
-
const bank = require('../shared/bank.
|
|
7
|
+
const bank = require('../shared/bank.DQZxSHKV.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');
|
|
@@ -425,18 +425,18 @@ async function pushToQueue(queue, message) {
|
|
|
425
425
|
}
|
|
426
426
|
class BankSyncAccountPayments extends cloudflare_workers.WorkflowEntrypoint {
|
|
427
427
|
async run(event, step) {
|
|
428
|
-
const { accountId
|
|
429
|
-
const iterationBudget = bank.resolveIterationBudget(maxIterations);
|
|
428
|
+
const { accountId } = event.payload;
|
|
430
429
|
const db = d1.drizzle(this.env.BANK_D1, { schema: paymentDirection.tables, relations: paymentDirection.relations });
|
|
431
430
|
const logger = createWorkflowLogger(event.instanceId);
|
|
432
431
|
if (!accountId) {
|
|
433
432
|
throw new cloudflare_workflows.NonRetryableError(`Haven't obtained accountId to load.`);
|
|
434
433
|
}
|
|
434
|
+
const deadlineMs = bank.computeWindowDeadline(event.instanceId, accountId);
|
|
435
435
|
const workflowStartedAt = await step.do(
|
|
436
436
|
"capture workflow start time",
|
|
437
437
|
async () => Date.now()
|
|
438
438
|
);
|
|
439
|
-
for (let iteration = 0;
|
|
439
|
+
for (let iteration = 0; ; iteration++) {
|
|
440
440
|
const account = await step.do("load account", async () => {
|
|
441
441
|
const account2 = await bank.getAccountByIdQuery(db, { accountId });
|
|
442
442
|
if (!account2) {
|
|
@@ -481,6 +481,15 @@ class BankSyncAccountPayments extends cloudflare_workers.WorkflowEntrypoint {
|
|
|
481
481
|
isCatchUp: window.isCatchUp
|
|
482
482
|
};
|
|
483
483
|
});
|
|
484
|
+
if (deadlineMs != null && windowMs.dateFromMs >= deadlineMs) {
|
|
485
|
+
logger.info("sync.window-elapsed", {
|
|
486
|
+
accountId,
|
|
487
|
+
instanceId: event.instanceId,
|
|
488
|
+
iteration,
|
|
489
|
+
deadline: new Date(deadlineMs).toISOString()
|
|
490
|
+
});
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
484
493
|
const syncWindow = {
|
|
485
494
|
dateFrom: new Date(windowMs.dateFromMs),
|
|
486
495
|
dateTo: new Date(windowMs.dateToMs),
|
|
@@ -695,6 +704,12 @@ class BankSyncAccountPayments extends cloudflare_workers.WorkflowEntrypoint {
|
|
|
695
704
|
lastSyncMetadata,
|
|
696
705
|
seenInstanceId: account.lastSyncMetadata?.instanceId ?? null
|
|
697
706
|
}).command;
|
|
707
|
+
if (eventsToEmit.length) {
|
|
708
|
+
await pushToQueue(
|
|
709
|
+
this.env.QUEUE_BUS_QUEUE,
|
|
710
|
+
eventsToEmit
|
|
711
|
+
);
|
|
712
|
+
}
|
|
698
713
|
let syncStateRows;
|
|
699
714
|
if (createCommands.length) {
|
|
700
715
|
const [updateResult] = await db.batch(
|
|
@@ -710,12 +725,6 @@ class BankSyncAccountPayments extends cloudflare_workers.WorkflowEntrypoint {
|
|
|
710
725
|
instanceId: event.instanceId
|
|
711
726
|
});
|
|
712
727
|
}
|
|
713
|
-
if (eventsToEmit.length) {
|
|
714
|
-
await pushToQueue(
|
|
715
|
-
this.env.QUEUE_BUS_QUEUE,
|
|
716
|
-
eventsToEmit
|
|
717
|
-
);
|
|
718
|
-
}
|
|
719
728
|
return {
|
|
720
729
|
...lastSyncMetadata,
|
|
721
730
|
newLastSyncAt: effectiveWindow.dateTo
|
|
@@ -9,7 +9,6 @@ declare class BankProcessBatch extends WorkflowEntrypoint<BankEnv, Params$1> {
|
|
|
9
9
|
|
|
10
10
|
type Params = {
|
|
11
11
|
accountId: string;
|
|
12
|
-
maxIterations?: number;
|
|
13
12
|
};
|
|
14
13
|
declare class BankSyncAccountPayments extends WorkflowEntrypoint<BankEnv, Params> {
|
|
15
14
|
run(event: WorkflowEvent<Params>, step: WorkflowStep): Promise<void>;
|
|
@@ -9,7 +9,6 @@ declare class BankProcessBatch extends WorkflowEntrypoint<BankEnv, Params$1> {
|
|
|
9
9
|
|
|
10
10
|
type Params = {
|
|
11
11
|
accountId: string;
|
|
12
|
-
maxIterations?: number;
|
|
13
12
|
};
|
|
14
13
|
declare class BankSyncAccountPayments extends WorkflowEntrypoint<BankEnv, Params> {
|
|
15
14
|
run(event: WorkflowEvent<Params>, step: WorkflowStep): Promise<void>;
|
|
@@ -9,7 +9,6 @@ declare class BankProcessBatch extends WorkflowEntrypoint<BankEnv, Params$1> {
|
|
|
9
9
|
|
|
10
10
|
type Params = {
|
|
11
11
|
accountId: string;
|
|
12
|
-
maxIterations?: number;
|
|
13
12
|
};
|
|
14
13
|
declare class BankSyncAccountPayments extends WorkflowEntrypoint<BankEnv, Params> {
|
|
15
14
|
run(event: WorkflowEvent<Params>, step: WorkflowStep): Promise<void>;
|
|
@@ -2,7 +2,7 @@ import { first, uuidv4, asNonEmpty } from '@develit-io/backend-sdk';
|
|
|
2
2
|
import { G as tables, H as relations, v as toBatchedPaymentFromPaymentRequest, z as toPreparedPayment, m as isPaymentCompleted } from '../shared/bank.kz-PKVi5.mjs';
|
|
3
3
|
import { i as isBatchAuthorized, b as isBatchFailed, d as isBatchProcessing } from '../shared/bank.XqSw509X.mjs';
|
|
4
4
|
import { sql, and, eq, 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
|
|
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 computeWindowDeadline, h as isSupersededBy, j as createPaymentCommand } from '../shared/bank.D9DoIABz.mjs';
|
|
6
6
|
import { WorkflowEntrypoint } from 'cloudflare:workers';
|
|
7
7
|
import { NonRetryableError } from 'cloudflare:workflows';
|
|
8
8
|
import { drizzle } from 'drizzle-orm/d1';
|
|
@@ -423,18 +423,18 @@ async function pushToQueue(queue, message) {
|
|
|
423
423
|
}
|
|
424
424
|
class BankSyncAccountPayments extends WorkflowEntrypoint {
|
|
425
425
|
async run(event, step) {
|
|
426
|
-
const { accountId
|
|
427
|
-
const iterationBudget = resolveIterationBudget(maxIterations);
|
|
426
|
+
const { accountId } = event.payload;
|
|
428
427
|
const db = drizzle(this.env.BANK_D1, { schema: tables, relations });
|
|
429
428
|
const logger = createWorkflowLogger(event.instanceId);
|
|
430
429
|
if (!accountId) {
|
|
431
430
|
throw new NonRetryableError(`Haven't obtained accountId to load.`);
|
|
432
431
|
}
|
|
432
|
+
const deadlineMs = computeWindowDeadline(event.instanceId, accountId);
|
|
433
433
|
const workflowStartedAt = await step.do(
|
|
434
434
|
"capture workflow start time",
|
|
435
435
|
async () => Date.now()
|
|
436
436
|
);
|
|
437
|
-
for (let iteration = 0;
|
|
437
|
+
for (let iteration = 0; ; iteration++) {
|
|
438
438
|
const account = await step.do("load account", async () => {
|
|
439
439
|
const account2 = await getAccountByIdQuery(db, { accountId });
|
|
440
440
|
if (!account2) {
|
|
@@ -479,6 +479,15 @@ class BankSyncAccountPayments extends WorkflowEntrypoint {
|
|
|
479
479
|
isCatchUp: window.isCatchUp
|
|
480
480
|
};
|
|
481
481
|
});
|
|
482
|
+
if (deadlineMs != null && windowMs.dateFromMs >= deadlineMs) {
|
|
483
|
+
logger.info("sync.window-elapsed", {
|
|
484
|
+
accountId,
|
|
485
|
+
instanceId: event.instanceId,
|
|
486
|
+
iteration,
|
|
487
|
+
deadline: new Date(deadlineMs).toISOString()
|
|
488
|
+
});
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
482
491
|
const syncWindow = {
|
|
483
492
|
dateFrom: new Date(windowMs.dateFromMs),
|
|
484
493
|
dateTo: new Date(windowMs.dateToMs),
|
|
@@ -693,6 +702,12 @@ class BankSyncAccountPayments extends WorkflowEntrypoint {
|
|
|
693
702
|
lastSyncMetadata,
|
|
694
703
|
seenInstanceId: account.lastSyncMetadata?.instanceId ?? null
|
|
695
704
|
}).command;
|
|
705
|
+
if (eventsToEmit.length) {
|
|
706
|
+
await pushToQueue(
|
|
707
|
+
this.env.QUEUE_BUS_QUEUE,
|
|
708
|
+
eventsToEmit
|
|
709
|
+
);
|
|
710
|
+
}
|
|
696
711
|
let syncStateRows;
|
|
697
712
|
if (createCommands.length) {
|
|
698
713
|
const [updateResult] = await db.batch(
|
|
@@ -708,12 +723,6 @@ class BankSyncAccountPayments extends WorkflowEntrypoint {
|
|
|
708
723
|
instanceId: event.instanceId
|
|
709
724
|
});
|
|
710
725
|
}
|
|
711
|
-
if (eventsToEmit.length) {
|
|
712
|
-
await pushToQueue(
|
|
713
|
-
this.env.QUEUE_BUS_QUEUE,
|
|
714
|
-
eventsToEmit
|
|
715
|
-
);
|
|
716
|
-
}
|
|
717
726
|
return {
|
|
718
727
|
...lastSyncMetadata,
|
|
719
728
|
newLastSyncAt: effectiveWindow.dateTo
|
package/dist/service.d.cts
CHANGED
|
@@ -19,7 +19,6 @@ interface BankServiceVariables {
|
|
|
19
19
|
SYNC_WORKFLOW_RESET_AFTER_ITERATIONS: string;
|
|
20
20
|
CRON_SYNC_WORKFLOW_DISPATCH: string;
|
|
21
21
|
SYNC_DISPATCH_ACCOUNT_IDS: string;
|
|
22
|
-
SYNC_WORKFLOW_MAX_ITERATIONS: string;
|
|
23
22
|
[key: string]: string | number | boolean;
|
|
24
23
|
}
|
|
25
24
|
declare const BANK_SERVICE_BINDINGS: {
|
package/dist/service.d.mts
CHANGED
|
@@ -19,7 +19,6 @@ interface BankServiceVariables {
|
|
|
19
19
|
SYNC_WORKFLOW_RESET_AFTER_ITERATIONS: string;
|
|
20
20
|
CRON_SYNC_WORKFLOW_DISPATCH: string;
|
|
21
21
|
SYNC_DISPATCH_ACCOUNT_IDS: string;
|
|
22
|
-
SYNC_WORKFLOW_MAX_ITERATIONS: string;
|
|
23
22
|
[key: string]: string | number | boolean;
|
|
24
23
|
}
|
|
25
24
|
declare const BANK_SERVICE_BINDINGS: {
|
package/dist/service.d.ts
CHANGED
|
@@ -19,7 +19,6 @@ interface BankServiceVariables {
|
|
|
19
19
|
SYNC_WORKFLOW_RESET_AFTER_ITERATIONS: string;
|
|
20
20
|
CRON_SYNC_WORKFLOW_DISPATCH: string;
|
|
21
21
|
SYNC_DISPATCH_ACCOUNT_IDS: string;
|
|
22
|
-
SYNC_WORKFLOW_MAX_ITERATIONS: string;
|
|
23
22
|
[key: string]: string | number | boolean;
|
|
24
23
|
}
|
|
25
24
|
declare const BANK_SERVICE_BINDINGS: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { e as CurrencyCode, S as BankCode, a2 as CountryCode, P as PaymentRequestSelectType } from './bank.
|
|
1
|
+
import { e as CurrencyCode, S as BankCode, a2 as CountryCode, P as PaymentRequestSelectType } from './bank.CgiEbvJu.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
type ReferenceType = `${'VS' | 'SS' | 'KS'}:${number}`;
|
|
@@ -3280,7 +3280,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
3280
3280
|
name: string;
|
|
3281
3281
|
tableName: "batch";
|
|
3282
3282
|
dataType: "string enum";
|
|
3283
|
-
data: "AUTHORIZED" | "
|
|
3283
|
+
data: "AUTHORIZED" | "COMPLETED" | "PROCESSING" | "READY_TO_SIGN" | "FAILED";
|
|
3284
3284
|
driverParam: string;
|
|
3285
3285
|
notNull: false;
|
|
3286
3286
|
hasDefault: false;
|
|
@@ -3656,7 +3656,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
3656
3656
|
name: string;
|
|
3657
3657
|
tableName: "payment";
|
|
3658
3658
|
dataType: "string enum";
|
|
3659
|
-
data: "
|
|
3659
|
+
data: "BOOKED" | "REJECTED" | "PENDING" | "PROCESSING" | "CANCELLED" | "SCHEDULED" | "HOLD" | "INFO";
|
|
3660
3660
|
driverParam: string;
|
|
3661
3661
|
notNull: true;
|
|
3662
3662
|
hasDefault: false;
|
|
@@ -4160,7 +4160,7 @@ declare const paymentRequest: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
4160
4160
|
name: string;
|
|
4161
4161
|
tableName: "payment_request";
|
|
4162
4162
|
dataType: "string enum";
|
|
4163
|
-
data: "
|
|
4163
|
+
data: "OPENED" | "AUTHORIZED" | "COMPLETED" | "BOOKED" | "SETTLED" | "REJECTED" | "CLOSED";
|
|
4164
4164
|
driverParam: string;
|
|
4165
4165
|
notNull: true;
|
|
4166
4166
|
hasDefault: false;
|
|
@@ -3280,7 +3280,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
3280
3280
|
name: string;
|
|
3281
3281
|
tableName: "batch";
|
|
3282
3282
|
dataType: "string enum";
|
|
3283
|
-
data: "AUTHORIZED" | "
|
|
3283
|
+
data: "AUTHORIZED" | "COMPLETED" | "PROCESSING" | "READY_TO_SIGN" | "FAILED";
|
|
3284
3284
|
driverParam: string;
|
|
3285
3285
|
notNull: false;
|
|
3286
3286
|
hasDefault: false;
|
|
@@ -3656,7 +3656,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
3656
3656
|
name: string;
|
|
3657
3657
|
tableName: "payment";
|
|
3658
3658
|
dataType: "string enum";
|
|
3659
|
-
data: "
|
|
3659
|
+
data: "BOOKED" | "REJECTED" | "PENDING" | "PROCESSING" | "CANCELLED" | "SCHEDULED" | "HOLD" | "INFO";
|
|
3660
3660
|
driverParam: string;
|
|
3661
3661
|
notNull: true;
|
|
3662
3662
|
hasDefault: false;
|
|
@@ -4160,7 +4160,7 @@ declare const paymentRequest: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
4160
4160
|
name: string;
|
|
4161
4161
|
tableName: "payment_request";
|
|
4162
4162
|
dataType: "string enum";
|
|
4163
|
-
data: "
|
|
4163
|
+
data: "OPENED" | "AUTHORIZED" | "COMPLETED" | "BOOKED" | "SETTLED" | "REJECTED" | "CLOSED";
|
|
4164
4164
|
driverParam: string;
|
|
4165
4165
|
notNull: true;
|
|
4166
4166
|
hasDefault: false;
|
|
@@ -3280,7 +3280,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
3280
3280
|
name: string;
|
|
3281
3281
|
tableName: "batch";
|
|
3282
3282
|
dataType: "string enum";
|
|
3283
|
-
data: "AUTHORIZED" | "
|
|
3283
|
+
data: "AUTHORIZED" | "COMPLETED" | "PROCESSING" | "READY_TO_SIGN" | "FAILED";
|
|
3284
3284
|
driverParam: string;
|
|
3285
3285
|
notNull: false;
|
|
3286
3286
|
hasDefault: false;
|
|
@@ -3656,7 +3656,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
3656
3656
|
name: string;
|
|
3657
3657
|
tableName: "payment";
|
|
3658
3658
|
dataType: "string enum";
|
|
3659
|
-
data: "
|
|
3659
|
+
data: "BOOKED" | "REJECTED" | "PENDING" | "PROCESSING" | "CANCELLED" | "SCHEDULED" | "HOLD" | "INFO";
|
|
3660
3660
|
driverParam: string;
|
|
3661
3661
|
notNull: true;
|
|
3662
3662
|
hasDefault: false;
|
|
@@ -4160,7 +4160,7 @@ declare const paymentRequest: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
4160
4160
|
name: string;
|
|
4161
4161
|
tableName: "payment_request";
|
|
4162
4162
|
dataType: "string enum";
|
|
4163
|
-
data: "
|
|
4163
|
+
data: "OPENED" | "AUTHORIZED" | "COMPLETED" | "BOOKED" | "SETTLED" | "REJECTED" | "CLOSED";
|
|
4164
4164
|
driverParam: string;
|
|
4165
4165
|
notNull: true;
|
|
4166
4166
|
hasDefault: false;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { e as CurrencyCode, S as BankCode, a2 as CountryCode, P as PaymentRequestSelectType } from './bank.
|
|
1
|
+
import { e as CurrencyCode, S as BankCode, a2 as CountryCode, P as PaymentRequestSelectType } from './bank.CgiEbvJu.mjs';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
type ReferenceType = `${'VS' | 'SS' | 'KS'}:${number}`;
|
|
@@ -7,6 +7,7 @@ import 'jose';
|
|
|
7
7
|
import '@develit-io/general-codes';
|
|
8
8
|
import { createHash } from 'node:crypto';
|
|
9
9
|
|
|
10
|
+
const DISPATCH_RECOVERY_WINDOW_MS = 5 * 60 * 1e3;
|
|
10
11
|
function parseInstanceWindow(instanceId, accountId) {
|
|
11
12
|
const prefix = `${accountId}-`;
|
|
12
13
|
if (!instanceId.startsWith(prefix)) return -1;
|
|
@@ -14,6 +15,37 @@ function parseInstanceWindow(instanceId, accountId) {
|
|
|
14
15
|
if (!/^\d+$/.test(suffix)) return -1;
|
|
15
16
|
return Number(suffix);
|
|
16
17
|
}
|
|
18
|
+
function buildDispatchInstanceId(accountId, nowMs, recoveryWindowMs = DISPATCH_RECOVERY_WINDOW_MS) {
|
|
19
|
+
return `${accountId}-${Math.floor(nowMs / recoveryWindowMs)}`;
|
|
20
|
+
}
|
|
21
|
+
function buildDispatchCreateOptions(instanceId, accountId) {
|
|
22
|
+
return {
|
|
23
|
+
id: instanceId,
|
|
24
|
+
params: { accountId },
|
|
25
|
+
// Dispatch mints ~24 instances per account per day and step outputs carry
|
|
26
|
+
// bank payloads — the default 30-day retention would pile up billable
|
|
27
|
+
// storage for state nobody reads after success.
|
|
28
|
+
retention: {
|
|
29
|
+
successRetention: "1 day",
|
|
30
|
+
errorRetention: "7 days"
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function computeWindowDeadline(instanceId, accountId, recoveryWindowMs = DISPATCH_RECOVERY_WINDOW_MS) {
|
|
35
|
+
const window = parseInstanceWindow(instanceId, accountId);
|
|
36
|
+
if (window < 0) return null;
|
|
37
|
+
return (window + 1) * recoveryWindowMs;
|
|
38
|
+
}
|
|
39
|
+
function isAlreadyExists(err) {
|
|
40
|
+
return /already exists/i.test(extractMessage(err));
|
|
41
|
+
}
|
|
42
|
+
function isInstanceNotFound(err) {
|
|
43
|
+
return /instance.*not.?found|not.?found.*instance/i.test(extractMessage(err));
|
|
44
|
+
}
|
|
45
|
+
function extractMessage(err) {
|
|
46
|
+
return err instanceof Error ? err.message : typeof err === "object" && err !== null && "message" in err ? String(err.message) : "";
|
|
47
|
+
}
|
|
48
|
+
|
|
17
49
|
function resolveCurrentSyncInstanceId(accountId, recordedInstanceId) {
|
|
18
50
|
return recordedInstanceId ?? accountId;
|
|
19
51
|
}
|
|
@@ -22,18 +54,6 @@ function isSupersededBy(myInstanceId, recordedInstanceId, accountId) {
|
|
|
22
54
|
return parseInstanceWindow(recordedInstanceId, accountId) > parseInstanceWindow(myInstanceId, accountId);
|
|
23
55
|
}
|
|
24
56
|
|
|
25
|
-
function normalizeBudget(value) {
|
|
26
|
-
if (!Number.isFinite(value) || value < 1) return void 0;
|
|
27
|
-
return Math.floor(value);
|
|
28
|
-
}
|
|
29
|
-
function parseIterationBudgetParam(value) {
|
|
30
|
-
return normalizeBudget(Number(value?.trim() || Number.NaN));
|
|
31
|
-
}
|
|
32
|
-
function resolveIterationBudget(maxIterations) {
|
|
33
|
-
if (maxIterations == null) return Number.POSITIVE_INFINITY;
|
|
34
|
-
return normalizeBudget(maxIterations) ?? Number.POSITIVE_INFINITY;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
57
|
const createPaymentCommand = (db, { payment }) => {
|
|
38
58
|
return {
|
|
39
59
|
command: db.insert(tables.payment).values({
|
|
@@ -386,4 +406,4 @@ const initiateConnector = async ({
|
|
|
386
406
|
}
|
|
387
407
|
};
|
|
388
408
|
|
|
389
|
-
export { getPaymentRequestsByBatchIdQuery as a, getAccountByIdQuery as b, checksum as c, createCredentialsResolver as d, updatePaymentRequestStatusCommand as e,
|
|
409
|
+
export { DISPATCH_RECOVERY_WINDOW_MS as D, getPaymentRequestsByBatchIdQuery as a, getAccountByIdQuery as b, checksum as c, createCredentialsResolver as d, updatePaymentRequestStatusCommand as e, computeWindowDeadline as f, getBatchByIdQuery as g, isSupersededBy as h, initiateConnector as i, createPaymentCommand as j, isAlreadyExists as k, buildDispatchInstanceId as l, encrypt as m, buildDispatchCreateOptions as n, isInstanceNotFound as o, importAesKey as p, resolveCurrentSyncInstanceId as r, upsertBatchCommand as u };
|
|
@@ -9,6 +9,7 @@ require('jose');
|
|
|
9
9
|
require('@develit-io/general-codes');
|
|
10
10
|
const node_crypto = require('node:crypto');
|
|
11
11
|
|
|
12
|
+
const DISPATCH_RECOVERY_WINDOW_MS = 5 * 60 * 1e3;
|
|
12
13
|
function parseInstanceWindow(instanceId, accountId) {
|
|
13
14
|
const prefix = `${accountId}-`;
|
|
14
15
|
if (!instanceId.startsWith(prefix)) return -1;
|
|
@@ -16,6 +17,37 @@ function parseInstanceWindow(instanceId, accountId) {
|
|
|
16
17
|
if (!/^\d+$/.test(suffix)) return -1;
|
|
17
18
|
return Number(suffix);
|
|
18
19
|
}
|
|
20
|
+
function buildDispatchInstanceId(accountId, nowMs, recoveryWindowMs = DISPATCH_RECOVERY_WINDOW_MS) {
|
|
21
|
+
return `${accountId}-${Math.floor(nowMs / recoveryWindowMs)}`;
|
|
22
|
+
}
|
|
23
|
+
function buildDispatchCreateOptions(instanceId, accountId) {
|
|
24
|
+
return {
|
|
25
|
+
id: instanceId,
|
|
26
|
+
params: { accountId },
|
|
27
|
+
// Dispatch mints ~24 instances per account per day and step outputs carry
|
|
28
|
+
// bank payloads — the default 30-day retention would pile up billable
|
|
29
|
+
// storage for state nobody reads after success.
|
|
30
|
+
retention: {
|
|
31
|
+
successRetention: "1 day",
|
|
32
|
+
errorRetention: "7 days"
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function computeWindowDeadline(instanceId, accountId, recoveryWindowMs = DISPATCH_RECOVERY_WINDOW_MS) {
|
|
37
|
+
const window = parseInstanceWindow(instanceId, accountId);
|
|
38
|
+
if (window < 0) return null;
|
|
39
|
+
return (window + 1) * recoveryWindowMs;
|
|
40
|
+
}
|
|
41
|
+
function isAlreadyExists(err) {
|
|
42
|
+
return /already exists/i.test(extractMessage(err));
|
|
43
|
+
}
|
|
44
|
+
function isInstanceNotFound(err) {
|
|
45
|
+
return /instance.*not.?found|not.?found.*instance/i.test(extractMessage(err));
|
|
46
|
+
}
|
|
47
|
+
function extractMessage(err) {
|
|
48
|
+
return err instanceof Error ? err.message : typeof err === "object" && err !== null && "message" in err ? String(err.message) : "";
|
|
49
|
+
}
|
|
50
|
+
|
|
19
51
|
function resolveCurrentSyncInstanceId(accountId, recordedInstanceId) {
|
|
20
52
|
return recordedInstanceId ?? accountId;
|
|
21
53
|
}
|
|
@@ -24,18 +56,6 @@ function isSupersededBy(myInstanceId, recordedInstanceId, accountId) {
|
|
|
24
56
|
return parseInstanceWindow(recordedInstanceId, accountId) > parseInstanceWindow(myInstanceId, accountId);
|
|
25
57
|
}
|
|
26
58
|
|
|
27
|
-
function normalizeBudget(value) {
|
|
28
|
-
if (!Number.isFinite(value) || value < 1) return void 0;
|
|
29
|
-
return Math.floor(value);
|
|
30
|
-
}
|
|
31
|
-
function parseIterationBudgetParam(value) {
|
|
32
|
-
return normalizeBudget(Number(value?.trim() || Number.NaN));
|
|
33
|
-
}
|
|
34
|
-
function resolveIterationBudget(maxIterations) {
|
|
35
|
-
if (maxIterations == null) return Number.POSITIVE_INFINITY;
|
|
36
|
-
return normalizeBudget(maxIterations) ?? Number.POSITIVE_INFINITY;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
59
|
const createPaymentCommand = (db, { payment }) => {
|
|
40
60
|
return {
|
|
41
61
|
command: db.insert(paymentDirection.tables.payment).values({
|
|
@@ -388,7 +408,11 @@ const initiateConnector = async ({
|
|
|
388
408
|
}
|
|
389
409
|
};
|
|
390
410
|
|
|
411
|
+
exports.DISPATCH_RECOVERY_WINDOW_MS = DISPATCH_RECOVERY_WINDOW_MS;
|
|
412
|
+
exports.buildDispatchCreateOptions = buildDispatchCreateOptions;
|
|
413
|
+
exports.buildDispatchInstanceId = buildDispatchInstanceId;
|
|
391
414
|
exports.checksum = checksum;
|
|
415
|
+
exports.computeWindowDeadline = computeWindowDeadline;
|
|
392
416
|
exports.createCredentialsResolver = createCredentialsResolver;
|
|
393
417
|
exports.createPaymentCommand = createPaymentCommand;
|
|
394
418
|
exports.encrypt = encrypt;
|
|
@@ -397,9 +421,9 @@ exports.getBatchByIdQuery = getBatchByIdQuery;
|
|
|
397
421
|
exports.getPaymentRequestsByBatchIdQuery = getPaymentRequestsByBatchIdQuery;
|
|
398
422
|
exports.importAesKey = importAesKey;
|
|
399
423
|
exports.initiateConnector = initiateConnector;
|
|
424
|
+
exports.isAlreadyExists = isAlreadyExists;
|
|
425
|
+
exports.isInstanceNotFound = isInstanceNotFound;
|
|
400
426
|
exports.isSupersededBy = isSupersededBy;
|
|
401
|
-
exports.parseIterationBudgetParam = parseIterationBudgetParam;
|
|
402
427
|
exports.resolveCurrentSyncInstanceId = resolveCurrentSyncInstanceId;
|
|
403
|
-
exports.resolveIterationBudget = resolveIterationBudget;
|
|
404
428
|
exports.updatePaymentRequestStatusCommand = updatePaymentRequestStatusCommand;
|
|
405
429
|
exports.upsertBatchCommand = upsertBatchCommand;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { e as CurrencyCode, S as BankCode, a2 as CountryCode, P as PaymentRequestSelectType } from './bank.
|
|
1
|
+
import { e as CurrencyCode, S as BankCode, a2 as CountryCode, P as PaymentRequestSelectType } from './bank.CgiEbvJu.cjs';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
type ReferenceType = `${'VS' | 'SS' | 'KS'}:${number}`;
|
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, E as EndToEndIdPayment, 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.
|
|
2
|
-
export { y as ACCOUNT_STATUSES, z as AccountCredentialsPatchType, D as AccountCredentialsSelectType, F as AccountCredentialsUpdateType, G as AccountPatchType, J as AccountStatus, K as AccountUpdateType, M as AuthorizedBatch, N as BASE_TERMINAL_STATUSES, O as BATCH_MODES, Q as BATCH_STATUES, Q as BATCH_STATUSES, R as BankAccountWithLastSync, S as BankCode, T as BatchInsertType, U as BatchLifecycle, V as BatchMode, W as BatchPayment, B as BatchSelectType, X as BatchStatus, Y as CHARGE_BEARERS, Z as CONNECTOR_KEYS, _ as COUNTRY_CODES, $ as CREDENTIALS_TYPES, a0 as ChargeBearer, a1 as CompletedBatch, c as ConfigEnvironmentBank, C as ConnectorConfig, a2 as CountryCode, a3 as CredentialsType, e as CurrencyCode, a4 as INSTRUCTION_PRIORITIES, a5 as InstructionPriority, L as LastSyncMetadata, a6 as PAYMENT_DIRECTIONS, a7 as PAYMENT_REQUEST_STATUSES, a8 as PAYMENT_STATUSES, a9 as PAYMENT_TYPES, aa as PaymentDirection, ab as PaymentFailedInsertType, ac as PaymentInsertType, ad as PaymentLifecycle, ae as PaymentPreparedInsertType, af as PaymentStatus, ag as ProcessingBatch, ah as ReadyToSignBatch, ai as ResolvedCredentials, aj as TOKEN_TYPES, ak as TokenType, al as accountCredentialsInsertSchema, am as accountCredentialsSelectSchema, an as accountCredentialsUpdateSchema, ao as accountInsertSchema, ap as accountSelectSchema, aq as accountUpdateSchema, ar as hasPaymentAccountAssigned, as as isBatchAuthorized, at as isBatchCompleted, au as isBatchFailed, av as isBatchInitiated, aw as isBatchProcessing, ax as isBatchReadyToSign, ay as isPaymentCompleted, az as isPendingStatus, aA as isProcessedStatus, aB as isTerminalStatus } from './shared/bank.
|
|
3
|
-
import { d as FinbricksAccount, R as ReferenceType, S as SendPaymentInput } from './shared/bank.
|
|
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.
|
|
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, E as EndToEndIdPayment, 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.CgiEbvJu.cjs';
|
|
2
|
+
export { y as ACCOUNT_STATUSES, z as AccountCredentialsPatchType, D as AccountCredentialsSelectType, F as AccountCredentialsUpdateType, G as AccountPatchType, J as AccountStatus, K as AccountUpdateType, M as AuthorizedBatch, N as BASE_TERMINAL_STATUSES, O as BATCH_MODES, Q as BATCH_STATUES, Q as BATCH_STATUSES, R as BankAccountWithLastSync, S as BankCode, T as BatchInsertType, U as BatchLifecycle, V as BatchMode, W as BatchPayment, B as BatchSelectType, X as BatchStatus, Y as CHARGE_BEARERS, Z as CONNECTOR_KEYS, _ as COUNTRY_CODES, $ as CREDENTIALS_TYPES, a0 as ChargeBearer, a1 as CompletedBatch, c as ConfigEnvironmentBank, C as ConnectorConfig, a2 as CountryCode, a3 as CredentialsType, e as CurrencyCode, a4 as INSTRUCTION_PRIORITIES, a5 as InstructionPriority, L as LastSyncMetadata, a6 as PAYMENT_DIRECTIONS, a7 as PAYMENT_REQUEST_STATUSES, a8 as PAYMENT_STATUSES, a9 as PAYMENT_TYPES, aa as PaymentDirection, ab as PaymentFailedInsertType, ac as PaymentInsertType, ad as PaymentLifecycle, ae as PaymentPreparedInsertType, af as PaymentStatus, ag as ProcessingBatch, ah as ReadyToSignBatch, ai as ResolvedCredentials, aj as TOKEN_TYPES, ak as TokenType, al as accountCredentialsInsertSchema, am as accountCredentialsSelectSchema, an as accountCredentialsUpdateSchema, ao as accountInsertSchema, ap as accountSelectSchema, aq as accountUpdateSchema, ar as hasPaymentAccountAssigned, as as isBatchAuthorized, at as isBatchCompleted, au as isBatchFailed, av as isBatchInitiated, aw as isBatchProcessing, ax as isBatchReadyToSign, ay as isPaymentCompleted, az as isPendingStatus, aA as isProcessedStatus, aB as isTerminalStatus } from './shared/bank.CgiEbvJu.cjs';
|
|
3
|
+
import { d as FinbricksAccount, R as ReferenceType, S as SendPaymentInput } from './shared/bank.DZyrkXc_.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.DZyrkXc_.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';
|
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, E as EndToEndIdPayment, 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.
|
|
2
|
-
export { y as ACCOUNT_STATUSES, z as AccountCredentialsPatchType, D as AccountCredentialsSelectType, F as AccountCredentialsUpdateType, G as AccountPatchType, J as AccountStatus, K as AccountUpdateType, M as AuthorizedBatch, N as BASE_TERMINAL_STATUSES, O as BATCH_MODES, Q as BATCH_STATUES, Q as BATCH_STATUSES, R as BankAccountWithLastSync, S as BankCode, T as BatchInsertType, U as BatchLifecycle, V as BatchMode, W as BatchPayment, B as BatchSelectType, X as BatchStatus, Y as CHARGE_BEARERS, Z as CONNECTOR_KEYS, _ as COUNTRY_CODES, $ as CREDENTIALS_TYPES, a0 as ChargeBearer, a1 as CompletedBatch, c as ConfigEnvironmentBank, C as ConnectorConfig, a2 as CountryCode, a3 as CredentialsType, e as CurrencyCode, a4 as INSTRUCTION_PRIORITIES, a5 as InstructionPriority, L as LastSyncMetadata, a6 as PAYMENT_DIRECTIONS, a7 as PAYMENT_REQUEST_STATUSES, a8 as PAYMENT_STATUSES, a9 as PAYMENT_TYPES, aa as PaymentDirection, ab as PaymentFailedInsertType, ac as PaymentInsertType, ad as PaymentLifecycle, ae as PaymentPreparedInsertType, af as PaymentStatus, ag as ProcessingBatch, ah as ReadyToSignBatch, ai as ResolvedCredentials, aj as TOKEN_TYPES, ak as TokenType, al as accountCredentialsInsertSchema, am as accountCredentialsSelectSchema, an as accountCredentialsUpdateSchema, ao as accountInsertSchema, ap as accountSelectSchema, aq as accountUpdateSchema, ar as hasPaymentAccountAssigned, as as isBatchAuthorized, at as isBatchCompleted, au as isBatchFailed, av as isBatchInitiated, aw as isBatchProcessing, ax as isBatchReadyToSign, ay as isPaymentCompleted, az as isPendingStatus, aA as isProcessedStatus, aB as isTerminalStatus } from './shared/bank.
|
|
3
|
-
import { d as FinbricksAccount, R as ReferenceType, S as SendPaymentInput } from './shared/bank.
|
|
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.
|
|
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, E as EndToEndIdPayment, 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.CgiEbvJu.mjs';
|
|
2
|
+
export { y as ACCOUNT_STATUSES, z as AccountCredentialsPatchType, D as AccountCredentialsSelectType, F as AccountCredentialsUpdateType, G as AccountPatchType, J as AccountStatus, K as AccountUpdateType, M as AuthorizedBatch, N as BASE_TERMINAL_STATUSES, O as BATCH_MODES, Q as BATCH_STATUES, Q as BATCH_STATUSES, R as BankAccountWithLastSync, S as BankCode, T as BatchInsertType, U as BatchLifecycle, V as BatchMode, W as BatchPayment, B as BatchSelectType, X as BatchStatus, Y as CHARGE_BEARERS, Z as CONNECTOR_KEYS, _ as COUNTRY_CODES, $ as CREDENTIALS_TYPES, a0 as ChargeBearer, a1 as CompletedBatch, c as ConfigEnvironmentBank, C as ConnectorConfig, a2 as CountryCode, a3 as CredentialsType, e as CurrencyCode, a4 as INSTRUCTION_PRIORITIES, a5 as InstructionPriority, L as LastSyncMetadata, a6 as PAYMENT_DIRECTIONS, a7 as PAYMENT_REQUEST_STATUSES, a8 as PAYMENT_STATUSES, a9 as PAYMENT_TYPES, aa as PaymentDirection, ab as PaymentFailedInsertType, ac as PaymentInsertType, ad as PaymentLifecycle, ae as PaymentPreparedInsertType, af as PaymentStatus, ag as ProcessingBatch, ah as ReadyToSignBatch, ai as ResolvedCredentials, aj as TOKEN_TYPES, ak as TokenType, al as accountCredentialsInsertSchema, am as accountCredentialsSelectSchema, an as accountCredentialsUpdateSchema, ao as accountInsertSchema, ap as accountSelectSchema, aq as accountUpdateSchema, ar as hasPaymentAccountAssigned, as as isBatchAuthorized, at as isBatchCompleted, au as isBatchFailed, av as isBatchInitiated, aw as isBatchProcessing, ax as isBatchReadyToSign, ay as isPaymentCompleted, az as isPendingStatus, aA as isProcessedStatus, aB as isTerminalStatus } from './shared/bank.CgiEbvJu.mjs';
|
|
3
|
+
import { d as FinbricksAccount, R as ReferenceType, S as SendPaymentInput } from './shared/bank.D19D3a9C.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.D19D3a9C.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';
|
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, E as EndToEndIdPayment, 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.
|
|
2
|
-
export { y as ACCOUNT_STATUSES, z as AccountCredentialsPatchType, D as AccountCredentialsSelectType, F as AccountCredentialsUpdateType, G as AccountPatchType, J as AccountStatus, K as AccountUpdateType, M as AuthorizedBatch, N as BASE_TERMINAL_STATUSES, O as BATCH_MODES, Q as BATCH_STATUES, Q as BATCH_STATUSES, R as BankAccountWithLastSync, S as BankCode, T as BatchInsertType, U as BatchLifecycle, V as BatchMode, W as BatchPayment, B as BatchSelectType, X as BatchStatus, Y as CHARGE_BEARERS, Z as CONNECTOR_KEYS, _ as COUNTRY_CODES, $ as CREDENTIALS_TYPES, a0 as ChargeBearer, a1 as CompletedBatch, c as ConfigEnvironmentBank, C as ConnectorConfig, a2 as CountryCode, a3 as CredentialsType, e as CurrencyCode, a4 as INSTRUCTION_PRIORITIES, a5 as InstructionPriority, L as LastSyncMetadata, a6 as PAYMENT_DIRECTIONS, a7 as PAYMENT_REQUEST_STATUSES, a8 as PAYMENT_STATUSES, a9 as PAYMENT_TYPES, aa as PaymentDirection, ab as PaymentFailedInsertType, ac as PaymentInsertType, ad as PaymentLifecycle, ae as PaymentPreparedInsertType, af as PaymentStatus, ag as ProcessingBatch, ah as ReadyToSignBatch, ai as ResolvedCredentials, aj as TOKEN_TYPES, ak as TokenType, al as accountCredentialsInsertSchema, am as accountCredentialsSelectSchema, an as accountCredentialsUpdateSchema, ao as accountInsertSchema, ap as accountSelectSchema, aq as accountUpdateSchema, ar as hasPaymentAccountAssigned, as as isBatchAuthorized, at as isBatchCompleted, au as isBatchFailed, av as isBatchInitiated, aw as isBatchProcessing, ax as isBatchReadyToSign, ay as isPaymentCompleted, az as isPendingStatus, aA as isProcessedStatus, aB as isTerminalStatus } from './shared/bank.
|
|
3
|
-
import { d as FinbricksAccount, R as ReferenceType, S as SendPaymentInput } from './shared/bank.
|
|
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.
|
|
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, E as EndToEndIdPayment, 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.CgiEbvJu.js';
|
|
2
|
+
export { y as ACCOUNT_STATUSES, z as AccountCredentialsPatchType, D as AccountCredentialsSelectType, F as AccountCredentialsUpdateType, G as AccountPatchType, J as AccountStatus, K as AccountUpdateType, M as AuthorizedBatch, N as BASE_TERMINAL_STATUSES, O as BATCH_MODES, Q as BATCH_STATUES, Q as BATCH_STATUSES, R as BankAccountWithLastSync, S as BankCode, T as BatchInsertType, U as BatchLifecycle, V as BatchMode, W as BatchPayment, B as BatchSelectType, X as BatchStatus, Y as CHARGE_BEARERS, Z as CONNECTOR_KEYS, _ as COUNTRY_CODES, $ as CREDENTIALS_TYPES, a0 as ChargeBearer, a1 as CompletedBatch, c as ConfigEnvironmentBank, C as ConnectorConfig, a2 as CountryCode, a3 as CredentialsType, e as CurrencyCode, a4 as INSTRUCTION_PRIORITIES, a5 as InstructionPriority, L as LastSyncMetadata, a6 as PAYMENT_DIRECTIONS, a7 as PAYMENT_REQUEST_STATUSES, a8 as PAYMENT_STATUSES, a9 as PAYMENT_TYPES, aa as PaymentDirection, ab as PaymentFailedInsertType, ac as PaymentInsertType, ad as PaymentLifecycle, ae as PaymentPreparedInsertType, af as PaymentStatus, ag as ProcessingBatch, ah as ReadyToSignBatch, ai as ResolvedCredentials, aj as TOKEN_TYPES, ak as TokenType, al as accountCredentialsInsertSchema, am as accountCredentialsSelectSchema, an as accountCredentialsUpdateSchema, ao as accountInsertSchema, ap as accountSelectSchema, aq as accountUpdateSchema, ar as hasPaymentAccountAssigned, as as isBatchAuthorized, at as isBatchCompleted, au as isBatchFailed, av as isBatchInitiated, aw as isBatchProcessing, ax as isBatchReadyToSign, ay as isPaymentCompleted, az as isPendingStatus, aA as isProcessedStatus, aB as isTerminalStatus } from './shared/bank.CgiEbvJu.js';
|
|
3
|
+
import { d as FinbricksAccount, R as ReferenceType, S as SendPaymentInput } from './shared/bank.-8YAJoxw.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.-8YAJoxw.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';
|