@bob-kit/client 0.0.13 → 0.0.15

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
@@ -4,7 +4,7 @@ type BobQueryParams = {
4
4
  driver: Driver;
5
5
  input: TemplateStringsArray | string;
6
6
  };
7
- export declare const bobQuery: ({ id, driver: { cache, driver }, input, }: BobQueryParams) => Promise<BobQueryResult>;
7
+ export declare const bobQuery: ({ id, driver: { cache }, input, }: BobQueryParams) => Promise<BobQueryResult>;
8
8
  export default function bob(driver: Driver): {
9
9
  query: <A, B = any>(input: TemplateStringsArray | string, ...parameters: B[]) => Promise<BobResult<A>>;
10
10
  cache: (id: string) => <A, B = any>(input: TemplateStringsArray | string, ...parameters: B[]) => Promise<BobResult<A>>;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { WASM } from "./wasm.js";
2
2
  let bobInstance;
3
- export const bobQuery = async ({ id, driver: { cache, driver }, input, }) => {
3
+ export const bobQuery = async ({ id, driver: { cache }, input, }) => {
4
4
  const query = typeof input === "string" ? input : input.join("?");
5
5
  const cacheKey = id ?? query;
6
6
  if (cache) {
@@ -8,27 +8,25 @@ export const bobQuery = async ({ id, driver: { cache, driver }, input, }) => {
8
8
  if (cached)
9
9
  return cache.get(cacheKey);
10
10
  }
11
- const { value, error } = bobInstance.query(query);
12
- if (error)
13
- throw new Error(error);
11
+ const result = bobInstance.query(query);
14
12
  if (cache) {
15
- cache.set(cacheKey, value);
13
+ cache.set(cacheKey, result);
16
14
  }
17
- return value;
15
+ return result;
18
16
  };
19
17
  export default function bob(driver) {
20
18
  bobInstance = new WASM(driver.driver);
21
19
  const execute = async (input, parameters = [], id) => {
22
- const { error, tables, actions } = await bobQuery({ input, driver, id });
20
+ const { error, value } = await bobQuery({ input, driver, id });
23
21
  if (error)
24
22
  return { error };
25
- if (tables) {
26
- for (const table of tables) {
23
+ if (value?.tables) {
24
+ for (const table of value.tables) {
27
25
  await driver.querier(table.trim());
28
26
  }
29
27
  }
30
- if (actions) {
31
- 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)));
32
30
  if (result.length === 1) {
33
31
  return { value: (result[0].length ? result[0] : undefined) };
34
32
  }
package/dist/wasm.d.ts CHANGED
@@ -1,13 +1,6 @@
1
- interface BobResult {
2
- error: string | null;
3
- value: {
4
- tables: string[];
5
- actions: string[];
6
- };
7
- }
1
+ import { BobQueryResult } from "@bob-kit/types";
8
2
  export declare class WASM {
9
3
  private driver;
10
4
  constructor(driver: string);
11
- query(query: string): BobResult;
5
+ query(query: string): BobQueryResult;
12
6
  }
13
- export {};
package/dist/wasm.js CHANGED
@@ -23,12 +23,6 @@ export class WASM {
23
23
  throw new Error("WASM 'bob' is not available or did not return a function.");
24
24
  }
25
25
  const result = fn(query.trim());
26
- if (result.error)
27
- throw new Error(result.error);
28
- const value = JSON.parse(JSON.stringify(result.value));
29
- return {
30
- error: null,
31
- value,
32
- };
26
+ return result;
33
27
  }
34
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bob-kit/client",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
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.2"
31
+ "@bob-kit/types": "^0.0.4"
32
32
  },
33
33
  "scripts": {
34
34
  "build": "tsc && tsc-alias",