@rokkit/data 1.0.1 → 1.0.3

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Jerry Thomas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Generate sales rows: { region, product, year, revenue, units, status }
3
+ */
4
+ export function generateSalesData(n: any): {
5
+ region: string;
6
+ product: string;
7
+ year: number;
8
+ revenue: number;
9
+ units: number;
10
+ status: string;
11
+ }[];
12
+ /**
13
+ * Generate orders/customers pair for join benchmarks.
14
+ */
15
+ export function generateJoinData(n: any): {
16
+ customers: {
17
+ id: number;
18
+ name: string;
19
+ tier: string;
20
+ }[];
21
+ orders: {
22
+ orderId: number;
23
+ customerId: number;
24
+ amount: number;
25
+ year: number;
26
+ }[];
27
+ };
28
+ export function generateAlignData(n: any): {
29
+ revenue: number;
30
+ region: string;
31
+ product: string;
32
+ year: number;
33
+ }[];
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env bun
2
+ export {};
@@ -0,0 +1,10 @@
1
+ export function runBenchmarks(phase?: string): {
2
+ phase: string;
3
+ timestamp: string;
4
+ environment: {
5
+ runtime: string;
6
+ platform: NodeJS.Platform;
7
+ arch: NodeJS.Architecture;
8
+ };
9
+ results: never[];
10
+ };
@@ -0,0 +1,2 @@
1
+ export function counter(values: any[]): number;
2
+ export function violin(values: number[]): Object;
@@ -0,0 +1,45 @@
1
+ export function pickAllowedConfig(obj: any): {};
2
+ /** @type {import('./types').DataFrameConfig */
3
+ export const defaultConfig: import("./types").DataFrameConfig;
4
+ export namespace defaultPathOptions {
5
+ let path: null;
6
+ let separator: string;
7
+ let currencySuffix: string;
8
+ }
9
+ export namespace defaultViewOptions {
10
+ let expanded: boolean;
11
+ let actions: never[];
12
+ let language: string;
13
+ let scanMode: string;
14
+ }
15
+ export namespace defaultActionOrder {
16
+ export let select: number;
17
+ export let edit: number;
18
+ let _delete: number;
19
+ export { _delete as delete };
20
+ }
21
+ /**
22
+ * Returns the default properties for a column
23
+ * @param {string} key - the key to use for the column
24
+ * @returns {Object} the default properties for a column
25
+ */
26
+ export const filterOperations: {
27
+ '=': (value: any, pattern: any) => boolean;
28
+ '<': (value: any, pattern: any) => boolean;
29
+ '>': (value: any, pattern: any) => boolean;
30
+ '<=': (value: any, pattern: any) => boolean;
31
+ '>=': (value: any, pattern: any) => boolean;
32
+ '~*': (value: any, pattern: any) => any;
33
+ '~': (value: any, pattern: any) => any;
34
+ '!=': (value: any, pattern: any) => boolean;
35
+ '!~*': (value: any, pattern: any) => boolean;
36
+ '!~': (value: any, pattern: any) => boolean;
37
+ };
38
+ export namespace typeConverters {
39
+ function string(value: any): string;
40
+ function number(value: any): number;
41
+ function boolean(value: any): boolean;
42
+ function date(value: any): Date;
43
+ function mixed(x: any): any;
44
+ }
45
+ export function includeAll(): boolean;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Converts an array of objects into a columnar structure, returning an object with two attributes:
3
+ *
4
+ * - columns, which contains an array of column names
5
+ * - data, which is an object with column names as keys and arrays as values.
6
+ *
7
+ * @param {Array<Object>} input
8
+ * @returns {import('./types').Dataframe}
9
+ */
10
+ export function fromArray(input: Array<Object>): import("./types").Dataframe;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Returns the default aggregator which rolls up non-group_by columns into a children array.
3
+ */
4
+ export function defaultAggregator(config: any): {
5
+ mapper: (row: any) => {};
6
+ reducers: {
7
+ field: any;
8
+ formula: (x: any) => any;
9
+ }[];
10
+ };
11
+ export function dataset(data: any, options?: {}): DataSet;
12
+ export class DataSet {
13
+ constructor(data: any);
14
+ set data(values: any[]);
15
+ get data(): any[];
16
+ set config(props: any);
17
+ override(props: any): this;
18
+ where(condition: any): this;
19
+ apply(callback: any): this;
20
+ sortBy(...fields: any[]): this;
21
+ rename(how: any): this;
22
+ drop(...fields: any[]): DataSet;
23
+ fillNA(value: any): this;
24
+ remove(): this;
25
+ update(value: any): this;
26
+ groupBy(...fields: any[]): this;
27
+ alignBy(...fields: any[]): this;
28
+ usingTemplate(template: any): this;
29
+ summarize(from: any, fields: any): this;
30
+ rollup(): DataSet;
31
+ select(...cols: any[]): any;
32
+ /**
33
+ * Derive column definitions from the current data.
34
+ *
35
+ * Returns `{ name, type, scale, sortable, filterable, fields, formatter }` for each
36
+ * column, plus any user-supplied properties from `options.enhancements`.
37
+ *
38
+ * @param {Object} [options]
39
+ * @param {Array<Object>} [options.enhancements=[]] - Per-column overrides keyed by name.
40
+ * @param {string} [options.language='en-US'] - Locale for formatters.
41
+ * @param {string} [options.scanMode='fast'] - 'fast' or 'deep'.
42
+ * @returns {Array<Object>}
43
+ */
44
+ columnDefs(options?: {
45
+ enhancements?: Object[] | undefined;
46
+ language?: string | undefined;
47
+ scanMode?: string | undefined;
48
+ }): Array<Object>;
49
+ union(other: any): DataSet;
50
+ minus(other: any): DataSet;
51
+ intersect(other: any): DataSet;
52
+ innerJoin(other: any, condition: any): DataSet;
53
+ leftJoin(other: any, condition: any): DataSet;
54
+ rightJoin(other: any, condition: any): DataSet;
55
+ fullJoin(other: any, condition: any): DataSet;
56
+ crossJoin(other: any): DataSet;
57
+ semiJoin(other: any, condition: any): DataSet;
58
+ antiJoin(other: any, condition: any): DataSet;
59
+ nestedJoin(other: any, condition: any): DataSet;
60
+ #private;
61
+ }
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Factory function for `ReactiveDataSet`.
3
+ *
4
+ * @param {any[]} [data=[]] - Initial source rows.
5
+ * @returns {ReactiveDataSet}
6
+ */
7
+ export function reactiveDataset(data?: any[]): ReactiveDataSet;
8
+ export class ReactiveDataSet {
9
+ /**
10
+ * @param {any[]} data - Initial source rows.
11
+ */
12
+ constructor(data?: any[]);
13
+ /**
14
+ * Reactive computed result of filter + transforms + sort.
15
+ * Bind to this in templates instead of calling `.select()`.
16
+ */
17
+ get rows(): any;
18
+ /**
19
+ * Reactive derived column definitions: name, type, scale (discrete|continuous),
20
+ * sortable, filterable, fields, formatter — merged with any `withColumns` overrides.
21
+ *
22
+ * Re-computes when source data or column enhancements change.
23
+ * Bind to this in templates for Table / TreeTable column specs.
24
+ */
25
+ get columns(): Object[];
26
+ /**
27
+ * Set the filter predicate. Replaces any previous filter.
28
+ * @param {Function|null} fn
29
+ */
30
+ where(fn: Function | null): this;
31
+ /**
32
+ * Append a row transform. Each call to `apply` adds a new stage.
33
+ * @param {Function} fn
34
+ */
35
+ apply(fn: Function): this;
36
+ /**
37
+ * Set sort fields. Replaces any previous sort.
38
+ * @param {...string} fields
39
+ */
40
+ sortBy(...fields: string[]): this;
41
+ /**
42
+ * Set per-column enhancements / overrides for the reactive `columns` property.
43
+ *
44
+ * Each entry is matched by `name` and merged into the auto-derived column def.
45
+ * Unknown names are appended as synthetic columns (useful for action columns).
46
+ *
47
+ * @param {Array<Object>} enhancements - e.g. [{ name: 'revenue', label: 'Revenue ($)', scale: 'continuous' }]
48
+ * @param {Object} [options] - Options forwarded to deriveColumnDefs (language, scanMode).
49
+ */
50
+ withColumns(enhancements: Array<Object>, options?: Object): this;
51
+ /** Clear the current filter. */
52
+ clearFilter(): this;
53
+ /** Clear all transforms. */
54
+ clearTransforms(): this;
55
+ /**
56
+ * Replace the entire source dataset.
57
+ * @param {any[]} rows
58
+ */
59
+ setData(rows: any[]): this;
60
+ /**
61
+ * Append a single row to the source.
62
+ * @param {any} row
63
+ */
64
+ push(row: any): this;
65
+ /**
66
+ * Remove rows matching the predicate from the source.
67
+ * @param {Function} predicate
68
+ */
69
+ remove(predicate: Function): this;
70
+ /**
71
+ * Update rows matching the predicate with patch (object or function).
72
+ * @param {Function} predicate
73
+ * @param {Object|Function} patch
74
+ */
75
+ update(predicate: Function, patch: Object | Function): this;
76
+ /** Return a plain snapshot of the current reactive result (non-reactive copy). */
77
+ snapshot(): any[];
78
+ #private;
79
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Filters an array of objects based on a specified condition defined in the options.
3
+ * If a column is provided, it filters based on the value of that column. Otherwise, it filters
4
+ * based on a value present in any of the object's properties.
5
+ *
6
+ * @param {Object[]} data - The array of objects to filter.
7
+ * @param {Object} options - The filtering options that define the condition.
8
+ * @param {string} [options.column] - The property name in the objects to filter by. If omitted, all properties are considered.
9
+ * @param {string|number} [options.value] - The value to compare against when filtering.
10
+ * @param {string} [options.operator] - The operator to use for comparison, should match a key in the filterOperations object.
11
+ * @returns {Object[]} - The filtered array of objects.
12
+ */
13
+ export function filterObjectArray(data: Object[], options: {
14
+ column?: string | undefined;
15
+ value?: string | number | undefined;
16
+ operator?: string | undefined;
17
+ }): Object[];
18
+ /**
19
+ * Applies multiple filtering conditions to an array of objects. This function iterates through each filter option,
20
+ * successively narrowing down the data.
21
+ *
22
+ * @param {Object[]} data - The array of objects to filter.
23
+ * @param {Object[]} filters - An array of filtering options to apply to the data.
24
+ * @returns {Object[]} - The filtered array of objects that meet all conditions specified by the filters.
25
+ */
26
+ export function filterData(data: Object[], filters: Object[]): Object[];
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Creates a formatter function that formats a value according to the specified type and optional locale settings.
3
+ * Supported types include 'default' (no formatting), 'integer', 'number', 'date', 'time',, 'object', 'array', 'currency' & 'ellipsis''
4
+ *
5
+ * @param {string} type - The type of the formatter to use (e.g., 'integer', 'number', 'date', 'time', 'currency').
6
+ * @param {string} [language='en-US'] - Optional IETF language tag used for locale-specific formatting.
7
+ * @param {number} [decimalPlaces=2] - Optional number of decimal places to show with number and currency formatting.
8
+ * @returns {*} - A format function that takes a value and returns a formatted string.
9
+ */
10
+ export function createFormatter(type: string, language?: string, decimalPlaces?: number): any;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Removes objects from an array where the parent attribute is not null.
3
+ * @param {Array<Object>} arr - The array of objects.
4
+ */
5
+ export function removeChildren(arr: Array<Object>): void;
6
+ /**
7
+ * Flatten nested children arrays within an array of objects.
8
+ * @param {Array<Object>} arr - The array of objects.
9
+ */
10
+ export function flattenNestedChildren(arr: Array<Object>): void;
11
+ /**
12
+ * Applies a hierarchical filter to an array of objects.
13
+ * @param {Array<Object>} arr - The array of objects.
14
+ * @param {Function} filterFn - The filter function to apply on each object.
15
+ */
16
+ export function hierarchicalFilter(arr: Array<Object>, filterFn: Function): void;
17
+ /**
18
+ * Derives the hierarchy from the data.
19
+ *
20
+ * @param {Array} data - The data to derive the hierarchy from.
21
+ * @param {string} path - The column name to be used as hierarchical path.
22
+ * @param {string} separator - The separator to be used in the path.
23
+ * @returns {Array<import('./types').Hierarchy>} - The derived hierarchy.
24
+ */
25
+ export function deriveHierarchy(data: any[], options: any): Array<import("./types").Hierarchy>;
26
+ /**
27
+ * Toggles the expansion state of a node and updates the visibility of its children accordingly.
28
+ * If the node is a parent (has child nodes), it will invert its 'isExpanded' property and call
29
+ * 'changeVisibilityForChildren' to reflect changes to its child nodes.
30
+ *
31
+ * @param {Object} node - The node to toggle expansion for. The node is expected to have an
32
+ * 'isParent' property indicating if the node has children, an
33
+ * 'isExpanded' property indicating if the node is expanded, and an array
34
+ * of child nodes under the 'children' property if it is a parent.
35
+ */
36
+ export function toggleExpansion(node: Object): void;
@@ -0,0 +1,10 @@
1
+ export * from "./types";
2
+ export { typeOf } from "./utils";
3
+ export { renamer } from "./renamer";
4
+ export { model } from "./model";
5
+ export { dataset } from "./dataset";
6
+ export { dataview } from "./view";
7
+ export { parseFilters } from "./parser";
8
+ export { innerJoin, leftJoin, rightJoin, fullJoin, crossJoin, antiJoin, semiJoin } from "./join";
9
+ export { deriveColumns, deriveMetadata, deriveSortableColumn, inferScale, addScales, deriveColumnDefs, mergeColumnEnhancements } from "./infer";
10
+ export { filterData, filterObjectArray } from "./filter";
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Derives the sorting information for a column based on the type of the input value.
3
+ *
4
+ * @param {import('./types').SortableColumn} value - The value that determines the sorting behavior of the column.
5
+ * @returns {import('./types').ColumnSorter} An object containing the 'name' of the column and a 'sorter' function.
6
+ * @throws {Error} Throws an error if the value type is not supported or the value format is invalid.
7
+ */
8
+ export function deriveSortableColumn(value: import("./types").SortableColumn): import("./types").ColumnSorter;
9
+ /**
10
+ * Creates a deep scan sample object that contains a union of all keys from all
11
+ * objects in the array, pulling the values from the last item that contains the key.
12
+ *
13
+ * @param {Array<Object>} data - An array of objects to deep scan and collect sample values.
14
+ * @returns {Object} A sample object consolidating all unique keys with their latest non-null values.
15
+ */
16
+ export function getSample(data: Array<Object>, deepScan?: boolean): Object;
17
+ /**
18
+ * Derives a unique list of column names from an array of data objects.
19
+ * Each data object represents a row and this function compiles a list of all unique property keys
20
+ * present across these objects.
21
+ *
22
+ * @param {Object[]} data - The array of data objects to analyze for column names.
23
+ * @returns {string[]} - An array of strings representing the unique column names found across all data objects.
24
+ */
25
+ export function deriveColumns(data: Object[], options: any): string[];
26
+ /**
27
+ * Derives the data types of columns based on the data provided in an array of objects.
28
+ * The function assumes that all values of a single field (column) are of the same type. It uses
29
+ * the first object in the data array as a reference for the field names. Each field is categorized
30
+ * as either 'string' or 'number' based on whether any of the field values in the data set are non-numeric.
31
+ *
32
+ * @param {Object[]} data - The array of data objects to assess for column data types.
33
+ * @returns {Object} - An object with keys being the data types ('string' & 'number') and values
34
+ * being arrays of field names that correspond to that data type.
35
+ */
36
+ export function deriveDataTypes(data: Object[]): Object;
37
+ /**
38
+ * Infers the data type of a set of values by examining the values in the array.
39
+ * Assumes all values in the array should have the same type, unless they are 'null'.
40
+ * If multiple types are detected (excluding 'null'), the function will return 'mixed'.
41
+ * If all values are 'null', it returns 'null', and it returns 'undefined' for an empty array.
42
+ *
43
+ * @param {Array} values - An array of values for which the data type is to be inferred.
44
+ * @returns {string} - A string representing the inferred data type. Possible values are
45
+ * 'undefined', 'null', 'mixed', or any data type returned by the getType function.
46
+ */
47
+ export function inferDataType(values: any[]): string;
48
+ /**
49
+ * Adds a formatter function to each column in the array based on the column type. If a formatter
50
+ * function is already present, it will not be overwritten. The formatter is created based on the
51
+ * override formatter if present, or the column type and language.
52
+ *
53
+ * @param {Array<import('./types').ColumnMetadata>} columns - The array of column metadata to add formatters to.
54
+ * @param {string} language - The language to use for formatting.
55
+ * @returns {Array<import('./types').ColumnMetadata>} - The array of column metadata with formatters added.
56
+ */
57
+ export function addFormatters(columns: Array<import("./types").ColumnMetadata>, language: string): Array<import("./types").ColumnMetadata>;
58
+ /**
59
+ * Converts an array of action names to an array of action objects.
60
+ *
61
+ * @param {Array<string|import('./types').Action>} input - The input to convert to actions.
62
+ * @returns {Array<import('./types').Action>} - The converted actions.
63
+ */
64
+ export function convertToActions(input: Array<string | import("./types").Action>): Array<import("./types").Action>;
65
+ /**
66
+ * Adds actions to the column metadata. This function updates the columns array in place.
67
+ *
68
+ * @param {Array<import('./types').ColumnMetadata>} columns - The column metadata to update.
69
+ * @param {Array<string|import('./types').Action>} input - The actions to add to the column metadata.
70
+ * @returns {Array<import('./types').ColumnMetadata>} - The updated column metadata.
71
+ */
72
+ export function deriveActions(columns: Array<import("./types").ColumnMetadata>, input: Array<string | import("./types").Action>): Array<import("./types").ColumnMetadata>;
73
+ /**
74
+ * Derives column metadata from the data to be used in a tabular component.
75
+ *
76
+ * @param {Array} data - The data to derive column metadata from.
77
+ * @param {Object} [options] - The options to use when deriving column metadata.
78
+ * @returns {Array<import('./types').ColumnMetadata>} - The derived column metadata.
79
+ */
80
+ export function deriveMetadata(dataArray: any, options?: Object): Array<import("./types").ColumnMetadata>;
81
+ export function inferScale(values: any): any;
82
+ /**
83
+ * Adds a `scale` property to each column definition.
84
+ *
85
+ * @param {Array<Object>} columns - Column definitions (from deriveColumns / deriveMetadata).
86
+ * @param {any[]} data - Source rows.
87
+ * @returns {Array<Object>} Column definitions with `scale` added.
88
+ */
89
+ export function addScales(columns: Array<Object>, data: any[]): Array<Object>;
90
+ /**
91
+ * Merges user-provided enhancements into auto-derived column definitions.
92
+ * Enhancements are matched by `name` and merged (user values win).
93
+ * Enhancements for unknown column names are appended as synthetic columns.
94
+ *
95
+ * @param {Array<Object>} derived - Auto-derived column definitions.
96
+ * @param {Array<Object>} enhancements - User-provided overrides/additions.
97
+ * @returns {Array<Object>} Merged column definitions.
98
+ */
99
+ export function mergeColumnEnhancements(derived: Array<Object>, enhancements: Array<Object>): Array<Object>;
100
+ /**
101
+ * Full column definition pipeline: derive → format → scale → merge enhancements.
102
+ *
103
+ * Produces column descriptors suitable for use in Table, TreeTable, and chart
104
+ * components. Each column gets: name, type, scale, sortable, filterable, fields,
105
+ * formatter — plus any user-supplied properties from `enhancements`.
106
+ *
107
+ * @param {any[]} data - Source rows.
108
+ * @param {Object} [options] - Options forwarded to deriveColumns / addFormatters.
109
+ * @param {Array<Object>} [options.enhancements=[]] - Per-column overrides keyed by name.
110
+ * Use to override scale, add a label, attach a custom formatter, etc.
111
+ * @param {string} [options.language='en-US'] - Locale for formatters.
112
+ * @param {string} [options.scanMode='fast'] - 'fast' (first row) or 'deep' (all rows).
113
+ * @returns {Array<Object>} Column definitions with scale and formatters.
114
+ */
115
+ export function deriveColumnDefs(data: any[], options?: {
116
+ enhancements?: Object[] | undefined;
117
+ language?: string | undefined;
118
+ scanMode?: string | undefined;
119
+ }): Array<Object>;
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Filters the results of the first dataset based on the condition using the second dataset.
3
+ *
4
+ * @param {Array<Object>} first - The first dataset to filter.
5
+ * @param {Array<Object>} second - The second dataset to filter by.
6
+ * @param {Function} condition - The condition to filter the first dataset by.
7
+ * @returns {Array<Object>} - The filtered dataset.
8
+ */
9
+ export function antiJoin(first: Array<Object>, second: Array<Object>, condition: Function): Array<Object>;
10
+ /**
11
+ * Joins two datasets together based on a condition. Result includes all rows from the first
12
+ * dataset and matching rows from the second dataset. In case of multiple matches, all
13
+ * combinations are returned. When combining the rows, the columns from the first dataset take
14
+ * precedence.
15
+ *
16
+ * @param {Array<Object>} first - The first dataset to join.
17
+ * @param {Array<Object>} second - The second dataset to join.
18
+ * @param {Function} condition - The condition to join the datasets on.
19
+ * @returns {Array<Object>} - The joined dataset.
20
+ */
21
+ export function innerJoin(first: Array<Object>, second: Array<Object>, condition: Function): Array<Object>;
22
+ /**
23
+ * Performs a left join on two datasets based on a condition.
24
+ *
25
+ * - Result includes all rows from the first dataset and matching rows from the second dataset.
26
+ * - In case of multiple matches, all combinations are returned.
27
+ * - When combining the rows, the columns from the first dataset take precedence.
28
+ * - If there is no match in the second dataset, only the row from the first dataset is returned.
29
+ *
30
+ * This can be used to perform a right join by swapping the datasets.
31
+ *
32
+ * @param {Array<Object>} first - The first dataset to join.
33
+ * @param {Array<Object>} second - The second dataset to join.
34
+ * @param {Function} condition - The condition to join the datasets on.
35
+ * @returns {Array<Object>} - The joined dataset.
36
+ */
37
+ export function leftJoin(first: Array<Object>, second: Array<Object>, condition: Function): Array<Object>;
38
+ /**
39
+ * Performs a right join on two datasets based on a condition.
40
+ *
41
+ * - Result includes all rows from both datasets.
42
+ * - In case of multiple matches, all combinations are returned.
43
+ * - When combining the rows, the columns from the second dataset take precedence.
44
+ * - If there is no match in the first dataset, only the row from the second dataset is returned.
45
+ *
46
+ * @param {Array<Object>} first - The first dataset to join.
47
+ * @param {Array<Object>} second - The second dataset to join.
48
+ * @param {Function} condition - The condition to join the datasets on.
49
+ * @returns {Array<Object>} - The joined dataset.
50
+ */
51
+ export function rightJoin(first: Array<Object>, second: Array<Object>, condition: Function): Array<Object>;
52
+ /**
53
+ * Performs a full join on two datasets based on a condition.
54
+ *
55
+ * - Result includes all rows from both datasets.
56
+ * - In case of multiple matches, all combinations are returned.
57
+ * - When combining the rows, the columns from the second dataset take precedence.
58
+ * - If there is no match in the first dataset, only the row from the second dataset is returned.
59
+ *
60
+ * @param {Array<Object>} first - The first dataset to join.
61
+ * @param {Array<Object>} second - The second dataset to join.
62
+ * @param {Function} condition - The condition to join the datasets on.
63
+ * @returns {Array<Object>} - The joined dataset.
64
+ */
65
+ export function fullJoin(first: Array<Object>, second: Array<Object>, condition: Function): Array<Object>;
66
+ /**
67
+ * Performs a cross join on two datasets. Result includes all combinations of rows from both datasets.
68
+ *
69
+ * @param {Array<Object>} first - The first dataset to join.
70
+ * @param {Array<Object>} second - The second dataset to join.
71
+ * @returns {Array<Object>} - The joined dataset.
72
+ */
73
+ export function crossJoin(first: Array<Object>, second: Array<Object>): Array<Object>;
74
+ /**
75
+ * Performs a semi join on two datasets based on a condition. Result includes all rows from the first
76
+ * dataset that have a match in the second dataset.
77
+ *
78
+ * @param {Array<Object>} first - The first dataset to join.
79
+ * @param {Array<Object>} second - The second dataset to join.
80
+ * @param {Function} condition - The condition to join the datasets on.
81
+ * @returns {Array<Object>} - The joined dataset.
82
+ */
83
+ export function semiJoin(first: Array<Object>, second: Array<Object>, condition: Function): Array<Object>;
84
+ /**
85
+ * Performs a nested join on two datasets based on a condition. Result includes all rows from the first
86
+ * dataset that have a match in the second dataset. The result is nested with the matching rows from the
87
+ * second dataset.
88
+ *
89
+ * @param {Array<Object>} first - The first dataset to join.
90
+ * @param {Array<Object>} second - The second dataset to join.
91
+ * @param {Function} condition - The condition to join the datasets on.
92
+ * @param {String} [key='children'] - The key to nest the matching rows under.
93
+ * @returns {Array<Object>} - The joined dataset.
94
+ */
95
+ export function nestedJoin(first: Array<Object>, second: Array<Object>, condition: Function, key?: string): Array<Object>;
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Compares two items for sorting. When grouped, uses group comparison before item comparison
3
+ *
4
+ * @param {*} a first item
5
+ * @param {*} b second item
6
+ * @param {*} data
7
+ * @returns
8
+ */
9
+ export function compare(a: any, b: any, data: any): number;
10
+ /**
11
+ * Search the data for existence of string in the data
12
+ *
13
+ * @param {List} data
14
+ * @param {string} value
15
+ * @returns
16
+ */
17
+ export function quickSearch(data: List, value: string): object[];
18
+ /**
19
+ * Create a new list
20
+ *
21
+ * @param {Array<object>} data
22
+ * @returns
23
+ */
24
+ export function list(data: Array<object>): List;
25
+ /**
26
+ * Implements a list containing data and functionality for sorting, filtering, and grouping.
27
+ */
28
+ export class List {
29
+ /**
30
+ * Creates a List instance with initial data and default settings for keys and functions.
31
+ * @param {Array<object>} data - The initial array of objects to populate the list.
32
+ */
33
+ constructor(data: Array<object>);
34
+ data: object[];
35
+ primaryKey: string;
36
+ filterKey: string | undefined;
37
+ sortKey: string | undefined;
38
+ groupKey: string | undefined;
39
+ lookup: {};
40
+ searchText: string;
41
+ filterUsing: Function | undefined;
42
+ sortUsing: Function | undefined;
43
+ filtered: import("svelte/store").Writable<object[]>;
44
+ /**
45
+ * Sets a primary key attribute for list items and assigns a unique identifier if not present.
46
+ *
47
+ * @param {string} value - The property name to be set as the primary key.
48
+ * @returns {List} This list instance for method chaining.
49
+ */
50
+ key(value: string): List;
51
+ /**
52
+ * Configures sorting by a given key and sorting function.
53
+ *
54
+ * @param {string} key - The property name to sort by.
55
+ * @param {Function} [using=compare] - The function used to sort the list items.
56
+ * @returns {List} This list instance for method chaining.
57
+ */
58
+ sortBy(key: string, using?: Function): List;
59
+ /**
60
+ * Groups list items by a given key and maps group keys for display using an optional lookup object.
61
+ *
62
+ * @param {string} key - The property name to group by.
63
+ * @param {object|null} [lookup=null] - An object mapping group keys to display names.
64
+ * @returns {List} This list instance for method chaining.
65
+ */
66
+ groupBy(key: string, lookup?: object | null): List;
67
+ /**
68
+ * Sets the key and function for filtering list items.
69
+ *
70
+ * @param {string} key - The property name to filter by.
71
+ * @param {Function} [using=quickSearch] - The function used to filter the list items.
72
+ * @returns {List} This list instance for method chaining.
73
+ */
74
+ filterBy(key: string, using?: Function): List;
75
+ /**
76
+ * Sorts the list based on the configured sorting function.
77
+ *
78
+ * @returns {List} This list instance for method chaining.
79
+ */
80
+ sort(): List;
81
+ /**
82
+ * Adds a new item to the list, assigning a primary key if necessary, and then sorts and refreshes the list.
83
+ *
84
+ * @param {object} item - The item to add to the list.
85
+ * @returns {List} This list instance for method chaining.
86
+ */
87
+ add(item: object): List;
88
+ /**
89
+ * Removes an item from the list by primary key and refreshes the list.
90
+ *
91
+ * @param {object} item - The item to remove from the list.
92
+ * @returns {List} This list instance for method chaining.
93
+ */
94
+ remove(item: object): List;
95
+ /**
96
+ * Modifies an existing item in the list, identified by primary key, and then sorts and refreshes the list.
97
+ *
98
+ * @param {object} item - The item to modify in the list.
99
+ * @returns {List} This list instance for method chaining.
100
+ */
101
+ modify(item: object): List;
102
+ /**
103
+ * Sets the text to search for in the list's items and then refreshes the list.
104
+ *
105
+ * @param {string} text - The text to search for.
106
+ * @returns {List} This list instance for method chaining.
107
+ */
108
+ search(text: string): List;
109
+ /**
110
+ * Refreshes the list based on current sorting, grouping, and filtering configuration.
111
+ *
112
+ * @returns {List} This list instance for method chaining.
113
+ */
114
+ refresh(): List;
115
+ /**
116
+ * Gets the current state of the filtered list data.
117
+ *
118
+ * @returns {Array<object>} The current filtered data of the list.
119
+ */
120
+ current(): Array<object>;
121
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Adds a path modifier to column definitions that match a specific path.
3
+ *
4
+ * @param {Array<Object>} columns - The original array of column definitions.
5
+ * @param {string|null} path - The path used to identify columns that require path modifiers.
6
+ * @param {string} separator - The separator used in conjunction with the path.
7
+ * @returns {Array<Object>} The array of column definitions with path modifiers added as needed.
8
+ */
9
+ export function addPathModifier(columns: Array<Object>, path: string | null, separator: string): Array<Object>;
10
+ /**
11
+ * Derives column properties for a given sample and options.
12
+ *
13
+ * @param {Object} sample - The sample object used to derive column properties.
14
+ * @param {Object} options - The options used to modify column properties.
15
+ * It can specify path, separator, and currencySuffix for column customization.
16
+ * @returns {Array<Object>} An array of derived column definitions.
17
+ */
18
+ export function deriveColumnProperties(sample: Object, options: Object): Array<Object>;
19
+ /**
20
+ * Derives the column metadata from the provided data and options.
21
+ *
22
+ * @param {Array} data - The data to derive the column metadata from.
23
+ * @param {Object} [options] - Optional parameters to control the metadata derivation.
24
+ * @param {Array} [options.metadata] - The metadata to use instead of deriving it from the data.
25
+ * @param {boolean} [options.deepScan=false] - Determines if the metadata derivation should perform a deep scan of the data.
26
+ *
27
+ * @returns {import('./types').Metadata} The derived column metadata.
28
+ */
29
+ export function deriveColumnMetadata(data: any[], options?: {
30
+ metadata?: any[] | undefined;
31
+ deepScan?: boolean | undefined;
32
+ }): import("./types").Metadata;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * A model is a representation of a dataset
3
+ * @returns an object with methods to manipulate the model
4
+ */
5
+ export function model(): {
6
+ get: () => any[];
7
+ clone: (other: any) => /*elided*/ any;
8
+ /**
9
+ * Renames the reference names using a renamer
10
+ * @param {Function} rename - the renamer function
11
+ */
12
+ renameUsing: (rename: Function) => /*elided*/ any;
13
+ /**
14
+ * Analyzes the input data and derives a model from it
15
+ *
16
+ * @param {Array|Object} value - the data to derive the model from
17
+ * @param {boolean} sparseData - indicates that rows may have missing attributes
18
+ * @returns {Object} this
19
+ */
20
+ from: (value: any[] | Object, sparseData: boolean) => Object;
21
+ /**
22
+ * Merges the model with another model
23
+ *
24
+ * @param {Array} other - the model to merge with
25
+ * @param {Boolean} override - whether to override the type of the first model
26
+ * @returns {Object} this
27
+ */
28
+ merge: (other: any[], override?: boolean) => Object;
29
+ };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Constructs a regular expression pattern for matching search filter strings.
3
+ * The pattern captures "column", "operator", and "value" groups for filter expressions.
4
+ * Supported operators include common comparison and wildcard operators.
5
+ *
6
+ * Examples of valid expressions this regex can match:
7
+ * - "username:john_doe"
8
+ * - "age>30"
9
+ * - "status!=active"
10
+ * - "title~\"Product Manager\""
11
+ * - "completed!~*yes"
12
+ *
13
+ * The "column" group matches one or more word characters.
14
+ * The "operator" group matches one among the specified comparison or wildcard operators:
15
+ * :, >, <, >=, <=, =<, =>, =, !=, ~, ~*, !~, !~*.
16
+ * The "value" group matches either a double-quoted string or a single unquoted word
17
+ * that doesn't include whitespace or any of the operator characters.
18
+ *
19
+ * @returns {RegExp} - The regular expression pattern to identify search filter elements.
20
+ */
21
+ export function getRegex(): RegExp;
22
+ /**
23
+ * Parses a search string and extracts filters based on a predefined regular expression pattern.
24
+ * Each filter captures column, operator, and value components. Any remaining text that
25
+ * does not fit the pattern is considered a general search term.
26
+ *
27
+ * @param {string} string - The search string to parse for filters.
28
+ * @returns {Object[]} - An array of filter objects each containing the column, operator, and value,
29
+ * plus an additional object for general search if there is remaining text.
30
+ */
31
+ export function parseFilters(string: string): Object[];
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Sort an array in-place by one or more field specs.
3
+ * @param {any[]} data - Array to sort (mutated in place).
4
+ * @param {...string|Object|Array} fields - Sort field specs (same as DataSet.sortBy).
5
+ * @returns {any[]}
6
+ */
7
+ export function sortDataByFields(data: any[], ...fields: (string | Object | any[])[]): any[];
8
+ export function executeFused(data: any, ops: any): any;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * A generator function that produces a function to rename keys.
3
+ *
4
+ * @param {OptionsToRenameKeys} options - Options to rename keys
5
+ * @returns {Object} - A renamer object.
6
+ *
7
+ * Example:
8
+ *
9
+ * renamer({ prefix: 'a', keys: ['a', 'b'] }).get()
10
+ * renamer({ prefix: 'a', separator: '-' }).get()
11
+ * renamer().setPrefix('a')
12
+ * .setSeparator('-')
13
+ * .setKeys(['a', 'b'])
14
+ * .get()
15
+ * renamer().setPrefix('a').get()
16
+ * renamer().setSuffix('b').get()
17
+ * renamer().setKeys(['a', 'b']).get()
18
+ */
19
+ export function renamer(options?: OptionsToRenameKeys): Object;
20
+ export type OptionsToRenameKeys = {
21
+ /**
22
+ * - The prefix to add to the key.
23
+ */
24
+ prefix?: string | undefined;
25
+ /**
26
+ * - The suffix to add to the key.
27
+ */
28
+ suffix?: string | undefined;
29
+ /**
30
+ * - The separator to use between the key and the prefix or suffix.
31
+ */
32
+ separator?: string | undefined;
33
+ /**
34
+ * - The keys to rename.
35
+ */
36
+ keys?: any[] | undefined;
37
+ };
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Sets initial values for summaries.
3
+ *
4
+ * @param {Array} summaries - An array of summary objects.
5
+ * @returns {Object} An object with keys for each summary initialized to empty arrays.
6
+ */
7
+ export function initialValues(summaries: any[]): Object;
8
+ /**
9
+ * Adds data to summary aggregation arrays.
10
+ *
11
+ * @param {Object} group - The group object to add data to.
12
+ * @param {Object} row - The data row being processed.
13
+ * @param {Array} summaries - An array of summary objects.
14
+ */
15
+ export function addToSummaries(group: Object, row: Object, summaries: any[]): void;
16
+ /**
17
+ * Groups data by specified keys using a composite string key (Phase 3: replaces JSON.stringify).
18
+ *
19
+ * @param {Array} data - An array of data points.
20
+ * @param {Array} groupByKeys - Keys to group the data by.
21
+ * @param {Array} summaries - An array of summary objects to define aggregation operations.
22
+ * @returns {Object} Grouped data object with aggregation placeholders.
23
+ */
24
+ export function groupDataByKeys(data: any[], groupByKeys: any[], summaries: any[]): Object;
25
+ /**
26
+ * Fills grouped data with aligned data if specified in configuration.
27
+ *
28
+ * @param {Object} groupedData - The grouped data object.
29
+ * @param {Object} config - Configuration object containing alignment settings.
30
+ * @returns {Array} Aligned data array.
31
+ */
32
+ export function fillAlignedData(groupedData: Object, config: Object, fillRowsFunc: any): any[];
33
+ export function getAlignGenerator(data: any, config: any): (children: any) => any[];
34
+ /**
35
+ * Performs aggregation operations on grouped data.
36
+ *
37
+ * @param {Array} dataArray - An array of grouped data with aggregation arrays.
38
+ * @param {Array} summaries - An array of summary objects with reducer functions.
39
+ * @returns {Array} Aggregated data array with computed summary values.
40
+ */
41
+ export function aggregateData(dataArray: any[], summaries: any[]): any[];
@@ -0,0 +1,346 @@
1
+ declare const _default: {};
2
+ export default _default;
3
+ export type FieldMapping = import("@rokkit/core").FieldMapping;
4
+ export type SortOptions = import("@rokkit/core").SortOptions;
5
+ export type HorizontalAlignOptions = import("@rokkit/core").HorizontalAlignOptions;
6
+ export type ActionTypes = import("@rokkit/core").ActionTypes;
7
+ export type SelectionState = import("@rokkit/core").SelectionState;
8
+ export type ColumnSorter = {
9
+ name: string;
10
+ sorter: Function;
11
+ };
12
+ export type SortableColumn = string | [string, boolean] | ColumnSorter;
13
+ export type ColumnAggregator = {
14
+ name: string;
15
+ aggregator: Function;
16
+ suffix: string;
17
+ };
18
+ /**
19
+ * Options for joining two data sets
20
+ */
21
+ export type OptionsToRenameKeys = {
22
+ /**
23
+ * - Prefix to be added to each attribute
24
+ */
25
+ prefix?: string | undefined;
26
+ /**
27
+ * - Suffix to be added to each attribute
28
+ */
29
+ suffix?: string | undefined;
30
+ /**
31
+ * - Separator to be used when adding prefix or suffix. defaults to _
32
+ */
33
+ separator?: string | undefined;
34
+ };
35
+ /**
36
+ * Column metadata for the table.
37
+ */
38
+ export type ColumnMetadata = {
39
+ /**
40
+ * - The name of the column.
41
+ */
42
+ name: string;
43
+ /**
44
+ * - The data type of the column (e.g., "string", "number", "date").
45
+ */
46
+ type: string;
47
+ /**
48
+ * - The field mapping for the column.
49
+ */
50
+ field?: import("@rokkit/core").FieldMapping | undefined;
51
+ /**
52
+ * - The number of digits for numeric values (defaults to 0).
53
+ */
54
+ digits?: number | undefined;
55
+ /**
56
+ * - A function to format the column value.
57
+ */
58
+ formatter: Function;
59
+ /**
60
+ * - Indicates if the column is sortable (true/false).
61
+ */
62
+ sortable?: boolean | undefined;
63
+ /**
64
+ * - The sort order of the column.
65
+ */
66
+ sortOrder?: import("@rokkit/core").SortOptions | undefined;
67
+ /**
68
+ * - The alignment of the column content.
69
+ */
70
+ align?: import("@rokkit/core").HorizontalAlignOptions | undefined;
71
+ /**
72
+ * - Action attribute for action columns.
73
+ */
74
+ action?: import("@rokkit/core").ActionTypes | undefined;
75
+ };
76
+ export type Metadata = Array<ColumnMetadata>;
77
+ export type ColumnIndexMap = {
78
+ [x: string]: number;
79
+ };
80
+ /**
81
+ * Track the state of a row in the table.
82
+ */
83
+ export type TreeTableNode = {
84
+ /**
85
+ * - Reference to actual row in the data.
86
+ */
87
+ row: number;
88
+ /**
89
+ * - The depth of the node in the hierarchy.
90
+ */
91
+ depth: number;
92
+ /**
93
+ * - The value of the hierarchy node.
94
+ */
95
+ value?: string | undefined;
96
+ /**
97
+ * - Indicates whether the node is visible (true/false).
98
+ */
99
+ isHidden?: boolean | undefined;
100
+ /**
101
+ * - Indicates if this node is a parent (true/false).
102
+ */
103
+ isParent?: boolean | undefined;
104
+ /**
105
+ * - Indicates whether the node is expanded (true/false).
106
+ */
107
+ isExpanded?: boolean | undefined;
108
+ /**
109
+ * - Reference to the parent node in the flat list.
110
+ */
111
+ parent?: number | undefined;
112
+ /**
113
+ * - Indicates whether the node is selected (true/false/indeterminate).
114
+ */
115
+ selected?: import("@rokkit/core").SelectionState | undefined;
116
+ /**
117
+ * - Reference to the children nodes in the flat list.
118
+ */
119
+ children: Array<any>;
120
+ };
121
+ /**
122
+ * Track the state of all rows in the table.
123
+ */
124
+ export type TreeTable = {
125
+ /**
126
+ * - Flat list of hierarchy nodes.
127
+ */
128
+ rows: TreeTableNode[];
129
+ };
130
+ export type OverrideConfig = {
131
+ /**
132
+ * - the field used for identifying filler rows in the data
133
+ */
134
+ actual_flag: string;
135
+ /**
136
+ * - the field used for collecting children of a node in rollup
137
+ */
138
+ children: string;
139
+ };
140
+ export type ReducerConfig = {
141
+ /**
142
+ * - The target field to hold the reduced value
143
+ */
144
+ field: string;
145
+ /**
146
+ * - The function to use for reducing the data
147
+ */
148
+ using: Function;
149
+ };
150
+ export type SummaryConfig = {
151
+ /**
152
+ * - A function used to collect the data for the summary
153
+ */
154
+ mapper: Function;
155
+ /**
156
+ * - Array of reducer configurations
157
+ */
158
+ reducers: Array<ReducerConfig>;
159
+ /**
160
+ * - Array of column metadata for the summary
161
+ */
162
+ metadata?: Metadata | undefined;
163
+ };
164
+ export type DataFrameConfig = {
165
+ /**
166
+ * =[] - The columns to group by.
167
+ */
168
+ group_by: Array<string>;
169
+ /**
170
+ * =[] - The columns to be aligned during rollup.
171
+ */
172
+ align_by: Array<string>;
173
+ /**
174
+ * =[] - Array of summary configurations.
175
+ */
176
+ summaries: Array<SummaryConfig>;
177
+ /**
178
+ * ={} - Template row to be used for filling in missing rows.
179
+ */
180
+ template: any;
181
+ };
182
+ export type SortBy = Function;
183
+ /**
184
+ * DataFrame-like object with data manipulation methods.
185
+ */
186
+ export type DataFrame = {
187
+ /**
188
+ * - Array of objects representing the rows of data.
189
+ */
190
+ data: Array<Object>;
191
+ /**
192
+ * - Array of column metadata for the data.
193
+ */
194
+ metadata: Metadata;
195
+ /**
196
+ * - Configuration options for the DataFrame.
197
+ */
198
+ config: DataFrameConfig;
199
+ /**
200
+ * - A map of column names to their index in the metadata.
201
+ */
202
+ columns: ColumnIndexMap;
203
+ /**
204
+ * - Method to override the configuration of the DataFrame.
205
+ */
206
+ override: (arg0: OverrideConfig) => DataFrame;
207
+ /**
208
+ * - Method to group the DataFrame by specified columns.
209
+ */
210
+ groupBy: (...args: string[]) => DataFrame;
211
+ /**
212
+ * - Sets the filter function for the DataFrame
213
+ */
214
+ where: (arg0: (arg0: any) => any) => DataFrame;
215
+ /**
216
+ * - Method to align the DataFrame.
217
+ */
218
+ align: () => DataFrame;
219
+ /**
220
+ * - set the template to be used for filling in missing rows.
221
+ */
222
+ using: () => DataFrame;
223
+ /**
224
+ * - add a summarizer to be used during rollup
225
+ */
226
+ summarize: () => DataFrame;
227
+ /**
228
+ * - Method to sort the DataFrame by specified columns.
229
+ */
230
+ sortBy: (...args: SortableColumn[]) => DataFrame;
231
+ /**
232
+ * - perform join with another DataFrame returning a new DataFrmae. Defaults to innerJoin, other join types can be specified.
233
+ */
234
+ join: () => DataFrame;
235
+ /**
236
+ * - perform an ineer join with another DataFrame and return a new DataFrame.
237
+ */
238
+ innerJoin: () => DataFrame;
239
+ /**
240
+ * - perform a left join with another DataFrame and return a new DataFrame.
241
+ */
242
+ leftJoin: () => DataFrame;
243
+ /**
244
+ * - perform a right join with another DataFrame returning a new DataFrame.
245
+ */
246
+ rightJoin: () => DataFrame;
247
+ /**
248
+ * - perform a full join with another DataFrame returning a new DataFrame.
249
+ */
250
+ fullJoin: () => DataFrame;
251
+ /**
252
+ * - perform a nested join with another DataFrame returning a new DataFrame.
253
+ */
254
+ nestedJoin: () => DataFrame;
255
+ /**
256
+ * - Method to rename the columns of the DataFrame.
257
+ */
258
+ rename: () => DataFrame;
259
+ /**
260
+ * - Method to drop the columns of the DataFrame.
261
+ */
262
+ drop: () => DataFrame;
263
+ /**
264
+ * - Method to delete the rows of the DataFrame.
265
+ */
266
+ delete: () => DataFrame;
267
+ /**
268
+ * - Method to update the rows of the DataFrame.
269
+ */
270
+ update: () => DataFrame;
271
+ /**
272
+ * - Method to combine the rows of the DataFrame with another DataFrame.
273
+ */
274
+ union: () => DataFrame;
275
+ /**
276
+ * - Method to remove the rows of the DataFrame which are present in another DataFrame.
277
+ */
278
+ minus: () => DataFrame;
279
+ /**
280
+ * - Method to keep the rows of the DataFrame which are present in another DataFrame.
281
+ */
282
+ intersect: () => DataFrame;
283
+ /**
284
+ * - Method to rollup the DataFrame.
285
+ */
286
+ rollup: () => DataFrame;
287
+ /**
288
+ * - Method to select the columns of the DataFrame.
289
+ */
290
+ select: () => Arrat<Object>;
291
+ };
292
+ export type JoinType = inner | outer | full | nested;
293
+ /**
294
+ * Options for joining two data sets
295
+ */
296
+ export type JoinOptions = {
297
+ /**
298
+ * - Flag indicating inner join
299
+ */
300
+ inner?: boolean | undefined;
301
+ /**
302
+ * {string} [prefix] - prefix to be used for renaming keys in the second data set.
303
+ */
304
+ type?: JoinType;
305
+ /**
306
+ * - suffix to be used for renaming keys in the second data set.
307
+ */
308
+ suffix?: string | undefined;
309
+ /**
310
+ * - separator to be used for renaming keys in the second data set.
311
+ */
312
+ separator?: string | undefined;
313
+ };
314
+ /**
315
+ * DataView
316
+ */
317
+ export type DataView = {
318
+ /**
319
+ * - The state of the rows in the table.
320
+ */
321
+ hierarchy: TreeTable;
322
+ /**
323
+ * - The metadata for the columns in the table.
324
+ */
325
+ columns: Metadata;
326
+ /**
327
+ * - Sort the DataView by the specified columns.
328
+ */
329
+ sortBy: Function;
330
+ /**
331
+ * - Clear the sorting of the DataView.
332
+ */
333
+ clearSort: Function;
334
+ /**
335
+ * - Filter the DataView by the specified columns.
336
+ */
337
+ filter: Function;
338
+ /**
339
+ * - toggle expand or collapse the DataView by the specified columns.
340
+ */
341
+ toggle: Function;
342
+ /**
343
+ * - select the DataView by the specified columns.
344
+ */
345
+ select: Function;
346
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Derive the type of a value
3
+ * @param {any} value
4
+ * @returns {string}
5
+ */
6
+ export function typeOf(value: any): string;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Sorts a hierarchy based on a group of sorters.
3
+ *
4
+ * @param {Array<Object>} hierarchy - The hierarchy to sort.
5
+ * @param {Array<Array<string, boolean>>} sortGroup - The group of sorters to apply.
6
+ */
7
+ export function groupSort(hierarchy: Array<Object>, sortGroup: Array<Array<string, boolean>>): void;
8
+ /**
9
+ * Determines the selected state of a group of children in the hierarchy.
10
+ * If all children are checked, returns 'checked'.
11
+ * If all children are unchecked, returns 'unchecked'.
12
+ * Otherwise, returns 'indeterminate'.
13
+ *
14
+ * @param {Array<Object>} children - The array of child objects with a 'selected' property.
15
+ * @returns {string} The determined selected state: 'checked', 'unchecked', or 'indeterminate'.
16
+ */
17
+ export function determineSelectedState(children: Array<Object>): string;
18
+ /**
19
+ * Toggles the selection state of a node in the hierarchy.
20
+ * Depending on whether the node to toggle is a parent or child,
21
+ * it will either select or deselect all children, or update the parent's selection state based on its children's states.
22
+ *
23
+ * @param {import('./types').Hierarchy} item - The node to toggle.
24
+ *
25
+ */
26
+ export function toggleSelection(item: import("./types").Hierarchy): void;
27
+ /**
28
+ * Creates a view object for managing data presentation with metadata and hierarchy structures,
29
+ * as well as providing methods for sorting, selection, and toggling of data expansion.
30
+ *
31
+ * @param {Array<Object>} data - The source data array to be presented by the view.
32
+ * @param {Object} options - The configuration options used for deriving metadata and hierarchy from the data.
33
+ * @returns {import('svelte/store').Writable} An object representing the view, providing methods to manipulate and query the presentation state.
34
+ */
35
+ export function dataview(data: Array<Object>, options: Object): import("svelte/store").Writable<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rokkit/data",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Contains generic data manipulation functions that can be used in various components.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@lukeed/uuid": "^2.0.1",
41
- "@rokkit/core": "1.0.1",
41
+ "@rokkit/core": "1.0.3",
42
42
  "d3-array": "^3.2.4",
43
43
  "d3-collection": "^1.0.7",
44
44
  "ramda": "^0.32.0",