@bob-kit/client 0.0.5 → 0.0.35
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 +8 -2
- package/dist/daemon.js +10 -7
- package/dist/index.js +10 -5
- package/dist/install.js +60 -8
- package/package.json +1 -1
- package/dist/get-program.d.ts +0 -1
- package/dist/get-program.js +0 -18
- package/dist/motor.exe +0 -0
package/dist/cache.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
+
}
|
|
3
8
|
get(id) {
|
|
4
9
|
return this.cache.get(id);
|
|
5
10
|
}
|
|
@@ -10,3 +15,4 @@ export class MemoryCache {
|
|
|
10
15
|
return this.cache.set(id, value);
|
|
11
16
|
}
|
|
12
17
|
}
|
|
18
|
+
exports.MemoryCache = MemoryCache;
|
package/dist/daemon.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
queue = [];
|
|
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 {
|
|
7
6
|
constructor(driver) {
|
|
8
|
-
this.
|
|
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"], {
|
|
9
11
|
stdio: ["pipe", "pipe", "pipe"],
|
|
10
12
|
windowsHide: true,
|
|
11
13
|
});
|
|
@@ -46,3 +48,4 @@ export class Daemon {
|
|
|
46
48
|
return !!this.process && !this.process.killed;
|
|
47
49
|
}
|
|
48
50
|
}
|
|
51
|
+
exports.Daemon = Daemon;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
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");
|
|
2
6
|
let daemon;
|
|
3
|
-
|
|
4
|
-
daemon = new Daemon(driver);
|
|
7
|
+
const bobQuery = async ({ id, driver: { cache, driver }, input, }) => {
|
|
8
|
+
daemon = new daemon_js_1.Daemon(driver);
|
|
5
9
|
const query = typeof input === "string" ? input : input.join("?");
|
|
6
10
|
const cacheKey = id ?? query;
|
|
7
11
|
if (cache) {
|
|
@@ -22,9 +26,10 @@ export const bobQuery = async ({ id, driver: { cache, driver }, input, }) => {
|
|
|
22
26
|
}
|
|
23
27
|
return json;
|
|
24
28
|
};
|
|
25
|
-
|
|
29
|
+
exports.bobQuery = bobQuery;
|
|
30
|
+
function bob(driver) {
|
|
26
31
|
const execute = async (input, parameters = [], id) => {
|
|
27
|
-
const { error, tables, actions } = await bobQuery({ input, driver, id });
|
|
32
|
+
const { error, tables, actions } = await (0, exports.bobQuery)({ input, driver, id });
|
|
28
33
|
if (error)
|
|
29
34
|
return { error };
|
|
30
35
|
if (tables) {
|
package/dist/install.js
CHANGED
|
@@ -1,9 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
+
}
|
|
7
59
|
async function downloadFile(url, folder, filename) {
|
|
8
60
|
const res = await fetch(url);
|
|
9
61
|
if (!res.ok)
|
|
@@ -17,10 +69,10 @@ async function downloadFile(url, folder, filename) {
|
|
|
17
69
|
(async () => {
|
|
18
70
|
try {
|
|
19
71
|
const version = "v0.0.1"; // or dynamic
|
|
20
|
-
const fileName =
|
|
72
|
+
const fileName = detectBobFile();
|
|
21
73
|
const url = `https://github.com/bob-object-builder/bob/releases/download/${version}/${fileName}`;
|
|
22
74
|
const downloadFolder = "dist";
|
|
23
|
-
await downloadFile(url, downloadFolder,
|
|
75
|
+
await downloadFile(url, downloadFolder, "motor");
|
|
24
76
|
}
|
|
25
77
|
catch (err) {
|
|
26
78
|
console.error("Error:", err);
|
package/package.json
CHANGED
package/dist/get-program.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getProgram(): string;
|
package/dist/get-program.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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/motor.exe
DELETED
|
Binary file
|