@perspective-dev/client 4.3.0 → 4.4.1

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.
Files changed (35) hide show
  1. package/dist/cdn/perspective.js +2 -2
  2. package/dist/cdn/perspective.js.map +3 -3
  3. package/dist/esm/perspective.inline.js +2 -2
  4. package/dist/esm/perspective.inline.js.map +3 -3
  5. package/dist/esm/perspective.js +2 -2
  6. package/dist/esm/perspective.js.map +3 -3
  7. package/dist/esm/perspective.node.d.ts +10 -0
  8. package/dist/esm/perspective.node.js +99 -12
  9. package/dist/esm/perspective.node.js.map +2 -2
  10. package/dist/esm/ts-rs/JoinOptions.d.ts +9 -0
  11. package/dist/esm/ts-rs/JoinType.d.ts +1 -0
  12. package/dist/esm/virtual_server.d.ts +7 -0
  13. package/dist/esm/virtual_servers/clickhouse.js +1 -1
  14. package/dist/esm/virtual_servers/clickhouse.js.map +3 -3
  15. package/dist/esm/virtual_servers/duckdb.d.ts +4 -0
  16. package/dist/esm/virtual_servers/duckdb.js +1 -1
  17. package/dist/esm/virtual_servers/duckdb.js.map +3 -3
  18. package/dist/wasm/perspective-js.d.ts +41 -5
  19. package/dist/wasm/perspective-js.js +89 -10
  20. package/dist/wasm/perspective-js.wasm +0 -0
  21. package/dist/wasm/perspective-js.wasm.d.ts +8 -5
  22. package/package.json +5 -5
  23. package/src/rust/client.rs +70 -1
  24. package/src/rust/generic_sql_model.rs +16 -0
  25. package/src/rust/lib.rs +4 -0
  26. package/src/rust/utils/errors.rs +4 -0
  27. package/src/rust/utils/futures.rs +4 -0
  28. package/src/rust/view.rs +13 -4
  29. package/src/rust/virtual_server.rs +68 -1
  30. package/src/ts/perspective.node.ts +21 -2
  31. package/src/ts/ts-rs/JoinOptions.ts +7 -0
  32. package/src/ts/ts-rs/JoinType.ts +3 -0
  33. package/src/ts/virtual_server.ts +5 -0
  34. package/src/ts/virtual_servers/clickhouse.ts +2 -13
  35. package/src/ts/virtual_servers/duckdb.ts +18 -64
@@ -35,6 +35,15 @@ export declare function on_hosted_tables_update(cb: () => void): Promise<number>
35
35
  export declare function remove_hosted_tables_update(id: number): Promise<void>;
36
36
  export declare function system_info(): Promise<perspective_client.SystemInfo>;
37
37
  export declare function on_error(callback: Function): Promise<number>;
