@dbcube/core 1.0.57 → 1.0.59
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/index.cjs +4 -80
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +2 -7
- package/dist/index.d.ts +2 -7
- package/dist/index.js +4 -80
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -7,14 +7,12 @@ interface ResponseEngine {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
declare class Engine {
|
|
10
|
-
private static instances;
|
|
11
10
|
private name;
|
|
12
11
|
private config;
|
|
13
12
|
private arguments;
|
|
14
13
|
private binary;
|
|
15
14
|
private timeout;
|
|
16
|
-
private
|
|
17
|
-
private isConnecting;
|
|
15
|
+
private static instances;
|
|
18
16
|
constructor(name: string, timeout?: number);
|
|
19
17
|
static getInstance(name: string, timeout?: number): Engine;
|
|
20
18
|
initializeBinary(): Promise<void>;
|
|
@@ -23,10 +21,7 @@ declare class Engine {
|
|
|
23
21
|
[x: string]: any;
|
|
24
22
|
} | null;
|
|
25
23
|
getConfig(): any;
|
|
26
|
-
run(binary: string, args:
|
|
27
|
-
ensureDaemonConnected(): Promise<void>;
|
|
28
|
-
disconnect(): Promise<void>;
|
|
29
|
-
private setupProcessExitHandlers;
|
|
24
|
+
run(binary: string, args: []): Promise<ResponseEngine>;
|
|
30
25
|
}
|
|
31
26
|
|
|
32
27
|
interface SystemInfo {
|
package/dist/index.d.ts
CHANGED
|
@@ -7,14 +7,12 @@ interface ResponseEngine {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
declare class Engine {
|
|
10
|
-
private static instances;
|
|
11
10
|
private name;
|
|
12
11
|
private config;
|
|
13
12
|
private arguments;
|
|
14
13
|
private binary;
|
|
15
14
|
private timeout;
|
|
16
|
-
private
|
|
17
|
-
private isConnecting;
|
|
15
|
+
private static instances;
|
|
18
16
|
constructor(name: string, timeout?: number);
|
|
19
17
|
static getInstance(name: string, timeout?: number): Engine;
|
|
20
18
|
initializeBinary(): Promise<void>;
|
|
@@ -23,10 +21,7 @@ declare class Engine {
|
|
|
23
21
|
[x: string]: any;
|
|
24
22
|
} | null;
|
|
25
23
|
getConfig(): any;
|
|
26
|
-
run(binary: string, args:
|
|
27
|
-
ensureDaemonConnected(): Promise<void>;
|
|
28
|
-
disconnect(): Promise<void>;
|
|
29
|
-
private setupProcessExitHandlers;
|
|
24
|
+
run(binary: string, args: []): Promise<ResponseEngine>;
|
|
30
25
|
}
|
|
31
26
|
|
|
32
27
|
interface SystemInfo {
|
package/dist/index.js
CHANGED
|
@@ -550,24 +550,21 @@ var Config = class {
|
|
|
550
550
|
import { spawn } from "child_process";
|
|
551
551
|
import { createRequire } from "module";
|
|
552
552
|
var Engine = class _Engine {
|
|
553
|
-
|
|
554
|
-
name = "";
|
|
553
|
+
name;
|
|
555
554
|
config;
|
|
556
555
|
arguments;
|
|
557
556
|
binary = null;
|
|
558
|
-
timeout
|
|
559
|
-
|
|
560
|
-
isConnecting = false;
|
|
557
|
+
timeout;
|
|
558
|
+
static instances = /* @__PURE__ */ new Map();
|
|
561
559
|
constructor(name, timeout = 3e4) {
|
|
562
560
|
if (_Engine.instances.has(name)) {
|
|
563
561
|
return _Engine.instances.get(name);
|
|
564
562
|
}
|
|
565
563
|
this.name = name;
|
|
564
|
+
this.timeout = timeout;
|
|
566
565
|
this.config = this.setConfig(name);
|
|
567
566
|
this.arguments = this.setArguments();
|
|
568
|
-
this.timeout = timeout;
|
|
569
567
|
_Engine.instances.set(name, this);
|
|
570
|
-
this.setupProcessExitHandlers();
|
|
571
568
|
}
|
|
572
569
|
static getInstance(name, timeout = 3e4) {
|
|
573
570
|
if (_Engine.instances.has(name)) {
|
|
@@ -645,12 +642,6 @@ var Engine = class _Engine {
|
|
|
645
642
|
if (!this.binary) {
|
|
646
643
|
throw new Error("Binary not initialized");
|
|
647
644
|
}
|
|
648
|
-
const isConnectAction = args.includes("connect");
|
|
649
|
-
const isDisconnectAction = args.includes("disconnect");
|
|
650
|
-
const isExecuteAction = args.includes("execute");
|
|
651
|
-
if (isExecuteAction) {
|
|
652
|
-
await this.ensureDaemonConnected();
|
|
653
|
-
}
|
|
654
645
|
return new Promise((resolve5, reject) => {
|
|
655
646
|
const child = spawn(this.binary[binary], [...this.arguments, ...args]);
|
|
656
647
|
let stdoutBuffer = "";
|
|
@@ -668,12 +659,6 @@ var Engine = class _Engine {
|
|
|
668
659
|
isResolved = true;
|
|
669
660
|
clearTimeout(timeoutId);
|
|
670
661
|
resolve5(response);
|
|
671
|
-
if (isConnectAction && response.status === 200) {
|
|
672
|
-
this.isDaemonConnected = true;
|
|
673
|
-
this.isConnecting = false;
|
|
674
|
-
} else if (isDisconnectAction) {
|
|
675
|
-
this.isDaemonConnected = false;
|
|
676
|
-
}
|
|
677
662
|
}
|
|
678
663
|
};
|
|
679
664
|
child.stdout.on("data", (data) => {
|
|
@@ -741,67 +726,6 @@ var Engine = class _Engine {
|
|
|
741
726
|
child.unref();
|
|
742
727
|
});
|
|
743
728
|
}
|
|
744
|
-
async ensureDaemonConnected() {
|
|
745
|
-
if (this.isDaemonConnected) {
|
|
746
|
-
return;
|
|
747
|
-
}
|
|
748
|
-
if (this.isConnecting) {
|
|
749
|
-
while (this.isConnecting) {
|
|
750
|
-
await new Promise((resolve5) => setTimeout(resolve5, 50));
|
|
751
|
-
}
|
|
752
|
-
return;
|
|
753
|
-
}
|
|
754
|
-
this.isConnecting = true;
|
|
755
|
-
try {
|
|
756
|
-
const response = await this.run("query_engine", ["--action", "connect"]);
|
|
757
|
-
if (response.status !== 200) {
|
|
758
|
-
throw new Error(`Failed to connect daemon: ${response.message}`);
|
|
759
|
-
}
|
|
760
|
-
} catch (error) {
|
|
761
|
-
this.isConnecting = false;
|
|
762
|
-
throw error;
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
async disconnect() {
|
|
766
|
-
if (this.isDaemonConnected) {
|
|
767
|
-
await this.run("query_engine", ["--action", "disconnect"]);
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
setupProcessExitHandlers() {
|
|
771
|
-
const gracefulShutdown = async () => {
|
|
772
|
-
if (this.isDaemonConnected) {
|
|
773
|
-
console.log("\u{1F504} Disconnecting daemon before exit...");
|
|
774
|
-
try {
|
|
775
|
-
await this.disconnect();
|
|
776
|
-
console.log("\u2705 Daemon disconnected successfully");
|
|
777
|
-
} catch (error) {
|
|
778
|
-
console.error("\u274C Error disconnecting daemon:", error);
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
};
|
|
782
|
-
process.on("exit", () => {
|
|
783
|
-
});
|
|
784
|
-
process.on("SIGINT", async () => {
|
|
785
|
-
console.log("\n\u{1F6D1} Received SIGINT (Ctrl+C)");
|
|
786
|
-
await gracefulShutdown();
|
|
787
|
-
process.exit(0);
|
|
788
|
-
});
|
|
789
|
-
process.on("SIGTERM", async () => {
|
|
790
|
-
console.log("\u{1F6D1} Received SIGTERM");
|
|
791
|
-
await gracefulShutdown();
|
|
792
|
-
process.exit(0);
|
|
793
|
-
});
|
|
794
|
-
process.on("uncaughtException", async (error) => {
|
|
795
|
-
console.error("\u{1F4A5} Uncaught Exception:", error);
|
|
796
|
-
await gracefulShutdown();
|
|
797
|
-
process.exit(1);
|
|
798
|
-
});
|
|
799
|
-
process.on("unhandledRejection", async (reason, promise) => {
|
|
800
|
-
console.error("\u{1F4A5} Unhandled Rejection at:", promise, "reason:", reason);
|
|
801
|
-
await gracefulShutdown();
|
|
802
|
-
process.exit(1);
|
|
803
|
-
});
|
|
804
|
-
}
|
|
805
729
|
};
|
|
806
730
|
|
|
807
731
|
// src/lib/SqliteExecutor.ts
|