@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.
Files changed (36) hide show
  1. package/dist/connector/connector.d.ts +30 -0
  2. package/dist/controller/base-controller.d.ts +49 -0
  3. package/dist/controller/cake-controller.d.ts +30 -0
  4. package/dist/controller/component-controller.d.ts +68 -0
  5. package/dist/controller/controller.d.ts +48 -0
  6. package/dist/controller/layer-controller.d.ts +26 -0
  7. package/dist/controller/slice-id-controller.d.ts +22 -0
  8. package/dist/db.d.ts +63 -6
  9. package/dist/db.js +2301 -20
  10. package/dist/db.js.map +1 -0
  11. package/dist/edit/edit-action.d.ts +53 -0
  12. package/dist/edit/edit.d.ts +23 -0
  13. package/dist/edit/multi-edit-manager.d.ts +30 -0
  14. package/dist/edit/multi-edit-processor.d.ts +75 -0
  15. package/dist/example-static/example-static.d.ts +45 -0
  16. package/dist/index.d.ts +7 -1
  17. package/dist/join/filter/boolean-filter-processor.d.ts +13 -0
  18. package/dist/join/filter/boolean-filter.d.ts +15 -0
  19. package/dist/join/filter/column-filter-processor.d.ts +9 -0
  20. package/dist/join/filter/column-filter.d.ts +18 -0
  21. package/dist/join/filter/number-filter-processor.d.ts +16 -0
  22. package/dist/join/filter/number-filter.d.ts +7 -0
  23. package/dist/join/filter/row-filter-processor.d.ts +19 -0
  24. package/dist/join/filter/row-filter.d.ts +19 -0
  25. package/dist/join/filter/string-filter-processor.d.ts +15 -0
  26. package/dist/join/filter/string-filter.d.ts +8 -0
  27. package/dist/join/join.d.ts +141 -0
  28. package/dist/join/selection/column-selection.d.ts +48 -0
  29. package/dist/join/set-value/set-value.d.ts +11 -0
  30. package/dist/join/sort/row-sort.d.ts +18 -0
  31. package/dist/notify.d.ts +6 -2
  32. package/dist/tools/inject.d.ts +1 -0
  33. package/dist/tools/isolate.d.ts +1 -0
  34. package/dist/tools/make-unique.d.ts +4 -0
  35. package/dist/tools/merge-trees.d.ts +5 -0
  36. package/package.json +13 -13
package/dist/db.js CHANGED
@@ -1,9 +1,93 @@
1
+ import { timeId, createInsertHistoryTableCfg, Validate, BaseValidator, Route, isTimeId, getTimeIdTimestamp, createSliceIdsTableCfg, createLayerTableCfg, createCakeTableCfg, createHeadsTableCfg } from "@rljson/rljson";
1
2
  import { rmhsh, hsh, Hash, hip } from "@rljson/hash";
2
3
  import { equals, merge } from "@rljson/json";
3
- import { timeId, createInsertHistoryTableCfg, Validate, BaseValidator, Route, isTimeId } from "@rljson/rljson";
4
4
  import { IoMem } from "@rljson/io";
5
5
  import { traverse } from "object-traversal";
6
6
  import { compileExpression } from "filtrex";
