@perspective-dev/client 4.0.0

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 (91) hide show
  1. package/LICENSE.md +193 -0
  2. package/README.md +3 -0
  3. package/dist/cdn/perspective-server.worker.js +2 -0
  4. package/dist/cdn/perspective-server.worker.js.map +7 -0
  5. package/dist/cdn/perspective.js +3 -0
  6. package/dist/cdn/perspective.js.map +7 -0
  7. package/dist/esm/perspective-server.worker.d.ts +1 -0
  8. package/dist/esm/perspective.browser.d.ts +14 -0
  9. package/dist/esm/perspective.inline.js +3 -0
  10. package/dist/esm/perspective.inline.js.map +7 -0
  11. package/dist/esm/perspective.js +3 -0
  12. package/dist/esm/perspective.js.map +7 -0
  13. package/dist/esm/perspective.node.d.ts +60 -0
  14. package/dist/esm/perspective.node.js +2431 -0
  15. package/dist/esm/perspective.node.js.map +7 -0
  16. package/dist/esm/ts-rs/Aggregate.d.ts +1 -0
  17. package/dist/esm/ts-rs/ColumnWindow.d.ts +4 -0
  18. package/dist/esm/ts-rs/DeleteOptions.d.ts +6 -0
  19. package/dist/esm/ts-rs/Expressions.d.ts +3 -0
  20. package/dist/esm/ts-rs/Filter.d.ts +2 -0
  21. package/dist/esm/ts-rs/FilterReducer.d.ts +1 -0
  22. package/dist/esm/ts-rs/FilterTerm.d.ts +2 -0
  23. package/dist/esm/ts-rs/OnUpdateMode.d.ts +9 -0
  24. package/dist/esm/ts-rs/OnUpdateOptions.d.ts +7 -0
  25. package/dist/esm/ts-rs/Scalar.d.ts +5 -0
  26. package/dist/esm/ts-rs/Sort.d.ts +2 -0
  27. package/dist/esm/ts-rs/SortDir.d.ts +1 -0
  28. package/dist/esm/ts-rs/SystemInfo.d.ts +40 -0
  29. package/dist/esm/ts-rs/TableInitOptions.d.ts +22 -0
  30. package/dist/esm/ts-rs/TableReadFormat.d.ts +7 -0
  31. package/dist/esm/ts-rs/UpdateOptions.d.ts +8 -0
  32. package/dist/esm/ts-rs/ViewConfigUpdate.d.ts +90 -0
  33. package/dist/esm/ts-rs/ViewOnUpdateResp.d.ts +4 -0
  34. package/dist/esm/ts-rs/ViewWindow.d.ts +23 -0
  35. package/dist/esm/wasm/browser.d.ts +21 -0
  36. package/dist/esm/wasm/decompress.d.ts +1 -0
  37. package/dist/esm/wasm/emscripten_api.d.ts +5 -0
  38. package/dist/esm/wasm/engine.d.ts +40 -0
  39. package/dist/esm/wasm/perspective-server.poly.d.ts +1 -0
  40. package/dist/esm/websocket.d.ts +4 -0
  41. package/dist/wasm/perspective-js.d.ts +712 -0
  42. package/dist/wasm/perspective-js.js +1934 -0
  43. package/dist/wasm/perspective-js.wasm +0 -0
  44. package/dist/wasm/perspective-js.wasm.d.ts +75 -0
  45. package/package.json +68 -0
  46. package/src/rust/client.rs +483 -0
  47. package/src/rust/lib.rs +70 -0
  48. package/src/rust/table.rs +364 -0
  49. package/src/rust/table_data.rs +159 -0
  50. package/src/rust/utils/browser.rs +39 -0
  51. package/src/rust/utils/console_logger.rs +236 -0
  52. package/src/rust/utils/errors.rs +288 -0
  53. package/src/rust/utils/futures.rs +174 -0
  54. package/src/rust/utils/json.rs +252 -0
  55. package/src/rust/utils/local_poll_loop.rs +63 -0
  56. package/src/rust/utils/mod.rs +32 -0
  57. package/src/rust/utils/serde.rs +46 -0
  58. package/src/rust/utils/trace_allocator.rs +98 -0
  59. package/src/rust/view.rs +355 -0
  60. package/src/ts/perspective-server.worker.ts +54 -0
  61. package/src/ts/perspective.browser.ts +132 -0
  62. package/src/ts/perspective.cdn.ts +22 -0
  63. package/src/ts/perspective.inline.ts +27 -0
  64. package/src/ts/perspective.node.ts +315 -0
  65. package/src/ts/ts-rs/Aggregate.ts +3 -0
  66. package/src/ts/ts-rs/ColumnWindow.ts +3 -0
  67. package/src/ts/ts-rs/DeleteOptions.ts +6 -0
  68. package/src/ts/ts-rs/Expressions.ts +3 -0
  69. package/src/ts/ts-rs/Filter.ts +4 -0
  70. package/src/ts/ts-rs/FilterReducer.ts +3 -0
  71. package/src/ts/ts-rs/FilterTerm.ts +4 -0
  72. package/src/ts/ts-rs/OnUpdateData.ts +8 -0
  73. package/src/ts/ts-rs/OnUpdateMode.ts +11 -0
  74. package/src/ts/ts-rs/OnUpdateOptions.ts +7 -0
  75. package/src/ts/ts-rs/Scalar.ts +7 -0
  76. package/src/ts/ts-rs/Sort.ts +4 -0
  77. package/src/ts/ts-rs/SortDir.ts +3 -0
  78. package/src/ts/ts-rs/SystemInfo.ts +41 -0
  79. package/src/ts/ts-rs/TableInitOptions.ts +21 -0
  80. package/src/ts/ts-rs/TableReadFormat.ts +9 -0
  81. package/src/ts/ts-rs/UpdateOptions.ts +7 -0
  82. package/src/ts/ts-rs/ViewConfigUpdate.ts +87 -0
  83. package/src/ts/ts-rs/ViewOnUpdateResp.ts +3 -0
  84. package/src/ts/ts-rs/ViewWindow.ts +17 -0
  85. package/src/ts/wasm/browser.ts +123 -0
  86. package/src/ts/wasm/decompress.ts +64 -0
  87. package/src/ts/wasm/emscripten_api.ts +63 -0
  88. package/src/ts/wasm/engine.ts +271 -0
  89. package/src/ts/wasm/perspective-server.poly.ts +244 -0
  90. package/src/ts/websocket.ts +95 -0
  91. package/tsconfig.json +20 -0
