@perspective-dev/client 5.0.0 → 5.1.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 (42) 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.js +10 -10
  8. package/dist/esm/perspective.node.js.map +2 -2
  9. package/dist/esm/ts-rs/AggSpec.d.ts +8 -0
  10. package/dist/esm/ts-rs/Features.d.ts +59 -0
  11. package/dist/esm/ts-rs/ViewConfig.d.ts +2 -0
  12. package/dist/esm/ts-rs/ViewConfigUpdate.d.ts +9 -0
  13. package/dist/esm/ts-rs/WindowAggregate.d.ts +1 -0
  14. package/dist/esm/ts-rs/WindowSort.d.ts +7 -0
  15. package/dist/esm/ts-rs/WindowSortDir.d.ts +6 -0
  16. package/dist/esm/ts-rs/WindowSpec.d.ts +46 -0
  17. package/dist/esm/ts-rs/Windows.d.ts +10 -0
  18. package/dist/esm/virtual_server.d.ts +8 -34
  19. package/dist/esm/virtual_servers/clickhouse.js +1 -1
  20. package/dist/esm/virtual_servers/clickhouse.js.map +3 -3
  21. package/dist/esm/virtual_servers/duckdb.d.ts +6 -26
  22. package/dist/esm/virtual_servers/duckdb.js +1 -1
  23. package/dist/esm/virtual_servers/duckdb.js.map +3 -3
  24. package/dist/wasm/perspective-js.d.ts +96 -6
  25. package/dist/wasm/perspective-js.js +11 -11
  26. package/dist/wasm/perspective-js.wasm +0 -0
  27. package/dist/wasm/perspective-js.wasm.d.ts +5 -5
  28. package/package.json +1 -1
  29. package/src/rust/lib.rs +6 -0
  30. package/src/rust/virtual_server.rs +98 -2
  31. package/src/ts/ts-rs/AggSpec.ts +10 -0
  32. package/src/ts/ts-rs/Features.ts +54 -0
  33. package/src/ts/ts-rs/ViewConfig.ts +2 -1
  34. package/src/ts/ts-rs/ViewConfigUpdate.ts +9 -0
  35. package/src/ts/ts-rs/WindowAggregate.ts +3 -0
  36. package/src/ts/ts-rs/WindowSort.ts +9 -0
  37. package/src/ts/ts-rs/WindowSortDir.ts +8 -0
  38. package/src/ts/ts-rs/WindowSpec.ts +46 -0
  39. package/src/ts/ts-rs/Windows.ts +10 -0
  40. package/src/ts/virtual_server.ts +17 -55
  41. package/src/ts/virtual_servers/clickhouse.ts +44 -2
  42. package/src/ts/virtual_servers/duckdb.ts +43 -3
