@rljson/db 0.0.8 → 0.0.10
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/dist/connector/connector.d.ts +30 -0
- package/dist/controller/base-controller.d.ts +49 -0
- package/dist/controller/cake-controller.d.ts +30 -0
- package/dist/controller/component-controller.d.ts +68 -0
- package/dist/controller/controller.d.ts +48 -0
- package/dist/controller/layer-controller.d.ts +26 -0
- package/dist/controller/slice-id-controller.d.ts +22 -0
- package/dist/db.d.ts +63 -6
- package/dist/db.js +2301 -20
- package/dist/db.js.map +1 -0
- package/dist/edit/edit-action.d.ts +53 -0
- package/dist/edit/edit.d.ts +23 -0
- package/dist/edit/multi-edit-manager.d.ts +30 -0
- package/dist/edit/multi-edit-processor.d.ts +75 -0
- package/dist/example-static/example-static.d.ts +45 -0
- package/dist/index.d.ts +7 -1
- package/dist/join/filter/boolean-filter-processor.d.ts +13 -0
- package/dist/join/filter/boolean-filter.d.ts +15 -0
- package/dist/join/filter/column-filter-processor.d.ts +9 -0
- package/dist/join/filter/column-filter.d.ts +18 -0
- package/dist/join/filter/number-filter-processor.d.ts +16 -0
- package/dist/join/filter/number-filter.d.ts +7 -0
- package/dist/join/filter/row-filter-processor.d.ts +19 -0
- package/dist/join/filter/row-filter.d.ts +19 -0
- package/dist/join/filter/string-filter-processor.d.ts +15 -0
- package/dist/join/filter/string-filter.d.ts +8 -0
- package/dist/join/join.d.ts +141 -0
- package/dist/join/selection/column-selection.d.ts +48 -0
- package/dist/join/set-value/set-value.d.ts +11 -0
- package/dist/join/sort/row-sort.d.ts +18 -0
- package/dist/notify.d.ts +6 -2
- package/dist/tools/inject.d.ts +1 -0
- package/dist/tools/isolate.d.ts +1 -0
- package/dist/tools/make-unique.d.ts +4 -0
- package/dist/tools/merge-trees.d.ts +5 -0
- package/package.json +13 -13
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { EditAction } from '@rljson/rljson';
|
|
2
|
+
import { RowFilter } from '../join/filter/row-filter.ts';
|
|
3
|
+
import { ColumnInfo } from '../join/selection/column-selection.ts';
|
|
4
|
+
import { SetValue } from '../join/set-value/set-value.ts';
|
|
5
|
+
import { RowSortType } from '../join/sort/row-sort.ts';
|
|
6
|
+
export interface EditActionColumnSelection extends EditAction {
|
|
7
|
+
type: 'selection';
|
|
8
|
+
data: {
|
|
9
|
+
columns: ColumnInfo[];
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface EditActionRowFilter extends EditAction {
|
|
13
|
+
type: 'filter';
|
|
14
|
+
data: RowFilter;
|
|
15
|
+
}
|
|
16
|
+
export interface EditActionSetValue extends EditAction {
|
|
17
|
+
type: 'setValue';
|
|
18
|
+
data: SetValue;
|
|
19
|
+
}
|
|
20
|
+
export interface EditActionRowSort extends EditAction {
|
|
21
|
+
type: 'sort';
|
|
22
|
+
data: RowSortType;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Example EditAction of type 'selection'
|
|
26
|
+
* @returns An example EditAction representing a column selection
|
|
27
|
+
*/
|
|
28
|
+
export declare const exampleEditActionColumnSelection: () => EditActionColumnSelection;
|
|
29
|
+
/**
|
|
30
|
+
* Example EditAction of type 'selection' with only some columns
|
|
31
|
+
* @returns An example EditAction representing a column selection with limited columns
|
|
32
|
+
*/
|
|
33
|
+
export declare const exampleEditActionColumnSelectionOnlySomeColumns: () => EditActionColumnSelection;
|
|
34
|
+
/**
|
|
35
|
+
* Example EditAction of type 'filter'
|
|
36
|
+
* @returns An example EditAction representing a row filter
|
|
37
|
+
*/
|
|
38
|
+
export declare const exampleEditActionRowFilter: () => EditActionRowFilter;
|
|
39
|
+
/**
|
|
40
|
+
* Example EditAction of type 'setValue'
|
|
41
|
+
* @returns An example EditAction representing a set value action
|
|
42
|
+
*/
|
|
43
|
+
export declare const exampleEditActionSetValue: () => EditActionSetValue;
|
|
44
|
+
/**
|
|
45
|
+
* Example EditAction of type 'setValue' for a referenced column
|
|
46
|
+
* @returns An example EditAction representing a set value action for a referenced column
|
|
47
|
+
*/
|
|
48
|
+
export declare const exampleEditSetValueReferenced: () => EditActionSetValue;
|
|
49
|
+
/**
|
|
50
|
+
* Example EditAction of type 'sort'
|
|
51
|
+
* @returns An example EditAction representing a row sort action
|
|
52
|
+
*/
|
|
53
|
+
export declare const exampleEditActionRowSort: () => EditActionRowSort;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Edit } from '@rljson/rljson';
|
|
2
|
+
import { EditActionColumnSelection, EditActionRowFilter, EditActionRowSort, EditActionSetValue } from './edit-action.ts';
|
|
3
|
+
export interface EditColumnSelection extends Edit {
|
|
4
|
+
name: string;
|
|
5
|
+
action: EditActionColumnSelection;
|
|
6
|
+
_hash: string;
|
|
7
|
+
}
|
|
8
|
+
export interface EditRowFilter extends Edit {
|
|
9
|
+
name: string;
|
|
10
|
+
action: EditActionRowFilter;
|
|
11
|
+
_hash: string;
|
|
12
|
+
}
|
|
13
|
+
export interface EditSetValue extends Edit {
|
|
14
|
+
name: string;
|
|
15
|
+
action: EditActionSetValue;
|
|
16
|
+
_hash: string;
|
|
17
|
+
}
|
|
18
|
+
export interface EditRowSort extends Edit {
|
|
19
|
+
name: string;
|
|
20
|
+
action: EditActionRowSort;
|
|
21
|
+
_hash: string;
|
|
22
|
+
}
|
|
23
|
+
export declare const exampleEditColumnSelection: () => Edit;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Edit } from '@rljson/rljson';
|
|
2
|
+
import { Db } from '../db.ts';
|
|
3
|
+
import { Join } from '../join/join.ts';
|
|
4
|
+
import { MultiEditProcessor } from './multi-edit-processor.ts';
|
|
5
|
+
export declare class MultiEditManager {
|
|
6
|
+
private readonly _cakeKey;
|
|
7
|
+
private readonly _db;
|
|
8
|
+
private _head;
|
|
9
|
+
private _headListener;
|
|
10
|
+
private _processors;
|
|
11
|
+
private _isListening;
|
|
12
|
+
constructor(_cakeKey: string, _db: Db);
|
|
13
|
+
init(): void;
|
|
14
|
+
tearDown(): void;
|
|
15
|
+
edit(edit: Edit, cakeRef?: string): Promise<void>;
|
|
16
|
+
publish(): Promise<MultiEditProcessor>;
|
|
17
|
+
listenToHeadChanges(callback: (editHistoryRef: string) => Promise<void>): void;
|
|
18
|
+
private _notifyHeadListener;
|
|
19
|
+
editHistoryRef(editHistoryRef: string): Promise<MultiEditProcessor>;
|
|
20
|
+
private _persistEdit;
|
|
21
|
+
private _persistMultiEdit;
|
|
22
|
+
private _persistEditHistory;
|
|
23
|
+
get processors(): Map<string, MultiEditProcessor>;
|
|
24
|
+
get head(): {
|
|
25
|
+
editHistoryRef: string;
|
|
26
|
+
processor: MultiEditProcessor;
|
|
27
|
+
} | null;
|
|
28
|
+
get join(): Join;
|
|
29
|
+
get isListening(): boolean;
|
|
30
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Edit, EditHistory, MultiEdit } from '@rljson/rljson';
|
|
2
|
+
import { Db } from '../db.ts';
|
|
3
|
+
import { Join, JoinRowsHashed } from '../join/join.ts';
|
|
4
|
+
import { ColumnSelection } from '../join/selection/column-selection.ts';
|
|
5
|
+
export type MultiEditColumnSelection = ColumnSelection;
|
|
6
|
+
export type MultiEditRowHashed = JoinRowsHashed;
|
|
7
|
+
export type MultiEditRows = any[][];
|
|
8
|
+
export declare class MultiEditProcessor {
|
|
9
|
+
private readonly _db;
|
|
10
|
+
private readonly _cakeKey;
|
|
11
|
+
private readonly _cakeRef;
|
|
12
|
+
private _multiEdit;
|
|
13
|
+
private _edits;
|
|
14
|
+
private _join;
|
|
15
|
+
constructor(_db: Db, _cakeKey: string, _cakeRef: string);
|
|
16
|
+
/**
|
|
17
|
+
* Create MultiEditProcessor from EditHistory
|
|
18
|
+
* @param db - Db instance
|
|
19
|
+
* @param cakeKey - Cake key
|
|
20
|
+
* @param editHistory - EditHistory
|
|
21
|
+
* @returns MultiEditProcessor
|
|
22
|
+
*/
|
|
23
|
+
static fromEditHistory(db: Db, cakeKey: string, editHistory: EditHistory): Promise<MultiEditProcessor>;
|
|
24
|
+
/**
|
|
25
|
+
* Create MultiEditProcessor from MultiEdit
|
|
26
|
+
* @param db - Db instance
|
|
27
|
+
* @param cakeKey - Cake key
|
|
28
|
+
* @param cakeRef - Cake ref
|
|
29
|
+
* @param multiEdit - MultiEdit
|
|
30
|
+
* @returns MultiEditProcessor
|
|
31
|
+
*/
|
|
32
|
+
static fromMultiEdit(db: Db, cakeKey: string, cakeRef: string, multiEdit: MultiEdit): Promise<MultiEditProcessor>;
|
|
33
|
+
get join(): Join;
|
|
34
|
+
get multiEdit(): MultiEdit;
|
|
35
|
+
get cakeRef(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Apply an Edit to the MultiEditProcessor
|
|
38
|
+
* @param edit - Edit to apply
|
|
39
|
+
* @returns MultiEditProcessor
|
|
40
|
+
*/
|
|
41
|
+
edit(edit: Edit): Promise<MultiEditProcessor>;
|
|
42
|
+
applyEditHistory(editHistory: EditHistory): Promise<MultiEditProcessor>;
|
|
43
|
+
/**
|
|
44
|
+
* Publish the MultiEditProcessor. Inserts the resulting Join as new data,
|
|
45
|
+
* updates the head revision, and saves the resulting MultiEdit.
|
|
46
|
+
* @param options - Publish options
|
|
47
|
+
* @returns MultiEditProcessor
|
|
48
|
+
*/
|
|
49
|
+
publish(options?: {
|
|
50
|
+
skipHeadUpdate?: boolean;
|
|
51
|
+
skipSaveMultiEdit?: boolean;
|
|
52
|
+
}): Promise<MultiEditProcessor>;
|
|
53
|
+
/**
|
|
54
|
+
* Clone the MultiEditProcessor
|
|
55
|
+
* @returns Cloned MultiEditProcessor
|
|
56
|
+
*/
|
|
57
|
+
clone(): MultiEditProcessor;
|
|
58
|
+
/**
|
|
59
|
+
* Resolve MultiEdit chain recursively
|
|
60
|
+
* @param multiEdit - MultiEdit to resolve
|
|
61
|
+
* @returns Promise<void>
|
|
62
|
+
*/
|
|
63
|
+
private _resolve;
|
|
64
|
+
/**
|
|
65
|
+
* Process all Edits in the MultiEditProcessor
|
|
66
|
+
* @returns Resulting Join
|
|
67
|
+
*/
|
|
68
|
+
private _processAll;
|
|
69
|
+
/**
|
|
70
|
+
* Process a single Edit and update the Join
|
|
71
|
+
* @param edit - Edit to process
|
|
72
|
+
* @returns Resulting Join
|
|
73
|
+
*/
|
|
74
|
+
private _process;
|
|
75
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Json, JsonH, JsonValueH } from '@rljson/json';
|
|
2
|
+
import { CakesTable, ComponentsTable, LayersTable, Rljson, SliceIdsTable, TablesCfgTable } from '@rljson/rljson';
|
|
3
|
+
export interface StaticExample extends Rljson {
|
|
4
|
+
carSliceId: SliceIdsTable;
|
|
5
|
+
carGeneral: ComponentsTable<CarGeneral>;
|
|
6
|
+
carTechnical: ComponentsTable<Json>;
|
|
7
|
+
carColor: ComponentsTable<Json>;
|
|
8
|
+
carDimensions: ComponentsTable<CarDimension>;
|
|
9
|
+
carGeneralLayer: LayersTable;
|
|
10
|
+
carTechnicalLayer: LayersTable;
|
|
11
|
+
carColorLayer: LayersTable;
|
|
12
|
+
carCake: CakesTable;
|
|
13
|
+
seriesSliceId: SliceIdsTable;
|
|
14
|
+
seriesGeneral: ComponentsTable<Json>;
|
|
15
|
+
seriesCars: ComponentsTable<Json>;
|
|
16
|
+
seriesGeneralLayer: LayersTable;
|
|
17
|
+
seriesCarsLayer: LayersTable;
|
|
18
|
+
seriesCake: CakesTable;
|
|
19
|
+
catalogSliceId: SliceIdsTable;
|
|
20
|
+
catalogSeries: ComponentsTable<Json>;
|
|
21
|
+
catalogSeriesLayer: LayersTable;
|
|
22
|
+
catalogCake: CakesTable;
|
|
23
|
+
tableCfgs: TablesCfgTable;
|
|
24
|
+
}
|
|
25
|
+
export interface CarGeneral extends JsonH {
|
|
26
|
+
brand: string;
|
|
27
|
+
type: string;
|
|
28
|
+
doors: number;
|
|
29
|
+
energyConsumption: number;
|
|
30
|
+
units: JsonValueH;
|
|
31
|
+
serviceIntervals: number[];
|
|
32
|
+
isElectric: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface CarDimension extends JsonH {
|
|
35
|
+
height: number;
|
|
36
|
+
width: number;
|
|
37
|
+
length: number;
|
|
38
|
+
}
|
|
39
|
+
export interface CarTechnical extends JsonH {
|
|
40
|
+
engine: string;
|
|
41
|
+
transmission: string;
|
|
42
|
+
gears: number;
|
|
43
|
+
carDimensionsRef: string;
|
|
44
|
+
}
|
|
45
|
+
export declare const staticExample: () => StaticExample;
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Connector } from './connector/connector.ts';
|
|
2
|
+
export type { ConnectorCallback, ConnectorPayload, } from './connector/connector.ts';
|
|
3
|
+
export { Db } from './db.ts';
|
|
4
|
+
export { exampleEditActionColumnSelection, exampleEditActionColumnSelectionOnlySomeColumns, exampleEditActionRowFilter, exampleEditActionRowSort, exampleEditActionSetValue, exampleEditSetValueReferenced, } from './edit/edit-action.ts';
|
|
5
|
+
export { MultiEditManager } from './edit/multi-edit-manager.ts';
|
|
6
|
+
export { staticExample } from './example-static/example-static.ts';
|
|
7
|
+
export { Join } from './join/join.ts';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BooleanFilter } from './boolean-filter.ts';
|
|
2
|
+
import { ColumnFilterProcessor } from './column-filter-processor.ts';
|
|
3
|
+
export declare class BooleanFilterProcessor implements ColumnFilterProcessor {
|
|
4
|
+
readonly operator: BoolOperator;
|
|
5
|
+
constructor(operator: BoolOperator, search: boolean | string | number | null);
|
|
6
|
+
search: boolean | null;
|
|
7
|
+
static fromModel(model: BooleanFilter): BooleanFilterProcessor;
|
|
8
|
+
equals(other: ColumnFilterProcessor): boolean;
|
|
9
|
+
static readonly allOperators: BoolOperator[];
|
|
10
|
+
matches(cellValue: any): boolean;
|
|
11
|
+
static get example(): BooleanFilterProcessor;
|
|
12
|
+
}
|
|
13
|
+
export type BoolOperator = 'equals' | 'notEquals';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BoolOperator } from './boolean-filter-processor.ts';
|
|
2
|
+
import { ColumnFilter } from './column-filter.ts';
|
|
3
|
+
export interface BooleanFilter extends ColumnFilter<boolean> {
|
|
4
|
+
type: 'boolean';
|
|
5
|
+
operator: BoolOperator;
|
|
6
|
+
}
|
|
7
|
+
export declare const trueValues: string[];
|
|
8
|
+
export declare const falseValues: string[];
|
|
9
|
+
/**
|
|
10
|
+
* Parses a boolean search
|
|
11
|
+
* @param search The search value to be parsed
|
|
12
|
+
* @returns the parse result
|
|
13
|
+
*/
|
|
14
|
+
export declare const parseBooleanSearch: (search: any) => boolean | null;
|
|
15
|
+
export declare const exampleBooleanFilter: () => BooleanFilter;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ColumnFilter } from './column-filter.ts';
|
|
2
|
+
export declare class ColumnFilterProcessor {
|
|
3
|
+
matches(_cellValue: string): boolean;
|
|
4
|
+
equals(_other: ColumnFilterProcessor): boolean;
|
|
5
|
+
static fromModel(model: ColumnFilter<any>): ColumnFilterProcessor;
|
|
6
|
+
static operatorsForType(type: string): string[];
|
|
7
|
+
static translationsForType(type: string, language: 'de' | 'en'): string[];
|
|
8
|
+
static translateOperator(operator: string, language: 'de' | 'en'): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Json, JsonValue } from '@rljson/json';
|
|
2
|
+
import { BoolOperator } from './boolean-filter-processor.ts';
|
|
3
|
+
import { NumberOperator } from './number-filter-processor.ts';
|
|
4
|
+
import { StringOperator } from './string-filter-processor.ts';
|
|
5
|
+
/** Describes a particularly filter setting */
|
|
6
|
+
export interface ColumnFilter<T extends JsonValue> extends Json {
|
|
7
|
+
/** The data type of the filter value. */
|
|
8
|
+
type: 'number' | 'string' | 'boolean';
|
|
9
|
+
/** The address of the column, the filter is applied to. */
|
|
10
|
+
column: string;
|
|
11
|
+
/** The operator the filter is using. */
|
|
12
|
+
operator: NumberOperator | StringOperator | BoolOperator;
|
|
13
|
+
/** The value the data are filtered / searched for. */
|
|
14
|
+
search: T;
|
|
15
|
+
/** The json hash of the filter */
|
|
16
|
+
_hash: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const exampleColumnFilter: () => ColumnFilter<number>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ColumnFilterProcessor } from './column-filter-processor.ts';
|
|
2
|
+
import { NumberFilter } from './number-filter.ts';
|
|
3
|
+
export declare class NumberFilterProcessor implements ColumnFilterProcessor {
|
|
4
|
+
readonly operator: NumberOperator;
|
|
5
|
+
constructor(operator: NumberOperator, search: number | string);
|
|
6
|
+
static fromModel(model: NumberFilter): NumberFilterProcessor;
|
|
7
|
+
equals(other: ColumnFilterProcessor): boolean;
|
|
8
|
+
static readonly allOperators: NumberOperator[];
|
|
9
|
+
matches(cellValue: any): boolean;
|
|
10
|
+
search: number | string;
|
|
11
|
+
static get example(): NumberFilterProcessor;
|
|
12
|
+
private _expression;
|
|
13
|
+
private _initFiltrex;
|
|
14
|
+
private _evalExpression;
|
|
15
|
+
}
|
|
16
|
+
export type NumberOperator = 'equals' | 'notEquals' | 'greaterThan' | 'greaterThanOrEquals' | 'lessThan' | 'lessThanOrEquals' | 'filtrex';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ColumnFilter } from './column-filter.ts';
|
|
2
|
+
import { NumberOperator } from './number-filter-processor.ts';
|
|
3
|
+
export interface NumberFilter extends ColumnFilter<number> {
|
|
4
|
+
type: 'number';
|
|
5
|
+
operator: NumberOperator;
|
|
6
|
+
}
|
|
7
|
+
export declare const exampleNumberFilter: () => NumberFilter;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Join, JoinRowsHashed } from '../join.ts';
|
|
2
|
+
import { ColumnFilterProcessor } from './column-filter-processor.ts';
|
|
3
|
+
import { RowFilter } from './row-filter.ts';
|
|
4
|
+
export declare class RowFilterProcessor {
|
|
5
|
+
readonly operator: 'and' | 'or';
|
|
6
|
+
constructor(columnFilters: Record<string, ColumnFilterProcessor>, operator?: 'and' | 'or');
|
|
7
|
+
static fromModel(model: RowFilter): RowFilterProcessor;
|
|
8
|
+
get processors(): ColumnFilterProcessor[];
|
|
9
|
+
static get empty(): RowFilterProcessor;
|
|
10
|
+
equals(other: RowFilterProcessor): boolean;
|
|
11
|
+
applyTo(join: Join): JoinRowsHashed;
|
|
12
|
+
private readonly _columnFilters;
|
|
13
|
+
private _initColumnFilters;
|
|
14
|
+
private _filterRowsAnd;
|
|
15
|
+
private _filterColumnAnd;
|
|
16
|
+
private _filterRowsOr;
|
|
17
|
+
private _filterColumnOr;
|
|
18
|
+
private _throwOnWrongRoutes;
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Json } from '@rljson/json';
|
|
2
|
+
import { ColumnFilter } from './column-filter.ts';
|
|
3
|
+
/** Describes the data of a row filter */
|
|
4
|
+
export interface RowFilter extends Json {
|
|
5
|
+
/**
|
|
6
|
+
* The filters applied to specific columns of the table.
|
|
7
|
+
*/
|
|
8
|
+
columnFilters: ColumnFilter<any>[];
|
|
9
|
+
/**
|
|
10
|
+
* The operator the column filters are combined with.
|
|
11
|
+
*/
|
|
12
|
+
operator: 'and' | 'or';
|
|
13
|
+
/** The json hash of the object */
|
|
14
|
+
_hash: string;
|
|
15
|
+
}
|
|
16
|
+
/** An example row filter for test purposes */
|
|
17
|
+
export declare const exampleRowFilter: () => RowFilter;
|
|
18
|
+
/** En empty row filter doing nothing */
|
|
19
|
+
export declare const emptyRowFilter: RowFilter;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ColumnFilterProcessor } from './column-filter-processor.ts';
|
|
2
|
+
import { StringFilter } from './string-filter.ts';
|
|
3
|
+
export declare class StringFilterProcessor implements ColumnFilterProcessor {
|
|
4
|
+
readonly operator: StringOperator;
|
|
5
|
+
readonly matchCase: boolean;
|
|
6
|
+
constructor(operator: StringOperator, search: string, matchCase?: boolean);
|
|
7
|
+
static fromModel(model: StringFilter): StringFilterProcessor;
|
|
8
|
+
search: string;
|
|
9
|
+
regExp: RegExp | null;
|
|
10
|
+
equals(other: ColumnFilterProcessor): boolean;
|
|
11
|
+
static readonly allOperators: StringOperator[];
|
|
12
|
+
matches(cellValue: any): boolean;
|
|
13
|
+
static get example(): StringFilterProcessor;
|
|
14
|
+
}
|
|
15
|
+
export type StringOperator = 'startsWith' | 'contains' | 'endsWith' | 'equals' | 'notEquals' | 'notContains' | 'regExp';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ColumnFilter } from './column-filter.ts';
|
|
2
|
+
import { StringOperator } from './string-filter-processor.ts';
|
|
3
|
+
export interface StringFilter extends ColumnFilter<string> {
|
|
4
|
+
type: 'string';
|
|
5
|
+
operator: StringOperator;
|
|
6
|
+
matchCase?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const exampleStringFilter: () => StringFilter;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { Json, JsonValue, JsonValueType } from '@rljson/json';
|
|
2
|
+
import { Ref, Route, SliceId } from '@rljson/rljson';
|
|
3
|
+
import { Container } from '../db.ts';
|
|
4
|
+
import { RowFilter } from './filter/row-filter.ts';
|
|
5
|
+
import { ColumnSelection } from './selection/column-selection.ts';
|
|
6
|
+
import { SetValue } from './set-value/set-value.ts';
|
|
7
|
+
import { RowSort } from './sort/row-sort.ts';
|
|
8
|
+
export declare const joinPreserveKeys: string[];
|
|
9
|
+
export type JoinProcessType = 'filter' | 'setValue' | 'selection' | 'sort';
|
|
10
|
+
export type JoinProcess = {
|
|
11
|
+
type: JoinProcessType;
|
|
12
|
+
instance: RowFilter | SetValue | ColumnSelection | RowSort;
|
|
13
|
+
data: JoinRowsHashed;
|
|
14
|
+
columnSelection: ColumnSelection;
|
|
15
|
+
};
|
|
16
|
+
export interface JoinColumn {
|
|
17
|
+
route: Route;
|
|
18
|
+
value: Container;
|
|
19
|
+
inserts: Container[] | null;
|
|
20
|
+
}
|
|
21
|
+
export type JoinRow = JoinColumn[];
|
|
22
|
+
export type JoinRows = Record<SliceId, JoinRow>;
|
|
23
|
+
export type JoinRowHashed = {
|
|
24
|
+
rowHash: Ref;
|
|
25
|
+
columns: JoinColumn[];
|
|
26
|
+
};
|
|
27
|
+
export type JoinRowsHashed = Record<SliceId, JoinRowHashed>;
|
|
28
|
+
export declare class Join {
|
|
29
|
+
private _base;
|
|
30
|
+
private _baseColumnSelection;
|
|
31
|
+
private _processes;
|
|
32
|
+
constructor(rows: JoinRows, columnSelection: ColumnSelection);
|
|
33
|
+
/**
|
|
34
|
+
* Applies a filter to the join and returns the filtered view
|
|
35
|
+
*
|
|
36
|
+
* @param filter The filter to apply
|
|
37
|
+
*/
|
|
38
|
+
filter(filter: RowFilter): Join;
|
|
39
|
+
/**
|
|
40
|
+
* Applies a set value action to the join and returns the edited join
|
|
41
|
+
*
|
|
42
|
+
* @param setValue The set value action to apply
|
|
43
|
+
*/
|
|
44
|
+
setValue(setValue: SetValue): Join;
|
|
45
|
+
/**
|
|
46
|
+
* Applies multiple set value actions to the join and returns the edited join
|
|
47
|
+
*
|
|
48
|
+
* @param setValues The set value actions to apply
|
|
49
|
+
*/
|
|
50
|
+
setValues(setValues: SetValue[]): Join;
|
|
51
|
+
/**
|
|
52
|
+
* Selects columns from the join and returns the resulting join
|
|
53
|
+
*
|
|
54
|
+
* @param columnSelection The column selection to apply
|
|
55
|
+
*/
|
|
56
|
+
select(columnSelection: ColumnSelection): Join;
|
|
57
|
+
/**
|
|
58
|
+
* Sorts the join rows and returns the sorted join
|
|
59
|
+
*
|
|
60
|
+
* @param rowSort The row sort to apply
|
|
61
|
+
*/
|
|
62
|
+
sort(rowSort: RowSort): Join;
|
|
63
|
+
/**
|
|
64
|
+
* Returns insert Object of the join
|
|
65
|
+
*/
|
|
66
|
+
insert(): {
|
|
67
|
+
route: Route;
|
|
68
|
+
tree: Json;
|
|
69
|
+
}[];
|
|
70
|
+
/**
|
|
71
|
+
* Returns the value at the given row and column index
|
|
72
|
+
*
|
|
73
|
+
* @param row The row index
|
|
74
|
+
* @param column The column index
|
|
75
|
+
* @returns The value at the given row and column
|
|
76
|
+
*/
|
|
77
|
+
value(row: number, column: number): JsonValue[];
|
|
78
|
+
/**
|
|
79
|
+
* Clones the join
|
|
80
|
+
*
|
|
81
|
+
* @returns The cloned join
|
|
82
|
+
*/
|
|
83
|
+
clone(): Join;
|
|
84
|
+
/**
|
|
85
|
+
* Returns all component routes of the join
|
|
86
|
+
*/
|
|
87
|
+
get componentRoutes(): Route[];
|
|
88
|
+
/**
|
|
89
|
+
* Returns all layer routes of the join
|
|
90
|
+
*/
|
|
91
|
+
get layerRoutes(): Route[];
|
|
92
|
+
/**
|
|
93
|
+
* Returns the cake route of the join
|
|
94
|
+
*/
|
|
95
|
+
get cakeRoute(): Route;
|
|
96
|
+
/**
|
|
97
|
+
* Returns the number of rows in the join
|
|
98
|
+
*/
|
|
99
|
+
get rowCount(): number;
|
|
100
|
+
/**
|
|
101
|
+
* Returns the number of columns in the join
|
|
102
|
+
*/
|
|
103
|
+
get columnCount(): number;
|
|
104
|
+
/**
|
|
105
|
+
* Returns the row indices (sliceIds) of the join
|
|
106
|
+
*/
|
|
107
|
+
get rowIndices(): SliceId[];
|
|
108
|
+
/**
|
|
109
|
+
* Returns the join row for the given slice id
|
|
110
|
+
*
|
|
111
|
+
* @param sliceId - The slice id
|
|
112
|
+
* @returns The join row
|
|
113
|
+
*/
|
|
114
|
+
row(sliceId: SliceId): JoinRow;
|
|
115
|
+
/**
|
|
116
|
+
* Returns the data of the join
|
|
117
|
+
*/
|
|
118
|
+
get data(): JoinRowsHashed;
|
|
119
|
+
/**
|
|
120
|
+
* Returns the column types of the join
|
|
121
|
+
*/
|
|
122
|
+
get columnTypes(): JsonValueType[];
|
|
123
|
+
/**
|
|
124
|
+
* Returns the column selection of the join
|
|
125
|
+
*/
|
|
126
|
+
get columnSelection(): ColumnSelection;
|
|
127
|
+
/**
|
|
128
|
+
* Returns all rows of the join w/ nulled missing values
|
|
129
|
+
*
|
|
130
|
+
* @return The rows of the join
|
|
131
|
+
*/
|
|
132
|
+
get rows(): any[][];
|
|
133
|
+
static empty(): Join;
|
|
134
|
+
/**
|
|
135
|
+
* Hashes the given join rows. If insert value is present, it is used for hashing.
|
|
136
|
+
*
|
|
137
|
+
* @param rows The join rows to hash
|
|
138
|
+
* @returns The hashed join rows
|
|
139
|
+
*/
|
|
140
|
+
private _hashedRows;
|
|
141
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ColumnCfgWithRoute, Ref, Route } from '@rljson/rljson';
|
|
2
|
+
export type ColumnRoute = string | string[] | number;
|
|
3
|
+
export interface ColumnInfo extends ColumnCfgWithRoute {
|
|
4
|
+
alias: string;
|
|
5
|
+
routeHash?: Ref;
|
|
6
|
+
index?: number;
|
|
7
|
+
value?: any;
|
|
8
|
+
}
|
|
9
|
+
export declare class ColumnSelection {
|
|
10
|
+
constructor(columns: ColumnInfo[]);
|
|
11
|
+
/**
|
|
12
|
+
* Returns unique routes from a list of routes
|
|
13
|
+
* @param routes - The list of routes
|
|
14
|
+
* @returns Unique routes
|
|
15
|
+
*/
|
|
16
|
+
static uniqueRoutes(routes: Route[]): Route[];
|
|
17
|
+
/**
|
|
18
|
+
* Returns a ColumnSelection from a list of route segments
|
|
19
|
+
* @param routeSegmentsList - A list of route segments
|
|
20
|
+
* @returns A ColumnSelection object
|
|
21
|
+
*/
|
|
22
|
+
static fromRoutes(routes: Route[]): ColumnSelection;
|
|
23
|
+
readonly columns: ColumnInfo[];
|
|
24
|
+
readonly routes: string[];
|
|
25
|
+
readonly aliases: string[];
|
|
26
|
+
readonly routeHashes: string[];
|
|
27
|
+
metadata(key: string): any[];
|
|
28
|
+
static merge(columnSelections: ColumnSelection[]): ColumnSelection;
|
|
29
|
+
static calcHash(str: string): string;
|
|
30
|
+
route(aliasRouteOrHash: ColumnRoute): string;
|
|
31
|
+
alias(aliasRouteOrHash: ColumnRoute): string;
|
|
32
|
+
columnIndex(hashAliasOrRoute: ColumnRoute, throwIfNotExisting?: boolean): number;
|
|
33
|
+
/***
|
|
34
|
+
* Returns the column config for a specific alias, route or hash.
|
|
35
|
+
*/
|
|
36
|
+
column(aliasRouteOrHash: ColumnRoute): ColumnInfo;
|
|
37
|
+
get count(): number;
|
|
38
|
+
addedColumns(columnSelection: ColumnSelection): string[];
|
|
39
|
+
static check(aliases: string[], routes: string[]): void;
|
|
40
|
+
private _throwOnWrongAlias;
|
|
41
|
+
private _initColumns;
|
|
42
|
+
static example(): ColumnSelection;
|
|
43
|
+
static exampleBroken(): ColumnInfo[];
|
|
44
|
+
static exampleCarsColumnSelection(): ColumnSelection;
|
|
45
|
+
static exampleCarsDeeplyNestedColumnSelection(): ColumnSelection;
|
|
46
|
+
static exampleCarsColumnSelectionOnlySomeColumns(): ColumnSelection;
|
|
47
|
+
static empty(): ColumnSelection;
|
|
48
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RouteRef, SliceId } from '@rljson/rljson';
|
|
2
|
+
import { Join } from '../join.ts';
|
|
3
|
+
export type RowSortOrder = 'asc' | 'desc';
|
|
4
|
+
export type RowSortType = Record<RouteRef, RowSortOrder>;
|
|
5
|
+
export declare class RowSort {
|
|
6
|
+
constructor(columnSorts: Record<string, 'asc' | 'desc'>);
|
|
7
|
+
/**
|
|
8
|
+
* Sorts the rows of a join according to the sort configuration.
|
|
9
|
+
* @param join - The join to be sorted
|
|
10
|
+
* @returns Returns the row indices in a sorted manner
|
|
11
|
+
*/
|
|
12
|
+
applyTo(join: Join): SliceId[];
|
|
13
|
+
get columnSorts(): Record<string, 'asc' | 'desc'>;
|
|
14
|
+
private readonly _columnSorts;
|
|
15
|
+
private _initColumnSorts;
|
|
16
|
+
private _sortRows;
|
|
17
|
+
private _throwOnWrongRoutes;
|
|
18
|
+
}
|
package/dist/notify.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InsertHistoryRow, Route } from '@rljson/rljson';
|
|
2
|
-
type NotifyCallback<N extends string> = (InsertHistoryRow: InsertHistoryRow<N>) =>
|
|
2
|
+
export type NotifyCallback<N extends string> = (InsertHistoryRow: InsertHistoryRow<N>) => Promise<any>;
|
|
3
3
|
/**
|
|
4
4
|
* Notification system to manage callbacks for specific routes and notify them with edit protocol rows.
|
|
5
5
|
*/
|
|
@@ -18,6 +18,11 @@ export declare class Notify {
|
|
|
18
18
|
* @param callback The callback function to be removed.
|
|
19
19
|
*/
|
|
20
20
|
unregister(route: Route, callback: NotifyCallback<any>): void;
|
|
21
|
+
/**
|
|
22
|
+
* Unregisters all callbacks for a specific route.
|
|
23
|
+
* @param route The route to unregister all callbacks from.
|
|
24
|
+
*/
|
|
25
|
+
unregisterAll(route: Route): void;
|
|
21
26
|
/**
|
|
22
27
|
* Notifies all registered callbacks for a specific route with the provided edit protocol row.
|
|
23
28
|
* @param route The route to notify callbacks for.
|
|
@@ -36,4 +41,3 @@ export declare class Notify {
|
|
|
36
41
|
*/
|
|
37
42
|
getCallBacksForRoute(route: Route): NotifyCallback<any>[];
|
|
38
43
|
}
|
|
39
|
-
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const inject: (tree: any, path: (string | number)[], value: any) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isolate: (tree: any, path: (string | number)[], preservedKeys?: string[]) => any;
|