@develit-services/bank 5.8.0 → 5.9.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,14 +1,14 @@
1
1
  'use strict';
2
2
 
3
3
  const backendSdk = require('@develit-io/backend-sdk');
4
- const paymentDirection = require('./shared/bank.CQjuudum.cjs');
5
- const bank = require('./shared/bank.Cy7xa566.cjs');
4
+ const paymentDirection = require('./shared/bank.BsWBG0gb.cjs');
5
+ const bank = require('./shared/bank.DBTtRCcf.cjs');
6
6
  const drizzleOrm = require('drizzle-orm');
7
7
  const cloudflare_workers = require('cloudflare:workers');
8
8
  const d1 = require('drizzle-orm/d1');
9
9
  require('jose');
10
10
  const zod = require('zod');
11
- const database_schema = require('./shared/bank.9Yw4KHyl.cjs');
11
+ const database_schema = require('./shared/bank.Ca3jzmIb.cjs');
12
12
  const generalCodes = require('@develit-io/general-codes');
13
13
  require('date-fns');
14
14
  require('node:crypto');
@@ -208,6 +208,26 @@ function isAlreadyFiniteError(err) {
208
208
  return /cannot_terminate|finite state/i.test(message);
209
209
  }
210
210
 
211
+ async function disableAccountSync({
212
+ accountId,
213
+ persistDisabled,
214
+ terminateInstance,
215
+ logger
216
+ }) {
217
+ await persistDisabled();
218
+ try {
219
+ const instanceId = await terminateInstance();
220
+ logger.info("sync-workflow.disable.terminated", { accountId, instanceId });
221
+ return { terminated: true, instanceId };
222
+ } catch (err) {
223
+ logger.warn("sync-workflow.disable.terminate-skipped", {
224
+ accountId,
225
+ error: err instanceof Error ? err.message : String(err)
226
+ });
227
+ return { terminated: false, instanceId: null };
228
+ }
229
+ }
230
+
211
231
  const upsertAccountCommand = (db, { account }) => {
212
232
  const id = account.id || backendSdk.uuidv4();
213
233
  const { id: _id, ...accountWithoutId } = account;
@@ -295,6 +315,13 @@ const createPaymentRequestCommand = (db, { paymentRequest }) => {
295
315
  };
296
316
  };
297
317
 
