@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 +87 -27
- package/dist/base.d.cts +31 -11
- package/dist/base.d.mts +31 -11
- package/dist/base.d.ts +31 -11
- package/dist/base.mjs +87 -27
- package/dist/database/schema.cjs +1 -1
- 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/database/schema.mjs +1 -1
- package/dist/export/workflows.cjs +11 -3
- package/dist/export/workflows.mjs +11 -3
- package/dist/shared/{bank.BzDNLxB_.mjs → bank.BT7HayCV.mjs} +4 -0
- package/dist/shared/{bank.oNDZ44du.d.mts → bank.Bhh_O_5-.d.mts} +1 -1
- package/dist/shared/{bank.CtIkqQG9.d.cts → bank.BhyIbhvK.d.cts} +1 -1
- package/dist/shared/{bank.BOeuHdjy.d.ts → bank.Bnc_DoG4.d.ts} +1 -1
- package/dist/shared/{bank.CQjuudum.cjs → bank.BsWBG0gb.cjs} +1 -1
- package/dist/shared/{bank.9Yw4KHyl.cjs → bank.Ca3jzmIb.cjs} +4 -0
- package/dist/shared/{bank.D6gBgL07.mjs → bank.DAjqsBQN.mjs} +2 -2
- package/dist/shared/{bank.Cy7xa566.cjs → bank.DBTtRCcf.cjs} +2 -2
- package/dist/shared/{bank.BVXtqHnq.mjs → bank.kz-PKVi5.mjs} +1 -1
- package/dist/shared/{bank.CefGTNH1.d.cts → bank.mkq4IlpC.d.cts} +67 -3
- package/dist/shared/{bank.CefGTNH1.d.mts → bank.mkq4IlpC.d.mts} +67 -3
- package/dist/shared/{bank.CefGTNH1.d.ts → bank.mkq4IlpC.d.ts} +67 -3
- package/dist/types.cjs +2 -2
- package/dist/types.d.cts +4 -4
- package/dist/types.d.mts +4 -4
- package/dist/types.d.ts +4 -4
- package/dist/types.mjs +2 -2
- package/package.json +1 -1
package/dist/base.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { uuidv4, first, buildMultiFilterConditions as buildMultiFilterConditions$1, bankAccountMetadataSchema, structuredAddressSchema, workflowInstanceStatusSchema, develitWorker, createInternalError, action, service } from '@develit-io/backend-sdk';
|
|
2
|
-
import { G as tables, g as accountInsertSchema, H as relations, o as isProcessedStatus, p as isTerminalStatus, L as getNonTerminalPaymentRequestsQuery, x as toIncomingPayment, N as calculateCzechIban, j as assignAccount, u as toBatchedPayment, y as toPaymentRequestInsert, a as FinbricksClient, F as FINBRICKS_ENDPOINTS } from './shared/bank.
|
|
3
|
-
import { j as encrypt, d as createCredentialsResolver, i as initiateConnector, p as parseIterationBudgetParam, e as updatePaymentRequestStatusCommand, a as getPaymentRequestsByBatchIdQuery, g as getBatchByIdQuery, u as upsertBatchCommand,
|
|
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 { j as encrypt, d as createCredentialsResolver, i as initiateConnector, b as getAccountByIdQuery, p as parseIterationBudgetParam, e as updatePaymentRequestStatusCommand, a as getPaymentRequestsByBatchIdQuery, g as getBatchByIdQuery, u as upsertBatchCommand, k as resolveCurrentSyncInstanceId, l as importAesKey, h as createPaymentCommand } from './shared/bank.DAjqsBQN.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';
|
|
7
7
|
import 'jose';
|
|
8
8
|
import { z } from 'zod';
|
|
9
|
-
import { I as INSTRUCTION_PRIORITIES, C as CHARGE_BEARERS, g as PAYMENT_TYPES, b as CONNECTOR_KEYS, a as BATCH_STATUSES, f as PAYMENT_STATUSES, P as PAYMENT_DIRECTIONS, e as PAYMENT_REQUEST_STATUSES } from './shared/bank.
|
|
9
|
+
import { I as INSTRUCTION_PRIORITIES, C as CHARGE_BEARERS, g as PAYMENT_TYPES, b as CONNECTOR_KEYS, a as BATCH_STATUSES, f as PAYMENT_STATUSES, P as PAYMENT_DIRECTIONS, e as PAYMENT_REQUEST_STATUSES } from './shared/bank.BT7HayCV.mjs';
|
|
10
10
|
import { CURRENCY_CODES } from '@develit-io/general-codes';
|
|
11
11
|
import 'date-fns';
|
|
12
12
|
import 'node:crypto';
|
|
@@ -206,6 +206,26 @@ function isAlreadyFiniteError(err) {
|
|
|
206
206
|
return /cannot_terminate|finite state/i.test(message);
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
+
async function disableAccountSync({
|
|
210
|
+
accountId,
|
|
211
|
+
persistDisabled,
|
|
212
|
+
terminateInstance,
|
|
213
|
+
logger
|
|
214
|
+
}) {
|
|
215
|
+
await persistDisabled();
|
|
216
|
+
try {
|
|
217
|
+
const instanceId = await terminateInstance();
|
|
218
|
+
logger.info("sync-workflow.disable.terminated", { accountId, instanceId });
|
|
219
|
+
return { terminated: true, instanceId };
|
|
220
|
+
} catch (err) {
|
|
221
|
+
logger.warn("sync-workflow.disable.terminate-skipped", {
|
|
222
|
+
accountId,
|
|
223
|
+
error: err instanceof Error ? err.message : String(err)
|
|
224
|
+
});
|
|
225
|
+
return { terminated: false, instanceId: null };
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
209
229
|
const upsertAccountCommand = (db, { account }) => {
|
|
210
230
|
const id = account.id || uuidv4();
|
|
211
231
|
const { id: _id, ...accountWithoutId } = account;
|
|
@@ -293,6 +313,13 @@ const createPaymentRequestCommand = (db, { paymentRequest }) => {
|
|
|
293
313
|
};
|
|
294
314
|
};
|
|
295
315
|
|
|
316
|
+
const updateAccountSyncEnabledCommand = (db, { accountId, syncEnabled }) => {
|
|
317
|
+
const command = db.update(tables.account).set({ syncEnabled }).where(eq(tables.account.id, accountId)).returning();
|
|
318
|
+
return {
|
|
319
|
+
command
|
|
320
|
+
};
|
|
321
|
+
};
|
|
322
|
+
|
|
296
323
|
const getAccountBatchCountsQuery = async (db, { accountId }) => {
|
|
297
324
|
const result = await db.select({
|
|
298
325
|
totalCount: sql`COUNT(*)`.as("totalCount"),
|
|
@@ -562,6 +589,21 @@ const getPaymentRequestsQuery = async (db, params) => {
|
|
|
562
589
|
return { paymentRequests, totalCount };
|
|
563
590
|
};
|
|
564
591
|
|
|
592
|
+
const getSyncCandidateAccountsQuery = async (db) => {
|
|
593
|
+
return await db.select({
|
|
594
|
+
id: tables.account.id,
|
|
595
|
+
syncIntervalS: tables.account.syncIntervalS,
|
|
596
|
+
lastSyncAt: tables.account.lastSyncAt,
|
|
597
|
+
lastSyncMetadata: tables.account.lastSyncMetadata,
|
|
598
|
+
createdAt: tables.account.createdAt
|
|
599
|
+
}).from(tables.account).where(
|
|
600
|
+
and(
|
|
601
|
+
eq(tables.account.status, "AUTHORIZED"),
|
|
602
|
+
eq(tables.account.syncEnabled, true)
|
|
603
|
+
)
|
|
604
|
+
).all();
|
|
605
|
+
};
|
|
606
|
+
|
|
565
607
|
const SIGNAL_MAP = {
|
|
566
608
|
OPENED: "paymentRequestOpened",
|
|
567
609
|
AUTHORIZED: "paymentRequestAuthorized",
|
|
@@ -788,7 +830,9 @@ const syncAccountTerminateInputSchema = z.object({
|
|
|
788
830
|
accountId: z.uuid()
|
|
789
831
|
});
|
|
790
832
|
z.object({
|
|
791
|
-
|
|
833
|
+
terminated: z.boolean(),
|
|
834
|
+
// Null when the flag was persisted but no live instance existed to kill.
|
|
835
|
+
instanceId: z.string().nullable()
|
|
792
836
|
});
|
|
793
837
|
|
|
794
838
|
const updateAccountInputSchema = z.object({
|
|
@@ -864,6 +908,11 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
864
908
|
if (kind && result) __defProp(target, key, result);
|
|
865
909
|
return result;
|
|
866
910
|
};
|
|
911
|
+
const accountNotFoundError = () => createInternalError(null, {
|
|
912
|
+
message: "Account not found",
|
|
913
|
+
code: "DB-B-005",
|
|
914
|
+
status: 404
|
|
915
|
+
});
|
|
867
916
|
const syncEventConsoleLogger = {
|
|
868
917
|
info: (event, data) => console.log(JSON.stringify({ level: "info", event, ...data })),
|
|
869
918
|
warn: (event, data) => console.warn(JSON.stringify({ level: "warn", event, ...data })),
|
|
@@ -971,6 +1020,17 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
971
1020
|
{ data: input, schema: syncAccountInputSchema },
|
|
972
1021
|
{ successMessage: "Account sync workflow started" },
|
|
973
1022
|
async ({ accountId }) => {
|
|
1023
|
+
const account = await getAccountByIdQuery(this.db, { accountId });
|
|
1024
|
+
if (!account) {
|
|
1025
|
+
throw accountNotFoundError();
|
|
1026
|
+
}
|
|
1027
|
+
if (!account.syncEnabled) {
|
|
1028
|
+
throw createInternalError(null, {
|
|
1029
|
+
message: `Account sync is disabled for ${accountId}. Enable it via restart-sync first.`,
|
|
1030
|
+
code: "VALID-B-018",
|
|
1031
|
+
status: 422
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
974
1034
|
if (isDispatchActive(
|
|
975
1035
|
accountId,
|
|
976
1036
|
this.env.SYNC_DISPATCH_ACCOUNT_IDS,
|
|
@@ -1025,6 +1085,7 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
1025
1085
|
{ data: input, schema: syncAccountRestartInputSchema },
|
|
1026
1086
|
{ successMessage: "Account sync workflow restarted" },
|
|
1027
1087
|
async ({ accountId }) => {
|
|
1088
|
+
await this.setSyncEnabledOrThrow(accountId, true);
|
|
1028
1089
|
const instance = await this.getCurrentSyncInstance(accountId);
|
|
1029
1090
|
await instance.restart();
|
|
1030
1091
|
return {
|
|
@@ -1039,11 +1100,16 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
1039
1100
|
{ data: input, schema: syncAccountTerminateInputSchema },
|
|
1040
1101
|
{ successMessage: "Account sync workflow terminated" },
|
|
1041
1102
|
async ({ accountId }) => {
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1103
|
+
return disableAccountSync({
|
|
1104
|
+
accountId,
|
|
1105
|
+
persistDisabled: () => this.setSyncEnabledOrThrow(accountId, false),
|
|
1106
|
+
terminateInstance: async () => {
|
|
1107
|
+
const instance = await this.getCurrentSyncInstance(accountId);
|
|
1108
|
+
await terminateSyncWorkflow(instance);
|
|
1109
|
+
return instance.id;
|
|
1110
|
+
},
|
|
1111
|
+
logger: syncEventConsoleLogger
|
|
1112
|
+
});
|
|
1047
1113
|
}
|
|
1048
1114
|
);
|
|
1049
1115
|
}
|
|
@@ -1337,6 +1403,15 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
1337
1403
|
* account — under dispatch that is the windowed instance recorded with the
|
|
1338
1404
|
* last sync write, not the legacy canonical id.
|
|
1339
1405
|
*/
|
|
1406
|
+
async setSyncEnabledOrThrow(accountId, syncEnabled) {
|
|
1407
|
+
const [updated] = await updateAccountSyncEnabledCommand(this.db, {
|
|
1408
|
+
accountId,
|
|
1409
|
+
syncEnabled
|
|
1410
|
+
}).command;
|
|
1411
|
+
if (!updated) {
|
|
1412
|
+
throw accountNotFoundError();
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1340
1415
|
async getCurrentSyncInstance(accountId) {
|
|
1341
1416
|
const account = await getAccountByIdQuery(this.db, { accountId });
|
|
1342
1417
|
return this.env.SYNC_ACCOUNT_PAYMENTS_WORKFLOW.get(
|
|
@@ -1349,12 +1424,7 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
1349
1424
|
async dispatchSyncWorkflows() {
|
|
1350
1425
|
const selection = this.env.SYNC_DISPATCH_ACCOUNT_IDS;
|
|
1351
1426
|
if (!selection?.trim()) return;
|
|
1352
|
-
const accounts = await this.db
|
|
1353
|
-
id: tables.account.id,
|
|
1354
|
-
syncIntervalS: tables.account.syncIntervalS,
|
|
1355
|
-
lastSyncAt: tables.account.lastSyncAt,
|
|
1356
|
-
createdAt: tables.account.createdAt
|
|
1357
|
-
}).from(tables.account).where(eq(tables.account.status, "AUTHORIZED")).all();
|
|
1427
|
+
const accounts = await getSyncCandidateAccountsQuery(this.db);
|
|
1358
1428
|
const maxIterations = parseIterationBudgetParam(
|
|
1359
1429
|
this.env.SYNC_WORKFLOW_MAX_ITERATIONS
|
|
1360
1430
|
);
|
|
@@ -1373,13 +1443,7 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
1373
1443
|
});
|
|
1374
1444
|
}
|
|
1375
1445
|
async heartbeatSyncWorkflows() {
|
|
1376
|
-
const accounts = await this.db
|
|
1377
|
-
id: tables.account.id,
|
|
1378
|
-
lastSyncMetadata: tables.account.lastSyncMetadata,
|
|
1379
|
-
syncIntervalS: tables.account.syncIntervalS,
|
|
1380
|
-
lastSyncAt: tables.account.lastSyncAt,
|
|
1381
|
-
createdAt: tables.account.createdAt
|
|
1382
|
-
}).from(tables.account).where(eq(tables.account.status, "AUTHORIZED")).all();
|
|
1446
|
+
const accounts = await getSyncCandidateAccountsQuery(this.db);
|
|
1383
1447
|
const resetAfterIterations = Number(
|
|
1384
1448
|
this.env.SYNC_WORKFLOW_RESET_AFTER_ITERATIONS
|
|
1385
1449
|
);
|
|
@@ -2271,11 +2335,7 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
2271
2335
|
async ({ accountId }) => {
|
|
2272
2336
|
const account = await getAccountByIdQuery(this.db, { accountId });
|
|
2273
2337
|
if (!account) {
|
|
2274
|
-
throw
|
|
2275
|
-
message: "Account not found",
|
|
2276
|
-
code: "DB-B-005",
|
|
2277
|
-
status: 404
|
|
2278
|
-
});
|
|
2338
|
+
throw accountNotFoundError();
|
|
2279
2339
|
}
|
|
2280
2340
|
try {
|
|
2281
2341
|
const instance = await this.env.SYNC_ACCOUNT_PAYMENTS_WORKFLOW.get(
|
package/dist/database/schema.cjs
CHANGED
|
@@ -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.mkq4IlpC.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.mkq4IlpC.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.mkq4IlpC.js';
|
|
2
2
|
import 'drizzle-orm/sqlite-core';
|
|
3
3
|
import 'drizzle-orm';
|
|
4
4
|
import '@develit-io/general-codes';
|
package/dist/database/schema.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { h as account, i as accountCredentials, j as batch, o as ott, p as payment, k as paymentRequest } from '../shared/bank.
|
|
1
|
+
export { h as account, i as accountCredentials, j as batch, o as ott, p as payment, k as paymentRequest } from '../shared/bank.BT7HayCV.mjs';
|
|
2
2
|
import '@develit-io/backend-sdk';
|
|
3
3
|
import 'drizzle-orm/sqlite-core';
|
|
4
4
|
import '@develit-io/general-codes';
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const backendSdk = require('@develit-io/backend-sdk');
|
|
4
|
-
const paymentDirection = require('../shared/bank.
|
|
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.DBTtRCcf.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');
|
|
11
11
|
require('node:crypto');
|
|
12
12
|
require('date-fns');
|
|
13
|
-
require('../shared/bank.
|
|
13
|
+
require('../shared/bank.Ca3jzmIb.cjs');
|
|
14
14
|
require('drizzle-orm/sqlite-core');
|
|
15
15
|
require('@develit-io/general-codes');
|
|
16
16
|
require('jose');
|
|
@@ -444,6 +444,14 @@ class BankSyncAccountPayments extends cloudflare_workers.WorkflowEntrypoint {
|
|
|
444
444
|
}
|
|
445
445
|
return account2;
|
|
446
446
|
});
|
|
447
|
+
if (!account.syncEnabled) {
|
|
448
|
+
logger.info("sync.disabled", {
|
|
449
|
+
accountId,
|
|
450
|
+
instanceId: event.instanceId,
|
|
451
|
+
iteration
|
|
452
|
+
});
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
447
455
|
if (!account.lastSyncAt) {
|
|
448
456
|
throw new Error(`lastSyncedAt is not set for account: ${accountId}`);
|
|
449
457
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { first, uuidv4, asNonEmpty } from '@develit-io/backend-sdk';
|
|
2
|
-
import { G as tables, H as relations, v as toBatchedPaymentFromPaymentRequest, z as toPreparedPayment, m as isPaymentCompleted } from '../shared/bank.
|
|
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 isSupersededBy, h as createPaymentCommand, r as resolveIterationBudget } from '../shared/bank.
|
|
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 isSupersededBy, h as createPaymentCommand, r as resolveIterationBudget } from '../shared/bank.DAjqsBQN.mjs';
|
|
6
6
|
import { WorkflowEntrypoint } from 'cloudflare:workers';
|
|
7
7
|
import { NonRetryableError } from 'cloudflare:workflows';
|
|
8
8
|
import { drizzle } from 'drizzle-orm/d1';
|
|
9
9
|
import 'node:crypto';
|
|
10
10
|
import 'date-fns';
|
|
11
|
-
import '../shared/bank.
|
|
11
|
+
import '../shared/bank.BT7HayCV.mjs';
|
|
12
12
|
import 'drizzle-orm/sqlite-core';
|
|
13
13
|
import '@develit-io/general-codes';
|
|
14
14
|
import 'jose';
|
|
@@ -442,6 +442,14 @@ class BankSyncAccountPayments extends WorkflowEntrypoint {
|
|
|
442
442
|
}
|
|
443
443
|
return account2;
|
|
444
444
|
});
|
|
445
|
+
if (!account.syncEnabled) {
|
|
446
|
+
logger.info("sync.disabled", {
|
|
447
|
+
accountId,
|
|
448
|
+
instanceId: event.instanceId,
|
|
449
|
+
iteration
|
|
450
|
+
});
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
445
453
|
if (!account.lastSyncAt) {
|
|
446
454
|
throw new Error(`lastSyncedAt is not set for account: ${accountId}`);
|
|
447
455
|
}
|
|
@@ -75,6 +75,10 @@ const account = sqliteTable(
|
|
|
75
75
|
status: text("status", { enum: ACCOUNT_STATUSES }).$type().notNull(),
|
|
76
76
|
bankRefId: text("bank_ref_id").notNull(),
|
|
77
77
|
batchSizeLimit: integer("batch_size_limit").notNull().default(50),
|
|
78
|
+
// Ops toggle ("should this account sync?"), separate from `status`:
|
|
79
|
+
// DISABLED is owned by disconnect (deletes credentials) and status also
|
|
80
|
+
// gates payments, so neither can express "stop syncing only".
|
|
81
|
+
syncEnabled: integer("sync_enabled", { mode: "boolean" }).notNull().default(true),
|
|
78
82
|
syncIntervalS: integer("sync_interval_s").notNull().default(600),
|
|
79
83
|
lastSyncAt: integer("last_sync_at", { mode: "timestamp_ms" }),
|
|
80
84
|
lastSyncMetadata: text("last_sync_metadata", {
|
|
@@ -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.mkq4IlpC.mjs';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
type ReferenceType = `${'VS' | 'SS' | 'KS'}:${number}`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { e as CurrencyCode, 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.mkq4IlpC.cjs';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
type ReferenceType = `${'VS' | 'SS' | 'KS'}:${number}`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { e as CurrencyCode, 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.mkq4IlpC.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
type ReferenceType = `${'VS' | 'SS' | 'KS'}:${number}`;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const backendSdk = require('@develit-io/backend-sdk');
|
|
4
4
|
const dateFns = require('date-fns');
|
|
5
|
-
const database_schema = require('./bank.
|
|
5
|
+
const database_schema = require('./bank.Ca3jzmIb.cjs');
|
|
6
6
|
const drizzleOrm = require('drizzle-orm');
|
|
7
7
|
const jose = require('jose');
|
|
8
8
|
const zod = require('zod');
|
|
@@ -77,6 +77,10 @@ const account = sqliteCore.sqliteTable(
|
|
|
77
77
|
status: sqliteCore.text("status", { enum: ACCOUNT_STATUSES }).$type().notNull(),
|
|
78
78
|
bankRefId: sqliteCore.text("bank_ref_id").notNull(),
|
|
79
79
|
batchSizeLimit: sqliteCore.integer("batch_size_limit").notNull().default(50),
|
|
80
|
+
// Ops toggle ("should this account sync?"), separate from `status`:
|
|
81
|
+
// DISABLED is owned by disconnect (deletes credentials) and status also
|
|
82
|
+
// gates payments, so neither can express "stop syncing only".
|
|
83
|
+
syncEnabled: sqliteCore.integer("sync_enabled", { mode: "boolean" }).notNull().default(true),
|
|
80
84
|
syncIntervalS: sqliteCore.integer("sync_interval_s").notNull().default(600),
|
|
81
85
|
lastSyncAt: sqliteCore.integer("last_sync_at", { mode: "timestamp_ms" }),
|
|
82
86
|
lastSyncMetadata: sqliteCore.text("last_sync_metadata", {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { sql, and, eq, isNull } from 'drizzle-orm';
|
|
2
|
-
import { G as tables, b as FinbricksConnector, J as buildEndToEndId, c as MockConnector, D as DbuConnector, C as CsobConnector, K as KBConnector, M as MockCobsConnector, E as ErsteConnector } from './bank.
|
|
2
|
+
import { G as tables, b as FinbricksConnector, J as buildEndToEndId, c as MockConnector, D as DbuConnector, C as CsobConnector, K as KBConnector, M as MockCobsConnector, E as ErsteConnector } from './bank.kz-PKVi5.mjs';
|
|
3
3
|
import { uuidv4 } from '@develit-io/backend-sdk';
|
|
4
|
-
import './bank.
|
|
4
|
+
import './bank.BT7HayCV.mjs';
|
|
5
5
|
import 'date-fns';
|
|
6
6
|
import 'jose';
|
|
7
7
|
import '@develit-io/general-codes';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const drizzleOrm = require('drizzle-orm');
|
|
4
|
-
const paymentDirection = require('./bank.
|
|
4
|
+
const paymentDirection = require('./bank.BsWBG0gb.cjs');
|
|
5
5
|
const backendSdk = require('@develit-io/backend-sdk');
|
|
6
|
-
require('./bank.
|
|
6
|
+
require('./bank.Ca3jzmIb.cjs');
|
|
7
7
|
require('date-fns');
|
|
8
8
|
require('jose');
|
|
9
9
|
require('@develit-io/general-codes');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { uuidv4, createInternalError, bicSchema, useResult, structuredAddressSchema } from '@develit-io/backend-sdk';
|
|
2
2
|
import { format, parseISO } from 'date-fns';
|
|
3
|
-
import { s as schema, h as account, i as accountCredentials, o as ott } from './bank.
|
|
3
|
+
import { s as schema, h as account, i as accountCredentials, o as ott } from './bank.BT7HayCV.mjs';
|
|
4
4
|
import { defineRelations, and, not, inArray, isNull } from 'drizzle-orm';
|
|
5
5
|
import { importPKCS8, SignJWT } from 'jose';
|
|
6
6
|
import { z } from 'zod';
|
|
@@ -1042,6 +1042,22 @@ declare const accountInsertSchema: drizzle_orm_zod.BuildSchema<"insert", {
|
|
|
1042
1042
|
identity: undefined;
|
|
1043
1043
|
generated: undefined;
|
|
1044
1044
|
}, {}>;
|
|
1045
|
+
syncEnabled: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1046
|
+
name: string;
|
|
1047
|
+
tableName: "account";
|
|
1048
|
+
dataType: "boolean";
|
|
1049
|
+
data: boolean;
|
|
1050
|
+
driverParam: number;
|
|
1051
|
+
notNull: true;
|
|
1052
|
+
hasDefault: true;
|
|
1053
|
+
isPrimaryKey: false;
|
|
1054
|
+
isAutoincrement: false;
|
|
1055
|
+
hasRuntimeDefault: false;
|
|
1056
|
+
enumValues: undefined;
|
|
1057
|
+
baseColumn: never;
|
|
1058
|
+
identity: undefined;
|
|
1059
|
+
generated: undefined;
|
|
1060
|
+
}, {}>;
|
|
1045
1061
|
syncIntervalS: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1046
1062
|
name: string;
|
|
1047
1063
|
tableName: "account";
|
|
@@ -1747,6 +1763,22 @@ declare const accountUpdateSchema: drizzle_orm_zod.BuildSchema<"update", {
|
|
|
1747
1763
|
identity: undefined;
|
|
1748
1764
|
generated: undefined;
|
|
1749
1765
|
}, {}>;
|
|
1766
|
+
syncEnabled: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1767
|
+
name: string;
|
|
1768
|
+
tableName: "account";
|
|
1769
|
+
dataType: "boolean";
|
|
1770
|
+
data: boolean;
|
|
1771
|
+
driverParam: number;
|
|
1772
|
+
notNull: true;
|
|
1773
|
+
hasDefault: true;
|
|
1774
|
+
isPrimaryKey: false;
|
|
1775
|
+
isAutoincrement: false;
|
|
1776
|
+
hasRuntimeDefault: false;
|
|
1777
|
+
enumValues: undefined;
|
|
1778
|
+
baseColumn: never;
|
|
1779
|
+
identity: undefined;
|
|
1780
|
+
generated: undefined;
|
|
1781
|
+
}, {}>;
|
|
1750
1782
|
syncIntervalS: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1751
1783
|
name: string;
|
|
1752
1784
|
tableName: "account";
|
|
@@ -2452,6 +2484,22 @@ declare const accountSelectSchema: drizzle_orm_zod.BuildSchema<"select", {
|
|
|
2452
2484
|
identity: undefined;
|
|
2453
2485
|
generated: undefined;
|
|
2454
2486
|
}, {}>;
|
|
2487
|
+
syncEnabled: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
2488
|
+
name: string;
|
|
2489
|
+
tableName: "account";
|
|
2490
|
+
dataType: "boolean";
|
|
2491
|
+
data: boolean;
|
|
2492
|
+
driverParam: number;
|
|
2493
|
+
notNull: true;
|
|
2494
|
+
hasDefault: true;
|
|
2495
|
+
isPrimaryKey: false;
|
|
2496
|
+
isAutoincrement: false;
|
|
2497
|
+
hasRuntimeDefault: false;
|
|
2498
|
+
enumValues: undefined;
|
|
2499
|
+
baseColumn: never;
|
|
2500
|
+
identity: undefined;
|
|
2501
|
+
generated: undefined;
|
|
2502
|
+
}, {}>;
|
|
2455
2503
|
syncIntervalS: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
2456
2504
|
name: string;
|
|
2457
2505
|
tableName: "account";
|
|
@@ -3232,7 +3280,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
3232
3280
|
name: string;
|
|
3233
3281
|
tableName: "batch";
|
|
3234
3282
|
dataType: "string enum";
|
|
3235
|
-
data: "AUTHORIZED" | "
|
|
3283
|
+
data: "AUTHORIZED" | "PROCESSING" | "READY_TO_SIGN" | "COMPLETED" | "FAILED";
|
|
3236
3284
|
driverParam: string;
|
|
3237
3285
|
notNull: false;
|
|
3238
3286
|
hasDefault: false;
|
|
@@ -3608,7 +3656,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
3608
3656
|
name: string;
|
|
3609
3657
|
tableName: "payment";
|
|
3610
3658
|
dataType: "string enum";
|
|
3611
|
-
data: "
|
|
3659
|
+
data: "PROCESSING" | "BOOKED" | "REJECTED" | "PENDING" | "CANCELLED" | "SCHEDULED" | "HOLD" | "INFO";
|
|
3612
3660
|
driverParam: string;
|
|
3613
3661
|
notNull: true;
|
|
3614
3662
|
hasDefault: false;
|
|
@@ -4112,7 +4160,7 @@ declare const paymentRequest: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
4112
4160
|
name: string;
|
|
4113
4161
|
tableName: "payment_request";
|
|
4114
4162
|
dataType: "string enum";
|
|
4115
|
-
data: "
|
|
4163
|
+
data: "AUTHORIZED" | "COMPLETED" | "OPENED" | "BOOKED" | "SETTLED" | "REJECTED" | "CLOSED";
|
|
4116
4164
|
driverParam: string;
|
|
4117
4165
|
notNull: true;
|
|
4118
4166
|
hasDefault: false;
|
|
@@ -4812,6 +4860,22 @@ declare const account: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
4812
4860
|
identity: undefined;
|
|
4813
4861
|
generated: undefined;
|
|
4814
4862
|
}, {}>;
|
|
4863
|
+
syncEnabled: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
4864
|
+
name: string;
|
|
4865
|
+
tableName: "account";
|
|
4866
|
+
dataType: "boolean";
|
|
4867
|
+
data: boolean;
|
|
4868
|
+
driverParam: number;
|
|
4869
|
+
notNull: true;
|
|
4870
|
+
hasDefault: true;
|
|
4871
|
+
isPrimaryKey: false;
|
|
4872
|
+
isAutoincrement: false;
|
|
4873
|
+
hasRuntimeDefault: false;
|
|
4874
|
+
enumValues: undefined;
|
|
4875
|
+
baseColumn: never;
|
|
4876
|
+
identity: undefined;
|
|
4877
|
+
generated: undefined;
|
|
4878
|
+
}, {}>;
|
|
4815
4879
|
syncIntervalS: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
4816
4880
|
name: string;
|
|
4817
4881
|
tableName: "account";
|
|
@@ -1042,6 +1042,22 @@ declare const accountInsertSchema: drizzle_orm_zod.BuildSchema<"insert", {
|
|
|
1042
1042
|
identity: undefined;
|
|
1043
1043
|
generated: undefined;
|
|
1044
1044
|
}, {}>;
|
|
1045
|
+
syncEnabled: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1046
|
+
name: string;
|
|
1047
|
+
tableName: "account";
|
|
1048
|
+
dataType: "boolean";
|
|
1049
|
+
data: boolean;
|
|
1050
|
+
driverParam: number;
|
|
1051
|
+
notNull: true;
|
|
1052
|
+
hasDefault: true;
|
|
1053
|
+
isPrimaryKey: false;
|
|
1054
|
+
isAutoincrement: false;
|
|
1055
|
+
hasRuntimeDefault: false;
|
|
1056
|
+
enumValues: undefined;
|
|
1057
|
+
baseColumn: never;
|
|
1058
|
+
identity: undefined;
|
|
1059
|
+
generated: undefined;
|
|
1060
|
+
}, {}>;
|
|
1045
1061
|
syncIntervalS: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1046
1062
|
name: string;
|
|
1047
1063
|
tableName: "account";
|
|
@@ -1747,6 +1763,22 @@ declare const accountUpdateSchema: drizzle_orm_zod.BuildSchema<"update", {
|
|
|
1747
1763
|
identity: undefined;
|
|
1748
1764
|
generated: undefined;
|
|
1749
1765
|
}, {}>;
|
|
1766
|
+
syncEnabled: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1767
|
+
name: string;
|
|
1768
|
+
tableName: "account";
|
|
1769
|
+
dataType: "boolean";
|
|
1770
|
+
data: boolean;
|
|
1771
|
+
driverParam: number;
|
|
1772
|
+
notNull: true;
|
|
1773
|
+
hasDefault: true;
|
|
1774
|
+
isPrimaryKey: false;
|
|
1775
|
+
isAutoincrement: false;
|
|
1776
|
+
hasRuntimeDefault: false;
|
|
1777
|
+
enumValues: undefined;
|
|
1778
|
+
baseColumn: never;
|
|
1779
|
+
identity: undefined;
|
|
1780
|
+
generated: undefined;
|
|
1781
|
+
}, {}>;
|
|
1750
1782
|
syncIntervalS: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1751
1783
|
name: string;
|
|
1752
1784
|
tableName: "account";
|
|
@@ -2452,6 +2484,22 @@ declare const accountSelectSchema: drizzle_orm_zod.BuildSchema<"select", {
|
|
|
2452
2484
|
identity: undefined;
|
|
2453
2485
|
generated: undefined;
|
|
2454
2486
|
}, {}>;
|
|
2487
|
+
syncEnabled: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
2488
|
+
name: string;
|
|
2489
|
+
tableName: "account";
|
|
2490
|
+
dataType: "boolean";
|
|
2491
|
+
data: boolean;
|
|
2492
|
+
driverParam: number;
|
|
2493
|
+
notNull: true;
|
|
2494
|
+
hasDefault: true;
|
|
2495
|
+
isPrimaryKey: false;
|
|
2496
|
+
isAutoincrement: false;
|
|
2497
|
+
hasRuntimeDefault: false;
|
|
2498
|
+
enumValues: undefined;
|
|
2499
|
+
baseColumn: never;
|
|
2500
|
+
identity: undefined;
|
|
2501
|
+
generated: undefined;
|
|
2502
|
+
}, {}>;
|
|
2455
2503
|
syncIntervalS: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
2456
2504
|
name: string;
|
|
2457
2505
|
tableName: "account";
|
|
@@ -3232,7 +3280,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
3232
3280
|
name: string;
|
|
3233
3281
|
tableName: "batch";
|
|
3234
3282
|
dataType: "string enum";
|
|
3235
|
-
data: "AUTHORIZED" | "
|
|
3283
|
+
data: "AUTHORIZED" | "PROCESSING" | "READY_TO_SIGN" | "COMPLETED" | "FAILED";
|
|
3236
3284
|
driverParam: string;
|
|
3237
3285
|
notNull: false;
|
|
3238
3286
|
hasDefault: false;
|
|
@@ -3608,7 +3656,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
3608
3656
|
name: string;
|
|
3609
3657
|
tableName: "payment";
|
|
3610
3658
|
dataType: "string enum";
|
|
3611
|
-
data: "
|
|
3659
|
+
data: "PROCESSING" | "BOOKED" | "REJECTED" | "PENDING" | "CANCELLED" | "SCHEDULED" | "HOLD" | "INFO";
|
|
3612
3660
|
driverParam: string;
|
|
3613
3661
|
notNull: true;
|
|
3614
3662
|
hasDefault: false;
|
|
@@ -4112,7 +4160,7 @@ declare const paymentRequest: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
4112
4160
|
name: string;
|
|
4113
4161
|
tableName: "payment_request";
|
|
4114
4162
|
dataType: "string enum";
|
|
4115
|
-
data: "
|
|
4163
|
+
data: "AUTHORIZED" | "COMPLETED" | "OPENED" | "BOOKED" | "SETTLED" | "REJECTED" | "CLOSED";
|
|
4116
4164
|
driverParam: string;
|
|
4117
4165
|
notNull: true;
|
|
4118
4166
|
hasDefault: false;
|
|
@@ -4812,6 +4860,22 @@ declare const account: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
4812
4860
|
identity: undefined;
|
|
4813
4861
|
generated: undefined;
|
|
4814
4862
|
}, {}>;
|
|
4863
|
+
syncEnabled: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
4864
|
+
name: string;
|
|
4865
|
+
tableName: "account";
|
|
4866
|
+
dataType: "boolean";
|
|
4867
|
+
data: boolean;
|
|
4868
|
+
driverParam: number;
|
|
4869
|
+
notNull: true;
|
|
4870
|
+
hasDefault: true;
|
|
4871
|
+
isPrimaryKey: false;
|
|
4872
|
+
isAutoincrement: false;
|
|
4873
|
+
hasRuntimeDefault: false;
|
|
4874
|
+
enumValues: undefined;
|
|
4875
|
+
baseColumn: never;
|
|
4876
|
+
identity: undefined;
|
|
4877
|
+
generated: undefined;
|
|
4878
|
+
}, {}>;
|
|
4815
4879
|
syncIntervalS: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
4816
4880
|
name: string;
|
|
4817
4881
|
tableName: "account";
|