@rljson/db 0.0.11 → 0.0.12
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/controller/controller.d.ts +2 -2
- package/dist/controller/tree-controller.d.ts +18 -0
- package/dist/db.d.ts +0 -6
- package/dist/db.js +263 -106
- package/dist/db.js.map +1 -1
- package/package.json +16 -16
|
@@ -20,7 +20,7 @@ export type ControllerChildProperty = {
|
|
|
20
20
|
* @property {ControllerRunFn<N>} insert - Function to execute a command on the table.
|
|
21
21
|
* @property {() => Promise<void>} init - Initializes the controller.
|
|
22
22
|
* @property {() => Promise<T>} table - Retrieves the current state of the table.
|
|
23
|
-
* @property {(where: string | { [column: string]: JsonValue }) => Promise<Rljson>} get - Fetches data from the table based on a condition.
|
|
23
|
+
* @property {(where: string | { [column: string]: JsonValue }, filter: Json | undefined, path: string | undefined) => Promise<Rljson>} get - Fetches data from the table based on a condition.
|
|
24
24
|
* @property {(where: string | Json, filter?: Json) => Promise<Array<{ tableKey: TableKey; ref: Ref }>>} getChildRefs - Retrieves references to child entries in related tables based on a condition.
|
|
25
25
|
* @param {string | Json }} where - The condition to filter the data.
|
|
26
26
|
* @returns {Promise<Json[] | null>} A promise that resolves to an array of JSON objects or null if no data is found.
|
|
@@ -30,7 +30,7 @@ export interface Controller<T extends TableType, C extends JsonValue, N extends
|
|
|
30
30
|
insert: ControllerRunFn<N, C>;
|
|
31
31
|
init(): Promise<void>;
|
|
32
32
|
table(): Promise<T>;
|
|
33
|
-
get(where: string | Json, filter?: Json): Promise<Rljson>;
|
|
33
|
+
get(where: string | Json, filter?: Json, path?: string): Promise<Rljson>;
|
|
34
34
|
getChildRefs(where: string | Json, filter?: Json): Promise<ControllerChildProperty[]>;
|
|
35
35
|
filterRow(row: Json, key: string, value: JsonValue): Promise<boolean>;
|
|
36
36
|
contentType(): ContentType;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Json } from '@rljson/json';
|
|
2
|
+
import { InsertCommand, InsertHistoryRow, Ref, Rljson, TableKey, Tree, TreesTable } from '@rljson/rljson';
|
|
3
|
+
import { Core } from '../core.ts';
|
|
4
|
+
import { Cell } from '../db.ts';
|
|
5
|
+
import { BaseController } from './base-controller.ts';
|
|
6
|
+
import { Controller, ControllerChildProperty } from './controller.ts';
|
|
7
|
+
export declare class TreeController<N extends string, C extends Tree> extends BaseController<TreesTable, C> implements Controller<TreesTable, C, N> {
|
|
8
|
+
protected readonly _core: Core;
|
|
9
|
+
protected readonly _tableKey: TableKey;
|
|
10
|
+
constructor(_core: Core, _tableKey: TableKey);
|
|
11
|
+
init(): Promise<void>;
|
|
12
|
+
insert(command: InsertCommand, value: Tree, origin?: Ref): Promise<InsertHistoryRow<any>[]>;
|
|
13
|
+
get(where: string | Json, filter?: Json, path?: string): Promise<Rljson>;
|
|
14
|
+
buildTreeFromTrees(trees: Tree[]): Promise<Json>;
|
|
15
|
+
buildCellsFromTree(trees: Tree[]): Promise<Cell[]>;
|
|
16
|
+
getChildRefs(where: string | Json, filter?: Json): Promise<ControllerChildProperty[]>;
|
|
17
|
+
filterRow(): Promise<boolean>;
|
|
18
|
+
}
|
package/dist/db.d.ts
CHANGED
|
@@ -131,12 +131,6 @@ export declare class Db {
|
|
|
131
131
|
* @throws {Error} If the InsertHistory table does not exist
|
|
132
132
|
*/
|
|
133
133
|
private _writeInsertHistory;
|
|
134
|
-
/**
|
|
135
|
-
* Add a head revision for a cake
|
|
136
|
-
* @param cakeKey - The cake table key
|
|
137
|
-
* @param cakeRef - The cake reference
|
|
138
|
-
*/
|
|
139
|
-
addHeadRevision(cakeKey: string, cakeRef: Ref): Promise<InsertHistoryRow<string>[]>;
|
|
140
134
|
/**
|
|
141
135
|
* Add a multiEdit
|
|
142
136
|
* @param cakeKey - The cake table key
|
package/dist/db.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { timeId, createInsertHistoryTableCfg, Validate, BaseValidator,
|
|
1
|
+
import { timeId, Route, createInsertHistoryTableCfg, Validate, BaseValidator, treeFromObject, isTimeId, getTimeIdTimestamp, createSliceIdsTableCfg, createLayerTableCfg, createCakeTableCfg } from "@rljson/rljson";
|
|
2
2
|
import { rmhsh, hsh, Hash, hip } from "@rljson/hash";
|
|
3
3
|
import { equals, merge } from "@rljson/json";
|
|
4
4
|
import { IoMem } from "@rljson/io";
|
|
@@ -208,9 +208,6 @@ class CakeController extends BaseController {
|
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
async getChildRefs(where, filter) {
|
|
211
|
-
if (!this._tableCfg) {
|
|
212
|
-
throw new Error(`Controller not initialized.`);
|
|
213
|
-
}
|
|
214
211
|
const childRefs = [];
|
|
215
212
|
const { [this._tableKey]: table } = await this.get(where, filter);
|
|
216
213
|
const cakes = table._data;
|
|
@@ -291,7 +288,7 @@ class ComponentController extends BaseController {
|
|
|
291
288
|
"edits",
|
|
292
289
|
"editHistory",
|
|
293
290
|
"multiEdits",
|
|
294
|
-
"
|
|
291
|
+
"insertHistory"
|
|
295
292
|
];
|
|
296
293
|
_resolvedColumns = null;
|
|
297
294
|
_refTableKeyToColumnKeyMap = null;
|
|
@@ -933,6 +930,199 @@ class LayerController extends BaseController {
|
|
|
933
930
|
return false;
|
|
934
931
|
}
|
|
935
932
|
}
|
|
933
|
+
class TreeController extends BaseController {
|
|
934
|
+
constructor(_core, _tableKey) {
|
|
935
|
+
super(_core, _tableKey);
|
|
936
|
+
this._core = _core;
|
|
937
|
+
this._tableKey = _tableKey;
|
|
938
|
+
this._contentType = "trees";
|
|
939
|
+
}
|
|
940
|
+
async init() {
|
|
941
|
+
if (this._tableKey.endsWith("Tree") === false) {
|
|
942
|
+
throw new Error(
|
|
943
|
+
`Table ${this._tableKey} is not supported by TreeController.`
|
|
944
|
+
);
|
|
945
|
+
}
|
|
946
|
+
const contentType = await this._core.contentType(this._tableKey);
|
|
947
|
+
if (contentType !== "trees") {
|
|
948
|
+
throw new Error(`Table ${this._tableKey} is not of type trees.`);
|
|
949
|
+
}
|
|
950
|
+
this._tableCfg = await this._core.tableCfg(this._tableKey);
|
|
951
|
+
}
|
|
952
|
+
async insert(command, value, origin) {
|
|
953
|
+
if (!command.startsWith("add") && !command.startsWith("remove")) {
|
|
954
|
+
throw new Error(`Command ${command} is not supported by TreeController.`);
|
|
955
|
+
}
|
|
956
|
+
const rlJson = { [this._tableKey]: { _data: [value] } };
|
|
957
|
+
await this._core.import(rlJson);
|
|
958
|
+
const result = {
|
|
959
|
+
//Ref to component
|
|
960
|
+
[this._tableKey + "Ref"]: hsh(value)._hash,
|
|
961
|
+
//Data from edit
|
|
962
|
+
route: "",
|
|
963
|
+
origin,
|
|
964
|
+
//Unique id/timestamp
|
|
965
|
+
timeId: timeId()
|
|
966
|
+
};
|
|
967
|
+
return [result];
|
|
968
|
+
}
|
|
969
|
+
async get(where, filter, path) {
|
|
970
|
+
const {
|
|
971
|
+
[this._tableKey]: { _data: trees }
|
|
972
|
+
} = typeof where === "string" ? await this._getByHash(where, filter) : await this._getByWhere(where, filter);
|
|
973
|
+
if (trees.length === 0) {
|
|
974
|
+
return { [this._tableKey]: { _data: [], _type: "trees" } };
|
|
975
|
+
}
|
|
976
|
+
if (trees.length > 1) {
|
|
977
|
+
throw new Error(
|
|
978
|
+
`Multiple trees found for where clause. Please specify a more specific query.`
|
|
979
|
+
);
|
|
980
|
+
}
|
|
981
|
+
const treeRoute = Route.fromFlat(path || "");
|
|
982
|
+
const treeId = treeRoute.segments.length > 0 ? treeRoute.top.tableKey : null;
|
|
983
|
+
const tree = trees[0];
|
|
984
|
+
if (treeId && treeId !== tree.id) {
|
|
985
|
+
return { [this._tableKey]: { _data: [], _type: "trees" } };
|
|
986
|
+
}
|
|
987
|
+
const children = [];
|
|
988
|
+
for (const childRef of tree.children ?? []) {
|
|
989
|
+
const child = await this.get(
|
|
990
|
+
childRef,
|
|
991
|
+
void 0,
|
|
992
|
+
treeRoute.deeper().flat
|
|
993
|
+
);
|
|
994
|
+
const childData = child[this._tableKey]._data;
|
|
995
|
+
children.push(...childData);
|
|
996
|
+
}
|
|
997
|
+
return {
|
|
998
|
+
[this._tableKey]: {
|
|
999
|
+
_data: [...children, tree],
|
|
1000
|
+
_type: "trees"
|
|
1001
|
+
}
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
async buildTreeFromTrees(trees) {
|
|
1005
|
+
if (trees.length === 0) {
|
|
1006
|
+
return {};
|
|
1007
|
+
}
|
|
1008
|
+
const treeMap = /* @__PURE__ */ new Map();
|
|
1009
|
+
for (const tree of trees) {
|
|
1010
|
+
treeMap.set(tree._hash, tree);
|
|
1011
|
+
}
|
|
1012
|
+
const buildObject = (tree) => {
|
|
1013
|
+
if (!tree.isParent || !tree.children || tree.children.length === 0) {
|
|
1014
|
+
return tree;
|
|
1015
|
+
}
|
|
1016
|
+
const result2 = {};
|
|
1017
|
+
for (const childHash of tree.children) {
|
|
1018
|
+
const childTree = treeMap.get(childHash);
|
|
1019
|
+
if (childTree && childTree.id) {
|
|
1020
|
+
result2[childTree.id] = buildObject(childTree);
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
return result2;
|
|
1024
|
+
};
|
|
1025
|
+
const referencedHashes = /* @__PURE__ */ new Set();
|
|
1026
|
+
for (const tree of trees) {
|
|
1027
|
+
if (tree.children) {
|
|
1028
|
+
for (const childHash of tree.children) {
|
|
1029
|
+
referencedHashes.add(childHash);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
const rootTrees = trees.filter(
|
|
1034
|
+
(tree) => !referencedHashes.has(tree._hash)
|
|
1035
|
+
);
|
|
1036
|
+
if (rootTrees.length === 0) {
|
|
1037
|
+
return {};
|
|
1038
|
+
}
|
|
1039
|
+
if (rootTrees.length === 1) {
|
|
1040
|
+
const rootTree = rootTrees[0];
|
|
1041
|
+
if (rootTree.id) {
|
|
1042
|
+
return { [rootTree.id]: buildObject(rootTree) };
|
|
1043
|
+
}
|
|
1044
|
+
return buildObject(rootTree);
|
|
1045
|
+
}
|
|
1046
|
+
const result = {};
|
|
1047
|
+
for (const rootTree of rootTrees) {
|
|
1048
|
+
if (rootTree.id) {
|
|
1049
|
+
result[rootTree.id] = buildObject(rootTree);
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
return result;
|
|
1053
|
+
}
|
|
1054
|
+
async buildCellsFromTree(trees) {
|
|
1055
|
+
const cells = [];
|
|
1056
|
+
if (trees.length === 0) {
|
|
1057
|
+
return cells;
|
|
1058
|
+
}
|
|
1059
|
+
const treeMap = /* @__PURE__ */ new Map();
|
|
1060
|
+
const childToParentMap = /* @__PURE__ */ new Map();
|
|
1061
|
+
for (const tree of trees) {
|
|
1062
|
+
const treeHash = tree._hash;
|
|
1063
|
+
treeMap.set(treeHash, tree);
|
|
1064
|
+
if (tree.children) {
|
|
1065
|
+
for (const childHash of tree.children) {
|
|
1066
|
+
childToParentMap.set(childHash, treeHash);
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
const availableHashes = /* @__PURE__ */ new Set();
|
|
1071
|
+
for (const tree of trees) {
|
|
1072
|
+
availableHashes.add(tree._hash);
|
|
1073
|
+
}
|
|
1074
|
+
const leafNodes = trees.filter((tree) => {
|
|
1075
|
+
if (!tree.children || tree.children.length === 0) {
|
|
1076
|
+
return true;
|
|
1077
|
+
}
|
|
1078
|
+
const hasChildInTrees = tree.children.some(
|
|
1079
|
+
(childHash) => availableHashes.has(childHash)
|
|
1080
|
+
);
|
|
1081
|
+
return !hasChildInTrees;
|
|
1082
|
+
});
|
|
1083
|
+
for (const leaf of leafNodes) {
|
|
1084
|
+
const pathIds = [];
|
|
1085
|
+
let currentHash = leaf._hash;
|
|
1086
|
+
while (currentHash) {
|
|
1087
|
+
const current = treeMap.get(currentHash);
|
|
1088
|
+
if (!current) break;
|
|
1089
|
+
if (current.id) {
|
|
1090
|
+
pathIds.unshift(current.id);
|
|
1091
|
+
}
|
|
1092
|
+
const parentHash = childToParentMap.get(currentHash);
|
|
1093
|
+
if (!parentHash) break;
|
|
1094
|
+
currentHash = parentHash;
|
|
1095
|
+
}
|
|
1096
|
+
const routeStr = "/" + pathIds.join("/");
|
|
1097
|
+
const route = Route.fromFlat(routeStr);
|
|
1098
|
+
cells.push({
|
|
1099
|
+
route,
|
|
1100
|
+
value: leaf,
|
|
1101
|
+
row: leaf,
|
|
1102
|
+
path: [[this._tableKey, "_data", 0, ...pathIds]]
|
|
1103
|
+
});
|
|
1104
|
+
}
|
|
1105
|
+
return cells;
|
|
1106
|
+
}
|
|
1107
|
+
async getChildRefs(where, filter) {
|
|
1108
|
+
const childRefs = [];
|
|
1109
|
+
const { [this._tableKey]: table } = await this.get(where, filter);
|
|
1110
|
+
const trees = table._data;
|
|
1111
|
+
for (const tree of trees) {
|
|
1112
|
+
for (const treeChildRef of tree.children ?? []) {
|
|
1113
|
+
childRefs.push({
|
|
1114
|
+
tableKey: this._tableKey,
|
|
1115
|
+
ref: treeChildRef
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
return childRefs;
|
|
1120
|
+
}
|
|
1121
|
+
/* v8 ignore next -- @preserve */
|
|
1122
|
+
async filterRow() {
|
|
1123
|
+
return false;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
936
1126
|
const createController = async (type, core, tableKey, refs) => {
|
|
937
1127
|
let ctrl;
|
|
938
1128
|
switch (type) {
|
|
@@ -943,7 +1133,7 @@ const createController = async (type, core, tableKey, refs) => {
|
|
|
943
1133
|
case "edits":
|
|
944
1134
|
case "editHistory":
|
|
945
1135
|
case "multiEdits":
|
|
946
|
-
case "
|
|
1136
|
+
case "insertHistory":
|
|
947
1137
|
ctrl = new ComponentController(core, tableKey, refs);
|
|
948
1138
|
break;
|
|
949
1139
|
case "cakes":
|
|
@@ -956,6 +1146,9 @@ const createController = async (type, core, tableKey, refs) => {
|
|
|
956
1146
|
refs
|
|
957
1147
|
);
|
|
958
1148
|
break;
|
|
1149
|
+
case "trees":
|
|
1150
|
+
ctrl = new TreeController(core, tableKey);
|
|
1151
|
+
break;
|
|
959
1152
|
default:
|
|
960
1153
|
throw new Error(`Controller for type ${type} is not implemented yet.`);
|
|
961
1154
|
}
|
|
@@ -1062,7 +1255,7 @@ const inject = (tree, path, value) => {
|
|
|
1062
1255
|
tree[segment] = value;
|
|
1063
1256
|
delete tree["_hash"];
|
|
1064
1257
|
} else {
|
|
1065
|
-
if (!tree[segment]) {
|
|
1258
|
+
if (!tree[segment] || typeof tree[segment] !== "object") {
|
|
1066
1259
|
tree[segment] = {};
|
|
1067
1260
|
}
|
|
1068
1261
|
tree = tree[segment];
|
|
@@ -2762,7 +2955,7 @@ class Db {
|
|
|
2762
2955
|
delete nodeWhere["_tableKey"];
|
|
2763
2956
|
const {
|
|
2764
2957
|
[nodeTableKey]: { _data: nodeRows, _type: nodeType, _hash: nodeHash }
|
|
2765
|
-
} = await nodeController.get(nodeWhere);
|
|
2958
|
+
} = await nodeController.get(nodeWhere, void 0, route.propertyKey);
|
|
2766
2959
|
const nodeColumnCfgs = nodeController.tableCfg().columns;
|
|
2767
2960
|
const filterActive = filter && filter.length > 0;
|
|
2768
2961
|
const sliceIdActive = nodeSliceIds && nodeSliceIds.length > 0;
|
|
@@ -2892,20 +3085,39 @@ class Db {
|
|
|
2892
3085
|
const routeWithProperty = opts.skipCell ? null : Route.fromFlat(
|
|
2893
3086
|
baseRouteStr + `/${route.propertyKey}`
|
|
2894
3087
|
).toRouteWithProperty();
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
3088
|
+
let result3;
|
|
3089
|
+
if (nodeType === "trees") {
|
|
3090
|
+
const rljson3 = node;
|
|
3091
|
+
const tree3 = opts.skipTree ? {} : {
|
|
3092
|
+
[nodeTableKey]: {
|
|
3093
|
+
_data: [
|
|
3094
|
+
await nodeController.buildTreeFromTrees(nodeRows)
|
|
3095
|
+
],
|
|
3096
|
+
_type: "trees"
|
|
3097
|
+
}
|
|
3098
|
+
};
|
|
3099
|
+
const cell3 = opts.skipCell ? [] : await nodeController.buildCellsFromTree(nodeRows);
|
|
3100
|
+
result3 = {
|
|
3101
|
+
rljson: rljson3,
|
|
3102
|
+
tree: tree3,
|
|
3103
|
+
cell: cell3
|
|
3104
|
+
};
|
|
3105
|
+
} else {
|
|
3106
|
+
const tree3 = opts.skipTree ? {} : { [nodeTableKey]: node[nodeTableKey] };
|
|
3107
|
+
const cell3 = opts.skipCell ? [] : nodeRowsFiltered.map(
|
|
3108
|
+
(v, idx) => ({
|
|
3109
|
+
value: v[route.propertyKey] ?? null,
|
|
3110
|
+
row: v,
|
|
3111
|
+
route: routeWithProperty,
|
|
3112
|
+
path: [[nodeTableKey, "_data", idx, route.propertyKey]]
|
|
3113
|
+
})
|
|
3114
|
+
);
|
|
3115
|
+
result3 = {
|
|
3116
|
+
rljson: isolatedNode,
|
|
3117
|
+
tree: tree3,
|
|
3118
|
+
cell: cell3
|
|
3119
|
+
};
|
|
3120
|
+
}
|
|
2909
3121
|
this._cache.set(cacheHash, result3);
|
|
2910
3122
|
return result3;
|
|
2911
3123
|
}
|
|
@@ -3319,7 +3531,10 @@ class Db {
|
|
|
3319
3531
|
for (const [tableKey, controller] of Object.entries(controllers)) {
|
|
3320
3532
|
runFns[tableKey] = controller.insert.bind(controller);
|
|
3321
3533
|
}
|
|
3322
|
-
|
|
3534
|
+
const insertHistoryRow = await this._insert(route, tree, runFns, options);
|
|
3535
|
+
if (!options?.skipHistory)
|
|
3536
|
+
await this._writeInsertHistory(route.top.tableKey, insertHistoryRow[0]);
|
|
3537
|
+
return insertHistoryRow;
|
|
3323
3538
|
}
|
|
3324
3539
|
// ...........................................................................
|
|
3325
3540
|
/**
|
|
@@ -3345,7 +3560,7 @@ class Db {
|
|
|
3345
3560
|
const previousHash = nodeSegment[nodeTableKey + "Ref"] ?? null;
|
|
3346
3561
|
const previousTimeId = nodeSegment[nodeTableKey + "InsertHistoryRef"] ?? null;
|
|
3347
3562
|
const previous = previousHash ? await this.getTimeIdsForRef(nodeTableKey, previousHash) : previousTimeId ? [previousTimeId] : [];
|
|
3348
|
-
if (!nodeRoute.isRoot) {
|
|
3563
|
+
if (!nodeRoute.isRoot && nodeType != "trees") {
|
|
3349
3564
|
const childRoute = nodeRoute.deeper(1);
|
|
3350
3565
|
const childTableKey = childRoute.top.tableKey;
|
|
3351
3566
|
if (nodeType === "cakes") {
|
|
@@ -3516,10 +3731,31 @@ class Db {
|
|
|
3516
3731
|
);
|
|
3517
3732
|
}
|
|
3518
3733
|
}
|
|
3734
|
+
if (nodeType === "trees") {
|
|
3735
|
+
const treeObject = tree[nodeTableKey]._data[0];
|
|
3736
|
+
if (!treeObject) {
|
|
3737
|
+
throw new Error(
|
|
3738
|
+
`Db._insert: No tree data found for table "${nodeTableKey}" in route "${route.flat}".`
|
|
3739
|
+
);
|
|
3740
|
+
}
|
|
3741
|
+
const trees = treeFromObject(treeObject);
|
|
3742
|
+
const writePromises = trees.map(
|
|
3743
|
+
(tree2) => runFn("add", tree2, "db.insert")
|
|
3744
|
+
);
|
|
3745
|
+
const writeResults = await Promise.all(writePromises);
|
|
3746
|
+
const lastResult = writeResults[writeResults.length - 1];
|
|
3747
|
+
if (lastResult && lastResult.length > 0) {
|
|
3748
|
+
results.push(
|
|
3749
|
+
...lastResult.map((r) => ({
|
|
3750
|
+
...r,
|
|
3751
|
+
...{ previous },
|
|
3752
|
+
...{ route: route.flat }
|
|
3753
|
+
}))
|
|
3754
|
+
);
|
|
3755
|
+
}
|
|
3756
|
+
}
|
|
3519
3757
|
}
|
|
3520
3758
|
for (const result of results) {
|
|
3521
|
-
if (!options?.skipHistory)
|
|
3522
|
-
await this._writeInsertHistory(nodeTableKey, result);
|
|
3523
3759
|
if (!options?.skipNotification)
|
|
3524
3760
|
this.notify.notify(Route.fromFlat(result.route), result);
|
|
3525
3761
|
}
|
|
@@ -3599,21 +3835,6 @@ class Db {
|
|
|
3599
3835
|
});
|
|
3600
3836
|
}
|
|
3601
3837
|
// ...........................................................................
|
|
3602
|
-
/**
|
|
3603
|
-
* Add a head revision for a cake
|
|
3604
|
-
* @param cakeKey - The cake table key
|
|
3605
|
-
* @param cakeRef - The cake reference
|
|
3606
|
-
*/
|
|
3607
|
-
async addHeadRevision(cakeKey, cakeRef) {
|
|
3608
|
-
const cakeHeadKey = cakeKey + "Heads";
|
|
3609
|
-
const cakeHeadController = await this.getController(cakeHeadKey);
|
|
3610
|
-
return await cakeHeadController.insert("add", {
|
|
3611
|
-
cakeRef,
|
|
3612
|
-
timeId: timeId(),
|
|
3613
|
-
_hash: ""
|
|
3614
|
-
});
|
|
3615
|
-
}
|
|
3616
|
-
// ...........................................................................
|
|
3617
3838
|
/**
|
|
3618
3839
|
* Add a multiEdit
|
|
3619
3840
|
* @param cakeKey - The cake table key
|
|
@@ -4194,9 +4415,6 @@ class MultiEditProcessor {
|
|
|
4194
4415
|
}
|
|
4195
4416
|
const inserted = inserteds[0];
|
|
4196
4417
|
const writtenCakeRef = inserted[this._cakeKey + "Ref"];
|
|
4197
|
-
if (!options?.skipHeadUpdate) {
|
|
4198
|
-
await this._db.addHeadRevision(this._cakeKey, writtenCakeRef);
|
|
4199
|
-
}
|
|
4200
4418
|
if (!options?.skipSaveMultiEdit) {
|
|
4201
4419
|
await this._db.addMultiEdit(this._cakeKey, this._multiEdit);
|
|
4202
4420
|
}
|
|
@@ -5358,27 +5576,6 @@ const staticExample = () => {
|
|
|
5358
5576
|
}
|
|
5359
5577
|
]
|
|
5360
5578
|
});
|
|
5361
|
-
const carCakeHeadTableCfg = hip(
|
|
5362
|
-
createHeadsTableCfg("carCake")
|
|
5363
|
-
);
|
|
5364
|
-
const carCakeHeads = hip({
|
|
5365
|
-
_tableCfg: carCakeHeadTableCfg._hash,
|
|
5366
|
-
_type: "head",
|
|
5367
|
-
_data: [
|
|
5368
|
-
{
|
|
5369
|
-
timeId: "1764756756311:jkCG",
|
|
5370
|
-
cakeRef: carCake._data[0]._hash
|
|
5371
|
-
},
|
|
5372
|
-
{
|
|
5373
|
-
timeId: "1764756756312:1AGV",
|
|
5374
|
-
cakeRef: carCake._data[1]._hash
|
|
5375
|
-
},
|
|
5376
|
-
{
|
|
5377
|
-
timeId: "1764756756312:g8nh",
|
|
5378
|
-
cakeRef: carCake._data[2]._hash
|
|
5379
|
-
}
|
|
5380
|
-
]
|
|
5381
|
-
});
|
|
5382
5579
|
const seriesSliceIdTableCfg = hip(
|
|
5383
5580
|
createSliceIdsTableCfg("seriesSliceId")
|
|
5384
5581
|
);
|
|
@@ -5735,27 +5932,6 @@ const staticExample = () => {
|
|
|
5735
5932
|
}
|
|
5736
5933
|
]
|
|
5737
5934
|
});
|
|
5738
|
-
const seriesCakeHeadTableCfg = hip(
|
|
5739
|
-
createHeadsTableCfg("seriesCake")
|
|
5740
|
-
);
|
|
5741
|
-
const seriesCakeHeads = hip({
|
|
5742
|
-
_tableCfg: seriesCakeHeadTableCfg._hash,
|
|
5743
|
-
_type: "head",
|
|
5744
|
-
_data: [
|
|
5745
|
-
{
|
|
5746
|
-
timeId: "1764756756315:L14y",
|
|
5747
|
-
cakeRef: seriesCake._data[0]._hash
|
|
5748
|
-
},
|
|
5749
|
-
{
|
|
5750
|
-
timeId: "1764756756315:xCXT",
|
|
5751
|
-
cakeRef: seriesCake._data[1]._hash
|
|
5752
|
-
},
|
|
5753
|
-
{
|
|
5754
|
-
timeId: "1764756756315:fZwA",
|
|
5755
|
-
cakeRef: seriesCake._data[2]._hash
|
|
5756
|
-
}
|
|
5757
|
-
]
|
|
5758
|
-
});
|
|
5759
5935
|
const catalogSliceIdTableCfg = hip(
|
|
5760
5936
|
createSliceIdsTableCfg("catalogSliceId")
|
|
5761
5937
|
);
|
|
@@ -5857,19 +6033,6 @@ const staticExample = () => {
|
|
|
5857
6033
|
}
|
|
5858
6034
|
]
|
|
5859
6035
|
});
|
|
5860
|
-
const catalogCakeHeadTableCfg = hip(
|
|
5861
|
-
createHeadsTableCfg("catalogCake")
|
|
5862
|
-
);
|
|
5863
|
-
const catalogCakeHeads = hip({
|
|
5864
|
-
_tableCfg: catalogCakeHeadTableCfg._hash,
|
|
5865
|
-
_type: "head",
|
|
5866
|
-
_data: [
|
|
5867
|
-
{
|
|
5868
|
-
timeId: "1764756756317:5UTy",
|
|
5869
|
-
cakeRef: catalogCake._data[0]._hash
|
|
5870
|
-
}
|
|
5871
|
-
]
|
|
5872
|
-
});
|
|
5873
6036
|
const tableCfgs = {
|
|
5874
6037
|
_data: [
|
|
5875
6038
|
carSliceIdTableCfg,
|
|
@@ -5881,19 +6044,16 @@ const staticExample = () => {
|
|
|
5881
6044
|
carTechnicalLayerTableCfg,
|
|
5882
6045
|
carColorLayerTableCfg,
|
|
5883
6046
|
carCakeTableCfg,
|
|
5884
|
-
carCakeHeadTableCfg,
|
|
5885
6047
|
seriesSliceIdTableCfg,
|
|
5886
6048
|
seriesGeneralTableCfg,
|
|
5887
6049
|
seriesCarsTableCfg,
|
|
5888
6050
|
seriesGeneralLayerTableCfg,
|
|
5889
6051
|
seriesCarsLayerTableCfg,
|
|
5890
6052
|
seriesCakeTableCfg,
|
|
5891
|
-
seriesCakeHeadTableCfg,
|
|
5892
6053
|
catalogSliceIdTableCfg,
|
|
5893
6054
|
catalogSeriesTableCfg,
|
|
5894
6055
|
catalogSeriesLayerTableCfg,
|
|
5895
|
-
catalogCakeTableCfg
|
|
5896
|
-
catalogCakeHeadTableCfg
|
|
6056
|
+
catalogCakeTableCfg
|
|
5897
6057
|
]
|
|
5898
6058
|
};
|
|
5899
6059
|
const staticExample2 = {
|
|
@@ -5906,19 +6066,16 @@ const staticExample = () => {
|
|
|
5906
6066
|
carTechnicalLayer,
|
|
5907
6067
|
carColorLayer,
|
|
5908
6068
|
carCake,
|
|
5909
|
-
carCakeHeads,
|
|
5910
6069
|
seriesSliceId,
|
|
5911
6070
|
seriesGeneral,
|
|
5912
6071
|
seriesCars,
|
|
5913
6072
|
seriesGeneralLayer,
|
|
5914
6073
|
seriesCarsLayer,
|
|
5915
6074
|
seriesCake,
|
|
5916
|
-
seriesCakeHeads,
|
|
5917
6075
|
catalogSliceId,
|
|
5918
6076
|
catalogSeries,
|
|
5919
6077
|
catalogSeriesLayer,
|
|
5920
6078
|
catalogCake,
|
|
5921
|
-
catalogCakeHeads,
|
|
5922
6079
|
tableCfgs
|
|
5923
6080
|
};
|
|
5924
6081
|
return staticExample2;
|