@cequrebackends/cequre-ts 0.12.2 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -556,6 +556,7 @@ var init_logger = __esm(() => {
|
|
|
556
556
|
|
|
557
557
|
// shared/utils/queue-manager.ts
|
|
558
558
|
import { Queue as BullQueue, Worker as BullWorker, QueueEvents as BullQueueEvents } from "bullmq";
|
|
559
|
+
import { Effect } from "effect";
|
|
559
560
|
init_logger();
|
|
560
561
|
|
|
561
562
|
class BullMQQueueAdapter {
|
|
@@ -627,6 +628,11 @@ class CequreQueueManager {
|
|
|
627
628
|
...this.config.defaultQueueOptions ?? {},
|
|
628
629
|
...this.getBullMQBaseOptions()
|
|
629
630
|
});
|
|
631
|
+
queue.on("error", (err) => {
|
|
632
|
+
if (err?.message?.includes("Connection is closed"))
|
|
633
|
+
return;
|
|
634
|
+
logger.error(err, `[ ${name.toUpperCase()} QUEUE ] Error`);
|
|
635
|
+
});
|
|
630
636
|
const wrapped = new BullMQQueueAdapter(queue);
|
|
631
637
|
this.queues.set(name, wrapped);
|
|
632
638
|
return wrapped;
|
|
@@ -663,6 +669,8 @@ class CequreQueueManager {
|
|
|
663
669
|
logger.error(err, `${queueNameForLogs} Job ${job?.id ?? "unknown"} failed`);
|
|
664
670
|
});
|
|
665
671
|
worker.on("error", (err) => {
|
|
672
|
+
if (err?.message?.includes("Connection is closed"))
|
|
673
|
+
return;
|
|
666
674
|
logger.error(err, `${queueNameForLogs} Worker error`);
|
|
667
675
|
});
|
|
668
676
|
await worker.waitUntilReady();
|
|
@@ -685,6 +693,11 @@ class CequreQueueManager {
|
|
|
685
693
|
const events = new BullQueueEvents(name, {
|
|
686
694
|
...this.getBullMQBaseOptions()
|
|
687
695
|
});
|
|
696
|
+
events.on("error", (err) => {
|
|
697
|
+
if (err?.message?.includes("Connection is closed"))
|
|
698
|
+
return;
|
|
699
|
+
logger.error(err, `[ ${name.toUpperCase()} QUEUE EVENTS ] Error`);
|
|
700
|
+
});
|
|
688
701
|
const wrapped = {
|
|
689
702
|
disconnect: async () => {
|
|
690
703
|
await events.close();
|
|
@@ -707,21 +720,26 @@ class CequreQueueManager {
|
|
|
707
720
|
if (this.closing)
|
|
708
721
|
return;
|
|
709
722
|
this.closing = true;
|
|
710
|
-
const
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
};
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
723
|
+
const closeItemEffect = (item, label) => Effect.tryPromise({
|
|
724
|
+
try: async () => {
|
|
725
|
+
if (item.close)
|
|
726
|
+
await item.close();
|
|
727
|
+
else if (item.disconnect)
|
|
728
|
+
await item.disconnect();
|
|
729
|
+
},
|
|
730
|
+
catch: (err) => err
|
|
731
|
+
}).pipe(Effect.catchAll((err) => Effect.sync(() => {
|
|
732
|
+
logger.error(err, `[QueueManager] Error closing ${label}`);
|
|
733
|
+
})));
|
|
734
|
+
const closeGroupEffect = (items, label) => Effect.all(items.map((item) => closeItemEffect(item, label)), { concurrency: "unbounded" });
|
|
735
|
+
const workers = Array.from(this.workers.values());
|
|
736
|
+
const queueEvents = Array.from(this.queueEvents.values());
|
|
737
|
+
const queues = Array.from(this.queues.values());
|
|
738
|
+
await Effect.runPromise(Effect.gen(function* () {
|
|
739
|
+
yield* closeGroupEffect(workers, "worker");
|
|
740
|
+
yield* closeGroupEffect(queueEvents, "queue events");
|
|
741
|
+
yield* closeGroupEffect(queues, "queue");
|
|
742
|
+
}));
|
|
725
743
|
this.workers.clear();
|
|
726
744
|
this.queueEvents.clear();
|
|
727
745
|
this.queues.clear();
|
package/dist/index.js
CHANGED
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
init_kv,
|
|
38
38
|
init_logger,
|
|
39
39
|
logger
|
|
40
|
-
} from "./index-
|
|
40
|
+
} from "./index-c3vh32en.js";
|
|
41
41
|
import {
|
|
42
42
|
CequreError,
|
|
43
43
|
__require,
|
|
@@ -2532,8 +2532,13 @@ class CequreRuntime {
|
|
|
2532
2532
|
result[f.name] = f.default;
|
|
2533
2533
|
}
|
|
2534
2534
|
const v = result[f.name];
|
|
2535
|
-
if (v !== undefined &&
|
|
2536
|
-
|
|
2535
|
+
if (v !== undefined && v !== null) {
|
|
2536
|
+
if (typeof v === "string" && !isEncrypted(v)) {
|
|
2537
|
+
result[f.name] = await encryptField(key, v);
|
|
2538
|
+
} else if (typeof v !== "string") {
|
|
2539
|
+
const jsonStr = JSON.stringify(v);
|
|
2540
|
+
result[f.name] = await encryptField(key, jsonStr);
|
|
2541
|
+
}
|
|
2537
2542
|
}
|
|
2538
2543
|
}
|
|
2539
2544
|
}
|
|
@@ -2553,8 +2558,13 @@ class CequreRuntime {
|
|
|
2553
2558
|
for (const [k, v] of Object.entries(result)) {
|
|
2554
2559
|
if (encFields.has(k) && typeof v === "string" && isEncrypted(v)) {
|
|
2555
2560
|
const decrypted = await decryptField(key, v);
|
|
2556
|
-
if (decrypted !== null)
|
|
2557
|
-
|
|
2561
|
+
if (decrypted !== null) {
|
|
2562
|
+
try {
|
|
2563
|
+
result[k] = JSON.parse(decrypted);
|
|
2564
|
+
} catch {
|
|
2565
|
+
result[k] = decrypted;
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2558
2568
|
}
|
|
2559
2569
|
}
|
|
2560
2570
|
return result;
|