@vuu-ui/vuu-data-local 3.4.1 → 3.5.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.4.1",
2
+ "version": "3.5.0-beta.2",
3
3
  "main": "./src/index.js",
4
4
  "author": "heswell",
5
5
  "license": "Apache-2.0",
@@ -10,14 +10,14 @@
10
10
  "type-defs": "node ../../scripts/build-type-defs.mjs"
11
11
  },
12
12
  "devDependencies": {
13
- "@vuu-ui/vuu-data-types": "3.4.1",
14
- "@vuu-ui/vuu-table-types": "3.4.1",
15
- "@vuu-ui/vuu-filter-types": "3.4.1",
16
- "@vuu-ui/vuu-protocol-types": "3.4.1"
13
+ "@vuu-ui/vuu-data-types": "3.5.0-beta.2",
14
+ "@vuu-ui/vuu-table-types": "3.5.0-beta.2",
15
+ "@vuu-ui/vuu-filter-types": "3.5.0-beta.2",
16
+ "@vuu-ui/vuu-protocol-types": "3.5.0-beta.2"
17
17
  },
18
18
  "dependencies": {
19
- "@vuu-ui/vuu-filter-parser": "3.4.1",
20
- "@vuu-ui/vuu-utils": "3.4.1"
19
+ "@vuu-ui/vuu-filter-parser": "3.5.0-beta.2",
20
+ "@vuu-ui/vuu-utils": "3.5.0-beta.2"
21
21
  },
22
22
  "sideEffects": false,
