@bob-kit/client 0.0.3 → 0.0.5

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/cache.js CHANGED
@@ -1,10 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MemoryCache = void 0;
4
- class MemoryCache {
5
- constructor() {
6
- this.cache = new Map();
7
- }
1
+ export class MemoryCache {
2
+ cache = new Map();
8
3
  get(id) {
9
4
  return this.cache.get(id);
10
5
  }
@@ -15,4 +10,3 @@ class MemoryCache {
15
10
  return this.cache.set(id, value);
16
11
  }
17
12
  }
18
- exports.MemoryCache = MemoryCache;
package/dist/daemon.js CHANGED
@@ -1,13 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Daemon = void 0;
4
- const node_child_process_1 = require("node:child_process");
5
- class Daemon {
1
+ import { getProgram } from "./get-program.js";
2
+ import { spawn } from "node:child_process";
3
+ export class Daemon {
4
+ process;
5
+ buffer = "";
6
+ queue = [];
6
7
  constructor(driver) {
7
- this.buffer = "";
8
- this.queue = [];
9
- const cwd = process.cwd();
10
- this.process = (0, node_child_process_1.spawn)(`./motor`, ["-d", driver, "--json", "--daemon"], {
8
+ this.process = spawn(`./${getProgram()}`, ["-d", driver, "--json", "--daemon"], {
11
9
  stdio: ["pipe", "pipe", "pipe"],
12
10
  windowsHide: true,
13
11
  });
@@ -48,4 +46,3 @@ class Daemon {
48
46
  return !!this.process && !this.process.killed;
49
47
  }
50
48
  }
51
- exports.Daemon = Daemon;
@@ -0,0 +1 @@
1
+ export declare function getProgram(): string;
@@ -0,0 +1,18 @@
1
+ export function getProgram() {
2
+ const platform = process.platform; // 'win32', 'darwin', 'linux'
3
+ const arch = process.arch; // 'x64', 'arm64', etc.
4
+ let file = "";
5
+ if (platform === "win32") {
6
+ file = "bob-windows-amd64.exe";
7
+ }
8
+ else if (platform === "darwin") {
9
+ file = arch === "arm64" ? "bob-darwin-arm64" : "bob-darwin-amd64";
10
+ }
11
+ else if (platform === "linux") {
12
+ file = arch === "arm64" ? "bob-linux-arm64" : "bob-linux-amd64";
13
+ }
14
+ else {
15
+ throw new Error(`Unsupported platform: ${platform}`);
16
+ }
17
+ return file;
18
+ }
package/dist/index.js CHANGED
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.bobQuery = void 0;
4
- exports.default = bob;
5
- const daemon_js_1 = require("./daemon.js");
1
+ import { Daemon } from "./daemon.js";
6
2
  let daemon;
7
- const bobQuery = async ({ id, driver: { cache, driver }, input, }) => {
8
- daemon = new daemon_js_1.Daemon(driver);
3
+ export const bobQuery = async ({ id, driver: { cache, driver }, input, }) => {
4
+ daemon = new Daemon(driver);
9
5
  const query = typeof input === "string" ? input : input.join("?");
10
6
  const cacheKey = id ?? query;
11
7
  if (cache) {
@@ -26,10 +22,9 @@ const bobQuery = async ({ id, driver: { cache, driver }, input, }) => {
26
22
  }
27
23
  return json;
28
24
  };
29
- exports.bobQuery = bobQuery;
30
- function bob(driver) {
25
+ export default function bob(driver) {
31
26
  const execute = async (input, parameters = [], id) => {
32
- const { error, tables, actions } = await (0, exports.bobQuery)({ input, driver, id });
27
+ const { error, tables, actions } = await bobQuery({ input, driver, id });
33
28
  if (error)
34
29
  return { error };
35
30
  if (tables) {
package/dist/install.js CHANGED
@@ -1,61 +1,9 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- const fs = __importStar(require("fs"));
37
- const path = __importStar(require("path"));
38
- const stream_1 = require("stream");
39
- const util_1 = require("util");
40
- const streamPipeline = (0, util_1.promisify)(stream_1.pipeline);
41
- function detectBobFile() {
42
- const platform = process.platform; // 'win32', 'darwin', 'linux'
43
- const arch = process.arch; // 'x64', 'arm64', etc.
44
- let file = "";
45
- if (platform === "win32") {
46
- file = "bob-windows-amd64.exe";
47
- }
48
- else if (platform === "darwin") {
49
- file = arch === "arm64" ? "bob-darwin-arm64" : "bob-darwin-amd64";
50
- }
51
- else if (platform === "linux") {
52
- file = arch === "arm64" ? "bob-linux-arm64" : "bob-linux-amd64";
53
- }
54
- else {
55
- throw new Error(`Unsupported platform: ${platform}`);
56
- }
57
- return file;
58
- }
1
+ import { getProgram } from "./get-program.js";
2
+ import * as fs from "fs";
3
+ import * as path from "path";
4
+ import { pipeline } from "stream";
5
+ import { promisify } from "util";
6
+ const streamPipeline = promisify(pipeline);
59
7
  async function downloadFile(url, folder, filename) {
60
8
  const res = await fetch(url);
61
9
  if (!res.ok)
@@ -69,10 +17,10 @@ async function downloadFile(url, folder, filename) {
69
17
  (async () => {
70
18
  try {
71
19
  const version = "v0.0.1"; // or dynamic
72
- const fileName = detectBobFile();
20
+ const fileName = getProgram();
73
21
  const url = `https://github.com/bob-object-builder/bob/releases/download/${version}/${fileName}`;
74
22
  const downloadFolder = "dist";
75
- await downloadFile(url, downloadFolder, "motor");
23
+ await downloadFile(url, downloadFolder, fileName);
76
24
  }
77
25
  catch (err) {
78
26
  console.error("Error:", err);
package/dist/motor.exe ADDED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bob-kit/client",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "",