@bob-kit/client 0.0.14 → 0.0.16

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/bob.wasm CHANGED
Binary file
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { BobQueryResult, BobResult, Driver } from "@bob-kit/types";
1
+ import { BobQueryResult, BobResult, Driver } from "@bob-kit/types";
2
2
  type BobQueryParams = {
3
3
  id?: string;
4
4
  driver: Driver;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { WASM } from "./wasm.js";
1
+ import { WASM } from "./wasm";
2
2
  let bobInstance;
3
3
  export const bobQuery = async ({ id, driver: { cache }, input, }) => {
4
4
  const query = typeof input === "string" ? input : input.join("?");
@@ -17,16 +17,16 @@ export const bobQuery = async ({ id, driver: { cache }, input, }) => {
17
17
  export default function bob(driver) {
18
18
  bobInstance = new WASM(driver.driver);
19
19
  const execute = async (input, parameters = [], id) => {
20
- const { error, value: { tables, actions }, } = await bobQuery({ input, driver, id });
20
+ const { error, value } = await bobQuery({ input, driver, id });
21
21
  if (error)
22
22
  return { error };
23
- if (tables) {
24
- for (const table of tables) {
23
+ if (value?.tables) {
24
+ for (const table of value.tables) {
25
25
  await driver.querier(table.trim());
26
26
  }
27
27
  }
28
- if (actions) {
29
- const result = await Promise.all(actions.map((action) => driver.querier(action, ...parameters)));
28
+ if (value?.actions) {
29
+ const result = await Promise.all(value.actions.map((action) => driver.querier(action, ...parameters)));
30
30
  if (result.length === 1) {
31
31
  return { value: (result[0].length ? result[0] : undefined) };
32
32
  }
package/dist/install.js CHANGED
@@ -13,13 +13,22 @@ async function downloadFile(url, folder, filename) {
13
13
  await streamPipeline(nodeStream, fs.createWriteStream(filePath));
14
14
  console.log(`Downloaded ${filename} to ${filePath}`);
15
15
  }
16
+ async function getLatestRelease() {
17
+ const apiUrl = "https://api.github.com/repos/bob-object-builder/bob/releases/latest";
18
+ const res = await fetch(apiUrl);
19
+ if (!res.ok)
20
+ throw new Error(`Failed to fetch latest release: ${res.statusText}`);
21
+ return res.json();
22
+ }
16
23
  (async () => {
17
24
  try {
18
- const version = "v0.0.4"; // or dynamic
19
25
  const fileName = "bob.wasm";
20
- const url = `https://github.com/bob-object-builder/bob/releases/download/${version}/${fileName}`;
21
26
  const downloadFolder = "dist";
22
- await downloadFile(url, downloadFolder, fileName);
27
+ const release = await getLatestRelease();
28
+ const asset = release.assets.find((a) => a.name === fileName);
29
+ if (!asset)
30
+ throw new Error(`${fileName} not found in latest release`);
31
+ await downloadFile(asset.browser_download_url, downloadFolder, fileName);
23
32
  }
24
33
  catch (err) {
25
34
  console.error("Error:", err);
package/dist/wasm.d.ts CHANGED
@@ -1,14 +1,6 @@
1
- import { BobError } from "@bob-kit/types/errors";
2
- interface WasmBobResult {
3
- error?: BobError;
4
- value?: {
5
- tables: string[];
6
- actions: string[];
7
- };
8
- }
1
+ import { BobQueryResult } from "@bob-kit/types";
9
2
  export declare class WASM {
10
3
  private driver;
11
4
  constructor(driver: string);
12
- query(query: string): WasmBobResult;
5
+ query(query: string): BobQueryResult;
13
6
  }
14
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bob-kit/client",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "",
@@ -28,7 +28,7 @@
28
28
  "typescript": "5.9.3"
29
29
  },
30
30
  "dependencies": {
31
- "@bob-kit/types": "^0.0.3"
31
+ "@bob-kit/types": "^0.0.4"
32
32
  },
33
33
  "scripts": {
34
34
  "build": "tsc && tsc-alias",