318
+ const updateAccountSyncEnabledCommand = (db, { accountId, syncEnabled }) => {
319
+ const command = db.update(paymentDirection.tables.account).set({ syncEnabled }).where(drizzleOrm.eq(paymentDirection.tables.account.id, accountId)).returning();
320
+ return {
321
+ command
322
+ };
323
+ };
324
+
298
325
  const getAccountBatchCountsQuery = async (db, { accountId }) => {
299
326
  const result = await db.select({
300
327
  totalCount: drizzleOrm.sql`COUNT(*)`.as("totalCount"),
@@ -564,6 +591,21 @@ const getPaymentRequestsQuery = async (db, params) => {
564
591
  return { paymentRequests, totalCount };
565
592
  };
566
593
 
594
+ const getSyncCandidateAccountsQuery = async (db) => {
595
+ return await db.select({
596
+ id: paymentDirection.tables.account.id,
597
+ syncIntervalS: paymentDirection.tables.account.syncIntervalS,
598
+ lastSyncAt: paymentDirection.tables.account.lastSyncAt,
599
+ lastSyncMetadata: paymentDirection.tables.account.lastSyncMetadata,
600
+ createdAt: paymentDirection.tables.account.createdAt
601
+ }).from(paymentDirection.tables.account).where(
602
+ drizzleOrm.and(
603
+ drizzleOrm.eq(paymentDirection.tables.account.status, "AUTHORIZED"),
604
+ drizzleOrm.eq(paymentDirection.tables.account.syncEnabled, true)
605
+ )
606
+ ).all();
607
+ };
608
+
567
609
  const SIGNAL_MAP = {
568
610
  OPENED: "paymentRequestOpened",
569
611
  AUTHORIZED: "paymentRequestAuthorized",
@@ -790,7 +832,9 @@ const syncAccountTerminateInputSchema = zod.z.object({
790
832
  accountId: zod.z.uuid()
791
833
  });
792
834
  zod.z.object({
793
- instanceId: zod.z.string()
835
+ terminated: zod.z.boolean(),
836
+ // Null when the flag was persisted but no live instance existed to kill.
837
+ instanceId: zod.z.string().nullable()
794
838
  });
795
839
 
796
840
  const updateAccountInputSchema = zod.z.object({
@@ -866,6 +910,11 @@ var __decorateClass = (decorators, target, key, kind) => {
866
910
  if (kind && result) __defProp(target, key, result);
867
911
  return result;
868
912
  };
913
+ const accountNotFoundError = () => backendSdk.createInternalError(null, {
914
+ message: "Account not found",
915
+ code: "DB-B-005",
916
+ status: 404
917
+ });
869
918
  const syncEventConsoleLogger = {
870
919
  info: (event, data) => console.log(JSON.stringify({ level: "info", event, ...data })),
871
920
  warn: (event, data) => console.warn(JSON.stringify({ level: "warn", event, ...data })),
@@ -973,6 +1022,17 @@ exports.BankServiceBase = class BankServiceBase extends backendSdk.develitWorker
973
1022
  { data: input, schema: syncAccountInputSchema },
974
1023
  { successMessage: "Account sync workflow started" },
975
1024
  async ({ accountId }) => {
1025
+ const account = await bank.getAccountByIdQuery(this.db, { accountId });
1026
+ if (!account) {
1027
+ throw accountNotFoundError();
1028
+ }
1029
+ if (!account.syncEnabled) {
1030
+ throw backendSdk.createInternalError(null, {
1031
+ message: `Account sync is disabled for ${accountId}. Enable it via restart-sync first.`,
1032
+ code: "VALID-B-018",
1033
+ status: 422
1034
+ });
1035
+ }
976
1036
  if (isDispatchActive(
977
1037
  accountId,
978
1038
  this.env.SYNC_DISPATCH_ACCOUNT_IDS,
@@ -1027,6 +1087,7 @@ exports.BankServiceBase = class BankServiceBase extends backendSdk.develitWorker
1027
1087
  { data: input, schema: syncAccountRestartInputSchema },
1028
1088
  { successMessage: "Account sync workflow restarted" },
1029
1089
  async ({ accountId }) => {
1090
+ await this.setSyncEnabledOrThrow(accountId, true);
1030
1091
  const instance = await this.getCurrentSyncInstance(accountId);
1031
1092
  await instance.restart();
1032
1093
  return {
@@ -1041,11 +1102,16 @@ exports.BankServiceBase = class BankServiceBase extends backendSdk.develitWorker
1041
1102
  { data: input, schema: syncAccountTerminateInputSchema },
1042
1103
  { successMessage: "Account sync workflow terminated" },
1043
1104
  async ({ accountId }) => {
1044
- const instance = await this.getCurrentSyncInstance(accountId);
1045
- await terminateSyncWorkflow(instance);
1046
- return {
1047
- instanceId: instance.id
1048
- };
1105
+ return disableAccountSync({
1106
+ accountId,
1107
+ persistDisabled: () => this.setSyncEnabledOrThrow(accountId, false),
1108
+ terminateInstance: async () => {
1109
+ const instance = await this.getCurrentSyncInstance(accountId);
1110
+ await terminateSyncWorkflow(instance);
1111
+ return instance.id;
1112
+ },
1113
+ logger: syncEventConsoleLogger
1114
+ });
1049
1115
  }
1050
1116
  );
1051
1117
  }
@@ -1339,6 +1405,15 @@ exports.BankServiceBase = class BankServiceBase extends backendSdk.develitWorker
1339
1405
  * account — under dispatch that is the windowed instance recorded with the
1340
1406
  * last sync write, not the legacy canonical id.
1341
1407
  */
1408
+ async setSyncEnabledOrThrow(accountId, syncEnabled) {
1409
+ const [updated] = await updateAccountSyncEnabledCommand(this.db, {
1410
+ accountId,
1411
+ syncEnabled
1412
+ }).command;
1413
+ if (!updated) {
1414
+ throw accountNotFoundError();
1415
+ }
1416
+ }
1342
1417
  async getCurrentSyncInstance(accountId) {
1343
1418
  const account = await bank.getAccountByIdQuery(this.db, { accountId });
1344
1419
  return this.env.SYNC_ACCOUNT_PAYMENTS_WORKFLOW.get(
@@ -1351,12 +1426,7 @@ exports.BankServiceBase = class BankServiceBase extends backendSdk.develitWorker
1351
1426
  async dispatchSyncWorkflows() {
1352
1427
  const selection = this.env.SYNC_DISPATCH_ACCOUNT_IDS;
1353
1428
  if (!selection?.trim()) return;
1354
- const accounts = await this.db.select({
1355
- id: paymentDirection.tables.account.id,
1356
- syncIntervalS: paymentDirection.tables.account.syncIntervalS,
1357
- lastSyncAt: paymentDirection.tables.account.lastSyncAt,
1358
- createdAt: paymentDirection.tables.account.createdAt
1359
- }).from(paymentDirection.tables.account).where(drizzleOrm.eq(paymentDirection.tables.account.status, "AUTHORIZED")).all();
1429
+ const accounts = await getSyncCandidateAccountsQuery(this.db);
1360
1430
  const maxIterations = bank.parseIterationBudgetParam(
1361
1431
  this.env.SYNC_WORKFLOW_MAX_ITERATIONS
1362
1432
  );
@@ -1375,13 +1445,7 @@ exports.BankServiceBase = class BankServiceBase extends backendSdk.develitWorker
1375
1445
  });
1376
1446
  }
1377
1447
  async heartbeatSyncWorkflows() {
1378
- const accounts = await this.db.select({
1379
- id: paymentDirection.tables.account.id,
1380
- lastSyncMetadata: paymentDirection.tables.account.lastSyncMetadata,
1381
- syncIntervalS: paymentDirection.tables.account.syncIntervalS,
1382
- lastSyncAt: paymentDirection.tables.account.lastSyncAt,
1383
- createdAt: paymentDirection.tables.account.createdAt
1384
- }).from(paymentDirection.tables.account).where(drizzleOrm.eq(paymentDirection.tables.account.status, "AUTHORIZED")).all();
1448
+ const accounts = await getSyncCandidateAccountsQuery(this.db);
1385
1449
  const resetAfterIterations = Number(
1386
1450
  this.env.SYNC_WORKFLOW_RESET_AFTER_ITERATIONS
1387
1451
  );
@@ -2273,11 +2337,7 @@ exports.BankServiceBase = class BankServiceBase extends backendSdk.develitWorker
2273
2337
  async ({ accountId }) => {
2274
2338
  const account = await bank.getAccountByIdQuery(this.db, { accountId });
2275
2339
  if (!account) {
2276
- throw backendSdk.createInternalError(null, {
2277
- message: "Account not found",
2278
- code: "DB-B-005",
2279
- status: 404
2280
- });
2340
+ throw accountNotFoundError();
2281
2341
  }
2282
2342
  try {
2283
2343
  const instance = await this.env.SYNC_ACCOUNT_PAYMENTS_WORKFLOW.get(
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.CefGTNH1.cjs';
2
- import { S as SendPaymentInput, a as SendPaymentOutput, b as SendPaymentSyncInput, c as SendPaymentSyncOutput, F as FinbricksSupportedBanksResponse } from './shared/bank.CtIkqQG9.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.mkq4IlpC.cjs';
2
+ import { S as SendPaymentInput, a as SendPaymentOutput, b as SendPaymentSyncInput, c as SendPaymentSyncOutput, F as FinbricksSupportedBanksResponse } from './shared/bank.BhyIbhvK.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';
@@ -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";
2715
2714
  PROCESSING: "PROCESSING";
2716
2715
  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";
2721
2720
  PROCESSING: "PROCESSING";
2722
2721
  READY_TO_SIGN: "READY_TO_SIGN";
2722
+ COMPLETED: "COMPLETED";
2723
2723
  FAILED: "FAILED";
2724
2724
  }>>]>>;
2725
2725
  }, z.core.$strip>;
@@ -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";
2829
2828
  createdAt: "createdAt";
2830
2829
  updatedAt: "updatedAt";
2830
+ amount: "amount";
2831
2831
  }>;
2832
2832
  direction: z.ZodEnum<{
2833
2833
  asc: "asc";
@@ -2956,18 +2956,18 @@ 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";
2959
2960
  BOOKED: "BOOKED";
2960
2961
  REJECTED: "REJECTED";
2961
- PROCESSING: "PROCESSING";
2962
2962
  PENDING: "PENDING";
2963
2963
  CANCELLED: "CANCELLED";
2964
2964
  SCHEDULED: "SCHEDULED";
2965
2965
  HOLD: "HOLD";
2966
2966
  INFO: "INFO";
2967
2967
  }>, z.ZodArray<z.ZodEnum<{
2968
+ PROCESSING: "PROCESSING";
2968
2969
  BOOKED: "BOOKED";
2969
2970
  REJECTED: "REJECTED";
2970
- PROCESSING: "PROCESSING";
2971
2971
  PENDING: "PENDING";
2972
2972
  CANCELLED: "CANCELLED";
2973
2973
  SCHEDULED: "SCHEDULED";
@@ -3114,7 +3114,8 @@ declare const syncAccountTerminateInputSchema: z.ZodObject<{
3114
3114
  accountId: z.ZodUUID;
3115
3115
  }, z.core.$strip>;
3116
3116
  declare const syncAccountTerminateOutputSchema: z.ZodObject<{
3117
- instanceId: z.ZodString;
3117
+ terminated: z.ZodBoolean;
3118
+ instanceId: z.ZodNullable<z.ZodString>;
3118
3119
  }, z.core.$strip>;
3119
3120
  interface SyncAccountTerminateInput extends z.infer<typeof syncAccountTerminateInputSchema> {
3120
3121
  }
@@ -3266,6 +3267,22 @@ declare const updateAccountInputSchema: z.ZodObject<{
3266
3267
  identity: undefined;
3267
3268
  generated: undefined;
3268
3269
  }, {}>;
3270
+ syncEnabled: drizzle_orm_sqlite_core.SQLiteColumn<{
3271
+ name: string;
3272
+ tableName: "account";
3273
+ dataType: "boolean";
3274
+ data: boolean;
3275
+ driverParam: number;
3276
+ notNull: true;
3277
+ hasDefault: true;
3278
+ isPrimaryKey: false;
3279
+ isAutoincrement: false;
3280
+ hasRuntimeDefault: false;
3281
+ enumValues: undefined;
3282
+ baseColumn: never;
3283
+ identity: undefined;
3284
+ generated: undefined;
3285
+ }, {}>;
3269
3286
  syncIntervalS: drizzle_orm_sqlite_core.SQLiteColumn<{
3270
3287
  name: string;
3271
3288
  tableName: "account";
@@ -3875,9 +3892,9 @@ declare const getPaymentRequestsInputSchema: z.ZodObject<{
3875
3892
  limit: z.ZodNumber;
3876
3893
  sort: z.ZodObject<{
3877
3894
  column: z.ZodEnum<{
3878
- amount: "amount";
3879
3895
  createdAt: "createdAt";
3880
3896
  updatedAt: "updatedAt";
3897
+ amount: "amount";
3881
3898
  }>;
3882
3899
  direction: z.ZodEnum<{
3883
3900
  asc: "asc";
@@ -3886,17 +3903,17 @@ declare const getPaymentRequestsInputSchema: z.ZodObject<{
3886
3903
  }, z.core.$strip>;
3887
3904
  filterAccountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodUUID, z.ZodArray<z.ZodUUID>]>>;
3888
3905
  filterStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
3889
- OPENED: "OPENED";
3890
3906
  AUTHORIZED: "AUTHORIZED";
3891
3907
  COMPLETED: "COMPLETED";
3908
+ OPENED: "OPENED";
3892
3909
  BOOKED: "BOOKED";
3893
3910
  SETTLED: "SETTLED";
3894
3911
  REJECTED: "REJECTED";
3895
3912
  CLOSED: "CLOSED";
3896
3913
  }>, z.ZodArray<z.ZodEnum<{
3897
- OPENED: "OPENED";
3898
3914
  AUTHORIZED: "AUTHORIZED";
3899
3915
  COMPLETED: "COMPLETED";
3916
+ OPENED: "OPENED";
3900
3917
  BOOKED: "BOOKED";
3901
3918
  SETTLED: "SETTLED";
3902
3919
  REJECTED: "REJECTED";
@@ -4092,6 +4109,7 @@ declare class BankServiceBase extends BankServiceBase_base {
4092
4109
  status: "AUTHORIZED" | "DISABLED" | "EXPIRED";
4093
4110
  bankRefId: string;
4094
4111
  batchSizeLimit: number;
4112
+ syncEnabled: boolean;
4095
4113
  syncIntervalS: number;
4096
4114
  lastSyncAt: Date | null;
4097
4115
  lastSyncMetadata: LastSyncMetadata | null;
@@ -4127,6 +4145,7 @@ declare class BankServiceBase extends BankServiceBase_base {
4127
4145
  status: "AUTHORIZED" | "DISABLED" | "EXPIRED";
4128
4146
  bankRefId: string;
4129
4147
  batchSizeLimit: number;
4148
+ syncEnabled: boolean;
4130
4149
  syncIntervalS: number;
4131
4150
  lastSyncAt: Date | null;
4132
4151
  lastSyncMetadata: LastSyncMetadata | null;
@@ -4198,6 +4217,7 @@ declare class BankServiceBase extends BankServiceBase_base {
4198
4217
  * account — under dispatch that is the windowed instance recorded with the
4199
4218
  * last sync write, not the legacy canonical id.
4200
4219
  */
4220
+ private setSyncEnabledOrThrow;
4201
4221
  private getCurrentSyncInstance;
4202
4222
  private dispatchSyncWorkflows;
4203
4223
  private heartbeatSyncWorkflows;
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.CefGTNH1.mjs';
2
- import { S as SendPaymentInput, a as SendPaymentOutput, b as SendPaymentSyncInput, c as SendPaymentSyncOutput, F as FinbricksSupportedBanksResponse } from './shared/bank.oNDZ44du.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.mkq4IlpC.mjs';
2
+ import { S as SendPaymentInput, a as SendPaymentOutput, b as SendPaymentSyncInput, c as SendPaymentSyncOutput, F as FinbricksSupportedBanksResponse } from './shared/bank.Bhh_O_5-.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';
@@ -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";
2715
2714
  PROCESSING: "PROCESSING";
2716
2715
  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";
2721
2720
  PROCESSING: "PROCESSING";
2722
2721
  READY_TO_SIGN: "READY_TO_SIGN";
2722
+ COMPLETED: "COMPLETED";
2723
2723
  FAILED: "FAILED";
2724
2724
  }>>]>>;
2725
2725
  }, z.core.$strip>;
@@ -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";
2829
2828
  createdAt: "createdAt";
2830
2829
  updatedAt: "updatedAt";
2830
+ amount: "amount";
2831
2831
  }>;
2832
2832
  direction: z.ZodEnum<{
2833
2833
  asc: "asc";
@@ -2956,18 +2956,18 @@ 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";
2959
2960
  BOOKED: "BOOKED";
2960
2961
  REJECTED: "REJECTED";
2961
- PROCESSING: "PROCESSING";
2962
2962
  PENDING: "PENDING";
2963
2963
  CANCELLED: "CANCELLED";
2964
2964
  SCHEDULED: "SCHEDULED";
2965
2965
  HOLD: "HOLD";
2966
2966
  INFO: "INFO";
2967
2967
  }>, z.ZodArray<z.ZodEnum<{
2968
+ PROCESSING: "PROCESSING";
2968
2969
  BOOKED: "BOOKED";
2969
2970
  REJECTED: "REJECTED";
2970
- PROCESSING: "PROCESSING";
2971
2971
  PENDING: "PENDING";
2972
2972
  CANCELLED: "CANCELLED";
2973
2973
  SCHEDULED: "SCHEDULED";
@@ -3114,7 +3114,8 @@ declare const syncAccountTerminateInputSchema: z.ZodObject<{
3114
3114
  accountId: z.ZodUUID;
3115
3115
  }, z.core.$strip>;
3116
3116
  declare const syncAccountTerminateOutputSchema: z.ZodObject<{
3117
- instanceId: z.ZodString;
3117
+ terminated: z.ZodBoolean;
3118
+ instanceId: z.ZodNullable<z.ZodString>;
3118
3119
  }, z.core.$strip>;
3119
3120
  interface SyncAccountTerminateInput extends z.infer<typeof syncAccountTerminateInputSchema> {
3120
3121
  }
@@ -3266,6 +3267,22 @@ declare const updateAccountInputSchema: z.ZodObject<{
3266
3267
  identity: undefined;
3267
3268
  generated: undefined;
3268
3269
  }, {}>;
3270
+ syncEnabled: drizzle_orm_sqlite_core.SQLiteColumn<{
3271
+ name: string;
3272
+ tableName: "account";
3273
+ dataType: "boolean";
3274
+ data: boolean;
3275
+ driverParam: number;
3276
+ notNull: true;
3277
+ hasDefault: true;
3278
+ isPrimaryKey: false;
3279
+ isAutoincrement: false;
3280
+ hasRuntimeDefault: false;
3281
+ enumValues: undefined;
3282
+ baseColumn: never;
3283
+ identity: undefined;
3284
+ generated: undefined;
3285
+ }, {}>;
3269
3286
  syncIntervalS: drizzle_orm_sqlite_core.SQLiteColumn<{
3270
3287
  name: string;
3271
3288
  tableName: "account";
@@ -3875,9 +3892,9 @@ declare const getPaymentRequestsInputSchema: z.ZodObject<{
3875
3892
  limit: z.ZodNumber;
3876
3893
  sort: z.ZodObject<{
3877
3894
  column: z.ZodEnum<{
3878
- amount: "amount";
3879
3895
  createdAt: "createdAt";
3880
3896
  updatedAt: "updatedAt";
3897
+ amount: "amount";
3881
3898
  }>;
3882
3899
  direction: z.ZodEnum<{
3883
3900
  asc: "asc";
@@ -3886,17 +3903,17 @@ declare const getPaymentRequestsInputSchema: z.ZodObject<{
3886
3903
  }, z.core.$strip>;
3887
3904
  filterAccountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodUUID, z.ZodArray<z.ZodUUID>]>>;
3888
3905
  filterStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
3889
- OPENED: "OPENED";
3890
3906
  AUTHORIZED: "AUTHORIZED";
3891
3907
  COMPLETED: "COMPLETED";
3908
+ OPENED: "OPENED";
3892
3909
  BOOKED: "BOOKED";
3893
3910
  SETTLED: "SETTLED";
3894
3911
  REJECTED: "REJECTED";
3895
3912
  CLOSED: "CLOSED";
3896
3913
  }>, z.ZodArray<z.ZodEnum<{
3897
- OPENED: "OPENED";
3898
3914
  AUTHORIZED: "AUTHORIZED";
3899
3915
  COMPLETED: "COMPLETED";
3916
+ OPENED: "OPENED";
3900
3917
  BOOKED: "BOOKED";
3901
3918
  SETTLED: "SETTLED";
3902
3919
  REJECTED: "REJECTED";
@@ -4092,6 +4109,7 @@ declare class BankServiceBase extends BankServiceBase_base {
4092
4109
  status: "AUTHORIZED" | "DISABLED" | "EXPIRED";
4093
4110
  bankRefId: string;
4094
4111
  batchSizeLimit: number;
4112
+ syncEnabled: boolean;
4095
4113
  syncIntervalS: number;
4096
4114
  lastSyncAt: Date | null;
4097
4115
  lastSyncMetadata: LastSyncMetadata | null;
@@ -4127,6 +4145,7 @@ declare class BankServiceBase extends BankServiceBase_base {
4127
4145
  status: "AUTHORIZED" | "DISABLED" | "EXPIRED";
4128
4146
  bankRefId: string;
4129
4147
  batchSizeLimit: number;
4148
+ syncEnabled: boolean;
4130
4149
  syncIntervalS: number;
4131
4150
  lastSyncAt: Date | null;
4132
4151
  lastSyncMetadata: LastSyncMetadata | null;
@@ -4198,6 +4217,7 @@ declare class BankServiceBase extends BankServiceBase_base {
4198
4217
  * account — under dispatch that is the windowed instance recorded with the
4199
4218
  * last sync write, not the legacy canonical id.
4200
4219
  */
4220
+ private setSyncEnabledOrThrow;
4201
4221
  private getCurrentSyncInstance;
4202
4222
  private dispatchSyncWorkflows;
4203
4223
  private heartbeatSyncWorkflows;
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.CefGTNH1.js';
2
- import { S as SendPaymentInput, a as SendPaymentOutput, b as SendPaymentSyncInput, c as SendPaymentSyncOutput, F as FinbricksSupportedBanksResponse } from './shared/bank.BOeuHdjy.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.mkq4IlpC.js';
2
+ import { S as SendPaymentInput, a as SendPaymentOutput, b as SendPaymentSyncInput, c as SendPaymentSyncOutput, F as FinbricksSupportedBanksResponse } from './shared/bank.Bnc_DoG4.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';
@@ -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";
2715
2714
  PROCESSING: "PROCESSING";
2716
2715
  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";
2721
2720
  PROCESSING: "PROCESSING";
2722
2721
  READY_TO_SIGN: "READY_TO_SIGN";
2722
+ COMPLETED: "COMPLETED";
2723
2723
  FAILED: "FAILED";
2724
2724
  }>>]>>;
2725
2725
  }, z.core.$strip>;
@@ -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";
2829
2828
  createdAt: "createdAt";
2830
2829
  updatedAt: "updatedAt";
2830
+ amount: "amount";
2831
2831
  }>;
2832
2832
  direction: z.ZodEnum<{
2833
2833
  asc: "asc";
@@ -2956,18 +2956,18 @@ 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";
2959
2960
  BOOKED: "BOOKED";
2960
2961
  REJECTED: "REJECTED";
2961
- PROCESSING: "PROCESSING";
2962
2962
  PENDING: "PENDING";
2963
2963
  CANCELLED: "CANCELLED";
2964
2964
  SCHEDULED: "SCHEDULED";
2965
2965
  HOLD: "HOLD";
2966
2966
  INFO: "INFO";
2967
2967
  }>, z.ZodArray<z.ZodEnum<{
2968
+ PROCESSING: "PROCESSING";
2968
2969
  BOOKED: "BOOKED";
2969
2970
  REJECTED: "REJECTED";
2970
- PROCESSING: "PROCESSING";
2971
2971
  PENDING: "PENDING";
2972
2972
  CANCELLED: "CANCELLED";
2973
2973
  SCHEDULED: "SCHEDULED";
@@ -3114,7 +3114,8 @@ declare const syncAccountTerminateInputSchema: z.ZodObject<{
3114
3114
  accountId: z.ZodUUID;
3115
3115
  }, z.core.$strip>;
3116
3116
  declare const syncAccountTerminateOutputSchema: z.ZodObject<{
3117
- instanceId: z.ZodString;
3117
+ terminated: z.ZodBoolean;
3118
+ instanceId: z.ZodNullable<z.ZodString>;
3118
3119
  }, z.core.$strip>;
3119
3120
  interface SyncAccountTerminateInput extends z.infer<typeof syncAccountTerminateInputSchema> {
3120
3121
  }
@@ -3266,6 +3267,22 @@ declare const updateAccountInputSchema: z.ZodObject<{
3266
3267
  identity: undefined;
3267
3268
  generated: undefined;
3268
3269
  }, {}>;
3270
+ syncEnabled: drizzle_orm_sqlite_core.SQLiteColumn<{
3271
+ name: string;
3272
+ tableName: "account";
3273
+ dataType: "boolean";
3274
+ data: boolean;
3275
+ driverParam: number;
3276
+ notNull: true;
3277
+ hasDefault: true;
3278
+ isPrimaryKey: false;
3279
+ isAutoincrement: false;
3280
+ hasRuntimeDefault: false;
3281
+ enumValues: undefined;
3282
+ baseColumn: never;
3283
+ identity: undefined;
3284
+ generated: undefined;
3285
+ }, {}>;
3269
3286
  syncIntervalS: drizzle_orm_sqlite_core.SQLiteColumn<{
3270
3287
  name: string;
3271
3288
  tableName: "account";
@@ -3875,9 +3892,9 @@ declare const getPaymentRequestsInputSchema: z.ZodObject<{
3875
3892
  limit: z.ZodNumber;
3876
3893
  sort: z.ZodObject<{
3877
3894
  column: z.ZodEnum<{
3878
- amount: "amount";
3879
3895
  createdAt: "createdAt";
3880
3896
  updatedAt: "updatedAt";
3897
+ amount: "amount";
3881
3898
  }>;
3882
3899
  direction: z.ZodEnum<{
3883
3900
  asc: "asc";
@@ -3886,17 +3903,17 @@ declare const getPaymentRequestsInputSchema: z.ZodObject<{
3886
3903
  }, z.core.$strip>;
3887
3904
  filterAccountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodUUID, z.ZodArray<z.ZodUUID>]>>;
3888
3905
  filterStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
3889
- OPENED: "OPENED";
3890
3906
  AUTHORIZED: "AUTHORIZED";
3891
3907
  COMPLETED: "COMPLETED";
3908
+ OPENED: "OPENED";
3892
3909
  BOOKED: "BOOKED";
3893
3910
  SETTLED: "SETTLED";
3894
3911
  REJECTED: "REJECTED";
3895
3912
  CLOSED: "CLOSED";
3896
3913
  }>, z.ZodArray<z.ZodEnum<{
3897
- OPENED: "OPENED";
3898
3914
  AUTHORIZED: "AUTHORIZED";
3899
3915
  COMPLETED: "COMPLETED";
3916
+ OPENED: "OPENED";
3900
3917
  BOOKED: "BOOKED";
3901
3918
  SETTLED: "SETTLED";
3902
3919
  REJECTED: "REJECTED";
@@ -4092,6 +4109,7 @@ declare class BankServiceBase extends BankServiceBase_base {
4092
4109
  status: "AUTHORIZED" | "DISABLED" | "EXPIRED";
4093
4110
  bankRefId: string;
4094
4111
  batchSizeLimit: number;
4112
+ syncEnabled: boolean;
4095
4113
  syncIntervalS: number;
4096
4114
  lastSyncAt: Date | null;
4097
4115
  lastSyncMetadata: LastSyncMetadata | null;
@@ -4127,6 +4145,7 @@ declare class BankServiceBase extends BankServiceBase_base {
4127
4145
  status: "AUTHORIZED" | "DISABLED" | "EXPIRED";
4128
4146
  bankRefId: string;
4129
4147
  batchSizeLimit: number;
4148
+ syncEnabled: boolean;
4130
4149
  syncIntervalS: number;
4131
4150
  lastSyncAt: Date | null;
4132
4151
  lastSyncMetadata: LastSyncMetadata | null;
@@ -4198,6 +4217,7 @@ declare class BankServiceBase extends BankServiceBase_base {
4198
4217
  * account — under dispatch that is the windowed instance recorded with the
4199
4218
  * last sync write, not the legacy canonical id.
4200
4219
  */
4220
+ private setSyncEnabledOrThrow;
4201
4221
  private getCurrentSyncInstance;
4202
4222
  private dispatchSyncWorkflows;
4203
4223
  private heartbeatSyncWorkflows;