@develit-services/bank 0.3.45 → 0.3.46
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/export/worker.cjs +89 -54
- package/dist/export/worker.d.cts +13 -3
- package/dist/export/worker.d.mts +13 -3
- package/dist/export/worker.d.ts +13 -3
- package/dist/export/worker.mjs +89 -54
- package/package.json +1 -1
package/dist/export/worker.cjs
CHANGED
|
@@ -260,7 +260,9 @@ const getAuthUriInputSchema = zod.z.object({
|
|
|
260
260
|
|
|
261
261
|
const authorizeAccountInputSchema = zod.z.object({
|
|
262
262
|
ott: zod.z.string(),
|
|
263
|
-
urlParams: zod.z.string()
|
|
263
|
+
urlParams: zod.z.string(),
|
|
264
|
+
syncIntervalS: zod.z.number().int().positive().optional(),
|
|
265
|
+
startSync: zod.z.boolean().optional()
|
|
264
266
|
});
|
|
265
267
|
|
|
266
268
|
const simulateDepositInputSchema = zod.z.object({
|
|
@@ -314,6 +316,14 @@ zod.z.object({
|
|
|
314
316
|
details: backendSdk.workflowInstanceStatusSchema
|
|
315
317
|
});
|
|
316
318
|
|
|
319
|
+
const updateBatchStatusesInputSchema = zod.z.object({
|
|
320
|
+
batchId: zod.z.uuid().optional()
|
|
321
|
+
}).optional();
|
|
322
|
+
zod.z.object({
|
|
323
|
+
processed: zod.z.number(),
|
|
324
|
+
statusChanged: zod.z.number()
|
|
325
|
+
});
|
|
326
|
+
|
|
317
327
|
const ALLOWED_PAYMENT_FILTERS = {
|
|
318
328
|
ACCOUNT_ID: "filterPaymentAccountId",
|
|
319
329
|
AMOUNT: "filterPaymentAmount",
|
|
@@ -564,60 +574,72 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
564
574
|
};
|
|
565
575
|
}
|
|
566
576
|
async updateBatchStatuses(input) {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
this.
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
batch
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
577
|
+
return this.handleAction(
|
|
578
|
+
{ data: input, schema: updateBatchStatusesInputSchema },
|
|
579
|
+
{ successMessage: "Batch statuses updated" },
|
|
580
|
+
async (validatedInput) => {
|
|
581
|
+
let pendingBatches;
|
|
582
|
+
if (validatedInput?.batchId) {
|
|
583
|
+
const batch = await encryption.getBatchByIdQuery(this.db, {
|
|
584
|
+
batchId: validatedInput.batchId
|
|
585
|
+
});
|
|
586
|
+
if (!batch) {
|
|
587
|
+
throw backendSdk.createInternalError(null, {
|
|
588
|
+
message: `Batch not found: ${validatedInput.batchId}`,
|
|
589
|
+
code: "DB-B-007",
|
|
590
|
+
status: 404
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
pendingBatches = [batch];
|
|
594
|
+
} else {
|
|
595
|
+
pendingBatches = await getAllPendingBatchesQuery(this.db);
|
|
596
|
+
}
|
|
597
|
+
const accounts = await this._getConnectedAccounts();
|
|
598
|
+
console.log(`Processing ${pendingBatches.length} pending batche(s)`);
|
|
599
|
+
const batchesByConnector = /* @__PURE__ */ new Map();
|
|
600
|
+
for (const batch of pendingBatches) {
|
|
601
|
+
const account = accounts.find((acc) => acc.id === batch.accountId);
|
|
602
|
+
if (!account) {
|
|
603
|
+
this.logError({
|
|
604
|
+
message: `Account not found for batch ${batch.id}, skipping`
|
|
605
|
+
});
|
|
606
|
+
await encryption.upsertBatchCommand(this.db, {
|
|
607
|
+
batch: {
|
|
608
|
+
...batch,
|
|
609
|
+
status: "FAILED",
|
|
610
|
+
statusReason: "ACCOUNT_NOT_FOUND"
|
|
611
|
+
}
|
|
612
|
+
}).command.execute();
|
|
613
|
+
continue;
|
|
614
|
+
}
|
|
615
|
+
const batches = batchesByConnector.get(account.connectorKey) || [];
|
|
616
|
+
batches.push(batch);
|
|
617
|
+
batchesByConnector.set(account.connectorKey, batches);
|
|
618
|
+
}
|
|
619
|
+
const allResults = [];
|
|
620
|
+
for (const [connectorKey, batches] of batchesByConnector) {
|
|
621
|
+
console.log(
|
|
622
|
+
`Initializing ${connectorKey} connector for ${batches.length} batches`
|
|
623
|
+
);
|
|
624
|
+
const connector = await this._initiateBankConnector({
|
|
625
|
+
connectorKey
|
|
626
|
+
});
|
|
627
|
+
for (const batch of batches) {
|
|
628
|
+
const result = await this._resolveSingleBatch(batch, connector);
|
|
629
|
+
if (result) {
|
|
630
|
+
allResults.push(result);
|
|
631
|
+
}
|
|
595
632
|
}
|
|
596
|
-
}).command.execute();
|
|
597
|
-
continue;
|
|
598
|
-
}
|
|
599
|
-
const batches = batchesByConnector.get(account.connectorKey) || [];
|
|
600
|
-
batches.push(batch);
|
|
601
|
-
batchesByConnector.set(account.connectorKey, batches);
|
|
602
|
-
}
|
|
603
|
-
const allResults = [];
|
|
604
|
-
for (const [connectorKey, batches] of batchesByConnector) {
|
|
605
|
-
console.log(
|
|
606
|
-
`Initializing ${connectorKey} connector for ${batches.length} batches`
|
|
607
|
-
);
|
|
608
|
-
const connector = await this._initiateBankConnector({
|
|
609
|
-
connectorKey
|
|
610
|
-
});
|
|
611
|
-
for (const batch of batches) {
|
|
612
|
-
const result = await this._resolveSingleBatch(batch, connector);
|
|
613
|
-
if (result) {
|
|
614
|
-
allResults.push(result);
|
|
615
633
|
}
|
|
634
|
+
const changedCount = allResults.filter((r) => r.statusChanged).length;
|
|
635
|
+
console.log(
|
|
636
|
+
`Batch update completed: ${changedCount} status change(s) detected`
|
|
637
|
+
);
|
|
638
|
+
return {
|
|
639
|
+
processed: allResults.length,
|
|
640
|
+
statusChanged: changedCount
|
|
641
|
+
};
|
|
616
642
|
}
|
|
617
|
-
}
|
|
618
|
-
const changedCount = allResults.filter((r) => r.statusChanged).length;
|
|
619
|
-
console.log(
|
|
620
|
-
`Batch update completed: ${changedCount} status change(s) detected.`
|
|
621
643
|
);
|
|
622
644
|
}
|
|
623
645
|
async addPaymentsToBatch({
|
|
@@ -802,7 +824,7 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
802
824
|
return this.handleAction(
|
|
803
825
|
{ data: input, schema: authorizeAccountInputSchema },
|
|
804
826
|
{ successMessage: "Erste code saved." },
|
|
805
|
-
async ({ ott, urlParams }) => {
|
|
827
|
+
async ({ ott, urlParams, syncIntervalS, startSync }) => {
|
|
806
828
|
const ottRow = await getOttQuery(this.db, {
|
|
807
829
|
ott
|
|
808
830
|
});
|
|
@@ -832,7 +854,7 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
832
854
|
);
|
|
833
855
|
const upsertAccounts = accounts.map(
|
|
834
856
|
(acc) => upsertAccountCommand(this.db, {
|
|
835
|
-
account: acc
|
|
857
|
+
account: syncIntervalS ? { ...acc, syncIntervalS } : acc
|
|
836
858
|
}).command
|
|
837
859
|
);
|
|
838
860
|
const deleteCredentials = alreadyExistingAccounts.map(
|
|
@@ -864,6 +886,19 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
864
886
|
code: "DB-B-003",
|
|
865
887
|
status: 404
|
|
866
888
|
});
|
|
889
|
+
if (startSync) {
|
|
890
|
+
for (const account of fetchedAccounts) {
|
|
891
|
+
const { error } = await this.syncAccount({
|
|
892
|
+
accountId: account.id
|
|
893
|
+
});
|
|
894
|
+
if (error) {
|
|
895
|
+
this.logError({
|
|
896
|
+
message: `Failed to auto-start sync workflow for account ${account.id}`,
|
|
897
|
+
error
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
}
|
|
867
902
|
return {
|
|
868
903
|
accounts: fetchedAccounts
|
|
869
904
|
};
|
package/dist/export/worker.d.cts
CHANGED
|
@@ -772,6 +772,8 @@ type GetAuthUriOutput = {
|
|
|
772
772
|
declare const authorizeAccountInputSchema: z.ZodObject<{
|
|
773
773
|
ott: z.ZodString;
|
|
774
774
|
urlParams: z.ZodString;
|
|
775
|
+
syncIntervalS: z.ZodOptional<z.ZodNumber>;
|
|
776
|
+
startSync: z.ZodOptional<z.ZodBoolean>;
|
|
775
777
|
}, z.core.$strip>;
|
|
776
778
|
interface AuthorizeAccountInput extends z.infer<typeof authorizeAccountInputSchema> {
|
|
777
779
|
}
|
|
@@ -1642,6 +1644,16 @@ interface ProcessBatchRestartInput extends z.infer<typeof processBatchRestartInp
|
|
|
1642
1644
|
}
|
|
1643
1645
|
type ProcessBatchRestartOutput = z.infer<typeof processBatchRestartOutputSchema>;
|
|
1644
1646
|
|
|
1647
|
+
declare const updateBatchStatusesInputSchema: z.ZodOptional<z.ZodObject<{
|
|
1648
|
+
batchId: z.ZodOptional<z.ZodUUID>;
|
|
1649
|
+
}, z.core.$strip>>;
|
|
1650
|
+
declare const updateBatchStatusesOutputSchema: z.ZodObject<{
|
|
1651
|
+
processed: z.ZodNumber;
|
|
1652
|
+
statusChanged: z.ZodNumber;
|
|
1653
|
+
}, z.core.$strip>;
|
|
1654
|
+
type UpdateBatchStatusesInput = z.infer<typeof updateBatchStatusesInputSchema>;
|
|
1655
|
+
type UpdateBatchStatusesOutput = z.infer<typeof updateBatchStatusesOutputSchema>;
|
|
1656
|
+
|
|
1645
1657
|
declare const getPaymentsInputSchema: z.ZodObject<{
|
|
1646
1658
|
page: z.ZodNumber;
|
|
1647
1659
|
limit: z.ZodNumber;
|
|
@@ -2483,9 +2495,7 @@ declare class BankServiceBase extends BankServiceBase_base {
|
|
|
2483
2495
|
currentStatus: string;
|
|
2484
2496
|
statusChanged: boolean;
|
|
2485
2497
|
} | null>;
|
|
2486
|
-
updateBatchStatuses(input?:
|
|
2487
|
-
batchId?: string;
|
|
2488
|
-
}): Promise<void>;
|
|
2498
|
+
updateBatchStatuses(input?: UpdateBatchStatusesInput): Promise<IRPCResponse<UpdateBatchStatusesOutput>>;
|
|
2489
2499
|
addPaymentsToBatch({ paymentsToBatch, }: {
|
|
2490
2500
|
paymentsToBatch: SendPaymentInput[];
|
|
2491
2501
|
}): Promise<IRPCResponse<{
|
package/dist/export/worker.d.mts
CHANGED
|
@@ -772,6 +772,8 @@ type GetAuthUriOutput = {
|
|
|
772
772
|
declare const authorizeAccountInputSchema: z.ZodObject<{
|
|
773
773
|
ott: z.ZodString;
|
|
774
774
|
urlParams: z.ZodString;
|
|
775
|
+
syncIntervalS: z.ZodOptional<z.ZodNumber>;
|
|
776
|
+
startSync: z.ZodOptional<z.ZodBoolean>;
|
|
775
777
|
}, z.core.$strip>;
|
|
776
778
|
interface AuthorizeAccountInput extends z.infer<typeof authorizeAccountInputSchema> {
|
|
777
779
|
}
|
|
@@ -1642,6 +1644,16 @@ interface ProcessBatchRestartInput extends z.infer<typeof processBatchRestartInp
|
|
|
1642
1644
|
}
|
|
1643
1645
|
type ProcessBatchRestartOutput = z.infer<typeof processBatchRestartOutputSchema>;
|
|
1644
1646
|
|
|
1647
|
+
declare const updateBatchStatusesInputSchema: z.ZodOptional<z.ZodObject<{
|
|
1648
|
+
batchId: z.ZodOptional<z.ZodUUID>;
|
|
1649
|
+
}, z.core.$strip>>;
|
|
1650
|
+
declare const updateBatchStatusesOutputSchema: z.ZodObject<{
|
|
1651
|
+
processed: z.ZodNumber;
|
|
1652
|
+
statusChanged: z.ZodNumber;
|
|
1653
|
+
}, z.core.$strip>;
|
|
1654
|
+
type UpdateBatchStatusesInput = z.infer<typeof updateBatchStatusesInputSchema>;
|
|
1655
|
+
type UpdateBatchStatusesOutput = z.infer<typeof updateBatchStatusesOutputSchema>;
|
|
1656
|
+
|
|
1645
1657
|
declare const getPaymentsInputSchema: z.ZodObject<{
|
|
1646
1658
|
page: z.ZodNumber;
|
|
1647
1659
|
limit: z.ZodNumber;
|
|
@@ -2483,9 +2495,7 @@ declare class BankServiceBase extends BankServiceBase_base {
|
|
|
2483
2495
|
currentStatus: string;
|
|
2484
2496
|
statusChanged: boolean;
|
|
2485
2497
|
} | null>;
|
|
2486
|
-
updateBatchStatuses(input?:
|
|
2487
|
-
batchId?: string;
|
|
2488
|
-
}): Promise<void>;
|
|
2498
|
+
updateBatchStatuses(input?: UpdateBatchStatusesInput): Promise<IRPCResponse<UpdateBatchStatusesOutput>>;
|
|
2489
2499
|
addPaymentsToBatch({ paymentsToBatch, }: {
|
|
2490
2500
|
paymentsToBatch: SendPaymentInput[];
|
|
2491
2501
|
}): Promise<IRPCResponse<{
|
package/dist/export/worker.d.ts
CHANGED
|
@@ -772,6 +772,8 @@ type GetAuthUriOutput = {
|
|
|
772
772
|
declare const authorizeAccountInputSchema: z.ZodObject<{
|
|
773
773
|
ott: z.ZodString;
|
|
774
774
|
urlParams: z.ZodString;
|
|
775
|
+
syncIntervalS: z.ZodOptional<z.ZodNumber>;
|
|
776
|
+
startSync: z.ZodOptional<z.ZodBoolean>;
|
|
775
777
|
}, z.core.$strip>;
|
|
776
778
|
interface AuthorizeAccountInput extends z.infer<typeof authorizeAccountInputSchema> {
|
|
777
779
|
}
|
|
@@ -1642,6 +1644,16 @@ interface ProcessBatchRestartInput extends z.infer<typeof processBatchRestartInp
|
|
|
1642
1644
|
}
|
|
1643
1645
|
type ProcessBatchRestartOutput = z.infer<typeof processBatchRestartOutputSchema>;
|
|
1644
1646
|
|
|
1647
|
+
declare const updateBatchStatusesInputSchema: z.ZodOptional<z.ZodObject<{
|
|
1648
|
+
batchId: z.ZodOptional<z.ZodUUID>;
|
|
1649
|
+
}, z.core.$strip>>;
|
|
1650
|
+
declare const updateBatchStatusesOutputSchema: z.ZodObject<{
|
|
1651
|
+
processed: z.ZodNumber;
|
|
1652
|
+
statusChanged: z.ZodNumber;
|
|
1653
|
+
}, z.core.$strip>;
|
|
1654
|
+
type UpdateBatchStatusesInput = z.infer<typeof updateBatchStatusesInputSchema>;
|
|
1655
|
+
type UpdateBatchStatusesOutput = z.infer<typeof updateBatchStatusesOutputSchema>;
|
|
1656
|
+
|
|
1645
1657
|
declare const getPaymentsInputSchema: z.ZodObject<{
|
|
1646
1658
|
page: z.ZodNumber;
|
|
1647
1659
|
limit: z.ZodNumber;
|
|
@@ -2483,9 +2495,7 @@ declare class BankServiceBase extends BankServiceBase_base {
|
|
|
2483
2495
|
currentStatus: string;
|
|
2484
2496
|
statusChanged: boolean;
|
|
2485
2497
|
} | null>;
|
|
2486
|
-
updateBatchStatuses(input?:
|
|
2487
|
-
batchId?: string;
|
|
2488
|
-
}): Promise<void>;
|
|
2498
|
+
updateBatchStatuses(input?: UpdateBatchStatusesInput): Promise<IRPCResponse<UpdateBatchStatusesOutput>>;
|
|
2489
2499
|
addPaymentsToBatch({ paymentsToBatch, }: {
|
|
2490
2500
|
paymentsToBatch: SendPaymentInput[];
|
|
2491
2501
|
}): Promise<IRPCResponse<{
|
package/dist/export/worker.mjs
CHANGED
|
@@ -258,7 +258,9 @@ const getAuthUriInputSchema = z.object({
|
|
|
258
258
|
|
|
259
259
|
const authorizeAccountInputSchema = z.object({
|
|
260
260
|
ott: z.string(),
|
|
261
|
-
urlParams: z.string()
|
|
261
|
+
urlParams: z.string(),
|
|
262
|
+
syncIntervalS: z.number().int().positive().optional(),
|
|
263
|
+
startSync: z.boolean().optional()
|
|
262
264
|
});
|
|
263
265
|
|
|
264
266
|
const simulateDepositInputSchema = z.object({
|
|
@@ -312,6 +314,14 @@ z.object({
|
|
|
312
314
|
details: workflowInstanceStatusSchema
|
|
313
315
|
});
|
|
314
316
|
|
|
317
|
+
const updateBatchStatusesInputSchema = z.object({
|
|
318
|
+
batchId: z.uuid().optional()
|
|
319
|
+
}).optional();
|
|
320
|
+
z.object({
|
|
321
|
+
processed: z.number(),
|
|
322
|
+
statusChanged: z.number()
|
|
323
|
+
});
|
|
324
|
+
|
|
315
325
|
const ALLOWED_PAYMENT_FILTERS = {
|
|
316
326
|
ACCOUNT_ID: "filterPaymentAccountId",
|
|
317
327
|
AMOUNT: "filterPaymentAmount",
|
|
@@ -562,60 +572,72 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
562
572
|
};
|
|
563
573
|
}
|
|
564
574
|
async updateBatchStatuses(input) {
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
this.
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
batch
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
575
|
+
return this.handleAction(
|
|
576
|
+
{ data: input, schema: updateBatchStatusesInputSchema },
|
|
577
|
+
{ successMessage: "Batch statuses updated" },
|
|
578
|
+
async (validatedInput) => {
|
|
579
|
+
let pendingBatches;
|
|
580
|
+
if (validatedInput?.batchId) {
|
|
581
|
+
const batch = await getBatchByIdQuery(this.db, {
|
|
582
|
+
batchId: validatedInput.batchId
|
|
583
|
+
});
|
|
584
|
+
if (!batch) {
|
|
585
|
+
throw createInternalError(null, {
|
|
586
|
+
message: `Batch not found: ${validatedInput.batchId}`,
|
|
587
|
+
code: "DB-B-007",
|
|
588
|
+
status: 404
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
pendingBatches = [batch];
|
|
592
|
+
} else {
|
|
593
|
+
pendingBatches = await getAllPendingBatchesQuery(this.db);
|
|
594
|
+
}
|
|
595
|
+
const accounts = await this._getConnectedAccounts();
|
|
596
|
+
console.log(`Processing ${pendingBatches.length} pending batche(s)`);
|
|
597
|
+
const batchesByConnector = /* @__PURE__ */ new Map();
|
|
598
|
+
for (const batch of pendingBatches) {
|
|
599
|
+
const account = accounts.find((acc) => acc.id === batch.accountId);
|
|
600
|
+
if (!account) {
|
|
601
|
+
this.logError({
|
|
602
|
+
message: `Account not found for batch ${batch.id}, skipping`
|
|
603
|
+
});
|
|
604
|
+
await upsertBatchCommand(this.db, {
|
|
605
|
+
batch: {
|
|
606
|
+
...batch,
|
|
607
|
+
status: "FAILED",
|
|
608
|
+
statusReason: "ACCOUNT_NOT_FOUND"
|
|
609
|
+
}
|
|
610
|
+
}).command.execute();
|
|
611
|
+
continue;
|
|
612
|
+
}
|
|
613
|
+
const batches = batchesByConnector.get(account.connectorKey) || [];
|
|
614
|
+
batches.push(batch);
|
|
615
|
+
batchesByConnector.set(account.connectorKey, batches);
|
|
616
|
+
}
|
|
617
|
+
const allResults = [];
|
|
618
|
+
for (const [connectorKey, batches] of batchesByConnector) {
|
|
619
|
+
console.log(
|
|
620
|
+
`Initializing ${connectorKey} connector for ${batches.length} batches`
|
|
621
|
+
);
|
|
622
|
+
const connector = await this._initiateBankConnector({
|
|
623
|
+
connectorKey
|
|
624
|
+
});
|
|
625
|
+
for (const batch of batches) {
|
|
626
|
+
const result = await this._resolveSingleBatch(batch, connector);
|
|
627
|
+
if (result) {
|
|
628
|
+
allResults.push(result);
|
|
629
|
+
}
|
|
593
630
|
}
|
|
594
|
-
}).command.execute();
|
|
595
|
-
continue;
|
|
596
|
-
}
|
|
597
|
-
const batches = batchesByConnector.get(account.connectorKey) || [];
|
|
598
|
-
batches.push(batch);
|
|
599
|
-
batchesByConnector.set(account.connectorKey, batches);
|
|
600
|
-
}
|
|
601
|
-
const allResults = [];
|
|
602
|
-
for (const [connectorKey, batches] of batchesByConnector) {
|
|
603
|
-
console.log(
|
|
604
|
-
`Initializing ${connectorKey} connector for ${batches.length} batches`
|
|
605
|
-
);
|
|
606
|
-
const connector = await this._initiateBankConnector({
|
|
607
|
-
connectorKey
|
|
608
|
-
});
|
|
609
|
-
for (const batch of batches) {
|
|
610
|
-
const result = await this._resolveSingleBatch(batch, connector);
|
|
611
|
-
if (result) {
|
|
612
|
-
allResults.push(result);
|
|
613
631
|
}
|
|
632
|
+
const changedCount = allResults.filter((r) => r.statusChanged).length;
|
|
633
|
+
console.log(
|
|
634
|
+
`Batch update completed: ${changedCount} status change(s) detected`
|
|
635
|
+
);
|
|
636
|
+
return {
|
|
637
|
+
processed: allResults.length,
|
|
638
|
+
statusChanged: changedCount
|
|
639
|
+
};
|
|
614
640
|
}
|
|
615
|
-
}
|
|
616
|
-
const changedCount = allResults.filter((r) => r.statusChanged).length;
|
|
617
|
-
console.log(
|
|
618
|
-
`Batch update completed: ${changedCount} status change(s) detected.`
|
|
619
641
|
);
|
|
620
642
|
}
|
|
621
643
|
async addPaymentsToBatch({
|
|
@@ -800,7 +822,7 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
800
822
|
return this.handleAction(
|
|
801
823
|
{ data: input, schema: authorizeAccountInputSchema },
|
|
802
824
|
{ successMessage: "Erste code saved." },
|
|
803
|
-
async ({ ott, urlParams }) => {
|
|
825
|
+
async ({ ott, urlParams, syncIntervalS, startSync }) => {
|
|
804
826
|
const ottRow = await getOttQuery(this.db, {
|
|
805
827
|
ott
|
|
806
828
|
});
|
|
@@ -830,7 +852,7 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
830
852
|
);
|
|
831
853
|
const upsertAccounts = accounts.map(
|
|
832
854
|
(acc) => upsertAccountCommand(this.db, {
|
|
833
|
-
account: acc
|
|
855
|
+
account: syncIntervalS ? { ...acc, syncIntervalS } : acc
|
|
834
856
|
}).command
|
|
835
857
|
);
|
|
836
858
|
const deleteCredentials = alreadyExistingAccounts.map(
|
|
@@ -862,6 +884,19 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
862
884
|
code: "DB-B-003",
|
|
863
885
|
status: 404
|
|
864
886
|
});
|
|
887
|
+
if (startSync) {
|
|
888
|
+
for (const account of fetchedAccounts) {
|
|
889
|
+
const { error } = await this.syncAccount({
|
|
890
|
+
accountId: account.id
|
|
891
|
+
});
|
|
892
|
+
if (error) {
|
|
893
|
+
this.logError({
|
|
894
|
+
message: `Failed to auto-start sync workflow for account ${account.id}`,
|
|
895
|
+
error
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
}
|
|
865
900
|
return {
|
|
866
901
|
accounts: fetchedAccounts
|
|
867
902
|
};
|