@rljson/db 0.0.6 → 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 +39 -28
- package/dist/db.js +1457 -506
- package/package.json +14 -14
- 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,11 +43,24 @@ 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<
|
|
36
|
-
|
|
51
|
+
get(route: Route, where: string | Json, filter?: ControllerChildProperty[], sliceIds?: SliceId[]): Promise<ContainerWithControllers>;
|
|
52
|
+
/**
|
|
53
|
+
* Resolves the route and returns corresponding data for any segment of the route,
|
|
54
|
+
* matching recursive filters and where clauses
|
|
55
|
+
*
|
|
56
|
+
* @param route - The route to get data from
|
|
57
|
+
* @param where - The recursive filtering key/value pairs to apply to the data
|
|
58
|
+
* @param controllers - The controllers to use for fetching data
|
|
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
|
|
61
|
+
* @returns - An Rljson object matching the route and filters
|
|
62
|
+
*/
|
|
63
|
+
_get(route: Route, where: string | Json, controllers: Record<string, Controller<any, any, any>>, filter?: ControllerChildProperty[], sliceIds?: SliceId[], routeAccumulator?: Route): Promise<Container>;
|
|
37
64
|
/**
|
|
38
65
|
* Get the reference (hash) of a route segment, considering default refs and insertHistory refs
|
|
39
66
|
* @param segment - The route segment to get the reference for
|
|
@@ -45,20 +72,17 @@ export declare class Db {
|
|
|
45
72
|
* @param rljson - The Rljson to join data for
|
|
46
73
|
*/
|
|
47
74
|
join(columnSelection: ColumnSelection, cakeKey: string, cakeRef: Ref): Promise<Join>;
|
|
48
|
-
|
|
49
|
-
* Fetches data for the given ColumnSelection
|
|
50
|
-
* @param columnSelection - The ColumnSelection to fetch data for
|
|
51
|
-
*/
|
|
52
|
-
private _getBaseDataForColumnSelection;
|
|
75
|
+
private _resolveSliceIds;
|
|
53
76
|
/**
|
|
54
77
|
* Runs an Insert by executing the appropriate controller(s) based on the Insert's route
|
|
55
78
|
* @param Insert - The Insert to run
|
|
56
79
|
* @returns The result of the Insert as an InsertHistoryRow
|
|
57
80
|
* @throws {Error} If the Insert is not valid or if any controller cannot be created
|
|
58
81
|
*/
|
|
59
|
-
insert(
|
|
82
|
+
insert(route: Route, tree: Json, options?: {
|
|
60
83
|
skipNotification?: boolean;
|
|
61
|
-
|
|
84
|
+
skipHistory?: boolean;
|
|
85
|
+
}): Promise<InsertHistoryRow<any>[]>;
|
|
62
86
|
/**
|
|
63
87
|
* Recursively runs controllers based on the route of the Insert
|
|
64
88
|
* @param insert - The Insert to run
|
|
@@ -80,19 +104,6 @@ export declare class Db {
|
|
|
80
104
|
* @param callback - The callback to be unregistered
|
|
81
105
|
*/
|
|
82
106
|
unregisterObserver(route: Route, callback: (InsertHistoryRow: InsertHistoryRow<any>) => void): void;
|
|
83
|
-
/**
|
|
84
|
-
* Resolves an Insert by returning the run functions of all controllers involved in the Insert's route
|
|
85
|
-
* @param Insert - The Insert to resolve
|
|
86
|
-
* @returns A record of controller run functions, keyed by table name
|
|
87
|
-
* @throws {Error} If the route is not valid or if any controller cannot be created
|
|
88
|
-
*/
|
|
89
|
-
private _resolveInsert;
|
|
90
|
-
/**
|
|
91
|
-
* Returns the keys of child refs in a value based on a route
|
|
92
|
-
* @param value - The value to check
|
|
93
|
-
* @returns An array of keys of child refs in the value
|
|
94
|
-
*/
|
|
95
|
-
private _childKeys;
|
|
96
107
|
/**
|
|
97
108
|
* Get a controller for a specific table
|
|
98
109
|
* @param tableKey - The key of the table to get the controller for
|
|
@@ -100,8 +111,8 @@ export declare class Db {
|
|
|
100
111
|
* @returns A controller for the specified table
|
|
101
112
|
* @throws {Error} If the table does not exist or if the table type is not supported
|
|
102
113
|
*/
|
|
103
|
-
getController(tableKey: string, refs?: ControllerRefs): Promise<Controller<any, string>>;
|
|
104
|
-
|
|
114
|
+
getController(tableKey: string, refs?: ControllerRefs): Promise<Controller<TableType, any, string>>;
|
|
115
|
+
indexedControllers(route: Route): Promise<Record<string, Controller<any, any, any>>>;
|
|
105
116
|
/**
|
|
106
117
|
* Adds an InsertHistory row to the InsertHistory table of a table
|
|
107
118
|
* @param table - The table the Insert was made on
|
|
@@ -166,5 +177,5 @@ export declare class Db {
|
|
|
166
177
|
/**
|
|
167
178
|
* Get the current cache of the Db instance
|
|
168
179
|
*/
|
|
169
|
-
get cache(): Map<string,
|
|
180
|
+
get cache(): Map<string, Container>;
|
|
170
181
|
}
|