@perspective-dev/client 5.6.1 → 5.8.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 (142) hide show
  1. package/README.md +5 -1
  2. package/dist/cdn/perspective.js +3 -2
  3. package/dist/cdn/perspective.js.map +4 -4
  4. package/dist/esm/perspective.browser.d.ts +71 -17
  5. package/dist/esm/perspective.js +2 -2
  6. package/dist/esm/perspective.js.map +4 -4
  7. package/dist/esm/perspective.node.d.ts +20 -3
  8. package/dist/esm/perspective.node.js +734 -39
  9. package/dist/esm/perspective.node.js.map +4 -4
  10. package/dist/esm/public_types.d.ts +31 -0
  11. package/dist/esm/virtual_servers/clickhouse.d.ts +41 -0
  12. package/dist/esm/virtual_servers/clickhouse.js +6 -1
  13. package/dist/esm/virtual_servers/clickhouse.js.map +3 -3
  14. package/dist/esm/virtual_servers/duckdb.d.ts +19 -9
  15. package/dist/esm/virtual_servers/duckdb.js +1 -1
  16. package/dist/esm/virtual_servers/duckdb.js.map +3 -3
  17. package/dist/esm/wasm/cdn.d.ts +12 -0
  18. package/dist/esm/wasm/migrate.d.ts +40 -0
  19. package/dist/esm/wasm/registry.d.ts +123 -0
  20. package/dist/esm/wasm/registry.js +3 -0
  21. package/dist/esm/wasm/registry.js.map +7 -0
  22. package/{src/ts/ts-rs/AggSpec.ts → dist/ts-rs/AggSpec.d.ts} +1 -1
  23. package/{src/ts/ts-rs/Features.ts → dist/ts-rs/Features.d.ts} +16 -6
  24. package/{src/ts/ts-rs/Filter.ts → dist/ts-rs/Filter.d.ts} +1 -1
  25. package/{src/ts/ts-rs/FilterTerm.ts → dist/ts-rs/FilterTerm.d.ts} +1 -1
  26. package/{src/ts/ts-rs/JoinOptions.ts → dist/ts-rs/JoinOptions.d.ts} +1 -1
  27. package/dist/ts-rs/ListFlatten.d.ts +3 -0
  28. package/dist/ts-rs/MapFlatten.d.ts +3 -0
  29. package/{src/ts/ts-rs/OnRemoveData.ts → dist/ts-rs/OnRemoveData.d.ts} +1 -1
  30. package/{src/ts/ts-rs/OnUpdateData.ts → dist/ts-rs/OnUpdateData.d.ts} +1 -1
  31. package/{src/ts/ts-rs/OnUpdateOptions.ts → dist/ts-rs/OnUpdateOptions.d.ts} +1 -1
  32. package/{src/ts/ts-rs/Sort.ts → dist/ts-rs/Sort.d.ts} +1 -1
  33. package/dist/ts-rs/StructFlatten.d.ts +3 -0
  34. package/dist/ts-rs/TableIndex.d.ts +9 -0
  35. package/dist/ts-rs/TableInitOptions.d.ts +65 -0
  36. package/{src/ts/ts-rs/UpdateOptions.ts → dist/ts-rs/UpdateOptions.d.ts} +1 -1
  37. package/{src/ts/ts-rs/ViewConfig.ts → dist/ts-rs/ViewConfig.d.ts} +8 -8
  38. package/{src/ts/ts-rs/ViewConfigUpdate.ts → dist/ts-rs/ViewConfigUpdate.d.ts} +8 -8
  39. package/{src/ts/ts-rs/ViewOnUpdateResp.ts → dist/ts-rs/ViewOnUpdateResp.d.ts} +1 -1
  40. package/{src/ts/ts-rs/WindowAggSpec.ts → dist/ts-rs/WindowAggSpec.d.ts} +1 -1
  41. package/{src/ts/ts-rs/WindowSort.ts → dist/ts-rs/WindowSort.d.ts} +1 -1
  42. package/{src/ts/ts-rs/WindowSpec.ts → dist/ts-rs/WindowSpec.d.ts} +1 -1
  43. package/{src/ts/ts-rs/Windows.ts → dist/ts-rs/Windows.d.ts} +1 -1
  44. package/dist/wasm/perspective-js.d.ts +136 -58
  45. package/dist/wasm/perspective-js.js +190 -24
  46. package/dist/wasm/perspective-js.wasm +0 -0
  47. package/dist/wasm/perspective-js.wasm.d.ts +14 -8
  48. package/dist/wasm/perspective-migrate.d.ts +41 -0
  49. package/dist/wasm/perspective-migrate.js +524 -0
  50. package/dist/wasm/perspective-migrate.wasm +0 -0
  51. package/dist/wasm/perspective-migrate.wasm.d.ts +8 -0
  52. package/package.json +30 -15
  53. package/dist/esm/ts-rs/AggSpec.d.ts +0 -8
  54. package/dist/esm/ts-rs/Aggregate.d.ts +0 -1
  55. package/dist/esm/ts-rs/ColumnType.d.ts +0 -4
  56. package/dist/esm/ts-rs/ColumnWindow.d.ts +0 -4
  57. package/dist/esm/ts-rs/DeleteOptions.d.ts +0 -6
  58. package/dist/esm/ts-rs/Expressions.d.ts +0 -3
  59. package/dist/esm/ts-rs/Features.d.ts +0 -71
  60. package/dist/esm/ts-rs/Filter.d.ts +0 -2
  61. package/dist/esm/ts-rs/FilterReducer.d.ts +0 -1
  62. package/dist/esm/ts-rs/FilterTerm.d.ts +0 -2
  63. package/dist/esm/ts-rs/GroupRollupMode.d.ts +0 -1
  64. package/dist/esm/ts-rs/JoinOptions.d.ts +0 -9
  65. package/dist/esm/ts-rs/JoinType.d.ts +0 -1
  66. package/dist/esm/ts-rs/ListFlatten.d.ts +0 -1
  67. package/dist/esm/ts-rs/OnRemoveData.d.ts +0 -6
  68. package/dist/esm/ts-rs/OnUpdateData.d.ts +0 -6
  69. package/dist/esm/ts-rs/OnUpdateMode.d.ts +0 -9
  70. package/dist/esm/ts-rs/OnUpdateOptions.d.ts +0 -7
  71. package/dist/esm/ts-rs/Scalar.d.ts +0 -5
  72. package/dist/esm/ts-rs/Sort.d.ts +0 -2
  73. package/dist/esm/ts-rs/SortDir.d.ts +0 -1
  74. package/dist/esm/ts-rs/SplitRollupMode.d.ts +0 -9
  75. package/dist/esm/ts-rs/SystemInfo.d.ts +0 -40
  76. package/dist/esm/ts-rs/TableInitOptions.d.ts +0 -45
  77. package/dist/esm/ts-rs/TableReadFormat.d.ts +0 -7
  78. package/dist/esm/ts-rs/TypedArrayWindow.d.ts +0 -33
  79. package/dist/esm/ts-rs/UpdateOptions.d.ts +0 -8
  80. package/dist/esm/ts-rs/ViewConfig.d.ts +0 -24
  81. package/dist/esm/ts-rs/ViewConfigUpdate.d.ts +0 -116
  82. package/dist/esm/ts-rs/ViewOnRemoveResp.d.ts +0 -4
  83. package/dist/esm/ts-rs/ViewOnUpdateResp.d.ts +0 -4
  84. package/dist/esm/ts-rs/ViewWindow.d.ts +0 -30
  85. package/dist/esm/ts-rs/WindowAggSpec.d.ts +0 -25
  86. package/dist/esm/ts-rs/WindowSort.d.ts +0 -7
  87. package/dist/esm/ts-rs/WindowSortDir.d.ts +0 -6
  88. package/dist/esm/ts-rs/WindowSpec.d.ts +0 -47
  89. package/dist/esm/ts-rs/Windows.d.ts +0 -10
  90. package/src/rust/client.rs +0 -590
  91. package/src/rust/generic_sql_model.rs +0 -276
  92. package/src/rust/lib.rs +0 -99
  93. package/src/rust/table.rs +0 -397
  94. package/src/rust/table_data.rs +0 -164
  95. package/src/rust/typed_array.rs +0 -386
  96. package/src/rust/utils/browser.rs +0 -35
  97. package/src/rust/utils/console_logger.rs +0 -237
  98. package/src/rust/utils/errors.rs +0 -274
  99. package/src/rust/utils/futures.rs +0 -274
  100. package/src/rust/utils/json.rs +0 -252
  101. package/src/rust/utils/local_poll_loop.rs +0 -63
  102. package/src/rust/utils/mod.rs +0 -32
  103. package/src/rust/utils/serde.rs +0 -46
  104. package/src/rust/utils/trace_allocator.rs +0 -98
  105. package/src/rust/view.rs +0 -463
  106. package/src/rust/virtual_server.rs +0 -991
  107. package/src/ts/perspective-server.worker.ts +0 -74
  108. package/src/ts/perspective.browser.ts +0 -380
  109. package/src/ts/perspective.cdn.ts +0 -28
  110. package/src/ts/perspective.node.ts +0 -556
  111. package/src/ts/ts-rs/ListFlatten.ts +0 -3
  112. package/src/ts/ts-rs/TableInitOptions.ts +0 -42
  113. package/src/ts/virtual_server.ts +0 -83
  114. package/src/ts/virtual_servers/clickhouse.ts +0 -533
  115. package/src/ts/virtual_servers/duckdb.ts +0 -549
  116. package/src/ts/wasm/browser.ts +0 -134
  117. package/src/ts/wasm/cdn.ts +0 -32
  118. package/src/ts/wasm/decompress.ts +0 -83
  119. package/src/ts/wasm/emscripten_api.ts +0 -91
  120. package/src/ts/wasm/engine.ts +0 -309
  121. package/src/ts/wasm/features.ts +0 -31
  122. package/src/ts/wasm/perspective-server.poly.ts +0 -460
  123. package/src/ts/websocket.ts +0 -95
  124. package/tsconfig.json +0 -22
  125. /package/{src/ts/ts-rs/Aggregate.ts → dist/ts-rs/Aggregate.d.ts} +0 -0
  126. /package/{src/ts/ts-rs/ColumnType.ts → dist/ts-rs/ColumnType.d.ts} +0 -0
  127. /package/{src/ts/ts-rs/ColumnWindow.ts → dist/ts-rs/ColumnWindow.d.ts} +0 -0
  128. /package/{src/ts/ts-rs/DeleteOptions.ts → dist/ts-rs/DeleteOptions.d.ts} +0 -0
  129. /package/{src/ts/ts-rs/Expressions.ts → dist/ts-rs/Expressions.d.ts} +0 -0
  130. /package/{src/ts/ts-rs/FilterReducer.ts → dist/ts-rs/FilterReducer.d.ts} +0 -0
  131. /package/{src/ts/ts-rs/GroupRollupMode.ts → dist/ts-rs/GroupRollupMode.d.ts} +0 -0
  132. /package/{src/ts/ts-rs/JoinType.ts → dist/ts-rs/JoinType.d.ts} +0 -0
  133. /package/{src/ts/ts-rs/OnUpdateMode.ts → dist/ts-rs/OnUpdateMode.d.ts} +0 -0
  134. /package/{src/ts/ts-rs/Scalar.ts → dist/ts-rs/Scalar.d.ts} +0 -0
  135. /package/{src/ts/ts-rs/SortDir.ts → dist/ts-rs/SortDir.d.ts} +0 -0
  136. /package/{src/ts/ts-rs/SplitRollupMode.ts → dist/ts-rs/SplitRollupMode.d.ts} +0 -0
  137. /package/{src/ts/ts-rs/SystemInfo.ts → dist/ts-rs/SystemInfo.d.ts} +0 -0
  138. /package/{src/ts/ts-rs/TableReadFormat.ts → dist/ts-rs/TableReadFormat.d.ts} +0 -0
  139. /package/{src/ts/ts-rs/TypedArrayWindow.ts → dist/ts-rs/TypedArrayWindow.d.ts} +0 -0
  140. /package/{src/ts/ts-rs/ViewOnRemoveResp.ts → dist/ts-rs/ViewOnRemoveResp.d.ts} +0 -0
  141. /package/{src/ts/ts-rs/ViewWindow.ts → dist/ts-rs/ViewWindow.d.ts} +0 -0
  142. /package/{src/ts/ts-rs/WindowSortDir.ts → dist/ts-rs/WindowSortDir.d.ts} +0 -0
