@rljson/db 0.0.11 → 0.0.13
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/README.architecture.md +859 -1
- package/README.contributors.md +534 -20
- package/README.public.md +943 -4
- package/README.trouble.md +49 -0
- package/dist/README.architecture.md +859 -1
- package/dist/README.contributors.md +534 -20
- package/dist/README.public.md +943 -4
- package/dist/README.trouble.md +49 -0
- 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 +317 -110
- package/dist/db.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/package.json +16 -16
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,237 @@ 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 shouldExpandChildren = path !== void 0;
|
|
988
|
+
if (!shouldExpandChildren) {
|
|
989
|
+
return {
|
|
990
|
+
[this._tableKey]: {
|
|
991
|
+
_data: [tree],
|
|
992
|
+
_type: "trees"
|
|
993
|
+
}
|
|
994
|
+
};
|
|
995
|
+
}
|
|
996
|
+
const children = [];
|
|
997
|
+
for (const childRef of tree.children ?? []) {
|
|
998
|
+
const child = await this.get(
|
|
999
|
+
childRef,
|
|
1000
|
+
void 0,
|
|
1001
|
+
treeRoute.deeper().flat
|
|
1002
|
+
);
|
|
1003
|
+
const childData = child[this._tableKey]._data;
|
|
1004
|
+
children.push(...childData);
|
|
1005
|
+
}
|
|
1006
|
+
return {
|
|
1007
|
+
[this._tableKey]: {
|
|
1008
|
+
_data: [...children, tree],
|
|
1009
|
+
_type: "trees"
|
|
1010
|
+
}
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
async buildTreeFromTrees(trees) {
|
|
1014
|
+
if (trees.length === 0) {
|
|
1015
|
+
return {};
|
|
1016
|
+
}
|
|
1017
|
+
if (trees.length > 1e5) {
|
|
1018
|
+
throw new Error(
|
|
1019
|
+
`TreeController.buildTreeFromTrees: Tree size exceeds limit (${trees.length} > 100000 nodes). This may indicate a performance issue or data structure problem.`
|
|
1020
|
+
);
|
|
1021
|
+
}
|
|
1022
|
+
const treeMap = /* @__PURE__ */ new Map();
|
|
1023
|
+
for (const tree of trees) {
|
|
1024
|
+
treeMap.set(tree._hash, tree);
|
|
1025
|
+
}
|
|
1026
|
+
const memo = /* @__PURE__ */ new Map();
|
|
1027
|
+
let buildObjectCallCount = 0;
|
|
1028
|
+
const MAX_ITERATIONS = 1e6;
|
|
1029
|
+
const buildObject = (tree, depth = 0) => {
|
|
1030
|
+
buildObjectCallCount++;
|
|
1031
|
+
if (buildObjectCallCount > MAX_ITERATIONS) {
|
|
1032
|
+
throw new Error(
|
|
1033
|
+
`TreeController.buildTreeFromTrees: Maximum iterations (${MAX_ITERATIONS}) exceeded. This likely indicates a bug. Processed ${buildObjectCallCount} nodes from ${trees.length} total.`
|
|
1034
|
+
);
|
|
1035
|
+
}
|
|
1036
|
+
if (depth > 1e4) {
|
|
1037
|
+
throw new Error(
|
|
1038
|
+
`TreeController.buildTreeFromTrees: Tree depth exceeds limit (${depth} > 10000). This may indicate a circular reference or extremely deep structure.`
|
|
1039
|
+
);
|
|
1040
|
+
}
|
|
1041
|
+
const hash = tree._hash;
|
|
1042
|
+
if (memo.has(hash)) {
|
|
1043
|
+
return memo.get(hash);
|
|
1044
|
+
}
|
|
1045
|
+
if (!tree.isParent || !tree.children || tree.children.length === 0) {
|
|
1046
|
+
const result3 = tree;
|
|
1047
|
+
memo.set(hash, result3);
|
|
1048
|
+
return result3;
|
|
1049
|
+
}
|
|
1050
|
+
const result2 = {};
|
|
1051
|
+
for (const childHash of tree.children) {
|
|
1052
|
+
const childTree = treeMap.get(childHash);
|
|
1053
|
+
if (childTree && childTree.id) {
|
|
1054
|
+
result2[childTree.id] = buildObject(childTree, depth + 1);
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
memo.set(hash, result2);
|
|
1058
|
+
return result2;
|
|
1059
|
+
};
|
|
1060
|
+
const referencedHashes = /* @__PURE__ */ new Set();
|
|
1061
|
+
for (const tree of trees) {
|
|
1062
|
+
if (tree.children) {
|
|
1063
|
+
for (const childHash of tree.children) {
|
|
1064
|
+
referencedHashes.add(childHash);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
const rootTrees = trees.filter(
|
|
1069
|
+
(tree) => !referencedHashes.has(tree._hash)
|
|
1070
|
+
);
|
|
1071
|
+
if (rootTrees.length === 0) {
|
|
1072
|
+
return {};
|
|
1073
|
+
}
|
|
1074
|
+
if (rootTrees.length === 1) {
|
|
1075
|
+
const rootTree = rootTrees[0];
|
|
1076
|
+
if (rootTree.id) {
|
|
1077
|
+
return { [rootTree.id]: buildObject(rootTree) };
|
|
1078
|
+
}
|
|
1079
|
+
return buildObject(rootTree);
|
|
1080
|
+
}
|
|
1081
|
+
const result = {};
|
|
1082
|
+
for (const rootTree of rootTrees) {
|
|
1083
|
+
if (rootTree.id) {
|
|
1084
|
+
result[rootTree.id] = buildObject(rootTree);
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
return result;
|
|
1088
|
+
}
|
|
1089
|
+
async buildCellsFromTree(trees) {
|
|
1090
|
+
const cells = [];
|
|
1091
|
+
if (trees.length === 0) {
|
|
1092
|
+
return cells;
|
|
1093
|
+
}
|
|
1094
|
+
const treeMap = /* @__PURE__ */ new Map();
|
|
1095
|
+
const childToParentMap = /* @__PURE__ */ new Map();
|
|
1096
|
+
for (const tree of trees) {
|
|
1097
|
+
const treeHash = tree._hash;
|
|
1098
|
+
treeMap.set(treeHash, tree);
|
|
1099
|
+
if (tree.children) {
|
|
1100
|
+
for (const childHash of tree.children) {
|
|
1101
|
+
childToParentMap.set(childHash, treeHash);
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
const availableHashes = /* @__PURE__ */ new Set();
|
|
1106
|
+
for (const tree of trees) {
|
|
1107
|
+
availableHashes.add(tree._hash);
|
|
1108
|
+
}
|
|
1109
|
+
const leafNodes = trees.filter((tree) => {
|
|
1110
|
+
if (!tree.children || tree.children.length === 0) {
|
|
1111
|
+
return true;
|
|
1112
|
+
}
|
|
1113
|
+
const hasChildInTrees = tree.children.some(
|
|
1114
|
+
(childHash) => availableHashes.has(childHash)
|
|
1115
|
+
);
|
|
1116
|
+
return !hasChildInTrees;
|
|
1117
|
+
});
|
|
1118
|
+
for (const leaf of leafNodes) {
|
|
1119
|
+
const pathIds = [];
|
|
1120
|
+
let currentHash = leaf._hash;
|
|
1121
|
+
while (currentHash) {
|
|
1122
|
+
const current = treeMap.get(currentHash);
|
|
1123
|
+
if (!current) break;
|
|
1124
|
+
if (current.id) {
|
|
1125
|
+
pathIds.unshift(current.id);
|
|
1126
|
+
}
|
|
1127
|
+
const parentHash = childToParentMap.get(currentHash);
|
|
1128
|
+
if (!parentHash) break;
|
|
1129
|
+
currentHash = parentHash;
|
|
1130
|
+
}
|
|
1131
|
+
const routeStr = "/" + pathIds.join("/");
|
|
1132
|
+
const route = Route.fromFlat(routeStr);
|
|
1133
|
+
cells.push({
|
|
1134
|
+
route,
|
|
1135
|
+
value: leaf,
|
|
1136
|
+
row: leaf,
|
|
1137
|
+
path: [[this._tableKey, "_data", 0, ...pathIds]]
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
1140
|
+
return cells;
|
|
1141
|
+
}
|
|
1142
|
+
async getChildRefs(where, filter) {
|
|
1143
|
+
if (typeof where === "string") {
|
|
1144
|
+
return [];
|
|
1145
|
+
}
|
|
1146
|
+
const childRefs = [];
|
|
1147
|
+
const { [this._tableKey]: table } = await this.get(where, filter);
|
|
1148
|
+
const trees = table._data;
|
|
1149
|
+
for (const tree of trees) {
|
|
1150
|
+
for (const treeChildRef of tree.children ?? []) {
|
|
1151
|
+
childRefs.push({
|
|
1152
|
+
tableKey: this._tableKey,
|
|
1153
|
+
ref: treeChildRef
|
|
1154
|
+
});
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
return childRefs;
|
|
1158
|
+
}
|
|
1159
|
+
/* v8 ignore next -- @preserve */
|
|
1160
|
+
async filterRow() {
|
|
1161
|
+
return false;
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
936
1164
|
const createController = async (type, core, tableKey, refs) => {
|
|
937
1165
|
let ctrl;
|
|
938
1166
|
switch (type) {
|
|
@@ -943,7 +1171,7 @@ const createController = async (type, core, tableKey, refs) => {
|
|
|
943
1171
|
case "edits":
|
|
944
1172
|
case "editHistory":
|
|
945
1173
|
case "multiEdits":
|
|
946
|
-
case "
|
|
1174
|
+
case "insertHistory":
|
|
947
1175
|
ctrl = new ComponentController(core, tableKey, refs);
|
|
948
1176
|
break;
|
|
949
1177
|
case "cakes":
|
|
@@ -956,6 +1184,9 @@ const createController = async (type, core, tableKey, refs) => {
|
|
|
956
1184
|
refs
|
|
957
1185
|
);
|
|
958
1186
|
break;
|
|
1187
|
+
case "trees":
|
|
1188
|
+
ctrl = new TreeController(core, tableKey);
|
|
1189
|
+
break;
|
|
959
1190
|
default:
|
|
960
1191
|
throw new Error(`Controller for type ${type} is not implemented yet.`);
|
|
961
1192
|
}
|
|
@@ -1048,7 +1279,11 @@ class Core {
|
|
|
1048
1279
|
// ...........................................................................
|
|
1049
1280
|
/** Reads a specific row from a database table */
|
|
1050
1281
|
async readRow(table, rowHash) {
|
|
1051
|
-
|
|
1282
|
+
const result = await this._io.readRows({
|
|
1283
|
+
table,
|
|
1284
|
+
where: { _hash: rowHash }
|
|
1285
|
+
});
|
|
1286
|
+
return result;
|
|
1052
1287
|
}
|
|
1053
1288
|
// ...........................................................................
|
|
1054
1289
|
async readRows(table, where) {
|
|
@@ -1062,7 +1297,7 @@ const inject = (tree, path, value) => {
|
|
|
1062
1297
|
tree[segment] = value;
|
|
1063
1298
|
delete tree["_hash"];
|
|
1064
1299
|
} else {
|
|
1065
|
-
if (!tree[segment]) {
|
|
1300
|
+
if (!tree[segment] || typeof tree[segment] !== "object") {
|
|
1066
1301
|
tree[segment] = {};
|
|
1067
1302
|
}
|
|
1068
1303
|
tree = tree[segment];
|
|
@@ -2726,6 +2961,12 @@ class Db {
|
|
|
2726
2961
|
* @returns - An Rljson object matching the route and filters
|
|
2727
2962
|
*/
|
|
2728
2963
|
async _get(route, where, controllers, filter, sliceIds, routeAccumulator, options) {
|
|
2964
|
+
const depth = routeAccumulator ? routeAccumulator.flat.split("/").length : 1;
|
|
2965
|
+
if (depth > 100) {
|
|
2966
|
+
throw new Error(
|
|
2967
|
+
`Db._get: Maximum recursion depth (100) exceeded. This likely indicates a bug in route resolution or where clause construction. Current route: ${route.flat}, routeAccumulator: ${routeAccumulator?.flat}`
|
|
2968
|
+
);
|
|
2969
|
+
}
|
|
2729
2970
|
const opts = options ?? {};
|
|
2730
2971
|
const routeHasRefs = route.flat != route.flatWithoutRefs;
|
|
2731
2972
|
const hasFilter = filter !== void 0 && filter.length > 0;
|
|
@@ -2762,7 +3003,7 @@ class Db {
|
|
|
2762
3003
|
delete nodeWhere["_tableKey"];
|
|
2763
3004
|
const {
|
|
2764
3005
|
[nodeTableKey]: { _data: nodeRows, _type: nodeType, _hash: nodeHash }
|
|
2765
|
-
} = await nodeController.get(nodeWhere);
|
|
3006
|
+
} = await nodeController.get(nodeWhere, void 0, route.propertyKey);
|
|
2766
3007
|
const nodeColumnCfgs = nodeController.tableCfg().columns;
|
|
2767
3008
|
const filterActive = filter && filter.length > 0;
|
|
2768
3009
|
const sliceIdActive = nodeSliceIds && nodeSliceIds.length > 0;
|
|
@@ -2892,20 +3133,39 @@ class Db {
|
|
|
2892
3133
|
const routeWithProperty = opts.skipCell ? null : Route.fromFlat(
|
|
2893
3134
|
baseRouteStr + `/${route.propertyKey}`
|
|
2894
3135
|
).toRouteWithProperty();
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
3136
|
+
let result3;
|
|
3137
|
+
if (nodeType === "trees") {
|
|
3138
|
+
const rljson3 = node;
|
|
3139
|
+
const tree3 = opts.skipTree ? {} : {
|
|
3140
|
+
[nodeTableKey]: {
|
|
3141
|
+
_data: [
|
|
3142
|
+
await nodeController.buildTreeFromTrees(nodeRows)
|
|
3143
|
+
],
|
|
3144
|
+
_type: "trees"
|
|
3145
|
+
}
|
|
3146
|
+
};
|
|
3147
|
+
const cell3 = opts.skipCell ? [] : await nodeController.buildCellsFromTree(nodeRows);
|
|
3148
|
+
result3 = {
|
|
3149
|
+
rljson: rljson3,
|
|
3150
|
+
tree: tree3,
|
|
3151
|
+
cell: cell3
|
|
3152
|
+
};
|
|
3153
|
+
} else {
|
|
3154
|
+
const tree3 = opts.skipTree ? {} : { [nodeTableKey]: node[nodeTableKey] };
|
|
3155
|
+
const cell3 = opts.skipCell ? [] : nodeRowsFiltered.map(
|
|
3156
|
+
(v, idx) => ({
|
|
3157
|
+
value: v[route.propertyKey] ?? null,
|
|
3158
|
+
row: v,
|
|
3159
|
+
route: routeWithProperty,
|
|
3160
|
+
path: [[nodeTableKey, "_data", idx, route.propertyKey]]
|
|
3161
|
+
})
|
|
3162
|
+
);
|
|
3163
|
+
result3 = {
|
|
3164
|
+
rljson: isolatedNode,
|
|
3165
|
+
tree: tree3,
|
|
3166
|
+
cell: cell3
|
|
3167
|
+
};
|
|
3168
|
+
}
|
|
2909
3169
|
this._cache.set(cacheHash, result3);
|
|
2910
3170
|
return result3;
|
|
2911
3171
|
}
|
|
@@ -3319,7 +3579,10 @@ class Db {
|
|
|
3319
3579
|
for (const [tableKey, controller] of Object.entries(controllers)) {
|
|
3320
3580
|
runFns[tableKey] = controller.insert.bind(controller);
|
|
3321
3581
|
}
|
|
3322
|
-
|
|
3582
|
+
const insertHistoryRow = await this._insert(route, tree, runFns, options);
|
|
3583
|
+
if (!options?.skipHistory)
|
|
3584
|
+
await this._writeInsertHistory(route.top.tableKey, insertHistoryRow[0]);
|
|
3585
|
+
return insertHistoryRow;
|
|
3323
3586
|
}
|
|
3324
3587
|
// ...........................................................................
|
|
3325
3588
|
/**
|
|
@@ -3345,7 +3608,7 @@ class Db {
|
|
|
3345
3608
|
const previousHash = nodeSegment[nodeTableKey + "Ref"] ?? null;
|
|
3346
3609
|
const previousTimeId = nodeSegment[nodeTableKey + "InsertHistoryRef"] ?? null;
|
|
3347
3610
|
const previous = previousHash ? await this.getTimeIdsForRef(nodeTableKey, previousHash) : previousTimeId ? [previousTimeId] : [];
|
|
3348
|
-
if (!nodeRoute.isRoot) {
|
|
3611
|
+
if (!nodeRoute.isRoot && nodeType != "trees") {
|
|
3349
3612
|
const childRoute = nodeRoute.deeper(1);
|
|
3350
3613
|
const childTableKey = childRoute.top.tableKey;
|
|
3351
3614
|
if (nodeType === "cakes") {
|
|
@@ -3516,10 +3779,31 @@ class Db {
|
|
|
3516
3779
|
);
|
|
3517
3780
|
}
|
|
3518
3781
|
}
|
|
3782
|
+
if (nodeType === "trees") {
|
|
3783
|
+
const treeObject = tree[nodeTableKey]._data[0];
|
|
3784
|
+
if (!treeObject) {
|
|
3785
|
+
throw new Error(
|
|
3786
|
+
`Db._insert: No tree data found for table "${nodeTableKey}" in route "${route.flat}".`
|
|
3787
|
+
);
|
|
3788
|
+
}
|
|
3789
|
+
const trees = treeFromObject(treeObject, true);
|
|
3790
|
+
const writePromises = trees.map(
|
|
3791
|
+
(tree2) => runFn("add", tree2, "db.insert")
|
|
3792
|
+
);
|
|
3793
|
+
const writeResults = await Promise.all(writePromises);
|
|
3794
|
+
const lastResult = writeResults[writeResults.length - 1];
|
|
3795
|
+
if (lastResult && lastResult.length > 0) {
|
|
3796
|
+
results.push(
|
|
3797
|
+
...lastResult.map((r) => ({
|
|
3798
|
+
...r,
|
|
3799
|
+
...{ previous },
|
|
3800
|
+
...{ route: route.flat }
|
|
3801
|
+
}))
|
|
3802
|
+
);
|
|
3803
|
+
}
|
|
3804
|
+
}
|
|
3519
3805
|
}
|
|
3520
3806
|
for (const result of results) {
|
|
3521
|
-
if (!options?.skipHistory)
|
|
3522
|
-
await this._writeInsertHistory(nodeTableKey, result);
|
|
3523
3807
|
if (!options?.skipNotification)
|
|
3524
3808
|
this.notify.notify(Route.fromFlat(result.route), result);
|
|
3525
3809
|
}
|
|
@@ -3599,21 +3883,6 @@ class Db {
|
|
|
3599
3883
|
});
|
|
3600
3884
|
}
|
|
3601
3885
|
// ...........................................................................
|
|
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
3886
|
/**
|
|
3618
3887
|
* Add a multiEdit
|
|
3619
3888
|
* @param cakeKey - The cake table key
|
|
@@ -3641,9 +3910,7 @@ class Db {
|
|
|
3641
3910
|
const multiEditController = await this.getController(
|
|
3642
3911
|
cakeKey + "MultiEdits"
|
|
3643
3912
|
);
|
|
3644
|
-
const { [cakeKey + "MultiEdits"]: result } = await multiEditController.get(
|
|
3645
|
-
where
|
|
3646
|
-
);
|
|
3913
|
+
const { [cakeKey + "MultiEdits"]: result } = await multiEditController.get(where);
|
|
3647
3914
|
return result._data;
|
|
3648
3915
|
}
|
|
3649
3916
|
// ...........................................................................
|
|
@@ -4194,9 +4461,6 @@ class MultiEditProcessor {
|
|
|
4194
4461
|
}
|
|
4195
4462
|
const inserted = inserteds[0];
|
|
4196
4463
|
const writtenCakeRef = inserted[this._cakeKey + "Ref"];
|
|
4197
|
-
if (!options?.skipHeadUpdate) {
|
|
4198
|
-
await this._db.addHeadRevision(this._cakeKey, writtenCakeRef);
|
|
4199
|
-
}
|
|
4200
4464
|
if (!options?.skipSaveMultiEdit) {
|
|
4201
4465
|
await this._db.addMultiEdit(this._cakeKey, this._multiEdit);
|
|
4202
4466
|
}
|
|
@@ -5358,27 +5622,6 @@ const staticExample = () => {
|
|
|
5358
5622
|
}
|
|
5359
5623
|
]
|
|
5360
5624
|
});
|
|
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
5625
|
const seriesSliceIdTableCfg = hip(
|
|
5383
5626
|
createSliceIdsTableCfg("seriesSliceId")
|
|
5384
5627
|
);
|
|
@@ -5735,27 +5978,6 @@ const staticExample = () => {
|
|
|
5735
5978
|
}
|
|
5736
5979
|
]
|
|
5737
5980
|
});
|
|
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
5981
|
const catalogSliceIdTableCfg = hip(
|
|
5760
5982
|
createSliceIdsTableCfg("catalogSliceId")
|
|
5761
5983
|
);
|
|
@@ -5857,19 +6079,6 @@ const staticExample = () => {
|
|
|
5857
6079
|
}
|
|
5858
6080
|
]
|
|
5859
6081
|
});
|
|
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
6082
|
const tableCfgs = {
|
|
5874
6083
|
_data: [
|
|
5875
6084
|
carSliceIdTableCfg,
|
|
@@ -5881,19 +6090,16 @@ const staticExample = () => {
|
|
|
5881
6090
|
carTechnicalLayerTableCfg,
|
|
5882
6091
|
carColorLayerTableCfg,
|
|
5883
6092
|
carCakeTableCfg,
|
|
5884
|
-
carCakeHeadTableCfg,
|
|
5885
6093
|
seriesSliceIdTableCfg,
|
|
5886
6094
|
seriesGeneralTableCfg,
|
|
5887
6095
|
seriesCarsTableCfg,
|
|
5888
6096
|
seriesGeneralLayerTableCfg,
|
|
5889
6097
|
seriesCarsLayerTableCfg,
|
|
5890
6098
|
seriesCakeTableCfg,
|
|
5891
|
-
seriesCakeHeadTableCfg,
|
|
5892
6099
|
catalogSliceIdTableCfg,
|
|
5893
6100
|
catalogSeriesTableCfg,
|
|
5894
6101
|
catalogSeriesLayerTableCfg,
|
|
5895
|
-
catalogCakeTableCfg
|
|
5896
|
-
catalogCakeHeadTableCfg
|
|
6102
|
+
catalogCakeTableCfg
|
|
5897
6103
|
]
|
|
5898
6104
|
};
|
|
5899
6105
|
const staticExample2 = {
|
|
@@ -5906,19 +6112,16 @@ const staticExample = () => {
|
|
|
5906
6112
|
carTechnicalLayer,
|
|
5907
6113
|
carColorLayer,
|
|
5908
6114
|
carCake,
|
|
5909
|
-
carCakeHeads,
|
|
5910
6115
|
seriesSliceId,
|
|
5911
6116
|
seriesGeneral,
|
|
5912
6117
|
seriesCars,
|
|
5913
6118
|
seriesGeneralLayer,
|
|
5914
6119
|
seriesCarsLayer,
|
|
5915
6120
|
seriesCake,
|
|
5916
|
-
seriesCakeHeads,
|
|
5917
6121
|
catalogSliceId,
|
|
5918
6122
|
catalogSeries,
|
|
5919
6123
|
catalogSeriesLayer,
|
|
5920
6124
|
catalogCake,
|
|
5921
|
-
catalogCakeHeads,
|
|
5922
6125
|
tableCfgs
|
|
5923
6126
|
};
|
|
5924
6127
|
return staticExample2;
|
|
@@ -5934,6 +6137,10 @@ export {
|
|
|
5934
6137
|
exampleEditActionRowSort,
|
|
5935
6138
|
exampleEditActionSetValue,
|
|
5936
6139
|
exampleEditSetValueReferenced,
|
|
6140
|
+
inject,
|
|
6141
|
+
isolate,
|
|
6142
|
+
makeUnique,
|
|
6143
|
+
mergeTrees,
|
|
5937
6144
|
staticExample
|
|
5938
6145
|
};
|
|
5939
6146
|
//# sourceMappingURL=db.js.map
|