@@ -1,6 +1,90 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
+ /**
5
+ * A table hosted by a `VirtualServerHandler`, as returned by
6
+ * `getHostedTables()`. A plain `string` is shorthand for `{ name }`.
7
+ */
8
+ export interface VirtualHostedTable {
9
+ name: string;
10
+ index?: string;
11
+ limit?: number;
12
+ }
13
+
14
+ /**
15
+ * Handler interface that you implement to provide custom data sources.
16
+ *
17
+ * All methods will be called by the `VirtualServer` when handling protocol
18
+ * messages from Perspective clients. Methods can return values directly or
19
+ * return Promises for asynchronous operations (e.g., database queries).
20
+ * Optional methods fall back to defaults documented per-method.
21
+ */
22
+ export interface VirtualServerHandler {
23
+ getHostedTables():
24
+ | (string | VirtualHostedTable)[]
25
+ | Promise<(string | VirtualHostedTable)[]>;
26
+ tableSchema(
27
+ tableId: string,
28
+ ): Record<string, ColumnType> | Promise<Record<string, ColumnType>>;
29
+ tableSize(tableId: string): number | Promise<number>;
30
+ tableMakeView(
31
+ tableId: string,
32
+ viewId: string,
33
+ config: ViewConfigUpdate,
34
+ ): void | Promise<void>;
35
+ viewDelete(viewId: string): void | Promise<void>;
36
+ viewGetData(
37
+ viewId: string,
38
+ config: ViewConfig,
39
+ schema: Record<string, ColumnType>,
40
+ viewport: ViewWindow,
41
+ dataSlice: VirtualDataSlice,
42
+ ): void | Promise<void>;
43
+
44
+ /** Defaults to `tableSchema(viewId)`. */
45
+ viewSchema?(
46
+ viewId: string,
47
+ config: ViewConfig,
48
+ ): Record<string, ColumnType> | Promise<Record<string, ColumnType>>;
49
+
50
+ /** Defaults to `tableSize(viewId)`. */
51
+ viewSize?(viewId: string): number | Promise<number>;
52
+
53
+ /** Defaults to the length of `tableSchema(tableId)`. */
54
+ tableColumnsSize?(tableId: string): number | Promise<number>;
55
+
56
+ /** Defaults to the length of `viewSchema(viewId, config)`. */
57
+ viewColumnSize?(
58
+ viewId: string,
59
+ config: ViewConfig,
60
+ ): number | Promise<number>;
61
+
62
+ /** Required when `getFeatures()` reports `expressions: true`. */
63
+ tableValidateExpression?(
64
+ tableId: string,
65
+ expression: string,
66
+ ): ColumnType | Promise<ColumnType>;
67
+
68
+ viewGetMinMax?(
69
+ viewId: string,
70
+ columnName: string,
71
+ config: ViewConfig,
72
+ ): { min: Scalar; max: Scalar } | Promise<{ min: Scalar; max: Scalar }>;
73
+
74
+ /** Defaults to no optional features. */
75
+ getFeatures?(): Features | Promise<Features>;
76
+
77
+ /** Defaults to port `0`. */
78
+ tableMakePort?(): number | Promise<number>;
79
+
80
+ makeTable?(
81
+ tableId: string,
82
+ data: string | Uint8Array,
83
+ ): void | Promise<void>;
84
+ }
85
+
86
+
87
+
4
88
  export type * from "../../src/ts/ts-rs/ViewWindow.d.ts";
5
89
  export type * from "../../src/ts/ts-rs/ColumnType.d.ts";
6
90
  export type * from "../../src/ts/ts-rs/ColumnWindow.d.ts";
@@ -18,6 +102,9 @@ export type * from "../../src/ts/ts-rs/ViewConfig.d.ts";
18
102
  export type * from "../../src/ts/ts-rs/JoinOptions.ts";
19
103
  export type * from "../../src/ts/ts-rs/JoinType.ts";
20
104
  export type * from "../../src/ts/ts-rs/TypedArrayWindow.ts";
105
+ export type * from "../../src/ts/ts-rs/Features.ts";
106
+ export type * from "../../src/ts/ts-rs/AggSpec.ts";
107
+ export type * from "../../src/ts/ts-rs/WindowAggregate.ts";
21
108
 
22
109
  import type {ColumnWindow} from "../../src/ts/ts-rs/ColumnWindow.d.ts";
23
110
  import type {ColumnType} from "../../src/ts/ts-rs/ColumnType.d.ts";
@@ -32,6 +119,9 @@ import type {OnUpdateOptions} from "../../src/ts/ts-rs/OnUpdateOptions.d.ts";
32
119
  import type {UpdateOptions} from "../../src/ts/ts-rs/UpdateOptions.d.ts";
33
120
  import type {DeleteOptions} from "../../src/ts/ts-rs/DeleteOptions.d.ts";
34
121
  import type {SystemInfo} from "../../src/ts/ts-rs/SystemInfo.d.ts";
122
+ import type {ViewConfig} from "../../src/ts/ts-rs/ViewConfig.d.ts";
123
+ import type {Scalar} from "../../src/ts/ts-rs/Scalar.d.ts";
124
+ import type {Features} from "../../src/ts/ts-rs/Features.ts";
35
125
 
36
126
 
37
127
 
@@ -773,7 +863,7 @@ export class VirtualServer {
773
863
  free(): void;
774
864
  [Symbol.dispose](): void;
775
865
  handleRequest(bytes: Uint8Array): Promise<any>;
776
- constructor(handler: object);
866
+ constructor(handler: VirtualServerHandler);
777
867
  }