@@ -1,71 +0,0 @@
1
- import type { AggSpec } from "./AggSpec.js";
2
- import type { ColumnType } from "./ColumnType.js";
3
- import type { GroupRollupMode } from "./GroupRollupMode.js";
4
- import type { SplitRollupMode } from "./SplitRollupMode.js";
5
- import type { WindowAggSpec } from "./WindowAggSpec.js";
6
- /**
7
- * Describes the capabilities supported by a virtual server handler.
8
- *
9
- * This struct is returned by
10
- * [`VirtualServerHandler::get_features`](super::VirtualServerHandler::get_features)
11
- * to inform clients about which operations are available.
12
- */
13
- export type Features = {
14
- /**
15
- * Whether group-by aggregation is supported.
16
- */
17
- group_by?: boolean;
18
- /**
19
- * Which `group_by_rollup_mode` options are supported
20
- */
21
- group_rollup_mode?: Array<GroupRollupMode>;
22
- /**
23
- * Whether split-by (pivot) operations are supported.
24
- */
25
- split_by?: boolean;
26
- /**
27
- * Which `split_rollup_mode` options are supported. Empty (the default)
28
- * means `["flat"]` - a server must opt in to `"rollup"` explicitly, as
29
- * it requires emitting subtotal and grand-total column groups.
30
- */
31
- split_rollup_mode?: Array<SplitRollupMode>;
32
- /**
33
- * Available filter operators per column type.
34
- */
35
- filter_ops?: {
36
- [key in ColumnType]?: Array<string>;
37
- };
38
- /**
39
- * Available aggregate functions per column type.
40
- */
41
- aggregates?: {
42
- [key in ColumnType]?: Array<AggSpec>;
43
- };
44
- /**
45
- * Whether sorting is supported.
46
- */
47
- sort?: boolean;
48
- /**
49
- * Whether computed expressions are supported.
50
- */
51
- expressions?: boolean;
52
- /**
53
- * Available window aggregates per column type.
54
- */
55
- window_aggregates?: {
56
- [key in ColumnType]?: Array<WindowAggSpec>;
57
- };
58
- /**
59
- * Whether update callbacks are supported.
60
- */
61
- on_update?: boolean;
62
- /**
63
- * The data store has no reliable natural row order
64
- */
65
- unordered?: boolean;
66
- /**
67
- * Whether a `Table` can be derived from a `View`, which requires
68
- * [`VirtualServerHandler::view_make_table`](super::VirtualServerHandler::view_make_table).
69
- */
70
- view_derivations?: boolean;
71
- };
@@ -1,2 +0,0 @@
1
- import type { FilterTerm } from "./FilterTerm.js";
2
- export type Filter = [string, string, FilterTerm];
@@ -1 +0,0 @@
1
- export type FilterReducer = "and" | "or";
@@ -1,2 +0,0 @@
1
- import type { Scalar } from "./Scalar.js";
2
- export type FilterTerm = Array<Scalar> | Scalar;
@@ -1 +0,0 @@
1
- export type GroupRollupMode = "rollup" | "flat" | "total";
@@ -1,9 +0,0 @@
1
- import type { JoinType } from "./JoinType.js";
2
- /**
3
- * Options for [`Client::join`].
4
- */
5
- export type JoinOptions = {
6
- join_type?: JoinType;
7
- name?: string;
8
- right_on?: string;
9
- };
@@ -1 +0,0 @@
1
- export type JoinType = "inner" | "left" | "outer";
@@ -1 +0,0 @@
1
- export type ListFlatten = "zip" | "cartesian" | "stringify";
@@ -1,6 +0,0 @@
1
- import type { ViewOnRemoveResp } from "./ViewOnRemoveResp.js";
2
- /**
3
- * Removed index values and port ID corresponding to a remove batch, provided
4
- * to the callback argument to [`View::on_remove`].
5
- */
6
- export type OnRemoveData = ViewOnRemoveResp;
@@ -1,6 +0,0 @@
1
- import type { ViewOnUpdateResp } from "./ViewOnUpdateResp.js";
2
- /**
3
- * Rows updated and port ID corresponding to an update batch, provided to the
4
- * callback argument to [`View::on_update`] with the "rows" mode.
5
- */
6
- export type OnUpdateData = ViewOnUpdateResp;
@@ -1,9 +0,0 @@
1
- /**
2
- * The update mode for [`View::on_update`].
3
- *
4
- * `Row` mode calculates and provides the update batch new rows/columns as an
5
- * Apache Arrow to the callback provided to [`View::on_update`]. This allows
6
- * incremental updates if your callbakc can read this format, but should be
7
- * disabled otherwise.
8
- */
9
- export type OnUpdateMode = "row";
@@ -1,7 +0,0 @@
1
- import type { OnUpdateMode } from "./OnUpdateMode.js";
2
- /**
3
- * Options for [`View::on_update`].
4
- */
5
- export type OnUpdateOptions = {
6
- mode: OnUpdateMode | null;
7
- };
@@ -1,5 +0,0 @@
1
- /**
2
- * This type represents the ViewConfig serializable type, which must be JSON
3
- * safe.
4
- */
5
- export type Scalar = number | string | boolean | null;
@@ -1,2 +0,0 @@
1
- import type { SortDir } from "./SortDir.js";
2
- export type Sort = [string, SortDir];
@@ -1 +0,0 @@
1
- export type SortDir = "none" | "desc" | "asc" | "col desc" | "col asc" | "desc abs" | "asc abs" | "col desc abs" | "col asc abs";
@@ -1,9 +0,0 @@
1
- /**
2
- * The `split_by` corollary to [`GroupRollupMode`]. `Flat` (the default,
3
- * matching this crate's historical behavior) emits only full-depth split
4
- * combinations as columns; `Rollup` additionally emits grand-total and
5
- * subtotal column groups in "totals before" order. There is no `Total`
6
- * variant - an empty `split_by` already expresses a single grand-total
7
- * column group.
8
- */
9
- export type SplitRollupMode = "flat" | "rollup";
@@ -1,40 +0,0 @@
1
- /**
2
- * Metadata about the engine runtime (such as total heap utilization).
3
- */
4
- export type SystemInfo<T = bigint> = {
5
- /**
6
- * Total available bytes for allocation on the [`Server`].
7
- */
8
- heap_size: T;
9
- /**
10
- * Bytes allocated for use on the [`Server`].
11
- */
12
- used_size: T;
13
- /**
14
- * Wall-clock time spent processing requests on the [`Server`], in
15
- * milliseconds (estimated). This does not properly account for the
16
- * internal thread pool (which enables column-parallel processing of
17
- * individual requests).
18
- */
19
- cpu_time: number;
20
- /**
21
- * Milliseconds since internal CPU time accumulator was reset.
22
- */
23
- cpu_time_epoch: number;
24
- /**
25
- * Timestamp (POSIX) this request was made. This field may be omitted
26
- * for wasm due to `perspective-client` lacking a dependency on
27
- * `wasm_bindgen`.
28
- */
29
- timestamp: T | null;
30
- /**
31
- * Total available bytes for allocation on the [`Client`]. This is only
32
- * available if `trace-allocator` is enabled.
33
- */
34
- client_heap: T | null;
35
- /**
36
- * Bytes allocated for use on the [`Client`]. This is only
37
- * available if `trace-allocator` is enabled.
38
- */
39
- client_used: T | null;
40
- };
@@ -1,45 +0,0 @@
1
- import type { ColumnType } from "./ColumnType.js";
2
- import type { ListFlatten } from "./ListFlatten.js";
3
- import type { TableReadFormat } from "./TableReadFormat.js";
4
- /**
5
- * Options which impact the behavior of [`Client::table`], as well as
6
- * subsequent calls to [`Table::update`].
7
- */
8
- export type TableInitOptions = {
9
- name?: string;
10
- format?: TableReadFormat;
11
- /**
12
- * This [`Table`] should use the column named by the `index` parameter as
13
- * the `index`, which causes [`Table::update`] and [`Client::table`] input
14
- * to either insert or update existing rows based on `index` column
15
- * value equality.
16
- */
17
- index?: string;
18
- /**
19
- * This [`Table`] should be limited to `limit` rows, after which the
20
- * _earliest_ rows will be overwritten (where _earliest_ is defined as
21
- * relative to insertion order).
22
- */
23
- limit?: number;
24
- /**
25
- * Back this [`Table`]'s canonical data with the on-disk storage backend
26
- * instead of memory. On native targets this is a memory-mapped file; on
27
- * WASM it is OPFS (Worker only). Defaults to in-memory.
28
- */
29
- page_to_disk?: boolean;
30
- /**
31
- * How Arrow `LIST` and JSON `Array` columns are ingested. `zip` (the
32
- * default) and `cartesian` expand a row into one row per list element,
33
- * and are incompatible with `index`, as the rows of an expansion
34
- * repeat their index. `stringify` encodes each list as a JSON array in
35
- * a single string column instead.
36
- */
37
- list_flatten?: ListFlatten;
38
- /**
39
- * The columns of a [`Table`] made from a [`View`], in place of the ones
40
- * inferred from it.
41
- */
42
- schema?: {
43
- [key in string]?: ColumnType;
44
- };
45
- };
@@ -1,7 +0,0 @@
1
- /**
2
- * The format to interpret data preovided to [`Client::table`].
3
- *
4
- * When serialized, these values are `"csv"`, `"json"`, `"columns"`, `"arrow"`
5
- * and `"ndjson"`.
6
- */
7
- export type TableReadFormat = "csv" | "json" | "columns" | "arrow" | "ndjson";
@@ -1,33 +0,0 @@
1
- /**
2
- * Options for `with_typed_arrays`, extending `ViewWindow` with
3
- * typed-array-specific options.
4
- */
5
- export type TypedArrayWindow = {
6
- /**
7
- * When `true`, Float64/Date32/Timestamp columns are output as
8
- * `Float32Array` instead of `Float64Array`.
9
- */
10
- float32: boolean;
11
- start_row?: number;
12
- start_col?: number;
13
- end_row?: number;
14
- end_col?: number;
15
- id?: boolean;
16
- index?: boolean;
17
- /**
18
- * Only impacts [`View::to_csv`]
19
- */
20
- formatted?: boolean;
21
- /**
22
- * Arrow IPC body compression for [`View::to_arrow`], `"lz4"` or `"zstd"`
23
- * (uncompressed when omitted).
24
- */
25
- compression?: "lz4" | "zstd";
26
- /**
27
- * When `true`, [`View::to_arrow`] names `group_by` key columns
28
- * `__ROW_PATH_N__` and never qualifies an aggregate, instead of the
29
- * human-readable names a key column and its aggregate would otherwise
30
- * take.
31
- */
32
- machine_column_names?: boolean;
33
- };
@@ -1,8 +0,0 @@
1
- import type { TableReadFormat } from "./TableReadFormat.js";
2
- /**
3
- * Options for [`Table::update`].
4
- */
5
- export type UpdateOptions = {
6
- port_id: number | null;
7
- format: TableReadFormat | null;
8
- };
@@ -1,24 +0,0 @@
1
- import type { Aggregate } from "./Aggregate.js";
2
- import type { Expressions } from "./Expressions.js";
3
- import type { Filter } from "./Filter.js";
4
- import type { FilterReducer } from "./FilterReducer.js";
5
- import type { GroupRollupMode } from "./GroupRollupMode.js";
6
- import type { Sort } from "./Sort.js";
7
- import type { SplitRollupMode } from "./SplitRollupMode.js";
8
- import type { Windows } from "./Windows.js";
9
- export type ViewConfig = {
10
- group_by: Array<string>;
11
- split_by: Array<string>;
12
- sort: Array<Sort>;
13
- filter: Array<Filter>;
14
- group_rollup_mode: GroupRollupMode;
15
- split_rollup_mode: SplitRollupMode;
16
- filter_op?: FilterReducer;
17
- expressions: Expressions;
18
- windows?: Windows;
19
- columns: Array<string | null>;
20
- aggregates: {
21
- [key in string]?: Aggregate;
22
- };
23
- group_by_depth?: number | null;
24
- };
@@ -1,116 +0,0 @@
1
- import type { Aggregate } from "./Aggregate.js";
2
- import type { Expressions } from "./Expressions.js";
3
- import type { Filter } from "./Filter.js";
4
- import type { FilterReducer } from "./FilterReducer.js";
5
- import type { GroupRollupMode } from "./GroupRollupMode.js";
6
- import type { Sort } from "./Sort.js";
7
- import type { SplitRollupMode } from "./SplitRollupMode.js";
8
- import type { Windows } from "./Windows.js";
9
- export type ViewConfigUpdate = {
10
- /**
11
- * A group by _groups_ the dataset by the unique values of each column used
12
- * as a group by - a close analogue in SQL to the `GROUP BY` statement.
13
- * The underlying dataset is aggregated to show the values belonging to
14
- * each group, and a total row is calculated for each group, showing
15
- * the currently selected aggregated value (e.g. `sum`) of the column.
16
- * Group by are useful for hierarchies, categorizing data and
17
- * attributing values, i.e. showing the number of units sold based on
18
- * State and City. In Perspective, group by are represented as an array
19
- * of string column names to pivot, are applied in the order provided;
20
- * For example, a group by of `["State", "City", "Postal Code"]` shows
21
- * the values for each Postal Code, which are grouped by City,
22
- * which are in turn grouped by State.
23
- */
24
- group_by?: Array<string>;
25
- /**
26
- * A split by _splits_ the dataset by the unique values of each column used
27
- * as a split by. The underlying dataset is not aggregated, and a new
28
- * column is created for each unique value of the split by. Each newly
29
- * created column contains the parts of the dataset that correspond to
30
- * the column header, i.e. a `View` that has `["State"]` as its split
31
- * by will have a new column for each state. In Perspective, Split By
32
- * are represented as an array of string column names to pivot.
33
- */
34
- split_by?: Array<string>;
35
- /**
36
- * The `columns` property specifies which columns should be included in the
37
- * [`crate::View`]'s output. This allows users to show or hide a specific
38
- * subset of columns, as well as control the order in which columns
39
- * appear to the user. This is represented in Perspective as an array
40
- * of string column names.
41
- */
42
- columns?: Array<string | null>;
43
- /**
44
- * The `filter` property specifies columns on which the query can be
45
- * filtered, returning rows that pass the specified filter condition.
46
- * This is analogous to the `WHERE` clause in SQL. There is no limit on
47
- * the number of columns where `filter` is applied, but the resulting
48
- * dataset is one that passes all the filter conditions, i.e. the
49
- * filters are joined with an `AND` condition.
50
- *
51
- * Perspective represents `filter` as an array of arrays, with the values
52
- * of each inner array being a string column name, a string filter
53
- * operator, and a filter operand in the type of the column.
54
- */
55
- filter?: Array<Filter>;
56
- /**
57
- * The `sort` property specifies columns on which the query should be
58
- * sorted, analogous to `ORDER BY` in SQL. A column can be sorted
59
- * regardless of its data type, and sorts can be applied in ascending
60
- * or descending order. Perspective represents `sort` as an array of
61
- * arrays, with the values of each inner array being a string column
62
- * name and a string sort direction. When `column-pivots` are applied,
63
- * the additional sort directions `"col asc"` and `"col desc"` will
64
- * determine the order of pivot columns groups.
65
- *
66
- * `sort` is the ONLY thing that orders a `View`'s rows — without it
67
- * they keep the `Table`'s natural (insertion) order, which any
68
- * consumer reading rows sequentially will reflect. Not to be
69
- * confused with a window column's `order_by`, which orders rows
70
- * WITHIN a window frame and does not reorder the `View`.
71
- */
72
- sort?: Array<Sort>;
73
- /**
74
- * The `expressions` property specifies _new_ columns in Perspective that
75
- * are created using existing column values or arbitary scalar values
76
- * defined within the expression. In `<perspective-viewer>`,
77
- * expressions are added using the "New Column" button in the side
78
- * panel.
79
- */
80
- expressions?: Expressions;
81
- /**
82
- * The `windows` property declares ordered, partitioned rolling
83
- * computations (moving aggregates, cumulative sums) as _new_ columns
84
- * keyed by output alias (`{"name": {...spec}}`, symmetric with
85
- * `expressions`), analogous to SQL window functions. See
86
- * [`crate::config::WindowSpec`].
87
- */
88
- windows?: Windows;
89
- /**
90
- * Aggregates perform a calculation over an entire column, and are
91
- * displayed when one or more [Group By](#group-by) are applied to the
92
- * `View`. Aggregates can be specified by the user, or Perspective will
93
- * use the following sensible default aggregates based on column type:
94
- *
95
- * - "sum" for `integer` and `float` columns
96
- * - "count" for all other columns
97
- *
98
- * Perspective provides a selection of aggregate functions that can be
99
- * applied to columns in the `View` constructor using a dictionary of
100
- * column name to aggregate function name.
101
- *
102
- * An aggregate also determines the column's RESULT TYPE, which need
103
- * not match the input: `"count"` yields an `integer` whatever it
104
- * counts, so a `date` column left on the default `"count"` is an
105
- * `integer` in the resulting `View` — no longer a date. Set an
106
- * aggregate that preserves the type (e.g. `"any"`, `"last"`) when
107
- * the original type matters, such as a date used as a chart axis.
108
- */
109
- aggregates?: {
110
- [key in string]?: Aggregate;
111
- };
112
- group_by_depth?: number;
113
- filter_op?: FilterReducer;
114
- group_rollup_mode?: GroupRollupMode;
115
- split_rollup_mode?: SplitRollupMode;
116
- };
@@ -1,4 +0,0 @@
1
- export type ViewOnRemoveResp = {
2
- indices: Uint8Array;
3
- port_id: number;
4
- };
@@ -1,4 +0,0 @@
1
- export type ViewOnUpdateResp = {
2
- delta: Uint8Array | undefined;
3
- port_id: number;
4
- };
@@ -1,30 +0,0 @@
1
- /**
2
- * Options for serializing a window of data from a [`View`].
3
- *
4
- * Some fields of [`ViewWindow`] are only applicable to specific methods of
5
- * [`View`].
6
- */
7
- export type ViewWindow = {
8
- start_row?: number;
9
- start_col?: number;
10
- end_row?: number;
11
- end_col?: number;
12
- id?: boolean;
13
- index?: boolean;
14
- /**
15
- * Only impacts [`View::to_csv`]
16
- */
17
- formatted?: boolean;
18
- /**
19
- * Arrow IPC body compression for [`View::to_arrow`], `"lz4"` or `"zstd"`
20
- * (uncompressed when omitted).
21
- */
22
- compression?: "lz4" | "zstd";
23
- /**
24
- * When `true`, [`View::to_arrow`] names `group_by` key columns
25
- * `__ROW_PATH_N__` and never qualifies an aggregate, instead of the
26
- * human-readable names a key column and its aggregate would otherwise
27
- * take.
28
- */
29
- machine_column_names?: boolean;
30
- };
@@ -1,25 +0,0 @@
1
- import type { ColumnType } from "./ColumnType.js";
2
- /**
3
- * Specification for a window aggregate.
4
- */
5
- export type WindowAggSpec = {
6
- name: string;
7
- /**
8
- * Frame kinds this aggregate accepts (`rows`, `range`, `cumulative`).
9
- * Empty means it takes no frame at all.
10
- */
11
- frames?: Array<string>;
12
- /**
13
- * Takes a row offset, as `lag` / `lead` / `diff` do.
14
- */
15
- offset?: boolean;
16
- /**
17
- * Takes a smoothing factor, as `ema` does.
18
- */
19
- alpha?: boolean;
20
- /**
21
- * The output column type. `None` means the source column's type, which
22
- * is what `min` / `max` / `lag` do.
23
- */
24
- result_type?: ColumnType;
25
- };
@@ -1,7 +0,0 @@
1
- import type { WindowSortDir } from "./WindowSortDir.js";
2
- /**
3
- * The `Table` column which orders each partition, with its direction -
4
- * serialized as a two-element array (`["ts", "desc"]`), symmetric with the
5
- * `ViewConfig`'s `sort` field.
6
- */
7
- export type WindowSort = [string, WindowSortDir];
@@ -1,6 +0,0 @@
1
- /**
2
- * A window's order direction. A dedicated two-variant enum rather than
3
- * [`crate::config::SortDir`] - the column-sort extras (`col asc`, `abs`,
4
- * `none`) are meaningless inside a window frame and unrepresentable here.
5
- */
6
- export type WindowSortDir = "asc" | "desc";
@@ -1,47 +0,0 @@
1
- import type { WindowSort } from "./WindowSort.js";
2
- /**
3
- * The serialized form of [`WindowSpec`].
4
- */
5
- export type WindowSpec = {
6
- /**
7
- * The input column - either a real `Table` column or an expression
8
- * alias from the same `ViewConfig`.
9
- */
10
- column: string;
11
- aggregate: string;
12
- /**
13
- * Columns whose distinct value tuples partition the rows; empty
14
- * partitions the whole `Table` as one group.
15
- */
16
- partition_by?: Array<string>;
17
- /**
18
- * The `Table` column which orders each partition, and the direction.
19
- * This orders rows WITHIN the window frame only — it does not
20
- * reorder the `View`, which is what the view-level `sort` does.
21
- */
22
- order_by?: WindowSort | null;
23
- /**
24
- * A frame of the `rows` preceding each row, plus the row itself.
25
- * Mutually exclusive with `range` and `cumulative`.
26
- */
27
- rows?: number | null;
28
- /**
29
- * A frame of the rows whose `order_by` value lies within `range` of
30
- * each row's, requiring a numeric or temporal `order_by`. Mutually
31
- * exclusive with `rows` and `cumulative`.
32
- */
33
- range?: number | null;
34
- /**
35
- * `true` frames all rows from the partition start through each row.
36
- * Default can be omitted.
37
- */
38
- cumulative?: boolean | null;
39
- /**
40
- * Row offset for `lag`/`lead` (default 1).
41
- */
42
- offset?: number | null;
43
- /**
44
- * Smoothing factor in `(0, 1]` for `ema`.
45
- */
46
- alpha?: number | null;
47
- };
@@ -1,10 +0,0 @@
1
- import type { WindowSpec } from "./WindowSpec.js";
2
- /**
3
- * The window columns of a `ViewConfig`, keyed by output column alias -
4
- * symmetric with `expressions` (`{"name": {...spec}}`). An alias must not
5
- * collide with a `Table` column, expression alias, or another window's
6
- * key.
7
- */
8
- export type Windows = {
9
- [key in string]?: WindowSpec;
10
- };