@@ -0,0 +1,712 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export function init(): void;
4
+
5
+ export type * from "../../src/ts/ts-rs/ViewWindow.d.ts";
6
+ export type * from "../../src/ts/ts-rs/ColumnWindow.d.ts";
7
+ export type * from "../../src/ts/ts-rs/TableInitOptions.d.ts";
8
+ export type * from "../../src/ts/ts-rs/ViewConfigUpdate.d.ts";
9
+ export type * from "../../src/ts/ts-rs/ViewOnUpdateResp.d.ts";
10
+ export type * from "../../src/ts/ts-rs/OnUpdateOptions.d.ts";
11
+ export type * from "../../src/ts/ts-rs/UpdateOptions.d.ts";
12
+ export type * from "../../src/ts/ts-rs/DeleteOptions.d.ts";
13
+ export type * from "../../src/ts/ts-rs/SystemInfo.d.ts";
14
+
15
+ import type {ColumnWindow} from "../../src/ts/ts-rs/ColumnWindow.d.ts";
16
+ import type {ViewWindow} from "../../src/ts/ts-rs/ViewWindow.d.ts";
17
+ import type {TableInitOptions} from "../../src/ts/ts-rs/TableInitOptions.d.ts";
18
+ import type {ViewConfigUpdate} from "../../src/ts/ts-rs/ViewConfigUpdate.d.ts";
19
+ import type * as on_update_args from "../../src/ts/ts-rs/ViewOnUpdateResp.d.ts";
20
+ import type {OnUpdateOptions} from "../../src/ts/ts-rs/OnUpdateOptions.d.ts";
21
+ import type {UpdateOptions} from "../../src/ts/ts-rs/UpdateOptions.d.ts";
22
+ import type {DeleteOptions} from "../../src/ts/ts-rs/DeleteOptions.d.ts";
23
+ import type {SystemInfo} from "../../src/ts/ts-rs/SystemInfo.d.ts";
24
+
25
+
26
+ /**
27
+ * An instance of a [`Client`] is a connection to a single
28
+ * `perspective_server::Server`, whether locally in-memory or remote over some
29
+ * transport like a WebSocket.
30
+ *
31
+ * The browser and node.js libraries both support the `websocket(url)`
32
+ * constructor, which connects to a remote `perspective_server::Server`
33
+ * instance over a WebSocket transport.
34
+ *
35
+ * In the browser, the `worker()` constructor creates a new Web Worker
36
+ * `perspective_server::Server` and returns a [`Client`] connected to it.
37
+ *
38
+ * In node.js, a pre-instantied [`Client`] connected synhronously to a global
39
+ * singleton `perspective_server::Server` is the default module export.
40
+ *
41
+ * # JavaScript Examples
42
+ *
43
+ * Create a Web Worker `perspective_server::Server` in the browser and return a
44
+ * [`Client`] instance connected for it:
45
+ *
46
+ * ```javascript
47
+ * import perspective from "@perspective-dev/client";
48
+ * const client = await perspective.worker();
49
+ * ```
50
+ *
51
+ * Create a WebSocket connection to a remote `perspective_server::Server`:
52
+ *
53
+ * ```javascript
54
+ * import perspective from "@perspective-dev/client";
55
+ * const client = await perspective.websocket("ws://locahost:8080/ws");
56
+ * ```
57
+ *
58
+ * Access the synchronous client in node.js:
59
+ *
60
+ * ```javascript
61
+ * import { default as client } from "@perspective-dev/client";
62
+ * ```
63
+ */
64
+ export class Client {
65
+ free(): void;
66
+ __getClassname(): string;
67
+ constructor(send_request: Function, close?: Function | null);
68
+ new_proxy_session(on_response: Function): ProxySession;
69
+ handle_response(value: any): Promise<void>;
70
+ handle_error(error: string, reconnect?: Function | null): Promise<void>;
71
+ on_error(callback: Function): Promise<number>;
72
+ /**
73
+ * Creates a new [`Table`] from either a _schema_ or _data_.
74
+ *
75
+ * The [`Client::table`] factory function can be initialized with either a
76
+ * _schema_ (see [`Table::schema`]), or data in one of these formats:
77
+ *
78
+ * - Apache Arrow
79
+ * - CSV
80
+ * - JSON row-oriented
81
+ * - JSON column-oriented
82
+ * - NDJSON
83
+ *
84
+ * When instantiated with _data_, the schema is inferred from this data.
85
+ * While this is convenient, inferrence is sometimes imperfect e.g.
86
+ * when the input is empty, null or ambiguous. For these cases,
87
+ * [`Client::table`] can first be instantiated with a explicit schema.
88
+ *
89
+ * When instantiated with a _schema_, the resulting [`Table`] is empty but
90
+ * with known column names and column types. When subsqeuently
91
+ * populated with [`Table::update`], these columns will be _coerced_ to
92
+ * the schema's type. This behavior can be useful when
93
+ * [`Client::table`]'s column type inferences doesn't work.
94
+ *
95
+ * The resulting [`Table`] is _virtual_, and invoking its methods
96
+ * dispatches events to the `perspective_server::Server` this
97
+ * [`Client`] connects to, where the data is stored and all calculation
98
+ * occurs.
99
+ *
100
+ * # Arguments
101
+ *
102
+ * - `arg` - Either _schema_ or initialization _data_.
103
+ * - `options` - Optional configuration which provides one of:
104
+ * - `limit` - The max number of rows the resulting [`Table`] can
105
+ * store.
106
+ * - `index` - The column name to use as an _index_ column. If this
107
+ * `Table` is being instantiated by _data_, this column name must be
108
+ * present in the data.
109
+ * - `name` - The name of the table. This will be generated if it is
110
+ * not provided.
111
+ * - `format` - The explicit format of the input data, can be one of
112
+ * `"json"`, `"columns"`, `"csv"` or `"arrow"`. This overrides
113
+ * language-specific type dispatch behavior, which allows stringified
114
+ * and byte array alternative inputs.
115
+ *
116
+ * # JavaScript Examples
117
+ *
118
+ * Load a CSV from a `string`:
119
+ *
120
+ * ```javascript
121
+ * const table = await client.table("x,y\n1,2\n3,4");
122
+ * ```
123
+ *
124
+ * Load an Arrow from an `ArrayBuffer`:
125
+ *
126
+ * ```javascript
127
+ * import * as fs from "node:fs/promises";
128
+ * const table2 = await client.table(await fs.readFile("superstore.arrow"));
129
+ * ```
130
+ *
131
+ * Load a CSV from a `UInt8Array` (the default for this type is Arrow)
132
+ * using a format override:
133
+ *
134
+ * ```javascript
135
+ * const enc = new TextEncoder();
136
+ * const table = await client.table(enc.encode("x,y\n1,2\n3,4"), {
137
+ * format: "csv",
138
+ * });
139
+ * ```
140
+ *
141
+ * Create a table with an `index`:
142
+ *
143
+ * ```javascript
144
+ * const table = await client.table(data, { index: "Row ID" });
145
+ * ```
146
+ */
147
+ table(value: string | ArrayBuffer | Record<string, unknown[]> | Record<string, unknown>[], options?: TableInitOptions | null): Promise<Table>;
148
+ /**
149
+ * Terminates this [`Client`], cleaning up any [`crate::View`] handles the
150
+ * [`Client`] has open as well as its callbacks.
151
+ */
152
+ terminate(): any;
153
+ /**
154
+ * Opens a [`Table`] that is hosted on the `perspective_server::Server`
155
+ * that is connected to this [`Client`].
156
+ *
157
+ * The `name` property of [`TableInitOptions`] is used to identify each
158
+ * [`Table`]. [`Table`] `name`s can be looked up for each [`Client`]
159
+ * via [`Client::get_hosted_table_names`].
160
+ *
161
+ * # JavaScript Examples
162
+ *
163
+ * Get a virtual [`Table`] named "table_one" from this [`Client`]
164
+ *
165
+ * ```javascript
166
+ * const tables = await client.open_table("table_one");
167
+ * ```
168
+ */
169
+ open_table(entity_id: string): Promise<Table>;
170
+ /**
171
+ * Retrieves the names of all tables that this client has access to.
172
+ *
173
+ * `name` is a string identifier unique to the [`Table`] (per [`Client`]),
174
+ * which can be used in conjunction with [`Client::open_table`] to get
175
+ * a [`Table`] instance without the use of [`Client::table`]
176
+ * constructor directly (e.g., one created by another [`Client`]).
177
+ *
178
+ * # JavaScript Examples
179
+ *
180
+ * ```javascript
181
+ * const tables = await client.get_hosted_table_names();
182
+ * ```
183
+ */
184
+ get_hosted_table_names(): Promise<any>;
185
+ /**
186
+ * Register a callback which is invoked whenever [`Client::table`] (on this
187
+ * [`Client`]) or [`Table::delete`] (on a [`Table`] belinging to this
188
+ * [`Client`]) are called.
189
+ */
190
+ on_hosted_tables_update(on_update_js: Function): Promise<number>;
191
+ /**
192
+ * Remove a callback previously registered via
193
+ * `Client::on_hosted_tables_update`.
194
+ */
195
+ remove_hosted_tables_update(update_id: number): Promise<void>;
196
+ /**
197
+ * Provides the [`SystemInfo`] struct, implementation-specific metadata
198
+ * about the [`perspective_server::Server`] runtime such as Memory and
199
+ * CPU usage.
200
+ *
201
+ * For WebAssembly servers, this method includes the WebAssembly heap size.
202
+ *
203
+ * # JavaScript Examples
204
+ *
205
+ * ```javascript
206
+ * const info = await client.system_info();
207
+ * ```
208
+ */
209
+ system_info(): Promise<SystemInfo>;
210
+ }
211
+ export class ProxySession {
212
+ free(): void;
213
+ constructor(client: Client, on_response: Function);
214
+ handle_request(value: any): Promise<void>;
215
+ close(): Promise<void>;
216
+ }
217
+ export class Table {
218
+ private constructor();
219
+ free(): void;
220
+ __getClassname(): string;
221
+ /**
222
+ * Returns the name of the index column for the table.
223
+ *
224
+ * # JavaScript Examples
225
+ *
226
+ * ```javascript
227
+ * const table = await client.table("x,y\n1,2\n3,4", { index: "x" });
228
+ * const index = table.get_index(); // "x"
229
+ * ```
230
+ */
231
+ get_index(): Promise<string | undefined>;
232
+ /**
233
+ * Get a copy of the [`Client`] this [`Table`] came from.
234
+ */
235
+ get_client(): Promise<Client>;
236
+ /**
237
+ * Returns the user-specified name for this table, or the auto-generated
238
+ * name if a name was not specified when the table was created.
239
+ */
240
+ get_name(): Promise<string>;
241
+ /**
242
+ * Returns the user-specified row limit for this table.
243
+ */
244
+ get_limit(): Promise<number | undefined>;
245
+ /**
246
+ * Removes all the rows in the [`Table`], but preserves everything else
247
+ * including the schema, index, and any callbacks or registered
248
+ * [`View`] instances.
249
+ *
250
+ * Calling [`Table::clear`], like [`Table::update`] and [`Table::remove`],
251
+ * will trigger an update event to any registered listeners via
252
+ * [`View::on_update`].
253
+ */
254
+ clear(): Promise<void>;
255
+ /**
256
+ * Delete this [`Table`] and cleans up associated resources.
257
+ *
258
+ * [`Table`]s do not stop consuming resources or processing updates when
259
+ * they are garbage collected in their host language - you must call
260
+ * this method to reclaim these.
261
+ *
262
+ * # Arguments
263
+ *
264
+ * - `options` An options dictionary.
265
+ * - `lazy` Whether to delete this [`Table`] _lazily_. When false (the
266
+ * default), the delete will occur immediately, assuming it has no
267
+ * [`View`] instances registered to it (which must be deleted first,
268
+ * otherwise this method will throw an error). When true, the
269
+ * [`Table`] will only be marked for deltion once its [`View`]
270
+ * dependency count reaches 0.
271
+ *
272
+ * # JavaScript Examples
273
+ *
274
+ * ```javascript
275
+ * const table = await client.table("x,y\n1,2\n3,4");
276
+ *
277
+ * // ...
278
+ *
279
+ * await table.delete({ lazy: true });
280
+ * ```
281
+ */
282
+ delete(options?: DeleteOptions | null): Promise<void>;
283
+ /**
284
+ * Returns the number of rows in a [`Table`].
285
+ */
286
+ size(): Promise<number>;
287
+ /**
288
+ * Returns a table's [`Schema`], a mapping of column names to column types.
289
+ *
290
+ * The mapping of a [`Table`]'s column names to data types is referred to
291
+ * as a [`Schema`]. Each column has a unique name and a data type, one
292
+ * of:
293
+ *
294
+ * - `"boolean"` - A boolean type
295
+ * - `"date"` - A timesonze-agnostic date type (month/day/year)
296
+ * - `"datetime"` - A millisecond-precision datetime type in the UTC
297
+ * timezone
298
+ * - `"float"` - A 64 bit float
299
+ * - `"integer"` - A signed 32 bit integer (the integer type supported by
300
+ * JavaScript)
301
+ * - `"string"` - A [`String`] data type (encoded internally as a
302
+ * _dictionary_)
303
+ *
304
+ * Note that all [`Table`] columns are _nullable_, regardless of the data
305
+ * type.
306
+ */
307
+ schema(): Promise<any>;
308
+ /**
309
+ * Returns the column names of this [`Table`] in "natural" order (the
310
+ * ordering implied by the input format).
311
+ *
312
+ * # JavaScript Examples
313
+ *
314
+ * ```javascript
315
+ * const columns = await table.columns();
316
+ * ```
317
+ */
318
+ columns(): Promise<any>;
319
+ /**
320
+ * Create a unique channel ID on this [`Table`], which allows
321
+ * `View::on_update` callback calls to be associated with the
322
+ * `Table::update` which caused them.
323
+ */
324
+ make_port(): Promise<number>;
325
+ /**
326
+ * Register a callback which is called exactly once, when this [`Table`] is
327
+ * deleted with the [`Table::delete`] method.
328
+ *
329
+ * [`Table::on_delete`] resolves when the subscription message is sent, not
330
+ * when the _delete_ event occurs.
331
+ */
332
+ on_delete(on_delete: Function): Promise<any>;
333
+ /**
334
+ * Removes a listener with a given ID, as returned by a previous call to
335
+ * [`Table::on_delete`].
336
+ */
337
+ remove_delete(callback_id: number): Promise<any>;
338
+ /**
339
+ * Removes rows from this [`Table`] with the `index` column values
340
+ * supplied.
341
+ *
342
+ * # Arguments
343
+ *
344
+ * - `indices` - A list of `index` column values for rows that should be
345
+ * removed.
346
+ *
347
+ * # JavaScript Examples
348
+ *
349
+ * ```javascript
350
+ * await table.remove([1, 2, 3]);
351
+ * ```
352
+ */
353
+ remove(value: any, options?: UpdateOptions | null): Promise<void>;
354
+ /**
355
+ * Replace all rows in this [`Table`] with the input data, coerced to this
356
+ * [`Table`]'s existing [`perspective_client::Schema`], notifying any
357
+ * derived [`View`] and [`View::on_update`] callbacks.
358
+ *
359
+ * Calling [`Table::replace`] is an easy way to replace _all_ the data in a
360
+ * [`Table`] without losing any derived [`View`] instances or
361
+ * [`View::on_update`] callbacks. [`Table::replace`] does _not_ infer
362
+ * data types like [`Client::table`] does, rather it _coerces_ input
363
+ * data to the `Schema` like [`Table::update`]. If you need a [`Table`]
364
+ * with a different `Schema`, you must create a new one.
365
+ *
366
+ * # JavaScript Examples
367
+ *
368
+ * ```javascript
369
+ * await table.replace("x,y\n1,2");
370
+ * ```
371
+ */
372
+ replace(input: any, options?: UpdateOptions | null): Promise<void>;
373
+ /**
374
+ * Updates the rows of this table and any derived [`View`] instances.
375
+ *
376
+ * Calling [`Table::update`] will trigger the [`View::on_update`] callbacks
377
+ * register to derived [`View`], and the call itself will not resolve until
378
+ * _all_ derived [`View`]'s are notified.
379
+ *
380
+ * When updating a [`Table`] with an `index`, [`Table::update`] supports
381
+ * partial updates, by omitting columns from the update data.
382
+ *
383
+ * # Arguments
384
+ *
385
+ * - `input` - The input data for this [`Table`]. The schema of a [`Table`]
386
+ * is immutable after creation, so this method cannot be called with a
387
+ * schema.
388
+ * - `options` - Options for this update step - see [`UpdateOptions`].
389
+ *
390
+ * # JavaScript Examples
391
+ *
392
+ * ```javascript
393
+ * await table.update("x,y\n1,2");
394
+ * ```
395
+ */
396
+ update(input: string | ArrayBuffer | Record<string, unknown[]> | Record<string, unknown>[], options?: UpdateOptions | null): Promise<any>;
397
+ /**
398
+ * Create a new [`View`] from this table with a specified
399
+ * [`ViewConfigUpdate`].
400
+ *
401
+ * See [`View`] struct.
402
+ *
403
+ * # JavaScript Examples
404
+ *
405
+ * ```javascript
406
+ * const view = await table.view({
407
+ * columns: ["Sales"],
408
+ * aggregates: { Sales: "sum" },
409
+ * group_by: ["Region", "Country"],
410
+ * filter: [["Category", "in", ["Furniture", "Technology"]]],
411
+ * });
412
+ * ```
413
+ */
414
+ view(config?: ViewConfigUpdate | null): Promise<View>;
415
+ /**
416
+ * Validates the given expressions.
417
+ */
418
+ validate_expressions(exprs: any): Promise<any>;
419
+ }
420
+ /**
421
+ * The [`View`] struct is Perspective's query and serialization interface. It
422
+ * represents a query on the `Table`'s dataset and is always created from an
423
+ * existing `Table` instance via the [`Table::view`] method.
424
+ *
425
+ * [`View`]s are immutable with respect to the arguments provided to the
426
+ * [`Table::view`] method; to change these parameters, you must create a new
427
+ * [`View`] on the same [`Table`]. However, each [`View`] is _live_ with
428
+ * respect to the [`Table`]'s data, and will (within a conflation window)
429
+ * update with the latest state as its parent [`Table`] updates, including
430
+ * incrementally recalculating all aggregates, pivots, filters, etc. [`View`]
431
+ * query parameters are composable, in that each parameter works independently
432
+ * _and_ in conjunction with each other, and there is no limit to the number of
433
+ * pivots, filters, etc. which can be applied.
434
+ */
435
+ export class View {
436
+ private constructor();
437
+ free(): void;
438
+ __get_model(): View;
439
+ /**
440
+ * Returns an array of strings containing the column paths of the [`View`]
441
+ * without any of the source columns.
442
+ *
443
+ * A column path shows the columns that a given cell belongs to after
444
+ * pivots are applied.
445
+ */
446
+ column_paths(window?: ColumnWindow | null): Promise<any>;
447
+ /**
448
+ * Delete this [`View`] and clean up all resources associated with it.
449
+ * [`View`] objects do not stop consuming resources or processing
450
+ * updates when they are garbage collected - you must call this method
451
+ * to reclaim these.
452
+ */
453
+ delete(): Promise<void>;
454
+ /**
455
+ * Returns this [`View`]'s _dimensions_, row and column count, as well as
456
+ * those of the [`crate::Table`] from which it was derived.
457
+ *
458
+ * - `num_table_rows` - The number of rows in the underlying
459
+ * [`crate::Table`].
460
+ * - `num_table_columns` - The number of columns in the underlying
461
+ * [`crate::Table`] (including the `index` column if this
462
+ * [`crate::Table`] was constructed with one).
463
+ * - `num_view_rows` - The number of rows in this [`View`]. If this
464
+ * [`View`] has a `group_by` clause, `num_view_rows` will also include
465
+ * aggregated rows.
466
+ * - `num_view_columns` - The number of columns in this [`View`]. If this
467
+ * [`View`] has a `split_by` clause, `num_view_columns` will include all
468
+ * _column paths_, e.g. the number of `columns` clause times the number
469
+ * of `split_by` groups.
470
+ */
471
+ dimensions(): Promise<any>;
472
+ /**
473
+ * The expression schema of this [`View`], which contains only the
474
+ * expressions created on this [`View`]. See [`View::schema`] for
475
+ * details.
476
+ */
477
+ expression_schema(): Promise<any>;
478
+ /**
479
+ * A copy of the config object passed to the [`Table::view`] method which
480
+ * created this [`View`].
481
+ */
482
+ get_config(): Promise<any>;
483
+ /**
484
+ * Calculates the [min, max] of the leaf nodes of a column `column_name`.
485
+ *
486
+ * # Returns
487
+ *
488
+ * A tuple of [min, max], whose types are column and aggregate dependent.
489
+ */
490
+ get_min_max(name: string): Promise<Array<any>>;
491
+ /**
492
+ * The number of aggregated rows in this [`View`]. This is affected by the
493
+ * "group_by" configuration parameter supplied to this view's contructor.
494
+ *
495
+ * # Returns
496
+ *
497
+ * The number of aggregated rows.
498
+ */
499
+ num_rows(): Promise<number>;
500
+ /**
501
+ * The schema of this [`View`].
502
+ *
503
+ * The [`View`] schema differs from the `schema` returned by
504
+ * [`Table::schema`]; it may have different column names due to
505
+ * `expressions` or `columns` configs, or it maye have _different
506
+ * column types_ due to the application og `group_by` and `aggregates`
507
+ * config. You can think of [`Table::schema`] as the _input_ schema and
508
+ * [`View::schema`] as the _output_ schema of a Perspective pipeline.
509
+ */
510
+ schema(): Promise<any>;
511
+ /**
512
+ * Serializes a [`View`] to the Apache Arrow data format.
513
+ */
514
+ to_arrow(window?: ViewWindow | null): Promise<ArrayBuffer>;
515
+ /**
516
+ * Serializes this [`View`] to a string of JSON data. Useful if you want to
517
+ * save additional round trip serialize/deserialize cycles.
518
+ */
519
+ to_columns_string(window?: ViewWindow | null): Promise<string>;
520
+ /**
521
+ * Serializes this [`View`] to JavaScript objects in a column-oriented
522
+ * format.
523
+ */
524
+ to_columns(window?: ViewWindow | null): Promise<object>;
525
+ /**
526
+ * Render this `View` as a JSON string.
527
+ */
528
+ to_json_string(window?: ViewWindow | null): Promise<string>;
529
+ /**
530
+ * Serializes this [`View`] to JavaScript objects in a row-oriented
531
+ * format.
532
+ */
533
+ to_json(window?: ViewWindow | null): Promise<Array<any>>;
534
+ /**
535
+ * Renders this [`View`] as an [NDJSON](https://github.com/ndjson/ndjson-spec)
536
+ * formatted [`String`].
537
+ */
538
+ to_ndjson(window?: ViewWindow | null): Promise<string>;
539
+ /**
540
+ * Serializes this [`View`] to CSV data in a standard format.
541
+ */
542
+ to_csv(window?: ViewWindow | null): Promise<string>;
543
+ /**
544
+ * Register a callback with this [`View`]. Whenever the view's underlying
545
+ * table emits an update, this callback will be invoked with an object
546
+ * containing `port_id`, indicating which port the update fired on, and
547
+ * optionally `delta`, which is the new data that was updated for each
548
+ * cell or each row.
549
+ *
550
+ * # Arguments
551
+ *
552
+ * - `on_update` - A callback function invoked on update, which receives an
553
+ * object with two keys: `port_id`, indicating which port the update was
554
+ * triggered on, and `delta`, whose value is dependent on the mode
555
+ * parameter.
556
+ * - `options` - If this is provided as `OnUpdateOptions { mode:
557
+ * Some(OnUpdateMode::Row) }`, then `delta` is an Arrow of the updated
558
+ * rows. Otherwise `delta` will be [`Option::None`].
559
+ *
560
+ * # JavaScript Examples
561
+ *
562
+ * ```javascript
563
+ * // Attach an `on_update` callback
564
+ * view.on_update((updated) => console.log(updated.port_id));
565
+ * ```
566
+ *
567
+ * ```javascript
568
+ * // `on_update` with row deltas
569
+ * view.on_update((updated) => console.log(updated.delta), { mode: "row" });
570
+ * ```
571
+ */
572
+ on_update(on_update_js: Function, options?: OnUpdateOptions | null): Promise<any>;
573
+ /**
574
+ * Unregister a previously registered update callback with this [`View`].
575
+ *
576
+ * # Arguments
577
+ *
578
+ * - `id` - A callback `id` as returned by a recipricol call to
579
+ * [`View::on_update`].
580
+ */
581
+ remove_update(callback_id: number): Promise<void>;
582
+ /**
583
+ * Register a callback with this [`View`]. Whenever the [`View`] is
584
+ * deleted, this callback will be invoked.
585
+ */
586
+ on_delete(on_delete: Function): Promise<any>;
587
+ /**
588
+ * The number of aggregated columns in this [`View`]. This is affected by
589
+ * the "split_by" configuration parameter supplied to this view's
590
+ * contructor.
591
+ *
592
+ * # Returns
593
+ *
594
+ * The number of aggregated columns.
595
+ */
596
+ num_columns(): Promise<number>;
597
+ /**
598
+ * Unregister a previously registered [`View::on_delete`] callback.
599
+ */
600
+ remove_delete(callback_id: number): Promise<any>;
601
+ /**
602
+ * Collapses the `group_by` row at `row_index`.
603
+ */
604
+ collapse(row_index: number): Promise<number>;
605
+ /**
606
+ * Expand the `group_by` row at `row_index`.
607
+ */
608
+ expand(row_index: number): Promise<number>;
609
+ /**
610
+ * Set expansion `depth` of the `group_by` tree.
611
+ */
612
+ set_depth(depth: number): Promise<void>;
613
+ }
614
+
615
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
616
+
617
+ export interface InitOutput {
618
+ readonly memory: WebAssembly.Memory;
619
+ readonly __wbg_proxysession_free: (a: number, b: number) => void;
620
+ readonly proxysession_handle_request: (a: number, b: number) => number;
621
+ readonly proxysession_close: (a: number) => number;
622
+ readonly __wbg_client_free: (a: number, b: number) => void;
623
+ readonly client___getClassname: (a: number, b: number) => void;
624
+ readonly client_new: (a: number, b: number, c: number) => void;
625
+ readonly client_new_proxy_session: (a: number, b: number) => number;
626
+ readonly client_handle_response: (a: number, b: number) => number;
627
+ readonly client_handle_error: (a: number, b: number, c: number, d: number) => number;
628
+ readonly client_on_error: (a: number, b: number) => number;
629
+ readonly client_table: (a: number, b: number, c: number) => number;
630
+ readonly client_terminate: (a: number, b: number) => void;
631
+ readonly client_open_table: (a: number, b: number, c: number) => number;
632
+ readonly client_get_hosted_table_names: (a: number) => number;
633
+ readonly client_on_hosted_tables_update: (a: number, b: number) => number;
634
+ readonly client_remove_hosted_tables_update: (a: number, b: number) => number;
635
+ readonly client_system_info: (a: number) => number;
636
+ readonly table___getClassname: (a: number, b: number) => void;
637
+ readonly __wbg_table_free: (a: number, b: number) => void;
638
+ readonly table_get_index: (a: number) => number;
639
+ readonly table_get_client: (a: number) => number;
640
+ readonly table_get_name: (a: number) => number;
641
+ readonly table_get_limit: (a: number) => number;
642
+ readonly table_clear: (a: number) => number;
643
+ readonly table_delete: (a: number, b: number) => number;
644
+ readonly table_size: (a: number) => number;
645
+ readonly table_schema: (a: number) => number;
646
+ readonly table_columns: (a: number) => number;
647
+ readonly table_make_port: (a: number) => number;
648
+ readonly table_on_delete: (a: number, b: number) => number;
649
+ readonly table_remove_delete: (a: number, b: number) => number;
650
+ readonly table_remove: (a: number, b: number, c: number) => number;
651
+ readonly table_replace: (a: number, b: number, c: number) => number;
652
+ readonly table_update: (a: number, b: number, c: number) => number;
653
+ readonly table_view: (a: number, b: number) => number;
654
+ readonly table_validate_expressions: (a: number, b: number) => number;
655
+ readonly __wbg_view_free: (a: number, b: number) => void;
656
+ readonly view___get_model: (a: number) => number;
657
+ readonly view_column_paths: (a: number, b: number) => number;
658
+ readonly view_delete: (a: number) => number;
659
+ readonly view_dimensions: (a: number) => number;
660
+ readonly view_expression_schema: (a: number) => number;
661
+ readonly view_get_config: (a: number) => number;
662
+ readonly view_get_min_max: (a: number, b: number, c: number) => number;
663
+ readonly view_num_rows: (a: number) => number;
664
+ readonly view_schema: (a: number) => number;
665
+ readonly view_to_arrow: (a: number, b: number) => number;
666
+ readonly view_to_columns_string: (a: number, b: number) => number;
667
+ readonly view_to_columns: (a: number, b: number) => number;
668
+ readonly view_to_json_string: (a: number, b: number) => number;
669
+ readonly view_to_json: (a: number, b: number) => number;
670
+ readonly view_to_ndjson: (a: number, b: number) => number;
671
+ readonly view_to_csv: (a: number, b: number) => number;
672
+ readonly view_on_update: (a: number, b: number, c: number) => number;
673
+ readonly view_remove_update: (a: number, b: number) => number;
674
+ readonly view_on_delete: (a: number, b: number) => number;
675
+ readonly view_num_columns: (a: number) => number;
676
+ readonly view_remove_delete: (a: number, b: number) => number;
677
+ readonly view_collapse: (a: number, b: number) => number;
678
+ readonly view_expand: (a: number, b: number) => number;
679
+ readonly view_set_depth: (a: number, b: number) => number;
680
+ readonly init: () => void;
681
+ readonly proxysession_new: (a: number, b: number) => number;
682
+ readonly __wbindgen_export_0: (a: number, b: number) => number;
683
+ readonly __wbindgen_export_1: (a: number, b: number, c: number, d: number) => number;
684
+ readonly __wbindgen_export_2: (a: number) => void;
685
+ readonly __wbindgen_export_3: (a: number, b: number, c: number) => void;
686
+ readonly __wbindgen_export_4: WebAssembly.Table;
687
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
688
+ readonly __wbindgen_export_5: (a: number, b: number) => number;
689
+ readonly __wbindgen_export_6: (a: number, b: number, c: number) => void;
690
+ readonly __wbindgen_export_7: (a: number, b: number, c: number, d: number) => void;
691
+ }
692
+
693
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
694
+ /**
695
+ * Instantiates the given `module`, which can either be bytes or
696
+ * a precompiled `WebAssembly.Module`.
697
+ *
698
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
699
+ *
700
+ * @returns {InitOutput}
701
+ */
702
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
703
+
704
+ /**
705
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
706
+ * for everything else, calls `WebAssembly.instantiate` directly.
707
+ *
708
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
709
+ *
710
+ * @returns {Promise<InitOutput>}
711
+ */
712
+ export default function __wbg_init (module_or_path: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;