38
+ /**
39
+ * Create a read-only table from a JOIN of two source tables.
40
+ * @param left - The left source table (a Table instance or a table name string).
41
+ * @param right - The right source table (a Table instance or a table name string).
42
+ * @param on
43
+ * @param options - Optional join configuration: { join_type?: "inner"|"left"|"outer", name?: string }
44
+ * @returns
45
+ */
46
+ export declare function join(left: perspective_client.Table | string, right: perspective_client.Table | string, on: string, options?: perspective_client.JoinOptions): Promise<perspective_client.Table>;
38
47
  /**
39
48
  * Create a table from the global Perspective instance.
40
49
  * @param init_data
@@ -59,6 +68,7 @@ export declare function createMessageHandler(handler: virtual_server.VirtualServ
59
68
  export { perspective_client as wasmModule };
60
69
  declare const _default: {
61
70
  table: typeof table;
71
+ join: typeof join;
62
72
  websocket: typeof websocket;
63
73
  worker: typeof worker;
64
74
  get_hosted_table_names: typeof get_hosted_table_names;
@@ -102,6 +102,40 @@ var Client = class _Client {
102
102
  const ret = wasm.client_handle_response(this.__wbg_ptr, addHeapObject(value));
103
103
  return takeObject(ret);
104
104
  }
105
+ /**
106
+ * Creates a new read-only [`Table`] by performing an INNER JOIN on two
107
+ * source tables. The resulting table is reactive: when either source
108
+ * table is updated, the join is automatically recomputed.
109
+ *
110
+ * # Arguments
111
+ *
112
+ * - `left` - The left source table (a [`Table`] instance or a table name
113
+ * string).
114
+ * - `right` - The right source table (a [`Table`] instance or a table name
115
+ * string).
116
+ * - `on` - The column name to join on. Must exist in both tables with the
117
+ * same type.
118
+ * - `options` - Optional join configuration: `{ join_type?: "inner" |
119
+ * "left" | "outer", name?: string }`.
120
+ *
121
+ * # JavaScript Examples
122
+ *
123
+ * ```javascript
124
+ * const joined = await client.join(orders_table, products_table, "Product ID", { join_type: "left" });
125
+ * const joined = await client.join("orders", "products", "Product ID", { join_type: "left" });
126
+ * ```
127
+ * @param {any} left
128
+ * @param {any} right
129
+ * @param {string} on
130
+ * @param {JoinOptions | null} [options]
131
+ * @returns {Promise<Table>}
132
+ */
133
+ join(left, right, on, options) {
134
+ const ptr0 = passStringToWasm0(on, wasm.__wbindgen_export, wasm.__wbindgen_export2);
135
+ const len0 = WASM_VECTOR_LEN;
136
+ const ret = wasm.client_join(this.__wbg_ptr, addHeapObject(left), addHeapObject(right), ptr0, len0, isLikeNone(options) ? 0 : addHeapObject(options));
137
+ return takeObject(ret);
138
+ }
105
139
  /**
106
140
  * @param {Function} send_request
107
141
  * @param {Function | null} [close]
@@ -566,6 +600,37 @@ var GenericSQLVirtualServerModel = class {
566
600
  wasm.__wbindgen_add_to_stack_pointer(16);
567
601
  }
568
602
  }
603
+ /**
604
+ * Returns the SQL query to get the min and max values of a column.
605
+ * @param {string} view_id
606
+ * @param {string} column_name
607
+ * @param {any} config
608
+ * @returns {string}
609
+ */
610
+ viewGetMinMax(view_id, column_name, config) {
611
+ try {
612
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
613
+ const ptr0 = passStringToWasm0(view_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
614
+ const len0 = WASM_VECTOR_LEN;
615
+ const ptr1 = passStringToWasm0(column_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
616
+ const len1 = WASM_VECTOR_LEN;
617
+ wasm.genericsqlvirtualservermodel_viewGetMinMax(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, addHeapObject(config));
618
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
619
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
620
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
621
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
622
+ if (r3) {
623
+ throw takeObject(r2);
624
+ }
625
+ var v3 = getCachedStringFromWasm0(r0, r1);
626
+ if (r0 !== 0) {
627
+ wasm.__wbindgen_export4(r0, r1, 1);
628
+ }
629
+ return v3;
630
+ } finally {
631
+ wasm.__wbindgen_add_to_stack_pointer(16);
632
+ }
633
+ }
569
634
  /**
570
635
  * Returns the SQL query to describe a view's schema.
571
636
  * @param {string} view_id
@@ -1326,6 +1391,22 @@ var VirtualDataSlice = class _VirtualDataSlice {
1326
1391
  const ptr = this.__destroy_into_raw();
1327
1392
  wasm.__wbg_virtualdataslice_free(ptr, 0);
1328
1393
  }
1394
+ /**
1395
+ * @param {Uint8Array} ipc
1396
+ */
1397
+ fromArrowIpc(ipc) {
1398
+ try {
1399
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1400
+ wasm.virtualdataslice_fromArrowIpc(retptr, this.__wbg_ptr, addHeapObject(ipc));
1401
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1402
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1403
+ if (r1) {
1404
+ throw takeObject(r0);
1405
+ }
1406
+ } finally {
1407
+ wasm.__wbindgen_add_to_stack_pointer(16);
1408
+ }
1409
+ }
1329
1410
  /**
1330
1411
  * @param {ViewConfigUpdate} config
1331
1412
  */
@@ -1867,7 +1948,7 @@ function __wbg_get_imports() {
1867
1948
  const a = state0.a;
1868
1949
  state0.a = 0;
1869
1950
  try {
1870
- return __wasm_bindgen_func_elem_5713(a, state0.b, arg02, arg12);
1951
+ return __wasm_bindgen_func_elem_10784(a, state0.b, arg02, arg12);
1871
1952
  } finally {
1872
1953
  state0.a = a;
1873
1954
  }
@@ -2027,11 +2108,11 @@ function __wbg_get_imports() {
2027
2108
  console.warn(getObject(arg0));
2028
2109
  },
2029
2110
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
2030
- const ret = makeClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_813, __wasm_bindgen_func_elem_1689);
2111
+ const ret = makeClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_838, __wasm_bindgen_func_elem_1727);
2031
2112
  return addHeapObject(ret);
2032
2113
  },