23
23
  "files": [
@@ -1,5 +1,5 @@
1
1
  import { filterPredicate, parseFilter } from "@vuu-ui/vuu-filter-parser";
2
- import { EventEmitter, KeySet, NULL_RANGE, Range, buildColumnMap, combineFilters, filterAsQuery, getAddedItems, hasBaseFilter, hasFilter, hasGroupBy, hasSort, isConfigChanged, isGroupByChanged, logger, metadataKeys, rangeNewItems, toSchemaColumn, uuid, vanillaConfig, withConfigDefaults } from "@vuu-ui/vuu-utils";
2
+ import { EventEmitter, KeySet, NULL_RANGE, Range, buildColumnMap, combineFilters, filterAsQuery, filterRequiresResolution, getAddedItems, getColumnsByName, getColumnsByNameForFilter, hasBaseFilter, hasFilter, hasGroupBy, hasSort, isConfigChanged, isGroupByChanged, logger, metadataKeys, rangeNewItems, toSchemaColumn, uuid, vanillaConfig, withConfigDefaults } from "@vuu-ui/vuu-utils";
3
3
  import { aggregateData } from "./aggregate-utils.js";
4
4
  import { buildDataToClientMap, toClientRow } from "./array-data-utils.js";
5
5
  import { collapseGroup, expandGroup, groupRows } from "./group-utils.js";
@@ -49,6 +49,7 @@ class ArrayDataSource extends EventEmitter {
49
49
  openTreeNodes = [];
50
50
  preserveScrollPositionAcrossConfigChange = false;
51
51
  #columnMap;
52
+ #filterColumnsByName;
52
53
  _config = vanillaConfig;
53
54
  #data;
54
55
  #freezeTimestamp = void 0;
@@ -68,6 +69,7 @@ class ArrayDataSource extends EventEmitter {
68
69
  super();
69
70
  if (!data || !columnDescriptors) throw Error("ArrayDataSource constructor called without data or without columnDescriptors");
70
71
  this.columnDescriptors = columnDescriptors;
72
+ this.#filterColumnsByName = getColumnsByName(columnDescriptors);
71
73
  this.dataMap = dataMap;
72
74
  this.key = keyColumn ? this.columnDescriptors.findIndex((col)=>col.name === keyColumn) : 0;
73
75
  this.rangeChangeRowset = rangeChangeRowset;
@@ -316,7 +318,8 @@ class ArrayDataSource extends EventEmitter {
316
318
  });
317
319
  }
318
320
  getFilterPredicate() {
319
- const { filterSpec: { filterStruct } } = combineFilters(this._config);
321
+ const { filterSpec: { filter, filterStruct: rawFilterStruct } } = combineFilters(this._config);
322
+ const filterStruct = rawFilterStruct && filter && filterRequiresResolution(rawFilterStruct, getColumnsByNameForFilter(this.tableSchema, this.#filterColumnsByName)) ? parseFilter(filter) : rawFilterStruct;
320
323
  if (filterStruct) {
321
324
  if (this.dataMap) {
322
325
  const { count: offset } = metadataKeys;
@@ -617,9 +620,15 @@ class ArrayDataSource extends EventEmitter {
617
620
  filterSpec: filter
618
621
  };
619
622
  }
620
- setFilter(filter) {
623
+ setFilter(filter, options) {
624
+ this.#filterColumnsByName = {
625
+ ...getColumnsByName(this.columnDescriptors),
626
+ ...options?.columnsByName
627
+ };
621
628
  const dataSourceFilter = {
622
- filter: filterAsQuery(filter),
629
+ filter: filterAsQuery(filter, {
630
+ columnsByName: getColumnsByNameForFilter(this.tableSchema, this.#filterColumnsByName)
631
+ }),
623
632
  filterStruct: filter
624
633
  };
625
634
  this.filter = dataSourceFilter;
@@ -164,6 +164,7 @@ class TreeDataSource extends BaseDataSource {
164
164
  applySelectedKeyValues(keys, revealSelected = false) {
165
165
  keys.forEach((key)=>{
166
166
  const rowIdx = this.indexOfRowWithKey(key);
167
+ if (-1 === rowIdx) return;
167
168
  const row = this.#data[rowIdx];
168
169
  row[SELECTED] = 1;
169
170
  if (revealSelected && 1 !== row[DEPTH]) {
@@ -1,4 +1,4 @@
1
- import type { DataSourceBase, DataSourceConstructorProps, DataSourceEvents, DataSourceFilter, DataSourceRow, DataSourceRowWithBigint, DataSourceStatus, DataSourceSubscribeCallback, DataSourceSubscribeProps, TableSchema, WithBaseFilter, WithFullConfig } from "@vuu-ui/vuu-data-types";
1
+ import type { DataSourceBase, DataSourceConstructorProps, DataSourceEvents, DataSourceFilter, DataSourceRow, DataSourceRowWithBigint, DataSourceStatus, DataSourceSubscribeCallback, DataSourceSubscribeProps, SetFilterOptions, TableSchema, WithBaseFilter, WithFullConfig } from "@vuu-ui/vuu-data-types";
2
2
  import type { Filter } from "@vuu-ui/vuu-filter-types";
3
3
  import type { LinkDescriptorWithLabel, SelectRequest, VuuAggregation, VuuGroupBy, VuuMenu, VuuRowDataItemType, VuuRpcRequest, VuuRpcResponse, VuuSort } from "@vuu-ui/vuu-protocol-types";
4
4
  import type { ColumnDescriptor } from "@vuu-ui/vuu-table-types";
@@ -93,7 +93,7 @@ export declare class ArrayDataSource extends EventEmitter<DataSourceEvents> impl
93
93
  set baseFilter(baseFilter: DataSourceFilter | undefined);
94
94
  get filter(): DataSourceFilter;
95
95
  set filter(filter: DataSourceFilter);
96
- setFilter(filter: Filter): void;
96
+ setFilter(filter: Filter, options?: SetFilterOptions): void;
97
97
  clearFilter(): void;
98
98
  get groupBy(): VuuGroupBy;
99
99
  set groupBy(groupBy: VuuGroupBy);
@@ -1,8 +0,0 @@
1
- import type { DataSourceRowWithBigint } from "@vuu-ui/vuu-data-types";
2
- import type { VuuAggregation, VuuGroupBy } from "@vuu-ui/vuu-protocol-types";
3
- import type { ColumnMap } from "@vuu-ui/vuu-utils";
4
- import type { GroupMap } from "./group-utils";
5
- export declare const count: (arr: unknown[]) => number;
6
- export declare const aggregateData: (aggregations: VuuAggregation[], targetData: readonly DataSourceRowWithBigint[], groupBy: VuuGroupBy, leafData: readonly DataSourceRowWithBigint[], columnMap: ColumnMap, groupMap: GroupMap) => {
7
- [key: string]: number;
8
- };
@@ -1,111 +0,0 @@
1
- import type { DataSourceBase, DataSourceConstructorProps, DataSourceEvents, DataSourceFilter, DataSourceRow, DataSourceRowWithBigint, DataSourceStatus, DataSourceSubscribeCallback, DataSourceSubscribeProps, TableSchema, WithBaseFilter, WithFullConfig } from "@vuu-ui/vuu-data-types";
2
- import type { Filter } from "@vuu-ui/vuu-filter-types";
3
- import type { LinkDescriptorWithLabel, SelectRequest, VuuAggregation, VuuGroupBy, VuuMenu, VuuRowDataItemType, VuuRpcRequest, VuuRpcResponse, VuuSort } from "@vuu-ui/vuu-protocol-types";
4
- import type { ColumnDescriptor } from "@vuu-ui/vuu-table-types";
5
- import { type ColumnMap, EventEmitter, Range } from "@vuu-ui/vuu-utils";
6
- export interface ArrayDataSourceConstructorProps extends Omit<DataSourceConstructorProps, "bufferSize" | "table"> {
7
- columnDescriptors: readonly ColumnDescriptor[];
8
- data: Array<Array<bigint | VuuRowDataItemType>>;
9
- dataMap?: ColumnMap;
10
- keyColumn?: string;
11
- rangeChangeRowset?: "delta" | "full";
12
- }
13
- export declare class ArrayDataSource extends EventEmitter<DataSourceEvents> implements DataSourceBase<DataSourceRowWithBigint> {
14
- #private;
15
- protected clientCallback: DataSourceSubscribeCallback | undefined;
16
- protected columnDescriptors: readonly ColumnDescriptor[];
17
- /** sorted offsets of data within raw data, reflecting sort order
18
- * of columns specified by client.
19
- */
20
- private dataIndices;
21
- /** Map reflecting positions of data items in raw data */
22
- private dataMap;
23
- private groupMap;
24
- /** the index of key field within raw data row */
25
- private key;
26
- private lastRangeServed;
27
- private rangeChangeRowset;
28
- private openTreeNodes;
29
- private preserveScrollPositionAcrossConfigChange;
30
- protected _config: WithBaseFilter<WithFullConfig> & {
31
- visualLink?: LinkDescriptorWithLabel;
32
- };
33
- protected _menu: VuuMenu | undefined;
34
- protected selectedRows: Set<string>;
35
- protected index: Map<string, number>;
36
- tableSchema: TableSchema;
37
- viewport: string;
38
- protected processedData: DataSourceRowWithBigint[] | undefined;
39
- constructor({ aggregations, baseFilterSpec, columnDescriptors, data, dataMap, filterSpec, groupBy, keyColumn, rangeChangeRowset, sort, title, viewport, }: ArrayDataSourceConstructorProps);
40
- subscribe({ viewport, columns, aggregations, baseFilterSpec, range, sort, groupBy, filterSpec, }: DataSourceSubscribeProps, callback: DataSourceSubscribeCallback): Promise<void>;
41
- unsubscribe(): void;
42
- suspend(): void;
43
- resume(callback?: DataSourceSubscribeCallback): void;
44
- disable(): void;
45
- enable(): void;
46
- select(selectRequest: Omit<SelectRequest, "vpId">): void;
47
- private getRowKey;
48
- openTreeNode(keyOrIndex: string | number): void;
49
- closeTreeNode(keyOrIndex: string | number): void;
50
- get pageSize(): number;
51
- get links(): LinkDescriptorWithLabel[] | undefined;
52
- set links(links: LinkDescriptorWithLabel[] | undefined);
53
- get menu(): VuuMenu | undefined;
54
- get status(): DataSourceStatus;
55
- get data(): DataSourceRow<bigint | VuuRowDataItemType>[];
56
- get currentData(): DataSourceRow<bigint | VuuRowDataItemType>[];
57
- get table(): import("@vuu-ui/vuu-data-types").TableSchemaTable;
58
- get columns(): string[];
59
- set columns(columns: string[]);
60
- get config(): WithBaseFilter<WithFullConfig>;
61
- set config(config: WithBaseFilter<WithFullConfig>);
62
- private processNewColumns;
63
- private indexProcessedData;
64
- private getFilterPredicate;
65
- private applyConfig;
66
- get columnMap(): ColumnMap;
67
- get selectedRowsCount(): number;
68
- get size(): number;
69
- get maxRangeEnd(): number;
70
- get range(): Range;
71
- set range(range: Range);
72
- protected delete(row: VuuRowDataItemType[]): void;
73
- protected insert: (row: Array<bigint | VuuRowDataItemType>) => void;
74
- private insertIntoSortedData;
75
- private validateDataValue;
76
- protected updateDataItem: (keyValue: string, columnName: string, value: VuuRowDataItemType) => void;
77
- getRowByKey(key: string): DataSourceRow<bigint | VuuRowDataItemType> | undefined;
78
- getRowAtIndex(rowIndex: number): DataSourceRow<bigint | VuuRowDataItemType>;
79
- indexOfRowWithKey: (key: string) => number;
80
- protected update: (row: VuuRowDataItemType[], columnName: string) => void;
81
- protected updateRow: (row: Array<bigint | VuuRowDataItemType>, _columnName?: string) => void;
82
- protected handleDeleteFromTable: (key: string) => Promise<true | string>;
83
- private setRange;
84
- private constrainRangeToMaxRangeEnd;
85
- private get rangeWithBufferWithinMaxRangeEnd();
86
- sendSizeUpdateToClient(): void;
87
- sendRowsToClient(forceFullRefresh?: boolean, row?: DataSourceRowWithBigint): void;
88
- get aggregations(): VuuAggregation[];
89
- set aggregations(aggregations: VuuAggregation[]);
90
- get sort(): VuuSort;
91
- set sort(sort: VuuSort);
92
- get baseFilter(): DataSourceFilter | undefined;
93
- set baseFilter(baseFilter: DataSourceFilter | undefined);
94
- get filter(): DataSourceFilter;
95
- set filter(filter: DataSourceFilter);
96
- setFilter(filter: Filter): void;
97
- clearFilter(): void;
98
- get groupBy(): VuuGroupBy;
99
- set groupBy(groupBy: VuuGroupBy);
100
- get title(): string;
101
- set title(title: string);
102
- get _clientCallback(): DataSourceSubscribeCallback | undefined;
103
- createLink({ parentVpId, link: { fromColumn, toColumn }, }: LinkDescriptorWithLabel): void;
104
- removeLink(): void;
105
- remoteProcedureCall<T extends VuuRpcResponse = VuuRpcResponse>(): Promise<T>;
106
- menuRpcCall(rpcRequest: Omit<VuuRpcRequest, "vpId">): Promise<VuuRpcResponse>;
107
- freeze(): void;
108
- unfreeze(): void;
109
- get freezeTimestamp(): number | undefined;
110
- get isFrozen(): boolean;
111
- }
@@ -1,4 +0,0 @@
1
- import type { DataSourceRow, DataSourceRowWithBigint } from "@vuu-ui/vuu-data-types";
2
- import { ColumnMap, KeySet } from "@vuu-ui/vuu-utils";
3
- export declare const toClientRow: (row: DataSourceRowWithBigint, keys: KeySet, selectedRows: Set<string>, dataIndices?: number[]) => DataSourceRow;
4
- export declare const buildDataToClientMap: (columnMap: ColumnMap, dataMap?: ColumnMap) => number[] | undefined;
@@ -1,10 +0,0 @@
1
- import type { DataSourceRow } from "@vuu-ui/vuu-data-types";
2
- import type { VuuGroupBy, VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
3
- import { ColumnMap } from "@vuu-ui/vuu-utils";
4
- export type KeyList = number[];
5
- export type GroupMap = {
6
- [key: string]: GroupMap | KeyList;
7
- };
8
- export declare const collapseGroup: (key: string, groupedRows: readonly DataSourceRow<bigint | VuuRowDataItemType>[]) => DataSourceRow<bigint | VuuRowDataItemType>[];
9
- export declare const expandGroup: (keys: string[], sourceRows: readonly DataSourceRow<bigint | VuuRowDataItemType>[], groupBy: VuuGroupBy, columnMap: ColumnMap, groupMap: GroupMap, processedData: readonly DataSourceRow[]) => DataSourceRow[];
10
- export declare const groupRows: (rows: ReadonlyArray<Array<bigint | VuuRowDataItemType>>, groupBy: VuuGroupBy, columnMap: ColumnMap) => [DataSourceRow[], GroupMap];
@@ -1,10 +0,0 @@
1
- import type { DataSourceRowWithBigint } from "@vuu-ui/vuu-data-types";
2
- import type { VuuSort, VuuSortType } from "@vuu-ui/vuu-protocol-types";
3
- import { ColumnMap } from "@vuu-ui/vuu-utils";
4
- export type ColIndexSortDef = [number, VuuSortType];
5
- type SortCompareResult = 0 | 1 | -1;
6
- export type RowSortComparator = (item1: DataSourceRowWithBigint, item2: DataSourceRowWithBigint) => SortCompareResult;
7
- export declare const sortComparator: (sortDefs: ColIndexSortDef[]) => RowSortComparator;
8
- export declare const sortRows: (rows: readonly DataSourceRowWithBigint[], { sortDefs }: VuuSort, columnMap: ColumnMap) => DataSourceRowWithBigint[];
9
- export declare function binarySearch(items: DataSourceRowWithBigint[], item: DataSourceRowWithBigint, comparator: RowSortComparator): number;
10
- export {};
@@ -1,3 +0,0 @@
1
- export * from "./array-data-source/array-data-source";
2
- export * from "./json-data-source/JsonDataSource";
3
- export * from "./tree-data-source/TreeDataSource";
@@ -1,55 +0,0 @@
1
- import type { ColumnDescriptor } from "@vuu-ui/vuu-table-types";
2
- import type { LinkDescriptorWithLabel, VuuGroupBy, VuuAggregation, VuuSort, VuuRpcResponse, VuuRpcRequest, SelectRequest } from "@vuu-ui/vuu-protocol-types";
3
- import type { DataSourceFilter, DataSourceRow, DataSourceConstructorProps, DataSourceEvents, DataSourceStatus, DataSourceSubscribeCallback, DataSourceSubscribeProps, WithFullConfig, MenuRpcResponse, DataSourceBase } from "@vuu-ui/vuu-data-types";
4
- import { EventEmitter, JsonData, Range } from "@vuu-ui/vuu-utils";
5
- export interface JsonDataSourceConstructorProps extends Omit<DataSourceConstructorProps, "bufferSize" | "table"> {
6
- data: JsonData;
7
- }
8
- export declare class JsonDataSource extends EventEmitter<DataSourceEvents> implements DataSourceBase {
9
- #private;
10
- columnDescriptors: ColumnDescriptor[];
11
- private clientCallback;
12
- private expandedRows;
13
- private visibleRows;
14
- rowCount: number | undefined;
15
- viewport: string;
16
- private keys;
17
- constructor({ aggregations, data, filterSpec, groupBy, sort, title, viewport, }: JsonDataSourceConstructorProps);
18
- subscribe({ viewport, columns, aggregations, range, sort, groupBy, filterSpec, }: DataSourceSubscribeProps, callback: DataSourceSubscribeCallback): Promise<void>;
19
- unsubscribe(): void;
20
- suspend(): this;
21
- resume(): this;
22
- disable(): this;
23
- enable(): this;
24
- set data(data: JsonData);
25
- select(selectRequest: Omit<SelectRequest, "vpId">): void;
26
- private getRowKey;
27
- openTreeNode(keyOrIndex: string | number): void;
28
- closeTreeNode(keyOrIndex: string | number, cascade?: boolean): void;
29
- get status(): DataSourceStatus;
30
- get config(): WithFullConfig;
31
- applyConfig(): import("@vuu-ui/vuu-utils").MaybeDataSourceConfigChanges;
32
- get selectedRowsCount(): number;
33
- get size(): number;
34
- get range(): Range;
35
- set range(range: Range);
36
- private sendRowsToClient;
37
- get columns(): string[];
38
- set columns(columns: string[]);
39
- get aggregations(): VuuAggregation[];
40
- set aggregations(aggregations: VuuAggregation[]);
41
- get sort(): VuuSort;
42
- set sort(sort: VuuSort);
43
- get filter(): DataSourceFilter;
44
- set filter(filter: DataSourceFilter);
45
- get groupBy(): VuuGroupBy;
46
- set groupBy(groupBy: VuuGroupBy);
47
- get title(): string;
48
- set title(title: string);
49
- createLink({ parentVpId, link: { fromColumn, toColumn }, }: LinkDescriptorWithLabel): void;
50
- removeLink(): void;
51
- remoteProcedureCall<T extends VuuRpcResponse = VuuRpcResponse>(): Promise<T>;
52
- menuRpcCall(rpcRequest: Omit<VuuRpcRequest, "vpId">): Promise<MenuRpcResponse | undefined>;
53
- getChildRows(rowKey: string): DataSourceRow[];
54
- getRowsAtDepth(depth: number, visibleOnly?: boolean): DataSourceRow[];
55
- }
@@ -1,6 +0,0 @@
1
- import { DataRow } from "@vuu-ui/vuu-table-types";
2
- export declare class IconProvider {
3
- #private;
4
- getIcon: (dataRow: DataRow) => string;
5
- setIcon(key: string, icon: string): void;
6
- }
@@ -1,51 +0,0 @@
1
- import type { ColumnDescriptor } from "@vuu-ui/vuu-table-types";
2
- import type { LinkDescriptorWithLabel, VuuRange, VuuRpcResponse, VuuRpcRequest, SelectRequest } from "@vuu-ui/vuu-protocol-types";
3
- import type { DataSourceRow, DataSourceConstructorProps, DataSourceStatus, DataSourceSubscribeCallback, DataSourceSubscribeProps, MenuRpcResponse, DataSourceFilter, DataSourceBase } from "@vuu-ui/vuu-data-types";
4
- import { BaseDataSource, TreeSourceNode } from "@vuu-ui/vuu-utils";
5
- export interface TreeDataSourceConstructorProps extends Omit<DataSourceConstructorProps, "bufferSize" | "table"> {
6
- data: TreeSourceNode[];
7
- }
8
- export declare class TreeDataSource extends BaseDataSource implements DataSourceBase {
9
- #private;
10
- columnDescriptors: ColumnDescriptor[];
11
- private clientCallback;
12
- private expandedRows;
13
- private visibleRows;
14
- private visibleRowIndex;
15
- rowCount: number | undefined;
16
- private keys;
17
- constructor({ data, ...props }: TreeDataSourceConstructorProps);
18
- subscribe({ aggregations, columns, range, revealSelected, selectedKeyValues, viewport, }: DataSourceSubscribeProps, callback: DataSourceSubscribeCallback): Promise<void>;
19
- unsubscribe(): void;
20
- suspend(): this;
21
- resume(): this;
22
- disable(): this;
23
- enable(): this;
24
- set data(data: TreeSourceNode[]);
25
- get filter(): DataSourceFilter;
26
- set filter(filter: DataSourceFilter);
27
- private applyFilter;
28
- /**
29
- * used to apply an initial selection. These may not necessarily be
30
- * visible. If revealOnSelect is in force, expand nodes as necessary
31
- * to ensure selected nodes are visible
32
- */
33
- private applySelectedKeyValues;
34
- private indexOfRowWithKey;
35
- select(selectRequest: Omit<SelectRequest, "vpId">): void;
36
- private getRowKey;
37
- openTreeNode(keyOrIndex: string | number): void;
38
- closeTreeNode(keyOrIndex: string | number, cascade?: boolean): void;
39
- get status(): DataSourceStatus;
40
- get selectedRowsCount(): number;
41
- get size(): number;
42
- rangeRequest(range: VuuRange): void;
43
- private sendRowsToClient;
44
- createLink({ parentVpId, link: { fromColumn, toColumn }, }: LinkDescriptorWithLabel): void;
45
- removeLink(): void;
46
- remoteProcedureCall<T extends VuuRpcResponse = VuuRpcResponse>(): Promise<T>;
47
- menuRpcCall(rpcRequest: Omit<VuuRpcRequest, "vpId">): Promise<MenuRpcResponse | undefined>;
48
- getChildRows(rowKey: string): DataSourceRow[];
49
- getRowsAtDepth(depth: number, visibleOnly?: boolean): DataSourceRow[];
50
- getRowAtIndex(rowIdx: number): DataSourceRow;
51
- }