@develit-services/bank 0.0.30 → 0.0.32
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/database/schema.cjs +1 -2
- 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 -2
- package/dist/export/worker.cjs +58 -69
- package/dist/export/worker.d.cts +21 -10
- package/dist/export/worker.d.mts +21 -10
- package/dist/export/worker.d.ts +21 -10
- package/dist/export/worker.mjs +59 -66
- package/dist/shared/{bank.D8o86NLF.d.mts → bank.-qiBc98X.d.mts} +63 -11
- package/dist/shared/{bank.DbNuuGvb.mjs → bank.A5zjotaU.mjs} +1 -1
- package/dist/shared/{bank.CtUeOz8i.d.ts → bank.BRiDHyNf.d.ts} +63 -11
- package/dist/shared/{bank.DuY4d2y_.cjs → bank.BiZtZWed.cjs} +1 -1
- package/dist/shared/{bank.BMRBXGF1.cjs → bank.Dx7kRjFL.cjs} +18 -10
- package/dist/shared/{bank.DUalSuEK.d.cts → bank._5C74-4K.d.cts} +63 -11
- package/dist/shared/{bank.Nf6oaNfB.d.cts → bank.e_XSg9KV.d.cts} +25 -6
- package/dist/shared/{bank.Nf6oaNfB.d.mts → bank.e_XSg9KV.d.mts} +25 -6
- package/dist/shared/{bank.Nf6oaNfB.d.ts → bank.e_XSg9KV.d.ts} +25 -6
- package/dist/shared/{bank.YCUhOduX.mjs → bank.uJ3YtInA.mjs} +18 -10
- package/dist/types.cjs +2 -3
- package/dist/types.d.cts +66 -68
- package/dist/types.d.mts +66 -68
- package/dist/types.d.ts +66 -68
- package/dist/types.mjs +2 -3
- package/package.json +1 -1
package/dist/database/schema.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const database_schema = require('../shared/bank.
|
|
3
|
+
const database_schema = require('../shared/bank.Dx7kRjFL.cjs');
|
|
4
4
|
require('@develit-io/backend-sdk');
|
|
5
5
|
require('drizzle-orm');
|
|
6
6
|
require('@develit-io/general-codes');
|
|
@@ -10,7 +10,6 @@ require('drizzle-zod');
|
|
|
10
10
|
require('drizzle-orm/sqlite-core');
|
|
11
11
|
require('date-fns');
|
|
12
12
|
require('drizzle-orm/relations');
|
|
13
|
-
require('superjson');
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { f as account, g as accountCredentials, c as batch, o as ott, d as payment, e as paymentRelations } from '../shared/bank.
|
|
1
|
+
export { f as account, g as accountCredentials, c as batch, o as ott, d as payment, e as paymentRelations } from '../shared/bank.e_XSg9KV.cjs';
|
|
2
2
|
import 'drizzle-orm/sqlite-core';
|
|
3
3
|
import 'drizzle-orm';
|
|
4
4
|
import 'zod';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { f as account, g as accountCredentials, c as batch, o as ott, d as payment, e as paymentRelations } from '../shared/bank.
|
|
1
|
+
export { f as account, g as accountCredentials, c as batch, o as ott, d as payment, e as paymentRelations } from '../shared/bank.e_XSg9KV.mjs';
|
|
2
2
|
import 'drizzle-orm/sqlite-core';
|
|
3
3
|
import 'drizzle-orm';
|
|
4
4
|
import 'zod';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { f as account, g as accountCredentials, c as batch, o as ott, d as payment, e as paymentRelations } from '../shared/bank.
|
|
1
|
+
export { f as account, g as accountCredentials, c as batch, o as ott, d as payment, e as paymentRelations } from '../shared/bank.e_XSg9KV.js';
|
|
2
2
|
import 'drizzle-orm/sqlite-core';
|
|
3
3
|
import 'drizzle-orm';
|
|
4
4
|
import 'zod';
|
package/dist/database/schema.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { y as account, z as accountCredentials, r as batch, x as ott, v as payment, w as paymentRelations } from '../shared/bank.
|
|
1
|
+
export { y as account, z as accountCredentials, r as batch, x as ott, v as payment, w as paymentRelations } from '../shared/bank.uJ3YtInA.mjs';
|
|
2
2
|
import '@develit-io/backend-sdk';
|
|
3
3
|
import 'drizzle-orm';
|
|
4
4
|
import '@develit-io/general-codes';
|
|
@@ -8,4 +8,3 @@ import 'drizzle-zod';
|
|
|
8
8
|
import 'drizzle-orm/sqlite-core';
|
|
9
9
|
import 'date-fns';
|
|
10
10
|
import 'drizzle-orm/relations';
|
|
11
|
-
import 'superjson';
|
package/dist/export/worker.cjs
CHANGED
|
@@ -3,24 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const backendSdk = require('@develit-io/backend-sdk');
|
|
6
|
-
const database_schema = require('../shared/bank.
|
|
6
|
+
const database_schema = require('../shared/bank.Dx7kRjFL.cjs');
|
|
7
7
|
const cloudflare_workers = require('cloudflare:workers');
|
|
8
8
|
const d1 = require('drizzle-orm/d1');
|
|
9
9
|
const zod = require('zod');
|
|
10
10
|
const generalCodes = require('@develit-io/general-codes');
|
|
11
11
|
require('jose');
|
|
12
12
|
const drizzleOrm = require('drizzle-orm');
|
|
13
|
-
const mockCobs_connector = require('../shared/bank.
|
|
14
|
-
const superjson = require('superjson');
|
|
13
|
+
const mockCobs_connector = require('../shared/bank.BiZtZWed.cjs');
|
|
15
14
|
require('drizzle-zod');
|
|
16
15
|
require('drizzle-orm/sqlite-core');
|
|
17
16
|
require('date-fns');
|
|
18
17
|
require('drizzle-orm/relations');
|
|
19
18
|
|
|
20
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
21
|
-
|
|
22
|
-
const superjson__default = /*#__PURE__*/_interopDefaultCompat(superjson);
|
|
23
|
-
|
|
24
19
|
const upsertAccountCommand = (db, { account }) => {
|
|
25
20
|
const id = account.id || backendSdk.uuidv4();
|
|
26
21
|
const command = db.insert(database_schema.tables.account).values({ ...account, id }).onConflictDoUpdate({
|
|
@@ -107,6 +102,15 @@ const deleteAccountCredentialsCommand = (db, { accountId }) => {
|
|
|
107
102
|
};
|
|
108
103
|
};
|
|
109
104
|
|
|
105
|
+
const updateAccountLastSyncCommand = (db, { lastSyncedAt, accountId }) => {
|
|
106
|
+
const command = db.update(database_schema.tables.account).set({
|
|
107
|
+
lastSyncedAt
|
|
108
|
+
}).where(drizzleOrm.eq(database_schema.tables.account.id, accountId)).returning();
|
|
109
|
+
return {
|
|
110
|
+
command
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
|
|
110
114
|
const getPaymentByRefIdQuery = async (db, { refId }) => {
|
|
111
115
|
const payment = await db.select().from(database_schema.tables.payment).where(drizzleOrm.eq(database_schema.tables.payment.refId, refId)).limit(1).get();
|
|
112
116
|
return payment;
|
|
@@ -140,6 +144,10 @@ const getAllPendingBatchesQuery = (db) => {
|
|
|
140
144
|
);
|
|
141
145
|
};
|
|
142
146
|
|
|
147
|
+
const getAccountByIdQuery = async (db, { accountId }) => {
|
|
148
|
+
return await db.select().from(database_schema.tables.account).where(drizzleOrm.eq(database_schema.tables.account.id, accountId)).get();
|
|
149
|
+
};
|
|
150
|
+
|
|
143
151
|
const getCredentialsByAccountId = async (db, { accountId }) => {
|
|
144
152
|
const cred = await db.select().from(database_schema.tables.accountCredentials).where(drizzleOrm.eq(database_schema.tables.accountCredentials.accountId, accountId)).get();
|
|
145
153
|
return cred;
|
|
@@ -298,35 +306,6 @@ const initiateConnector = ({
|
|
|
298
306
|
}
|
|
299
307
|
};
|
|
300
308
|
|
|
301
|
-
const useSync = (kv) => {
|
|
302
|
-
const getLastSync = async ({
|
|
303
|
-
account
|
|
304
|
-
}) => {
|
|
305
|
-
const [rawSync, rawSyncError] = await backendSdk.useResult(
|
|
306
|
-
kv.get(`sync-log:${account.iban}:${account.currency}`)
|
|
307
|
-
);
|
|
308
|
-
if (rawSyncError) throw backendSdk.createInternalError(rawSyncError);
|
|
309
|
-
if (!rawSync) return null;
|
|
310
|
-
return superjson__default.parse(rawSync);
|
|
311
|
-
};
|
|
312
|
-
const setLastSync = async ({
|
|
313
|
-
account,
|
|
314
|
-
log
|
|
315
|
-
}) => {
|
|
316
|
-
const [_, error] = await backendSdk.useResult(
|
|
317
|
-
kv.put(
|
|
318
|
-
`sync-log:${account.iban}:${account.currency}`,
|
|
319
|
-
superjson__default.stringify(log)
|
|
320
|
-
)
|
|
321
|
-
);
|
|
322
|
-
if (error) throw error;
|
|
323
|
-
};
|
|
324
|
-
return {
|
|
325
|
-
getLastSync,
|
|
326
|
-
setLastSync
|
|
327
|
-
};
|
|
328
|
-
};
|
|
329
|
-
|
|
330
309
|
const seperateSupportedPayments = (mappedPayments, accounts) => {
|
|
331
310
|
const [supportedPayments, unsupportedPayments] = mappedPayments.reduce(
|
|
332
311
|
([valid, invalid], payment) => {
|
|
@@ -433,6 +412,10 @@ const getPaymentsInputSchema = zod.z.object({
|
|
|
433
412
|
[ALLOWED_PAYMENT_FILTERS.STATUS]: zod.z.union([zod.z.enum(database_schema.PAYMENT_STATUSES), zod.z.enum(database_schema.PAYMENT_STATUSES).array()]).optional()
|
|
434
413
|
});
|
|
435
414
|
|
|
415
|
+
const syncAccountInputSchema = zod.z.object({
|
|
416
|
+
accountId: zod.z.uuid()
|
|
417
|
+
});
|
|
418
|
+
|
|
436
419
|
var __defProp = Object.defineProperty;
|
|
437
420
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
438
421
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
@@ -477,35 +460,46 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
477
460
|
return 0;
|
|
478
461
|
}
|
|
479
462
|
}
|
|
480
|
-
async
|
|
463
|
+
async syncAccount(input) {
|
|
464
|
+
return this.handleAction(
|
|
465
|
+
{ data: input, schema: syncAccountInputSchema },
|
|
466
|
+
{ successMessage: "" },
|
|
467
|
+
async ({ accountId }) => {
|
|
468
|
+
const account = await getAccountByIdQuery(this.db, {
|
|
469
|
+
accountId
|
|
470
|
+
});
|
|
471
|
+
if (!account)
|
|
472
|
+
throw backendSdk.createInternalError(null, {
|
|
473
|
+
code: "NOT_FOUND",
|
|
474
|
+
message: "Account not found",
|
|
475
|
+
status: 404
|
|
476
|
+
});
|
|
477
|
+
await this.syncAccounts({
|
|
478
|
+
accounts: [account]
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
async syncAccounts(options) {
|
|
481
484
|
return this.handleAction(null, {}, async () => {
|
|
482
485
|
const accountsToSync = [];
|
|
483
|
-
|
|
484
|
-
|
|
486
|
+
let accounts = options?.accounts || [];
|
|
487
|
+
if (!accounts.length) {
|
|
488
|
+
accounts = await this.getAccounts();
|
|
489
|
+
}
|
|
485
490
|
for (const account of accounts.filter(
|
|
486
491
|
(acc) => !!!acc.connectorKey.includes("MOCK")
|
|
487
492
|
)) {
|
|
488
|
-
let lastSync = await getLastSync({ account: { ...account, token: "" } });
|
|
489
|
-
if (!lastSync) {
|
|
490
|
-
await this.setLastSyncAt({
|
|
491
|
-
iban: account.iban,
|
|
492
|
-
lastSyncedAt: account.lastSyncedAt || /* @__PURE__ */ new Date()
|
|
493
|
-
});
|
|
494
|
-
lastSync = await getLastSync({ account: { ...account, token: "" } });
|
|
495
|
-
if (!lastSync) continue;
|
|
496
|
-
}
|
|
497
493
|
const accountFetchInterval = this.accountFetchInterval(
|
|
498
494
|
account.connectorKey
|
|
499
495
|
);
|
|
500
496
|
const now = Date.now();
|
|
501
|
-
const lastSyncTime =
|
|
497
|
+
const lastSyncTime = account.lastSyncedAt.getTime();
|
|
502
498
|
const intervalMs = accountFetchInterval * 1e3;
|
|
503
499
|
const shouldFetch = now - lastSyncTime >= intervalMs;
|
|
504
500
|
if (!shouldFetch) continue;
|
|
505
501
|
accountsToSync.push({
|
|
506
|
-
...account
|
|
507
|
-
lastSyncAt: lastSync,
|
|
508
|
-
token: ""
|
|
502
|
+
...account
|
|
509
503
|
});
|
|
510
504
|
}
|
|
511
505
|
console.log("ACCS TO SYNC", accountsToSync.length);
|
|
@@ -941,7 +935,6 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
941
935
|
);
|
|
942
936
|
}
|
|
943
937
|
async saveOrUpdatePayments(accounts) {
|
|
944
|
-
const { setLastSync } = useSync(this.env.BANK_KV);
|
|
945
938
|
return this.handleAction(null, {}, async () => {
|
|
946
939
|
const allFetchedPayments = [];
|
|
947
940
|
const connectorKeys = new Set(
|
|
@@ -952,12 +945,10 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
952
945
|
for (const account of accounts.filter(
|
|
953
946
|
(acc) => acc.connectorKey === connectorKey
|
|
954
947
|
)) {
|
|
955
|
-
const { lastSyncAt } = account;
|
|
956
948
|
const payments = await this.bankConnector.getAllAccountPayments({
|
|
957
949
|
db: this.db,
|
|
958
950
|
env: this.env.ENVIRONMENT,
|
|
959
|
-
account
|
|
960
|
-
lastSync: lastSyncAt
|
|
951
|
+
account
|
|
961
952
|
});
|
|
962
953
|
if (!payments || payments.length === 0) continue;
|
|
963
954
|
this.log(payments);
|
|
@@ -997,12 +988,10 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
997
988
|
)[0];
|
|
998
989
|
}
|
|
999
990
|
if (lastSyncPayment.createdAt) {
|
|
1000
|
-
await
|
|
1001
|
-
account,
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
}
|
|
1005
|
-
});
|
|
991
|
+
await updateAccountLastSyncCommand(this.db, {
|
|
992
|
+
accountId: account.id,
|
|
993
|
+
lastSyncedAt: lastSyncPayment.createdAt
|
|
994
|
+
}).command.execute();
|
|
1006
995
|
}
|
|
1007
996
|
}
|
|
1008
997
|
await this.pushToQueue(
|
|
@@ -1085,7 +1074,6 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
1085
1074
|
{ data: input, schema: setLastSyncAtInputSchema },
|
|
1086
1075
|
{ successMessage: "Last sync set." },
|
|
1087
1076
|
async ({ iban, lastSyncedAt }) => {
|
|
1088
|
-
const { setLastSync } = useSync(this.env.BANK_KV);
|
|
1089
1077
|
const account = await getAccountByIbanQuery(this.db, {
|
|
1090
1078
|
iban
|
|
1091
1079
|
});
|
|
@@ -1095,12 +1083,10 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
1095
1083
|
message: "Account for this organization does not exist."
|
|
1096
1084
|
});
|
|
1097
1085
|
}
|
|
1098
|
-
await
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
account: { ...account, token: "" }
|
|
1103
|
-
});
|
|
1086
|
+
await updateAccountLastSyncCommand(this.db, {
|
|
1087
|
+
accountId: account.id,
|
|
1088
|
+
lastSyncedAt
|
|
1089
|
+
}).command.execute();
|
|
1104
1090
|
return {};
|
|
1105
1091
|
}
|
|
1106
1092
|
);
|
|
@@ -1143,6 +1129,9 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
1143
1129
|
__decorateClass([
|
|
1144
1130
|
backendSdk.action("get-payments")
|
|
1145
1131
|
], BankServiceBase.prototype, "getPayments", 1);
|
|
1132
|
+
__decorateClass([
|
|
1133
|
+
backendSdk.action("sync-account")
|
|
1134
|
+
], BankServiceBase.prototype, "syncAccount", 1);
|
|
1146
1135
|
__decorateClass([
|
|
1147
1136
|
backendSdk.action("synchronize-accounts")
|
|
1148
1137
|
], BankServiceBase.prototype, "syncAccounts", 1);
|
package/dist/export/worker.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
|
|
2
2
|
import { IRPCResponse } from '@develit-io/backend-sdk';
|
|
3
|
-
import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as PaymentInsertType } from '../shared/bank.
|
|
3
|
+
import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as PaymentInsertType } from '../shared/bank.e_XSg9KV.cjs';
|
|
4
4
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
5
5
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
import { A as AccountSelectType, C as ConfigEnvironmentBank, I as IBankConnector, a as ConnectorKey
|
|
7
|
+
import { A as AccountSelectType, C as ConfigEnvironmentBank, I as IBankConnector, a as ConnectorKey } from '../shared/bank._5C74-4K.cjs';
|
|
8
8
|
import 'drizzle-orm/sqlite-core';
|
|
9
9
|
import 'drizzle-orm';
|
|
10
10
|
import '@develit-io/general-codes';
|
|
@@ -251,9 +251,9 @@ declare const getPaymentsInputSchema: z.ZodObject<{
|
|
|
251
251
|
limit: z.ZodNumber;
|
|
252
252
|
sort: z.ZodObject<{
|
|
253
253
|
column: z.ZodEnum<{
|
|
254
|
-
amount: "amount";
|
|
255
254
|
createdAt: "createdAt";
|
|
256
255
|
updatedAt: "updatedAt";
|
|
256
|
+
amount: "amount";
|
|
257
257
|
}>;
|
|
258
258
|
direction: z.ZodEnum<{
|
|
259
259
|
asc: "asc";
|
|
@@ -382,17 +382,17 @@ declare const getPaymentsInputSchema: z.ZodObject<{
|
|
|
382
382
|
filterPaymentDateTo: z.ZodOptional<z.ZodDate>;
|
|
383
383
|
filterPaymentStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
384
384
|
PREPARED: "PREPARED";
|
|
385
|
-
|
|
385
|
+
COMPLETED: "COMPLETED";
|
|
386
386
|
FAILED: "FAILED";
|
|
387
|
+
INITIALIZED: "INITIALIZED";
|
|
387
388
|
PENDING: "PENDING";
|
|
388
|
-
COMPLETED: "COMPLETED";
|
|
389
389
|
CREATED: "CREATED";
|
|
390
390
|
}>, z.ZodArray<z.ZodEnum<{
|
|
391
391
|
PREPARED: "PREPARED";
|
|
392
|
-
|
|
392
|
+
COMPLETED: "COMPLETED";
|
|
393
393
|
FAILED: "FAILED";
|
|
394
|
+
INITIALIZED: "INITIALIZED";
|
|
394
395
|
PENDING: "PENDING";
|
|
395
|
-
COMPLETED: "COMPLETED";
|
|
396
396
|
CREATED: "CREATED";
|
|
397
397
|
}>>]>>;
|
|
398
398
|
}, z.core.$strip>;
|
|
@@ -402,6 +402,13 @@ type GetPaymentsOutput = {
|
|
|
402
402
|
totalCount: number;
|
|
403
403
|
};
|
|
404
404
|
|
|
405
|
+
declare const syncAccountInputSchema: z.ZodObject<{
|
|
406
|
+
accountId: z.ZodUUID;
|
|
407
|
+
}, z.core.$strip>;
|
|
408
|
+
interface SyncAccountInput extends z.infer<typeof syncAccountInputSchema> {
|
|
409
|
+
}
|
|
410
|
+
type SyncAccountOutput = void;
|
|
411
|
+
|
|
405
412
|
declare const BankServiceBase_base: (abstract new (ctx: ExecutionContext, env: BankEnv) => WorkerEntrypoint<BankEnv, {}>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
|
|
406
413
|
declare class BankServiceBase extends BankServiceBase_base {
|
|
407
414
|
readonly db: DrizzleD1Database<typeof tables>;
|
|
@@ -413,6 +420,7 @@ declare class BankServiceBase extends BankServiceBase_base {
|
|
|
413
420
|
expiresAt: Date | undefined;
|
|
414
421
|
connectorKey: "ERSTE" | "FINBRICKS" | "MOCK" | "CREDITAS" | "MOCK_COBS" | "FIO" | "MONETA";
|
|
415
422
|
status: "AUTHORIZED" | "DISABLED" | "EXPIRED";
|
|
423
|
+
bankRefId: string;
|
|
416
424
|
sync: boolean;
|
|
417
425
|
syncPeriod: number | null;
|
|
418
426
|
lastSyncedAt: Date | null;
|
|
@@ -432,14 +440,17 @@ declare class BankServiceBase extends BankServiceBase_base {
|
|
|
432
440
|
}[]>;
|
|
433
441
|
getPayments(input: GetPaymentsInput): Promise<IRPCResponse<GetPaymentsOutput>>;
|
|
434
442
|
accountFetchInterval(connectorKey: ConnectorKey): number;
|
|
435
|
-
|
|
443
|
+
syncAccount(input: SyncAccountInput): Promise<IRPCResponse<SyncAccountOutput>>;
|
|
444
|
+
syncAccounts(options?: {
|
|
445
|
+
accounts?: AccountSelectType[];
|
|
446
|
+
}): Promise<IRPCResponse<void>>;
|
|
436
447
|
scheduled(controller: ScheduledController): Promise<void>;
|
|
437
448
|
updateBatchStatuses(): Promise<void>;
|
|
438
449
|
initiateBankConnector(input: initiateConnectorInput): Promise<initiateConnectorOutput>;
|
|
439
450
|
addPaymentsToBatch({ paymentsToBatch, }: {
|
|
440
451
|
paymentsToBatch: SendPaymentInput[];
|
|
441
452
|
}): Promise<IRPCResponse<{
|
|
442
|
-
status: "
|
|
453
|
+
status: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED" | null;
|
|
443
454
|
id: string;
|
|
444
455
|
createdAt: Date | null;
|
|
445
456
|
updatedAt: Date | null;
|
|
@@ -454,7 +465,7 @@ declare class BankServiceBase extends BankServiceBase_base {
|
|
|
454
465
|
queue(b: MessageBatch<SendPaymentInput>): Promise<void>;
|
|
455
466
|
getAuthUri(input: GetAuthUriInput): Promise<IRPCResponse<GetAuthUriOutput>>;
|
|
456
467
|
authorizeAccount(input: AuthorizeAccountInput): Promise<IRPCResponse<AuthorizeAccountOutput>>;
|
|
457
|
-
saveOrUpdatePayments(accounts:
|
|
468
|
+
saveOrUpdatePayments(accounts: AccountSelectType[]): Promise<IRPCResponse<void>>;
|
|
458
469
|
simulateDeposit(input: SimulateDepositInput): Promise<IRPCResponse<SimulateDepositOutput>>;
|
|
459
470
|
setLastSyncAt(input: SetLastSyncAtInput): Promise<IRPCResponse<SetLastSyncAtOutput>>;
|
|
460
471
|
sendPayment(input: SendPaymentInput): Promise<IRPCResponse<SendPaymentOutput>>;
|
package/dist/export/worker.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
|
|
2
2
|
import { IRPCResponse } from '@develit-io/backend-sdk';
|
|
3
|
-
import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as PaymentInsertType } from '../shared/bank.
|
|
3
|
+
import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as PaymentInsertType } from '../shared/bank.e_XSg9KV.mjs';
|
|
4
4
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
5
5
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
import { A as AccountSelectType, C as ConfigEnvironmentBank, I as IBankConnector, a as ConnectorKey
|
|
7
|
+
import { A as AccountSelectType, C as ConfigEnvironmentBank, I as IBankConnector, a as ConnectorKey } from '../shared/bank.-qiBc98X.mjs';
|
|
8
8
|
import 'drizzle-orm/sqlite-core';
|
|
9
9
|
import 'drizzle-orm';
|
|
10
10
|
import '@develit-io/general-codes';
|
|
@@ -251,9 +251,9 @@ declare const getPaymentsInputSchema: z.ZodObject<{
|
|
|
251
251
|
limit: z.ZodNumber;
|
|
252
252
|
sort: z.ZodObject<{
|
|
253
253
|
column: z.ZodEnum<{
|
|
254
|
-
amount: "amount";
|
|
255
254
|
createdAt: "createdAt";
|
|
256
255
|
updatedAt: "updatedAt";
|
|
256
|
+
amount: "amount";
|
|
257
257
|
}>;
|
|
258
258
|
direction: z.ZodEnum<{
|
|
259
259
|
asc: "asc";
|
|
@@ -382,17 +382,17 @@ declare const getPaymentsInputSchema: z.ZodObject<{
|
|
|
382
382
|
filterPaymentDateTo: z.ZodOptional<z.ZodDate>;
|
|
383
383
|
filterPaymentStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
384
384
|
PREPARED: "PREPARED";
|
|
385
|
-
|
|
385
|
+
COMPLETED: "COMPLETED";
|
|
386
386
|
FAILED: "FAILED";
|
|
387
|
+
INITIALIZED: "INITIALIZED";
|
|
387
388
|
PENDING: "PENDING";
|
|
388
|
-
COMPLETED: "COMPLETED";
|
|
389
389
|
CREATED: "CREATED";
|
|
390
390
|
}>, z.ZodArray<z.ZodEnum<{
|
|
391
391
|
PREPARED: "PREPARED";
|
|
392
|
-
|
|
392
|
+
COMPLETED: "COMPLETED";
|
|
393
393
|
FAILED: "FAILED";
|
|
394
|
+
INITIALIZED: "INITIALIZED";
|
|
394
395
|
PENDING: "PENDING";
|
|
395
|
-
COMPLETED: "COMPLETED";
|
|
396
396
|
CREATED: "CREATED";
|
|
397
397
|
}>>]>>;
|
|
398
398
|
}, z.core.$strip>;
|
|
@@ -402,6 +402,13 @@ type GetPaymentsOutput = {
|
|
|
402
402
|
totalCount: number;
|
|
403
403
|
};
|
|
404
404
|
|
|
405
|
+
declare const syncAccountInputSchema: z.ZodObject<{
|
|
406
|
+
accountId: z.ZodUUID;
|
|
407
|
+
}, z.core.$strip>;
|
|
408
|
+
interface SyncAccountInput extends z.infer<typeof syncAccountInputSchema> {
|
|
409
|
+
}
|
|
410
|
+
type SyncAccountOutput = void;
|
|
411
|
+
|
|
405
412
|
declare const BankServiceBase_base: (abstract new (ctx: ExecutionContext, env: BankEnv) => WorkerEntrypoint<BankEnv, {}>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
|
|
406
413
|
declare class BankServiceBase extends BankServiceBase_base {
|
|
407
414
|
readonly db: DrizzleD1Database<typeof tables>;
|
|
@@ -413,6 +420,7 @@ declare class BankServiceBase extends BankServiceBase_base {
|
|
|
413
420
|
expiresAt: Date | undefined;
|
|
414
421
|
connectorKey: "ERSTE" | "FINBRICKS" | "MOCK" | "CREDITAS" | "MOCK_COBS" | "FIO" | "MONETA";
|
|
415
422
|
status: "AUTHORIZED" | "DISABLED" | "EXPIRED";
|
|
423
|
+
bankRefId: string;
|
|
416
424
|
sync: boolean;
|
|
417
425
|
syncPeriod: number | null;
|
|
418
426
|
lastSyncedAt: Date | null;
|
|
@@ -432,14 +440,17 @@ declare class BankServiceBase extends BankServiceBase_base {
|
|
|
432
440
|
}[]>;
|
|
433
441
|
getPayments(input: GetPaymentsInput): Promise<IRPCResponse<GetPaymentsOutput>>;
|
|
434
442
|
accountFetchInterval(connectorKey: ConnectorKey): number;
|
|
435
|
-
|
|
443
|
+
syncAccount(input: SyncAccountInput): Promise<IRPCResponse<SyncAccountOutput>>;
|
|
444
|
+
syncAccounts(options?: {
|
|
445
|
+
accounts?: AccountSelectType[];
|
|
446
|
+
}): Promise<IRPCResponse<void>>;
|
|
436
447
|
scheduled(controller: ScheduledController): Promise<void>;
|
|
437
448
|
updateBatchStatuses(): Promise<void>;
|
|
438
449
|
initiateBankConnector(input: initiateConnectorInput): Promise<initiateConnectorOutput>;
|
|
439
450
|
addPaymentsToBatch({ paymentsToBatch, }: {
|
|
440
451
|
paymentsToBatch: SendPaymentInput[];
|
|
441
452
|
}): Promise<IRPCResponse<{
|
|
442
|
-
status: "
|
|
453
|
+
status: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED" | null;
|
|
443
454
|
id: string;
|
|
444
455
|
createdAt: Date | null;
|
|
445
456
|
updatedAt: Date | null;
|
|
@@ -454,7 +465,7 @@ declare class BankServiceBase extends BankServiceBase_base {
|
|
|
454
465
|
queue(b: MessageBatch<SendPaymentInput>): Promise<void>;
|
|
455
466
|
getAuthUri(input: GetAuthUriInput): Promise<IRPCResponse<GetAuthUriOutput>>;
|
|
456
467
|
authorizeAccount(input: AuthorizeAccountInput): Promise<IRPCResponse<AuthorizeAccountOutput>>;
|
|
457
|
-
saveOrUpdatePayments(accounts:
|
|
468
|
+
saveOrUpdatePayments(accounts: AccountSelectType[]): Promise<IRPCResponse<void>>;
|
|
458
469
|
simulateDeposit(input: SimulateDepositInput): Promise<IRPCResponse<SimulateDepositOutput>>;
|
|
459
470
|
setLastSyncAt(input: SetLastSyncAtInput): Promise<IRPCResponse<SetLastSyncAtOutput>>;
|
|
460
471
|
sendPayment(input: SendPaymentInput): Promise<IRPCResponse<SendPaymentOutput>>;
|
package/dist/export/worker.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
|
|
2
2
|
import { IRPCResponse } from '@develit-io/backend-sdk';
|
|
3
|
-
import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as PaymentInsertType } from '../shared/bank.
|
|
3
|
+
import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as PaymentInsertType } from '../shared/bank.e_XSg9KV.js';
|
|
4
4
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
5
5
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
import { A as AccountSelectType, C as ConfigEnvironmentBank, I as IBankConnector, a as ConnectorKey
|
|
7
|
+
import { A as AccountSelectType, C as ConfigEnvironmentBank, I as IBankConnector, a as ConnectorKey } from '../shared/bank.BRiDHyNf.js';
|
|
8
8
|
import 'drizzle-orm/sqlite-core';
|
|
9
9
|
import 'drizzle-orm';
|
|
10
10
|
import '@develit-io/general-codes';
|
|
@@ -251,9 +251,9 @@ declare const getPaymentsInputSchema: z.ZodObject<{
|
|
|
251
251
|
limit: z.ZodNumber;
|
|
252
252
|
sort: z.ZodObject<{
|
|
253
253
|
column: z.ZodEnum<{
|
|
254
|
-
amount: "amount";
|
|
255
254
|
createdAt: "createdAt";
|
|
256
255
|
updatedAt: "updatedAt";
|
|
256
|
+
amount: "amount";
|
|
257
257
|
}>;
|
|
258
258
|
direction: z.ZodEnum<{
|
|
259
259
|
asc: "asc";
|
|
@@ -382,17 +382,17 @@ declare const getPaymentsInputSchema: z.ZodObject<{
|
|
|
382
382
|
filterPaymentDateTo: z.ZodOptional<z.ZodDate>;
|
|
383
383
|
filterPaymentStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
384
384
|
PREPARED: "PREPARED";
|
|
385
|
-
|
|
385
|
+
COMPLETED: "COMPLETED";
|
|
386
386
|
FAILED: "FAILED";
|
|
387
|
+
INITIALIZED: "INITIALIZED";
|
|
387
388
|
PENDING: "PENDING";
|
|
388
|
-
COMPLETED: "COMPLETED";
|
|
389
389
|
CREATED: "CREATED";
|
|
390
390
|
}>, z.ZodArray<z.ZodEnum<{
|
|
391
391
|
PREPARED: "PREPARED";
|
|
392
|
-
|
|
392
|
+
COMPLETED: "COMPLETED";
|
|
393
393
|
FAILED: "FAILED";
|
|
394
|
+
INITIALIZED: "INITIALIZED";
|
|
394
395
|
PENDING: "PENDING";
|
|
395
|
-
COMPLETED: "COMPLETED";
|
|
396
396
|
CREATED: "CREATED";
|
|
397
397
|
}>>]>>;
|
|
398
398
|
}, z.core.$strip>;
|
|
@@ -402,6 +402,13 @@ type GetPaymentsOutput = {
|
|
|
402
402
|
totalCount: number;
|
|
403
403
|
};
|
|
404
404
|
|
|
405
|
+
declare const syncAccountInputSchema: z.ZodObject<{
|
|
406
|
+
accountId: z.ZodUUID;
|
|
407
|
+
}, z.core.$strip>;
|
|
408
|
+
interface SyncAccountInput extends z.infer<typeof syncAccountInputSchema> {
|
|
409
|
+
}
|
|
410
|
+
type SyncAccountOutput = void;
|
|
411
|
+
|
|
405
412
|
declare const BankServiceBase_base: (abstract new (ctx: ExecutionContext, env: BankEnv) => WorkerEntrypoint<BankEnv, {}>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
|
|
406
413
|
declare class BankServiceBase extends BankServiceBase_base {
|
|
407
414
|
readonly db: DrizzleD1Database<typeof tables>;
|
|
@@ -413,6 +420,7 @@ declare class BankServiceBase extends BankServiceBase_base {
|
|
|
413
420
|
expiresAt: Date | undefined;
|
|
414
421
|
connectorKey: "ERSTE" | "FINBRICKS" | "MOCK" | "CREDITAS" | "MOCK_COBS" | "FIO" | "MONETA";
|
|
415
422
|
status: "AUTHORIZED" | "DISABLED" | "EXPIRED";
|
|
423
|
+
bankRefId: string;
|
|
416
424
|
sync: boolean;
|
|
417
425
|
syncPeriod: number | null;
|
|
418
426
|
lastSyncedAt: Date | null;
|
|
@@ -432,14 +440,17 @@ declare class BankServiceBase extends BankServiceBase_base {
|
|
|
432
440
|
}[]>;
|
|
433
441
|
getPayments(input: GetPaymentsInput): Promise<IRPCResponse<GetPaymentsOutput>>;
|
|
434
442
|
accountFetchInterval(connectorKey: ConnectorKey): number;
|
|
435
|
-
|
|
443
|
+
syncAccount(input: SyncAccountInput): Promise<IRPCResponse<SyncAccountOutput>>;
|
|
444
|
+
syncAccounts(options?: {
|
|
445
|
+
accounts?: AccountSelectType[];
|
|
446
|
+
}): Promise<IRPCResponse<void>>;
|
|
436
447
|
scheduled(controller: ScheduledController): Promise<void>;
|
|
437
448
|
updateBatchStatuses(): Promise<void>;
|
|
438
449
|
initiateBankConnector(input: initiateConnectorInput): Promise<initiateConnectorOutput>;
|
|
439
450
|
addPaymentsToBatch({ paymentsToBatch, }: {
|
|
440
451
|
paymentsToBatch: SendPaymentInput[];
|
|
441
452
|
}): Promise<IRPCResponse<{
|
|
442
|
-
status: "
|
|
453
|
+
status: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED" | null;
|
|
443
454
|
id: string;
|
|
444
455
|
createdAt: Date | null;
|
|
445
456
|
updatedAt: Date | null;
|
|
@@ -454,7 +465,7 @@ declare class BankServiceBase extends BankServiceBase_base {
|
|
|
454
465
|
queue(b: MessageBatch<SendPaymentInput>): Promise<void>;
|
|
455
466
|
getAuthUri(input: GetAuthUriInput): Promise<IRPCResponse<GetAuthUriOutput>>;
|
|
456
467
|
authorizeAccount(input: AuthorizeAccountInput): Promise<IRPCResponse<AuthorizeAccountOutput>>;
|
|
457
|
-
saveOrUpdatePayments(accounts:
|
|
468
|
+
saveOrUpdatePayments(accounts: AccountSelectType[]): Promise<IRPCResponse<void>>;
|
|
458
469
|
simulateDeposit(input: SimulateDepositInput): Promise<IRPCResponse<SimulateDepositOutput>>;
|
|
459
470
|
setLastSyncAt(input: SetLastSyncAtInput): Promise<IRPCResponse<SetLastSyncAtOutput>>;
|
|
460
471
|
sendPayment(input: SendPaymentInput): Promise<IRPCResponse<SendPaymentOutput>>;
|