7
+ class Connector {
8
+ constructor(_db, _route, _socket) {
9
+ this._db = _db;
10
+ this._route = _route;
11
+ this._socket = _socket;
12
+ this._origin = timeId();
13
+ this._init();
14
+ }
15
+ _origin;
16
+ _callbacks = [];
17
+ _isListening = false;
18
+ _sentRefs = /* @__PURE__ */ new Set();
19
+ _receivedRefs = /* @__PURE__ */ new Set();
20
+ send(ref) {
21
+ if (this._sentRefs.has(ref) || this._receivedRefs.has(ref)) return;
22
+ this._sentRefs.add(ref);
23
+ this.socket.emit(this.route.flat, {
24
+ o: this._origin,
25
+ r: ref
26
+ });
27
+ }
28
+ listen(callback) {
29
+ this._socket.on(this._route.flat, async (payload) => {
30
+ try {
31
+ await callback(payload.r);
32
+ } catch (error) {
33
+ console.error("Error in connector listener callback:", error);
34
+ }
35
+ });
36
+ }
37
+ _init() {
38
+ this._registerSocketObserver();
39
+ this._registerDbObserver();
40
+ this._isListening = true;
41
+ }
42
+ teardown() {
43
+ this._socket.removeAllListeners(this._route.flat);
44
+ this._db.unregisterAllObservers(this._route);
45
+ this._isListening = false;
46
+ }
47
+ _notifyCallbacks(ref) {
48
+ Promise.all(this._callbacks.map((cb) => cb(ref))).catch((err) => {
49
+ console.error(`Error notifying connector callbacks for ref ${ref}:`, err);
50
+ });
51
+ }
52
+ _registerSocketObserver() {
53
+ this.socket.on(this.route.flat, (p) => {
54
+ if (p.o === this._origin) {
55
+ return;
56
+ }
57
+ const ref = p.r;
58
+ if (this._receivedRefs.has(ref)) {
59
+ return;
60
+ }
61
+ this._receivedRefs.add(p.r);
62
+ this._notifyCallbacks(p.r);
63
+ });
64
+ }
65
+ _registerDbObserver() {
66
+ this._db.registerObserver(this._route, (ins) => {
67
+ return new Promise((resolve) => {
68
+ const ref = ins[this.route.root.tableKey + "Ref"];
69
+ if (this._sentRefs.has(ref)) {
70
+ resolve();
71
+ return;
72
+ }
73
+ this.send(ref);
74
+ resolve();
75
+ });
76
+ });
77
+ }
78
+ get socket() {
79
+ return this._socket;
80
+ }
81
+ get route() {
82
+ return this._route;
83
+ }
84
+ get origin() {
85
+ return this._origin;
86
+ }
87
+ get isListening() {
88
+ return this._isListening;
89
+ }
90
+ }
7
91
  class BaseController {
8
92
  constructor(_core, _tableKey) {
9
93
  this._core = _core;
@@ -217,7 +301,8 @@ class ComponentController extends BaseController {
217
301
  "components",
218
302
  "edits",
219
303
  "editHistory",
220
- "multiEdits"
304
+ "multiEdits",
305
+ "head"
221
306
  ];
222
307
  _resolvedColumns = null;
223
308
  _refTableKeyToColumnKeyMap = null;
@@ -888,6 +973,7 @@ const createController = async (type, core, tableKey, refs) => {
888
973
  case "edits":
889
974
  case "editHistory":
890
975
  case "multiEdits":
976
+ case "head":
891
977
  ctrl = new ComponentController(core, tableKey, refs);
892
978
  break;
893
979
  case "cakes":
@@ -950,8 +1036,8 @@ class Core {
950
1036
  * @returns a dump of a table.
951
1037
  * @throws when table name does not exist
952
1038
  */
953
- dumpTable(table) {
954
- return this._io.dumpTable({ table });
1039
+ async dumpTable(table) {
1040
+ return await this._io.dumpTable({ table });
955
1041
  }
956
1042
  // ...........................................................................
957
1043
  /**
@@ -980,8 +1066,7 @@ class Core {
980
1066
  }
981
1067
  // ...........................................................................
982
1068
  async contentType(table) {
983
- const t = await this._io.dumpTable({ table });
984
- const contentType = t[table]?._type;
1069
+ const contentType = await this._io.contentType({ table });
985
1070
  return contentType;
986
1071
  }
987
1072
  // ...........................................................................
@@ -1001,12 +1086,12 @@ class Core {
1001
1086
  }
1002
1087
  // ...........................................................................
1003
1088
  /** Reads a specific row from a database table */
1004
- readRow(table, rowHash) {
1005
- return this._io.readRows({ table, where: { _hash: rowHash } });
1089
+ async readRow(table, rowHash) {
1090
+ return await this._io.readRows({ table, where: { _hash: rowHash } });
1006
1091
  }
1007
1092
  // ...........................................................................
1008
- readRows(table, where) {
1009
- return this._io.readRows({ table, where });
1093
+ async readRows(table, where) {
1094
+ return await this._io.readRows({ table, where });
1010
1095
  }
1011
1096
  }
1012
1097
  const inject = (tree, path, value) => {
@@ -2556,6 +2641,14 @@ class Notify {
2556
2641
  }
2557
2642
  }
2558
2643
  // ...........................................................................
2644
+ /**
2645
+ * Unregisters all callbacks for a specific route.
2646
+ * @param route The route to unregister all callbacks from.
2647
+ */
2648
+ unregisterAll(route) {
2649
+ this._callbacks.delete(route.flat);
2650
+ }
2651
+ // ...........................................................................
2559
2652
  /**
2560
2653
  * Notifies all registered callbacks for a specific route with the provided edit protocol row.
2561
2654
  * @param route The route to notify callbacks for.
@@ -2564,9 +2657,12 @@ class Notify {
2564
2657
  notify(route, insertHistoryRow) {
2565
2658
  const callbacks = this._callbacks.get(route.flat);
2566
2659
  if (callbacks) {
2567
- for (const cb of callbacks) {
2568
- cb(insertHistoryRow);
2569
- }
2660
+ Promise.all(callbacks.map((cb) => cb(insertHistoryRow))).catch((err) => {
2661
+ console.error(
2662
+ `Error notifying callbacks for route ${route.flat}:`,
2663
+ err
2664
+ );
2665
+ });
2570
2666
  }
2571
2667
  }
2572
2668
  // ...........................................................................
@@ -3278,9 +3374,13 @@ class Db {
3278
3374
  );
3279
3375
  }
3280
3376
  }
3281
- if (["components", "edits", "multiEdits"].includes(
3282
- nodeType
3283
- )) {
3377
+ if ([
3378
+ "components",
3379
+ "edits",
3380
+ "multiEdits",
3381
+ "editHistory",
3382
+ "head"
3383
+ ].includes(nodeType)) {
3284
3384
  const runFn = runFns[nodeTableKey];
3285
3385
  const components = nodeTree._data;
3286
3386
  for (const component of components) {
@@ -3313,9 +3413,13 @@ class Db {
3313
3413
  }
3314
3414
  } else {
3315
3415
  const runFn = runFns[nodeTableKey];
3316
- if (["components", "edits", "multiEdits"].includes(
3317
- nodeType
3318
- )) {
3416
+ if ([
3417
+ "components",
3418
+ "edits",
3419
+ "multiEdits",
3420
+ "editHistory",
3421
+ "head"
3422
+ ].includes(nodeType)) {
3319
3423
  const components = rmhsh(
3320
3424
  tree[nodeTableKey]
3321
3425
  );
@@ -3387,6 +3491,13 @@ class Db {
3387
3491
  this.notify.unregister(route, callback);
3388
3492
  }
3389
3493
  // ...........................................................................
3494
+ /**
3495
+ * Unregisters all observers from all routes
3496
+ */
3497
+ unregisterAllObservers(route) {
3498
+ this.notify.unregisterAll(route);
3499
+ }
3500
+ // ...........................................................................
3390
3501
  /**
3391
3502
  * Get a controller for a specific table
3392
3503
  * @param tableKey - The key of the table to get the controller for
@@ -3435,6 +3546,116 @@ class Db {
3435
3546
  });
3436
3547
  }
3437
3548
  // ...........................................................................
3549
+ /**
3550
+ * Add a head revision for a cake
3551
+ * @param cakeKey - The cake table key
3552
+ * @param cakeRef - The cake reference
3553
+ */
3554
+ async addHeadRevision(cakeKey, cakeRef) {
3555
+ const cakeHeadKey = cakeKey + "Heads";
3556
+ const cakeHeadController = await this.getController(cakeHeadKey);
3557
+ return await cakeHeadController.insert("add", {
3558
+ cakeRef,
3559
+ timeId: timeId(),
3560
+ _hash: ""
3561
+ });
3562
+ }
3563
+ // ...........................................................................
3564
+ /**
3565
+ * Add a multiEdit
3566
+ * @param cakeKey - The cake table key
3567
+ * @param multiEdit - The multiEdit to add
3568
+ */
3569
+ async addMultiEdit(cakeKey, multiEdit) {
3570
+ return this.insert(
3571
+ Route.fromFlat(cakeKey + "MultiEdits"),
3572
+ {
3573
+ [cakeKey + "MultiEdits"]: {
3574
+ _data: [multiEdit],
3575
+ _type: "multiEdits"
3576
+ }
3577
+ },
3578
+ { skipHistory: true }
3579
+ );
3580
+ }
3581
+ // ...........................................................................
3582
+ /**
3583
+ * Get multiEdits
3584
+ * @param cakeKey - The cake table key
3585
+ * @param where - The where clause to filter multiEdits
3586
+ */
3587
+ async getMultiEdits(cakeKey, where) {
3588
+ const multiEditController = await this.getController(
3589
+ cakeKey + "MultiEdits"
3590
+ );
3591
+ const { [cakeKey + "MultiEdits"]: result } = await multiEditController.get(
3592
+ where
3593
+ );
3594
+ return result._data;
3595
+ }
3596
+ // ...........................................................................
3597
+ /**
3598
+ * Add an edit
3599
+ * @param cakeKey - The cake table key
3600
+ * @param edit - The edit to add
3601
+ */
3602
+ async addEdit(cakeKey, edit) {
3603
+ return this.insert(
3604
+ Route.fromFlat(cakeKey + "Edits"),
3605
+ {
3606
+ [cakeKey + "Edits"]: {
3607
+ _data: [edit],
3608
+ _type: "edits"
3609
+ }
3610
+ },
3611
+ { skipHistory: true }
3612
+ );
3613
+ }
3614
+ // ...........................................................................
3615
+ /**
3616
+ * Get edits
3617
+ * @param cakeKey - The cake table key
3618
+ * @param where - The where clause to filter edits
3619
+ */
3620
+ async getEdits(cakeKey, where) {
3621
+ const editController = await this.getController(cakeKey + "Edits");
3622
+ const { [cakeKey + "Edits"]: result } = await editController.get(where);
3623
+ return result._data;
3624
+ }
3625
+ // ...........................................................................
3626
+ /**
3627
+ * Add an edit history entry
3628
+ * @param cakeKey - The cake table key
3629
+ * @param editHistory - The edit history entry to add
3630
+ */
3631
+ async addEditHistory(cakeKey, editHistory) {
3632
+ return this.insert(
3633
+ Route.fromFlat(cakeKey + "EditHistory"),
3634
+ {
3635
+ [cakeKey + "EditHistory"]: {
3636
+ _data: [editHistory],
3637
+ _type: "editHistory"
3638
+ }
3639
+ },
3640
+ { skipHistory: true }
3641
+ );
3642
+ }
3643
+ // ...........................................................................
3644
+ /**
3645
+ * Get edit history entries
3646
+ * @param cakeKey - The cake table key
3647
+ * @param where - The where clause to filter edit history entries
3648
+ */
3649
+ async getEditHistories(cakeKey, where) {
3650
+ const editHistoryController = await this.getController(
3651
+ cakeKey + "EditHistory"
3652
+ );
3653
+ const { [cakeKey + "EditHistory"]: result } = await editHistoryController.get(where);
3654
+ return result._data.sort(
3655
+ (h1, h2) => getTimeIdTimestamp(h2.timeId) - getTimeIdTimestamp(h1.timeId)
3656
+ );
3657
+ }
3658
+ // ...........................................................................
3438
3659
  /**
3439
3660
  * Get the InsertHistory of a table
3440
3661
  * @param table - The table to get the InsertHistory for
@@ -3581,13 +3802,2073 @@ class Db {
3581
3802
  return result;
3582
3803
  }
3583
3804
  // ...........................................................................
3805
+ /**
3806
+ * Clone the Db instance with a new Io instance
3807
+ * @param io - The new Io instance
3808
+ * @returns A new Db instance with the same cache as the current instance
3809
+ */
3810
+ clone(io) {
3811
+ const newDb = new Db(io);
3812
+ newDb.setCache(new Map(this._cache));
3813
+ return newDb;
3814
+ }
3815
+ // ...........................................................................
3584
3816
  /**
3585
3817
  * Get the current cache of the Db instance
3586
3818
  */
3587
3819
  get cache() {
3588
3820
  return this._cache;
3589
3821
  }
3822
+ // ...........................................................................
3823
+ /**
3824
+ * Set the cache of the Db instance
3825
+ * @param cache - The new cache to set
3826
+ */
3827
+ setCache(cache) {
3828
+ this._cache = cache;
3829
+ }
3830
+ }
3831
+ const exampleEditActionColumnSelection = () => ({
3832
+ name: "Car Selection",
3833
+ type: "selection",
3834
+ data: {
3835
+ columns: ColumnSelection.exampleCarsColumnSelection().columns
3836
+ },
3837
+ _hash: ""
3838
+ });
3839
+ const exampleEditActionColumnSelectionOnlySomeColumns = () => ({
3840
+ name: "Car Selection - Some Columns",
3841
+ type: "selection",
3842
+ data: {
3843
+ columns: ColumnSelection.exampleCarsColumnSelectionOnlySomeColumns().columns
3844
+ },
3845
+ _hash: ""
3846
+ });
3847
+ const exampleEditActionRowFilter = () => ({
3848
+ name: "Electric Cars Filter",
3849
+ type: "filter",
3850
+ data: {
3851
+ columnFilters: [
3852
+ {
3853
+ type: "boolean",
3854
+ column: "carCake/carGeneralLayer/carGeneral/isElectric",
3855
+ operator: "equals",
3856
+ search: true,
3857
+ _hash: ""
3858
+ },
3859
+ {
3860
+ type: "number",
3861
+ column: "carCake/carTechnicalLayer/carTechnical/carDimensions/length",
3862
+ operator: "greaterThan",
3863
+ search: 4e3,
3864
+ _hash: ""
3865
+ }
3866
+ ],
3867
+ operator: "and",
3868
+ value: true,
3869
+ _hash: ""
3870
+ },
3871
+ _hash: ""
3872
+ });
3873
+ const exampleEditActionSetValue = () => ({
3874
+ name: "Set: Service Intervals to [15000, 30000, 45000, 60000]",
3875
+ type: "setValue",
3876
+ data: {
3877
+ route: "carCake/carGeneralLayer/carGeneral/serviceIntervals",
3878
+ value: [15e3, 3e4, 45e3, 6e4],
3879
+ _hash: ""
3880
+ },
3881
+ _hash: ""
3882
+ });
3883
+ const exampleEditSetValueReferenced = () => ({
3884
+ name: "Set: Length to 4200",
3885
+ type: "setValue",
3886
+ data: {
3887
+ route: "carCake/carTechnicalLayer/carTechnical/carDimensions/length",
3888
+ value: 4800,
3889
+ _hash: ""
3890
+ },
3891
+ _hash: ""
3892
+ });
3893
+ const exampleEditActionRowSort = () => ({
3894
+ name: "Sort By Brand Edit",
3895
+ type: "sort",
3896
+ data: {
3897
+ ["carCake/carGeneralLayer/carGeneral/brand"]: "asc"
3898
+ },
3899
+ _hash: ""
3900
+ });
3901
+ class RowSort {
3902
+ constructor(columnSorts) {
3903
+ this._columnSorts = this._initColumnSorts(columnSorts);
3904
+ }
3905
+ // ...........................................................................
3906
+ /**
3907
+ * Sorts the rows of a join according to the sort configuration.
3908
+ * @param join - The join to be sorted
3909
+ * @returns Returns the row indices in a sorted manner
3910
+ */
3911
+ applyTo(join) {
3912
+ if (join.rowCount === 0) {
3913
+ return join.rowIndices;
3914
+ }
3915
+ this._throwOnWrongRoutes(join);
3916
+ const routeHashes = join.columnSelection.routeHashes;
3917
+ const sortIndices = [];
3918
+ const sortOrders = [];
3919
+ let hasSorts = false;
3920
+ for (const item of this._columnSorts) {
3921
+ const index = routeHashes.indexOf(item.routeHash);
3922
+ sortIndices.push(index);
3923
+ sortOrders.push(item.order);
3924
+ hasSorts = true;
3925
+ }
3926
+ if (!hasSorts) {
3927
+ return join.rowIndices;
3928
+ }
3929
+ return this._sortRows(join, sortIndices, sortOrders);
3930
+ }
3931
+ // ...........................................................................
3932
+ /* v8 ignore next -- @preserve */
3933
+ get columnSorts() {
3934
+ const result = {};
3935
+ for (const sort of this._columnSorts) {
3936
+ result[sort.route] = sort.order;
3937
+ }
3938
+ return result;
3939
+ }
3940
+ // ######################
3941
+ // Private
3942
+ // ######################
3943
+ _columnSorts;
3944
+ // ...........................................................................
3945
+ _initColumnSorts(columnSorts) {
3946
+ const result = [];
3947
+ const columns = Object.keys(columnSorts);
3948
+ const columnSelection = ColumnSelection.fromRoutes(
3949
+ columns.map((c) => Route.fromFlat(c))
3950
+ );
3951
+ const routes = columnSelection.routes;
3952
+ const routeHashes = columnSelection.routeHashes;
3953
+ for (let i = 0; i < routes.length; i++) {
3954
+ const route = routes[i];
3955
+ const routeHash = routeHashes[i];
3956
+ result.push({
3957
+ route,
3958
+ routeHash,
3959
+ order: columnSorts[route]
3960
+ });
3961
+ }
3962
+ return result;
3963
+ }
3964
+ // ...........................................................................
3965
+ _sortRows(join, sortIndices, sortOrders) {
3966
+ const result = [...join.rowIndices];
3967
+ return result.sort((a, b) => {
3968
+ const rowA = join.row(a);
3969
+ const rowB = join.row(b);
3970
+ let i = 0;
3971
+ for (const index of sortIndices) {
3972
+ const sort = sortOrders[i++];
3973
+ const rowAInsertValues = rowA[index].inserts ? Array.isArray(rowA[index].inserts[0].cell[0].value) ? rowA[index].inserts[0].cell[0].value : [rowA[index].inserts[0].cell[0].value] : null;
3974
+ const rowAValue = rowA[index].value.cell[0].value ? Array.isArray(rowA[index].value?.cell[0].value) ? rowA[index].value.cell[0].value : [rowA[index].value.cell[0].value] : null;
3975
+ const rowBInsertValues = rowB[index].inserts ? Array.isArray(rowB[index].inserts[0].cell[0].value) ? rowB[index].inserts[0].cell[0].value : [rowB[index].inserts[0].cell[0].value] : null;
3976
+ const rowBValue = rowB[index].value.cell[0].value ? Array.isArray(rowB[index].value?.cell[0].value) ? rowB[index].value.cell[0].value : [rowB[index].value.cell[0].value] : null;
3977
+ const vA = rowAInsertValues && rowAInsertValues[0] ? rowAInsertValues[0] : rowAValue ? rowAValue[0] : null;
3978
+ const vB = rowBInsertValues && rowBInsertValues[0] ? rowBInsertValues[0] : rowBValue ? rowBValue[0] : null;
3979
+ if (vA === vB) {
3980
+ continue;
3981
+ }
3982
+ if (sort === "asc") {
3983
+ return vA < vB ? -1 : 1;
3984
+ } else {
3985
+ return vA < vB ? 1 : -1;
3986
+ }
3987
+ }
3988
+ return 0;
3989
+ });
3990
+ }
3991
+ // ...........................................................................
3992
+ _throwOnWrongRoutes(join) {
3993
+ const availableRoutes = join.columnSelection.routes;
3994
+ for (const item of Object.values(this._columnSorts)) {
3995
+ const route = item.route;
3996
+ if (availableRoutes.includes(route) === false) {
3997
+ throw new Error(
3998
+ `RowFilterProcessor: Error while applying sort to join: There is a sort entry for route "${route}", but the join does not have a column with this route.
3999
+
4000
+ Available routes:
4001
+ ${availableRoutes.map((a) => `- ${a}`).join("\n")}`
4002
+ );
4003
+ }
4004
+ }
4005
+ }
4006
+ }
4007
+ class MultiEditProcessor {
4008
+ constructor(_db, _cakeKey, _cakeRef) {
4009
+ this._db = _db;
4010
+ this._cakeKey = _cakeKey;
4011
+ this._cakeRef = _cakeRef;
4012
+ }
4013
+ _multiEdit = null;
4014
+ _edits = [];
4015
+ _join = null;
4016
+ //...........................................................................
4017
+ /**
4018
+ * Create MultiEditProcessor from EditHistory
4019
+ * @param db - Db instance
4020
+ * @param cakeKey - Cake key
4021
+ * @param editHistory - EditHistory
4022
+ * @returns MultiEditProcessor
4023
+ */
4024
+ static async fromEditHistory(db, cakeKey, editHistory) {
4025
+ if (!editHistory || !editHistory.multiEditRef) {
4026
+ throw new Error("MultiEditProcessor: Invalid EditHistory provided.");
4027
+ }
4028
+ const cakeRef = editHistory.dataRef;
4029
+ const multiEdits = await db.getMultiEdits(
4030
+ cakeKey,
4031
+ editHistory.multiEditRef
4032
+ );
4033
+ if (!multiEdits || multiEdits.length === 0) {
4034
+ throw new Error(
4035
+ `MultiEditProcessor: MultiEdit not found for ref ${editHistory.multiEditRef}`
4036
+ );
4037
+ }
4038
+ if (multiEdits.length > 1) {
4039
+ throw new Error(
4040
+ `MultiEditProcessor: Multiple MultiEdits found for ref ${editHistory.multiEditRef}`
4041
+ );
4042
+ }
4043
+ const multiEdit = multiEdits[0];
4044
+ return MultiEditProcessor.fromMultiEdit(db, cakeKey, cakeRef, multiEdit);
4045
+ }
4046
+ //...........................................................................
4047
+ /**
4048
+ * Create MultiEditProcessor from MultiEdit
4049
+ * @param db - Db instance
4050
+ * @param cakeKey - Cake key
4051
+ * @param cakeRef - Cake ref
4052
+ * @param multiEdit - MultiEdit
4053
+ * @returns MultiEditProcessor
4054
+ */
4055
+ static async fromMultiEdit(db, cakeKey, cakeRef, multiEdit) {
4056
+ const processor = new MultiEditProcessor(db, cakeKey, cakeRef);
4057
+ await processor._resolve(multiEdit);
4058
+ await processor._processAll();
4059
+ return processor;
4060
+ }
4061
+ get join() {
4062
+ if (!this._join) {
4063
+ throw new Error("MultiEditProcessor: Join not processed yet.");
4064
+ }
4065
+ return this._join;
4066
+ }
4067
+ get multiEdit() {
4068
+ if (!this._multiEdit) {
4069
+ throw new Error("MultiEditProcessor: MultiEdit not resolved yet.");
4070
+ }
4071
+ return this._multiEdit;
4072
+ }
4073
+ get cakeRef() {
4074
+ return this._cakeRef;
4075
+ }
4076
+ //...........................................................................
4077
+ /**
4078
+ * Apply an Edit to the MultiEditProcessor
4079
+ * @param edit - Edit to apply
4080
+ * @returns MultiEditProcessor
4081
+ */
4082
+ async edit(edit) {
4083
+ this._edits.push(edit);
4084
+ this._join = await this._process(edit);
4085
+ this._multiEdit = hip({
4086
+ _hash: "",
4087
+ edit: edit._hash,
4088
+ previous: this.multiEdit ? this.multiEdit._hash : null
4089
+ });
4090
+ return this;
4091
+ }
4092
+ async applyEditHistory(editHistory) {
4093
+ if (!editHistory || !editHistory.multiEditRef) {
4094
+ throw new Error("MultiEditProcessor: Invalid EditHistory provided.");
4095
+ }
4096
+ const multiEdits = await this._db.getMultiEdits(
4097
+ this._cakeKey,
4098
+ editHistory.multiEditRef
4099
+ );
4100
+ if (!multiEdits || multiEdits.length === 0) {
4101
+ throw new Error(
4102
+ `MultiEditProcessor: MultiEdit not found for ref ${editHistory.multiEditRef}`
4103
+ );
4104
+ }
4105
+ if (multiEdits.length > 1) {
4106
+ throw new Error(
4107
+ `MultiEditProcessor: Multiple MultiEdits found for ref ${editHistory.multiEditRef}`
4108
+ );
4109
+ }
4110
+ const multiEdit = multiEdits[0];
4111
+ await this._resolve(multiEdit);
4112
+ await this._processAll();
4113
+ return this;
4114
+ }
4115
+ //...........................................................................
4116
+ /**
4117
+ * Publish the MultiEditProcessor. Inserts the resulting Join as new data,
4118
+ * updates the head revision, and saves the resulting MultiEdit.
4119
+ * @param options - Publish options
4120
+ * @returns MultiEditProcessor
4121
+ */
4122
+ async publish(options) {
4123
+ const inserts = this.join.insert();
4124
+ if (inserts.length === 0) {
4125
+ throw new Error("MultiEditProcessor: No inserts to publish.");
4126
+ }
4127
+ if (inserts.length > 1) {
4128
+ throw new Error(
4129
+ "MultiEditProcessor: Multiple inserts not supported yet."
4130
+ );
4131
+ }
4132
+ const insert = inserts[0];
4133
+ const inserteds = await this._db.insert(insert.route, insert.tree);
4134
+ if (inserteds.length === 0) {
4135
+ throw new Error("MultiEditProcessor: No rows inserted.");
4136
+ }
4137
+ if (inserteds.length > 1) {
4138
+ throw new Error(
4139
+ "MultiEditProcessor: Multiple inserted rows not supported yet."
4140
+ );
4141
+ }
4142
+ const inserted = inserteds[0];
4143
+ const writtenCakeRef = inserted[this._cakeKey + "Ref"];
4144
+ if (!options?.skipHeadUpdate) {
4145
+ await this._db.addHeadRevision(this._cakeKey, writtenCakeRef);
4146
+ }
4147
+ if (!options?.skipSaveMultiEdit) {
4148
+ await this._db.addMultiEdit(this._cakeKey, this._multiEdit);
4149
+ }
4150
+ return new MultiEditProcessor(this._db, this._cakeKey, writtenCakeRef);
4151
+ }
4152
+ //...........................................................................
4153
+ /**
4154
+ * Clone the MultiEditProcessor
4155
+ * @returns Cloned MultiEditProcessor
4156
+ */
4157
+ clone() {
4158
+ const clone = new MultiEditProcessor(
4159
+ this._db,
4160
+ this._cakeKey,
4161
+ this._cakeRef
4162
+ );
4163
+ clone._multiEdit = this._multiEdit;
4164
+ clone._edits = [...this._edits];
4165
+ clone._join = this._join;
4166
+ return clone;
4167
+ }
4168
+ //...........................................................................
4169
+ /**
4170
+ * Resolve MultiEdit chain recursively
4171
+ * @param multiEdit - MultiEdit to resolve
4172
+ * @returns Promise<void>
4173
+ */
4174
+ async _resolve(multiEdit) {
4175
+ this._multiEdit = multiEdit;
4176
+ const edits = await this._db.getEdits(this._cakeKey, multiEdit.edit);
4177
+ if (edits.length === 0) {
4178
+ throw new Error(
4179
+ `MultiEditProcessor: Edit not found for ref ${multiEdit.edit}`
4180
+ );
4181
+ }
4182
+ if (edits.length > 1) {
4183
+ throw new Error(
4184
+ `MultiEditProcessor: Multiple Edits found for ref ${multiEdit.edit}`
4185
+ );
4186
+ }
4187
+ const edit = edits[0];
4188
+ this._edits.push(edit);
4189
+ if (multiEdit.previous) {
4190
+ const previousMultiEdits = await this._db.getMultiEdits(
4191
+ this._cakeKey,
4192
+ multiEdit.previous
4193
+ );
4194
+ const previousMultiEdit = previousMultiEdits[0];
4195
+ return this._resolve(previousMultiEdit);
4196
+ }
4197
+ }
4198
+ //...........................................................................
4199
+ /**
4200
+ * Process all Edits in the MultiEditProcessor
4201
+ * @returns Resulting Join
4202
+ */
4203
+ async _processAll() {
4204
+ for (let i = this._edits.length - 1; i >= 0; i--) {
4205
+ const edit = this._edits[i];
4206
+ this._join = await this._process(edit);
4207
+ }
4208
+ return this._join;
4209
+ }
4210
+ //...........................................................................
4211
+ /**
4212
+ * Process a single Edit and update the Join
4213
+ * @param edit - Edit to process
4214
+ * @returns Resulting Join
4215
+ */
4216
+ async _process(edit) {
4217
+ const action = edit.action;
4218
+ if (!this._join) {
4219
+ switch (action.type) {
4220
+ case "selection":
4221
+ const editColInfos = edit.action.data.columns;
4222
+ const editColSelection = new ColumnSelection(editColInfos);
4223
+ this._join = await this._db.join(
4224
+ editColSelection,
4225
+ this._cakeKey,
4226
+ this._cakeRef
4227
+ );
4228
+ break;
4229
+ case "setValue":
4230
+ const editSetValue = edit.action.data;
4231
+ const editSetValueKey = Route.fromFlat(editSetValue.route).segment().tableKey;
4232
+ const editSetValueColumnInfo = {
4233
+ key: editSetValueKey,
4234
+ route: editSetValue.route,
4235
+ alias: editSetValueKey,
4236
+ titleLong: "",
4237
+ titleShort: "",
4238
+ type: "jsonValue",
4239
+ _hash: ""
4240
+ };
4241
+ const editSetValueColSelection = new ColumnSelection([
4242
+ editSetValueColumnInfo
4243
+ ]);
4244
+ this._join = (await this._db.join(
4245
+ editSetValueColSelection,
4246
+ this._cakeKey,
4247
+ this._cakeRef
4248
+ )).setValue(editSetValue);
4249
+ break;
4250
+ case "sort":
4251
+ const editRowSort = rmhsh(edit).action.data;
4252
+ const editRowSortColumnInfos = [];
4253
+ for (const routeStr of Object.keys(editRowSort)) {
4254
+ const route = Route.fromFlat(routeStr);
4255
+ const tableKey = route.segment().tableKey;
4256
+ const columnInfo = {
4257
+ key: tableKey,
4258
+ route: routeStr,
4259
+ alias: tableKey,
4260
+ titleLong: "",
4261
+ titleShort: "",
4262
+ type: "jsonValue",
4263
+ _hash: ""
4264
+ };
4265
+ editRowSortColumnInfos.push(columnInfo);
4266
+ }
4267
+ const editRowSortColSelection = new ColumnSelection(
4268
+ editRowSortColumnInfos
4269
+ );
4270
+ this._join = (await this._db.join(
4271
+ editRowSortColSelection,
4272
+ this._cakeKey,
4273
+ this._cakeRef
4274
+ )).sort(new RowSort(editRowSort));
4275
+ break;
4276
+ case "filter":
4277
+ const editRowFilter = edit.action.data;
4278
+ const editRowFilterColumnInfos = [];
4279
+ for (const colFilter of editRowFilter.columnFilters) {
4280
+ const route = Route.fromFlat(colFilter.column);
4281
+ const tableKey = route.segment().tableKey;
4282
+ const columnInfo = {
4283
+ key: tableKey,
4284
+ route: colFilter.column,
4285
+ alias: tableKey,
4286
+ titleLong: "",
4287
+ titleShort: "",
4288
+ type: "jsonValue",
4289
+ _hash: ""
4290
+ };
4291
+ editRowFilterColumnInfos.push(columnInfo);
4292
+ }
4293
+ const editRowFilterColSelection = new ColumnSelection(
4294
+ editRowFilterColumnInfos
4295
+ );
4296
+ this._join = (await this._db.join(
4297
+ editRowFilterColSelection,
4298
+ this._cakeKey,
4299
+ this._cakeRef
4300
+ )).filter(editRowFilter);
4301
+ break;
4302
+ }
4303
+ } else {
4304
+ switch (action.type) {
4305
+ case "selection":
4306
+ const editColInfos = edit.action.data.columns;
4307
+ const editColSelection = new ColumnSelection(editColInfos);
4308
+ this._join = this._join.select(editColSelection);
4309
+ break;
4310
+ case "setValue":
4311
+ const editSetValue = rmhsh(
4312
+ edit.action.data
4313
+ );
4314
+ this._join = this._join.setValue(editSetValue);
4315
+ break;
4316
+ case "sort":
4317
+ const editRowSort = rmhsh(
4318
+ edit.action.data
4319
+ );
4320
+ this._join = this._join.sort(new RowSort(editRowSort));
4321
+ break;
4322
+ case "filter":
4323
+ const editRowFilter = rmhsh(
4324
+ edit.action.data
4325
+ );
4326
+ this._join = this._join.filter(editRowFilter);
4327
+ break;
4328
+ }
4329
+ }
4330
+ return this._join;
4331
+ }
3590
4332
  }
4333
+ class MultiEditManager {
4334
+ constructor(_cakeKey, _db) {
4335
+ this._cakeKey = _cakeKey;
4336
+ this._db = _db;
4337
+ }
4338
+ _head = null;
4339
+ _headListener = [];
4340
+ _processors = /* @__PURE__ */ new Map();
4341
+ _isListening = false;
4342
+ init() {
4343
+ const editHistoryKey = `${this._cakeKey}EditHistory`;
4344
+ this._db.registerObserver(
4345
+ Route.fromFlat(editHistoryKey),
4346
+ (ins) => {
4347
+ const editHistoryRef = ins[editHistoryKey + "Ref"];
4348
+ return this.editHistoryRef(editHistoryRef);
4349
+ }
4350
+ );
4351
+ this._isListening = true;
4352
+ }
4353
+ tearDown() {
4354
+ const editHistoryKey = `${this._cakeKey}EditHistory`;
4355
+ this._db.unregisterAllObservers(Route.fromFlat(editHistoryKey));
4356
+ this._isListening = false;
4357
+ }
4358
+ async edit(edit, cakeRef) {
4359
+ if (!this.head && !cakeRef) {
4360
+ throw new Error(
4361
+ "No head MultiEditProcessor available. Provide a cakeRef."
4362
+ );
4363
+ }
4364
+ if (this.head && cakeRef) {
4365
+ throw new Error(
4366
+ "Head MultiEditProcessor already exists. Do not provide a cakeRef."
4367
+ );
4368
+ }
4369
+ await this._persistEdit(edit);
4370
+ let multiEditProc;
4371
+ if (!this.head) {
4372
+ const multiEdit = {
4373
+ _hash: "",
4374
+ edit: hsh(edit)._hash,
4375
+ previous: null
4376
+ };
4377
+ await this._persistMultiEdit(multiEdit);
4378
+ multiEditProc = await MultiEditProcessor.fromMultiEdit(
4379
+ this._db,
4380
+ this._cakeKey,
4381
+ cakeRef,
4382
+ multiEdit
4383
+ );
4384
+ } else {
4385
+ multiEditProc = await this.head.processor.edit(edit);
4386
+ }
4387
+ const multiEditRef = await this._persistMultiEdit(multiEditProc.multiEdit);
4388
+ const editHistoryRef = await this._persistEditHistory({
4389
+ _hash: "",
4390
+ dataRef: multiEditProc.cakeRef,
4391
+ multiEditRef: await multiEditRef,
4392
+ timeId: timeId(),
4393
+ previous: !!this.head && this.head.editHistoryRef ? [this.head.editHistoryRef] : null
4394
+ });
4395
+ this._processors.set(editHistoryRef, multiEditProc);
4396
+ this._head = {
4397
+ editHistoryRef,
4398
+ processor: multiEditProc
4399
+ };
4400
+ await this._notifyHeadListener(editHistoryRef);
4401
+ }
4402
+ async publish() {
4403
+ if (!this.head) {
4404
+ throw new Error("No head MultiEditProcessor available.");
4405
+ }
4406
+ return await this.head.processor.publish();
4407
+ }
4408
+ listenToHeadChanges(callback) {
4409
+ this._headListener.push(callback);
4410
+ }
4411
+ _notifyHeadListener(editHistoryRef) {
4412
+ return Promise.all(
4413
+ this._headListener.map((cb) => cb(editHistoryRef))
4414
+ ).catch((err) => {
4415
+ console.error(
4416
+ `Error notifying head observers for editHistoryRef ${editHistoryRef}:`,
4417
+ err
4418
+ );
4419
+ });
4420
+ }
4421
+ async editHistoryRef(editHistoryRef) {
4422
+ const editHistories = await this._db.getEditHistories(
4423
+ this._cakeKey,
4424
+ editHistoryRef
4425
+ );
4426
+ if (editHistories.length === 0) {
4427
+ throw new Error(`EditHistory with ref ${editHistoryRef} not found.`);
4428
+ }
4429
+ if (editHistories.length > 1) {
4430
+ throw new Error(
4431
+ `Multiple EditHistories with ref ${editHistoryRef} found.`
4432
+ );
4433
+ }
4434
+ const editHistory = editHistories[0];
4435
+ if (this._processors.has(editHistoryRef)) {
4436
+ const processor2 = this._processors.get(editHistoryRef);
4437
+ this._head = {
4438
+ editHistoryRef,
4439
+ processor: processor2
4440
+ };
4441
+ await this._notifyHeadListener(editHistoryRef);
4442
+ return processor2;
4443
+ }
4444
+ if (editHistory.previous && editHistory.previous.length > 0) {
4445
+ if (editHistory.previous.length > 1) {
4446
+ throw new Error(
4447
+ `EditHistory with ref ${editHistoryRef} has multiple previous refs. Not supported.`
4448
+ );
4449
+ }
4450
+ const previousEditHistoryRef = editHistory.previous[0];
4451
+ const previousProcessor = await this.editHistoryRef(
4452
+ previousEditHistoryRef
4453
+ );
4454
+ const previousProcessorCloned = previousProcessor.clone();
4455
+ const processor2 = await previousProcessorCloned.applyEditHistory(
4456
+ editHistory
4457
+ );
4458
+ this._processors.set(editHistoryRef, processor2);
4459
+ this._head = {
4460
+ editHistoryRef,
4461
+ processor: processor2
4462
+ };
4463
+ await this._notifyHeadListener(editHistoryRef);
4464
+ return processor2;
4465
+ }
4466
+ const processor = await MultiEditProcessor.fromEditHistory(
4467
+ this._db,
4468
+ this._cakeKey,
4469
+ editHistory
4470
+ );
4471
+ this._processors.set(editHistoryRef, processor);
4472
+ this._head = {
4473
+ editHistoryRef,
4474
+ processor
4475
+ };
4476
+ await this._notifyHeadListener(editHistoryRef);
4477
+ return processor;
4478
+ }
4479
+ async _persistEdit(edit) {
4480
+ const { [this._cakeKey + "EditsRef"]: editRef } = (await this._db.addEdit(this._cakeKey, edit))[0];
4481
+ if (!editRef) {
4482
+ throw new Error("MultiEditManager: Failed to create EditRef.");
4483
+ }
4484
+ return editRef;
4485
+ }
4486
+ async _persistMultiEdit(multiEdit) {
4487
+ const { [this._cakeKey + "MultiEditsRef"]: multiEditRef } = (await this._db.addMultiEdit(this._cakeKey, multiEdit))[0];
4488
+ if (!multiEditRef) {
4489
+ throw new Error("MultiEditManager: Failed to create MultiEditRef.");
4490
+ }
4491
+ return multiEditRef;
4492
+ }
4493
+ async _persistEditHistory(editHistory) {
4494
+ const { [this._cakeKey + "EditHistoryRef"]: editHistoryRef } = (await this._db.addEditHistory(this._cakeKey, editHistory))[0];
4495
+ if (!editHistoryRef) {
4496
+ throw new Error("MultiEditManager: Failed to create EditHistoryRef.");
4497
+ }
4498
+ return editHistoryRef;
4499
+ }
4500
+ get processors() {
4501
+ return this._processors;
4502
+ }
4503
+ get head() {
4504
+ return this._head;
4505
+ }
4506
+ get join() {
4507
+ if (!this.head) {
4508
+ throw new Error("No head MultiEditProcessor available.");
4509
+ }
4510
+ return this.head.processor.join;
4511
+ }
4512
+ get isListening() {
4513
+ return this._isListening;
4514
+ }
4515
+ }
4516
+ const chainLayers = (layers) => {
4517
+ const chainedLayers = [];
4518
+ for (let i = 0; i < layers.length; i++) {
4519
+ const newLayer = { ...rmhsh(layers[i]) };
4520
+ if (i == 0) {
4521
+ chainedLayers.push(hsh(newLayer));
4522
+ continue;
4523
+ }
4524
+ if (chainedLayers[i - 1]._hash) {
4525
+ newLayer.base = chainedLayers[i - 1]._hash;
4526
+ }
4527
+ chainedLayers.push(hsh(newLayer));
4528
+ }
4529
+ return chainedLayers;
4530
+ };
4531
+ const chainSliceIds = (sliceIds) => {
4532
+ const chainedSliceIds = [];
4533
+ for (let i = 0; i < sliceIds.length; i++) {
4534
+ const newSliceIds = { ...rmhsh(sliceIds[i]) };
4535
+ if (i == 0) {
4536
+ chainedSliceIds.push(hsh(newSliceIds));
4537
+ continue;
4538
+ }
4539
+ if (chainedSliceIds[i - 1]._hash) {
4540
+ newSliceIds.base = chainedSliceIds[i - 1]._hash;
4541
+ }
4542
+ chainedSliceIds.push(hsh(newSliceIds));
4543
+ }
4544
+ return chainedSliceIds;
4545
+ };
4546
+ const staticExample = () => {
4547
+ const carSliceIdTableCfg = hip(
4548
+ createSliceIdsTableCfg("carSliceId")
4549
+ );
4550
+ const carSliceIdData = [
4551
+ {
4552
+ add: ["VIN1", "VIN2", "VIN3", "VIN4", "VIN5", "VIN6", "VIN7", "VIN8"],
4553
+ _hash: ""
4554
+ },
4555
+ {
4556
+ add: ["VIN9", "VIN10"],
4557
+ _hash: ""
4558
+ },
4559
+ {
4560
+ add: ["VIN11", "VIN12"],
4561
+ _hash: ""
4562
+ }
4563
+ ].map((sliceIds) => hsh(sliceIds));
4564
+ const carSliceId = hip({
4565
+ _tableCfg: carSliceIdTableCfg._hash,
4566
+ _type: "sliceIds",
4567
+ _data: chainSliceIds(carSliceIdData),
4568
+ _hash: ""
4569
+ });
4570
+ const carGeneralTableCfg = hip({
4571
+ key: "carGeneral",
4572
+ type: "components",
4573
+ columns: [
4574
+ { key: "_hash", type: "string", titleLong: "Hash", titleShort: "Hash" },
4575
+ { key: "brand", type: "string", titleLong: "Brand", titleShort: "Brand" },
4576
+ { key: "type", type: "string", titleLong: "Type", titleShort: "Type" },
4577
+ { key: "doors", type: "number", titleLong: "Doors", titleShort: "Doors" },
4578
+ {
4579
+ key: "energyConsumption",
4580
+ type: "number",
4581
+ titleLong: "Energy Consumption",
4582
+ titleShort: "Energy"
4583
+ },
4584
+ {
4585
+ key: "units",
4586
+ type: "json",
4587
+ titleLong: "Energy Unit",
4588
+ titleShort: "Unit"
4589
+ },
4590
+ {
4591
+ key: "serviceIntervals",
4592
+ type: "jsonArray",
4593
+ titleLong: "Service Intervals",
4594
+ titleShort: "Intervals"
4595
+ },
4596
+ {
4597
+ key: "isElectric",
4598
+ type: "boolean",
4599
+ titleLong: "Is Electric",
4600
+ titleShort: "Electric"
4601
+ },
4602
+ {
4603
+ key: "meta",
4604
+ type: "jsonValue",
4605
+ titleLong: "Meta Information",
4606
+ titleShort: "Meta"
4607
+ }
4608
+ ],
4609
+ isHead: false,
4610
+ isRoot: false,
4611
+ isShared: true
4612
+ });
4613
+ const carGeneral = hip({
4614
+ _tableCfg: carGeneralTableCfg._hash,
4615
+ _type: "components",
4616
+ _data: [
4617
+ {
4618
+ brand: "Volkswagen",
4619
+ type: "Polo",
4620
+ doors: 5,
4621
+ energyConsumption: 7.4,
4622
+ units: {
4623
+ energy: "l/100km",
4624
+ _hash: ""
4625
+ },
4626
+ serviceIntervals: [15e3, 3e4, 45e3],
4627
+ isElectric: false,
4628
+ meta: {
4629
+ pressText: "A popular compact car.",
4630
+ _hash: ""
4631
+ },
4632
+ _hash: ""
4633
+ },
4634
+ {
4635
+ brand: "Volkswagen",
4636
+ type: "Golf",
4637
+ doors: 3,
4638
+ energyConsumption: 6.2,
4639
+ units: {
4640
+ energy: "l/100km",
4641
+ _hash: ""
4642
+ },
4643
+ serviceIntervals: [15e3, 3e4, 45e3],
4644
+ isElectric: false,
4645
+ meta: {
4646
+ pressText: "A well-known hatchback.",
4647
+ _hash: ""
4648
+ },
4649
+ _hash: ""
4650
+ },
4651
+ {
4652
+ brand: "Audi",
4653
+ type: "Q4 E-tron",
4654
+ doors: 5,
4655
+ energyConsumption: 18,
4656
+ units: {
4657
+ energy: "kWh/100km",
4658
+ _hash: ""
4659
+ },
4660
+ serviceIntervals: [2e4, 4e4, 6e4],
4661
+ isElectric: true,
4662
+ meta: [
4663
+ {
4664
+ pressText: "A stylish electric SUV.",
4665
+ _hash: ""
4666
+ },
4667
+ {
4668
+ pressText: "Combines performance with sustainability.",
4669
+ _hash: ""
4670
+ }
4671
+ ],
4672
+ _hash: ""
4673
+ },
4674
+ {
4675
+ brand: "Audi",
4676
+ type: "Q6 E-tron",
4677
+ doors: 5,
4678
+ energyConsumption: 16,
4679
+ units: {
4680
+ energy: "kWh/100km",
4681
+ _hash: ""
4682
+ },
4683
+ serviceIntervals: [2e4, 4e4, 6e4],
4684
+ isElectric: true,
4685
+ meta: [
4686
+ {
4687
+ pressText: "A premium electric SUV with advanced features.",
4688
+ _hash: ""
4689
+ },
4690
+ {
4691
+ pressText: "Offers a blend of luxury and eco-friendliness.",
4692
+ _hash: ""
4693
+ }
4694
+ ],
4695
+ _hash: ""
4696
+ },
4697
+ {
4698
+ brand: "BMW",
4699
+ type: "i4",
4700
+ doors: 5,
4701
+ energyConsumption: 19.5,
4702
+ units: {
4703
+ energy: "kWh/100km",
4704
+ _hash: ""
4705
+ },
4706
+ serviceIntervals: [2e4, 4e4, 6e4],
4707
+ isElectric: true,
4708
+ meta: [
4709
+ {
4710
+ pressText: "A sporty electric sedan.",
4711
+ _hash: ""
4712
+ },
4713
+ {
4714
+ pressText: "Delivers dynamic performance with zero emissions.",
4715
+ _hash: ""
4716
+ }
4717
+ ],
4718
+ _hash: ""
4719
+ },
4720
+ {
4721
+ brand: "BMW",
4722
+ type: "3 Series",
4723
+ doors: 4,
4724
+ energyConsumption: 5.8,
4725
+ units: {
4726
+ energy: "l/100km",
4727
+ _hash: ""
4728
+ },
4729
+ serviceIntervals: [15e3, 3e4, 45e3],
4730
+ isElectric: false,
4731
+ meta: {
4732
+ pressText: "A classic executive car.",
4733
+ _hash: ""
4734
+ },
4735
+ _hash: ""
4736
+ },
4737
+ {
4738
+ brand: "Tesla",
4739
+ type: "Model 3",
4740
+ doors: 4,
4741
+ energyConsumption: 15,
4742
+ units: {
4743
+ energy: "kWh/100km",
4744
+ _hash: ""
4745
+ },
4746
+ serviceIntervals: [25e3, 5e4, 75e3],
4747
+ isElectric: true,
4748
+ meta: {
4749
+ pressText: "A revolutionary electric sedan.",
4750
+ _hash: ""
4751
+ },
4752
+ _hash: ""
4753
+ },
4754
+ {
4755
+ brand: "Tesla",
4756
+ type: "Model Y",
4757
+ doors: 5,
4758
+ energyConsumption: 16.5,
4759
+ units: {
4760
+ energy: "kWh/100km",
4761
+ _hash: ""
4762
+ },
4763
+ serviceIntervals: [25e3, 5e4, 75e3],
4764
+ isElectric: true,
4765
+ meta: {
4766
+ pressText: "A versatile electric SUV.",
4767
+ _hash: ""
4768
+ },
4769
+ _hash: ""
4770
+ },
4771
+ {
4772
+ brand: "Ford",
4773
+ type: "Mustang Mach-E",
4774
+ doors: 5,
4775
+ energyConsumption: 17,
4776
+ units: {
4777
+ energy: "kWh/100km",
4778
+ _hash: ""
4779
+ },
4780
+ serviceIntervals: [2e4, 4e4, 6e4],
4781
+ isElectric: true,
4782
+ meta: {
4783
+ pressText: "An electric SUV with Mustang heritage.",
4784
+ _hash: ""
4785
+ },
4786
+ _hash: ""
4787
+ },
4788
+ {
4789
+ brand: "Chevrolet",
4790
+ type: "Bolt EV",
4791
+ doors: 5,
4792
+ energyConsumption: 14,
4793
+ units: {
4794
+ energy: "kWh/100km",
4795
+ _hash: ""
4796
+ },
4797
+ serviceIntervals: [2e4, 4e4, 6e4],
4798
+ isElectric: true,
4799
+ meta: {
4800
+ pressText: "An affordable electric hatchback.",
4801
+ _hash: ""
4802
+ },
4803
+ _hash: ""
4804
+ },
4805
+ {
4806
+ brand: "Nissan",
4807
+ type: "Leaf",
4808
+ doors: 5,
4809
+ energyConsumption: 15.5,
4810
+ units: {
4811
+ energy: "kWh/100km",
4812
+ _hash: ""
4813
+ },
4814
+ serviceIntervals: [2e4, 4e4, 6e4],
4815
+ isElectric: true,
4816
+ meta: {
4817
+ pressText: "A pioneering electric vehicle.",
4818
+ _hash: ""
4819
+ },
4820
+ _hash: ""
4821
+ },
4822
+ {
4823
+ brand: "Hyundai",
4824
+ type: "Kona Electric",
4825
+ doors: 5,
4826
+ energyConsumption: 14.5,
4827
+ units: {
4828
+ energy: "kWh/100km",
4829
+ _hash: ""
4830
+ },
4831
+ serviceIntervals: [2e4, 4e4, 6e4],
4832
+ isElectric: true,
4833
+ meta: {
4834
+ pressText: "A compact electric SUV.",
4835
+ _hash: ""
4836
+ },
4837
+ _hash: ""
4838
+ }
4839
+ ],
4840
+ _hash: ""
4841
+ });
4842
+ const carDimensionsTableCfg = hip({
4843
+ key: "carDimensions",
4844
+ type: "components",
4845
+ columns: [
4846
+ { key: "_hash", type: "string" },
4847
+ { key: "height", type: "number" },
4848
+ { key: "width", type: "number" },
4849
+ { key: "length", type: "number" }
4850
+ ],
4851
+ isHead: false,
4852
+ isRoot: false,
4853
+ isShared: true
4854
+ });
4855
+ const carDimensions = hip({
4856
+ _tableCfg: carDimensionsTableCfg._hash,
4857
+ _type: "components",
4858
+ _data: [
4859
+ {
4860
+ height: 1400,
4861
+ width: 1800,
4862
+ length: 4e3,
4863
+ _hash: ""
4864
+ },
4865
+ {
4866
+ height: 1450,
4867
+ width: 1850,
4868
+ length: 4100,
4869
+ _hash: ""
4870
+ },
4871
+ {
4872
+ height: 1600,
4873
+ width: 1900,
4874
+ length: 4500,
4875
+ _hash: ""
4876
+ },
4877
+ {
4878
+ height: 1650,
4879
+ width: 1950,
4880
+ length: 4700,
4881
+ _hash: ""
4882
+ },
4883
+ {
4884
+ height: 1500,
4885
+ width: 1820,
4886
+ length: 4200,
4887
+ _hash: ""
4888
+ },
4889
+ {
4890
+ height: 1550,
4891
+ width: 1880,
4892
+ length: 4300,
4893
+ _hash: ""
4894
+ },
4895
+ {
4896
+ height: 1450,
4897
+ width: 1830,
4898
+ length: 4150,
4899
+ _hash: ""
4900
+ },
4901
+ {
4902
+ height: 1700,
4903
+ width: 2e3,
4904
+ length: 4800,
4905
+ _hash: ""
4906
+ },
4907
+ {
4908
+ height: 1350,
4909
+ width: 1750,
4910
+ length: 3900,
4911
+ _hash: ""
4912
+ },
4913
+ {
4914
+ height: 1750,
4915
+ width: 2050,
4916
+ length: 4900,
4917
+ _hash: ""
4918
+ },
4919
+ {
4920
+ height: 1600,
4921
+ width: 1920,
4922
+ length: 4600,
4923
+ _hash: ""
4924
+ }
4925
+ ],
4926
+ _hash: ""
4927
+ });
4928
+ const carTechnicalTableCfg = hip({
4929
+ key: "carTechnical",
4930
+ type: "components",
4931
+ columns: [
4932
+ { key: "_hash", type: "string" },
4933
+ { key: "engine", type: "string" },
4934
+ { key: "transmission", type: "string" },
4935
+ { key: "gears", type: "number" },
4936
+ {
4937
+ key: "dimensions",
4938
+ type: "jsonValue",
4939
+ ref: {
4940
+ tableKey: "carDimensions",
4941
+ type: "components"
4942
+ }
4943
+ },
4944
+ { key: "repairedByWorkshop", type: "string" }
4945
+ ],
4946
+ isHead: false,
4947
+ isRoot: false,
4948
+ isShared: true
4949
+ });
4950
+ const carTechnical = hip({
4951
+ _tableCfg: carTechnicalTableCfg._hash,
4952
+ _type: "components",
4953
+ _data: [
4954
+ {
4955
+ engine: "Diesel",
4956
+ transmission: "Manual",
4957
+ gears: 6,
4958
+ dimensions: carDimensions._data[0]._hash,
4959
+ _hash: ""
4960
+ },
4961
+ {
4962
+ engine: "Petrol",
4963
+ transmission: "Automatic",
4964
+ gears: 7,
4965
+ dimensions: carDimensions._data[1]._hash,
4966
+ repairedByWorkshop: "Workshop A",
4967
+ _hash: ""
4968
+ },
4969
+ {
4970
+ engine: "Electric",
4971
+ transmission: "Single-Speed",
4972
+ gears: 1,
4973
+ dimensions: [
4974
+ carDimensions._data[1]._hash,
4975
+ carDimensions._data[2]._hash
4976
+ ],
4977
+ _hash: ""
4978
+ },
4979
+ {
4980
+ engine: "Electric",
4981
+ transmission: "Single-Speed",
4982
+ gears: 1,
4983
+ dimensions: carDimensions._data[3]._hash,
4984
+ repairedByWorkshop: "Workshop B",
4985
+ _hash: ""
4986
+ },
4987
+ {
4988
+ engine: "Electric",
4989
+ transmission: "Single-Speed",
4990
+ gears: 1,
4991
+ dimensions: carDimensions._data[4]._hash,
4992
+ _hash: ""
4993
+ },
4994
+ {
4995
+ engine: "Petrol",
4996
+ transmission: "Manual",
4997
+ gears: 6,
4998
+ dimensions: carDimensions._data[5]._hash,
4999
+ repairedByWorkshop: "Workshop A",
5000
+ _hash: ""
5001
+ },
5002
+ {
5003
+ engine: "Electric",
5004
+ transmission: "Single-Speed",
5005
+ gears: 1,
5006
+ dimensions: carDimensions._data[6]._hash,
5007
+ _hash: ""
5008
+ },
5009
+ {
5010
+ engine: "Electric",
5011
+ transmission: "Single-Speed",
5012
+ gears: 1,
5013
+ dimensions: carDimensions._data[7]._hash,
5014
+ repairedByWorkshop: "Workshop C",
5015
+ _hash: ""
5016
+ },
5017
+ {
5018
+ engine: "Electric",
5019
+ transmission: "Single-Speed",
5020
+ gears: 1,
5021
+ dimensions: carDimensions._data[8]._hash,
5022
+ _hash: ""
5023
+ },
5024
+ {
5025
+ engine: "Electric",
5026
+ transmission: "Single-Speed",
5027
+ gears: 1,
5028
+ dimensions: carDimensions._data[9]._hash,
5029
+ repairedByWorkshop: "Workshop B",
5030
+ _hash: ""
5031
+ },
5032
+ {
5033
+ engine: "Electric",
5034
+ transmission: "Single-Speed",
5035
+ gears: 1,
5036
+ dimensions: carDimensions._data[10]._hash,
5037
+ _hash: ""
5038
+ }
5039
+ ],
5040
+ _hash: ""
5041
+ });
5042
+ const carColorTableCfg = hip({
5043
+ key: "carColor",
5044
+ type: "components",
5045
+ columns: [
5046
+ { key: "_hash", type: "string" },
5047
+ { key: "sides", type: "string" },
5048
+ { key: "roof", type: "string" },
5049
+ { key: "highlights", type: "string" }
5050
+ ],
5051
+ isHead: false,
5052
+ isRoot: false,
5053
+ isShared: true
5054
+ });
5055
+ const carColor = hip({
5056
+ _tableCfg: carColorTableCfg._hash,
5057
+ _type: "components",
5058
+ _data: [
5059
+ {
5060
+ sides: "green",
5061
+ roof: "white",
5062
+ highlights: "chrome",
5063
+ _hash: ""
5064
+ },
5065
+ {
5066
+ sides: "blue",
5067
+ roof: "black",
5068
+ highlights: "chrome",
5069
+ _hash: ""
5070
+ },
5071
+ {
5072
+ sides: "red",
5073
+ roof: "red",
5074
+ highlights: "black",
5075
+ _hash: ""
5076
+ },
5077
+ {
5078
+ sides: "silver",
5079
+ roof: "silver",
5080
+ highlights: "chrome",
5081
+ _hash: ""
5082
+ },
5083
+ {
5084
+ sides: "black",
5085
+ roof: "black",
5086
+ highlights: "black",
5087
+ _hash: ""
5088
+ },
5089
+ {
5090
+ sides: "white",
5091
+ roof: "white",
5092
+ highlights: "chrome",
5093
+ _hash: ""
5094
+ },
5095
+ {
5096
+ sides: "grey",
5097
+ roof: "black",
5098
+ highlights: "chrome",
5099
+ _hash: ""
5100
+ },
5101
+ {
5102
+ sides: "red",
5103
+ roof: "white",
5104
+ highlights: "black",
5105
+ _hash: ""
5106
+ }
5107
+ ],
5108
+ _hash: ""
5109
+ });
5110
+ const carGeneralLayerTableCfg = hip(
5111
+ createLayerTableCfg("carGeneralLayer")
5112
+ );
5113
+ const carGeneralLayerData = [
5114
+ {
5115
+ add: {
5116
+ VIN1: carGeneral._data[0]._hash,
5117
+ VIN2: carGeneral._data[1]._hash,
5118
+ VIN3: carGeneral._data[2]._hash,
5119
+ VIN4: carGeneral._data[3]._hash,
5120
+ VIN5: carGeneral._data[4]._hash,
5121
+ VIN6: carGeneral._data[5]._hash,
5122
+ VIN7: carGeneral._data[6]._hash,
5123
+ VIN8: carGeneral._data[7]._hash,
5124
+ _hash: ""
5125
+ },
5126
+ sliceIdsTable: "carSliceId",
5127
+ sliceIdsTableRow: carSliceId._data[0]._hash,
5128
+ componentsTable: "carGeneral",
5129
+ _hash: ""
5130
+ },
5131
+ {
5132
+ add: {
5133
+ VIN9: carGeneral._data[8]._hash,
5134
+ VIN10: carGeneral._data[9]._hash,
5135
+ _hash: ""
5136
+ },
5137
+ sliceIdsTable: "carSliceId",
5138
+ sliceIdsTableRow: carSliceId._data[1]._hash,
5139
+ componentsTable: "carGeneral",
5140
+ _hash: ""
5141
+ },
5142
+ {
5143
+ add: {
5144
+ VIN11: carGeneral._data[10]._hash,
5145
+ VIN12: carGeneral._data[11]._hash,
5146
+ _hash: ""
5147
+ },
5148
+ sliceIdsTable: "carSliceId",
5149
+ sliceIdsTableRow: carSliceId._data[2]._hash,
5150
+ componentsTable: "carGeneral",
5151
+ _hash: ""
5152
+ }
5153
+ ].map((layer) => hsh(layer));
5154
+ const carGeneralLayer = hip({
5155
+ _tableCfg: carGeneralLayerTableCfg._hash,
5156
+ _type: "layers",
5157
+ _data: chainLayers(carGeneralLayerData),
5158
+ _hash: ""
5159
+ });
5160
+ const carTechnicalLayerTableCfg = hip(
5161
+ createLayerTableCfg("carTechnicalLayer")
5162
+ );
5163
+ const carTechnicalLayerData = [
5164
+ {
5165
+ add: {
5166
+ VIN1: carTechnical._data[0]._hash,
5167
+ VIN2: carTechnical._data[1]._hash,
5168
+ VIN3: carTechnical._data[2]._hash,
5169
+ VIN4: carTechnical._data[2]._hash,
5170
+ VIN5: carTechnical._data[4]._hash,
5171
+ VIN6: carTechnical._data[5]._hash,
5172
+ VIN7: carTechnical._data[6]._hash,
5173
+ VIN8: carTechnical._data[2]._hash,
5174
+ _hash: ""
5175
+ },
5176
+ sliceIdsTable: "carSliceId",
5177
+ sliceIdsTableRow: carSliceId._data[0]._hash,
5178
+ componentsTable: "carTechnical",
5179
+ _hash: ""
5180
+ },
5181
+ {
5182
+ add: {
5183
+ VIN9: carTechnical._data[7]._hash,
5184
+ VIN10: carTechnical._data[8]._hash,
5185
+ _hash: ""
5186
+ },
5187
+ sliceIdsTable: "carSliceId",
5188
+ sliceIdsTableRow: carSliceId._data[1]._hash,
5189
+ componentsTable: "carTechnical",
5190
+ _hash: ""
5191
+ },
5192
+ {
5193
+ add: {
5194
+ VIN11: carTechnical._data[9]._hash,
5195
+ VIN12: carTechnical._data[10]._hash,
5196
+ _hash: ""
5197
+ },
5198
+ sliceIdsTable: "carSliceId",
5199
+ sliceIdsTableRow: carSliceId._data[2]._hash,
5200
+ componentsTable: "carTechnical",
5201
+ _hash: ""
5202
+ }
5203
+ ].map((layer) => hsh(layer));
5204
+ const carTechnicalLayer = hip({
5205
+ _tableCfg: carTechnicalLayerTableCfg._hash,
5206
+ _type: "layers",
5207
+ _data: chainLayers(carTechnicalLayerData),
5208
+ _hash: ""
5209
+ });
5210
+ const carColorLayerTableCfg = hip(
5211
+ createLayerTableCfg("carColorLayer")
5212
+ );
5213
+ const carColorLayerData = [
5214
+ {
5215
+ add: {
5216
+ VIN1: carColor._data[0]._hash,
5217
+ VIN2: carColor._data[1]._hash,
5218
+ VIN3: carColor._data[2]._hash,
5219
+ VIN4: carColor._data[3]._hash,
5220
+ VIN5: carColor._data[4]._hash,
5221
+ VIN6: carColor._data[5]._hash,
5222
+ VIN7: carColor._data[6]._hash,
5223
+ VIN8: carColor._data[7]._hash,
5224
+ _hash: ""
5225
+ },
5226
+ sliceIdsTable: "carSliceId",
5227
+ sliceIdsTableRow: carSliceId._data[0]._hash,
5228
+ componentsTable: "carColor",
5229
+ _hash: ""
5230
+ },
5231
+ {
5232
+ add: {
5233
+ VIN9: carColor._data[3]._hash,
5234
+ VIN10: carColor._data[3]._hash,
5235
+ _hash: ""
5236
+ },
5237
+ sliceIdsTable: "carSliceId",
5238
+ sliceIdsTableRow: carSliceId._data[1]._hash,
5239
+ componentsTable: "carColor",
5240
+ _hash: ""
5241
+ },
5242
+ {
5243
+ add: {
5244
+ VIN11: carColor._data[7]._hash,
5245
+ VIN12: carColor._data[4]._hash,
5246
+ _hash: ""
5247
+ },
5248
+ sliceIdsTable: "carSliceId",
5249
+ sliceIdsTableRow: carSliceId._data[2]._hash,
5250
+ componentsTable: "carColor",
5251
+ _hash: ""
5252
+ }
5253
+ ].map((layer) => hsh(layer));
5254
+ const carColorLayer = hip({
5255
+ _tableCfg: carColorLayerTableCfg._hash,
5256
+ _type: "layers",
5257
+ _data: chainLayers(carColorLayerData),
5258
+ _hash: ""
5259
+ });
5260
+ const carCakeTableCfg = hip(
5261
+ createCakeTableCfg("carCake")
5262
+ );
5263
+ const carCake = hip({
5264
+ _tableCfg: carCakeTableCfg._hash,
5265
+ _type: "cakes",
5266
+ _data: [
5267
+ {
5268
+ sliceIdsTable: "carSliceId",
5269
+ sliceIdsRow: carSliceId._data[0]._hash,
5270
+ layers: {
5271
+ carGeneralLayer: carGeneralLayer._data[0]._hash,
5272
+ carTechnicalLayer: carTechnicalLayer._data[0]._hash,
5273
+ carColorLayer: carColorLayer._data[0]._hash
5274
+ }
5275
+ },
5276
+ {
5277
+ sliceIdsTable: "carSliceId",
5278
+ sliceIdsRow: carSliceId._data[1]._hash,
5279
+ layers: {
5280
+ carGeneralLayer: carGeneralLayer._data[1]._hash,
5281
+ carTechnicalLayer: carTechnicalLayer._data[1]._hash,
5282
+ carColorLayer: carColorLayer._data[1]._hash
5283
+ }
5284
+ },
5285
+ {
5286
+ sliceIdsTable: "carSliceId",
5287
+ sliceIdsRow: carSliceId._data[2]._hash,
5288
+ layers: {
5289
+ carGeneralLayer: carGeneralLayer._data[2]._hash,
5290
+ carTechnicalLayer: carTechnicalLayer._data[2]._hash,
5291
+ carColorLayer: carColorLayer._data[2]._hash
5292
+ }
5293
+ }
5294
+ ]
5295
+ });
5296
+ const carCakeHeadTableCfg = hip(
5297
+ createHeadsTableCfg("carCake")
5298
+ );
5299
+ const carCakeHeads = hip({
5300
+ _tableCfg: carCakeHeadTableCfg._hash,
5301
+ _type: "head",
5302
+ _data: [
5303
+ {
5304
+ timeId: "1764756756311:jkCG",
5305
+ cakeRef: carCake._data[0]._hash
5306
+ },
5307
+ {
5308
+ timeId: "1764756756312:1AGV",
5309
+ cakeRef: carCake._data[1]._hash
5310
+ },
5311
+ {
5312
+ timeId: "1764756756312:g8nh",
5313
+ cakeRef: carCake._data[2]._hash
5314
+ }
5315
+ ]
5316
+ });
5317
+ const seriesSliceIdTableCfg = hip(
5318
+ createSliceIdsTableCfg("seriesSliceId")
5319
+ );
5320
+ const seriesSliceIdData = [
5321
+ {
5322
+ add: ["Serie0", "Serie1", "Serie2", "Serie3"],
5323
+ _hash: ""
5324
+ },
5325
+ {
5326
+ add: ["Serie4", "Serie5", "Serie6", "Serie7"],
5327
+ _hash: ""
5328
+ },
5329
+ {
5330
+ add: ["Serie8", "Serie9", "Serie10", "Serie11"],
5331
+ _hash: ""
5332
+ }
5333
+ ].map((sliceIds) => hsh(sliceIds));
5334
+ const seriesSliceId = hip({
5335
+ _tableCfg: seriesSliceIdTableCfg._hash,
5336
+ _type: "sliceIds",
5337
+ _data: chainSliceIds(seriesSliceIdData),
5338
+ _hash: ""
5339
+ });
5340
+ const seriesGeneralTableCfg = hip({
5341
+ key: "seriesGeneral",
5342
+ type: "components",
5343
+ columns: [
5344
+ { key: "_hash", type: "string", titleShort: "Hash", titleLong: "Hash" },
5345
+ { key: "name", type: "string", titleShort: "Name", titleLong: "Name" }
5346
+ ],
5347
+ isHead: false,
5348
+ isRoot: false,
5349
+ isShared: true
5350
+ });
5351
+ const seriesGeneral = hip({
5352
+ _tableCfg: seriesGeneralTableCfg._hash,
5353
+ _type: "components",
5354
+ _data: [
5355
+ {
5356
+ name: "Polo",
5357
+ _hash: ""
5358
+ },
5359
+ {
5360
+ name: "Golf",
5361
+ _hash: ""
5362
+ },
5363
+ {
5364
+ name: "Q4",
5365
+ _hash: ""
5366
+ },
5367
+ {
5368
+ name: "Q6",
5369
+ _hash: ""
5370
+ },
5371
+ {
5372
+ name: "i4",
5373
+ _hash: ""
5374
+ },
5375
+ {
5376
+ name: "3",
5377
+ _hash: ""
5378
+ },
5379
+ {
5380
+ name: "Model 3",
5381
+ _hash: ""
5382
+ },
5383
+ {
5384
+ name: "Model Y",
5385
+ _hash: ""
5386
+ },
5387
+ {
5388
+ name: "Mustang",
5389
+ _hash: ""
5390
+ },
5391
+ {
5392
+ name: "Bolt",
5393
+ _hash: ""
5394
+ },
5395
+ {
5396
+ name: "Leaf",
5397
+ _hash: ""
5398
+ },
5399
+ {
5400
+ name: "Kona",
5401
+ _hash: ""
5402
+ }
5403
+ ],
5404
+ _hash: ""
5405
+ });
5406
+ const seriesCarsTableCfg = hip({
5407
+ key: "seriesCars",
5408
+ type: "components",
5409
+ columns: [
5410
+ { key: "_hash", type: "string", titleShort: "Hash", titleLong: "Hash" },
5411
+ {
5412
+ key: "cars",
5413
+ type: "jsonArray",
5414
+ titleShort: "Cars",
5415
+ titleLong: "Cars References",
5416
+ ref: {
5417
+ tableKey: "carCake",
5418
+ type: "cakes"
5419
+ }
5420
+ }
5421
+ ],
5422
+ isHead: false,
5423
+ isRoot: false,
5424
+ isShared: true
5425
+ });
5426
+ const seriesCars = hip({
5427
+ _tableCfg: seriesCarsTableCfg._hash,
5428
+ _type: "components",
5429
+ _data: [
5430
+ {
5431
+ cars: [
5432
+ {
5433
+ ref: carCake._data[2]._hash,
5434
+ sliceIds: ["VIN1"]
5435
+ }
5436
+ ],
5437
+ _hash: ""
5438
+ },
5439
+ {
5440
+ cars: [
5441
+ {
5442
+ ref: carCake._data[2]._hash,
5443
+ sliceIds: ["VIN2"]
5444
+ }
5445
+ ],
5446
+ _hash: ""
5447
+ },
5448
+ {
5449
+ cars: [
5450
+ {
5451
+ ref: carCake._data[0]._hash,
5452
+ sliceIds: ["VIN3"]
5453
+ }
5454
+ ],
5455
+ _hash: ""
5456
+ },
5457
+ {
5458
+ cars: [
5459
+ {
5460
+ ref: carCake._data[0]._hash,
5461
+ sliceIds: ["VIN4"]
5462
+ }
5463
+ ],
5464
+ _hash: ""
5465
+ },
5466
+ {
5467
+ cars: [
5468
+ {
5469
+ ref: carCake._data[1]._hash,
5470
+ sliceIds: ["VIN5"]
5471
+ }
5472
+ ],
5473
+ _hash: ""
5474
+ },
5475
+ {
5476
+ cars: [
5477
+ {
5478
+ ref: carCake._data[1]._hash,
5479
+ sliceIds: ["VIN6"]
5480
+ }
5481
+ ],
5482
+ _hash: ""
5483
+ },
5484
+ {
5485
+ cars: [
5486
+ {
5487
+ ref: carCake._data[2]._hash,
5488
+ sliceIds: ["VIN7"]
5489
+ }
5490
+ ],
5491
+ _hash: ""
5492
+ },
5493
+ {
5494
+ cars: [
5495
+ {
5496
+ ref: carCake._data[2]._hash,
5497
+ sliceIds: ["VIN8"]
5498
+ }
5499
+ ],
5500
+ _hash: ""
5501
+ },
5502
+ {
5503
+ cars: [
5504
+ {
5505
+ ref: carCake._data[2]._hash,
5506
+ sliceIds: ["VIN9"]
5507
+ }
5508
+ ],
5509
+ _hash: ""
5510
+ },
5511
+ {
5512
+ cars: [
5513
+ {
5514
+ ref: carCake._data[2]._hash,
5515
+ sliceIds: ["VIN10"]
5516
+ }
5517
+ ],
5518
+ _hash: ""
5519
+ },
5520
+ {
5521
+ cars: [
5522
+ {
5523
+ ref: carCake._data[2]._hash,
5524
+ sliceIds: ["VIN11"]
5525
+ }
5526
+ ],
5527
+ _hash: ""
5528
+ },
5529
+ {
5530
+ cars: [
5531
+ {
5532
+ ref: carCake._data[2]._hash,
5533
+ sliceIds: ["VIN12"]
5534
+ }
5535
+ ],
5536
+ _hash: ""
5537
+ }
5538
+ ],
5539
+ _hash: ""
5540
+ });
5541
+ const seriesGeneralLayerTableCfg = hip(
5542
+ createLayerTableCfg("seriesGeneralLayer")
5543
+ );
5544
+ const seriesGeneralLayerData = [
5545
+ {
5546
+ add: {
5547
+ Serie0: seriesGeneral._data[0]._hash,
5548
+ Serie1: seriesGeneral._data[1]._hash,
5549
+ Serie2: seriesGeneral._data[2]._hash,
5550
+ Serie3: seriesGeneral._data[3]._hash,
5551
+ _hash: ""
5552
+ },
5553
+ sliceIdsTable: "seriesSliceId",
5554
+ sliceIdsTableRow: seriesSliceId._data[0]._hash,
5555
+ componentsTable: "seriesGeneral",
5556
+ _hash: ""
5557
+ },
5558
+ {
5559
+ add: {
5560
+ Serie4: seriesGeneral._data[4]._hash,
5561
+ Serie5: seriesGeneral._data[5]._hash,
5562
+ Serie6: seriesGeneral._data[6]._hash,
5563
+ Serie7: seriesGeneral._data[7]._hash,
5564
+ _hash: ""
5565
+ },
5566
+ sliceIdsTable: "seriesSliceId",
5567
+ sliceIdsTableRow: seriesSliceId._data[1]._hash,
5568
+ componentsTable: "seriesGeneral",
5569
+ _hash: ""
5570
+ },
5571
+ {
5572
+ add: {
5573
+ Serie8: seriesGeneral._data[8]._hash,
5574
+ Serie9: seriesGeneral._data[9]._hash,
5575
+ Serie10: seriesGeneral._data[10]._hash,
5576
+ Serie11: seriesGeneral._data[11]._hash,
5577
+ _hash: ""
5578
+ },
5579
+ sliceIdsTable: "seriesSliceId",
5580
+ sliceIdsTableRow: seriesSliceId._data[2]._hash,
5581
+ componentsTable: "seriesGeneral",
5582
+ _hash: ""
5583
+ }
5584
+ ].map((layer) => hsh(layer));
5585
+ const seriesGeneralLayer = hip({
5586
+ _tableCfg: seriesGeneralLayerTableCfg._hash,
5587
+ _type: "layers",
5588
+ _data: chainLayers(seriesGeneralLayerData),
5589
+ _hash: ""
5590
+ });
5591
+ const seriesCarsLayerTableCfg = hip(
5592
+ createLayerTableCfg("seriesCarsLayer")
5593
+ );
5594
+ const seriesCarsLayerData = [
5595
+ {
5596
+ add: {
5597
+ Serie0: seriesCars._data[0]._hash,
5598
+ Serie1: seriesCars._data[1]._hash,
5599
+ Serie2: seriesCars._data[2]._hash,
5600
+ Serie3: seriesCars._data[3]._hash,
5601
+ _hash: ""
5602
+ },
5603
+ sliceIdsTable: "seriesSliceId",
5604
+ sliceIdsTableRow: seriesSliceId._data[0]._hash,
5605
+ componentsTable: "seriesCars",
5606
+ _hash: ""
5607
+ },
5608
+ {
5609
+ add: {
5610
+ Serie4: seriesCars._data[4]._hash,
5611
+ Serie5: seriesCars._data[5]._hash,
5612
+ Serie6: seriesCars._data[6]._hash,
5613
+ Serie7: seriesCars._data[7]._hash,
5614
+ _hash: ""
5615
+ },
5616
+ sliceIdsTable: "seriesSliceId",
5617
+ sliceIdsTableRow: seriesSliceId._data[1]._hash,
5618
+ componentsTable: "seriesCars",
5619
+ _hash: ""
5620
+ },
5621
+ {
5622
+ add: {
5623
+ Serie8: seriesCars._data[8]._hash,
5624
+ Serie9: seriesCars._data[9]._hash,
5625
+ Serie10: seriesCars._data[10]._hash,
5626
+ Serie11: seriesCars._data[11]._hash,
5627
+ _hash: ""
5628
+ },
5629
+ sliceIdsTable: "seriesSliceId",
5630
+ sliceIdsTableRow: seriesSliceId._data[2]._hash,
5631
+ componentsTable: "seriesCars",
5632
+ _hash: ""
5633
+ }
5634
+ ].map((layer) => hsh(layer));
5635
+ const seriesCarsLayer = hip({
5636
+ _tableCfg: seriesCarsLayerTableCfg._hash,
5637
+ _type: "layers",
5638
+ _data: chainLayers(seriesCarsLayerData)
5639
+ });
5640
+ const seriesCakeTableCfg = hip(
5641
+ createCakeTableCfg("seriesCake")
5642
+ );
5643
+ const seriesCake = hip({
5644
+ _tableCfg: seriesCakeTableCfg._hash,
5645
+ _type: "cakes",
5646
+ _data: [
5647
+ {
5648
+ sliceIdsTable: "seriesSliceId",
5649
+ sliceIdsRow: seriesSliceId._data[0]._hash,
5650
+ layers: {
5651
+ seriesGeneralLayer: seriesGeneralLayer._data[0]._hash,
5652
+ seriesCarsLayer: seriesCarsLayer._data[0]._hash
5653
+ }
5654
+ },
5655
+ {
5656
+ sliceIdsTable: "seriesSliceId",
5657
+ sliceIdsRow: seriesSliceId._data[1]._hash,
5658
+ layers: {
5659
+ seriesGeneralLayer: seriesGeneralLayer._data[1]._hash,
5660
+ seriesCarsLayer: seriesCarsLayer._data[1]._hash
5661
+ }
5662
+ },
5663
+ {
5664
+ sliceIdsTable: "seriesSliceId",
5665
+ sliceIdsRow: seriesSliceId._data[2]._hash,
5666
+ layers: {
5667
+ seriesGeneralLayer: seriesGeneralLayer._data[2]._hash,
5668
+ seriesCarsLayer: seriesCarsLayer._data[2]._hash
5669
+ }
5670
+ }
5671
+ ]
5672
+ });
5673
+ const seriesCakeHeadTableCfg = hip(
5674
+ createHeadsTableCfg("seriesCake")
5675
+ );
5676
+ const seriesCakeHeads = hip({
5677
+ _tableCfg: seriesCakeHeadTableCfg._hash,
5678
+ _type: "head",
5679
+ _data: [
5680
+ {
5681
+ timeId: "1764756756315:L14y",
5682
+ cakeRef: seriesCake._data[0]._hash
5683
+ },
5684
+ {
5685
+ timeId: "1764756756315:xCXT",
5686
+ cakeRef: seriesCake._data[1]._hash
5687
+ },
5688
+ {
5689
+ timeId: "1764756756315:fZwA",
5690
+ cakeRef: seriesCake._data[2]._hash
5691
+ }
5692
+ ]
5693
+ });
5694
+ const catalogSliceIdTableCfg = hip(
5695
+ createSliceIdsTableCfg("catalogSliceId")
5696
+ );
5697
+ const catalogSliceIdData = [
5698
+ {
5699
+ add: ["Catalog0", "Catalog1"],
5700
+ _hash: ""
5701
+ }
5702
+ ].map((sliceIds) => hsh(sliceIds));
5703
+ const catalogSliceId = hip({
5704
+ _tableCfg: catalogSliceIdTableCfg._hash,
5705
+ _type: "sliceIds",
5706
+ _data: chainSliceIds(catalogSliceIdData),
5707
+ _hash: ""
5708
+ });
5709
+ const catalogSeriesTableCfg = hip({
5710
+ key: "catalogSeries",
5711
+ type: "components",
5712
+ columns: [
5713
+ { key: "_hash", type: "string", titleShort: "Hash", titleLong: "Hash" },
5714
+ {
5715
+ key: "series",
5716
+ type: "jsonArray",
5717
+ titleShort: "Series",
5718
+ titleLong: "Series References",
5719
+ ref: {
5720
+ tableKey: "seriesCake",
5721
+ type: "cakes"
5722
+ }
5723
+ }
5724
+ ],
5725
+ isHead: false,
5726
+ isRoot: false,
5727
+ isShared: true
5728
+ });
5729
+ const catalogSeries = hip({
5730
+ _tableCfg: catalogSeriesTableCfg._hash,
5731
+ _type: "components",
5732
+ _data: [
5733
+ {
5734
+ series: [
5735
+ {
5736
+ ref: seriesCake._data[0]._hash,
5737
+ sliceIds: ["Serie0", "Serie1", "Serie2", "Serie3"]
5738
+ },
5739
+ {
5740
+ ref: seriesCake._data[1]._hash,
5741
+ sliceIds: ["Serie4", "Serie5", "Serie6", "Serie7"]
5742
+ }
5743
+ ],
5744
+ _hash: ""
5745
+ },
5746
+ {
5747
+ series: [
5748
+ {
5749
+ ref: seriesCake._data[2]._hash
5750
+ }
5751
+ ],
5752
+ _hash: ""
5753
+ }
5754
+ ],
5755
+ _hash: ""
5756
+ });
5757
+ const catalogSeriesLayerTableCfg = hip(
5758
+ createLayerTableCfg("catalogSeriesLayer")
5759
+ );
5760
+ const catalogSeriesLayerData = [
5761
+ {
5762
+ add: {
5763
+ Catalog0: catalogSeries._data[0]._hash,
5764
+ Catalog1: catalogSeries._data[1]._hash,
5765
+ _hash: ""
5766
+ },
5767
+ sliceIdsTable: "catalogSliceId",
5768
+ sliceIdsTableRow: catalogSliceId._data[0]._hash,
5769
+ componentsTable: "catalogSeries",
5770
+ _hash: ""
5771
+ }
5772
+ ].map((layer) => hsh(layer));
5773
+ const catalogSeriesLayer = hip({
5774
+ _tableCfg: catalogSeriesLayerTableCfg._hash,
5775
+ _type: "layers",
5776
+ _data: chainLayers(catalogSeriesLayerData),
5777
+ _hash: ""
5778
+ });
5779
+ const catalogCakeTableCfg = hip(
5780
+ createCakeTableCfg("catalogCake")
5781
+ );
5782
+ const catalogCake = hip({
5783
+ _tableCfg: catalogCakeTableCfg._hash,
5784
+ _type: "cakes",
5785
+ _data: [
5786
+ {
5787
+ sliceIdsTable: "catalogSliceId",
5788
+ sliceIdsRow: catalogSliceId._data[0]._hash,
5789
+ layers: {
5790
+ catalogSeriesLayer: catalogSeriesLayer._data[0]._hash
5791
+ }
5792
+ }
5793
+ ]
5794
+ });
5795
+ const catalogCakeHeadTableCfg = hip(
5796
+ createHeadsTableCfg("catalogCake")
5797
+ );
5798
+ const catalogCakeHeads = hip({
5799
+ _tableCfg: catalogCakeHeadTableCfg._hash,
5800
+ _type: "head",
5801
+ _data: [
5802
+ {
5803
+ timeId: "1764756756317:5UTy",
5804
+ cakeRef: catalogCake._data[0]._hash
5805
+ }
5806
+ ]
5807
+ });
5808
+ const tableCfgs = {
5809
+ _data: [
5810
+ carSliceIdTableCfg,
5811
+ carGeneralTableCfg,
5812
+ carDimensionsTableCfg,
5813
+ carTechnicalTableCfg,
5814
+ carColorTableCfg,
5815
+ carGeneralLayerTableCfg,
5816
+ carTechnicalLayerTableCfg,
5817
+ carColorLayerTableCfg,
5818
+ carCakeTableCfg,
5819
+ carCakeHeadTableCfg,
5820
+ seriesSliceIdTableCfg,
5821
+ seriesGeneralTableCfg,
5822
+ seriesCarsTableCfg,
5823
+ seriesGeneralLayerTableCfg,
5824
+ seriesCarsLayerTableCfg,
5825
+ seriesCakeTableCfg,
5826
+ seriesCakeHeadTableCfg,
5827
+ catalogSliceIdTableCfg,
5828
+ catalogSeriesTableCfg,
5829
+ catalogSeriesLayerTableCfg,
5830
+ catalogCakeTableCfg,
5831
+ catalogCakeHeadTableCfg
5832
+ ]
5833
+ };
5834
+ const staticExample2 = {
5835
+ carSliceId,
5836
+ carGeneral,
5837
+ carDimensions,
5838
+ carTechnical,
5839
+ carColor,
5840
+ carGeneralLayer,
5841
+ carTechnicalLayer,
5842
+ carColorLayer,
5843
+ carCake,
5844
+ carCakeHeads,
5845
+ seriesSliceId,
5846
+ seriesGeneral,
5847
+ seriesCars,
5848
+ seriesGeneralLayer,
5849
+ seriesCarsLayer,
5850
+ seriesCake,
5851
+ seriesCakeHeads,
5852
+ catalogSliceId,
5853
+ catalogSeries,
5854
+ catalogSeriesLayer,
5855
+ catalogCake,
5856
+ catalogCakeHeads,
5857
+ tableCfgs
5858
+ };
5859
+ return staticExample2;
5860
+ };
3591
5861
  export {
3592
- Db as RljsonDb
5862
+ Connector,
5863
+ Db,
5864
+ Join,
5865
+ MultiEditManager,
5866
+ exampleEditActionColumnSelection,
5867
+ exampleEditActionColumnSelectionOnlySomeColumns,
5868
+ exampleEditActionRowFilter,
5869
+ exampleEditActionRowSort,
5870
+ exampleEditActionSetValue,
5871
+ exampleEditSetValueReferenced,
5872
+ staticExample
3593
5873
  };
5874
+ //# sourceMappingURL=db.js.map