2033
2114
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
2034
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3857, __wasm_bindgen_func_elem_3874);
2115
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_3915, __wasm_bindgen_func_elem_3932);
2035
2116
  return addHeapObject(ret);
2036
2117
  },
2037
2118
  __wbindgen_cast_0000000000000003: function(arg0) {
@@ -2080,15 +2161,15 @@ function __wbg_get_imports() {
2080
2161
  "./perspective-js.wasm_bg.js": import0
2081
2162
  };
2082
2163
  }
2083
- function __wasm_bindgen_func_elem_1689(arg0, arg1) {
2084
- const ret = wasm.__wasm_bindgen_func_elem_1689(arg0, arg1);
2164
+ function __wasm_bindgen_func_elem_1727(arg0, arg1) {
2165
+ const ret = wasm.__wasm_bindgen_func_elem_1727(arg0, arg1);
2085
2166
  return takeObject(ret);
2086
2167
  }
2087
- function __wasm_bindgen_func_elem_3874(arg0, arg1, arg2) {
2088
- wasm.__wasm_bindgen_func_elem_3874(arg0, arg1, addHeapObject(arg2));
2168
+ function __wasm_bindgen_func_elem_3932(arg0, arg1, arg2) {
2169
+ wasm.__wasm_bindgen_func_elem_3932(arg0, arg1, addHeapObject(arg2));
2089
2170
  }
2090
- function __wasm_bindgen_func_elem_5713(arg0, arg1, arg2, arg3) {
2091
- wasm.__wasm_bindgen_func_elem_5713(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
2171
+ function __wasm_bindgen_func_elem_10784(arg0, arg1, arg2, arg3) {
2172
+ wasm.__wasm_bindgen_func_elem_10784(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
2092
2173
  }
2093
2174
  var ClientFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
2094
2175
  }, unregister: () => {
@@ -2933,7 +3014,8 @@ var CONTENT_TYPES = {
2933
3014
  ".json": "application/json",
2934
3015
  ".arrow": "arraybuffer",
2935
3016
  ".feather": "arraybuffer",
2936
- ".wasm": "application/wasm"
3017
+ ".wasm": "application/wasm",
3018
+ ".svg": "image/svg+xml"
2937
3019
  };
2938
3020
  async function cwd_static_file_handler(request, response, assets = ["./"], { debug = true } = {}) {
2939
3021
  let url2 = request.url?.split(/[\?\#]/)[0].replace(/@[\^~]?\d+.[\d\*]*.[\d\*]*/, "") || "/";
@@ -2956,9 +3038,9 @@ async function cwd_static_file_handler(request, response, assets = ["./"], { deb
2956
3038
  "Access-Control-Allow-Origin": "*"
2957
3039
  });
2958
3040
  if (extname === ".arrow" || extname === ".feather") {
2959
- response.end(content, "utf-8");
3041
+ response.end(content, "utf8");
2960
3042
  } else {
2961
- response.end(content);
3043
+ response.end(content, "utf8");
2962
3044
  }
2963
3045
  return;
2964
3046
  }
@@ -3057,6 +3139,9 @@ function system_info() {
3057
3139
  function on_error(callback) {
3058
3140
  return SYNC_CLIENT.on_error(callback);
3059
3141
  }
3142
+ function join(left, right, on, options) {
3143
+ return SYNC_CLIENT.join(left, right, on, options);
3144
+ }
3060
3145
  function table(init_data, options) {
3061
3146
  return SYNC_CLIENT.table(init_data, options);
3062
3147
  }
@@ -3102,6 +3187,7 @@ function createMessageHandler2(handler) {
3102
3187
  }
3103
3188
  var perspective_node_default = {
3104
3189
  table,
3190
+ join,
3105
3191
  websocket: websocket2,
3106
3192
  worker,
3107
3193
  get_hosted_table_names,
@@ -3124,6 +3210,7 @@ export {
3124
3210
  cwd_static_file_handler,
3125
3211
  perspective_node_default as default,
3126
3212
  get_hosted_table_names,
3213
+ join,
3127
3214
  make_client,
3128
3215
  make_session,
3129
3216
  on_error,