@rljson/db 0.0.7 → 0.0.8
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/db.d.ts +27 -40
- package/dist/db.js +1209 -675
- package/package.json +11 -11
- package/dist/cars-example.d.ts +0 -41
package/dist/db.d.ts
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import { Io } from '@rljson/io';
|
|
2
|
-
import { Json } from '@rljson/json';
|
|
3
|
-
import {
|
|
4
|
-
import { Controller, ControllerRefs } from './controller/controller.ts';
|
|
2
|
+
import { Json, JsonValue } from '@rljson/json';
|
|
3
|
+
import { InsertHistoryRow, InsertHistoryTimeId, Ref, Rljson, Route, SliceId, TableType } from '@rljson/rljson';
|
|
4
|
+
import { Controller, ControllerChildProperty, ControllerRefs } from './controller/controller.ts';
|
|
5
5
|
import { Core } from './core.ts';
|
|
6
6
|
import { Join } from './join/join.ts';
|
|
7
7
|
import { ColumnSelection } from './join/selection/column-selection.ts';
|
|
8
8
|
import { Notify } from './notify.ts';
|
|
9
|
+
export type Cell = {
|
|
10
|
+
route: Route;
|
|
11
|
+
value: JsonValue[] | null;
|
|
12
|
+
row: JsonValue[] | null;
|
|
13
|
+
path: Array<Array<string | number>>;
|
|
14
|
+
};
|
|
15
|
+
export type Container = {
|
|
16
|
+
rljson: Rljson;
|
|
17
|
+
tree: Json;
|
|
18
|
+
cell: Cell[];
|
|
19
|
+
};
|
|
20
|
+
export type ContainerWithControllers = Container & {
|
|
21
|
+
controllers: Record<string, Controller<any, any, any>>;
|
|
22
|
+
};
|
|
9
23
|
/**
|
|
10
24
|
* Access Rljson data
|
|
11
25
|
*/
|
|
@@ -29,10 +43,12 @@ export declare class Db {
|
|
|
29
43
|
* Get data from a route with optional filtering
|
|
30
44
|
* @param route - The route to get data from
|
|
31
45
|
* @param where - Optional filter to apply to the data
|
|
46
|
+
* @param filter - Optional filter to apply to child entries in related tables
|
|
47
|
+
* @param sliceIds - Optional slice IDs to filter the data
|
|
32
48
|
* @returns An array of Rljson objects matching the route and filter
|
|
33
49
|
* @throws {Error} If the route is not valid or if any controller cannot be created
|
|
34
50
|
*/
|
|
35
|
-
get(route: Route, where: string | Json): Promise<
|
|
51
|
+
get(route: Route, where: string | Json, filter?: ControllerChildProperty[], sliceIds?: SliceId[]): Promise<ContainerWithControllers>;
|
|
36
52
|
/**
|
|
37
53
|
* Resolves the route and returns corresponding data for any segment of the route,
|
|
38
54
|
* matching recursive filters and where clauses
|
|
@@ -41,13 +57,10 @@ export declare class Db {
|
|
|
41
57
|
* @param where - The recursive filtering key/value pairs to apply to the data
|
|
42
58
|
* @param controllers - The controllers to use for fetching data
|
|
43
59
|
* @param filter - Optional filter to apply to the data at the current route segment
|
|
60
|
+
* @param sliceIds - Optional slice IDs to filter the data at the current route segment
|
|
44
61
|
* @returns - An Rljson object matching the route and filters
|
|
45
62
|
*/
|
|
46
|
-
_get(route: Route, where: string | Json, controllers: Record<string, Controller<any, any>>, filter?:
|
|
47
|
-
tableKey: TableKey;
|
|
48
|
-
columnKey?: string;
|
|
49
|
-
ref: Ref;
|
|
50
|
-
}>): Promise<Rljson>;
|
|
63
|
+
_get(route: Route, where: string | Json, controllers: Record<string, Controller<any, any, any>>, filter?: ControllerChildProperty[], sliceIds?: SliceId[], routeAccumulator?: Route): Promise<Container>;
|
|
51
64
|
/**
|
|
52
65
|
* Get the reference (hash) of a route segment, considering default refs and insertHistory refs
|
|
53
66
|
* @param segment - The route segment to get the reference for
|
|
@@ -59,27 +72,14 @@ export declare class Db {
|
|
|
59
72
|
* @param rljson - The Rljson to join data for
|
|
60
73
|
*/
|
|
61
74
|
join(columnSelection: ColumnSelection, cakeKey: string, cakeRef: Ref): Promise<Join>;
|
|
62
|
-
private
|
|
63
|
-
/**
|
|
64
|
-
* Resolve a component's columns, including referenced components
|
|
65
|
-
*
|
|
66
|
-
* @param baseRoute - The base route for the component
|
|
67
|
-
* @param componentKey - The component's table key
|
|
68
|
-
* @returns - The resolved column configurations, column infos, and object map
|
|
69
|
-
*/
|
|
70
|
-
private _resolveComponent;
|
|
71
|
-
/**
|
|
72
|
-
* Fetches data for the given ColumnSelection
|
|
73
|
-
* @param columnSelection - The ColumnSelection to fetch data for
|
|
74
|
-
*/
|
|
75
|
-
private _getBaseDataForColumnSelection;
|
|
75
|
+
private _resolveSliceIds;
|
|
76
76
|
/**
|
|
77
77
|
* Runs an Insert by executing the appropriate controller(s) based on the Insert's route
|
|
78
78
|
* @param Insert - The Insert to run
|
|
79
79
|
* @returns The result of the Insert as an InsertHistoryRow
|
|
80
80
|
* @throws {Error} If the Insert is not valid or if any controller cannot be created
|
|
81
81
|
*/
|
|
82
|
-
insert(
|
|
82
|
+
insert(route: Route, tree: Json, options?: {
|
|
83
83
|
skipNotification?: boolean;
|
|
84
84
|
skipHistory?: boolean;
|
|
85
85
|
}): Promise<InsertHistoryRow<any>[]>;
|
|
@@ -104,19 +104,6 @@ export declare class Db {
|
|
|
104
104
|
* @param callback - The callback to be unregistered
|
|
105
105
|
*/
|
|
106
106
|
unregisterObserver(route: Route, callback: (InsertHistoryRow: InsertHistoryRow<any>) => void): void;
|
|
107
|
-
/**
|
|
108
|
-
* Resolves an Insert by returning the run functions of all controllers involved in the Insert's route
|
|
109
|
-
* @param Insert - The Insert to resolve
|
|
110
|
-
* @returns A record of controller run functions, keyed by table name
|
|
111
|
-
* @throws {Error} If the route is not valid or if any controller cannot be created
|
|
112
|
-
*/
|
|
113
|
-
private _resolveInsert;
|
|
114
|
-
/**
|
|
115
|
-
* Returns the keys of child refs in a value based on a route
|
|
116
|
-
* @param value - The value to check
|
|
117
|
-
* @returns An array of keys of child refs in the value
|
|
118
|
-
*/
|
|
119
|
-
private _childKeys;
|
|
120
107
|
/**
|
|
121
108
|
* Get a controller for a specific table
|
|
122
109
|
* @param tableKey - The key of the table to get the controller for
|
|
@@ -124,8 +111,8 @@ export declare class Db {
|
|
|
124
111
|
* @returns A controller for the specified table
|
|
125
112
|
* @throws {Error} If the table does not exist or if the table type is not supported
|
|
126
113
|
*/
|
|
127
|
-
getController(tableKey: string, refs?: ControllerRefs): Promise<Controller<any, string>>;
|
|
128
|
-
|
|
114
|
+
getController(tableKey: string, refs?: ControllerRefs): Promise<Controller<TableType, any, string>>;
|
|
115
|
+
indexedControllers(route: Route): Promise<Record<string, Controller<any, any, any>>>;
|
|
129
116
|
/**
|
|
130
117
|
* Adds an InsertHistory row to the InsertHistory table of a table
|
|
131
118
|
* @param table - The table the Insert was made on
|
|
@@ -190,5 +177,5 @@ export declare class Db {
|
|
|
190
177
|
/**
|
|
191
178
|
* Get the current cache of the Db instance
|
|
192
179
|
*/
|
|
193
|
-
get cache(): Map<string,
|
|
180
|
+
get cache(): Map<string, Container>;
|
|
194
181
|
}
|