778
868
 
779
869
  export function init(): void;
@@ -874,11 +964,11 @@ export interface InitOutput {
874
964
  readonly virtualdataslice_setStringCol: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
875
965
  readonly virtualserver_handleRequest: (a: number, b: number, c: number) => number;
876
966
  readonly virtualserver_new: (a: number, b: number) => void;
877
- readonly __wasm_bindgen_func_elem_1082: (a: number, b: number) => void;
878
- readonly __wasm_bindgen_func_elem_4003: (a: number, b: number) => void;
879
- readonly __wasm_bindgen_func_elem_11001: (a: number, b: number, c: number, d: number) => void;
880
- readonly __wasm_bindgen_func_elem_4020: (a: number, b: number, c: number) => void;
881
- readonly __wasm_bindgen_func_elem_1766: (a: number, b: number) => number;
967
+ readonly __wasm_bindgen_func_elem_1125: (a: number, b: number) => void;
968
+ readonly __wasm_bindgen_func_elem_4193: (a: number, b: number) => void;
969
+ readonly __wasm_bindgen_func_elem_11388: (a: number, b: number, c: number, d: number) => void;
970
+ readonly __wasm_bindgen_func_elem_4210: (a: number, b: number, c: number) => void;
971
+ readonly __wasm_bindgen_func_elem_1843: (a: number, b: number) => number;
882
972
  readonly __wbindgen_export: (a: number, b: number) => number;
883
973
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
884
974
  readonly __wbindgen_export3: (a: number) => void;
@@ -1649,7 +1649,7 @@ export class VirtualServer {
1649
1649
  return takeObject(ret);
1650
1650
  }
1651
1651
  /**
1652
- * @param {object} handler
1652
+ * @param {VirtualServerHandler} handler
1653
1653
  */
1654
1654
  constructor(handler) {
1655
1655
  try {
@@ -2016,7 +2016,7 @@ function __wbg_get_imports() {
2016
2016
  const a = state0.a;
2017
2017
  state0.a = 0;
2018
2018
  try {
2019
- return __wasm_bindgen_func_elem_11001(a, state0.b, arg0, arg1);
2019
+ return __wasm_bindgen_func_elem_11388(a, state0.b, arg0, arg1);
2020
2020
  } finally {
2021
2021
  state0.a = a;
2022
2022
  }
@@ -2175,12 +2175,12 @@ function __wbg_get_imports() {
2175
2175
  },
2176
2176
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
2177
2177
  // Cast intrinsic for `Closure(Closure { dtor_idx: 12, function: Function { arguments: [], shim_idx: 31, ret: NamedExternref("Promise<any>"), inner_ret: Some(NamedExternref("Promise<any>")) }, mutable: false }) -> Externref`.
2178
- const ret = makeClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_1082, __wasm_bindgen_func_elem_1766);
2178
+ const ret = makeClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_1125, __wasm_bindgen_func_elem_1843);
2179
2179
  return addHeapObject(ret);
2180
2180
  },
2181
2181
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
2182
- // Cast intrinsic for `Closure(Closure { dtor_idx: 568, function: Function { arguments: [Externref], shim_idx: 569, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2183
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_4003, __wasm_bindgen_func_elem_4020);
2182
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 575, function: Function { arguments: [Externref], shim_idx: 576, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2183
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_4193, __wasm_bindgen_func_elem_4210);
2184
2184
  return addHeapObject(ret);
2185
2185
  },
2186
2186
  __wbindgen_cast_0000000000000003: function(arg0) {
@@ -2257,17 +2257,17 @@ function __wbg_get_imports() {
2257
2257
  };
2258
2258
  }
2259
2259
 
