@dbcube/core 1.0.57 → 1.0.58

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.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 isDaemonConnected;
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: string[]): Promise<ResponseEngine>;
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 isDaemonConnected;
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: string[]): Promise<ResponseEngine>;
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
- static instances = /* @__PURE__ */ new Map();
554
- name = "";
553
+ name;
555
554
  config;
556
555
  arguments;
557
556
  binary = null;
558
- timeout = 3e4;
559
- isDaemonConnected = false;
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,17 +659,10 @@ 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) => {
680
665
  stdoutBuffer += data.toString();
681
- console.log(stdoutBuffer);
682
666
  const match = stdoutBuffer.match(/PROCESS_RESPONSE:(\{.*\})/);
683
667
  if (match) {
684
668
  try {
@@ -699,7 +683,6 @@ var Engine = class _Engine {
699
683
  });
700
684
  child.stderr.on("data", (data) => {
701
685
  stderrBuffer += data.toString();
702
- console.log(stderrBuffer);
703
686
  const match = stderrBuffer.match(/PROCESS_RESPONSE:(\{.*\})/);
704
687
  if (match) {
705
688
  try {
@@ -741,67 +724,6 @@ var Engine = class _Engine {
741
724
  child.unref();
742
725
  });
743
726
  }
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
727
  };
806
728
 
807
729
  // src/lib/SqliteExecutor.ts