@develit-services/bank 0.1.5 → 0.1.7
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.d.cts +1 -1
- package/dist/database/schema.d.mts +1 -1
- package/dist/database/schema.d.ts +1 -1
- package/dist/export/worker.cjs +1 -5
- package/dist/export/worker.d.cts +14 -14
- package/dist/export/worker.d.mts +14 -14
- package/dist/export/worker.d.ts +14 -14
- package/dist/export/worker.mjs +2 -6
- package/dist/export/workflows.cjs +1 -1
- package/dist/export/workflows.d.cts +1 -1
- package/dist/export/workflows.d.mts +1 -1
- package/dist/export/workflows.d.ts +1 -1
- package/dist/export/workflows.mjs +1 -1
- package/dist/shared/{bank.aQ9BdSZH.cjs → bank.B3isylGM.cjs} +71 -78
- package/dist/shared/{bank.DpCeuDbj.d.mts → bank.BFGDv0oC.d.cts} +6 -6
- package/dist/shared/{bank.DpCeuDbj.d.ts → bank.BFGDv0oC.d.mts} +6 -6
- package/dist/shared/{bank.DpCeuDbj.d.cts → bank.BFGDv0oC.d.ts} +6 -6
- package/dist/shared/{bank.CH22Zrdv.d.cts → bank.ChAGzUFo.d.cts} +1 -3
- package/dist/shared/{bank.CH22Zrdv.d.mts → bank.ChAGzUFo.d.mts} +1 -3
- package/dist/shared/{bank.CH22Zrdv.d.ts → bank.ChAGzUFo.d.ts} +1 -3
- package/dist/shared/{bank.CKFLzN49.d.mts → bank.CrRs_x0N.d.mts} +1 -1
- package/dist/shared/{bank.ClVtgYqT.d.ts → bank.DCTBX1dp.d.ts} +1 -1
- package/dist/shared/{bank.CRz5Du_I.d.cts → bank.DSVzOCrh.d.cts} +1 -1
- package/dist/shared/{bank.C4V6vvM1.mjs → bank.JtGSu6eH.mjs} +71 -78
- package/dist/types.d.cts +4 -4
- package/dist/types.d.mts +4 -4
- package/dist/types.d.ts +4 -4
- package/package.json +1 -1
|
@@ -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.BFGDv0oC.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.BFGDv0oC.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.BFGDv0oC.js';
|
|
2
2
|
import 'drizzle-orm/sqlite-core';
|
|
3
3
|
import 'drizzle-orm';
|
|
4
4
|
import 'zod';
|
package/dist/export/worker.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const export_workflows = require('../shared/bank.
|
|
3
|
+
const export_workflows = require('../shared/bank.B3isylGM.cjs');
|
|
4
4
|
const backendSdk = require('@develit-io/backend-sdk');
|
|
5
5
|
const cloudflare_workers = require('cloudflare:workers');
|
|
6
6
|
const d1 = require('drizzle-orm/d1');
|
|
@@ -633,10 +633,6 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
633
633
|
);
|
|
634
634
|
}
|
|
635
635
|
async scheduled(controller) {
|
|
636
|
-
if (controller.cron === this.env.CRON_PAYMENTS_PROCESSING) {
|
|
637
|
-
console.log("Scheduled CRON payments processing");
|
|
638
|
-
await this.syncAccounts();
|
|
639
|
-
}
|
|
640
636
|
if (controller.cron === this.env.CRON_BATCH_STATUSES) {
|
|
641
637
|
console.log("Scheduled CRON batch statuses");
|
|
642
638
|
await this.updateBatchStatuses();
|
package/dist/export/worker.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { w as BankWorkflows } from '../shared/bank.
|
|
1
|
+
export { w as BankWorkflows } from '../shared/bank.ChAGzUFo.cjs';
|
|
2
2
|
import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
|
|
3
3
|
import { WorkflowInstanceStatus, IRPCResponse } from '@develit-io/backend-sdk';
|
|
4
4
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
5
5
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
6
|
-
import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as PaymentInsertType } from '../shared/bank.
|
|
7
|
-
import { A as AccountSelectType, C as ConfigEnvironmentBank, I as IBankConnector, a as ConnectorKey } from '../shared/bank.
|
|
6
|
+
import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as PaymentInsertType } from '../shared/bank.BFGDv0oC.cjs';
|
|
7
|
+
import { A as AccountSelectType, C as ConfigEnvironmentBank, I as IBankConnector, a as ConnectorKey } from '../shared/bank.DSVzOCrh.cjs';
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
import * as drizzle_zod from 'drizzle-zod';
|
|
10
10
|
import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
|
|
@@ -1539,21 +1539,21 @@ declare const getBatchesInputSchema: z.ZodObject<{
|
|
|
1539
1539
|
}, z.core.$strip>;
|
|
1540
1540
|
filterBatchAccountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodUUID, z.ZodArray<z.ZodUUID>]>>;
|
|
1541
1541
|
filterBatchStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
1542
|
-
PREPARED: "PREPARED";
|
|
1543
|
-
FAILED: "FAILED";
|
|
1544
|
-
COMPLETED: "COMPLETED";
|
|
1545
1542
|
OPEN: "OPEN";
|
|
1546
1543
|
PROCESSING: "PROCESSING";
|
|
1547
1544
|
READY_TO_SIGN: "READY_TO_SIGN";
|
|
1548
1545
|
WAITING_FOR_PROCESSING: "WAITING_FOR_PROCESSING";
|
|
1549
|
-
}>, z.ZodArray<z.ZodEnum<{
|
|
1550
1546
|
PREPARED: "PREPARED";
|
|
1551
|
-
FAILED: "FAILED";
|
|
1552
1547
|
COMPLETED: "COMPLETED";
|
|
1548
|
+
FAILED: "FAILED";
|
|
1549
|
+
}>, z.ZodArray<z.ZodEnum<{
|
|
1553
1550
|
OPEN: "OPEN";
|
|
1554
1551
|
PROCESSING: "PROCESSING";
|
|
1555
1552
|
READY_TO_SIGN: "READY_TO_SIGN";
|
|
1556
1553
|
WAITING_FOR_PROCESSING: "WAITING_FOR_PROCESSING";
|
|
1554
|
+
PREPARED: "PREPARED";
|
|
1555
|
+
COMPLETED: "COMPLETED";
|
|
1556
|
+
FAILED: "FAILED";
|
|
1557
1557
|
}>>]>>;
|
|
1558
1558
|
}, z.core.$strip>;
|
|
1559
1559
|
type GetBatchesInput = z.input<typeof getBatchesInputSchema>;
|
|
@@ -1713,17 +1713,17 @@ declare const getPaymentsInputSchema: z.ZodObject<{
|
|
|
1713
1713
|
filterPaymentDateTo: z.ZodOptional<z.ZodDate>;
|
|
1714
1714
|
filterPaymentStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
1715
1715
|
PREPARED: "PREPARED";
|
|
1716
|
-
|
|
1716
|
+
COMPLETED: "COMPLETED";
|
|
1717
1717
|
FAILED: "FAILED";
|
|
1718
|
+
INITIALIZED: "INITIALIZED";
|
|
1718
1719
|
PENDING: "PENDING";
|
|
1719
|
-
COMPLETED: "COMPLETED";
|
|
1720
1720
|
CREATED: "CREATED";
|
|
1721
1721
|
}>, z.ZodArray<z.ZodEnum<{
|
|
1722
1722
|
PREPARED: "PREPARED";
|
|
1723
|
-
|
|
1723
|
+
COMPLETED: "COMPLETED";
|
|
1724
1724
|
FAILED: "FAILED";
|
|
1725
|
+
INITIALIZED: "INITIALIZED";
|
|
1725
1726
|
PENDING: "PENDING";
|
|
1726
|
-
COMPLETED: "COMPLETED";
|
|
1727
1727
|
CREATED: "CREATED";
|
|
1728
1728
|
}>>]>>;
|
|
1729
1729
|
}, z.core.$strip>;
|
|
@@ -2334,14 +2334,14 @@ declare class BankServiceBase extends BankServiceBase_base {
|
|
|
2334
2334
|
addPaymentsToBatch({ paymentsToBatch, }: {
|
|
2335
2335
|
paymentsToBatch: SendPaymentInput[];
|
|
2336
2336
|
}): Promise<IRPCResponse<{
|
|
2337
|
+
status: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED" | null;
|
|
2337
2338
|
id: string;
|
|
2338
2339
|
createdAt: Date | null;
|
|
2339
2340
|
updatedAt: Date | null;
|
|
2340
2341
|
deletedAt: Date | null;
|
|
2341
|
-
|
|
2342
|
+
accountId: string | null;
|
|
2342
2343
|
batchPaymentInitiatedAt: Date | null;
|
|
2343
2344
|
authorizationUrls: string | string[] | null;
|
|
2344
|
-
accountId: string | null;
|
|
2345
2345
|
payments: PaymentInsertType[];
|
|
2346
2346
|
metadata: object | null;
|
|
2347
2347
|
}[] | undefined>>;
|
package/dist/export/worker.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { w as BankWorkflows } from '../shared/bank.
|
|
1
|
+
export { w as BankWorkflows } from '../shared/bank.ChAGzUFo.mjs';
|
|
2
2
|
import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
|
|
3
3
|
import { WorkflowInstanceStatus, IRPCResponse } from '@develit-io/backend-sdk';
|
|
4
4
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
5
5
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
6
|
-
import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as PaymentInsertType } from '../shared/bank.
|
|
7
|
-
import { A as AccountSelectType, C as ConfigEnvironmentBank, I as IBankConnector, a as ConnectorKey } from '../shared/bank.
|
|
6
|
+
import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as PaymentInsertType } from '../shared/bank.BFGDv0oC.mjs';
|
|
7
|
+
import { A as AccountSelectType, C as ConfigEnvironmentBank, I as IBankConnector, a as ConnectorKey } from '../shared/bank.CrRs_x0N.mjs';
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
import * as drizzle_zod from 'drizzle-zod';
|
|
10
10
|
import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
|
|
@@ -1539,21 +1539,21 @@ declare const getBatchesInputSchema: z.ZodObject<{
|
|
|
1539
1539
|
}, z.core.$strip>;
|
|
1540
1540
|
filterBatchAccountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodUUID, z.ZodArray<z.ZodUUID>]>>;
|
|
1541
1541
|
filterBatchStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
1542
|
-
PREPARED: "PREPARED";
|
|
1543
|
-
FAILED: "FAILED";
|
|
1544
|
-
COMPLETED: "COMPLETED";
|
|
1545
1542
|
OPEN: "OPEN";
|
|
1546
1543
|
PROCESSING: "PROCESSING";
|
|
1547
1544
|
READY_TO_SIGN: "READY_TO_SIGN";
|
|
1548
1545
|
WAITING_FOR_PROCESSING: "WAITING_FOR_PROCESSING";
|
|
1549
|
-
}>, z.ZodArray<z.ZodEnum<{
|
|
1550
1546
|
PREPARED: "PREPARED";
|
|
1551
|
-
FAILED: "FAILED";
|
|
1552
1547
|
COMPLETED: "COMPLETED";
|
|
1548
|
+
FAILED: "FAILED";
|
|
1549
|
+
}>, z.ZodArray<z.ZodEnum<{
|
|
1553
1550
|
OPEN: "OPEN";
|
|
1554
1551
|
PROCESSING: "PROCESSING";
|
|
1555
1552
|
READY_TO_SIGN: "READY_TO_SIGN";
|
|
1556
1553
|
WAITING_FOR_PROCESSING: "WAITING_FOR_PROCESSING";
|
|
1554
|
+
PREPARED: "PREPARED";
|
|
1555
|
+
COMPLETED: "COMPLETED";
|
|
1556
|
+
FAILED: "FAILED";
|
|
1557
1557
|
}>>]>>;
|
|
1558
1558
|
}, z.core.$strip>;
|
|
1559
1559
|
type GetBatchesInput = z.input<typeof getBatchesInputSchema>;
|
|
@@ -1713,17 +1713,17 @@ declare const getPaymentsInputSchema: z.ZodObject<{
|
|
|
1713
1713
|
filterPaymentDateTo: z.ZodOptional<z.ZodDate>;
|
|
1714
1714
|
filterPaymentStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
1715
1715
|
PREPARED: "PREPARED";
|
|
1716
|
-
|
|
1716
|
+
COMPLETED: "COMPLETED";
|
|
1717
1717
|
FAILED: "FAILED";
|
|
1718
|
+
INITIALIZED: "INITIALIZED";
|
|
1718
1719
|
PENDING: "PENDING";
|
|
1719
|
-
COMPLETED: "COMPLETED";
|
|
1720
1720
|
CREATED: "CREATED";
|
|
1721
1721
|
}>, z.ZodArray<z.ZodEnum<{
|
|
1722
1722
|
PREPARED: "PREPARED";
|
|
1723
|
-
|
|
1723
|
+
COMPLETED: "COMPLETED";
|
|
1724
1724
|
FAILED: "FAILED";
|
|
1725
|
+
INITIALIZED: "INITIALIZED";
|
|
1725
1726
|
PENDING: "PENDING";
|
|
1726
|
-
COMPLETED: "COMPLETED";
|
|
1727
1727
|
CREATED: "CREATED";
|
|
1728
1728
|
}>>]>>;
|
|
1729
1729
|
}, z.core.$strip>;
|
|
@@ -2334,14 +2334,14 @@ declare class BankServiceBase extends BankServiceBase_base {
|
|
|
2334
2334
|
addPaymentsToBatch({ paymentsToBatch, }: {
|
|
2335
2335
|
paymentsToBatch: SendPaymentInput[];
|
|
2336
2336
|
}): Promise<IRPCResponse<{
|
|
2337
|
+
status: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED" | null;
|
|
2337
2338
|
id: string;
|
|
2338
2339
|
createdAt: Date | null;
|
|
2339
2340
|
updatedAt: Date | null;
|
|
2340
2341
|
deletedAt: Date | null;
|
|
2341
|
-
|
|
2342
|
+
accountId: string | null;
|
|
2342
2343
|
batchPaymentInitiatedAt: Date | null;
|
|
2343
2344
|
authorizationUrls: string | string[] | null;
|
|
2344
|
-
accountId: string | null;
|
|
2345
2345
|
payments: PaymentInsertType[];
|
|
2346
2346
|
metadata: object | null;
|
|
2347
2347
|
}[] | undefined>>;
|
package/dist/export/worker.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { w as BankWorkflows } from '../shared/bank.
|
|
1
|
+
export { w as BankWorkflows } from '../shared/bank.ChAGzUFo.js';
|
|
2
2
|
import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
|
|
3
3
|
import { WorkflowInstanceStatus, IRPCResponse } from '@develit-io/backend-sdk';
|
|
4
4
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
5
5
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
6
|
-
import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as PaymentInsertType } from '../shared/bank.
|
|
7
|
-
import { A as AccountSelectType, C as ConfigEnvironmentBank, I as IBankConnector, a as ConnectorKey } from '../shared/bank.
|
|
6
|
+
import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as PaymentInsertType } from '../shared/bank.BFGDv0oC.js';
|
|
7
|
+
import { A as AccountSelectType, C as ConfigEnvironmentBank, I as IBankConnector, a as ConnectorKey } from '../shared/bank.DCTBX1dp.js';
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
import * as drizzle_zod from 'drizzle-zod';
|
|
10
10
|
import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
|
|
@@ -1539,21 +1539,21 @@ declare const getBatchesInputSchema: z.ZodObject<{
|
|
|
1539
1539
|
}, z.core.$strip>;
|
|
1540
1540
|
filterBatchAccountId: z.ZodOptional<z.ZodUnion<readonly [z.ZodUUID, z.ZodArray<z.ZodUUID>]>>;
|
|
1541
1541
|
filterBatchStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
1542
|
-
PREPARED: "PREPARED";
|
|
1543
|
-
FAILED: "FAILED";
|
|
1544
|
-
COMPLETED: "COMPLETED";
|
|
1545
1542
|
OPEN: "OPEN";
|
|
1546
1543
|
PROCESSING: "PROCESSING";
|
|
1547
1544
|
READY_TO_SIGN: "READY_TO_SIGN";
|
|
1548
1545
|
WAITING_FOR_PROCESSING: "WAITING_FOR_PROCESSING";
|
|
1549
|
-
}>, z.ZodArray<z.ZodEnum<{
|
|
1550
1546
|
PREPARED: "PREPARED";
|
|
1551
|
-
FAILED: "FAILED";
|
|
1552
1547
|
COMPLETED: "COMPLETED";
|
|
1548
|
+
FAILED: "FAILED";
|
|
1549
|
+
}>, z.ZodArray<z.ZodEnum<{
|
|
1553
1550
|
OPEN: "OPEN";
|
|
1554
1551
|
PROCESSING: "PROCESSING";
|
|
1555
1552
|
READY_TO_SIGN: "READY_TO_SIGN";
|
|
1556
1553
|
WAITING_FOR_PROCESSING: "WAITING_FOR_PROCESSING";
|
|
1554
|
+
PREPARED: "PREPARED";
|
|
1555
|
+
COMPLETED: "COMPLETED";
|
|
1556
|
+
FAILED: "FAILED";
|
|
1557
1557
|
}>>]>>;
|
|
1558
1558
|
}, z.core.$strip>;
|
|
1559
1559
|
type GetBatchesInput = z.input<typeof getBatchesInputSchema>;
|
|
@@ -1713,17 +1713,17 @@ declare const getPaymentsInputSchema: z.ZodObject<{
|
|
|
1713
1713
|
filterPaymentDateTo: z.ZodOptional<z.ZodDate>;
|
|
1714
1714
|
filterPaymentStatus: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
1715
1715
|
PREPARED: "PREPARED";
|
|
1716
|
-
|
|
1716
|
+
COMPLETED: "COMPLETED";
|
|
1717
1717
|
FAILED: "FAILED";
|
|
1718
|
+
INITIALIZED: "INITIALIZED";
|
|
1718
1719
|
PENDING: "PENDING";
|
|
1719
|
-
COMPLETED: "COMPLETED";
|
|
1720
1720
|
CREATED: "CREATED";
|
|
1721
1721
|
}>, z.ZodArray<z.ZodEnum<{
|
|
1722
1722
|
PREPARED: "PREPARED";
|
|
1723
|
-
|
|
1723
|
+
COMPLETED: "COMPLETED";
|
|
1724
1724
|
FAILED: "FAILED";
|
|
1725
|
+
INITIALIZED: "INITIALIZED";
|
|
1725
1726
|
PENDING: "PENDING";
|
|
1726
|
-
COMPLETED: "COMPLETED";
|
|
1727
1727
|
CREATED: "CREATED";
|
|
1728
1728
|
}>>]>>;
|
|
1729
1729
|
}, z.core.$strip>;
|
|
@@ -2334,14 +2334,14 @@ declare class BankServiceBase extends BankServiceBase_base {
|
|
|
2334
2334
|
addPaymentsToBatch({ paymentsToBatch, }: {
|
|
2335
2335
|
paymentsToBatch: SendPaymentInput[];
|
|
2336
2336
|
}): Promise<IRPCResponse<{
|
|
2337
|
+
status: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED" | null;
|
|
2337
2338
|
id: string;
|
|
2338
2339
|
createdAt: Date | null;
|
|
2339
2340
|
updatedAt: Date | null;
|
|
2340
2341
|
deletedAt: Date | null;
|
|
2341
|
-
|
|
2342
|
+
accountId: string | null;
|
|
2342
2343
|
batchPaymentInitiatedAt: Date | null;
|
|
2343
2344
|
authorizationUrls: string | string[] | null;
|
|
2344
|
-
accountId: string | null;
|
|
2345
2345
|
payments: PaymentInsertType[];
|
|
2346
2346
|
metadata: object | null;
|
|
2347
2347
|
}[] | undefined>>;
|
package/dist/export/worker.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as getPaymentsByBankRefIdsQuery, u as updatePaymentCommand, c as createPaymentCommand, a as updateAccountLastSyncCommand, b as getCredentialsByAccountId, i as initiateConnector } from '../shared/bank.
|
|
2
|
-
export { w as BankWorkflows } from '../shared/bank.
|
|
1
|
+
import { g as getPaymentsByBankRefIdsQuery, u as updatePaymentCommand, c as createPaymentCommand, a as updateAccountLastSyncCommand, b as getCredentialsByAccountId, i as initiateConnector } from '../shared/bank.JtGSu6eH.mjs';
|
|
2
|
+
export { w as BankWorkflows } from '../shared/bank.JtGSu6eH.mjs';
|
|
3
3
|
import { uuidv4, bankAccountMetadataSchema, workflowInstanceStatusSchema, develitWorker, createInternalError, first, action, service } from '@develit-io/backend-sdk';
|
|
4
4
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
5
5
|
import { drizzle } from 'drizzle-orm/d1';
|
|
@@ -632,10 +632,6 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
632
632
|
);
|
|
633
633
|
}
|
|
634
634
|
async scheduled(controller) {
|
|
635
|
-
if (controller.cron === this.env.CRON_PAYMENTS_PROCESSING) {
|
|
636
|
-
console.log("Scheduled CRON payments processing");
|
|
637
|
-
await this.syncAccounts();
|
|
638
|
-
}
|
|
639
635
|
if (controller.cron === this.env.CRON_BATCH_STATUSES) {
|
|
640
636
|
console.log("Scheduled CRON batch statuses");
|
|
641
637
|
await this.updateBatchStatuses();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { S as SyncAccountPaymentsWorkflow } from '../shared/bank.
|
|
1
|
+
export { S as SyncAccountPaymentsWorkflow } from '../shared/bank.ChAGzUFo.cjs';
|
|
2
2
|
import 'cloudflare:workers';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { S as SyncAccountPaymentsWorkflow } from '../shared/bank.
|
|
1
|
+
export { S as SyncAccountPaymentsWorkflow } from '../shared/bank.ChAGzUFo.mjs';
|
|
2
2
|
import 'cloudflare:workers';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { S as SyncAccountPaymentsWorkflow } from '../shared/bank.
|
|
1
|
+
export { S as SyncAccountPaymentsWorkflow } from '../shared/bank.ChAGzUFo.js';
|
|
2
2
|
import 'cloudflare:workers';
|
|
@@ -142,9 +142,7 @@ class SyncAccountPaymentsWorkflow extends cloudflare_workers.WorkflowEntrypoint
|
|
|
142
142
|
return account2;
|
|
143
143
|
});
|
|
144
144
|
if (!account.lastSyncedAt) {
|
|
145
|
-
throw new
|
|
146
|
-
`lastSyncedAt is not set for account: ${accountId}`
|
|
147
|
-
);
|
|
145
|
+
throw new Error(`lastSyncedAt is not set for account: ${accountId}`);
|
|
148
146
|
}
|
|
149
147
|
const credentials = await step.do(
|
|
150
148
|
"load account credentials",
|
|
@@ -165,7 +163,6 @@ class SyncAccountPaymentsWorkflow extends cloudflare_workers.WorkflowEntrypoint
|
|
|
165
163
|
timeout: "30 seconds"
|
|
166
164
|
},
|
|
167
165
|
async () => {
|
|
168
|
-
console.log("starting connector initiation");
|
|
169
166
|
const connector = initiateConnector({
|
|
170
167
|
env: this.env,
|
|
171
168
|
bank: account.connectorKey,
|
|
@@ -177,7 +174,6 @@ class SyncAccountPaymentsWorkflow extends cloudflare_workers.WorkflowEntrypoint
|
|
|
177
174
|
}
|
|
178
175
|
]
|
|
179
176
|
});
|
|
180
|
-
console.log("fetching payments from connector");
|
|
181
177
|
const fetched = await connector.getAllAccountPayments({
|
|
182
178
|
environment: this.env.ENVIRONMENT,
|
|
183
179
|
db,
|
|
@@ -190,84 +186,81 @@ class SyncAccountPaymentsWorkflow extends cloudflare_workers.WorkflowEntrypoint
|
|
|
190
186
|
}));
|
|
191
187
|
}
|
|
192
188
|
);
|
|
193
|
-
if (payments.length
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return await getPaymentsByBankRefIdsQuery(db, {
|
|
200
|
-
ids: bankRefIds
|
|
189
|
+
if (payments.length) {
|
|
190
|
+
const bankRefIds = payments.map((payment) => payment.bankRefId).filter(Boolean);
|
|
191
|
+
const existing = await step.do("load existing payments", async () => {
|
|
192
|
+
return await getPaymentsByBankRefIdsQuery(db, {
|
|
193
|
+
ids: bankRefIds
|
|
194
|
+
});
|
|
201
195
|
});
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
(p) => existing.some((e) => e.bankRefId === p.bankRefId)
|
|
205
|
-
);
|
|
206
|
-
const paymentsToCreate = payments.filter(
|
|
207
|
-
(p) => !existing.some((e) => e.bankRefId === p.bankRefId)
|
|
208
|
-
);
|
|
209
|
-
await step.do("process payments and update lastSyncAt", async () => {
|
|
210
|
-
const eventsToEmit = [];
|
|
211
|
-
console.log("process payments and update lastSyncAt");
|
|
212
|
-
const updateCommands = paymentsToUpdate.map(
|
|
213
|
-
(p) => updatePaymentCommand(db, { payment: p }).command
|
|
214
|
-
);
|
|
215
|
-
eventsToEmit.push(
|
|
216
|
-
...paymentsToUpdate.map((p) => ({
|
|
217
|
-
eventType: "BANK_PAYMENT",
|
|
218
|
-
eventSignal: "paymentUpdated",
|
|
219
|
-
bankPayment: p,
|
|
220
|
-
metadata: {
|
|
221
|
-
correlationId: p.correlationId,
|
|
222
|
-
entityId: p.id,
|
|
223
|
-
idempotencySuffix: p.status,
|
|
224
|
-
timestamp: (/* @__PURE__ */ new Date()).toDateString()
|
|
225
|
-
}
|
|
226
|
-
}))
|
|
227
|
-
);
|
|
228
|
-
const createCommands = paymentsToCreate.map(
|
|
229
|
-
(p) => createPaymentCommand(db, { payment: p }).command
|
|
196
|
+
const paymentsToUpdate = payments.filter(
|
|
197
|
+
(p) => existing.some((e) => e.bankRefId === p.bankRefId)
|
|
230
198
|
);
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
eventType: "BANK_PAYMENT",
|
|
234
|
-
eventSignal: "paymentCreated",
|
|
235
|
-
bankPayment: p,
|
|
236
|
-
metadata: {
|
|
237
|
-
correlationId: p.correlationId,
|
|
238
|
-
entityId: p.id,
|
|
239
|
-
timestamp: (/* @__PURE__ */ new Date()).toDateString()
|
|
240
|
-
}
|
|
241
|
-
}))
|
|
199
|
+
const paymentsToCreate = payments.filter(
|
|
200
|
+
(p) => !existing.some((e) => e.bankRefId === p.bankRefId)
|
|
242
201
|
);
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
accountId: account.id,
|
|
248
|
-
lastSyncedAt: latest.processedAt
|
|
249
|
-
}).command;
|
|
250
|
-
if (eventsToEmit.length) {
|
|
251
|
-
await db.batch(
|
|
252
|
-
backendSdk.asNonEmpty([
|
|
253
|
-
updateLastSyncCommand,
|
|
254
|
-
...updateCommands,
|
|
255
|
-
...createCommands
|
|
256
|
-
])
|
|
202
|
+
await step.do("process payments and update lastSyncAt", async () => {
|
|
203
|
+
const eventsToEmit = [];
|
|
204
|
+
const updateCommands = paymentsToUpdate.map(
|
|
205
|
+
(p) => updatePaymentCommand(db, { payment: p }).command
|
|
257
206
|
);
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
207
|
+
eventsToEmit.push(
|
|
208
|
+
...paymentsToUpdate.map((p) => ({
|
|
209
|
+
eventType: "BANK_PAYMENT",
|
|
210
|
+
eventSignal: "paymentUpdated",
|
|
211
|
+
bankPayment: p,
|
|
212
|
+
metadata: {
|
|
213
|
+
correlationId: p.correlationId,
|
|
214
|
+
entityId: p.id,
|
|
215
|
+
idempotencySuffix: p.status,
|
|
216
|
+
timestamp: (/* @__PURE__ */ new Date()).toDateString()
|
|
217
|
+
}
|
|
218
|
+
}))
|
|
261
219
|
);
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
220
|
+
const createCommands = paymentsToCreate.map(
|
|
221
|
+
(p) => createPaymentCommand(db, { payment: p }).command
|
|
222
|
+
);
|
|
223
|
+
eventsToEmit.push(
|
|
224
|
+
...paymentsToCreate.map((p) => ({
|
|
225
|
+
eventType: "BANK_PAYMENT",
|
|
226
|
+
eventSignal: "paymentCreated",
|
|
227
|
+
bankPayment: p,
|
|
228
|
+
metadata: {
|
|
229
|
+
correlationId: p.correlationId,
|
|
230
|
+
entityId: p.id,
|
|
231
|
+
timestamp: (/* @__PURE__ */ new Date()).toDateString()
|
|
232
|
+
}
|
|
233
|
+
}))
|
|
234
|
+
);
|
|
235
|
+
const latest = payments.reduce((current, p) => {
|
|
236
|
+
return new Date(p.processedAt).getTime() > new Date(current.processedAt).getTime() ? p : current;
|
|
237
|
+
}, payments[0]);
|
|
238
|
+
const updateLastSyncCommand = updateAccountLastSyncCommand(db, {
|
|
239
|
+
accountId: account.id,
|
|
240
|
+
lastSyncedAt: latest.processedAt
|
|
241
|
+
}).command;
|
|
242
|
+
if (eventsToEmit.length) {
|
|
243
|
+
await db.batch(
|
|
244
|
+
backendSdk.asNonEmpty([
|
|
245
|
+
updateLastSyncCommand,
|
|
246
|
+
...updateCommands,
|
|
247
|
+
...createCommands
|
|
248
|
+
])
|
|
249
|
+
);
|
|
250
|
+
await pushToQueue(
|
|
251
|
+
this.env.QUEUE_BUS_QUEUE,
|
|
252
|
+
eventsToEmit
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
return {
|
|
256
|
+
payments: payments.length,
|
|
257
|
+
updated: paymentsToUpdate.length,
|
|
258
|
+
created: paymentsToCreate.length,
|
|
259
|
+
eventsEmitted: eventsToEmit.length,
|
|
260
|
+
lastSyncedAt: latest?.createdAt
|
|
261
|
+
};
|
|
262
|
+
});
|
|
263
|
+
}
|
|
271
264
|
await step.sleep(
|
|
272
265
|
"Sleep for next sync",
|
|
273
266
|
`${account.syncIntervalS} seconds`
|
|
@@ -83,10 +83,10 @@ declare const paymentInsertTypeZod: z.ZodObject<{
|
|
|
83
83
|
}>;
|
|
84
84
|
status: z.ZodEnum<{
|
|
85
85
|
PREPARED: "PREPARED";
|
|
86
|
-
|
|
86
|
+
COMPLETED: "COMPLETED";
|
|
87
87
|
FAILED: "FAILED";
|
|
88
|
+
INITIALIZED: "INITIALIZED";
|
|
88
89
|
PENDING: "PENDING";
|
|
89
|
-
COMPLETED: "COMPLETED";
|
|
90
90
|
CREATED: "CREATED";
|
|
91
91
|
}>;
|
|
92
92
|
batchId: z.ZodString;
|
|
@@ -166,7 +166,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
166
166
|
tableName: "batch";
|
|
167
167
|
dataType: "string";
|
|
168
168
|
columnType: "SQLiteText";
|
|
169
|
-
data: "
|
|
169
|
+
data: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED";
|
|
170
170
|
driverParam: string;
|
|
171
171
|
notNull: false;
|
|
172
172
|
hasDefault: false;
|
|
@@ -179,7 +179,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
179
179
|
generated: undefined;
|
|
180
180
|
}, {}, {
|
|
181
181
|
length: number | undefined;
|
|
182
|
-
$type: "
|
|
182
|
+
$type: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED";
|
|
183
183
|
}>;
|
|
184
184
|
payments: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
185
185
|
name: "payments";
|
|
@@ -475,7 +475,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
475
475
|
tableName: "payment";
|
|
476
476
|
dataType: "string";
|
|
477
477
|
columnType: "SQLiteText";
|
|
478
|
-
data: "PREPARED" | "
|
|
478
|
+
data: "PREPARED" | "COMPLETED" | "FAILED" | "INITIALIZED" | "PENDING" | "CREATED";
|
|
479
479
|
driverParam: string;
|
|
480
480
|
notNull: true;
|
|
481
481
|
hasDefault: false;
|
|
@@ -488,7 +488,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
488
488
|
generated: undefined;
|
|
489
489
|
}, {}, {
|
|
490
490
|
length: number | undefined;
|
|
491
|
-
$type: "PREPARED" | "
|
|
491
|
+
$type: "PREPARED" | "COMPLETED" | "FAILED" | "INITIALIZED" | "PENDING" | "CREATED";
|
|
492
492
|
}>;
|
|
493
493
|
statusReason: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
494
494
|
name: "status_reason";
|
|
@@ -83,10 +83,10 @@ declare const paymentInsertTypeZod: z.ZodObject<{
|
|
|
83
83
|
}>;
|
|
84
84
|
status: z.ZodEnum<{
|
|
85
85
|
PREPARED: "PREPARED";
|
|
86
|
-
|
|
86
|
+
COMPLETED: "COMPLETED";
|
|
87
87
|
FAILED: "FAILED";
|
|
88
|
+
INITIALIZED: "INITIALIZED";
|
|
88
89
|
PENDING: "PENDING";
|
|
89
|
-
COMPLETED: "COMPLETED";
|
|
90
90
|
CREATED: "CREATED";
|
|
91
91
|
}>;
|
|
92
92
|
batchId: z.ZodString;
|
|
@@ -166,7 +166,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
166
166
|
tableName: "batch";
|
|
167
167
|
dataType: "string";
|
|
168
168
|
columnType: "SQLiteText";
|
|
169
|
-
data: "
|
|
169
|
+
data: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED";
|
|
170
170
|
driverParam: string;
|
|
171
171
|
notNull: false;
|
|
172
172
|
hasDefault: false;
|
|
@@ -179,7 +179,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
179
179
|
generated: undefined;
|
|
180
180
|
}, {}, {
|
|
181
181
|
length: number | undefined;
|
|
182
|
-
$type: "
|
|
182
|
+
$type: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED";
|
|
183
183
|
}>;
|
|
184
184
|
payments: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
185
185
|
name: "payments";
|
|
@@ -475,7 +475,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
475
475
|
tableName: "payment";
|
|
476
476
|
dataType: "string";
|
|
477
477
|
columnType: "SQLiteText";
|
|
478
|
-
data: "PREPARED" | "
|
|
478
|
+
data: "PREPARED" | "COMPLETED" | "FAILED" | "INITIALIZED" | "PENDING" | "CREATED";
|
|
479
479
|
driverParam: string;
|
|
480
480
|
notNull: true;
|
|
481
481
|
hasDefault: false;
|
|
@@ -488,7 +488,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
488
488
|
generated: undefined;
|
|
489
489
|
}, {}, {
|
|
490
490
|
length: number | undefined;
|
|
491
|
-
$type: "PREPARED" | "
|
|
491
|
+
$type: "PREPARED" | "COMPLETED" | "FAILED" | "INITIALIZED" | "PENDING" | "CREATED";
|
|
492
492
|
}>;
|
|
493
493
|
statusReason: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
494
494
|
name: "status_reason";
|
|
@@ -83,10 +83,10 @@ declare const paymentInsertTypeZod: z.ZodObject<{
|
|
|
83
83
|
}>;
|
|
84
84
|
status: z.ZodEnum<{
|
|
85
85
|
PREPARED: "PREPARED";
|
|
86
|
-
|
|
86
|
+
COMPLETED: "COMPLETED";
|
|
87
87
|
FAILED: "FAILED";
|
|
88
|
+
INITIALIZED: "INITIALIZED";
|
|
88
89
|
PENDING: "PENDING";
|
|
89
|
-
COMPLETED: "COMPLETED";
|
|
90
90
|
CREATED: "CREATED";
|
|
91
91
|
}>;
|
|
92
92
|
batchId: z.ZodString;
|
|
@@ -166,7 +166,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
166
166
|
tableName: "batch";
|
|
167
167
|
dataType: "string";
|
|
168
168
|
columnType: "SQLiteText";
|
|
169
|
-
data: "
|
|
169
|
+
data: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED";
|
|
170
170
|
driverParam: string;
|
|
171
171
|
notNull: false;
|
|
172
172
|
hasDefault: false;
|
|
@@ -179,7 +179,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
179
179
|
generated: undefined;
|
|
180
180
|
}, {}, {
|
|
181
181
|
length: number | undefined;
|
|
182
|
-
$type: "
|
|
182
|
+
$type: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED";
|
|
183
183
|
}>;
|
|
184
184
|
payments: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
185
185
|
name: "payments";
|
|
@@ -475,7 +475,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
475
475
|
tableName: "payment";
|
|
476
476
|
dataType: "string";
|
|
477
477
|
columnType: "SQLiteText";
|
|
478
|
-
data: "PREPARED" | "
|
|
478
|
+
data: "PREPARED" | "COMPLETED" | "FAILED" | "INITIALIZED" | "PENDING" | "CREATED";
|
|
479
479
|
driverParam: string;
|
|
480
480
|
notNull: true;
|
|
481
481
|
hasDefault: false;
|
|
@@ -488,7 +488,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
488
488
|
generated: undefined;
|
|
489
489
|
}, {}, {
|
|
490
490
|
length: number | undefined;
|
|
491
|
-
$type: "PREPARED" | "
|
|
491
|
+
$type: "PREPARED" | "COMPLETED" | "FAILED" | "INITIALIZED" | "PENDING" | "CREATED";
|
|
492
492
|
}>;
|
|
493
493
|
statusReason: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
494
494
|
name: "status_reason";
|
|
@@ -4,9 +4,7 @@ type Params = {
|
|
|
4
4
|
accountId: string;
|
|
5
5
|
};
|
|
6
6
|
declare class SyncAccountPaymentsWorkflow extends WorkflowEntrypoint<BankEnv, Params> {
|
|
7
|
-
run(event: WorkflowEvent<Params>, step: WorkflowStep): Promise<
|
|
8
|
-
status: string;
|
|
9
|
-
}>;
|
|
7
|
+
run(event: WorkflowEvent<Params>, step: WorkflowStep): Promise<void>;
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
type workflows_SyncAccountPaymentsWorkflow = SyncAccountPaymentsWorkflow;
|
|
@@ -4,9 +4,7 @@ type Params = {
|
|
|
4
4
|
accountId: string;
|
|
5
5
|
};
|
|
6
6
|
declare class SyncAccountPaymentsWorkflow extends WorkflowEntrypoint<BankEnv, Params> {
|
|
7
|
-
run(event: WorkflowEvent<Params>, step: WorkflowStep): Promise<
|
|
8
|
-
status: string;
|
|
9
|
-
}>;
|
|
7
|
+
run(event: WorkflowEvent<Params>, step: WorkflowStep): Promise<void>;
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
type workflows_SyncAccountPaymentsWorkflow = SyncAccountPaymentsWorkflow;
|
|
@@ -4,9 +4,7 @@ type Params = {
|
|
|
4
4
|
accountId: string;
|
|
5
5
|
};
|
|
6
6
|
declare class SyncAccountPaymentsWorkflow extends WorkflowEntrypoint<BankEnv, Params> {
|
|
7
|
-
run(event: WorkflowEvent<Params>, step: WorkflowStep): Promise<
|
|
8
|
-
status: string;
|
|
9
|
-
}>;
|
|
7
|
+
run(event: WorkflowEvent<Params>, step: WorkflowStep): Promise<void>;
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
type workflows_SyncAccountPaymentsWorkflow = SyncAccountPaymentsWorkflow;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Environment } from '@develit-io/backend-sdk';
|
|
2
2
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
3
|
-
import { a as PaymentInsertType, t as tables } from './bank.
|
|
3
|
+
import { a as PaymentInsertType, t as tables } from './bank.BFGDv0oC.mjs';
|
|
4
4
|
import { CURRENCY_CODES, BANK_CODES, CODES } from '@develit-io/general-codes';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import * as drizzle_zod from 'drizzle-zod';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Environment } from '@develit-io/backend-sdk';
|
|
2
2
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
3
|
-
import { a as PaymentInsertType, t as tables } from './bank.
|
|
3
|
+
import { a as PaymentInsertType, t as tables } from './bank.BFGDv0oC.js';
|
|
4
4
|
import { CURRENCY_CODES, BANK_CODES, CODES } from '@develit-io/general-codes';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import * as drizzle_zod from 'drizzle-zod';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Environment } from '@develit-io/backend-sdk';
|
|
2
2
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
3
|
-
import { a as PaymentInsertType, t as tables } from './bank.
|
|
3
|
+
import { a as PaymentInsertType, t as tables } from './bank.BFGDv0oC.cjs';
|
|
4
4
|
import { CURRENCY_CODES, BANK_CODES, CODES } from '@develit-io/general-codes';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import * as drizzle_zod from 'drizzle-zod';
|
|
@@ -140,9 +140,7 @@ class SyncAccountPaymentsWorkflow extends WorkflowEntrypoint {
|
|
|
140
140
|
return account2;
|
|
141
141
|
});
|
|
142
142
|
if (!account.lastSyncedAt) {
|
|
143
|
-
throw new
|
|
144
|
-
`lastSyncedAt is not set for account: ${accountId}`
|
|
145
|
-
);
|
|
143
|
+
throw new Error(`lastSyncedAt is not set for account: ${accountId}`);
|
|
146
144
|
}
|
|
147
145
|
const credentials = await step.do(
|
|
148
146
|
"load account credentials",
|
|
@@ -163,7 +161,6 @@ class SyncAccountPaymentsWorkflow extends WorkflowEntrypoint {
|
|
|
163
161
|
timeout: "30 seconds"
|
|
164
162
|
},
|
|
165
163
|
async () => {
|
|
166
|
-
console.log("starting connector initiation");
|
|
167
164
|
const connector = initiateConnector({
|
|
168
165
|
env: this.env,
|
|
169
166
|
bank: account.connectorKey,
|
|
@@ -175,7 +172,6 @@ class SyncAccountPaymentsWorkflow extends WorkflowEntrypoint {
|
|
|
175
172
|
}
|
|
176
173
|
]
|
|
177
174
|
});
|
|
178
|
-
console.log("fetching payments from connector");
|
|
179
175
|
const fetched = await connector.getAllAccountPayments({
|
|
180
176
|
environment: this.env.ENVIRONMENT,
|
|
181
177
|
db,
|
|
@@ -188,84 +184,81 @@ class SyncAccountPaymentsWorkflow extends WorkflowEntrypoint {
|
|
|
188
184
|
}));
|
|
189
185
|
}
|
|
190
186
|
);
|
|
191
|
-
if (payments.length
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
return await getPaymentsByBankRefIdsQuery(db, {
|
|
198
|
-
ids: bankRefIds
|
|
187
|
+
if (payments.length) {
|
|
188
|
+
const bankRefIds = payments.map((payment) => payment.bankRefId).filter(Boolean);
|
|
189
|
+
const existing = await step.do("load existing payments", async () => {
|
|
190
|
+
return await getPaymentsByBankRefIdsQuery(db, {
|
|
191
|
+
ids: bankRefIds
|
|
192
|
+
});
|
|
199
193
|
});
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
(p) => existing.some((e) => e.bankRefId === p.bankRefId)
|
|
203
|
-
);
|
|
204
|
-
const paymentsToCreate = payments.filter(
|
|
205
|
-
(p) => !existing.some((e) => e.bankRefId === p.bankRefId)
|
|
206
|
-
);
|
|
207
|
-
await step.do("process payments and update lastSyncAt", async () => {
|
|
208
|
-
const eventsToEmit = [];
|
|
209
|
-
console.log("process payments and update lastSyncAt");
|
|
210
|
-
const updateCommands = paymentsToUpdate.map(
|
|
211
|
-
(p) => updatePaymentCommand(db, { payment: p }).command
|
|
212
|
-
);
|
|
213
|
-
eventsToEmit.push(
|
|
214
|
-
...paymentsToUpdate.map((p) => ({
|
|
215
|
-
eventType: "BANK_PAYMENT",
|
|
216
|
-
eventSignal: "paymentUpdated",
|
|
217
|
-
bankPayment: p,
|
|
218
|
-
metadata: {
|
|
219
|
-
correlationId: p.correlationId,
|
|
220
|
-
entityId: p.id,
|
|
221
|
-
idempotencySuffix: p.status,
|
|
222
|
-
timestamp: (/* @__PURE__ */ new Date()).toDateString()
|
|
223
|
-
}
|
|
224
|
-
}))
|
|
225
|
-
);
|
|
226
|
-
const createCommands = paymentsToCreate.map(
|
|
227
|
-
(p) => createPaymentCommand(db, { payment: p }).command
|
|
194
|
+
const paymentsToUpdate = payments.filter(
|
|
195
|
+
(p) => existing.some((e) => e.bankRefId === p.bankRefId)
|
|
228
196
|
);
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
eventType: "BANK_PAYMENT",
|
|
232
|
-
eventSignal: "paymentCreated",
|
|
233
|
-
bankPayment: p,
|
|
234
|
-
metadata: {
|
|
235
|
-
correlationId: p.correlationId,
|
|
236
|
-
entityId: p.id,
|
|
237
|
-
timestamp: (/* @__PURE__ */ new Date()).toDateString()
|
|
238
|
-
}
|
|
239
|
-
}))
|
|
197
|
+
const paymentsToCreate = payments.filter(
|
|
198
|
+
(p) => !existing.some((e) => e.bankRefId === p.bankRefId)
|
|
240
199
|
);
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
accountId: account.id,
|
|
246
|
-
lastSyncedAt: latest.processedAt
|
|
247
|
-
}).command;
|
|
248
|
-
if (eventsToEmit.length) {
|
|
249
|
-
await db.batch(
|
|
250
|
-
asNonEmpty([
|
|
251
|
-
updateLastSyncCommand,
|
|
252
|
-
...updateCommands,
|
|
253
|
-
...createCommands
|
|
254
|
-
])
|
|
200
|
+
await step.do("process payments and update lastSyncAt", async () => {
|
|
201
|
+
const eventsToEmit = [];
|
|
202
|
+
const updateCommands = paymentsToUpdate.map(
|
|
203
|
+
(p) => updatePaymentCommand(db, { payment: p }).command
|
|
255
204
|
);
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
205
|
+
eventsToEmit.push(
|
|
206
|
+
...paymentsToUpdate.map((p) => ({
|
|
207
|
+
eventType: "BANK_PAYMENT",
|
|
208
|
+
eventSignal: "paymentUpdated",
|
|
209
|
+
bankPayment: p,
|
|
210
|
+
metadata: {
|
|
211
|
+
correlationId: p.correlationId,
|
|
212
|
+
entityId: p.id,
|
|
213
|
+
idempotencySuffix: p.status,
|
|
214
|
+
timestamp: (/* @__PURE__ */ new Date()).toDateString()
|
|
215
|
+
}
|
|
216
|
+
}))
|
|
259
217
|
);
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
218
|
+
const createCommands = paymentsToCreate.map(
|
|
219
|
+
(p) => createPaymentCommand(db, { payment: p }).command
|
|
220
|
+
);
|
|
221
|
+
eventsToEmit.push(
|
|
222
|
+
...paymentsToCreate.map((p) => ({
|
|
223
|
+
eventType: "BANK_PAYMENT",
|
|
224
|
+
eventSignal: "paymentCreated",
|
|
225
|
+
bankPayment: p,
|
|
226
|
+
metadata: {
|
|
227
|
+
correlationId: p.correlationId,
|
|
228
|
+
entityId: p.id,
|
|
229
|
+
timestamp: (/* @__PURE__ */ new Date()).toDateString()
|
|
230
|
+
}
|
|
231
|
+
}))
|
|
232
|
+
);
|
|
233
|
+
const latest = payments.reduce((current, p) => {
|
|
234
|
+
return new Date(p.processedAt).getTime() > new Date(current.processedAt).getTime() ? p : current;
|
|
235
|
+
}, payments[0]);
|
|
236
|
+
const updateLastSyncCommand = updateAccountLastSyncCommand(db, {
|
|
237
|
+
accountId: account.id,
|
|
238
|
+
lastSyncedAt: latest.processedAt
|
|
239
|
+
}).command;
|
|
240
|
+
if (eventsToEmit.length) {
|
|
241
|
+
await db.batch(
|
|
242
|
+
asNonEmpty([
|
|
243
|
+
updateLastSyncCommand,
|
|
244
|
+
...updateCommands,
|
|
245
|
+
...createCommands
|
|
246
|
+
])
|
|
247
|
+
);
|
|
248
|
+
await pushToQueue(
|
|
249
|
+
this.env.QUEUE_BUS_QUEUE,
|
|
250
|
+
eventsToEmit
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
return {
|
|
254
|
+
payments: payments.length,
|
|
255
|
+
updated: paymentsToUpdate.length,
|
|
256
|
+
created: paymentsToCreate.length,
|
|
257
|
+
eventsEmitted: eventsToEmit.length,
|
|
258
|
+
lastSyncedAt: latest?.createdAt
|
|
259
|
+
};
|
|
260
|
+
});
|
|
261
|
+
}
|
|
269
262
|
await step.sleep(
|
|
270
263
|
"Sleep for next sync",
|
|
271
264
|
`${account.syncIntervalS} seconds`
|
package/dist/types.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { I as IBankConnector, b as IncomingPaymentMessage, c as InitiatedPayment, a as ConnectorKey, d as ConnectedAccount, e as AccountCredentialsInsertType, f as AccountInsertType, P as PaymentPreparedInsertType, g as InitiatedBatch, B as BatchMetadata, A as AccountSelectType, h as PaymentStatus, i as BatchStatus, j as CurrencyCode, k as BankCode, l as CountryCode, m as AuthInput, n as Currency } from './shared/bank.
|
|
2
|
-
export { D as ACCOUNT_STATUSES, Y as AccountCredentialsPatchType, Z as AccountCredentialsSelectType, X as AccountCredentialsUpdateType, S as AccountPatchType, E as AccountStatus, R as AccountUpdateType, q as BATCH_STATUES, q as BATCH_STATUSES, G as BankAccountWithLastSync, t as CHARGE_BEARERS, H as CONNECTOR_KEYS, F as COUNTRY_CODES, J as CREDENTIALS_TYPES, u as ChargeBearer, C as ConfigEnvironmentBank, K as CredentialsType, v as INSTRUCTION_PRIORITIES, w as InstructionPriority, O as OutgoingPaymentMessage, y as PAYMENT_DIRECTIONS, x as PAYMENT_STATUSES, r as PAYMENT_TYPES, z as PaymentDirection, o as PaymentFailedInsertType, s as PaymentType, T as TOKEN_TYPES, L as TokenType, U as accountCredentialsInsertSchema, W as accountCredentialsSelectSchema, V as accountCredentialsUpdateSchema, M as accountInsertSchema, Q as accountSelectSchema, N as accountUpdateSchema, p as paymentInitializedInsertType } from './shared/bank.
|
|
3
|
-
import { a as PaymentInsertType, t as tables, P as PaymentSelectType } from './shared/bank.
|
|
4
|
-
export { b as BatchInsertType, B as BatchSelectType, p as paymentInsertTypeZod } from './shared/bank.
|
|
1
|
+
import { I as IBankConnector, b as IncomingPaymentMessage, c as InitiatedPayment, a as ConnectorKey, d as ConnectedAccount, e as AccountCredentialsInsertType, f as AccountInsertType, P as PaymentPreparedInsertType, g as InitiatedBatch, B as BatchMetadata, A as AccountSelectType, h as PaymentStatus, i as BatchStatus, j as CurrencyCode, k as BankCode, l as CountryCode, m as AuthInput, n as Currency } from './shared/bank.DSVzOCrh.cjs';
|
|
2
|
+
export { D as ACCOUNT_STATUSES, Y as AccountCredentialsPatchType, Z as AccountCredentialsSelectType, X as AccountCredentialsUpdateType, S as AccountPatchType, E as AccountStatus, R as AccountUpdateType, q as BATCH_STATUES, q as BATCH_STATUSES, G as BankAccountWithLastSync, t as CHARGE_BEARERS, H as CONNECTOR_KEYS, F as COUNTRY_CODES, J as CREDENTIALS_TYPES, u as ChargeBearer, C as ConfigEnvironmentBank, K as CredentialsType, v as INSTRUCTION_PRIORITIES, w as InstructionPriority, O as OutgoingPaymentMessage, y as PAYMENT_DIRECTIONS, x as PAYMENT_STATUSES, r as PAYMENT_TYPES, z as PaymentDirection, o as PaymentFailedInsertType, s as PaymentType, T as TOKEN_TYPES, L as TokenType, U as accountCredentialsInsertSchema, W as accountCredentialsSelectSchema, V as accountCredentialsUpdateSchema, M as accountInsertSchema, Q as accountSelectSchema, N as accountUpdateSchema, p as paymentInitializedInsertType } from './shared/bank.DSVzOCrh.cjs';
|
|
3
|
+
import { a as PaymentInsertType, t as tables, P as PaymentSelectType } from './shared/bank.BFGDv0oC.cjs';
|
|
4
|
+
export { b as BatchInsertType, B as BatchSelectType, p as paymentInsertTypeZod } from './shared/bank.BFGDv0oC.cjs';
|
|
5
5
|
import { Environment, BaseEvent } from '@develit-io/backend-sdk';
|
|
6
6
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
7
7
|
export { b as BankServiceEnv, a as BankServiceEnvironmentConfig, B as BankServiceWranglerConfig } from './shared/bank.BchnXQDL.cjs';
|
package/dist/types.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { I as IBankConnector, b as IncomingPaymentMessage, c as InitiatedPayment, a as ConnectorKey, d as ConnectedAccount, e as AccountCredentialsInsertType, f as AccountInsertType, P as PaymentPreparedInsertType, g as InitiatedBatch, B as BatchMetadata, A as AccountSelectType, h as PaymentStatus, i as BatchStatus, j as CurrencyCode, k as BankCode, l as CountryCode, m as AuthInput, n as Currency } from './shared/bank.
|
|
2
|
-
export { D as ACCOUNT_STATUSES, Y as AccountCredentialsPatchType, Z as AccountCredentialsSelectType, X as AccountCredentialsUpdateType, S as AccountPatchType, E as AccountStatus, R as AccountUpdateType, q as BATCH_STATUES, q as BATCH_STATUSES, G as BankAccountWithLastSync, t as CHARGE_BEARERS, H as CONNECTOR_KEYS, F as COUNTRY_CODES, J as CREDENTIALS_TYPES, u as ChargeBearer, C as ConfigEnvironmentBank, K as CredentialsType, v as INSTRUCTION_PRIORITIES, w as InstructionPriority, O as OutgoingPaymentMessage, y as PAYMENT_DIRECTIONS, x as PAYMENT_STATUSES, r as PAYMENT_TYPES, z as PaymentDirection, o as PaymentFailedInsertType, s as PaymentType, T as TOKEN_TYPES, L as TokenType, U as accountCredentialsInsertSchema, W as accountCredentialsSelectSchema, V as accountCredentialsUpdateSchema, M as accountInsertSchema, Q as accountSelectSchema, N as accountUpdateSchema, p as paymentInitializedInsertType } from './shared/bank.
|
|
3
|
-
import { a as PaymentInsertType, t as tables, P as PaymentSelectType } from './shared/bank.
|
|
4
|
-
export { b as BatchInsertType, B as BatchSelectType, p as paymentInsertTypeZod } from './shared/bank.
|
|
1
|
+
import { I as IBankConnector, b as IncomingPaymentMessage, c as InitiatedPayment, a as ConnectorKey, d as ConnectedAccount, e as AccountCredentialsInsertType, f as AccountInsertType, P as PaymentPreparedInsertType, g as InitiatedBatch, B as BatchMetadata, A as AccountSelectType, h as PaymentStatus, i as BatchStatus, j as CurrencyCode, k as BankCode, l as CountryCode, m as AuthInput, n as Currency } from './shared/bank.CrRs_x0N.mjs';
|
|
2
|
+
export { D as ACCOUNT_STATUSES, Y as AccountCredentialsPatchType, Z as AccountCredentialsSelectType, X as AccountCredentialsUpdateType, S as AccountPatchType, E as AccountStatus, R as AccountUpdateType, q as BATCH_STATUES, q as BATCH_STATUSES, G as BankAccountWithLastSync, t as CHARGE_BEARERS, H as CONNECTOR_KEYS, F as COUNTRY_CODES, J as CREDENTIALS_TYPES, u as ChargeBearer, C as ConfigEnvironmentBank, K as CredentialsType, v as INSTRUCTION_PRIORITIES, w as InstructionPriority, O as OutgoingPaymentMessage, y as PAYMENT_DIRECTIONS, x as PAYMENT_STATUSES, r as PAYMENT_TYPES, z as PaymentDirection, o as PaymentFailedInsertType, s as PaymentType, T as TOKEN_TYPES, L as TokenType, U as accountCredentialsInsertSchema, W as accountCredentialsSelectSchema, V as accountCredentialsUpdateSchema, M as accountInsertSchema, Q as accountSelectSchema, N as accountUpdateSchema, p as paymentInitializedInsertType } from './shared/bank.CrRs_x0N.mjs';
|
|
3
|
+
import { a as PaymentInsertType, t as tables, P as PaymentSelectType } from './shared/bank.BFGDv0oC.mjs';
|
|
4
|
+
export { b as BatchInsertType, B as BatchSelectType, p as paymentInsertTypeZod } from './shared/bank.BFGDv0oC.mjs';
|
|
5
5
|
import { Environment, BaseEvent } from '@develit-io/backend-sdk';
|
|
6
6
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
7
7
|
export { b as BankServiceEnv, a as BankServiceEnvironmentConfig, B as BankServiceWranglerConfig } from './shared/bank.BchnXQDL.mjs';
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { I as IBankConnector, b as IncomingPaymentMessage, c as InitiatedPayment, a as ConnectorKey, d as ConnectedAccount, e as AccountCredentialsInsertType, f as AccountInsertType, P as PaymentPreparedInsertType, g as InitiatedBatch, B as BatchMetadata, A as AccountSelectType, h as PaymentStatus, i as BatchStatus, j as CurrencyCode, k as BankCode, l as CountryCode, m as AuthInput, n as Currency } from './shared/bank.
|
|
2
|
-
export { D as ACCOUNT_STATUSES, Y as AccountCredentialsPatchType, Z as AccountCredentialsSelectType, X as AccountCredentialsUpdateType, S as AccountPatchType, E as AccountStatus, R as AccountUpdateType, q as BATCH_STATUES, q as BATCH_STATUSES, G as BankAccountWithLastSync, t as CHARGE_BEARERS, H as CONNECTOR_KEYS, F as COUNTRY_CODES, J as CREDENTIALS_TYPES, u as ChargeBearer, C as ConfigEnvironmentBank, K as CredentialsType, v as INSTRUCTION_PRIORITIES, w as InstructionPriority, O as OutgoingPaymentMessage, y as PAYMENT_DIRECTIONS, x as PAYMENT_STATUSES, r as PAYMENT_TYPES, z as PaymentDirection, o as PaymentFailedInsertType, s as PaymentType, T as TOKEN_TYPES, L as TokenType, U as accountCredentialsInsertSchema, W as accountCredentialsSelectSchema, V as accountCredentialsUpdateSchema, M as accountInsertSchema, Q as accountSelectSchema, N as accountUpdateSchema, p as paymentInitializedInsertType } from './shared/bank.
|
|
3
|
-
import { a as PaymentInsertType, t as tables, P as PaymentSelectType } from './shared/bank.
|
|
4
|
-
export { b as BatchInsertType, B as BatchSelectType, p as paymentInsertTypeZod } from './shared/bank.
|
|
1
|
+
import { I as IBankConnector, b as IncomingPaymentMessage, c as InitiatedPayment, a as ConnectorKey, d as ConnectedAccount, e as AccountCredentialsInsertType, f as AccountInsertType, P as PaymentPreparedInsertType, g as InitiatedBatch, B as BatchMetadata, A as AccountSelectType, h as PaymentStatus, i as BatchStatus, j as CurrencyCode, k as BankCode, l as CountryCode, m as AuthInput, n as Currency } from './shared/bank.DCTBX1dp.js';
|
|
2
|
+
export { D as ACCOUNT_STATUSES, Y as AccountCredentialsPatchType, Z as AccountCredentialsSelectType, X as AccountCredentialsUpdateType, S as AccountPatchType, E as AccountStatus, R as AccountUpdateType, q as BATCH_STATUES, q as BATCH_STATUSES, G as BankAccountWithLastSync, t as CHARGE_BEARERS, H as CONNECTOR_KEYS, F as COUNTRY_CODES, J as CREDENTIALS_TYPES, u as ChargeBearer, C as ConfigEnvironmentBank, K as CredentialsType, v as INSTRUCTION_PRIORITIES, w as InstructionPriority, O as OutgoingPaymentMessage, y as PAYMENT_DIRECTIONS, x as PAYMENT_STATUSES, r as PAYMENT_TYPES, z as PaymentDirection, o as PaymentFailedInsertType, s as PaymentType, T as TOKEN_TYPES, L as TokenType, U as accountCredentialsInsertSchema, W as accountCredentialsSelectSchema, V as accountCredentialsUpdateSchema, M as accountInsertSchema, Q as accountSelectSchema, N as accountUpdateSchema, p as paymentInitializedInsertType } from './shared/bank.DCTBX1dp.js';
|
|
3
|
+
import { a as PaymentInsertType, t as tables, P as PaymentSelectType } from './shared/bank.BFGDv0oC.js';
|
|
4
|
+
export { b as BatchInsertType, B as BatchSelectType, p as paymentInsertTypeZod } from './shared/bank.BFGDv0oC.js';
|
|
5
5
|
import { Environment, BaseEvent } from '@develit-io/backend-sdk';
|
|
6
6
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
7
7
|
export { b as BankServiceEnv, a as BankServiceEnvironmentConfig, B as BankServiceWranglerConfig } from './shared/bank.BchnXQDL.js';
|