2260
- function __wasm_bindgen_func_elem_1766(arg0, arg1) {
2261
- const ret = wasm.__wasm_bindgen_func_elem_1766(arg0, arg1);
2260
+ function __wasm_bindgen_func_elem_1843(arg0, arg1) {
2261
+ const ret = wasm.__wasm_bindgen_func_elem_1843(arg0, arg1);
2262
2262
  return takeObject(ret);
2263
2263
  }
2264
2264
 
2265
- function __wasm_bindgen_func_elem_4020(arg0, arg1, arg2) {
2266
- wasm.__wasm_bindgen_func_elem_4020(arg0, arg1, addHeapObject(arg2));
2265
+ function __wasm_bindgen_func_elem_4210(arg0, arg1, arg2) {
2266
+ wasm.__wasm_bindgen_func_elem_4210(arg0, arg1, addHeapObject(arg2));
2267
2267
  }
2268
2268
 
2269
- function __wasm_bindgen_func_elem_11001(arg0, arg1, arg2, arg3) {
2270
- wasm.__wasm_bindgen_func_elem_11001(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
2269
+ function __wasm_bindgen_func_elem_11388(arg0, arg1, arg2, arg3) {
2270
+ wasm.__wasm_bindgen_func_elem_11388(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
2271
2271
  }
2272
2272
 
2273
2273
  const ClientFinalization = (typeof FinalizationRegistry === 'undefined')
Binary file
@@ -93,11 +93,11 @@ export const virtualdataslice_setIntegerCol: (a: number, b: number, c: number, d
93
93
  export const virtualdataslice_setStringCol: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
94
94
  export const virtualserver_handleRequest: (a: number, b: number, c: number) => number;
95
95
  export const virtualserver_new: (a: number, b: number) => void;
96
- export const __wasm_bindgen_func_elem_1082: (a: number, b: number) => void;
97
- export const __wasm_bindgen_func_elem_4003: (a: number, b: number) => void;
98
- export const __wasm_bindgen_func_elem_11001: (a: number, b: number, c: number, d: number) => void;
99
- export const __wasm_bindgen_func_elem_4020: (a: number, b: number, c: number) => void;
100
- export const __wasm_bindgen_func_elem_1766: (a: number, b: number) => number;
96
+ export const __wasm_bindgen_func_elem_1125: (a: number, b: number) => void;
97
+ export const __wasm_bindgen_func_elem_4193: (a: number, b: number) => void;
98
+ export const __wasm_bindgen_func_elem_11388: (a: number, b: number, c: number, d: number) => void;
99
+ export const __wasm_bindgen_func_elem_4210: (a: number, b: number, c: number) => void;
100
+ export const __wasm_bindgen_func_elem_1843: (a: number, b: number) => number;
101
101
  export const __wbindgen_export: (a: number, b: number) => number;
102
102
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
103
103
  export const __wbindgen_export3: (a: number) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perspective-dev/client",
3
- "version": "5.0.0",
3
+ "version": "5.1.0",
4
4
  "description": "Client for Perspective, a high-performance WASM engine with reactive Tables, Views, and joins.",
5
5
  "keywords": [
6
6
  "perspective",
package/src/rust/lib.rs CHANGED
@@ -64,6 +64,9 @@ export type * from "../../src/ts/ts-rs/ViewConfig.d.ts";
64
64
  export type * from "../../src/ts/ts-rs/JoinOptions.ts";
65
65
  export type * from "../../src/ts/ts-rs/JoinType.ts";
66
66
  export type * from "../../src/ts/ts-rs/TypedArrayWindow.ts";
67
+ export type * from "../../src/ts/ts-rs/Features.ts";
68
+ export type * from "../../src/ts/ts-rs/AggSpec.ts";
69
+ export type * from "../../src/ts/ts-rs/WindowAggregate.ts";
67
70
 
68
71
  import type {ColumnWindow} from "../../src/ts/ts-rs/ColumnWindow.d.ts";
69
72
  import type {ColumnType} from "../../src/ts/ts-rs/ColumnType.d.ts";
@@ -78,6 +81,9 @@ import type {OnUpdateOptions} from "../../src/ts/ts-rs/OnUpdateOptions.d.ts";
78
81
  import type {UpdateOptions} from "../../src/ts/ts-rs/UpdateOptions.d.ts";
79
82
  import type {DeleteOptions} from "../../src/ts/ts-rs/DeleteOptions.d.ts";
80
83
  import type {SystemInfo} from "../../src/ts/ts-rs/SystemInfo.d.ts";
84
+ import type {ViewConfig} from "../../src/ts/ts-rs/ViewConfig.d.ts";
85
+ import type {Scalar} from "../../src/ts/ts-rs/Scalar.d.ts";
86
+ import type {Features} from "../../src/ts/ts-rs/Features.ts";
81
87
  "#;
82
88
 
83
89
  #[cfg(feature = "export-init")]
@@ -74,6 +74,102 @@ fn jsvalue_to_scalar(val: &JsValue) -> perspective_client::config::Scalar {
74
74
  }
75
75
  }
76
76
 
77
+ // This interface is the TypeScript contract for [`JsServerHandler`] below.
78
+ // There is no codegen tying the two together - every method dispatched via
79
+ // `Reflect::get` in this file MUST be declared here, with the exact argument
80
+ // and return types the `Reflect` call sites accept. Keep them in sync when
81
+ // editing either.
82
+ #[wasm_bindgen(typescript_custom_section)]
83
+ const TS_VIRTUAL_SERVER_HANDLER: &'static str = r#"
84
+ /**
85
+ * A table hosted by a `VirtualServerHandler`, as returned by
86
+ * `getHostedTables()`. A plain `string` is shorthand for `{ name }`.
87
+ */
88
+ export interface VirtualHostedTable {
89
+ name: string;
90
+ index?: string;
91
+ limit?: number;
92
+ }
93
+
94
+ /**
95
+ * Handler interface that you implement to provide custom data sources.
96
+ *
97
+ * All methods will be called by the `VirtualServer` when handling protocol
98
+ * messages from Perspective clients. Methods can return values directly or
99
+ * return Promises for asynchronous operations (e.g., database queries).
100
+ * Optional methods fall back to defaults documented per-method.
101
+ */
102
+ export interface VirtualServerHandler {
103
+ getHostedTables():
104
+ | (string | VirtualHostedTable)[]
105
+ | Promise<(string | VirtualHostedTable)[]>;
106
+ tableSchema(
107
+ tableId: string,
108
+ ): Record<string, ColumnType> | Promise<Record<string, ColumnType>>;
109
+ tableSize(tableId: string): number | Promise<number>;
110
+ tableMakeView(
111
+ tableId: string,
112
+ viewId: string,
113
+ config: ViewConfigUpdate,
114
+ ): void | Promise<void>;
115
+ viewDelete(viewId: string): void | Promise<void>;
116
+ viewGetData(
117
+ viewId: string,
118
+ config: ViewConfig,
119
+ schema: Record<string, ColumnType>,
120
+ viewport: ViewWindow,
121
+ dataSlice: VirtualDataSlice,
122
+ ): void | Promise<void>;
123
+
124
+ /** Defaults to `tableSchema(viewId)`. */
125
+ viewSchema?(
126
+ viewId: string,
127
+ config: ViewConfig,
128
+ ): Record<string, ColumnType> | Promise<Record<string, ColumnType>>;
129
+
130
+ /** Defaults to `tableSize(viewId)`. */
131
+ viewSize?(viewId: string): number | Promise<number>;
132
+
133
+ /** Defaults to the length of `tableSchema(tableId)`. */
134
+ tableColumnsSize?(tableId: string): number | Promise<number>;
135
+
136
+ /** Defaults to the length of `viewSchema(viewId, config)`. */
137
+ viewColumnSize?(
138
+ viewId: string,
139
+ config: ViewConfig,
140
+ ): number | Promise<number>;
141
+
142
+ /** Required when `getFeatures()` reports `expressions: true`. */
143
+ tableValidateExpression?(
144
+ tableId: string,
145
+ expression: string,
146
+ ): ColumnType | Promise<ColumnType>;
147
+
148
+ viewGetMinMax?(
149
+ viewId: string,
150
+ columnName: string,
151
+ config: ViewConfig,
152
+ ): { min: Scalar; max: Scalar } | Promise<{ min: Scalar; max: Scalar }>;
153
+
154
+ /** Defaults to no optional features. */
155
+ getFeatures?(): Features | Promise<Features>;
156
+
157
+ /** Defaults to port `0`. */
158
+ tableMakePort?(): number | Promise<number>;
159
+
160
+ makeTable?(
161
+ tableId: string,
162
+ data: string | Uint8Array,
163
+ ): void | Promise<void>;
164
+ }
165
+ "#;
166
+
167
+ #[wasm_bindgen]
168
+ extern "C" {
169
+ #[wasm_bindgen(typescript_type = "VirtualServerHandler")]
170
+ pub type JsVirtualServerHandler;
171
+ }
172
+
77
173
  pub struct JsServerHandler(Object);
78
174
 
79
175
  impl JsServerHandler {
@@ -785,9 +881,9 @@ pub struct VirtualServer(Rc<UnsafeCell<virtual_server::VirtualServer<JsServerHan
785
881
  #[wasm_bindgen]
786
882
  impl VirtualServer {
787
883
  #[wasm_bindgen(constructor)]
788
- pub fn new(handler: Object) -> Result<VirtualServer, JsValue> {
884
+ pub fn new(handler: JsVirtualServerHandler) -> Result<VirtualServer, JsValue> {
789
885
  Ok(VirtualServer(Rc::new(UnsafeCell::new(
790
- virtual_server::VirtualServer::new(JsServerHandler(handler)),
886
+ virtual_server::VirtualServer::new(JsServerHandler(handler.unchecked_into())),
791
887
  ))))
792
888
  }
793
889
 
@@ -0,0 +1,10 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ import type { ColumnType } from "./ColumnType.js";
3
+
4
+ /**
5
+ * Specification for an aggregate function.
6
+ *
7
+ * Aggregates can either take no additional arguments ([`AggSpec::Single`])
8
+ * or require column type arguments ([`AggSpec::Multiple`]).
9
+ */
10
+ export type AggSpec = string | [string, Array<ColumnType>];
@@ -0,0 +1,54 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ import type { AggSpec } from "./AggSpec.js";
3
+ import type { ColumnType } from "./ColumnType.js";
4
+ import type { GroupRollupMode } from "./GroupRollupMode.js";
5
+ import type { WindowAggregate } from "./WindowAggregate.js";
6
+
7
+ /**
8
+ * Describes the capabilities supported by a virtual server handler.
9
+ *
10
+ * This struct is returned by
11
+ * [`VirtualServerHandler::get_features`](super::VirtualServerHandler::get_features)
12
+ * to inform clients about which operations are available.
13
+ */
14
+ export type Features = {
15
+ /**
16
+ * Whether group-by aggregation is supported.
17
+ */
18
+ group_by?: boolean,
19
+ /**
20
+ * Which `group_by_rollup_mode` options are supported
21
+ */
22
+ group_rollup_mode?: Array<GroupRollupMode>,
23
+ /**
24
+ * Whether split-by (pivot) operations are supported.
25
+ */
26
+ split_by?: boolean,
27
+ /**
28
+ * Available filter operators per column type.
29
+ */
30
+ filter_ops?: { [key in ColumnType]?: Array<string> },
31
+ /**
32
+ * Available aggregate functions per column type.
33
+ */
34
+ aggregates?: { [key in ColumnType]?: Array<AggSpec> },
35
+ /**
36
+ * Whether sorting is supported.
37
+ */
38
+ sort?: boolean,
39
+ /**
40
+ * Whether computed expressions are supported.
41
+ */
42
+ expressions?: boolean,
43
+ /**
44
+ * Available window aggregates.
45
+ */
46
+ window_aggregates?: { [key in ColumnType]?: Array<WindowAggregate> },
47
+ /**
48
+ * Whether update callbacks are supported.
49
+ */
50
+ on_update?: boolean,
51
+ /**
52
+ * The data store has no reliable natural row order
53
+ */
54
+ unordered?: boolean, };
@@ -5,5 +5,6 @@ import type { Filter } from "./Filter.js";
5
5
  import type { FilterReducer } from "./FilterReducer.js";
6
6
  import type { GroupRollupMode } from "./GroupRollupMode.js";
7
7
  import type { Sort } from "./Sort.js";
8
+ import type { Windows } from "./Windows.js";
8
9
 
9
- export type ViewConfig = { group_by: Array<string>, split_by: Array<string>, sort: Array<Sort>, filter: Array<Filter>, group_rollup_mode: GroupRollupMode, filter_op?: FilterReducer, expressions: Expressions, columns: Array<string | null>, aggregates: { [key in string]?: Aggregate }, group_by_depth?: number | null, };
10
+ export type ViewConfig = { group_by: Array<string>, split_by: Array<string>, sort: Array<Sort>, filter: Array<Filter>, group_rollup_mode: GroupRollupMode, filter_op?: FilterReducer, expressions: Expressions, windows?: Windows, columns: Array<string | null>, aggregates: { [key in string]?: Aggregate }, group_by_depth?: number | null, };
@@ -5,6 +5,7 @@ import type { Filter } from "./Filter.js";
5
5
  import type { FilterReducer } from "./FilterReducer.js";
6
6
  import type { GroupRollupMode } from "./GroupRollupMode.js";
7
7
  import type { Sort } from "./Sort.js";
8
+ import type { Windows } from "./Windows.js";
8
9
 
9
10
  export type ViewConfigUpdate = {
10
11
  /**
@@ -72,6 +73,14 @@ sort?: Array<Sort>,
72
73
  * panel.
73
74
  */
74
75
  expressions?: Expressions,
76
+ /**
77
+ * The `windows` property declares ordered, partitioned rolling
78
+ * computations (moving aggregates, cumulative sums) as _new_ columns
79
+ * keyed by output alias (`{"name": {...spec}}`, symmetric with
80
+ * `expressions`), analogous to SQL window functions. See
81
+ * [`crate::config::WindowSpec`].
82
+ */
83
+ windows?: Windows,
75
84
  /**
76
85
  * Aggregates perform a calculation over an entire column, and are
77
86
  * displayed when one or more [Group By](#group-by) are applied to the
@@ -0,0 +1,3 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+
3
+ export type WindowAggregate = "sum" | "avg" | "count" | "min" | "max" | "stddev" | "var" | "first" | "last" | "lag" | "lead" | "diff" | "rate" | "ema";
@@ -0,0 +1,9 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ import type { WindowSortDir } from "./WindowSortDir.js";
3
+
4
+ /**
5
+ * The `Table` column which orders each partition, with its direction -
6
+ * serialized as a two-element array (`["ts", "desc"]`), symmetric with the
7
+ * `ViewConfig`'s `sort` field.
8
+ */
9
+ export type WindowSort = [string, WindowSortDir];
@@ -0,0 +1,8 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+
3
+ /**
4
+ * A window's order direction. A dedicated two-variant enum rather than
5
+ * [`crate::config::SortDir`] - the column-sort extras (`col asc`, `abs`,
6
+ * `none`) are meaningless inside a window frame and unrepresentable here.
7
+ */
8
+ export type WindowSortDir = "asc" | "desc";
@@ -0,0 +1,46 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ import type { WindowAggregate } from "./WindowAggregate.js";
3
+ import type { WindowSort } from "./WindowSort.js";
4
+
5
+ /**
6
+ * The serialized form of [`WindowSpec`].
7
+ */
8
+ export type WindowSpec = {
9
+ /**
10
+ * The input column - either a real `Table` column or an expression
11
+ * alias from the same `ViewConfig`.
12
+ */
13
+ column: string, aggregate: WindowAggregate,
14
+ /**
15
+ * Columns whose distinct value tuples partition the rows; empty
16
+ * partitions the whole `Table` as one group.
17
+ */
18
+ partition_by?: Array<string>,
19
+ /**
20
+ * The `Table` column which orders each partition, and the direction.
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, };
@@ -0,0 +1,10 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ import type { WindowSpec } from "./WindowSpec.js";
3
+
4
+ /**
5
+ * The window columns of a `ViewConfig`, keyed by output column alias -
6
+ * symmetric with `expressions` (`{"name": {...spec}}`). An alias must not
7
+ * collide with a `Table` column, expression alias, or another window's
8
+ * key.
9
+ */
10
+ export type Windows = { [key in string]?: WindowSpec };
@@ -10,10 +10,6 @@
10
10
  // ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11
11
  // ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
12
 
13
- import { ColumnType } from "./ts-rs/ColumnType.ts";
14
- import { ViewConfig } from "./ts-rs/ViewConfig.ts";
15
- import { ViewWindow } from "./ts-rs/ViewWindow.ts";
16
-
17
13
  import type * as perspective from "../../dist/wasm/perspective-js.js";
18
14
 
19
15
  /**
@@ -26,63 +22,29 @@ import type * as perspective from "../../dist/wasm/perspective-js.js";
26
22
  * - Implementing custom aggregation or transformation logic
27
23
  * - Creating data adapters without copying data into Perspective tables
28
24
  *
25
+ * The `VirtualServerHandler` interface and `Features` struct are declared
26
+ * in Rust alongside the bridge that invokes them (`perspective-js`'s
27
+ * `virtual_server.rs` and `perspective-client`'s `features.rs`
28
+ * respectively) and re-exported here. `ServerFeatures` is a legacy alias
29
+ * for `Features`.
30
+ *
29
31
  * @module virtual_server
30
32
  */
31
33
 
32
- export interface ServerFeatures {
33
- expressions?: boolean;
34
- }
35
-
36
- /**
37
- * Handler interface that you implement to provide custom data sources.
38
- *
39
- * All methods will be called by the VirtualServer when handling protocol
40
- * messages from Perspective clients. Methods can return values directly or
41
- * return Promises for asynchronous operations (e.g., database queries).
42
- */
43
- export interface VirtualServerHandler {
44
- getHostedTables(): string[] | Promise<string[]>;
45
- tableSchema(
46
- tableId: string,
47
- ): Record<string, ColumnType> | Promise<Record<string, ColumnType>>;
48
- tableSize(tableId: string): number | Promise<number>;
49
- tableMakeView(
50
- tableId: string,
51
- viewId: string,
52
- config: ViewConfig,
53
- ): void | Promise<void>;
54
- viewDelete(viewId: string): void | Promise<void>;
55
- viewGetData(
56
- viewId: string,
57
- config: ViewConfig,
58
- schema: Record<string, ColumnType>,
59
- viewport: ViewWindow,
60
- dataSlice: perspective.VirtualDataSlice,
61
- ): void | Promise<void>;
62
- viewSchema?(
63
- viewId: string,
64
- config?: ViewConfig,
65
- ): Record<string, ColumnType> | Promise<Record<string, ColumnType>>;
66
- viewSize?(viewId: string): number | Promise<number>;
67
- tableValidateExpression?(
68
- tableId: string,
69
- expression: string,
70
- ): ColumnType | Promise<ColumnType>;
71
- viewGetMinMax?(
72
- viewId: string,
73
- columnName: string,
74
- config: ViewConfig,
75
- ): { min: any; max: any } | Promise<{ min: any; max: any }>;
76
- getFeatures?(): ServerFeatures | Promise<ServerFeatures>;
77
- makeTable?(
78
- tableId: string,
79
- data: string | Uint8Array,
80
- ): void | Promise<void>;
81
- }
34
+ // `Features` must re-export from the wasm `.d.ts` (NOT "./ts-rs/Features.ts")
35
+ // - `perspective.browser.ts` star-exports both this module and the wasm
36
+ // `.d.ts`, and star exports of the same name only merge when they resolve to
37
+ // the same declaration.
38
+ export type {
39
+ VirtualServerHandler,
40
+ VirtualHostedTable,
41
+ Features,
42
+ Features as ServerFeatures,
43
+ } from "../../dist/wasm/perspective-js.js";
82
44
 
83
45
  export function createMessageHandler(
84
46
  mod: typeof perspective,
85
- handler: VirtualServerHandler,
47
+ handler: perspective.VirtualServerHandler,
86
48
  ) {
87
49
  let virtualServer: perspective.VirtualServer;
88
50
  async function postMessage(port: MessagePort, msg: MessageEvent) {