@rljson/db 0.0.11 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/db.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"db.js","sources":["/Users/maximilianheller/Documents/Development/rljson-db/src/connector/connector.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/controller/base-controller.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/controller/cake-controller.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/controller/component-controller.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/controller/slice-id-controller.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/controller/layer-controller.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/controller/controller.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/core.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/tools/inject.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/tools/isolate.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/tools/merge-trees.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/join/selection/column-selection.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/join/filter/boolean-filter.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/join/filter/boolean-filter-processor.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/join/filter/number-filter.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/join/filter/number-filter-processor.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/join/filter/string-filter.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/join/filter/string-filter-processor.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/join/filter/column-filter-processor.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/join/filter/row-filter-processor.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/join/join.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/notify.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/tools/make-unique.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/db.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/edit/edit-action.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/join/sort/row-sort.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/edit/multi-edit-processor.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/edit/multi-edit-manager.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/example-static/example-static.ts"],"sourcesContent":["// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { Socket } from '@rljson/io';\nimport { Route, timeId } from '@rljson/rljson';\n\nimport { Db } from '../db.ts';\n\nexport type ConnectorPayload = { o: string; r: string };\nexport type ConnectorCallback = (ref: string) => Promise<any>;\n\nexport class Connector {\n private _origin: string;\n private _callbacks: ConnectorCallback[] = [];\n\n private _isListening: boolean = false;\n\n private _sentRefs: Set<string> = new Set();\n private _receivedRefs: Set<string> = new Set();\n\n constructor(\n private readonly _db: Db,\n private readonly _route: Route,\n private readonly _socket: Socket,\n ) {\n this._origin = timeId();\n\n this._init();\n }\n\n send(ref: string) {\n if (this._sentRefs.has(ref) || this._receivedRefs.has(ref)) return;\n\n this._sentRefs.add(ref);\n\n this.socket.emit(this.route.flat, {\n o: this._origin,\n r: ref,\n } as ConnectorPayload);\n }\n\n listen(callback: (editHistoryRef: string) => Promise<void>) {\n this._socket.on(this._route.flat, async (payload: ConnectorPayload) => {\n /* v8 ignore next -- @preserve */\n try {\n await callback(payload.r);\n } catch (error) {\n console.error('Error in connector listener callback:', error);\n }\n });\n }\n\n private _init() {\n this._registerSocketObserver();\n this._registerDbObserver();\n\n this._isListening = true;\n }\n\n public teardown() {\n this._socket.removeAllListeners(this._route.flat);\n this._db.unregisterAllObservers(this._route);\n\n this._isListening = false;\n }\n\n private _notifyCallbacks(ref: string) {\n /* v8 ignore next -- @preserve */\n Promise.all(this._callbacks.map((cb) => cb(ref))).catch((err) => {\n console.error(`Error notifying connector callbacks for ref ${ref}:`, err);\n });\n }\n\n private _registerSocketObserver() {\n this.socket.on(this.route.flat, (p: ConnectorPayload) => {\n if (p.o === this._origin) {\n return;\n }\n\n const ref = p.r;\n /* v8 ignore next -- @preserve */\n if (this._receivedRefs.has(ref)) {\n return;\n }\n\n this._receivedRefs.add(p.r);\n\n this._notifyCallbacks(p.r);\n });\n }\n\n private _registerDbObserver() {\n this._db.registerObserver(this._route, (ins) => {\n return new Promise<void>((resolve) => {\n const ref = (ins as any)[this.route.root.tableKey + 'Ref'] as string;\n /* v8 ignore next -- @preserve */\n if (this._sentRefs.has(ref)) {\n resolve();\n return;\n }\n this.send(ref);\n resolve();\n });\n });\n }\n\n get socket() {\n return this._socket;\n }\n\n get route() {\n return this._route;\n }\n\n get origin() {\n return this._origin;\n }\n\n get isListening() {\n return this._isListening;\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { equals, Json, JsonValue } from '@rljson/json';\nimport {\n ContentType, InsertHistoryRow, Ref, Rljson, TableCfg, TableKey, TableType\n} from '@rljson/rljson';\n\nimport { Core } from '../core.ts';\n\nimport { CakeControllerCommands } from './cake-controller.ts';\nimport { Controller, ControllerChildProperty, ControllerRefs } from './controller.ts';\n\n\nexport abstract class BaseController<T extends TableType, C extends JsonValue>\n implements Controller<T, C, string>\n{\n protected _contentType?: ContentType;\n protected _tableCfg?: TableCfg;\n\n constructor(\n protected readonly _core: Core,\n protected readonly _tableKey: TableKey,\n ) {}\n\n // ...........................................................................\n abstract insert(\n command: CakeControllerCommands,\n value: C,\n origin?: Ref,\n refs?: ControllerRefs,\n ): Promise<InsertHistoryRow<any>[]>;\n\n // ...........................................................................\n abstract init(): Promise<void>;\n\n // ...........................................................................\n abstract getChildRefs(\n where: string | Json,\n filter?: Json,\n ): Promise<ControllerChildProperty[]>;\n\n // ...........................................................................\n abstract filterRow(\n row: Json,\n key: string,\n value: JsonValue,\n ): Promise<boolean>;\n\n // ...........................................................................\n /**\n * Retrieves the current state of the table.\n * @returns A promise that resolves to the current state of the table.\n */\n async table(): Promise<T> {\n const rljson = await this._core.dumpTable(this._tableKey);\n return rljson[this._tableKey] as T;\n }\n\n // ...........................................................................\n /**\n * Fetches a specific entry from the table by its reference or by a partial match.\n * @param where A string representing the reference of the entry to fetch, or an object representing a partial match.\n * @returns A promise that resolves to an array of entries matching the criteria, or null if no entries are found.\n */\n async get(where: string | Json, filter?: Json): Promise<Rljson> {\n if (typeof where === 'string') {\n return this._getByHash(where, filter);\n } else if (typeof where === 'object' && where !== null) {\n // If where is an object with only _hash property\n if (\n Object.keys(where).length === 1 &&\n '_hash' in where &&\n typeof where['_hash'] === 'string'\n ) {\n return this._getByHash(where['_hash'], filter);\n }\n\n // If where is an object, we assume it's a partial match\n return this._getByWhere(where, filter);\n } else {\n return Promise.resolve({});\n }\n }\n\n // ...........................................................................\n /**\n * Fetches a specific entry from the table by its reference.\n * @param hash A string representing the reference of the entry to fetch.\n * @returns A promise that resolves to the entry matching the reference, or null if no entry is found.\n */\n protected async _getByHash(hash: string, filter?: Json): Promise<Rljson> {\n let result: Rljson = {};\n\n if (!filter || equals(filter, {})) {\n result = await this._core.readRow(this._tableKey, hash);\n } else {\n result = await this._core.readRows(this._tableKey, {\n _hash: hash,\n ...filter,\n } as { [column: string]: JsonValue });\n }\n\n return result;\n }\n\n // ...........................................................................\n /**\n * Fetches entries from the table that match the specified criteria.\n * @param where An object representing the criteria to match.\n * @returns A promise that resolves to an array of entries matching the criteria, or null if no entries are found.\n */\n protected async _getByWhere(where: Json, filter?: Json): Promise<Rljson> {\n const rows = await this._core.readRows(this._tableKey, {\n ...where,\n ...filter,\n } as { [column: string]: JsonValue });\n return rows;\n }\n\n // ...........................................................................\n /**\n * Gets the content type of the controller.\n * @returns The content type managed by the controller.\n */\n /* v8 ignore next -- @preserve */\n contentType(): ContentType {\n return this._contentType ?? 'components';\n }\n\n // ...........................................................................\n /**\n * Gets the table configuration of the controller.\n * @returns The table configuration managed by the controller.\n */\n tableCfg(): TableCfg {\n /* v8 ignore next -- @preserve */\n if (!this._tableCfg) {\n throw new Error(\n `TableCfg for controller ${this._tableKey} is not initialized.`,\n );\n }\n return this._tableCfg;\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\nimport { hsh, rmhsh } from '@rljson/hash';\nimport { Json, JsonValue } from '@rljson/json';\n// found in the LICENSE file in the root of this package.\nimport {\n Cake,\n CakesTable,\n InsertHistoryRow,\n LayerRef,\n Ref,\n Rljson,\n SliceIdsRef,\n TableKey,\n timeId,\n} from '@rljson/rljson';\n\nimport { Core } from '../core.ts';\n\nimport { BaseController } from './base-controller.ts';\nimport {\n Controller,\n ControllerChildProperty,\n ControllerCommands,\n ControllerRefs,\n} from './controller.ts';\n\nexport interface CakeValue extends Json {\n layers: {\n [layerTable: TableKey]: LayerRef;\n };\n id?: string;\n}\n\nexport type CakeControllerCommands = ControllerCommands | `add@${string}`;\n\nexport interface CakeControllerRefs extends Partial<Cake> {\n sliceIdsTable: TableKey;\n sliceIdsRow: SliceIdsRef;\n base?: Ref;\n}\n\nexport class CakeController<N extends string, C extends Cake>\n extends BaseController<CakesTable, C>\n implements Controller<CakesTable, C, N>\n{\n constructor(\n protected readonly _core: Core,\n protected readonly _tableKey: TableKey,\n private _refs?: CakeControllerRefs,\n ) {\n super(_core, _tableKey);\n this._contentType = 'cakes';\n }\n\n private _baseLayers: { [layerTable: string]: string } = {};\n\n async init() {\n // Validate Table\n\n // TableKey must end with 'Cake'\n if (this._tableKey.endsWith('Cake') === false) {\n throw new Error(\n `Table ${this._tableKey} is not supported by CakeController.`,\n );\n }\n\n // Table must be of type cakes\n const contentType = await this._core.contentType(this._tableKey);\n if (contentType !== 'cakes') {\n throw new Error(`Table ${this._tableKey} is not of type cakes.`);\n }\n\n //Get TableCfg\n this._tableCfg = await this._core.tableCfg(this._tableKey);\n\n // Validate refs or try to read them from the first row of the table\n if (\n this._refs &&\n this._refs.base &&\n this._refs.base !== undefined &&\n this._refs.base.length > 0\n ) {\n // Validate base cake exists\n const {\n [this._tableKey]: { _data: baseCakes },\n } = await this._core.readRow(this._tableKey, this._refs.base);\n\n // Base cake must exist\n if (baseCakes.length === 0) {\n throw new Error(`Base cake ${this._refs.base} does not exist.`);\n }\n\n const baseCake = baseCakes[0] as Cake;\n\n // Store base layers from base cake\n this._baseLayers = rmhsh(baseCake.layers);\n }\n }\n\n async getChildRefs(\n where: string | Json,\n filter?: Json,\n ): Promise<ControllerChildProperty[]> {\n /* v8 ignore next -- @preserve */\n if (!this._tableCfg) {\n throw new Error(`Controller not initialized.`);\n }\n\n const childRefs: ControllerChildProperty[] = [];\n const { [this._tableKey]: table } = await this.get(where, filter);\n\n const cakes = table._data as Cake[];\n for (const cake of cakes) {\n for (const layerTable of Object.keys(cake.layers)) {\n if (layerTable.startsWith('_')) continue; // Skip internal keys\n childRefs.push({\n tableKey: layerTable as TableKey,\n ref: cake.layers[layerTable],\n });\n }\n }\n\n return childRefs;\n }\n\n async insert(\n command: CakeControllerCommands,\n value: C,\n origin?: Ref,\n refs?: ControllerRefs,\n ): Promise<InsertHistoryRow<any>[]> {\n // Validate command\n if (!command.startsWith('add')) {\n throw new Error(`Command ${command} is not supported by CakeController.`);\n }\n\n /* v8 ignore next -- @preserve */\n if (this._refs?.base) delete this._refs.base; // Remove base ref to avoid conflicts\n\n const normalizedValue: { [layerTable: string]: string } = {};\n for (const [layerTable, layerRef] of Object.entries(\n value.layers as { [layerTable: string]: string },\n )) {\n /* v8 ignore next -- @preserve */\n if (Array.isArray(layerRef) && layerRef.length > 1) {\n throw new Error(\n `CakeController insert: Layer ref for table ${layerTable} cannot be an array of size > 1. No 1:n relations supported.`,\n );\n }\n\n /* v8 ignore next -- @preserve */\n normalizedValue[layerTable] = Array.isArray(layerRef)\n ? layerRef[0]\n : layerRef;\n }\n\n // Overwrite base layers with given layers\n const cake = {\n ...value,\n layers: { ...this._baseLayers, ...normalizedValue },\n ...(refs || this._refs),\n };\n\n const rlJson = { [this._tableKey]: { _data: [cake] } } as Rljson;\n\n //Write component to io\n await this._core.import(rlJson);\n\n //Create InsertHistoryRow\n const result = {\n //Ref to component\n [this._tableKey + 'Ref']: hsh(cake as Json)._hash as string,\n\n //Data from edit\n route: '',\n origin,\n\n //Unique id/timestamp\n timeId: timeId(),\n } as InsertHistoryRow<any>;\n\n return [result];\n }\n\n async get(where: string | Json, filter?: Json): Promise<Rljson> {\n if (typeof where === 'string') {\n return this._getByHash(where, filter);\n } else if (typeof where === 'object' && where !== null) {\n return this._getByWhere(where, filter);\n } else {\n return Promise.resolve({});\n }\n }\n\n async filterRow(row: Json, key: string, value: JsonValue): Promise<boolean> {\n const cake = row as Cake;\n for (const [layerKey, layerRef] of Object.entries(cake.layers)) {\n if (layerKey === key && layerRef === value) {\n return true;\n }\n }\n return false;\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\nimport { hsh } from '@rljson/hash';\n// Use of this source code is governed by terms that can be\nimport { equals, Json, JsonValue, merge } from '@rljson/json';\n// found in the LICENSE file in the root of this package.\nimport {\n CakeReference,\n ColumnCfg,\n ComponentsTable,\n ContentType,\n InsertHistoryRow,\n Ref,\n Rljson,\n TableKey,\n timeId,\n} from '@rljson/rljson';\n\nimport { Core } from '../core.ts';\n\nimport { BaseController } from './base-controller.ts';\nimport {\n Controller,\n ControllerChildProperty,\n ControllerCommands,\n ControllerRefs,\n} from './controller.ts';\n\nexport class ComponentController<\n N extends string,\n C extends Json,\n T extends Json,\n >\n extends BaseController<ComponentsTable<T>, C>\n implements Controller<ComponentsTable<T>, C, N>\n{\n private _allowedContentTypes: ContentType[] = [\n 'components',\n 'edits',\n 'editHistory',\n 'multiEdits',\n 'head',\n ];\n\n private _resolvedColumns: {\n base: ColumnCfg[];\n references: Record<TableKey, ColumnCfg[]>;\n } | null = null;\n private _refTableKeyToColumnKeyMap: Record<TableKey, string[]> | null = null;\n\n constructor(\n protected readonly _core: Core,\n protected readonly _tableKey: TableKey,\n private _refs?: ControllerRefs,\n ) {\n super(_core, _tableKey);\n this._contentType = 'components';\n }\n\n async init() {\n // Validate Table\n if (!!this._refs && !this._refs.base) {\n // No specific refs required for components table\n throw new Error(`Refs are not required on ComponentController.`);\n }\n\n // Table must be of allowed type\n const contentType = await this._core.contentType(this._tableKey);\n if (this._allowedContentTypes.indexOf(contentType) === -1) {\n throw new Error(`Table ${this._tableKey} is not of type components.`);\n }\n\n //Get TableCfg\n this._tableCfg = await this._core.tableCfg(this._tableKey);\n\n this._resolvedColumns = await this._resolveReferenceColumns({\n base: this._tableCfg.columns,\n });\n this._refTableKeyToColumnKeyMap = this._createRefTableKeyToColumnKeyMap();\n }\n\n async insert(\n command: ControllerCommands,\n value: Json,\n origin?: Ref,\n refs?: ControllerRefs,\n ): Promise<InsertHistoryRow<N>[]> {\n // Validate command\n if (!command.startsWith('add')) {\n throw new Error(\n `Command ${command} is not supported by ComponentController.`,\n );\n }\n /* v8 ignore else -- @preserve */\n if (!!refs) {\n throw new Error(`Refs are not supported on ComponentController.`);\n }\n\n const component = value as JsonValue & { _hash?: string };\n\n //Remove internal flags\n delete (component as any)._somethingToInsert;\n\n const rlJson = { [this._tableKey]: { _data: [component] } } as Rljson;\n\n //Write component to io\n await this._core.import(rlJson);\n\n return [\n {\n //Ref to component\n [this._tableKey + 'Ref']: hsh(component as Json)._hash as string,\n\n //Data from edit\n route: '',\n origin,\n //Unique id/timestamp\n timeId: timeId(),\n },\n ] as any as InsertHistoryRow<N>[];\n }\n\n // ...........................................................................\n /**\n * Retrieves references to child entries in related tables based on a condition.\n * @param where - The condition to filter the data.\n * @param filter - Optional filter to apply to the data.\n * @returns\n */\n async getChildRefs(\n where: string | Json,\n filter?: Json,\n ): Promise<ControllerChildProperty[]> {\n const { [this._tableKey]: table } = await this.get(where, filter);\n const { columns } = await this._core.tableCfg(this._tableKey);\n\n //Unique child refs\n const childRefs: Map<string, ControllerChildProperty> = new Map();\n\n for (const colCfg of columns) {\n if (!colCfg.ref || colCfg.ref === undefined) continue;\n\n const propertyKey = colCfg.key;\n const childRefTableKey = colCfg.ref.tableKey;\n\n for (const row of table._data) {\n const refValue = (row as any)[propertyKey];\n\n //Plain hashes given, reference table from columnCfg\n if (typeof refValue === 'string') {\n childRefs.set(`${childRefTableKey}|${propertyKey}|${refValue}`, {\n tableKey: childRefTableKey,\n columnKey: propertyKey,\n ref: refValue,\n } as ControllerChildProperty);\n continue;\n }\n\n /* v8 ignore if -- @preserve */\n if (Array.isArray(refValue)) {\n for (const refItem of refValue) {\n //Plain hashes given, reference table from columnCfg\n if (typeof refItem === 'string') {\n childRefs.set(`${childRefTableKey}|${propertyKey}|${refItem}`, {\n tableKey: childRefTableKey,\n columnKey: propertyKey,\n ref: refItem,\n } as ControllerChildProperty);\n continue;\n }\n\n //CakeRef: Object with ref and sliceIds given\n if (typeof refItem === 'object' && refItem !== null) {\n const cakeReference = refItem as CakeReference;\n childRefs.set(\n `${childRefTableKey}|${propertyKey}|${\n cakeReference.ref\n }|${cakeReference.sliceIds?.join(',')}`,\n {\n tableKey: childRefTableKey,\n columnKey: propertyKey,\n ref: cakeReference.ref,\n sliceIds: cakeReference.sliceIds,\n } as ControllerChildProperty,\n );\n continue;\n }\n }\n continue;\n }\n }\n }\n\n return Array.from(childRefs.values());\n }\n\n // ...........................................................................\n /**\n * Fetches a specific entry from the table by a partial match. Resolves references as needed.\n * @param where - An object representing a partial match.\n * @returns A promise that resolves to an array of entries matching the criteria, or null if no entries are found.\n */\n protected async _getByWhere(where: Json, filter?: Json): Promise<Rljson> {\n // If reference columns are present, resolve them\n // Check if where clause contains reference columns\n const consolidatedWheres: Json[] = [];\n const consolidatedRows: Map<string, Json> = new Map();\n const hasReferenceColumns = this._hasReferenceColumns(where);\n if (hasReferenceColumns) {\n const resolvedReferences: Record<TableKey, Ref[]> =\n await this._resolveReferences(this._getWhereReferences(where));\n const refWhereClauses =\n this._referencesToWhereClauses(resolvedReferences);\n for (const refWhere of refWhereClauses) {\n consolidatedWheres.push({\n ...this._getWhereBase(where),\n ...refWhere,\n });\n\n /* ....................................................................\n 1:1 reference resolution\n const {\n [this._tableKey]: { _data: refRows },\n } = await this._core.readRows(this._tableKey, {\n ...refWhere,\n ...filter,\n } as { [column: string]: JsonValue });\n .................................................................... */\n\n const {\n [this._tableKey]: { _data: tableData },\n } = await this._core.dumpTable(this._tableKey);\n\n const column = Object.keys(refWhere)[0];\n const refValue = refWhere[column]!;\n for (const row of tableData as Json[]) {\n if (await this.filterRow(row, column, refValue)) {\n consolidatedRows.set((row as any)._hash, row);\n }\n }\n }\n } else {\n const {\n [this._tableKey]: { _data: rows },\n } = await this._core.readRows(this._tableKey, {\n ...where,\n ...filter,\n } as { [column: string]: JsonValue });\n\n for (const row of rows as Json[]) {\n consolidatedRows.set((row as any)._hash, row);\n }\n }\n\n // Return result\n return {\n [this._tableKey]: {\n _data: Array.from(consolidatedRows.values()),\n _type: 'components',\n } as ComponentsTable<T>,\n };\n }\n\n private _referencesToWhereClauses(\n references: Record<TableKey, Ref[]>,\n ): Json[] {\n const whereClauses: Json[] = [];\n for (const [tableKey, refs] of Object.entries(references)) {\n const wherePropertyKeys =\n this._refTableKeyToColumnKeyMap?.[tableKey as TableKey];\n for (const propKey of wherePropertyKeys!) {\n for (const ref of refs) {\n whereClauses.push({ [propKey]: ref });\n }\n }\n }\n return whereClauses;\n }\n\n private _createRefTableKeyToColumnKeyMap(): Record<TableKey, string[]> {\n const map: Record<TableKey, string[]> = {};\n const columns = this._tableCfg?.columns;\n\n for (const colCfg of columns!) {\n if (colCfg.ref) {\n const tableKey = colCfg.ref.tableKey;\n /* v8 ignore if -- @preserve */\n if (!map[tableKey]) {\n map[tableKey] = [];\n }\n map[tableKey].push(colCfg.key);\n }\n }\n return map;\n }\n\n // ...........................................................................\n /**\n * Extracts reference columns from the where clause.\n * @param where - The condition to filter the data.\n * @returns An object representing only the reference columns in the where clause.\n */\n private _getWhereReferences(where: Json): Json {\n const whereRefs: Json = {};\n for (const colCfg of this._referenceColumns) {\n if (colCfg.key in where) {\n whereRefs[colCfg.key] = where[colCfg.key];\n }\n }\n return whereRefs;\n }\n\n // ...........................................................................\n /**\n * Removes reference columns from the where clause.\n * @param where - The condition to filter the data.\n * @returns An object representing the where clause without reference columns.\n */\n private _getWhereBase(where: Json): Json {\n const whereWithoutRefs: Json = { ...where };\n for (const colCfg of this._referenceColumns) {\n if (colCfg.key in whereWithoutRefs) {\n delete whereWithoutRefs[colCfg.key];\n }\n }\n return whereWithoutRefs;\n }\n\n // ...........................................................................\n /**\n * Retrieves all reference columns from the resolved columns.\n * @returns An array of ColumnCfg representing the reference columns.\n */\n private get _referenceColumns(): ColumnCfg[] {\n /* v8 ignore next -- @preserve */\n if (!this._resolvedColumns) {\n throw new Error(\n `Resolved columns are not available for table ${this._tableKey}. You must call init() first.`,\n );\n }\n const references: ColumnCfg[] = [];\n for (const refCols of Object.values(this._resolvedColumns.references)) {\n references.push(...refCols);\n }\n return references;\n }\n\n // ...........................................................................\n /**\n * Checks if the where clause contains any reference columns.\n * @param where - The condition to filter the data.\n * @returns A promise that resolves to true if reference columns are present, false otherwise.\n */\n private _hasReferenceColumns(where: Json): boolean {\n /* v8 ignore next -- @preserve */\n if (!this._resolvedColumns) {\n throw new Error(\n `Resolved columns are not available for table ${this._tableKey}. You must call init() first.`,\n );\n }\n\n for (const colCfg of this._referenceColumns) {\n if (colCfg.key in where) {\n return true;\n }\n }\n return false;\n }\n\n // ...........................................................................\n /**\n * Resolves reference columns in the where clause.\n * @param columns - The columns to resolve.\n * @returns A promise that resolves to an object containing base and reference columns.\n */\n private async _resolveReferenceColumns(columns: {\n base: ColumnCfg[];\n references?: Record<TableKey, ColumnCfg[]>;\n }): Promise<{\n base: ColumnCfg[];\n references: Record<TableKey, ColumnCfg[]>;\n }> {\n const base: ColumnCfg[] = [];\n const references: Record<TableKey, ColumnCfg[]> = {};\n\n for (const col of columns.base) {\n // If column has a ref, fetch referenced table columns\n if (!!col.ref) {\n const refTableKey = col.ref.tableKey;\n const { columns: refColumns } = await this._core.tableCfg(refTableKey);\n\n /* v8 ignore if -- @preserve */\n if (!references[refTableKey]) {\n references[refTableKey] = [];\n }\n\n // Check if referenced columns have refs themselves and resolve them too\n const refsHaveRefs = refColumns.some((c) => !!c.ref);\n /*v8 ignore next -- @preserve */\n if (refsHaveRefs) {\n const resolvedRefColumns = await this._resolveReferenceColumns({\n base: refColumns,\n });\n references[refTableKey].push(...resolvedRefColumns.base);\n }\n\n references[refTableKey].push(...refColumns);\n } else {\n base.push(col);\n }\n }\n\n return { base, references };\n }\n\n // ...........................................................................\n /**\n * Resolves references based on the where clause.\n * @param where - The condition to filter the data.\n * @returns - A promise that resolves to an object containing resolved references.\n */\n private async _resolveReferences(\n where: Json,\n ): Promise<Record<TableKey, Ref[]>> {\n /* v8 ignore next -- @preserve */\n if (!this._resolvedColumns) {\n throw new Error(\n `Resolved columns are not available for table ${this._tableKey}. You must call init() first.`,\n );\n }\n\n const resolvedReferences: Record<TableKey, Ref[]> = {};\n const references = this._resolvedColumns.references;\n for (const [tableKey, refColumns] of Object.entries(references)) {\n const whereForTable: Json = {};\n for (const colCfg of refColumns) {\n if (colCfg.key in where) {\n whereForTable[colCfg.key] = where[colCfg.key];\n }\n }\n\n /* v8 ignore next -- @preserve */\n if (Object.keys(whereForTable).length === 0) {\n continue; // No where clause for this table\n }\n\n const refRows = await this._readRowsWithReferences(\n tableKey as TableKey,\n whereForTable as { [column: string]: JsonValue },\n );\n\n const refs: Ref[] = refRows[tableKey as TableKey]._data.map(\n (r) => (r as any)._hash,\n );\n\n resolvedReferences[tableKey as TableKey] = refs;\n }\n\n return resolvedReferences;\n }\n\n private async _readRowsWithReferences(\n table: string,\n where: { [column: string]: JsonValue },\n ): Promise<Rljson> {\n //Split where clauses with array values into multiple queries\n const splitted: { [column: string]: JsonValue }[] = [];\n for (const [key, value] of Object.entries(where)) {\n if (Array.isArray(value)) {\n for (const v of value) {\n splitted.push({ ...where, ...{ [key]: v as JsonValue } });\n }\n }\n }\n\n //If we have multiple where clauses, merge the results\n if (splitted.length > 0) {\n const results = [];\n for (const s of splitted) {\n results.push(await this._core.readRows(table, s));\n }\n return merge(...results) as Rljson;\n } else {\n return this._core.readRows(table, where);\n }\n }\n\n async filterRow(row: Json, key: string, value: JsonValue): Promise<boolean> {\n for (const [propertyKey, propertyValue] of Object.entries(row)) {\n if (propertyKey === key && equals(propertyValue, value)) {\n return true;\n } else if (Array.isArray(propertyValue)) {\n for (const item of propertyValue) {\n if (equals(item, value)) {\n return true;\n }\n }\n }\n }\n return false;\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\nimport { hsh } from '@rljson/hash';\nimport { Json, JsonValue } from '@rljson/json';\n// found in the LICENSE file in the root of this package.\nimport {\n InsertCommand,\n InsertHistoryRow,\n Ref,\n Rljson,\n SliceId,\n SliceIds,\n SliceIdsRef,\n SliceIdsTable,\n TableKey,\n timeId,\n} from '@rljson/rljson';\n\nimport { Core } from '../core.ts';\n\nimport { BaseController } from './base-controller.ts';\nimport {\n Controller,\n ControllerChildProperty,\n ControllerRefs,\n} from './controller.ts';\n\nexport interface SliceIdControllerRefs extends Partial<SliceIds> {\n base?: SliceIdsRef;\n}\n\nexport class SliceIdController<N extends string, C extends SliceId[]>\n extends BaseController<SliceIdsTable, C>\n implements Controller<SliceIdsTable, C, N>\n{\n constructor(\n protected readonly _core: Core,\n protected readonly _tableKey: TableKey,\n private _refs?: SliceIdControllerRefs,\n ) {\n super(_core, _tableKey);\n this._contentType = 'sliceIds';\n }\n\n async init() {\n // Validate Table\n\n // TableKey must end with 'SliceId'\n if (this._tableKey.endsWith('SliceId') === false) {\n throw new Error(\n `Table ${this._tableKey} is not supported by SliceIdController.`,\n );\n }\n\n // Table must be of type sliceIds\n const contentType = await this._core.contentType(this._tableKey);\n /* v8 ignore next -- @preserve */\n if (contentType !== 'sliceIds') {\n throw new Error(`Table ${this._tableKey} is not of type sliceIds.`);\n }\n\n //Get TableCfg\n this._tableCfg = await this._core.tableCfg(this._tableKey);\n\n // Validate refs or try to read them from the first row of the table\n if (this._refs && this._refs.base) {\n // Validate base sliceId exists\n const {\n [this._tableKey]: { _data: SliceIds },\n } = await this._core.readRow(this._tableKey, this._refs.base);\n\n // Base sliceId must exist\n if (SliceIds.length === 0) {\n throw new Error(`Base sliceId ${this._refs.base} does not exist.`);\n }\n }\n }\n\n async insert(\n command: InsertCommand,\n value: SliceId[],\n origin?: Ref,\n refs?: ControllerRefs,\n ): Promise<InsertHistoryRow<any>[]> {\n // Validate command\n if (!command.startsWith('add') && !command.startsWith('remove')) {\n throw new Error(\n `Command ${command} is not supported by SliceIdController.`,\n );\n }\n\n // sliceIds to add/remove\n const sliceIds =\n command.startsWith('add') === true\n ? ({\n add: value,\n ...(refs || this._refs),\n } as SliceIds & { _hash?: string })\n : ({\n add: [],\n remove: value,\n ...(refs || this._refs),\n } as SliceIds & { _hash?: string });\n\n const rlJson = { [this._tableKey]: { _data: [sliceIds] } } as Rljson;\n\n //Write component to io\n await this._core.import(rlJson);\n\n //Create InsertHistoryRow\n const result = {\n //Ref to component\n [this._tableKey + 'Ref']: hsh(sliceIds as Json)._hash as string,\n\n //Data from edit\n route: '',\n origin,\n\n //Unique id/timestamp\n timeId: timeId(),\n } as InsertHistoryRow<any>;\n\n return [result];\n }\n\n async get(where: string | Json, filter?: Json): Promise<Rljson> {\n if (typeof where === 'string') {\n return this._getByHash(where, filter);\n } else {\n return this._getByWhere(where, filter);\n }\n }\n\n async resolveBaseSliceIds(sliceIds: SliceIds): Promise<{\n add: SliceId[];\n }> {\n const add = new Set<SliceId>();\n const remove = new Set<SliceId>();\n\n if (!!sliceIds.base) {\n const baseSliceIds = await this.get(sliceIds.base);\n\n /* v8 ignore next -- @preserve */\n if (!baseSliceIds[this._tableKey]?._data?.[0]) {\n throw new Error(`Base sliceIds ${sliceIds.base} does not exist.`);\n }\n /* v8 ignore next -- @preserve */\n if (baseSliceIds[this._tableKey]._data.length > 1) {\n throw new Error(\n `Base sliceIds ${sliceIds.base} has more than one entry.`,\n );\n }\n\n const baseSliceId = baseSliceIds[this._tableKey]._data[0] as SliceIds;\n const resolvedBaseSliceIds = await this.resolveBaseSliceIds(baseSliceId);\n\n for (const sliceId of resolvedBaseSliceIds.add) {\n add.add(sliceId);\n }\n }\n\n for (const sliceId of sliceIds.add) {\n add.add(sliceId);\n }\n\n /* v8 ignore next -- @preserve */\n if (!!sliceIds.remove)\n for (const sliceId of sliceIds.remove) {\n remove.add(sliceId);\n }\n\n // Remove sliceIds that are both in add and remove\n /* v8 ignore next -- @preserve */\n for (const sliceId of remove.values()) {\n if (add.has(sliceId)) {\n add.delete(sliceId);\n }\n }\n\n return { add: Array.from(add) };\n }\n\n /* v8 ignore next -- @preserve */\n async getChildRefs(): Promise<ControllerChildProperty[]> {\n return [];\n }\n\n async filterRow(row: Json, _: string, value: JsonValue): Promise<boolean> {\n const sliceIds = row as SliceIds;\n const sliceId = value as SliceId;\n\n for (const sId of Object.values(sliceIds.add)) {\n if (sliceId === sId) {\n return true;\n }\n }\n\n return false;\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\nimport { hsh, rmhsh } from '@rljson/hash';\nimport { Json, JsonValue } from '@rljson/json';\n// found in the LICENSE file in the root of this package.\nimport {\n ComponentRef,\n InsertCommand,\n InsertHistoryRow,\n Layer,\n LayerRef,\n LayersTable,\n Ref,\n Rljson,\n SliceId,\n SliceIds,\n SliceIdsRef,\n TableKey,\n timeId,\n} from '@rljson/rljson';\n\nimport { Core } from '../core.ts';\n\nimport { BaseController } from './base-controller.ts';\nimport {\n Controller,\n ControllerChildProperty,\n ControllerRefs,\n} from './controller.ts';\nimport { SliceIdController } from './slice-id-controller.ts';\n\nexport interface LayerControllerRefs extends Partial<Layer> {\n base?: LayerRef;\n sliceIdsTable: TableKey;\n sliceIdsTableRow: SliceIdsRef;\n componentsTable: TableKey;\n}\n\nexport class LayerController<N extends string, C extends Layer>\n extends BaseController<LayersTable, C>\n implements Controller<LayersTable, C, N>\n{\n constructor(\n protected readonly _core: Core,\n protected readonly _tableKey: TableKey,\n private _refs?: LayerControllerRefs,\n ) {\n super(_core, _tableKey);\n this._contentType = 'layers';\n }\n\n async init() {\n // Validate Table\n\n // TableKey must end with 'Layer'\n if (this._tableKey.endsWith('Layer') === false) {\n throw new Error(\n `Table ${this._tableKey} is not supported by LayerController.`,\n );\n }\n\n // Table must be of type layers\n const contentType = await this._core.contentType(this._tableKey);\n if (contentType !== 'layers') {\n throw new Error(`Table ${this._tableKey} is not of type layers.`);\n }\n\n //Get TableCfg\n this._tableCfg = await this._core.tableCfg(this._tableKey);\n\n // Validate refs or try to read them from the first row of the table\n if (this._refs && this._refs.base) {\n // Validate base layer exists\n const {\n [this._tableKey]: { _data: baseLayers },\n } = await this._core.readRow(this._tableKey, this._refs.base);\n\n // Base layer must exist\n if (baseLayers.length === 0) {\n throw new Error(`Base layer ${this._refs.base} does not exist.`);\n }\n\n const baseLayer = baseLayers[0] as Layer;\n\n // Try to read sliceIds from base layer if not provided directly\n /* v8 ignore next if -- @preserve */\n if (\n !this._refs.sliceIdsTable ||\n !this._refs.sliceIdsRow ||\n !this._refs.componentsTable\n ) {\n this._refs = {\n sliceIdsTable: baseLayer.sliceIdsTable,\n sliceIdsTableRow: baseLayer.sliceIdsTableRow,\n componentsTable: baseLayer.componentsTable,\n };\n }\n }\n }\n\n async insert(\n command: InsertCommand,\n value: C,\n origin?: Ref,\n refs?: ControllerRefs,\n ): Promise<InsertHistoryRow<any>[]> {\n // Validate command\n if (!command.startsWith('add') && !command.startsWith('remove')) {\n throw new Error(\n `Command ${command} is not supported by LayerController.`,\n );\n }\n const isAdd = command.startsWith('add');\n\n const normalizedValue: Record<SliceId, ComponentRef> = {};\n for (const [sliceId, compRef] of isAdd\n ? Object.entries(value.add as Record<string, any>)\n : Object.entries(value.remove as Record<string, any>)) {\n /* v8 ignore next -- @preserve */\n if (Array.isArray(compRef) && compRef.length > 1) {\n throw new Error(\n `LayerController insert: Component ref for slice ${sliceId} cannot be an array of size > 1. No 1:n relations supported.`,\n );\n }\n /* v8 ignore next -- @preserve */\n normalizedValue[sliceId] = Array.isArray(compRef)\n ? compRef[0]\n : (compRef as ComponentRef);\n }\n\n // layer to add/remove\n const layer = isAdd\n ? {\n ...value,\n ...{\n add: normalizedValue as Record<SliceId, ComponentRef>,\n remove: {},\n },\n ...refs,\n }\n : {\n ...value,\n ...{\n remove: normalizedValue as Record<SliceId, ComponentRef>,\n add: {},\n },\n ...refs,\n };\n\n const rlJson = { [this._tableKey]: { _data: [layer] } } as Rljson;\n\n //Write component to io\n await this._core.import(rlJson);\n\n //Create InsertHistoryRow\n const result = {\n //Ref to component\n [this._tableKey + 'Ref']: hsh(layer as Json)._hash as string,\n\n //Data from edit\n route: '',\n origin,\n\n //Unique id/timestamp\n timeId: timeId(),\n } as InsertHistoryRow<any>;\n\n return [result];\n }\n\n async get(where: string | Json, filter?: Json): Promise<Rljson> {\n if (typeof where === 'string') {\n return this._getByHash(where, filter);\n } else {\n return this._getByWhere(where, filter);\n }\n }\n\n async resolveBaseLayer(layer: Layer): Promise<{\n add: Record<string, string>;\n sliceIds: SliceId[];\n }> {\n const add = new Map<string, string>();\n const sliceIds: Set<SliceId> = new Set<SliceId>();\n\n if (!!layer.base) {\n // Get base layer first\n const baseLayer = await this.get(layer.base);\n\n /* v8 ignore next -- @preserve */\n if (!baseLayer[this._tableKey]?._data?.[0]) {\n throw new Error(`Base layer ${layer.base} does not exist.`);\n }\n /* v8 ignore next -- @preserve */\n if (baseLayer[this._tableKey]._data.length > 1) {\n throw new Error(\n `Base layer ${layer.base} resolving not possible. Not unique.`,\n );\n }\n\n // Get base layer chained layers recursively\n const baseLayerData = rmhsh(baseLayer[this._tableKey]._data[0]) as Layer;\n const baseLayerResolved = await this.resolveBaseLayer(baseLayerData);\n\n // Merge base layer's add components\n for (const [sliceId, compRef] of Object.entries(baseLayerResolved.add)) {\n /* v8 ignore next -- @preserve */\n if (sliceId.startsWith('_')) continue;\n\n add.set(sliceId, compRef);\n }\n\n // Merge base layer's sliceIds\n for (const sliceId of baseLayerResolved.sliceIds) {\n sliceIds.add(sliceId);\n }\n\n // Get sliceIds from base layer's sliceIds\n const baseLayerSliceIdsTable = baseLayerData.sliceIdsTable;\n const baseLayerSliceIdsRow = baseLayerData.sliceIdsTableRow;\n\n // Get sliceIds from base layer's sliceIds table\n const {\n [baseLayerSliceIdsTable]: { _data: baseLayerSliceIds },\n } = await this._core.readRow(\n baseLayerSliceIdsTable,\n baseLayerSliceIdsRow,\n );\n\n // Resolve base layer sliceIds recursively\n for (const sIds of baseLayerSliceIds as SliceIds[]) {\n //Resolve base SliceIds\n const sliceIdController = new SliceIdController(\n this._core,\n baseLayerSliceIdsTable,\n );\n const resolvedSliceIds = await sliceIdController.resolveBaseSliceIds(\n sIds,\n );\n\n // Merge resolved sliceIds\n for (const sId of resolvedSliceIds.add) {\n /* v8 ignore next -- @preserve */\n if (sId.startsWith('_')) continue;\n\n sliceIds.add(sId);\n }\n }\n }\n\n // Get sliceIds from current layer's sliceIds table\n const {\n [layer.sliceIdsTable]: { _data: layerSliceIds },\n } = await this._core.readRow(layer.sliceIdsTable, layer.sliceIdsTableRow);\n\n /* v8 ignore next -- @preserve */\n if (!layerSliceIds || layerSliceIds.length === 0) {\n throw new Error(\n `Layer sliceIds ${layer.sliceIdsTableRow} does not exist.`,\n );\n }\n /* v8 ignore next -- @preserve */\n if (layerSliceIds.length > 1) {\n throw new Error(\n `Layer sliceIds ${layer.sliceIdsTableRow} has more than one entry.`,\n );\n }\n\n const layerSliceId = layerSliceIds[0] as SliceIds;\n\n for (const sId of layerSliceId.add) {\n /* v8 ignore next -- @preserve */\n if (sId.startsWith('_')) continue;\n\n sliceIds.add(sId);\n }\n\n /* v8 ignore next -- @preserve */\n if (!!layerSliceId.remove)\n for (const sId of Object.keys(layerSliceId.remove)) {\n if (sliceIds.has(sId)) {\n sliceIds.delete(sId);\n }\n }\n\n for (const [sliceId, compRef] of Object.entries(layer.add)) {\n if (sliceId.startsWith('_')) continue;\n\n add.set(sliceId, compRef);\n }\n\n // Remove sliceIds that are both in add and remove\n /* v8 ignore next -- @preserve */\n if (!!layer.remove)\n for (const sliceId of Object.keys(layer.remove)) {\n if (add.has(sliceId)) {\n add.delete(sliceId);\n }\n }\n\n return { add: Object.fromEntries(add), sliceIds: Array.from(sliceIds) };\n }\n\n async getChildRefs(\n where: string | Json,\n filter?: Json,\n ): Promise<ControllerChildProperty[]> {\n const { [this._tableKey]: table } = await this.get(where, filter);\n const childRefs: ControllerChildProperty[] = [];\n\n for (const row of table._data) {\n const layer = row as Layer;\n const resolvedLayer = await this.resolveBaseLayer(layer);\n\n for (const [sliceId, ref] of Object.entries(resolvedLayer.add)) {\n /* v8 ignore next -- @preserve */ /* v8 ignore next -- @preserve */\n if (sliceId.startsWith('_')) continue;\n\n childRefs.push({\n tableKey: layer.componentsTable,\n ref,\n sliceIds: [sliceId],\n });\n }\n }\n\n return childRefs;\n }\n\n async filterRow(row: Json, _: string, value: JsonValue): Promise<boolean> {\n const layer = row as Layer;\n const compRef = value as ComponentRef;\n const resolvedLayer = await this.resolveBaseLayer(layer);\n\n for (const componentRef of Object.values(resolvedLayer.add)) {\n if (componentRef === compRef) {\n return true;\n }\n }\n\n return false;\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { Json, JsonValue } from '@rljson/json';\nimport {\n ContentType, InsertCommand, InsertHistoryRow, Ref, Rljson, SliceId, TableCfg, TableKey, TableType\n} from '@rljson/rljson';\n\nimport { Core } from '../core.ts';\n\nimport { CakeController, CakeControllerRefs } from './cake-controller.ts';\nimport { ComponentController } from './component-controller.ts';\nimport { LayerController, LayerControllerRefs } from './layer-controller.ts';\nimport { SliceIdController, SliceIdControllerRefs } from './slice-id-controller.ts';\n\n\nexport type ControllerRefs = CakeControllerRefs | LayerControllerRefs;\n\nexport type ControllerCommands = InsertCommand;\n\nexport type ControllerRunFn<N extends string, C extends JsonValue> = (\n command: ControllerCommands,\n value: C,\n origin?: Ref,\n refs?: ControllerRefs,\n) => Promise<InsertHistoryRow<N>[]>;\n\nexport type ControllerChildProperty = {\n tableKey: TableKey;\n columnKey?: string;\n ref: Ref;\n sliceIds?: SliceId[];\n};\n\n// ...........................................................................\n/**\n * Generic interface for a controller that manages a specific table in the database.\n * @template T The type of the table being managed.\n * @template C The type of the Insert.\n * @template N The name of the table being managed.\n * @property {ControllerRunFn<N>} insert - Function to execute a command on the table.\n * @property {() => Promise<void>} init - Initializes the controller.\n * @property {() => Promise<T>} table - Retrieves the current state of the table.\n * @property {(where: string | { [column: string]: JsonValue }) => Promise<Rljson>} get - Fetches data from the table based on a condition.\n * @property {(where: string | Json, filter?: Json) => Promise<Array<{ tableKey: TableKey; ref: Ref }>>} getChildRefs - Retrieves references to child entries in related tables based on a condition.\n * @param {string | Json }} where - The condition to filter the data.\n * @returns {Promise<Json[] | null>} A promise that resolves to an array of JSON objects or null if no data is found.\n * @throws {Error} If the data is invalid.\n */\nexport interface Controller<\n T extends TableType,\n C extends JsonValue,\n N extends string,\n> {\n insert: ControllerRunFn<N, C>;\n init(): Promise<void>;\n table(): Promise<T>;\n get(where: string | Json, filter?: Json): Promise<Rljson>;\n getChildRefs(\n where: string | Json,\n filter?: Json,\n ): Promise<ControllerChildProperty[]>;\n filterRow(row: Json, key: string, value: JsonValue): Promise<boolean>;\n contentType(): ContentType;\n tableCfg(): TableCfg;\n}\n\n// ...........................................................................\n/**\n * Factory function to create a controller based on the content type.\n * @param {ContentType} type - The type of content (e.g., 'layers', 'components', 'cakes').\n * @param {Core} core - The core instance managing the database.\n * @param {TableKey} tableKey - The key identifying the table to be managed.\n * @param {ControllerRefs} [refs] - Optional references for the controller.\n * @returns {Promise<Controller<any, string>>} A promise that resolves to the created controller.\n * @throws {Error} If the controller for the specified type is not implemented.\n */\nexport const createController = async (\n type: ContentType,\n core: Core,\n tableKey: TableKey,\n refs?: ControllerRefs,\n): Promise<Controller<TableType, any, string>> => {\n let ctrl: Controller<TableType, any, string>;\n switch (type) {\n case 'layers':\n ctrl = new LayerController(core, tableKey, refs as LayerControllerRefs);\n break;\n case 'components':\n case 'edits':\n case 'editHistory':\n case 'multiEdits':\n case 'head':\n ctrl = new ComponentController(core, tableKey, refs as ControllerRefs);\n break;\n case 'cakes':\n ctrl = new CakeController(core, tableKey, refs as CakeControllerRefs);\n break;\n case 'sliceIds':\n ctrl = new SliceIdController(\n core,\n tableKey,\n refs as SliceIdControllerRefs,\n );\n break;\n default:\n throw new Error(`Controller for type ${type} is not implemented yet.`);\n }\n\n await ctrl.init();\n return ctrl;\n};\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { Io, IoMem } from '@rljson/io';\nimport { JsonValue } from '@rljson/json';\nimport {\n BaseValidator,\n ContentType,\n createInsertHistoryTableCfg,\n Rljson,\n TableCfg,\n Validate,\n} from '@rljson/rljson';\n\n/** Implements core functionalities like importing data, setting tables */\nexport class Core {\n // ...........................................................................\n constructor(private readonly _io: Io) {}\n\n static example = async () => {\n return new Core(await IoMem.example());\n };\n\n // ...........................................................................\n /**\n * Creates a table and an insertHistory for the table\n * @param tableCfg TableCfg of table to create\n */\n async createTableWithInsertHistory(tableCfg: TableCfg): Promise<void> {\n await this.createTable(tableCfg);\n await this.createInsertHistory(tableCfg);\n }\n\n /**\n * Creates a table\n * @param tableCfg TableCfg of table to create\n */\n async createTable(tableCfg: TableCfg): Promise<void> {\n return this._io.createOrExtendTable({ tableCfg });\n }\n /**\n * Creates an insertHistory table for a given table\n * @param tableCfg TableCfg of table\n */\n async createInsertHistory(tableCfg: TableCfg): Promise<void> {\n const cfg = createInsertHistoryTableCfg(tableCfg);\n await this.createTable(cfg);\n }\n\n // ...........................................................................\n /**\n * Returns a dump of the database\n */\n dump(): Promise<Rljson> {\n return this._io.dump();\n }\n\n /**\n * Returns a dump of a table.\n * @returns a dump of a table.\n * @throws when table name does not exist\n */\n async dumpTable(table: string): Promise<Rljson> {\n return await this._io.dumpTable({ table });\n }\n\n // ...........................................................................\n /**\n * Imports data into the memory.\n * @param data - The rljson data to import.\n * @throws {Error} If the data is invalid.\n */\n async import(data: Rljson): Promise<void> {\n // Throw an error if the data is invalid\n const validate = new Validate();\n validate.addValidator(new BaseValidator());\n\n const result = await validate.run(data);\n // If there are errors and they are not refsNotFound, throw an error\n // refsNotFound can be ignored because we dont check against existing data\n // when importing new data\n if (\n (result.hasErrors || (result.base && result.base.hasErrors)) &&\n !result.base.refsNotFound &&\n !result.base.layerBasesNotFound\n ) {\n throw new Error(\n 'The imported rljson data is not valid:\\n' +\n JSON.stringify(result, null, 2),\n );\n }\n\n // Write data\n await this._io.write({ data });\n }\n\n // ...........................................................................\n async tables(): Promise<Rljson> {\n return await this._io.dump();\n }\n\n // ...........................................................................\n async hasTable(table: string): Promise<boolean> {\n return await this._io.tableExists(table);\n }\n\n // ...........................................................................\n async contentType(table: string): Promise<ContentType> {\n const contentType = await this._io.contentType({ table });\n return contentType;\n }\n\n // ...........................................................................\n async tableCfg(table: string): Promise<TableCfg> {\n const tableCfgs = await this._io.rawTableCfgs();\n const tableCfg = tableCfgs.find((tc) => tc.key === table) as TableCfg;\n return tableCfg;\n }\n\n // ...........................................................................\n /** Reads a specific row from a database table */\n async readRow(table: string, rowHash: string): Promise<Rljson> {\n return await this._io.readRows({ table, where: { _hash: rowHash } });\n }\n\n // ...........................................................................\n async readRows(\n table: string,\n where: { [column: string]: JsonValue },\n ): Promise<Rljson> {\n return await this._io.readRows({ table, where });\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\n/* v8 ignore next -- @preserve */\nexport const inject = (tree: any, path: (string | number)[], value: any) => {\n for (let i = 0; i < path.length; i++) {\n const segment = path[i];\n if (i === path.length - 1) {\n tree[segment] = value;\n delete tree['_hash'];\n } else {\n if (!tree[segment]) {\n tree[segment] = {};\n }\n tree = tree[segment];\n }\n }\n};\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\n/* v8 ignore next -- @preserve */\nexport const isolate = (\n tree: any,\n path: (string | number)[],\n preservedKeys: string[] = [],\n): any => {\n // Handle empty path - return empty object/array based on tree type\n if (path.length === 0) {\n return Array.isArray(tree) ? [] : {};\n }\n\n // Handle null/undefined tree\n if (tree == null) {\n return null;\n }\n\n const [currentKey, ...remainingPath] = path;\n\n // Create new container based on tree type\n const result = Array.isArray(tree) ? [] : {};\n\n // Preserve properties with keys starting with \"_\" and any keys in preservedKeys array\n if (!Array.isArray(tree)) {\n for (const key in tree) {\n if (\n (typeof key === 'string' && key.startsWith('_')) ||\n preservedKeys.includes(key)\n ) {\n (result as any)[key] = tree[key];\n }\n }\n }\n\n // Check if current key exists in tree\n if (!(currentKey in tree)) {\n return result;\n }\n\n const currentValue = tree[currentKey];\n\n // If this is the last key in path, include the full value\n if (remainingPath.length === 0) {\n if (Array.isArray(result)) {\n // For arrays, preserve the original index\n (result as any[])[currentKey as number] = currentValue;\n } else {\n (result as any)[currentKey] = currentValue;\n }\n } else {\n // Recursively isolate the remaining path, passing down preservedKeys\n const isolatedChild = isolate(currentValue, remainingPath, preservedKeys);\n\n // Only include the key if the isolated child has content\n const hasContent = Array.isArray(isolatedChild)\n ? isolatedChild.length > 0\n : Object.keys(isolatedChild).length > 0;\n\n if (hasContent || isolatedChild === null) {\n if (Array.isArray(result)) {\n // For arrays, preserve the original index\n (result as any[])[currentKey as number] = isolatedChild;\n } else {\n (result as any)[currentKey] = isolatedChild;\n }\n }\n }\n\n return result;\n};\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { Json } from '@rljson/json';\n\n/* v8 ignore next -- @preserve */\nexport const mergeTrees = (\n trees: {\n tree: Json;\n path: Array<string | number>;\n }[],\n): Json => {\n // Handle empty trees array\n if (!trees || trees.length === 0) {\n return {};\n }\n\n // First, merge all tree structures to preserve all properties along all paths\n let result: Json = {};\n\n for (const { tree } of trees) {\n if (tree != null) {\n result = mergeStructures(result, tree);\n }\n }\n\n // Extract values at each specified path\n const pathValues: { path: Array<string | number>; value: Json }[] = [];\n\n for (const { tree, path } of trees) {\n if (tree == null) continue;\n\n let current: any = tree;\n let pathExists = true;\n\n // Navigate through the path\n for (const key of path) {\n if (current == null || !(key in current)) {\n pathExists = false;\n break;\n }\n current = current[key];\n }\n\n // If we successfully navigated the path, store the path and value\n if (pathExists && current != null) {\n pathValues.push({ path, value: current });\n }\n }\n\n // Group values by their paths\n const pathGroups = new Map<string, Json[]>();\n\n for (const { path, value } of pathValues) {\n const pathKey = JSON.stringify(path);\n if (!pathGroups.has(pathKey)) {\n pathGroups.set(pathKey, []);\n }\n pathGroups.get(pathKey)!.push(value);\n }\n\n // Merge values for each unique path and set them in the result\n for (const [pathKey, values] of pathGroups) {\n const path = JSON.parse(pathKey) as Array<string | number>;\n\n // Merge all values at this path\n let mergedValue: Json | undefined = undefined;\n for (const value of values) {\n if (value == null) continue;\n\n if (mergedValue === undefined) {\n mergedValue = value;\n continue;\n }\n\n if (Array.isArray(mergedValue) && Array.isArray(value)) {\n mergedValue = [...mergedValue, ...value] as unknown as Json;\n } else if (!Array.isArray(mergedValue) && !Array.isArray(value)) {\n mergedValue = {\n ...(mergedValue as any),\n ...(value as any),\n } as unknown as Json;\n }\n // If types mismatch, keep the existing mergedValue\n }\n\n // Set the merged value at the path in the result\n let current: any = result;\n for (let i = 0; i < path.length - 1; i++) {\n const key = path[i];\n if (current == null || !(key in current)) {\n // Path doesn't exist in result, create it\n current[key] = typeof path[i + 1] === 'number' ? [] : {};\n }\n current = current[key];\n }\n\n if (path.length > 0) {\n current[path[path.length - 1]] = mergedValue;\n }\n }\n\n return result;\n};\n\n// Helper function to recursively merge two tree structures\n/* v8 ignore next -- @preserve */\nfunction mergeStructures(target: Json, source: Json): Json {\n if (source == null) return target;\n if (target == null) return source;\n\n // If both are arrays, merge them\n if (Array.isArray(target) && Array.isArray(source)) {\n const result = [...target];\n for (let i = 0; i < source.length; i++) {\n if (result[i] === undefined) {\n result[i] = source[i];\n } else {\n result[i] = mergeStructures(result[i], source[i]);\n }\n }\n return result as unknown as Json;\n }\n\n // If both are objects, merge their properties\n if (\n typeof target === 'object' &&\n typeof source === 'object' &&\n !Array.isArray(target) &&\n !Array.isArray(source) &&\n target !== null &&\n source !== null\n ) {\n const result = { ...target } as any;\n\n for (const key in source) {\n if (key in result) {\n result[key] = mergeStructures(result[key], (source as any)[key]);\n } else {\n result[key] = (source as any)[key];\n }\n }\n\n return result;\n }\n\n // For primitive values or type mismatches, return source\n return source;\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { Hash, hip } from '@rljson/hash';\nimport { ColumnCfgWithRoute, Ref, Route } from '@rljson/rljson';\n\n\nexport type ColumnRoute = string | string[] | number;\n\nexport interface ColumnInfo extends ColumnCfgWithRoute {\n alias: string;\n routeHash?: Ref;\n index?: number;\n value?: any;\n}\n\nexport class ColumnSelection {\n constructor(columns: ColumnInfo[]) {\n this._throwOnWrongAlias(columns);\n\n this.routes = columns.map((column) => column.route);\n this.routeHashes = this.routes.map(ColumnSelection.calcHash);\n\n this.aliases = columns.map((column) => column.alias);\n this.columns = this._initColumns(columns);\n\n ColumnSelection.check(this.aliases, this.routes);\n }\n\n // ...........................................................................\n /**\n * Returns unique routes from a list of routes\n * @param routes - The list of routes\n * @returns Unique routes\n */\n static uniqueRoutes(routes: Route[]): Route[] {\n return Array.from(new Set(routes.map((r) => r.flat))).map((flat) =>\n Route.fromFlat(flat),\n );\n }\n\n // ...........................................................................\n /**\n * Returns a ColumnSelection from a list of route segments\n * @param routeSegmentsList - A list of route segments\n * @returns A ColumnSelection object\n */\n static fromRoutes(routes: Route[]): ColumnSelection {\n const definition: ColumnInfo[] = [];\n const aliasCountMap: Record<string, number> = {};\n\n for (const route of this.uniqueRoutes(routes)) {\n const alias = route.root.tableKey;\n let uniqueAlias = alias;\n const aliasCount = aliasCountMap[alias] ?? 0;\n if (aliasCount > 0) {\n uniqueAlias = `${alias}${aliasCount}`;\n }\n aliasCountMap[alias] = aliasCount + 1;\n\n definition.push({\n key: uniqueAlias,\n type: 'jsonValue',\n alias: uniqueAlias,\n route: route.flat.slice(1),\n titleLong: '',\n titleShort: '',\n });\n }\n\n return new ColumnSelection(definition);\n }\n\n // ...........................................................................\n readonly columns: ColumnInfo[];\n readonly routes: string[];\n readonly aliases: string[];\n\n readonly routeHashes: string[];\n\n metadata(key: string): any[] {\n return this.columns.map((column) => column[key]);\n }\n\n // ...........................................................................\n static merge(columnSelections: ColumnSelection[]): ColumnSelection {\n //Flatten all routes from all selections\n const routes = columnSelections.map((selection) => selection.routes).flat();\n\n //Store strings here, because Set does not allow duplicates (on basic types)\n const routesWithoutDuplicates = Array.from(new Set(routes));\n\n //Create Route objects from flat (unique) strings\n return ColumnSelection.fromRoutes(\n routesWithoutDuplicates.map((route) => Route.fromFlat(route)),\n );\n }\n\n // ...........................................................................\n static calcHash(str: string): string {\n return Hash.default.calcHash(str);\n }\n\n route(aliasRouteOrHash: ColumnRoute): string {\n return this.column(aliasRouteOrHash).route;\n }\n\n // ...........................................................................\n alias(aliasRouteOrHash: ColumnRoute): string {\n return this.column(aliasRouteOrHash).alias;\n }\n\n // ...........................................................................\n columnIndex(\n hashAliasOrRoute: ColumnRoute,\n throwIfNotExisting: boolean = true,\n ): number {\n if (typeof hashAliasOrRoute === 'number') {\n return hashAliasOrRoute;\n }\n\n const str = Array.isArray(hashAliasOrRoute)\n ? hashAliasOrRoute.join('/')\n : hashAliasOrRoute;\n\n const hashIndex = this.routeHashes.indexOf(str);\n if (hashIndex >= 0) {\n return hashIndex;\n }\n\n const aliasIndex = this.aliases.indexOf(str);\n if (aliasIndex >= 0) {\n return aliasIndex;\n }\n\n const routeIndex = this.routes.indexOf(str);\n\n if (routeIndex < 0) {\n if (throwIfNotExisting) {\n throw new Error(`Unknown column alias or route: ${str}`);\n }\n return -1;\n }\n\n return routeIndex;\n }\n\n /***\n * Returns the column config for a specific alias, route or hash.\n */\n column(aliasRouteOrHash: ColumnRoute): ColumnInfo {\n const index = this.columnIndex(aliasRouteOrHash);\n return this.columns[index];\n }\n\n // ...........................................................................\n get count(): number {\n return this.aliases.length;\n }\n\n // ...........................................................................\n addedColumns(columnSelection: ColumnSelection): string[] {\n const a = this.routes.filter(\n (route) => !columnSelection.routes.includes(route),\n );\n\n return a;\n }\n\n // ...........................................................................\n static check(aliases: string[], routes: string[]) {\n // Make shure all keys are lowercase camel case\n // Numbers are not allowed at the beginning\n const camelCaseRegex = /^[a-z][a-zA-Z0-9]*$/;\n const invalidKeys = aliases.filter((key) => !camelCaseRegex.test(key));\n if (invalidKeys.length > 0) {\n throw new Error(\n `Invalid alias \"${invalidKeys[0]}\". ` +\n 'Aliases must be lower camel case.',\n );\n }\n\n // Values must only be letters, numbers and slashes\n const validValueRegex = /^[a-zA-Z0-9/]*$/;\n const invalidValues = routes.filter(\n (value) => !validValueRegex.test(value),\n );\n if (invalidValues.length > 0) {\n throw new Error(\n `Invalid route \"${invalidValues}\". ` +\n 'Routes must only contain letters, numbers and slashes.',\n );\n }\n\n // All path parts must be lower camel case\n const pathParts = routes.map((value) => value.split('/')).flat();\n const invalidPathParts = pathParts.filter(\n (part) => !camelCaseRegex.test(part),\n );\n\n if (invalidPathParts.length > 0) {\n throw new Error(\n `Invalid route segment \"${invalidPathParts[0]}\". ` +\n 'Route segments must be lower camel case.',\n );\n }\n\n // Routes must not occur more than once\n const routeCountMap: Record<string, number> = {};\n routes.forEach((value) => {\n routeCountMap[value] = (routeCountMap[value] ?? 0) + 1;\n });\n\n const duplicateRoutes = Object.entries(routeCountMap)\n .filter(([, count]) => count > 1)\n .map(([route]) => route);\n\n if (duplicateRoutes.length > 0) {\n throw new Error(\n `Duplicate route ${duplicateRoutes[0]}. A column must only occur once.`,\n );\n }\n }\n\n // ######################\n // Private\n // ######################\n\n private _throwOnWrongAlias(columns: ColumnInfo[]): void {\n const aliases = new Set<string>();\n for (const column of columns) {\n if (aliases.has(column.alias)) {\n throw new Error(`Duplicate alias: ${column.alias}`);\n }\n aliases.add(column.alias);\n }\n }\n\n private _initColumns(columns: ColumnInfo[]): ColumnInfo[] {\n let i = 0;\n return columns.map((column) =>\n hip({\n ...column,\n routeHash: this.routeHashes[i],\n index: i++,\n _hash: '',\n }),\n );\n }\n\n // ######################\n // Example\n // ######################\n\n static example(): ColumnSelection {\n return new ColumnSelection([\n {\n key: 'stringCol',\n alias: 'stringCol',\n route: 'basicTypes/stringsRef/value',\n type: 'string',\n titleLong: 'String values',\n titleShort: 'Strings',\n },\n {\n key: 'intCol',\n alias: 'intCol',\n route: 'basicTypes/numbersRef/intsRef/value',\n type: 'number',\n titleLong: 'Int values',\n titleShort: 'Ints',\n },\n {\n key: 'floatCol',\n alias: 'floatCol',\n route: 'basicTypes/numbersRef/floatsRef/value',\n type: 'number',\n titleLong: 'Float values',\n titleShort: 'Floats',\n },\n {\n key: 'booleanCol',\n alias: 'booleanCol',\n route: 'basicTypes/booleansRef/value',\n type: 'boolean',\n titleLong: 'Boolean values',\n titleShort: 'Booleans',\n },\n {\n key: 'jsonObjectCol',\n alias: 'jsonObjectCol',\n route: 'complexTypes/jsonObjectsRef/value',\n type: 'json',\n titleLong: 'Json objects',\n titleShort: 'JO',\n },\n {\n key: 'jsonArrayCol',\n alias: 'jsonArrayCol',\n route: 'complexTypes/jsonArraysRef/value',\n type: 'jsonArray',\n titleLong: 'Array values',\n titleShort: 'JA',\n },\n {\n key: 'jsonValueCol',\n alias: 'jsonValueCol',\n route: 'complexTypes/jsonValuesRef/value',\n type: 'jsonValue',\n titleLong: 'Json values',\n titleShort: 'JV',\n },\n ]);\n }\n\n static exampleBroken(): ColumnInfo[] {\n return [\n {\n key: 'stringCol',\n alias: 'stringCol',\n route: 'basicTypes/stringsRef/value',\n type: 'string',\n titleLong: 'String values',\n titleShort: 'Strings',\n },\n {\n key: 'stringCol2',\n alias: 'stringCol', // ⚠️ Duplicate alias\n route: 'basicTypes/stringsRef/value',\n type: 'string',\n titleLong: 'String values',\n titleShort: 'Strings',\n },\n ];\n }\n\n static exampleCarsColumnSelection(): ColumnSelection {\n return new ColumnSelection([\n {\n key: 'brand',\n route: 'carCake/carGeneralLayer/carGeneral/brand',\n alias: 'brand',\n titleLong: 'Car Brand',\n titleShort: 'Brand',\n type: 'string',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'type',\n route: 'carCake/carGeneralLayer/carGeneral/type',\n alias: 'type',\n titleLong: 'Car Type',\n titleShort: 'Type',\n type: 'string',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'serviceIntervals',\n route: 'carCake/carGeneralLayer/carGeneral/serviceIntervals',\n alias: 'serviceIntervals',\n titleLong: 'Car Service Intervals',\n titleShort: 'Service Intervals',\n type: 'jsonValue',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'isElectric',\n route: 'carCake/carGeneralLayer/carGeneral/isElectric',\n alias: 'isElectric',\n titleLong: 'Is Electric Car',\n titleShort: 'Electric',\n type: 'boolean',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'carDimensions/height',\n route: 'carCake/carTechnicalLayer/carTechnical/carDimensions/height',\n alias: 'height',\n titleLong: 'Car Height',\n titleShort: 'Height',\n type: 'number',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'carDimensions/width',\n route: 'carCake/carTechnicalLayer/carTechnical/carDimensions/width',\n alias: 'width',\n titleLong: 'Car Width',\n titleShort: 'Width',\n type: 'number',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'carDimensions/length',\n route: 'carCake/carTechnicalLayer/carTechnical/carDimensions/length',\n alias: 'length',\n titleLong: 'Car Length',\n titleShort: 'Length',\n type: 'number',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'engine',\n route: 'carCake/carTechnicalLayer/carTechnical/engine',\n alias: 'engine',\n titleLong: 'Car Engine',\n titleShort: 'Engine',\n type: 'string',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'repairedByWorkshop',\n route: 'carCake/carTechnicalLayer/carTechnical/repairedByWorkshop',\n alias: 'repairedByWorkshop',\n titleLong: 'Was Repaired By Workshop',\n titleShort: 'Repaired By Workshop',\n type: 'boolean',\n _hash: '',\n } as ColumnInfo,\n ]);\n }\n\n static exampleCarsDeeplyNestedColumnSelection(): ColumnSelection {\n return new ColumnSelection([\n {\n key: 'brand',\n route:\n 'catalogCake/catalogSeriesLayer/catalogSeries/seriesCake/seriesCarsLayer/seriesCars/carCake/carGeneralLayer/carGeneral/brand',\n alias: 'brand',\n titleLong: 'Car Brand',\n titleShort: 'Brand',\n type: 'string',\n _hash: '',\n } as ColumnInfo,\n ]);\n }\n\n static exampleCarsColumnSelectionOnlySomeColumns(): ColumnSelection {\n return new ColumnSelection([\n {\n key: 'brand',\n route: 'carCake/carGeneralLayer/carGeneral/brand',\n alias: 'brand',\n titleLong: 'Car Brand',\n titleShort: 'Brand',\n type: 'string',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'type',\n route: 'carCake/carGeneralLayer/carGeneral/type',\n alias: 'type',\n titleLong: 'Car Type',\n titleShort: 'Type',\n type: 'string',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'serviceIntervals',\n route: 'carCake/carGeneralLayer/carGeneral/serviceIntervals',\n alias: 'serviceIntervals',\n titleLong: 'Car Service Intervals',\n titleShort: 'Service Intervals',\n type: 'jsonValue',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'isElectric',\n route: 'carCake/carGeneralLayer/carGeneral/isElectric',\n alias: 'isElectric',\n titleLong: 'Is Electric Car',\n titleShort: 'Electric',\n type: 'boolean',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'carDimensions/length',\n route: 'carCake/carTechnicalLayer/carTechnical/carDimensions/length',\n alias: 'length',\n titleLong: 'Car Length',\n titleShort: 'Length',\n type: 'number',\n _hash: '',\n } as ColumnInfo,\n ]);\n }\n\n // ...........................................................................\n static empty(): ColumnSelection {\n return new ColumnSelection([]);\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { hip } from '@rljson/hash';\n\nimport { BoolOperator } from './boolean-filter-processor.ts';\nimport { ColumnFilter } from './column-filter.ts';\n\nexport interface BooleanFilter extends ColumnFilter<boolean> {\n type: 'boolean';\n operator: BoolOperator;\n}\n\nexport const trueValues = ['t', 'j', 'y'];\nexport const falseValues = ['n', 'f'];\n\n/**\n * Parses a boolean search\n * @param search The search value to be parsed\n * @returns the parse result\n */\nexport const parseBooleanSearch = (search: any): boolean | null => {\n if (typeof search == 'undefined' || search == null) {\n return null;\n }\n\n if (typeof search == 'boolean') {\n return search;\n }\n\n if (typeof search == 'number') {\n return search != 0;\n }\n\n if (typeof search == 'string') {\n const val = search.toLowerCase();\n\n for (const trueValue of trueValues) {\n if (val.startsWith(trueValue)) {\n return true;\n }\n }\n\n for (const falseValue of falseValues) {\n if (val.startsWith(falseValue)) {\n return false;\n }\n }\n\n const containsOnlyNumbers = /^\\d+$/.test(search);\n /* v8 ignore if -- @preserve */\n if (containsOnlyNumbers) {\n return parseInt(search) != 0;\n }\n }\n\n return false;\n};\n\n// ..............................................................................\n\nexport const exampleBooleanFilter = (): BooleanFilter =>\n hip<BooleanFilter>({\n column: 'basicTypes/booleansRef/value',\n operator: 'equals',\n type: 'boolean',\n search: true,\n _hash: '',\n });\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport {\n BooleanFilter,\n exampleBooleanFilter,\n parseBooleanSearch,\n} from './boolean-filter.ts';\nimport { ColumnFilterProcessor } from './column-filter-processor.ts';\n\nexport class BooleanFilterProcessor implements ColumnFilterProcessor {\n constructor(\n public readonly operator: BoolOperator,\n\n search: boolean | string | number | null,\n ) {\n this.search =\n search === null\n ? null\n : typeof search === 'boolean'\n ? search\n : parseBooleanSearch(search);\n }\n\n search: boolean | null;\n\n // ...........................................................................\n static fromModel(model: BooleanFilter): BooleanFilterProcessor {\n return new BooleanFilterProcessor(model.operator, model.search);\n }\n\n // ...........................................................................\n equals(other: ColumnFilterProcessor): boolean {\n return (\n other instanceof BooleanFilterProcessor &&\n this.operator === other.operator &&\n this.search === other.search\n );\n }\n\n // ...........................................................................\n static readonly allOperators: BoolOperator[] = ['equals', 'notEquals'];\n\n // ...........................................................................\n matches(cellValue: any): boolean {\n if (this.search === null || this.search === undefined) {\n return true;\n }\n\n if (cellValue === null || cellValue === undefined) {\n return false;\n }\n\n if (typeof cellValue == 'number') {\n cellValue = cellValue != 0;\n }\n\n if (typeof cellValue == 'string') {\n const val = cellValue.toLowerCase();\n cellValue = val === 'true' || val === 'yes' || '1';\n }\n\n switch (this.operator) {\n case 'equals':\n return cellValue === this.search;\n case 'notEquals':\n return cellValue !== this.search;\n }\n }\n\n // ...........................................................................\n static get example(): BooleanFilterProcessor {\n const model: BooleanFilter = exampleBooleanFilter();\n const filterProcessor = BooleanFilterProcessor.fromModel(model);\n return filterProcessor;\n }\n}\n\nexport type BoolOperator = 'equals' | 'notEquals';\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { hip } from '@rljson/hash';\n\nimport { ColumnFilter } from './column-filter.ts';\nimport { NumberOperator } from './number-filter-processor.ts';\n\nexport interface NumberFilter extends ColumnFilter<number> {\n type: 'number';\n operator: NumberOperator;\n}\n\n// ..............................................................................\n\nexport const exampleNumberFilter = (): NumberFilter =>\n hip<NumberFilter>({\n column: 'basicTypes/numbersRef/intsRef/value',\n operator: 'greaterThanOrEquals',\n type: 'number',\n search: 1000,\n _hash: '',\n });\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { compileExpression } from 'filtrex';\n\nimport { ColumnFilterProcessor } from './column-filter-processor.ts';\nimport { exampleNumberFilter, NumberFilter } from './number-filter.ts';\n\n// #############################################################################\nexport class NumberFilterProcessor implements ColumnFilterProcessor {\n constructor(\n public readonly operator: NumberOperator,\n\n search: number | string,\n ) {\n if (operator === 'filtrex') {\n this.search = search;\n this._initFiltrex();\n } else {\n this.search = typeof search == 'string' ? parseFloat(search) : search;\n }\n }\n\n // ...........................................................................\n static fromModel(model: NumberFilter): NumberFilterProcessor {\n return new NumberFilterProcessor(model.operator, model.search);\n }\n\n equals(other: ColumnFilterProcessor): boolean {\n return (\n other instanceof NumberFilterProcessor &&\n this.operator === other.operator &&\n this.search === other.search\n );\n }\n\n // ...........................................................................\n static readonly allOperators: NumberOperator[] = [\n 'equals',\n 'notEquals',\n 'greaterThan',\n 'greaterThanOrEquals',\n 'lessThan',\n 'lessThanOrEquals',\n 'filtrex',\n ];\n\n // ...........................................................................\n matches(cellValue: any): boolean {\n if (!this.search && this.search !== 0) {\n return true;\n }\n\n if (cellValue === null || cellValue === undefined) {\n return false;\n }\n\n switch (this.operator) {\n case 'equals':\n return cellValue === this.search;\n case 'notEquals':\n return cellValue !== this.search;\n case 'greaterThan':\n return cellValue > this.search;\n case 'lessThan':\n return cellValue < this.search;\n case 'greaterThanOrEquals':\n return cellValue >= this.search;\n case 'lessThanOrEquals':\n return cellValue <= this.search;\n case 'filtrex':\n return this?._evalExpression(cellValue);\n }\n }\n\n search: number | string = '';\n\n static get example(): NumberFilterProcessor {\n return NumberFilterProcessor.fromModel(exampleNumberFilter());\n }\n\n // ######################\n // Private\n // ######################\n\n private _expression: any = null;\n\n // ..........................................................................\n private _initFiltrex() {\n // If search is empty, no expression is needed\n if (this.search === '') {\n return;\n }\n\n // If search is a number, we can use it directly\n if (typeof this.search === 'number') {\n return;\n }\n\n // Check if this contains only numbers\n const isNumber = /^\\d+$/.test(this.search);\n if (isNumber) {\n this.search = parseInt(this.search);\n return;\n }\n\n // Try to compile the expression\n try {\n this._expression = compileExpression(this.search);\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (_) {\n // As long as the expression is not valid,\n // the searched value must equal the cell value\n this._expression = '';\n }\n }\n\n // ...........................................................................\n private _evalExpression(cellValue: any): boolean {\n return this._expression\n ? // result can also contain errors which could be sent to the outside here\n this._expression({ v: cellValue }) == true\n : cellValue == this.search;\n }\n}\n\nexport type NumberOperator =\n | 'equals'\n | 'notEquals'\n | 'greaterThan'\n | 'greaterThanOrEquals'\n | 'lessThan'\n | 'lessThanOrEquals'\n | 'filtrex';\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { hip } from '@rljson/hash';\n\nimport { ColumnFilter } from './column-filter.ts';\nimport { StringOperator } from './string-filter-processor.ts';\n\nexport interface StringFilter extends ColumnFilter<string> {\n type: 'string';\n operator: StringOperator;\n matchCase?: boolean;\n}\n\n// ..............................................................................\n\nexport const exampleStringFilter = (): StringFilter =>\n hip<StringFilter>({\n type: 'string',\n column: 'basicTypes/stringsRef/value',\n operator: 'startsWith',\n search: 't',\n matchCase: false,\n _hash: '',\n });\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { ColumnFilterProcessor } from './column-filter-processor.ts';\nimport { exampleStringFilter, StringFilter } from './string-filter.ts';\n\nexport class StringFilterProcessor implements ColumnFilterProcessor {\n constructor(\n public readonly operator: StringOperator,\n\n search: string,\n public readonly matchCase: boolean = false,\n ) {\n this.search = (matchCase ? search : search.toLowerCase()).replaceAll(\n ' ',\n '',\n );\n\n /* v8 ignore start */\n try {\n this.regExp = operator === 'regExp' ? new RegExp(search) : null;\n } catch {}\n /* v8 ignore stop */\n }\n\n // ...........................................................................\n static fromModel(model: StringFilter): StringFilterProcessor {\n return new StringFilterProcessor(\n model.operator,\n model.search,\n model.matchCase,\n );\n }\n\n // ...........................................................................\n search: string;\n regExp: RegExp | null = null;\n\n // ...........................................................................\n equals(other: ColumnFilterProcessor): boolean {\n return (\n other instanceof StringFilterProcessor &&\n this.operator === other.operator &&\n this.search === other.search &&\n this.matchCase === other.matchCase\n );\n }\n\n // ...........................................................................\n static readonly allOperators: StringOperator[] = [\n 'contains',\n 'equals',\n 'notEquals',\n 'startsWith',\n 'notContains',\n 'endsWith',\n 'regExp',\n ];\n\n // ...........................................................................\n matches(cellValue: any): boolean {\n if (!this.search) {\n return true;\n }\n\n if (cellValue === null || cellValue === undefined) {\n return false;\n }\n\n if (typeof cellValue !== 'string') {\n cellValue = `${cellValue}`;\n }\n\n if (!this.matchCase) {\n cellValue = cellValue.toLowerCase();\n }\n\n cellValue = cellValue.replaceAll(' ', '');\n\n switch (this.operator) {\n case 'equals':\n return cellValue === this.search;\n case 'notEquals':\n return cellValue !== this.search;\n case 'startsWith':\n return cellValue.startsWith(this.search);\n case 'contains':\n return cellValue.includes(this.search);\n case 'endsWith':\n return cellValue.endsWith(this.search);\n /* v8 ignore next -- @preserve */\n case 'regExp':\n return this.regExp?.test(cellValue) ?? false;\n\n case 'notContains':\n return !cellValue.includes(this.search);\n }\n }\n\n // ...........................................................................\n static get example(): StringFilterProcessor {\n const result = StringFilterProcessor.fromModel(exampleStringFilter());\n return result;\n }\n}\n\nexport type StringOperator =\n | 'startsWith'\n | 'contains'\n | 'endsWith'\n | 'equals'\n | 'notEquals'\n | 'notContains'\n | 'regExp';\n","/* eslint-disable @typescript-eslint/no-unused-vars */\n\n// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { BooleanFilterProcessor } from './boolean-filter-processor.ts';\nimport { BooleanFilter } from './boolean-filter.ts';\nimport { ColumnFilter } from './column-filter.ts';\nimport { NumberFilterProcessor } from './number-filter-processor.ts';\nimport { NumberFilter } from './number-filter.ts';\nimport { StringFilterProcessor } from './string-filter-processor.ts';\nimport { StringFilter } from './string-filter.ts';\n\nexport class ColumnFilterProcessor {\n /* v8 ignore next -- @preserve */\n matches(_cellValue: string): boolean {\n /* v8 ignore next -- @preserve */\n return true;\n }\n\n equals(_other: ColumnFilterProcessor): boolean {\n return this === _other;\n }\n\n // ...........................................................................\n static fromModel(model: ColumnFilter<any>): ColumnFilterProcessor {\n switch (model.type) {\n case 'string':\n return StringFilterProcessor.fromModel(model as StringFilter);\n case 'number':\n return NumberFilterProcessor.fromModel(model as NumberFilter);\n case 'boolean':\n return BooleanFilterProcessor.fromModel(model as BooleanFilter);\n /* v8 ignore next -- @preserve */\n default:\n return StringFilterProcessor.fromModel(model as StringFilter);\n }\n }\n\n // ...........................................................................\n /* v8 ignore stop */\n static operatorsForType(type: string): string[] {\n switch (type) {\n case 'string':\n return StringFilterProcessor.allOperators;\n case 'number':\n return NumberFilterProcessor.allOperators;\n case 'boolean':\n return BooleanFilterProcessor.allOperators;\n default:\n return StringFilterProcessor.allOperators;\n }\n }\n\n static translationsForType(type: string, language: 'de' | 'en'): string[] {\n const operators = ColumnFilterProcessor.operatorsForType(type);\n const translations = [];\n\n for (const operator of operators) {\n translations.push(\n ColumnFilterProcessor.translateOperator(operator, language),\n );\n }\n\n return translations;\n }\n\n static translateOperator(operator: string, language: 'de' | 'en') {\n const translations: Record<string, Record<string, string>> = {\n equals: { en: 'Equals', de: 'Gleich' },\n notEquals: { en: 'Not equals', de: 'Ungleich' },\n greaterThan: { en: 'Greater than', de: 'Größer' },\n greaterThanOrEquals: {\n en: 'Greater than or Equals',\n de: 'Größer oder gleich',\n },\n lessThan: { en: 'Less than', de: 'Kleiner als' },\n lessThanOrEquals: {\n en: 'Less than or equals',\n de: 'Kleiner gleich',\n },\n startsWith: { en: 'Starts with', de: 'Beginnt mit' },\n contains: { en: 'Contains', de: 'Enthält' },\n notContains: { en: 'Not contains', de: 'Enthält nicht' },\n endsWith: { en: 'Ends with', de: 'Endet mit' },\n regExp: { en: 'Regular expression', de: 'Regulärer Ausdruck' },\n filtrex: { en: 'Expression', de: 'Ausdruck' },\n };\n\n return translations[operator][language];\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { Route } from '@rljson/rljson';\n\nimport { Join, JoinRowsHashed } from '../join.ts';\nimport { ColumnSelection } from '../selection/column-selection.ts';\n\nimport { ColumnFilterProcessor } from './column-filter-processor.ts';\nimport { RowFilter } from './row-filter.ts';\n\n// #############################################################################\nexport class RowFilterProcessor {\n // ...........................................................................\n constructor(\n columnFilters: Record<string, ColumnFilterProcessor>,\n public readonly operator: 'and' | 'or' = 'and',\n ) {\n this._columnFilters = this._initColumnFilters(columnFilters);\n }\n\n // ...........................................................................\n static fromModel(model: RowFilter) {\n const operator = model.operator;\n const columnFilters: Record<string, ColumnFilterProcessor> = {};\n for (const columnFilter of model.columnFilters) {\n const key = columnFilter.column;\n const processor = ColumnFilterProcessor.fromModel(columnFilter);\n columnFilters[key] = processor;\n }\n\n return new RowFilterProcessor(columnFilters, operator);\n }\n\n // ...........................................................................\n get processors(): ColumnFilterProcessor[] {\n return Object.values(this._columnFilters).map((item) => item.processor);\n }\n\n // ...........................................................................\n /// Returns an empty filter\n static get empty(): RowFilterProcessor {\n return new RowFilterProcessor({}, 'and');\n }\n\n // ...........................................................................\n /// Checks if two filters are equal\n equals(other: RowFilterProcessor): boolean {\n if (this.operator !== other.operator) {\n return false;\n }\n\n const thisKeys = Object.keys(this._columnFilters);\n const otherKeys = Object.keys(other._columnFilters);\n\n if (thisKeys.length !== otherKeys.length) {\n return false;\n }\n\n for (const key of thisKeys) {\n const a = this._columnFilters[key];\n const b = other._columnFilters[key];\n if (a?.processor.equals(b?.processor) === false) {\n return false;\n }\n }\n\n return true;\n }\n\n // ...........................................................................\n applyTo(join: Join): JoinRowsHashed {\n if (join.rowCount === 0) {\n return join.data;\n }\n\n // Throw when filter specifies non existent column routes\n this._throwOnWrongRoutes(join.columnSelection);\n\n // Generate an array of filters\n const columnCount = join.columnCount;\n const columnHashes = join.columnSelection.routeHashes;\n\n const filterArray: ColumnFilterProcessor[] = new Array(columnCount).fill(\n null,\n );\n\n let hasFilters = false;\n for (let c = 0; c < columnCount; c++) {\n const hash = columnHashes[c];\n const filter = this._columnFilters[hash];\n if (filter) {\n filterArray[c] = filter.processor;\n hasFilters = true;\n }\n }\n\n // No filters set? Return unchanged indices.\n if (!hasFilters) {\n return join.data;\n }\n\n // Apply the filters\n let rowIndices: number[] = [];\n switch (this.operator) {\n case 'and':\n rowIndices = this._filterRowsAnd(join, filterArray);\n break;\n case 'or':\n rowIndices = this._filterRowsOr(join, filterArray);\n break;\n }\n\n // Build the resulting data\n const result: JoinRowsHashed = {};\n const rowIndexSet = new Set(rowIndices);\n let idx = 0;\n for (const [sliceId, row] of Object.entries(join.data)) {\n if (rowIndexSet.has(idx)) {\n result[sliceId] = row;\n }\n idx++;\n }\n return result;\n }\n\n // ######################\n // Private\n // ######################\n\n // ...........................................................................\n private readonly _columnFilters: Record<string, _ColumnFilterItem>;\n\n // ...........................................................................\n private _initColumnFilters(\n columnFilters: Record<string, ColumnFilterProcessor>,\n ) {\n const result: Record<string, _ColumnFilterItem> = {};\n\n const columnKeys = Object.keys(columnFilters);\n const columnRoutes = columnKeys.map((k) => Route.fromFlat(k));\n const columnSelection = ColumnSelection.fromRoutes(columnRoutes);\n\n const { routeHashes, routes } = columnSelection;\n\n for (let i = 0; i < routeHashes.length; i++) {\n const routeHash = routeHashes[i];\n const route = routes[i];\n const processor = columnFilters[route]!;\n\n result[routeHash] = {\n processor,\n routeHash,\n route,\n };\n }\n\n return result;\n }\n\n // ...........................................................................\n private _filterRowsAnd(\n join: Join,\n filters: ColumnFilterProcessor[],\n ): number[] {\n // Fill the array with all row indices\n const rowCount = join.rowCount;\n let remainingIndices: number[] = new Array(rowCount);\n for (let i = 0; i < rowCount; i++) {\n remainingIndices[i] = i;\n }\n\n const columnCount = join.columnCount;\n\n for (let c = 0; c < columnCount; c++) {\n remainingIndices = this._filterColumnAnd(\n join,\n c,\n remainingIndices,\n filters,\n );\n }\n\n return remainingIndices;\n }\n\n // ...........................................................................\n private _filterColumnAnd(\n join: Join,\n columnIndex: number,\n remainingIndices: number[],\n filters: ColumnFilterProcessor[],\n ): number[] {\n const result: number[] = [];\n const filter = filters[columnIndex];\n if (filter == null) {\n return remainingIndices;\n }\n\n for (const i of remainingIndices) {\n const cellValues = join.value(i, columnIndex);\n\n for (const cellValue of cellValues) {\n if (filter.matches(cellValue as string)) {\n result.push(i);\n }\n }\n }\n\n return result;\n }\n\n // ...........................................................................\n private _filterRowsOr(\n join: Join,\n filters: ColumnFilterProcessor[],\n ): number[] {\n // Fill the array with all row indices\n const applyTo: boolean[] = new Array(join.rowCount).fill(false);\n\n const columnCount = join.columnCount;\n\n for (let c = 0; c < columnCount; c++) {\n this._filterColumnOr(join, c, applyTo, filters);\n }\n\n let rowCount = 0;\n for (let r = 0; r < applyTo.length; r++) {\n if (applyTo[r]) {\n rowCount++;\n }\n }\n\n const result: number[] = new Array(rowCount);\n let resultIndex = 0;\n for (let r = 0; r < applyTo.length; r++) {\n if (applyTo[r]) {\n result[resultIndex] = r;\n resultIndex++;\n }\n }\n\n return result;\n }\n\n // ...........................................................................\n private _filterColumnOr(\n join: Join,\n columnIndex: number,\n applyTo: boolean[],\n filters: ColumnFilterProcessor[],\n ) {\n const filter = filters[columnIndex];\n if (filter == null) {\n return;\n }\n\n for (let r = 0; r < join.rowCount; r++) {\n if (applyTo[r]) {\n continue;\n }\n\n const cellValues = join.value(r, columnIndex);\n\n for (const cellValue of cellValues) {\n if (filter.matches(cellValue as string)) {\n applyTo[r] = true;\n }\n }\n }\n }\n\n // ...........................................................................\n private _throwOnWrongRoutes(columnSelection: ColumnSelection) {\n const availableRoutes = columnSelection.routes;\n for (const item of Object.values(this._columnFilters)) {\n const route = item.route;\n if (availableRoutes.includes(route) === false) {\n throw new Error(\n `RowFilterProcessor: Error while applying filter to join: ` +\n `There is a column filter for route \"${route}\", but the join ` +\n `does not have a column with this route.\\n\\nAvailable routes:\\n` +\n `${availableRoutes.map((a) => `- ${a}`).join('\\n')}`,\n );\n }\n }\n }\n}\n\n// #############################################################################\ninterface _ColumnFilterItem {\n processor: ColumnFilterProcessor;\n routeHash: string;\n\n route: string;\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { Hash } from '@rljson/hash';\nimport { Json, JsonValue, JsonValueType } from '@rljson/json';\nimport { Ref, Route, SliceId } from '@rljson/rljson';\n\nimport { traverse } from 'object-traversal';\n\nimport { Container } from '../db.ts';\nimport { inject } from '../tools/inject.ts';\nimport { isolate } from '../tools/isolate.ts';\nimport { mergeTrees } from '../tools/merge-trees.ts';\n\nimport { RowFilterProcessor } from './filter/row-filter-processor.ts';\nimport { RowFilter } from './filter/row-filter.ts';\nimport { ColumnSelection } from './selection/column-selection.ts';\nimport { SetValue } from './set-value/set-value.ts';\nimport { RowSort } from './sort/row-sort.ts';\n\nexport const joinPreserveKeys = [\n 'sliceIdsTable',\n 'sliceIdsRow',\n /*'base',*/\n 'sliceIdsTable',\n 'sliceIdsTableRow',\n 'componentsTable',\n];\n\nexport type JoinProcessType = 'filter' | 'setValue' | 'selection' | 'sort';\n\nexport type JoinProcess = {\n type: JoinProcessType;\n instance: RowFilter | SetValue | ColumnSelection | RowSort;\n data: JoinRowsHashed;\n columnSelection: ColumnSelection;\n};\n\nexport interface JoinColumn {\n route: Route;\n value: Container;\n inserts: Container[] | null;\n}\n\nexport type JoinRow = JoinColumn[];\nexport type JoinRows = Record<SliceId, JoinRow>;\n\nexport type JoinRowHashed = {\n rowHash: Ref;\n columns: JoinColumn[];\n};\nexport type JoinRowsHashed = Record<SliceId, JoinRowHashed>;\n\nexport class Join {\n private _base: JoinRowsHashed = {};\n private _baseColumnSelection: ColumnSelection;\n\n private _processes: JoinProcess[] = [];\n\n constructor(rows: JoinRows, columnSelection: ColumnSelection) {\n // Hash the rows\n this._base = this._hashedRows(rows);\n\n this._baseColumnSelection = columnSelection;\n }\n\n // ...........................................................................\n /**\n * Applies a filter to the join and returns the filtered view\n *\n * @param filter The filter to apply\n */\n filter(filter: RowFilter): Join {\n const proc = RowFilterProcessor.fromModel(filter);\n\n const data = proc.applyTo(this);\n\n // Create the process entry\n const process: JoinProcess = {\n type: 'filter',\n instance: filter,\n data,\n columnSelection: this.columnSelection,\n };\n\n // Store the process\n this._processes.push(process);\n\n return this;\n }\n\n // ...........................................................................\n /**\n * Applies a set value action to the join and returns the edited join\n *\n * @param setValue The set value action to apply\n */\n setValue(setValue: SetValue): Join {\n const data: JoinRowsHashed = {};\n\n for (const [sliceId, joinRowH] of Object.entries(this.data)) {\n const cols = [...joinRowH.columns];\n const insertCols = [];\n for (const col of cols) {\n const insertCol = {\n ...col,\n //inserts: col.inserts ? [...col.inserts] : [],\n };\n\n /*v8 ignore else -- @preserve */\n if (Route.fromFlat(setValue.route).equalsWithoutRefs(col.route)) {\n for (const cell of col.value.cell) {\n /* v8 ignore next -- @preserve */\n if (cell.path.length === 0) {\n throw new Error(\n `Join: Error while applying SetValue: ` +\n `Cannot set value for column without paths. ` +\n `Route: ${setValue.route.toString()}.`,\n );\n }\n\n /* v8 ignore next -- @preserve */\n if (cell.path.length > 1) {\n throw new Error(\n `Join: Error while applying SetValue: ` +\n `Cannot set value for multiple paths in one cell. ` +\n `Found paths: [${cell.path.join(', ')}] for route: ` +\n `${setValue.route.toString()}.`,\n );\n }\n\n const cellInsertTree = isolate(\n { ...col.value.tree },\n cell.path[0],\n joinPreserveKeys,\n );\n inject(cellInsertTree, cell.path[0], setValue.value);\n\n const propertyKey = cell.path[0].slice(-1)[0];\n const insert: Container = {\n cell: [\n {\n ...cell,\n ...{ value: setValue.value },\n ...{\n row: {\n ...(cell.row as Json),\n ...{ [propertyKey]: setValue.value },\n } as any,\n },\n },\n ],\n tree: cellInsertTree,\n rljson: col.value.rljson,\n };\n\n /* v8 ignore next -- @preserve */\n if (insert) {\n if (insertCol.inserts) insertCol.inserts.push(insert);\n else insertCol.inserts = [insert];\n }\n }\n }\n insertCols.push(insertCol);\n }\n\n data[sliceId] = {\n rowHash: Hash.default.calcHash(\n insertCols.map((col) =>\n col.value.cell.flatMap((c) => c.value),\n ) as any[],\n ),\n columns: insertCols,\n };\n }\n\n // Create the process entry\n const process: JoinProcess = {\n type: 'setValue',\n instance: setValue,\n data,\n columnSelection: this.columnSelection,\n };\n\n // Store the process\n this._processes.push(process);\n\n return this;\n }\n\n // ...........................................................................\n /**\n * Applies multiple set value actions to the join and returns the edited join\n *\n * @param setValues The set value actions to apply\n */\n setValues(setValues: SetValue[]): Join {\n // Apply the set values one by one to a copy of this join\n let result: Join = this.clone();\n\n for (const setValue of setValues) {\n result = result.setValue(setValue);\n }\n\n return result;\n }\n\n // ...........................................................................\n /**\n * Selects columns from the join and returns the resulting join\n *\n * @param columnSelection The column selection to apply\n */\n select(columnSelection: ColumnSelection): Join {\n const columnCount = columnSelection.count;\n const masterColumnIndices = new Array(columnCount);\n\n // Map selected columns to master column indices\n let i = 0;\n for (const hash of columnSelection.routeHashes) {\n const index = this.columnSelection.columnIndex(hash);\n masterColumnIndices[i] = index;\n i++;\n }\n\n // Select the columns\n const data: JoinRowsHashed = {};\n for (let i = 0; i < this.rowCount; i++) {\n const [sliceId, row] = Object.entries(this.data)[i];\n const cols: JoinColumn[] = [];\n // Select only the requested columns\n for (let j = 0; j < masterColumnIndices.length; j++) {\n cols.push(row.columns[masterColumnIndices[j]]);\n }\n // Store the selected columns\n data[sliceId] = {\n rowHash: Hash.default.calcHash(\n cols.map((col) => col.value.cell.flatMap((c) => c.value)) as any[],\n ),\n columns: cols,\n };\n }\n\n // Create the process entry\n const process: JoinProcess = {\n type: 'selection',\n instance: columnSelection,\n data,\n columnSelection,\n };\n\n // Store the process\n this._processes.push(process);\n\n return this;\n }\n\n // ...........................................................................\n /**\n * Sorts the join rows and returns the sorted join\n *\n * @param rowSort The row sort to apply\n */\n sort(rowSort: RowSort): Join {\n const sortedIndices = rowSort.applyTo(this);\n\n const data: JoinRowsHashed = {};\n for (let i = 0; i < sortedIndices.length; i++) {\n const sliceId = sortedIndices[i];\n data[sliceId] = this.data[sliceId];\n }\n\n // Create the process entry\n const process: JoinProcess = {\n type: 'sort',\n instance: rowSort,\n data,\n columnSelection: this.columnSelection,\n };\n\n // Store the process\n this._processes.push(process);\n\n return this;\n }\n\n // ...........................................................................\n /**\n * Returns insert Object of the join\n */\n insert(): {\n route: Route;\n tree: Json;\n }[] {\n const inserts: {\n route: Route;\n tree: Json;\n }[] = [];\n\n for (let i = 0; i < this.columnCount; i++) {\n const colInserts: {\n route: Route;\n tree: Json;\n path: Array<string | number>;\n }[] = [];\n for (const row of Object.values(this.data)) {\n const col = row.columns[i];\n if (col.inserts && col.inserts.length > 0) {\n for (const insert of col.inserts) {\n for (const cell of insert.cell) {\n const tree = insert.tree;\n const path = cell.path;\n\n // Inject the value at the path, inject complete row\n inject(tree, path[0].slice(0, -1), cell.row);\n\n colInserts.push({\n route: col.route,\n tree,\n path: path[0],\n });\n }\n }\n }\n }\n\n if (colInserts.length === 0) continue;\n\n //Merge all insert trees into one\n const routes = colInserts.map((ins) => ins.route.flat);\n const uniqueRoute = Array.from(new Set(routes));\n\n /* v8 ignore if -- @preserve */\n if (uniqueRoute.length > 1) {\n throw new Error(\n `Join: Error while generating insert: ` +\n `Multiple different routes found in inserts: ` +\n `${uniqueRoute.map((r) => r.toString()).join(', ')}. ` +\n `Cannot generate single insert object.`,\n );\n }\n\n const merged = mergeTrees(\n colInserts.map((ins) => ({\n tree: ins.tree,\n path: ins.path.slice(0, -1),\n })),\n );\n\n //Delete _hash and filter null values from _data arrays\n traverse(merged, ({ parent, key, value }) => {\n if (key == '_hash') {\n //delete parent![key];\n }\n if (key == '_data' && Array.isArray(value) && value.length > 0) {\n parent![key] = value.filter((v) => !!v);\n }\n });\n\n inserts.push({\n route: Route.fromFlat(uniqueRoute[0]).toRouteWithProperty(),\n tree: merged,\n });\n }\n\n return inserts;\n }\n\n // ...........................................................................\n /**\n * Returns the value at the given row and column index\n *\n * @param row The row index\n * @param column The column index\n * @returns The value at the given row and column\n */\n value(row: number, column: number): JsonValue[] {\n return this.rows[row][column];\n }\n\n // ...........................................................................\n /**\n * Clones the join\n *\n * @returns The cloned join\n */\n clone(): Join {\n const cloned = Object.create(this);\n cloned._data = this._base;\n cloned._processes = [...this._processes];\n return cloned;\n }\n\n // ...........................................................................\n /**\n * Returns all component routes of the join\n */\n get componentRoutes(): Route[] {\n return Array.from(\n new Set(\n Object.values(this.columnSelection.columns).map(\n (c) => Route.fromFlat(c.route).upper().flatWithoutRefs,\n ),\n ),\n ).map((r) => Route.fromFlat(r));\n }\n\n // ...........................................................................\n /**\n * Returns all layer routes of the join\n */\n get layerRoutes(): Route[] {\n return Array.from(\n new Set(\n Object.values(this.columnSelection.columns)\n .map((c) => [\n Route.fromFlat(c.route).top,\n Route.fromFlat(c.route).deeper(1).top,\n ])\n .map((segments) => new Route(segments).flat),\n ),\n ).map((r) => Route.fromFlat(r));\n }\n\n // ...........................................................................\n /**\n * Returns the cake route of the join\n */\n get cakeRoute(): Route {\n const cakeRoute = Array.from(\n new Set(\n Object.values(this.columnSelection.columns).map(\n (c) => Route.fromFlat(c.route).top.tableKey,\n ),\n ),\n ).map((r) => Route.fromFlat(r));\n\n /* v8 ignore if -- @preserve */\n if (cakeRoute.length !== 1) {\n throw new Error(\n `Join: Error while getting cake route: ` +\n `The join has ${cakeRoute.length} different cake routes. ` +\n `Cannot determine a single cake route.`,\n );\n }\n return cakeRoute[0];\n }\n\n // ...........................................................................\n /**\n * Returns the number of rows in the join\n */\n get rowCount(): number {\n return Object.keys(this.data).length;\n }\n\n // ...........................................................................\n /**\n * Returns the number of columns in the join\n */\n get columnCount(): number {\n return this.columnSelection.count;\n }\n\n // ...........................................................................\n /**\n * Returns the row indices (sliceIds) of the join\n */\n get rowIndices(): SliceId[] {\n return Object.keys(this.data);\n }\n\n // ...........................................................................\n /**\n * Returns the join row for the given slice id\n *\n * @param sliceId - The slice id\n * @returns The join row\n */\n row(sliceId: SliceId): JoinRow {\n return this.data[sliceId].columns;\n }\n\n // ...........................................................................\n /**\n * Returns the data of the join\n */\n get data(): JoinRowsHashed {\n if (this._processes.length > 0) {\n return this._processes[this._processes.length - 1].data;\n }\n return this._base;\n }\n\n // ...........................................................................\n /**\n * Returns the column types of the join\n */\n get columnTypes(): JsonValueType[] {\n return this.columnSelection.columns.map((col) => col.type);\n }\n\n // ...........................................................................\n /**\n * Returns the column selection of the join\n */\n get columnSelection(): ColumnSelection {\n if (this._processes.length > 0) {\n return this._processes[this._processes.length - 1].columnSelection;\n }\n return this._baseColumnSelection;\n }\n\n // ...........................................................................\n /**\n * Returns all rows of the join w/ nulled missing values\n *\n * @return The rows of the join\n */\n get rows(): any[][] {\n const result: any[][] = [];\n const sliceIds = Object.keys(this.data);\n for (const sliceId of sliceIds) {\n const dataColumns = (this.data[sliceId] as JoinRowHashed).columns;\n const row: any[] = [];\n for (const colInfo of this.columnSelection.columns) {\n const joinCol = dataColumns.find((dataCol) => {\n const colInfoRoute = Route.fromFlat(colInfo.route);\n const dataColRoute = dataCol.route;\n\n return colInfoRoute.equalsWithoutRefs(dataColRoute);\n });\n /* v8 ignore next -- @preserve */\n const insertValue =\n joinCol && joinCol.inserts\n ? joinCol.inserts.flatMap((con) =>\n con.cell.flatMap((c) => c.value),\n ) ?? null\n : null;\n /* v8 ignore next -- @preserve */\n const baseValue =\n joinCol && joinCol.value.cell\n ? joinCol.value.cell.flatMap((c) => c.value) ?? null\n : null;\n\n row.push(insertValue ?? baseValue);\n }\n result.push(row);\n }\n return result;\n }\n\n static empty(): Join {\n return new Join({}, ColumnSelection.empty());\n }\n\n // ...........................................................................\n /**\n * Hashes the given join rows. If insert value is present, it is used for hashing.\n *\n * @param rows The join rows to hash\n * @returns The hashed join rows\n */\n private _hashedRows(rows: JoinRows) {\n const sliceIds = Object.keys(rows);\n const hashedRows: JoinRowsHashed = {};\n for (const sliceId of sliceIds) {\n const cols = rows[sliceId];\n /* v8 ignore next -- @preserve */\n const rowHash = Hash.default.calcHash(\n cols.map((col) =>\n col.inserts?.flatMap((con) => con.cell.flatMap((c) => c.value)) ??\n col.value.cell\n ? col.value.cell.flatMap((c) => c.value)\n : [],\n ) as any[],\n );\n hashedRows[sliceId] = {\n rowHash,\n columns: cols,\n };\n }\n return hashedRows;\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { InsertHistoryRow, Route } from '@rljson/rljson';\n\nexport type NotifyCallback<N extends string> = (\n InsertHistoryRow: InsertHistoryRow<N>,\n) => Promise<any>;\n\n// ...........................................................................\n/**\n * Notification system to manage callbacks for specific routes and notify them with edit protocol rows.\n */\nexport class Notify {\n private _callbacks: Map<string, NotifyCallback<any>[]> = new Map();\n\n // ...........................................................................\n constructor() {}\n\n // ...........................................................................\n /**\n * Registers a callback for a specific route.\n * @param route The route to register the callback for.\n * @param callback The callback function to be invoked when a notification is sent.\n */\n register(route: Route, callback: NotifyCallback<any>) {\n this._callbacks.set(route.flat, [\n ...(this._callbacks.get(route.flat) || []),\n callback,\n ]);\n }\n\n // ...........................................................................\n /**\n * Unregisters a callback for a specific route.\n * @param route The route to unregister the callback from.\n * @param callback The callback function to be removed.\n */\n unregister(route: Route, callback: NotifyCallback<any>) {\n const callbacks = this._callbacks.get(route.flat);\n /*v8 ignore else -- @preserve */\n if (callbacks) {\n this._callbacks.set(\n route.flat,\n callbacks.filter((cb) => cb !== callback),\n );\n }\n }\n\n // ...........................................................................\n /**\n * Unregisters all callbacks for a specific route.\n * @param route The route to unregister all callbacks from.\n */\n unregisterAll(route: Route) {\n this._callbacks.delete(route.flat);\n }\n\n // ...........................................................................\n /**\n * Notifies all registered callbacks for a specific route with the provided edit protocol row.\n * @param route The route to notify callbacks for.\n * @param insertHistoryRow The edit protocol row to pass to the callbacks.\n */\n notify<N extends string>(\n route: Route,\n insertHistoryRow: InsertHistoryRow<N>,\n ) {\n const callbacks = this._callbacks.get(route.flat);\n if (callbacks) {\n /*v8 ignore next -- @preserve */\n Promise.all(callbacks.map((cb) => cb(insertHistoryRow))).catch((err) => {\n console.error(\n `Error notifying callbacks for route ${route.flat}:`,\n err,\n );\n });\n }\n }\n\n // ...........................................................................\n /**\n * Returns the current map of registered callbacks.\n * @returns A map where keys are route strings and values are arrays of callback functions.\n */\n get callbacks() {\n return this._callbacks;\n }\n\n // ...........................................................................\n /**\n * Retrieves the list of callbacks registered for a specific route.\n * @param route The route to get callbacks for.\n * @returns An array of callback functions registered for the specified route.\n */\n getCallBacksForRoute(route: Route) {\n return this._callbacks.get(route.flat) || [];\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { JsonH } from '@rljson/json';\nimport { Rljson } from '@rljson/rljson';\n\nimport { traverse } from 'object-traversal';\n\nexport const makeUniqueArrayByHash = <T extends JsonH>(arr: T[]): T[] => {\n const seen = new Map<string, T>();\n const result: T[] = [];\n for (const item of arr) {\n if (!seen.has(item._hash)) {\n seen.set(item._hash, item);\n result.push(item);\n }\n }\n return result;\n};\n\nexport const makeUnique = (rljson: Rljson): Rljson => {\n traverse(rljson, ({ parent, key, value }) => {\n if (key == '_data' && Array.isArray(value)) {\n parent![key] = makeUniqueArrayByHash<JsonH>(value);\n }\n });\n return rljson;\n};\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { hsh, rmhsh } from '@rljson/hash';\nimport { Io } from '@rljson/io';\nimport { Json, JsonValue, merge } from '@rljson/json';\nimport {\n Cake,\n CakesTable,\n ComponentRef,\n ComponentsTable,\n ContentType,\n Edit,\n EditHistory,\n EditHistoryTable,\n EditsTable,\n getTimeIdTimestamp,\n Head,\n InsertHistoryRow,\n InsertHistoryTimeId,\n isTimeId,\n Layer,\n LayersTable,\n MultiEdit,\n MultiEditsTable,\n Ref,\n Rljson,\n Route,\n RouteSegment,\n SliceId,\n SliceIds,\n TableType,\n timeId,\n} from '@rljson/rljson';\n\nimport {\n Controller,\n ControllerChildProperty,\n ControllerRefs,\n ControllerRunFn,\n createController,\n} from './controller/controller.ts';\nimport { SliceIdController } from './controller/slice-id-controller.ts';\nimport { Core } from './core.ts';\nimport { Join, JoinColumn, JoinRow, JoinRows } from './join/join.ts';\nimport { ColumnSelection } from './join/selection/column-selection.ts';\nimport { Notify, NotifyCallback } from './notify.ts';\nimport { makeUnique } from './tools/make-unique.ts';\n\nexport type Cell = {\n route: Route;\n value: JsonValue | JsonValue[] | null;\n row: JsonValue | JsonValue[] | null;\n path: Array<Array<string | number>>;\n};\n\nexport type Container = {\n rljson: Rljson;\n tree: Json;\n cell: Cell[];\n};\n\nexport type GetOptions = {\n skipRljson?: boolean;\n skipTree?: boolean;\n skipCell?: boolean;\n};\n\nexport type ContainerWithControllers = Container & {\n controllers: Record<string, Controller<any, any, any>>;\n};\n\n/**\n * Access Rljson data\n */\nexport class Db {\n /**\n * Constructor\n * @param _io - The Io instance used to read and write data\n */\n constructor(private readonly _io: Io) {\n this.core = new Core(this._io);\n this.notify = new Notify();\n }\n\n /**\n * Core functionalities like importing data, setting and getting tables\n */\n readonly core: Core;\n\n /**\n * Notification system to register callbacks on data changes\n */\n readonly notify: Notify;\n\n private _cache: Map<string, Container> = new Map();\n\n // ...........................................................................\n /**\n * Get data from a route with optional filtering\n * @param route - The route to get data from\n * @param where - Optional filter to apply to the data\n * @param filter - Optional filter to apply to child entries in related tables\n * @param sliceIds - Optional slice IDs to filter the data\n * @returns An array of Rljson objects matching the route and filter\n * @throws {Error} If the route is not valid or if any controller cannot be created\n */\n async get(\n route: Route,\n where: string | Json,\n filter?: ControllerChildProperty[],\n sliceIds?: SliceId[],\n options?: GetOptions,\n ): Promise<ContainerWithControllers> {\n // Validate Route\n if (!route.isValid) throw new Error(`Route ${route.flat} is not valid.`);\n\n //Isolate Property Key\n const isolatedRoute = await this.isolatePropertyKeyFromRoute(route);\n\n // Get Controllers\n const controllers = await this.indexedControllers(isolatedRoute);\n\n // Fetch Data\n const data = await this._get(\n isolatedRoute,\n where,\n controllers,\n filter,\n sliceIds,\n undefined,\n options,\n );\n\n const dataWithControllers: ContainerWithControllers = {\n ...data,\n ...{ controllers },\n };\n return dataWithControllers;\n }\n\n // ...........................................................................\n /**\n * Resolves the route and returns corresponding data for any segment of the route,\n * matching recursive filters and where clauses\n *\n * @param route - The route to get data from\n * @param where - The recursive filtering key/value pairs to apply to the data\n * @param controllers - The controllers to use for fetching data\n * @param filter - Optional filter to apply to the data at the current route segment\n * @param sliceIds - Optional slice IDs to filter the data at the current route segment\n * @param routeAccumulator - The accumulated route up to the current segment\n * @param options - Additional options for fetching data\n * @returns - An Rljson object matching the route and filters\n */\n async _get(\n route: Route,\n where: string | Json,\n controllers: Record<string, Controller<any, any, any>>,\n filter?: ControllerChildProperty[],\n sliceIds?: SliceId[],\n routeAccumulator?: Route,\n options?: GetOptions,\n ): Promise<Container> {\n // Default options\n const opts = options ?? {};\n\n //Check if cacheable\n const routeHasRefs = route.flat != route.flatWithoutRefs;\n const hasFilter = filter !== undefined && filter.length > 0;\n const cacheable = !!routeHasRefs || !!hasFilter;\n let cacheHash = '';\n\n if (cacheable) {\n //Activate Cache\n const params = {\n route: route.flat,\n where,\n filter,\n sliceIds,\n routeAccumulator: routeAccumulator ? routeAccumulator.flat : '',\n options: opts,\n };\n cacheHash = (hsh(rmhsh(params)) as any)._hash as string;\n\n const isCached = this._cache.has(cacheHash);\n if (isCached) {\n return this._cache.get(cacheHash)!;\n }\n }\n\n const nodeTableKey = route.top.tableKey;\n const nodeRoute = route;\n const nodeRouteRef = await this._getReferenceOfRouteSegment(nodeRoute.top);\n const nodeController = controllers[nodeTableKey];\n\n const nodeSliceIds = nodeRoute.top.sliceIds ?? sliceIds;\n\n let nodeWhere = typeof where === 'object' ? { ...where } : where;\n\n // If not root, remove child prompts from where\n if (!route.isRoot && typeof nodeWhere === 'object') {\n delete nodeWhere[nodeRoute.deeper().top.tableKey];\n }\n\n // Add ref to where\n /* v8 ignore next -- @preserve */\n nodeWhere = nodeWhere\n ? typeof nodeWhere === 'string'\n ? { _hash: nodeWhere }\n : nodeWhere\n : {};\n\n // Add route ref to where\n if (nodeRouteRef && nodeRouteRef.length > 0)\n nodeWhere = { _hash: nodeRouteRef };\n\n // Delete internal flags\n delete (nodeWhere as Json)['_through'];\n delete (nodeWhere as Json)['_tableKey'];\n\n // Fetch Node Data (actual access to underlying data model)\n const {\n [nodeTableKey]: { _data: nodeRows, _type: nodeType, _hash: nodeHash },\n } = await nodeController.get(nodeWhere);\n const nodeColumnCfgs = nodeController.tableCfg().columns;\n\n const filterActive = filter && filter.length > 0;\n const sliceIdActive = nodeSliceIds && nodeSliceIds.length > 0;\n\n // Pre-build filter map for O(1) lookups instead of O(n) searches\n const filterMap = filterActive\n ? new Map<string, ControllerChildProperty[]>()\n : null;\n\n if (filterActive) {\n for (const f of filter) {\n if (f.tableKey === nodeTableKey) {\n if (!filterMap!.has(f.ref)) {\n filterMap!.set(f.ref, []);\n }\n filterMap!.get(f.ref)!.push(f);\n }\n }\n }\n\n // Batch resolve all sliceIds at once instead of awaiting sequentially\n const sliceIdResolvePromises = new Map<string, Promise<SliceId[]>>();\n const nodeSliceIdSet = sliceIdActive ? new Set(nodeSliceIds) : null;\n\n if (sliceIdActive) {\n for (const nodeRow of nodeRows) {\n if (nodeType === 'cakes') {\n const cake = nodeRow as Cake;\n const key = `${cake.sliceIdsTable}:${cake.sliceIdsRow}`;\n /* v8 ignore next -- @preserve */\n if (!sliceIdResolvePromises.has(key)) {\n sliceIdResolvePromises.set(\n key,\n this._resolveSliceIds(cake.sliceIdsTable, cake.sliceIdsRow),\n );\n }\n } else if (nodeType === 'layers') {\n const layer = nodeRow as Layer;\n const key = `${layer.sliceIdsTable}:${layer.sliceIdsTableRow}`;\n /* v8 ignore next -- @preserve */\n if (!sliceIdResolvePromises.has(key)) {\n sliceIdResolvePromises.set(\n key,\n this._resolveSliceIds(\n layer.sliceIdsTable,\n layer.sliceIdsTableRow,\n ),\n );\n }\n }\n }\n }\n\n // Wait for all sliceId resolutions in parallel\n const resolvedSliceIds = new Map<string, Set<SliceId>>();\n if (sliceIdResolvePromises.size > 0) {\n const entries = Array.from(sliceIdResolvePromises.entries());\n const results = await Promise.all(entries.map(([, p]) => p));\n entries.forEach(([key], idx) => {\n resolvedSliceIds.set(key, new Set(results[idx]));\n });\n }\n\n const nodeRowsFiltered: Json[] = [];\n for (const nodeRow of nodeRows) {\n if (!filterActive && !sliceIdActive) {\n nodeRowsFiltered.push(nodeRow);\n continue;\n }\n\n // Apply Filters\n let filterResult = false;\n const filterProperties: ControllerChildProperty[] = [];\n if (filterActive) {\n const rowFilters = filterMap!.get(nodeRow._hash);\n if (rowFilters) {\n filterProperties.push(...rowFilters);\n filterResult = true;\n }\n } else {\n filterResult = true;\n }\n\n // Apply SliceIds\n let sliceIdResult = false;\n if (sliceIdActive) {\n switch (nodeType) {\n case 'cakes':\n const cake = nodeRow as Cake;\n const cakeKey = `${cake.sliceIdsTable}:${cake.sliceIdsRow}`;\n const cakeSliceIdSet = resolvedSliceIds.get(cakeKey)!;\n // Use Set intersection for O(n) instead of filter+includes O(n*m)\n for (const sId of nodeSliceIdSet!) {\n if (cakeSliceIdSet.has(sId)) {\n sliceIdResult = true;\n break;\n }\n }\n break;\n\n case 'layers':\n const layer = nodeRow as Layer;\n const layerKey = `${layer.sliceIdsTable}:${layer.sliceIdsTableRow}`;\n const layerSliceIdSet = resolvedSliceIds.get(layerKey)!;\n for (const sId of nodeSliceIdSet!) {\n if (layerSliceIdSet.has(sId)) {\n sliceIdResult = true;\n break;\n }\n }\n break;\n case 'components':\n if (filterProperties.length > 0) {\n // Use Set for faster lookups\n const componentSliceIdSet = new Set(\n filterProperties.flatMap((f) => f.sliceIds),\n );\n for (const sId of nodeSliceIdSet!) {\n if (componentSliceIdSet.has(sId)) {\n sliceIdResult = true;\n break;\n }\n }\n }\n break;\n /* v8 ignore next -- @preserve */\n default:\n sliceIdResult = true;\n break;\n }\n } else {\n sliceIdResult = true;\n }\n\n if (filterResult && sliceIdResult) nodeRowsFiltered.push(nodeRow);\n }\n\n // Construct Node w/ only filtered rows\n const node = {\n [nodeTableKey]: {\n _data: nodeRowsFiltered,\n _type: nodeType,\n _hash: nodeHash,\n },\n } as Rljson;\n\n // Return if is root node (deepest level, base case)\n if (route.isRoot) {\n // Pre-compute common route string to avoid repeated concatenation\n const baseRouteStr =\n (routeAccumulator ? routeAccumulator.flat : nodeTableKey) +\n (nodeHash ? `@${nodeHash}` : '');\n\n if (route.hasPropertyKey) {\n /* v8 ignore next -- @preserve */\n const isolatedNode = opts.skipRljson\n ? ({} as Rljson)\n : this.isolatePropertyFromComponents(node, route.propertyKey!);\n\n /* v8 ignore next -- @preserve */\n const routeWithProperty = opts.skipCell\n ? null\n : Route.fromFlat(\n baseRouteStr + `/${route.propertyKey}`,\n ).toRouteWithProperty();\n\n /* v8 ignore next -- @preserve */\n const tree = opts.skipTree\n ? ({} as Json)\n : { [nodeTableKey]: node[nodeTableKey] };\n\n /* v8 ignore next -- @preserve */\n const cell = opts.skipCell\n ? ([] as Cell[])\n : (nodeRowsFiltered.map(\n (v, idx) =>\n ({\n value: v[route.propertyKey!] ?? null,\n row: v,\n route: routeWithProperty,\n path: [[nodeTableKey, '_data', idx, route.propertyKey]],\n } as Cell),\n ) as Cell[]);\n\n const result = {\n rljson: isolatedNode,\n tree,\n cell,\n };\n\n //Set Cache\n this._cache.set(cacheHash, result);\n\n return result;\n }\n\n const routeObj = opts.skipCell ? null : Route.fromFlat(baseRouteStr);\n\n /* v8 ignore next -- @preserve */\n const rljson = opts.skipRljson ? ({} as Rljson) : node;\n /* v8 ignore next -- @preserve */\n const tree = opts.skipTree\n ? ({} as Json)\n : { [nodeTableKey]: node[nodeTableKey] };\n /* v8 ignore next -- @preserve */\n const cell = opts.skipCell\n ? ([] as Cell[])\n : (nodeRowsFiltered.map(\n (v, idx) =>\n ({\n value: v[route.propertyKey!] ?? null,\n row: v,\n route: routeObj,\n path: [[nodeTableKey, '_data', idx]],\n } as Cell),\n ) as Cell[]);\n\n const result = {\n rljson,\n tree,\n cell,\n };\n\n if (cacheable) {\n //Set Cache\n this._cache.set(cacheHash, result);\n }\n\n return result;\n }\n\n // Fetch Children Data\n const childrenRoute = route.deeper();\n const childrenTableKey = childrenRoute.top.tableKey;\n /* v8 ignore next -- @preserve */\n const childrenWhere = (\n typeof where === 'object' ? where[childrenTableKey] ?? {} : {}\n ) as Json | string;\n\n const childrenThroughProperty = (childrenWhere as any)?._through;\n\n const nodeChildrenArray = [];\n\n const nodeRowsMatchingChildrenRefs = new Map<\n string,\n {\n rljson: Json;\n tree: Json;\n cell: Cell[];\n }\n >();\n\n // Pre-build column reference map outside the loop\n const columnReferenceMap =\n nodeType === 'components'\n ? nodeColumnCfgs\n .filter((c) => c.ref?.tableKey === childrenTableKey)\n .filter(\n (c) => c.ref && ['components', 'cakes'].includes(c.ref.type),\n )\n .reduce((acc, curr) => {\n acc.set(curr.key, curr.ref!.tableKey);\n return acc;\n }, new Map<string, string>())\n : null;\n\n // Batch fetch all childRefs in parallel for better performance\n const childRefsPromises = nodeRowsFiltered.map((nodeRow) =>\n nodeController.getChildRefs((nodeRow as any)._hash),\n );\n const allChildRefs = await Promise.all(childRefsPromises);\n\n // Iterate over Node Rows to get Children\n for (let i = 0; i < nodeRowsFiltered.length; i++) {\n const nodeRow = nodeRowsFiltered[i];\n const nodeRowHash = (nodeRow as any)._hash;\n\n // Child References of this Node Row = Filter for Children\n const childrenRefs = allChildRefs[i];\n\n // If cake is referenced, we have to collect all sliceIds from\n // childrenRefs and switch to them\n const childrenRefTypes = new Map<string, string>();\n const childrenRefSliceIds = new Set<SliceId>();\n\n for (const cr of childrenRefs) {\n if (!!cr.columnKey) {\n const childrenRefColumnCfg = nodeColumnCfgs.find(\n (c) => c.key === cr.columnKey,\n );\n\n /* v8 ignore else -- @preserve */\n if (childrenRefColumnCfg) {\n /* v8 ignore next -- @preserve */\n childrenRefTypes.set(\n childrenRefColumnCfg.key,\n childrenRefColumnCfg.ref?.type ?? '',\n );\n }\n\n if (cr.sliceIds && cr.sliceIds.length > 0) {\n //Cake is referenced, switch sliceIds\n for (const sId of cr.sliceIds) {\n childrenRefSliceIds.add(sId);\n }\n }\n }\n }\n\n const childrenRefTypesSet = new Set<string>([\n ...childrenRefTypes.values(),\n ]);\n\n /* v8 ignore next -- @preserve */\n if (childrenRefTypesSet.size > 1) {\n throw new Error(\n `Db._get: Multiple reference types found for children of node table \"${nodeTableKey}\" and row \"${nodeRowHash}\". Found types: ${[\n ...childrenRefTypesSet,\n ].join(', ')}.`,\n );\n }\n\n const childrenRefType =\n childrenRefTypesSet.size > 0 ? [...childrenRefTypesSet][0] : null;\n\n const cakeIsReferenced =\n childrenRefTypes.size > 0 && childrenRefType === 'cakes';\n\n const componentIsReferenced =\n childrenRefTypes.size > 0 &&\n nodeType === 'components' &&\n childrenRefType === 'components';\n\n const childrenSliceIds = cakeIsReferenced\n ? [...childrenRefSliceIds]\n : componentIsReferenced\n ? undefined\n : nodeSliceIds;\n\n const {\n rljson: rowChildrenRljson,\n tree: rowChildrenTree,\n cell: rowChildrenCell,\n } = await this._get(\n childrenRoute,\n childrenWhere,\n controllers,\n childrenRefs,\n childrenSliceIds,\n Route.fromFlat(\n (routeAccumulator ? routeAccumulator.flat : nodeTableKey) +\n (nodeHash ? `@${nodeHash}` : '') +\n '/' +\n childrenTableKey,\n ),\n opts,\n );\n\n // No Children found for where + route => skip\n if (\n !rowChildrenRljson[childrenTableKey] ||\n rowChildrenRljson[childrenTableKey]._data.length === 0\n )\n continue;\n\n nodeChildrenArray.push(rowChildrenRljson);\n\n // Skip expensive tree/cell processing if not needed\n /* v8 ignore next -- @preserve */\n if (opts.skipTree && opts.skipCell) {\n nodeRowsMatchingChildrenRefs.set(nodeRowHash, {\n rljson: nodeRow,\n tree: {},\n cell: [],\n });\n continue;\n }\n\n // Create nodeRowObj only when needed for tree/cell\n const nodeRowObj = { ...nodeRow } as Json;\n\n if (cakeIsReferenced) {\n const refKey = [...childrenRefTypes.keys()][0] as string;\n nodeRowObj[refKey] = rowChildrenTree;\n }\n\n // Add Children as ThroughProperty value to Object representation\n if (childrenThroughProperty) {\n const resolvedChildrenHashesSet = new Set(\n rowChildrenRljson[childrenTableKey]._data.map(\n (rc) => rc._hash as string,\n ),\n );\n\n for (const nr of nodeRowsFiltered) {\n const throughHashesInRowCouldBeArray = (nr as any)[\n childrenThroughProperty\n ];\n const throughHashesInRow = Array.isArray(\n throughHashesInRowCouldBeArray,\n )\n ? throughHashesInRowCouldBeArray\n : [throughHashesInRowCouldBeArray];\n\n for (const th of throughHashesInRow) {\n if (resolvedChildrenHashesSet.has(th)) {\n //Add Child as ThroughProperty value\n nodeRowObj[childrenThroughProperty] = {\n ...(rowChildrenTree as any)[childrenTableKey],\n _tableKey: childrenTableKey,\n };\n break; // Exit early once matched\n }\n }\n }\n }\n\n const resolvedChildren = rowChildrenRljson[childrenTableKey]\n ._data as Json[];\n\n const childrenRefsOfRow = childrenRefs.filter(\n (cr) => cr.tableKey == childrenTableKey,\n );\n\n // Build hash set for faster lookups\n const resolvedChildrenHashSet = new Set(\n resolvedChildren.map((ch) => ch._hash),\n );\n\n const matchingChildrenRefs = childrenRefsOfRow.filter((cr) =>\n resolvedChildrenHashSet.has(cr.ref),\n );\n\n // Build ref map for O(1) lookups\n const matchingRefsMap = new Map(\n matchingChildrenRefs.map((cr) => [cr.ref, cr]),\n );\n\n // If Layer, construct layer objects with sliceIds relations\n /* v8 ignore else -- @preserve */\n if (nodeType === 'layers') {\n const compChildrenTrees = (\n (rowChildrenTree as any)[childrenTableKey]! as ComponentsTable<Json>\n )._data;\n const compChildrenPaths = rowChildrenCell.map((c) => c.path);\n\n const components = compChildrenTrees.map((c, idx) => {\n return {\n tree: c,\n path: compChildrenPaths.filter((p) => p[0][2] == idx),\n };\n });\n\n const layerTreesAndPaths = components.map(({ tree: comp, path }) => {\n const matchedRef = matchingRefsMap.get(comp._hash as string);\n const sliceIds = matchedRef?.sliceIds;\n\n /* v8 ignore next -- @preserve */\n if (!sliceIds || sliceIds.length === 0) {\n throw new Error(\n `Db._get: No sliceIds found for component ${\n comp._hash\n } of layer ${(nodeRow as any)._hash}.`,\n );\n }\n /* v8 ignore next -- @preserve */\n if (sliceIds.length > 1) {\n throw new Error(\n `Db._get: Multiple sliceIds found for component ${\n comp._hash\n } of layer ${(nodeRow as any)._hash}.`,\n );\n }\n\n const sliceId = sliceIds[0];\n\n const pathsForSliceId = path.map((p) => {\n const newPath = [...p[0]];\n newPath[2] = 0;\n return ['add', sliceId, ...newPath];\n });\n\n return {\n [sliceId]: {\n tree: {\n [childrenTableKey]: {\n _data: [comp],\n _type: 'components',\n },\n },\n path: pathsForSliceId,\n },\n };\n });\n\n const layer: Record<string, any> = {};\n const paths: any[] = [];\n\n for (const ltap of layerTreesAndPaths) {\n for (const [sliceId, value] of Object.entries(ltap)) {\n layer[sliceId] = value.tree;\n /* v8 ignore next -- @preserve */\n if (!opts.skipCell) {\n paths.push(value.path);\n }\n }\n }\n\n const rljson = nodeRow;\n\n /* v8 ignore next -- @preserve */\n const tree = opts.skipTree\n ? {}\n : {\n ...nodeRowObj,\n add: { ...(nodeRowObj.add as Json), ...layer },\n };\n\n /* v8 ignore next -- @preserve */\n const cell = opts.skipCell\n ? []\n : rowChildrenCell.map(\n (c, idx) =>\n ({\n ...c,\n path: [paths.flat()[idx]],\n } as Cell),\n );\n\n nodeRowsMatchingChildrenRefs.set(nodeRowHash, {\n rljson,\n tree,\n cell,\n });\n } else if (nodeType === 'cakes') {\n nodeRowsMatchingChildrenRefs.set(nodeRowHash, {\n rljson: nodeRow,\n tree: opts.skipTree\n ? {}\n : {\n ...nodeRowObj,\n layers: { ...(nodeRowObj.layers as Json), ...rowChildrenTree },\n },\n cell: opts.skipCell\n ? []\n : rowChildrenCell.map((c) => ({\n ...c,\n path: c.path.map((p) => ['layers', ...p]),\n })),\n });\n } else if (nodeType === 'components') {\n /* v8 ignore else -- @preserve */\n if (rowChildrenTree && Object.keys(rowChildrenTree).length > 0) {\n const resolvedProperties: Record<string, Json> = {};\n const allCells: Cell[] = [];\n\n for (const [colKey, childTableKey] of columnReferenceMap!) {\n if (!opts.skipTree) {\n resolvedProperties[colKey] = {\n ...(rowChildrenTree[childTableKey] as Json),\n _tableKey: childTableKey,\n };\n }\n\n if (!opts.skipCell) {\n const cell = rowChildrenCell.map((c) => ({\n ...c,\n path: c.path\n .filter((p) => p[0] === childTableKey)\n .map((p) => [colKey, ...p.slice(1)]),\n }));\n allCells.push(...cell);\n }\n }\n\n nodeRowsMatchingChildrenRefs.set(nodeRowHash, {\n rljson: nodeRow,\n tree: opts.skipTree\n ? {}\n : {\n ...nodeRowObj,\n ...resolvedProperties,\n },\n cell: allCells,\n });\n } else {\n nodeRowsMatchingChildrenRefs.set(nodeRowHash, {\n rljson: nodeRow,\n tree: { ...nodeRowObj },\n cell: rowChildrenCell,\n });\n }\n } else {\n throw new Error(\n `Db._get: Unsupported node type ${nodeType} for getting children.`,\n );\n }\n }\n\n // Merge Children Data - skip if not needed\n /* v8 ignore next -- @preserve */\n const nodeChildren = opts.skipRljson\n ? ({} as Rljson)\n : makeUnique(merge(...(nodeChildrenArray as Rljson[])) as Rljson);\n\n // Return Node with matched Children\n const matchedNodeRows = Array.from(nodeRowsMatchingChildrenRefs.values());\n\n /* v8 ignore next -- @preserve */\n const rljson = opts.skipRljson\n ? ({} as Rljson)\n : ({\n ...node,\n [nodeTableKey]: {\n _data: matchedNodeRows.map((mr) => mr.rljson),\n _type: nodeType,\n ...(nodeHash ? { _hash: nodeHash } : {}),\n },\n ...nodeChildren,\n } as Rljson);\n /* v8 ignore next -- @preserve */\n const tree = opts.skipTree\n ? ({} as Json)\n : {\n [nodeTableKey]: {\n _data: matchedNodeRows.map((mr) => mr.tree),\n _type: nodeType,\n ...(nodeHash ? { _hash: nodeHash } : {}),\n },\n };\n /* v8 ignore next -- @preserve */\n const cell = opts.skipCell\n ? []\n : (() => {\n // Pre-calculate total size and build array directly\n let totalSize = 0;\n for (const mr of matchedNodeRows) {\n totalSize += mr.cell.length;\n }\n const cells: Cell[] = new Array(totalSize);\n let cellIdx = 0;\n for (let rowIdx = 0; rowIdx < matchedNodeRows.length; rowIdx++) {\n const mr = matchedNodeRows[rowIdx];\n for (const c of mr.cell) {\n cells[cellIdx++] = {\n ...c,\n path: c.path.map((p) => [nodeTableKey, '_data', rowIdx, ...p]),\n };\n }\n }\n return cells;\n })();\n\n const result = {\n rljson,\n tree,\n cell,\n };\n //Set Cache\n this._cache.set(cacheHash, result);\n\n return result;\n }\n\n // ...........................................................................\n /**\n * Get the reference (hash) of a route segment, considering default refs and insertHistory refs\n * @param segment - The route segment to get the reference for\n * @returns\n */\n private async _getReferenceOfRouteSegment(\n segment: RouteSegment<any>,\n ): Promise<string | null> {\n if (Route.segmentHasRef(segment)) {\n if (Route.segmentHasDefaultRef(segment)) {\n // Use given ref\n return Route.segmentRef(segment)!;\n } else {\n // Get ref from insertHistory\n return (await this.getRefOfTimeId(\n segment.tableKey,\n Route.segmentRef(segment)!,\n ))!;\n }\n }\n return null;\n }\n\n // ...........................................................................\n /**\n * Joins data from layers in an Rljson into a single dataset\n * @param rljson - The Rljson to join data for\n */\n async join(\n columnSelection: ColumnSelection,\n cakeKey: string,\n cakeRef: Ref,\n ): Promise<Join> {\n const {\n tree: { [cakeKey]: cakesTable },\n } = await this.get(\n Route.fromFlat(`${cakeKey}@${cakeRef}`),\n {},\n undefined,\n undefined,\n { skipCell: true, skipRljson: true },\n );\n\n const cakes = (cakesTable as CakesTable)._data;\n\n /* v8 ignore next -- @preserve */\n if (cakes.length === 0) {\n throw new Error(\n `Db.join: Cake with ref \"${cakeRef}\" not found in cake table \"${cakeKey}\".`,\n );\n }\n /* v8 ignore next -- @preserve */\n if (cakes.length > 1) {\n throw new Error(\n `Db.join: Multiple cakes with ref \"${cakeRef}\" found in cake table \"${cakeKey}\".`,\n );\n }\n const cake = cakes[0] as Cake;\n\n const sliceIds = await this._resolveSliceIds(\n (cake as Cake).sliceIdsTable,\n (cake as Cake).sliceIdsRow,\n );\n const rows: JoinRows = {};\n for (const sliceId of sliceIds) {\n const row: JoinRow = [];\n\n for (const columnInfo of columnSelection.columns) {\n const columnRoute = Route.fromFlat(\n columnInfo.route,\n ).toRouteWithProperty();\n\n const columnContainer = await this.get(\n columnRoute,\n cakeRef,\n undefined,\n [sliceId],\n );\n\n const column: JoinColumn = {\n route: columnRoute,\n value: columnContainer,\n inserts: null,\n };\n row.push(column);\n }\n\n rows[sliceId] = row;\n }\n\n // Return Join\n return new Join(rows, columnSelection);\n }\n\n // ...........................................................................\n private async _resolveSliceIds(\n sliceIdTable: string,\n sliceIdRow: string,\n ): Promise<SliceId[]> {\n const sliceIdController: SliceIdController<any, any> =\n new SliceIdController(this.core, sliceIdTable);\n sliceIdController.init();\n\n const resolvedSliceIds: Set<SliceId> = new Set();\n\n const {\n [sliceIdTable]: { _data: sliceIds },\n } = await sliceIdController.get(sliceIdRow);\n\n for (const sliceId of sliceIds) {\n const baseSliceIds = await sliceIdController.resolveBaseSliceIds(\n sliceId as SliceIds,\n );\n for (const sId of baseSliceIds.add) {\n resolvedSliceIds.add(sId);\n }\n }\n\n return Array.from(resolvedSliceIds);\n }\n\n // ...........................................................................\n /**\n * Runs an Insert by executing the appropriate controller(s) based on the Insert's route\n * @param Insert - The Insert to run\n * @returns The result of the Insert as an InsertHistoryRow\n * @throws {Error} If the Insert is not valid or if any controller cannot be created\n */\n async insert(\n route: Route,\n tree: Json,\n options?: { skipNotification?: boolean; skipHistory?: boolean },\n ): Promise<InsertHistoryRow<any>[]> {\n const controllers = await this.indexedControllers(\n Route.fromFlat(route.flatWithoutRefs),\n );\n const runFns: Record<string, ControllerRunFn<any, any>> = {};\n for (const [tableKey, controller] of Object.entries(controllers)) {\n runFns[tableKey] = controller.insert.bind(controller);\n }\n return this._insert(route, tree, runFns, options);\n }\n\n // ...........................................................................\n /**\n * Recursively runs controllers based on the route of the Insert\n * @param insert - The Insert to run\n * @param route - The route of the Insert\n * @param runFns - A record of controller run functions, keyed by table name\n * @returns The result of the Insert\n * @throws {Error} If the route is not valid or if any controller cannot be created\n */\n private async _insert(\n route: Route,\n tree: Json,\n runFns: Record<string, ControllerRunFn<any, any>>,\n options?: { skipNotification?: boolean; skipHistory?: boolean },\n ): Promise<InsertHistoryRow<any>[]> {\n const results: InsertHistoryRow<any>[] = [];\n\n //Run parent controller with child refs as value\n const nodeRoute = route;\n const nodeSegment = nodeRoute.segment(0);\n const nodeTableKey = nodeSegment.tableKey;\n const nodeTree = (tree[nodeTableKey] as TableType)!;\n const nodeType = nodeTree._type as ContentType;\n\n /* v8 ignore next -- @preserve */\n if (nodeTree._data.length === 0) {\n throw new Error(\n `Db._insert: No data found for table \"${nodeTableKey}\" in route \"${route.flat}\".`,\n );\n }\n\n const previousHash = (nodeSegment as any)[nodeTableKey + 'Ref'] ?? null;\n const previousTimeId: string | null =\n (nodeSegment as any)[nodeTableKey + 'InsertHistoryRef'] ?? null;\n\n const previous: InsertHistoryTimeId[] = previousHash\n ? await this.getTimeIdsForRef(nodeTableKey, previousHash as string)\n : previousTimeId\n ? [previousTimeId]\n : [];\n\n //If not root, run nested controllers first\n if (!nodeRoute.isRoot) {\n //Run nested controller first\n const childRoute = nodeRoute.deeper(1);\n const childTableKey = childRoute.top.tableKey;\n\n if (nodeType === 'cakes') {\n const cakes = (nodeTree as CakesTable)._data;\n\n /* v8 ignore next -- @preserve */\n if (cakes.length > 1) {\n // throw new Error(\n // `Db._insert: Multiple cakes found for cake table \"${nodeTableKey}\" when inserting into child table \"${childTableKey}\". Only single cake inserts are supported.`,\n // );\n }\n\n //Check if there is no cake or no childTree --> Add new one\n const cake = cakes[0] as Cake;\n const childTree = (cake.layers as Json)[childTableKey] as TableType;\n const childResults = await this._insert(\n childRoute,\n { [childTableKey]: childTree },\n runFns,\n );\n\n /* v8 ignore next -- @preserve */\n if (childResults.length > 1) {\n throw new Error(\n `Db._insert: Multiple inserts returned for child table \"${childTableKey}\" when inserting into cake table \"${nodeTableKey}\". Only single child inserts are supported.`,\n );\n }\n\n const childResult = childResults[0];\n\n const insertValue = {\n ...(cake as any as Json),\n ...{\n layers: {\n ...cake.layers,\n ...{\n [childTableKey]: (childResult as any)[childTableKey + 'Ref'],\n },\n },\n },\n };\n const runFn = runFns[nodeTableKey];\n const result = await runFn('add', rmhsh(insertValue), 'db.insert');\n results.push(\n ...result.map((r) => ({\n ...r,\n ...{ previous },\n ...{ route: route.flat },\n })),\n );\n }\n if (nodeType === 'layers') {\n const layers = (nodeTree as LayersTable)._data;\n for (const layer of layers) {\n const layerInsert: Record<SliceId, ComponentRef> = {};\n\n //Check what if there is no layer or no compomentTree --> Add new one\n\n for (const [sliceId, componentTree] of Object.entries(layer.add)) {\n if (sliceId === '_hash') continue;\n\n const writtenComponents = await this._insert(\n childRoute,\n componentTree as any,\n runFns,\n );\n\n /* v8 ignore next -- @preserve */\n if (writtenComponents.length > 1) {\n throw new Error(\n `Db._insert: Multiple components written for layer \"${\n (layer as any)._hash\n }\" and sliceId \"${sliceId}\" is currently not supported.`,\n );\n }\n\n const writtenComponent = writtenComponents[0];\n\n /* v8 ignore next -- @preserve */\n if (\n !writtenComponent ||\n !(writtenComponent as any)[childTableKey + 'Ref']\n ) {\n throw new Error(\n `Db._insert: No component reference returned for layer \"${\n (layer as any)._hash\n }\" and sliceId \"${sliceId}\".`,\n );\n }\n\n layerInsert[sliceId] = (writtenComponent as any)[\n childTableKey + 'Ref'\n ];\n }\n const runFn = runFns[nodeTableKey];\n const result = await runFn(\n 'add',\n rmhsh({\n ...layer,\n ...{ add: layerInsert },\n }),\n 'db.insert',\n );\n results.push(\n ...result.map((r) => ({\n ...r,\n ...{ previous },\n ...{ route: route.flat },\n })),\n );\n }\n }\n if (\n (\n [\n 'components',\n 'edits',\n 'multiEdits',\n 'editHistory',\n 'head',\n ] as ContentType[]\n ).includes(nodeType)\n ) {\n const runFn = runFns[nodeTableKey];\n const components = (nodeTree as ComponentsTable<Json>)._data;\n for (const component of components) {\n const resolvedComponent = { ...component } as Json;\n for (const [property, value] of Object.entries(component)) {\n if (\n (value as any).hasOwnProperty('_tableKey') &&\n (value as any)._tableKey === childTableKey\n ) {\n const writtenReferences = await this._insert(\n childRoute,\n { [childTableKey]: value as any },\n runFns,\n );\n resolvedComponent[property] = writtenReferences.map(\n (wr) => (wr as any)[childTableKey + 'Ref'],\n );\n }\n }\n\n const result = await runFn(\n 'add',\n rmhsh(resolvedComponent),\n 'db.insert',\n );\n results.push(\n ...result.map((r) => ({\n ...r,\n ...{ previous },\n ...{ route: route.flat },\n })),\n );\n }\n }\n } else {\n //Run root controller\n const runFn = runFns[nodeTableKey];\n\n if (\n (\n [\n 'components',\n 'edits',\n 'multiEdits',\n 'editHistory',\n 'head',\n ] as ContentType[]\n ).includes(nodeType)\n ) {\n const components = rmhsh(\n (tree as any)[nodeTableKey],\n ) as ComponentsTable<Json>;\n\n for (const component of components._data) {\n /* v8 ignore next -- @preserve */\n if (!component) continue;\n\n delete (component as any)._tableKey;\n delete (component as any)._type;\n\n const result = await runFn('add', component, 'db.insert');\n results.push(\n ...result.map((r) => ({\n ...r,\n ...{ previous },\n ...{ route: route.flat },\n })),\n );\n }\n }\n if (nodeType === 'layers') {\n const layers = rmhsh((tree as any)[nodeTableKey]);\n for (const layer of (layers as LayersTable)._data) {\n const result = await runFn('add', layer, 'db.insert');\n\n results.push(\n ...result.map((r) => ({\n ...r,\n ...{ previous },\n ...{ route: route.flat },\n })),\n );\n }\n }\n if (nodeType === 'cakes') {\n const cakes = rmhsh((tree as any)[nodeTableKey]);\n for (const cake of (cakes as CakesTable)._data) {\n const result = await runFn('add', cake, 'db.insert');\n\n results.push(\n ...result.map((r) => ({\n ...r,\n ...{ previous },\n ...{ route: route.flat },\n })),\n );\n }\n }\n }\n\n for (const result of results) {\n //Write insertHistory\n if (!options?.skipHistory)\n await this._writeInsertHistory(nodeTableKey, result);\n\n //Notify listeners\n if (!options?.skipNotification)\n this.notify.notify(Route.fromFlat(result.route), result);\n }\n\n return results;\n }\n\n // ...........................................................................\n /**\n * Registers a callback to be called when an Insert is made on the given route\n * @param route - The route to register the callback on\n * @param callback - The callback to be called when an Insert is made\n */\n registerObserver(route: Route, callback: NotifyCallback<any>) {\n this.notify.register(route, callback);\n }\n\n // ...........................................................................\n /**\n * Unregisters a callback from the given route\n * @param route - The route to unregister the callback from\n * @param callback - The callback to be unregistered\n */\n unregisterObserver(route: Route, callback: NotifyCallback<any>) {\n this.notify.unregister(route, callback);\n }\n\n // ...........................................................................\n /**\n * Unregisters all observers from all routes\n */\n unregisterAllObservers(route: Route) {\n this.notify.unregisterAll(route);\n }\n\n // ...........................................................................\n /**\n * Get a controller for a specific table\n * @param tableKey - The key of the table to get the controller for\n * @param refs - Optional references required by some controllers\n * @returns A controller for the specified table\n * @throws {Error} If the table does not exist or if the table type is not supported\n */\n async getController(tableKey: string, refs?: ControllerRefs) {\n // Validate Table\n const hasTable = await this.core.hasTable(tableKey);\n if (!hasTable) {\n throw new Error(`Db.getController: Table ${tableKey} does not exist.`);\n }\n\n // Get Content Type of Table\n const contentType = await this.core.contentType(tableKey);\n\n // Create Controller\n return createController(contentType, this.core, tableKey, refs);\n }\n\n // ...........................................................................\n public async indexedControllers(\n route: Route,\n ): Promise<Record<string, Controller<any, any, any>>> {\n // Create Controllers\n const controllers: Record<string, Controller<any, any, any>> = {};\n const isolatedRoute = await this.isolatePropertyKeyFromRoute(route);\n\n for (let i = 0; i < isolatedRoute.segments.length; i++) {\n const segment = isolatedRoute.segments[i];\n const tableKey = segment.tableKey;\n //Base is helpful for cake and layer controllers. It contains the ref of\n // the base cake for taking over default layers definitions\n const segmentRef = Route.segmentRef(segment);\n const base = segmentRef\n ? isTimeId(segmentRef)\n ? await this.getRefOfTimeId(tableKey, segmentRef)\n : segmentRef\n : null;\n\n controllers[tableKey] ??= await this.getController(\n tableKey,\n base ? ({ base } as ControllerRefs) : undefined,\n );\n }\n\n return controllers;\n }\n\n // ...........................................................................\n /**\n * Adds an InsertHistory row to the InsertHistory table of a table\n * @param table - The table the Insert was made on\n * @param InsertHistoryRow - The InsertHistory row to add\n * @throws {Error} If the InsertHistory table does not exist\n */\n private async _writeInsertHistory(\n table: string,\n insertHistoryRow: InsertHistoryRow<any>,\n ): Promise<void> {\n const insertHistoryTable = table + 'InsertHistory';\n\n //Write InsertHistory row to io\n await this.core.import({\n [insertHistoryTable]: {\n _data: [insertHistoryRow],\n _type: 'insertHistory',\n },\n });\n }\n\n // ...........................................................................\n /**\n * Add a head revision for a cake\n * @param cakeKey - The cake table key\n * @param cakeRef - The cake reference\n */\n public async addHeadRevision(cakeKey: string, cakeRef: Ref) {\n const cakeHeadKey = cakeKey + 'Heads';\n const cakeHeadController = await this.getController(cakeHeadKey);\n\n return await cakeHeadController.insert('add', {\n cakeRef,\n timeId: timeId(),\n _hash: '',\n } as Head);\n }\n\n // ...........................................................................\n /**\n * Add a multiEdit\n * @param cakeKey - The cake table key\n * @param multiEdit - The multiEdit to add\n */\n public async addMultiEdit(cakeKey: string, multiEdit: MultiEdit) {\n return this.insert(\n Route.fromFlat(cakeKey + 'MultiEdits'),\n {\n [cakeKey + 'MultiEdits']: {\n _data: [multiEdit],\n _type: 'multiEdits' as ContentType,\n } as MultiEditsTable,\n },\n { skipHistory: true },\n );\n }\n\n // ...........................................................................\n /**\n * Get multiEdits\n * @param cakeKey - The cake table key\n * @param where - The where clause to filter multiEdits\n */\n public async getMultiEdits(\n cakeKey: string,\n where: string | Json,\n ): Promise<MultiEdit[]> {\n const multiEditController = await this.getController(\n cakeKey + 'MultiEdits',\n );\n const { [cakeKey + 'MultiEdits']: result } = await multiEditController.get(\n where,\n );\n return result._data as MultiEdit[];\n }\n\n // ...........................................................................\n /**\n * Add an edit\n * @param cakeKey - The cake table key\n * @param edit - The edit to add\n */\n public async addEdit(cakeKey: string, edit: Edit) {\n return this.insert(\n Route.fromFlat(cakeKey + 'Edits'),\n {\n [cakeKey + 'Edits']: {\n _data: [edit],\n _type: 'edits' as ContentType,\n } as EditsTable,\n },\n { skipHistory: true },\n );\n }\n\n // ...........................................................................\n /**\n * Get edits\n * @param cakeKey - The cake table key\n * @param where - The where clause to filter edits\n */\n public async getEdits(\n cakeKey: string,\n where: string | Json,\n ): Promise<Edit[]> {\n const editController = await this.getController(cakeKey + 'Edits');\n const { [cakeKey + 'Edits']: result } = await editController.get(where);\n return result._data as Edit[];\n }\n\n // ...........................................................................\n /**\n * Add an edit history entry\n * @param cakeKey - The cake table key\n * @param editHistory - The edit history entry to add\n */\n public async addEditHistory(cakeKey: string, editHistory: EditHistory) {\n return this.insert(\n Route.fromFlat(cakeKey + 'EditHistory'),\n {\n [cakeKey + 'EditHistory']: {\n _data: [editHistory],\n _type: 'editHistory' as ContentType,\n } as EditHistoryTable,\n },\n { skipHistory: true },\n );\n }\n\n // ...........................................................................\n /**\n * Get edit history entries\n * @param cakeKey - The cake table key\n * @param where - The where clause to filter edit history entries\n */\n public async getEditHistories(\n cakeKey: string,\n where: string | Json,\n ): Promise<EditHistory[]> {\n const editHistoryController = await this.getController(\n cakeKey + 'EditHistory',\n );\n\n const { [cakeKey + 'EditHistory']: result } =\n await editHistoryController.get(where);\n\n /* v8 ignore next -- @preserve */\n return result._data.sort(\n (h1, h2) =>\n getTimeIdTimestamp(h2.timeId)! - getTimeIdTimestamp(h1.timeId)!,\n ) as EditHistory[];\n }\n\n // ...........................................................................\n /**\n * Get the InsertHistory of a table\n * @param table - The table to get the InsertHistory for\n * @throws {Error} If the InsertHistory table does not exist\n */\n async getInsertHistory(\n table: string,\n options?: { sorted?: boolean; ascending?: boolean },\n ): Promise<Rljson> {\n const insertHistoryTable = table + 'InsertHistory';\n const hasTable = await this.core.hasTable(insertHistoryTable);\n if (!hasTable) {\n throw new Error(`Db.getInsertHistory: Table ${table} does not exist`);\n }\n\n if (options === undefined) {\n options = { sorted: false, ascending: true };\n }\n\n if (options.sorted) {\n const dumpedTable = await this.core.dumpTable(insertHistoryTable);\n const tableData = dumpedTable[insertHistoryTable]\n ._data as InsertHistoryRow<any>[];\n\n //Sort table\n tableData.sort((a, b) =>\n options!.ascending\n ? a.timeId.localeCompare(b.timeId)\n : b.timeId.localeCompare(a.timeId),\n );\n\n return {\n [insertHistoryTable]: { _data: tableData, _type: 'insertHistory' },\n };\n }\n\n return this.core.dumpTable(insertHistoryTable);\n }\n\n // ...........................................................................\n /**\n * Get a specific InsertHistory row from a table\n * @param table - The table to get the InsertHistory row from\n * @param ref - The reference of the InsertHistory row to get\n * @returns The InsertHistory row or null if it does not exist\n * @throws {Error} If the Inserts table does not exist\n */\n async getInsertHistoryRowsByRef(\n table: string,\n ref: string,\n ): Promise<InsertHistoryRow<any>[]> {\n const insertHistoryTable = table + 'InsertHistory';\n const {\n [insertHistoryTable]: { _data: insertHistory },\n } = await this.core.readRows(insertHistoryTable, { [table + 'Ref']: ref });\n return insertHistory as InsertHistoryRow<any>[];\n }\n\n // ...........................................................................\n /**\n * Get a specific InsertHistory row from a table by its timeId\n * @param table - The table to get the InsertHistory row from\n * @param timeId - The timeId of the InsertHistory row to get\n * @returns The InsertHistory row or null if it does not exist\n * @throws {Error} If the Inserts table does not exist\n */\n async getInsertHistoryRowByTimeId(\n table: string,\n timeId: InsertHistoryTimeId,\n ): Promise<InsertHistoryRow<any>> {\n const insertHistoryTable = table + 'InsertHistory';\n const { [insertHistoryTable]: result } = await this.core.readRows(\n insertHistoryTable,\n {\n timeId,\n },\n );\n return result._data?.[0];\n }\n\n // ...........................................................................\n /**\n * Get all timeIds for a specific ref in a table\n * @param table - The table to get the timeIds from\n * @param ref - The reference to get the timeIds for\n * @returns An array of timeIds\n * @throws {Error} If the Inserts table does not exist\n */\n async getTimeIdsForRef(\n table: string,\n ref: Ref,\n ): Promise<InsertHistoryTimeId[]> {\n const insertHistoryTable = table + 'InsertHistory';\n const { [insertHistoryTable]: result } = await this.core.readRows(\n insertHistoryTable,\n {\n [table + 'Ref']: ref,\n },\n );\n return result._data?.map((r) => r.timeId);\n }\n\n // ...........................................................................\n /**\n * Get the ref for a specific timeId in a table\n * @param table - The table to get the ref from\n * @param timeId - The timeId to get the ref for\n * @returns The ref or null if it does not exist\n * @throws {Error} If the Inserts table does not exist\n */\n async getRefOfTimeId(\n table: string,\n timeId: InsertHistoryTimeId,\n ): Promise<Ref | null> {\n const insertHistoryTable = table + 'InsertHistory';\n const { [insertHistoryTable]: result } = await this.core.readRows(\n insertHistoryTable,\n {\n timeId,\n },\n );\n return (result._data?.[0] as any)?.[table + 'Ref'];\n }\n\n // ...........................................................................\n /**\n * Isolates the property key from the last segment of a route if it is a property of a component\n * @param route - The route to extract property key from\n * @returns A route with extracted property key\n */\n async isolatePropertyKeyFromRoute(route: Route): Promise<Route> {\n const segmentLength = route.segments.length;\n let propertyKey = '';\n let result: Route = route;\n for (let i = segmentLength; i > 0; i--) {\n const segment = route.segments[i - 1];\n const tableKey = segment.tableKey;\n const tableExists = await this._io.tableExists(tableKey);\n\n /* v8 ignore next -- @preserve */\n if (!tableExists) {\n propertyKey =\n propertyKey.length > 0\n ? segment.tableKey + '/' + propertyKey\n : segment.tableKey;\n result = result.upper();\n result.propertyKey = propertyKey;\n }\n }\n return result;\n }\n\n // ...........................................................................\n /**\n * Isolates a property from all components in an Rljson\n * @param rljson - The Rljson to isolate the property from\n * @param propertyKey - The property key to isolate\n * @returns A new Rljson with only the isolated property\n */\n isolatePropertyFromComponents(rljson: Rljson, propertyKey: string): Rljson {\n const result: Rljson = {};\n for (const tableKey of Object.keys(rljson)) {\n const table = rljson[tableKey];\n const newData = table._data.map((row: any) => {\n if (row.hasOwnProperty(propertyKey)) {\n return {\n [propertyKey]: row[propertyKey],\n _hash: row._hash,\n };\n } else {\n return row;\n }\n });\n result[tableKey] = {\n _type: table._type,\n _data: newData,\n };\n }\n return result;\n }\n\n // ...........................................................................\n /**\n * Clone the Db instance with a new Io instance\n * @param io - The new Io instance\n * @returns A new Db instance with the same cache as the current instance\n */\n clone(io: Io): Db {\n const newDb = new Db(io);\n newDb.setCache(new Map(this._cache));\n return newDb;\n }\n\n // ...........................................................................\n /**\n * Get the current cache of the Db instance\n */\n get cache() {\n return this._cache;\n }\n\n // ...........................................................................\n /**\n * Set the cache of the Db instance\n * @param cache - The new cache to set\n */\n setCache(cache: Map<string, Container>) {\n this._cache = cache;\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { EditAction } from '@rljson/rljson';\n\nimport { ColumnFilter } from '../join/filter/column-filter.ts';\nimport { RowFilter } from '../join/filter/row-filter.ts';\nimport {\n ColumnInfo,\n ColumnSelection,\n} from '../join/selection/column-selection.ts';\nimport { SetValue } from '../join/set-value/set-value.ts';\nimport { RowSortType } from '../join/sort/row-sort.ts';\n\nexport interface EditActionColumnSelection extends EditAction {\n type: 'selection';\n data: {\n columns: ColumnInfo[];\n };\n}\n\nexport interface EditActionRowFilter extends EditAction {\n type: 'filter';\n data: RowFilter;\n}\n\nexport interface EditActionSetValue extends EditAction {\n type: 'setValue';\n data: SetValue;\n}\n\nexport interface EditActionRowSort extends EditAction {\n type: 'sort';\n data: RowSortType;\n}\n\n//..................................................................................\n\n/**\n * Example EditAction of type 'selection'\n * @returns An example EditAction representing a column selection\n */\nexport const exampleEditActionColumnSelection =\n (): EditActionColumnSelection => ({\n name: 'Car Selection',\n type: 'selection',\n data: {\n columns: ColumnSelection.exampleCarsColumnSelection().columns,\n },\n _hash: '',\n });\n\n//..................................................................................\n\n/**\n * Example EditAction of type 'selection' with only some columns\n * @returns An example EditAction representing a column selection with limited columns\n */\nexport const exampleEditActionColumnSelectionOnlySomeColumns =\n (): EditActionColumnSelection => ({\n name: 'Car Selection - Some Columns',\n type: 'selection',\n data: {\n columns:\n ColumnSelection.exampleCarsColumnSelectionOnlySomeColumns().columns,\n },\n _hash: '',\n });\n\n//..................................................................................\n\n/**\n * Example EditAction of type 'filter'\n * @returns An example EditAction representing a row filter\n */\nexport const exampleEditActionRowFilter = (): EditActionRowFilter => ({\n name: 'Electric Cars Filter',\n type: 'filter',\n data: {\n columnFilters: [\n {\n type: 'boolean',\n column: 'carCake/carGeneralLayer/carGeneral/isElectric',\n operator: 'equals',\n search: true,\n _hash: '',\n },\n {\n type: 'number',\n column: 'carCake/carTechnicalLayer/carTechnical/carDimensions/length',\n operator: 'greaterThan',\n search: 4000,\n _hash: '',\n },\n ] as ColumnFilter<any>[],\n operator: 'and',\n value: true,\n _hash: '',\n },\n _hash: '',\n});\n\n/**\n * Example EditAction of type 'setValue'\n * @returns An example EditAction representing a set value action\n */\n\nexport const exampleEditActionSetValue = (): EditActionSetValue => ({\n name: 'Set: Service Intervals to [15000, 30000, 45000, 60000]',\n type: 'setValue',\n data: {\n route: 'carCake/carGeneralLayer/carGeneral/serviceIntervals',\n value: [15000, 30000, 45000, 60000],\n _hash: '',\n },\n _hash: '',\n});\n\n/**\n * Example EditAction of type 'setValue' for a referenced column\n * @returns An example EditAction representing a set value action for a referenced column\n */\nexport const exampleEditSetValueReferenced = (): EditActionSetValue => ({\n name: 'Set: Length to 4200',\n type: 'setValue',\n data: {\n route: 'carCake/carTechnicalLayer/carTechnical/carDimensions/length',\n value: 4800,\n _hash: '',\n },\n _hash: '',\n});\n\n/**\n * Example EditAction of type 'sort'\n * @returns An example EditAction representing a row sort action\n */\nexport const exampleEditActionRowSort = (): EditActionRowSort => ({\n name: 'Sort By Brand Edit',\n type: 'sort',\n data: {\n ['carCake/carGeneralLayer/carGeneral/brand']: 'asc',\n },\n _hash: '',\n});\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { Route, RouteRef, SliceId } from '@rljson/rljson';\n\nimport { Join } from '../join.ts';\nimport { ColumnSelection } from '../selection/column-selection.ts';\n\nexport type RowSortOrder = 'asc' | 'desc';\nexport type RowSortType = Record<RouteRef, RowSortOrder>;\n\n/// Sort configuration for catalog data\nexport class RowSort {\n constructor(columnSorts: Record<string, 'asc' | 'desc'>) {\n this._columnSorts = this._initColumnSorts(columnSorts);\n }\n\n // ...........................................................................\n /**\n * Sorts the rows of a join according to the sort configuration.\n * @param join - The join to be sorted\n * @returns Returns the row indices in a sorted manner\n */\n applyTo(join: Join): SliceId[] {\n if (join.rowCount === 0) {\n return join.rowIndices;\n }\n\n // Throw when filter specifies non existent column routes\n this._throwOnWrongRoutes(join);\n\n const routeHashes = join.columnSelection.routeHashes;\n\n // Generate an array of sort operators\n const sortIndices: number[] = [];\n const sortOrders: Array<'asc' | 'desc'> = [];\n\n let hasSorts = false;\n for (const item of this._columnSorts) {\n const index = routeHashes.indexOf(item.routeHash);\n sortIndices.push(index);\n sortOrders.push(item.order);\n\n hasSorts = true;\n }\n\n // No filters set? Return unchanged rows.\n if (!hasSorts) {\n return join.rowIndices;\n }\n\n // Apply the filters\n return this._sortRows(join, sortIndices, sortOrders);\n }\n\n // ...........................................................................\n /* v8 ignore next -- @preserve */\n get columnSorts(): Record<string, 'asc' | 'desc'> {\n const result: Record<string, 'asc' | 'desc'> = {};\n for (const sort of this._columnSorts) {\n result[sort.route] = sort.order;\n }\n\n return result;\n }\n\n // ######################\n // Private\n // ######################\n\n private readonly _columnSorts: _SortItem[];\n\n // ...........................................................................\n private _initColumnSorts(\n columnSorts: Record<string, 'asc' | 'desc'>,\n ): _SortItem[] {\n const result: _SortItem[] = [];\n const columns = Object.keys(columnSorts);\n const columnSelection = ColumnSelection.fromRoutes(\n columns.map((c) => Route.fromFlat(c)),\n );\n\n const routes = columnSelection.routes;\n const routeHashes = columnSelection.routeHashes;\n\n for (let i = 0; i < routes.length; i++) {\n const route = routes[i];\n const routeHash = routeHashes[i];\n result.push({\n route,\n routeHash,\n order: columnSorts[route],\n });\n }\n\n return result;\n }\n\n // ...........................................................................\n private _sortRows(\n join: Join,\n sortIndices: number[],\n sortOrders: Array<'asc' | 'desc'>,\n ): SliceId[] {\n const result = [...join.rowIndices];\n\n // Sort\n return result.sort((a, b) => {\n const rowA = join.row(a);\n const rowB = join.row(b);\n\n let i = 0;\n for (const index of sortIndices) {\n const sort = sortOrders[i++];\n //TODO: Make cells holding several values sortable\n\n /* v8 ignore next -- @preserve */\n const rowAInsertValues = rowA[index].inserts\n ? Array.isArray(rowA[index].inserts![0].cell[0].value)\n ? rowA[index].inserts![0].cell[0].value!\n : [rowA[index].inserts![0].cell[0].value!]\n : null;\n /* v8 ignore next -- @preserve */\n const rowAValue = rowA[index].value.cell[0].value\n ? Array.isArray(rowA[index].value?.cell[0].value)\n ? rowA[index].value.cell[0].value!\n : [rowA[index].value.cell[0].value!]\n : null;\n /* v8 ignore next -- @preserve */\n const rowBInsertValues = rowB[index].inserts\n ? Array.isArray(rowB[index].inserts![0].cell[0].value)\n ? rowB[index].inserts![0].cell[0].value!\n : [rowB[index].inserts![0].cell[0].value!]\n : null;\n /* v8 ignore next -- @preserve */\n const rowBValue = rowB[index].value.cell[0].value\n ? Array.isArray(rowB[index].value?.cell[0].value)\n ? rowB[index].value.cell[0].value!\n : [rowB[index].value.cell[0].value!]\n : null;\n /* v8 ignore next -- @preserve */\n const vA =\n rowAInsertValues && rowAInsertValues[0]\n ? rowAInsertValues[0]\n : rowAValue\n ? rowAValue[0]\n : null;\n /* v8 ignore next -- @preserve */\n const vB =\n rowBInsertValues && rowBInsertValues[0]\n ? rowBInsertValues[0]\n : rowBValue\n ? rowBValue[0]\n : null;\n\n if (vA === vB) {\n continue;\n }\n if (sort === 'asc') {\n return vA! < vB! ? -1 : 1;\n } else {\n return vA! < vB! ? 1 : -1;\n }\n }\n\n return 0;\n });\n }\n\n // ...........................................................................\n private _throwOnWrongRoutes(join: Join) {\n const availableRoutes = join.columnSelection.routes;\n for (const item of Object.values(this._columnSorts)) {\n const route = item.route;\n if (availableRoutes.includes(route) === false) {\n throw new Error(\n `RowFilterProcessor: Error while applying sort to join: ` +\n `There is a sort entry for route \"${route}\", but the join ` +\n `does not have a column with this route.\\n\\nAvailable routes:\\n` +\n `${availableRoutes.map((a: string) => `- ${a}`).join('\\n')}`,\n );\n }\n }\n }\n}\n\n// #############################################################################\ninterface _SortItem {\n order: 'asc' | 'desc';\n routeHash: string;\n\n route: string;\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { hip, rmhsh } from '@rljson/hash';\nimport { Edit, EditHistory, MultiEdit, Route } from '@rljson/rljson';\n\nimport { Db } from '../db.ts';\nimport { RowFilter } from '../join/filter/row-filter.ts';\nimport { Join, JoinRowsHashed } from '../join/join.ts';\nimport {\n ColumnInfo,\n ColumnSelection,\n} from '../join/selection/column-selection.ts';\nimport { SetValue } from '../join/set-value/set-value.ts';\nimport { RowSort, RowSortType } from '../join/sort/row-sort.ts';\n\nimport {\n EditColumnSelection,\n EditRowFilter,\n EditRowSort,\n EditSetValue,\n} from './edit.ts';\n\nexport type MultiEditColumnSelection = ColumnSelection;\nexport type MultiEditRowHashed = JoinRowsHashed;\nexport type MultiEditRows = any[][];\n\nexport class MultiEditProcessor {\n private _multiEdit: MultiEdit | null = null;\n private _edits: Edit[] = [];\n private _join: Join | null = null;\n\n constructor(\n private readonly _db: Db,\n private readonly _cakeKey: string,\n private readonly _cakeRef: string,\n ) {\n // Initialization code can go here\n }\n\n //...........................................................................\n /**\n * Create MultiEditProcessor from EditHistory\n * @param db - Db instance\n * @param cakeKey - Cake key\n * @param editHistory - EditHistory\n * @returns MultiEditProcessor\n */\n static async fromEditHistory(\n db: Db,\n cakeKey: string,\n editHistory: EditHistory,\n ): Promise<MultiEditProcessor> {\n /* v8 ignore if -- @preserve */\n if (!editHistory || !editHistory.multiEditRef) {\n throw new Error('MultiEditProcessor: Invalid EditHistory provided.');\n }\n\n const cakeRef = editHistory.dataRef;\n const multiEdits = await db.getMultiEdits(\n cakeKey,\n editHistory.multiEditRef,\n );\n\n /* v8 ignore if -- @preserve */\n if (!multiEdits || multiEdits.length === 0) {\n throw new Error(\n `MultiEditProcessor: MultiEdit not found for ref ${editHistory.multiEditRef}`,\n );\n }\n\n /* v8 ignore if -- @preserve */\n if (multiEdits.length > 1) {\n throw new Error(\n `MultiEditProcessor: Multiple MultiEdits found for ref ${editHistory.multiEditRef}`,\n );\n }\n\n const multiEdit = multiEdits[0];\n\n return MultiEditProcessor.fromMultiEdit(db, cakeKey, cakeRef, multiEdit);\n }\n\n //...........................................................................\n /**\n * Create MultiEditProcessor from MultiEdit\n * @param db - Db instance\n * @param cakeKey - Cake key\n * @param cakeRef - Cake ref\n * @param multiEdit - MultiEdit\n * @returns MultiEditProcessor\n */\n static async fromMultiEdit(\n db: Db,\n cakeKey: string,\n cakeRef: string,\n multiEdit: MultiEdit,\n ): Promise<MultiEditProcessor> {\n const processor = new MultiEditProcessor(db, cakeKey, cakeRef);\n await processor._resolve(multiEdit);\n await processor._processAll();\n return processor;\n }\n\n get join(): Join {\n /* v8 ignore if -- @preserve */\n if (!this._join) {\n throw new Error('MultiEditProcessor: Join not processed yet.');\n }\n return this._join;\n }\n\n get multiEdit(): MultiEdit {\n /* v8 ignore if -- @preserve */\n if (!this._multiEdit) {\n throw new Error('MultiEditProcessor: MultiEdit not resolved yet.');\n }\n return this._multiEdit;\n }\n\n get cakeRef(): string {\n return this._cakeRef;\n }\n\n //...........................................................................\n /**\n * Apply an Edit to the MultiEditProcessor\n * @param edit - Edit to apply\n * @returns MultiEditProcessor\n */\n async edit(edit: Edit): Promise<MultiEditProcessor> {\n this._edits.push(edit);\n this._join = await this._process(edit);\n /* v8 ignore next -- @preserve */\n this._multiEdit = hip<MultiEdit>({\n _hash: '',\n edit: edit._hash,\n previous: this.multiEdit ? this.multiEdit._hash : null,\n });\n return this;\n }\n\n async applyEditHistory(\n editHistory: EditHistory,\n ): Promise<MultiEditProcessor> {\n /* v8 ignore if -- @preserve */\n if (!editHistory || !editHistory.multiEditRef) {\n throw new Error('MultiEditProcessor: Invalid EditHistory provided.');\n }\n\n const multiEdits = await this._db.getMultiEdits(\n this._cakeKey,\n editHistory.multiEditRef,\n );\n\n /* v8 ignore if -- @preserve */\n if (!multiEdits || multiEdits.length === 0) {\n throw new Error(\n `MultiEditProcessor: MultiEdit not found for ref ${editHistory.multiEditRef}`,\n );\n }\n\n /* v8 ignore if -- @preserve */\n if (multiEdits.length > 1) {\n throw new Error(\n `MultiEditProcessor: Multiple MultiEdits found for ref ${editHistory.multiEditRef}`,\n );\n }\n\n const multiEdit = multiEdits[0];\n\n await this._resolve(multiEdit);\n await this._processAll();\n\n return this;\n }\n\n //...........................................................................\n /**\n * Publish the MultiEditProcessor. Inserts the resulting Join as new data,\n * updates the head revision, and saves the resulting MultiEdit.\n * @param options - Publish options\n * @returns MultiEditProcessor\n */\n async publish(options?: {\n skipHeadUpdate?: boolean;\n skipSaveMultiEdit?: boolean;\n }): Promise<MultiEditProcessor> {\n const inserts = this.join.insert();\n\n /* v8 ignore if -- @preserve */\n if (inserts.length === 0) {\n throw new Error('MultiEditProcessor: No inserts to publish.');\n }\n\n /* v8 ignore if -- @preserve */\n if (inserts.length > 1) {\n throw new Error(\n 'MultiEditProcessor: Multiple inserts not supported yet.',\n );\n }\n\n const insert = inserts[0];\n const inserteds = await this._db.insert(insert.route, insert.tree);\n\n /* v8 ignore if -- @preserve */\n if (inserteds.length === 0) {\n throw new Error('MultiEditProcessor: No rows inserted.');\n }\n /* v8 ignore if -- @preserve */\n if (inserteds.length > 1) {\n throw new Error(\n 'MultiEditProcessor: Multiple inserted rows not supported yet.',\n );\n }\n\n const inserted = inserteds[0];\n const writtenCakeRef = (inserted as any)[this._cakeKey + 'Ref'] as string;\n\n /* v8 ignore else -- @preserve */\n if (!options?.skipHeadUpdate) {\n await this._db.addHeadRevision(this._cakeKey, writtenCakeRef);\n }\n\n /* v8 ignore else -- @preserve */\n if (!options?.skipSaveMultiEdit) {\n await this._db.addMultiEdit(this._cakeKey, this._multiEdit!);\n }\n\n return new MultiEditProcessor(this._db, this._cakeKey, writtenCakeRef);\n }\n\n //...........................................................................\n /**\n * Clone the MultiEditProcessor\n * @returns Cloned MultiEditProcessor\n */\n clone(): MultiEditProcessor {\n const clone = new MultiEditProcessor(\n this._db,\n this._cakeKey,\n this._cakeRef,\n );\n clone._multiEdit = this._multiEdit;\n clone._edits = [...this._edits];\n clone._join = this._join;\n return clone;\n }\n\n //...........................................................................\n /**\n * Resolve MultiEdit chain recursively\n * @param multiEdit - MultiEdit to resolve\n * @returns Promise<void>\n */\n private async _resolve(multiEdit: MultiEdit): Promise<void> {\n this._multiEdit = multiEdit;\n\n const edits = await this._db.getEdits(this._cakeKey, multiEdit.edit);\n\n /* v8 ignore if -- @preserve */\n if (edits.length === 0) {\n throw new Error(\n `MultiEditProcessor: Edit not found for ref ${multiEdit.edit}`,\n );\n }\n\n /* v8 ignore if -- @preserve */\n if (edits.length > 1) {\n throw new Error(\n `MultiEditProcessor: Multiple Edits found for ref ${multiEdit.edit}`,\n );\n }\n\n const edit = edits[0];\n\n this._edits.push(edit);\n\n if (multiEdit.previous) {\n const previousMultiEdits = await this._db.getMultiEdits(\n this._cakeKey,\n multiEdit.previous!,\n );\n\n const previousMultiEdit = previousMultiEdits[0];\n\n const previousEditFromMultiEdit = previousMultiEdit.edit;\n const previousEdit = this._edits[this._edits.length - 2]\n ? this._edits[this._edits.length - 2]._hash\n : null;\n\n if (previousEdit !== previousEditFromMultiEdit) {\n return await this._resolve(previousMultiEdit);\n }\n }\n }\n\n //...........................................................................\n /**\n * Process all Edits in the MultiEditProcessor\n * @returns Resulting Join\n */\n private async _processAll(): Promise<Join> {\n for (let i = this._edits.length - 1; i >= 0; i--) {\n const edit = this._edits[i];\n this._join = await this._process(edit);\n }\n\n return this._join!;\n }\n\n //...........................................................................\n /**\n * Process a single Edit and update the Join\n * @param edit - Edit to process\n * @returns Resulting Join\n */\n private async _process(edit: Edit): Promise<Join> {\n const action = edit.action;\n if (!this._join) {\n switch (action.type) {\n case 'selection':\n const editColInfos = (edit as EditColumnSelection).action.data\n .columns as ColumnInfo[];\n const editColSelection = new ColumnSelection(editColInfos);\n this._join = await this._db.join(\n editColSelection,\n this._cakeKey,\n this._cakeRef,\n );\n break;\n case 'setValue':\n const editSetValue = (edit as EditSetValue).action.data as SetValue;\n const editSetValueKey = Route.fromFlat(editSetValue.route).segment()\n .tableKey;\n const editSetValueColumnInfo: ColumnInfo = {\n key: editSetValueKey,\n route: editSetValue.route,\n alias: editSetValueKey,\n titleLong: '',\n titleShort: '',\n type: 'jsonValue',\n _hash: '',\n };\n const editSetValueColSelection = new ColumnSelection([\n editSetValueColumnInfo,\n ]);\n this._join = (\n await this._db.join(\n editSetValueColSelection,\n this._cakeKey,\n this._cakeRef,\n )\n ).setValue(editSetValue);\n break;\n case 'sort':\n const editRowSort = rmhsh(edit as EditRowSort).action.data;\n const editRowSortColumnInfos: ColumnInfo[] = [];\n for (const routeStr of Object.keys(editRowSort)) {\n const route = Route.fromFlat(routeStr);\n const tableKey = route.segment().tableKey;\n const columnInfo: ColumnInfo = {\n key: tableKey,\n route: routeStr,\n alias: tableKey,\n titleLong: '',\n titleShort: '',\n type: 'jsonValue',\n _hash: '',\n };\n editRowSortColumnInfos.push(columnInfo);\n }\n const editRowSortColSelection = new ColumnSelection(\n editRowSortColumnInfos,\n );\n this._join = (\n await this._db.join(\n editRowSortColSelection,\n this._cakeKey,\n this._cakeRef,\n )\n ).sort(new RowSort(editRowSort));\n break;\n case 'filter':\n const editRowFilter = (edit as EditRowFilter).action.data;\n const editRowFilterColumnInfos: ColumnInfo[] = [];\n for (const colFilter of editRowFilter.columnFilters) {\n const route = Route.fromFlat(colFilter.column);\n const tableKey = route.segment().tableKey;\n const columnInfo: ColumnInfo = {\n key: tableKey,\n route: colFilter.column,\n alias: tableKey,\n titleLong: '',\n titleShort: '',\n type: 'jsonValue',\n _hash: '',\n };\n editRowFilterColumnInfos.push(columnInfo);\n }\n const editRowFilterColSelection = new ColumnSelection(\n editRowFilterColumnInfos,\n );\n this._join = (\n await this._db.join(\n editRowFilterColSelection,\n this._cakeKey,\n this._cakeRef,\n )\n ).filter(editRowFilter);\n break;\n /* v8 ignore next -- @preserve */\n default:\n break;\n }\n } else {\n switch (action.type) {\n case 'selection':\n const editColInfos = (edit as EditColumnSelection).action.data\n .columns as ColumnInfo[];\n const editColSelection = new ColumnSelection(editColInfos);\n this._join = this._join.select(editColSelection);\n break;\n case 'setValue':\n const editSetValue = rmhsh(\n (edit as EditSetValue).action.data as SetValue,\n );\n this._join = this._join.setValue(editSetValue);\n break;\n case 'sort':\n const editRowSort = rmhsh(\n (edit as EditRowSort).action.data,\n ) as RowSortType;\n this._join = this._join.sort(new RowSort(editRowSort));\n break;\n case 'filter':\n const editRowFilter = rmhsh(\n (edit as EditRowFilter).action.data,\n ) as RowFilter;\n this._join = this._join.filter(editRowFilter);\n break;\n /* v8 ignore next -- @preserve */\n default:\n break;\n }\n }\n\n return this._join!;\n }\n\n //...........................................................................\n /**\n * Get the list of Edits applied in this MultiEditProcessor\n * @returns Array of Edits\n */\n get edits(): Edit[] {\n return this._edits;\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { hsh } from '@rljson/hash';\nimport { Edit, EditHistory, InsertHistoryRow, MultiEdit, Route, timeId } from '@rljson/rljson';\n\nimport { Db } from '../db.ts';\nimport { Join } from '../join/join.ts';\n\nimport { MultiEditProcessor } from './multi-edit-processor.ts';\n\n\nexport class MultiEditManager {\n private _head: {\n editHistoryRef: string;\n processor: MultiEditProcessor;\n } | null = null;\n private _headListener: ((editHistoryRef: string) => Promise<void>)[] = [];\n private _processors: Map<string, MultiEditProcessor> = new Map();\n private _isListening: boolean = false;\n\n constructor(private readonly _cakeKey: string, private readonly _db: Db) {}\n\n init() {\n const editHistoryKey = `${this._cakeKey}EditHistory`;\n this._db.registerObserver(\n Route.fromFlat(editHistoryKey),\n (ins: InsertHistoryRow<string>) => {\n const editHistoryRef = (ins as any)[editHistoryKey + 'Ref'] as string;\n return this.editHistoryRef(editHistoryRef);\n },\n );\n this._isListening = true;\n }\n\n tearDown() {\n const editHistoryKey = `${this._cakeKey}EditHistory`;\n this._db.unregisterAllObservers(Route.fromFlat(editHistoryKey));\n this._isListening = false;\n }\n\n async edit(edit: Edit, cakeRef?: string) {\n /* v8 ignore next -- @preserve */\n if (!this.head && !cakeRef) {\n throw new Error(\n 'No head MultiEditProcessor available. Provide a cakeRef.',\n );\n }\n /* v8 ignore next -- @preserve */\n if (this.head && cakeRef) {\n throw new Error(\n 'Head MultiEditProcessor already exists. Do not provide a cakeRef.',\n );\n }\n\n // Store the new Edit\n await this._persistEdit(edit);\n\n let multiEditProc: MultiEditProcessor;\n if (!this.head) {\n const multiEdit: MultiEdit = {\n _hash: '',\n edit: hsh(edit)._hash,\n previous: null,\n };\n\n await this._persistMultiEdit(multiEdit);\n\n multiEditProc = await MultiEditProcessor.fromMultiEdit(\n this._db,\n this._cakeKey,\n cakeRef!,\n multiEdit,\n );\n } else {\n multiEditProc = await this.head.processor.edit(edit);\n }\n\n // Store the new MultiEdit\n const multiEditRef = await this._persistMultiEdit(multiEditProc.multiEdit);\n\n // Create and store the new EditHistory pointing to the new MultiEdit\n const editHistoryRef = await this._persistEditHistory({\n _hash: '',\n dataRef: multiEditProc.cakeRef,\n multiEditRef: await multiEditRef,\n timeId: timeId(),\n previous:\n !!this.head && this.head.editHistoryRef\n ? [this.head.editHistoryRef]\n : null,\n } as EditHistory);\n\n // Update internal state\n this._processors.set(editHistoryRef, multiEditProc);\n this._head = {\n editHistoryRef,\n processor: multiEditProc,\n };\n\n // Notify listeners about head change\n await this._notifyHeadListener(editHistoryRef);\n }\n\n async publish() {\n if (!this.head) {\n throw new Error('No head MultiEditProcessor available.');\n }\n return await this.head.processor.publish();\n }\n\n listenToHeadChanges(callback: (editHistoryRef: string) => Promise<void>) {\n this._headListener.push(callback);\n }\n\n private _notifyHeadListener(editHistoryRef: string) {\n /* v8 ignore next -- @preserve */\n return Promise.all(\n this._headListener.map((cb) => cb(editHistoryRef)),\n ).catch((err) => {\n console.error(\n `Error notifying head observers for editHistoryRef ${editHistoryRef}:`,\n err,\n );\n });\n }\n\n async editHistoryRef(editHistoryRef: string): Promise<MultiEditProcessor> {\n const editHistories = await this._db.getEditHistories(\n this._cakeKey,\n editHistoryRef,\n );\n\n /* v8 ignore if -- @preserve */\n if (editHistories.length === 0) {\n throw new Error(`EditHistory with ref ${editHistoryRef} not found.`);\n }\n\n /* v8 ignore if -- @preserve */\n if (editHistories.length > 1) {\n throw new Error(\n `Multiple EditHistories with ref ${editHistoryRef} found.`,\n );\n }\n\n const editHistory = editHistories[0];\n\n // Check if processor already exists\n if (this._processors.has(editHistoryRef)) {\n const processor = this._processors.get(editHistoryRef)!;\n this._head = {\n editHistoryRef,\n processor,\n };\n await this._notifyHeadListener(editHistoryRef);\n return processor;\n }\n\n // Handle case with previous edit history\n if (editHistory.previous && editHistory.previous.length > 0) {\n /* v8 ignore if -- @preserve */\n if (editHistory.previous.length > 1) {\n throw new Error(\n `EditHistory with ref ${editHistoryRef} has multiple previous refs. Not supported.`,\n );\n }\n\n const previousEditHistoryRef = editHistory.previous[0];\n const previousProcessor = await this.editHistoryRef(\n previousEditHistoryRef,\n );\n const previousProcessorCloned = previousProcessor.clone();\n\n const processor = await previousProcessorCloned.applyEditHistory(\n editHistory,\n );\n\n this._processors.set(editHistoryRef, processor);\n this._head = {\n editHistoryRef,\n processor,\n };\n await this._notifyHeadListener(editHistoryRef);\n return processor;\n }\n\n // Handle case without previous edit history (base case)\n const processor = await MultiEditProcessor.fromEditHistory(\n this._db,\n this._cakeKey,\n editHistory,\n );\n\n this._processors.set(editHistoryRef, processor);\n this._head = {\n editHistoryRef,\n processor,\n };\n await this._notifyHeadListener(editHistoryRef);\n return processor;\n }\n\n private async _persistEdit(edit: Edit): Promise<string> {\n // Store the new Edit\n const { [this._cakeKey + 'EditsRef']: editRef } = (\n await this._db.addEdit(this._cakeKey, edit)\n )[0] as any;\n\n /* v8 ignore next -- @preserve */\n if (!editRef) {\n throw new Error('MultiEditManager: Failed to create EditRef.');\n }\n return editRef;\n }\n\n private async _persistMultiEdit(multiEdit: MultiEdit): Promise<string> {\n // Create and store the new MultiEdit\n const { [this._cakeKey + 'MultiEditsRef']: multiEditRef } = (\n await this._db.addMultiEdit(this._cakeKey, multiEdit)\n )[0] as any;\n /* v8 ignore next -- @preserve */\n if (!multiEditRef) {\n throw new Error('MultiEditManager: Failed to create MultiEditRef.');\n }\n return multiEditRef;\n }\n\n private async _persistEditHistory(editHistory: EditHistory): Promise<string> {\n // Create and store the new EditHistory pointing to the new MultiEdit\n const { [this._cakeKey + 'EditHistoryRef']: editHistoryRef } = (\n await this._db.addEditHistory(this._cakeKey, editHistory)\n )[0] as any;\n /* v8 ignore next -- @preserve */\n if (!editHistoryRef) {\n throw new Error('MultiEditManager: Failed to create EditHistoryRef.');\n }\n return editHistoryRef;\n }\n\n get processors() {\n return this._processors;\n }\n\n get head() {\n return this._head;\n }\n\n get join(): Join {\n if (!this.head) {\n throw new Error('No head MultiEditProcessor available.');\n }\n return this.head.processor.join;\n }\n\n get isListening() {\n return this._isListening;\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { hip, hsh, rmhsh } from '@rljson/hash';\nimport { Json, JsonH, JsonValueH } from '@rljson/json';\nimport {\n CakeReference,\n CakesTable,\n ColumnCfg,\n ComponentsTable,\n ContentType,\n createCakeTableCfg,\n createHeadsTableCfg,\n createLayerTableCfg,\n createSliceIdsTableCfg,\n Layer,\n LayersTable,\n Rljson,\n SliceId,\n SliceIds,\n SliceIdsTable,\n TableCfg,\n TablesCfgTable,\n} from '@rljson/rljson';\n\n//Corporate Group\n//Companies\n//Branches\n//Sites\n\nexport interface StaticExample extends Rljson {\n carSliceId: SliceIdsTable;\n carGeneral: ComponentsTable<CarGeneral>;\n carTechnical: ComponentsTable<Json>;\n carColor: ComponentsTable<Json>;\n carDimensions: ComponentsTable<CarDimension>;\n carGeneralLayer: LayersTable;\n carTechnicalLayer: LayersTable;\n carColorLayer: LayersTable;\n carCake: CakesTable;\n seriesSliceId: SliceIdsTable;\n seriesGeneral: ComponentsTable<Json>;\n seriesCars: ComponentsTable<Json>;\n seriesGeneralLayer: LayersTable;\n seriesCarsLayer: LayersTable;\n seriesCake: CakesTable;\n catalogSliceId: SliceIdsTable;\n catalogSeries: ComponentsTable<Json>;\n catalogSeriesLayer: LayersTable;\n catalogCake: CakesTable;\n tableCfgs: TablesCfgTable;\n}\n\nexport interface CarGeneral extends JsonH {\n brand: string;\n type: string;\n doors: number;\n energyConsumption: number;\n units: JsonValueH;\n serviceIntervals: number[];\n isElectric: boolean;\n}\n\nexport interface CarDimension extends JsonH {\n height: number;\n width: number;\n length: number;\n}\n\nexport interface CarTechnical extends JsonH {\n engine: string;\n transmission: string;\n gears: number;\n carDimensionsRef: string;\n}\n\nconst chainLayers = (layers: Layer[]): Layer[] => {\n const chainedLayers: Layer[] = [];\n for (let i = 0; i < layers.length; i++) {\n const newLayer = { ...rmhsh(layers[i]) };\n if (i == 0) {\n chainedLayers.push(hsh<Layer>(newLayer));\n continue;\n }\n\n /* v8 ignore else -- @preserve */\n if (chainedLayers[i - 1]._hash) {\n newLayer.base = chainedLayers[i - 1]._hash as string;\n }\n chainedLayers.push(hsh<Layer>(newLayer));\n }\n return chainedLayers;\n};\n\nconst chainSliceIds = (sliceIds: SliceIds[]): SliceIds[] => {\n const chainedSliceIds: SliceIds[] = [];\n for (let i = 0; i < sliceIds.length; i++) {\n const newSliceIds = { ...rmhsh(sliceIds[i]) };\n /* v8 ignore else -- @preserve */\n if (i == 0) {\n chainedSliceIds.push(hsh<SliceIds>(newSliceIds));\n continue;\n }\n /* v8 ignore else -- @preserve */\n if (chainedSliceIds[i - 1]._hash) {\n newSliceIds.base = chainedSliceIds[i - 1]._hash as string;\n }\n chainedSliceIds.push(hsh<SliceIds>(newSliceIds));\n }\n return chainedSliceIds;\n};\n\nexport const staticExample = (): StaticExample => {\n //................................................................\n //Car Data Tables\n //................................................................\n\n //CarSliceId\n //................................................................\n const carSliceIdTableCfg = hip<TableCfg>(\n createSliceIdsTableCfg('carSliceId'),\n ) as TableCfg;\n\n const carSliceIdData: Array<SliceIds> = [\n {\n add: ['VIN1', 'VIN2', 'VIN3', 'VIN4', 'VIN5', 'VIN6', 'VIN7', 'VIN8'],\n _hash: '',\n } as SliceIds,\n {\n add: ['VIN9', 'VIN10'],\n _hash: '',\n } as SliceIds,\n {\n add: ['VIN11', 'VIN12'],\n _hash: '',\n } as SliceIds,\n ].map((sliceIds) => hsh<SliceIds>(sliceIds as SliceIds));\n\n const carSliceId = hip<any>({\n _tableCfg: carSliceIdTableCfg._hash,\n _type: 'sliceIds',\n _data: chainSliceIds(carSliceIdData),\n _hash: '',\n }) as SliceIdsTable;\n\n //CarGeneral\n //................................................................\n const carGeneralTableCfg = hip<TableCfg>({\n key: 'carGeneral',\n type: 'components',\n columns: [\n { key: '_hash', type: 'string', titleLong: 'Hash', titleShort: 'Hash' },\n { key: 'brand', type: 'string', titleLong: 'Brand', titleShort: 'Brand' },\n { key: 'type', type: 'string', titleLong: 'Type', titleShort: 'Type' },\n { key: 'doors', type: 'number', titleLong: 'Doors', titleShort: 'Doors' },\n {\n key: 'energyConsumption',\n type: 'number',\n titleLong: 'Energy Consumption',\n titleShort: 'Energy',\n },\n {\n key: 'units',\n type: 'json',\n titleLong: 'Energy Unit',\n titleShort: 'Unit',\n },\n {\n key: 'serviceIntervals',\n type: 'jsonArray',\n titleLong: 'Service Intervals',\n titleShort: 'Intervals',\n },\n {\n key: 'isElectric',\n type: 'boolean',\n titleLong: 'Is Electric',\n titleShort: 'Electric',\n },\n {\n key: 'meta',\n type: 'jsonValue',\n titleLong: 'Meta Information',\n titleShort: 'Meta',\n },\n ] as ColumnCfg[],\n isHead: false,\n isRoot: false,\n isShared: true,\n } as TableCfg);\n\n const carGeneral = hip<ComponentsTable<CarGeneral>>({\n _tableCfg: carGeneralTableCfg._hash as string,\n _type: 'components',\n _data: [\n {\n brand: 'Volkswagen',\n type: 'Polo',\n doors: 5,\n energyConsumption: 7.4,\n units: {\n energy: 'l/100km',\n _hash: '',\n },\n serviceIntervals: [15000, 30000, 45000],\n isElectric: false,\n meta: {\n pressText: 'A popular compact car.',\n _hash: '',\n },\n _hash: '',\n },\n {\n brand: 'Volkswagen',\n type: 'Golf',\n doors: 3,\n energyConsumption: 6.2,\n units: {\n energy: 'l/100km',\n _hash: '',\n },\n serviceIntervals: [15000, 30000, 45000],\n isElectric: false,\n meta: {\n pressText: 'A well-known hatchback.',\n _hash: '',\n },\n _hash: '',\n },\n {\n brand: 'Audi',\n type: 'Q4 E-tron',\n doors: 5,\n energyConsumption: 18.0,\n units: {\n energy: 'kWh/100km',\n _hash: '',\n },\n serviceIntervals: [20000, 40000, 60000],\n isElectric: true,\n meta: [\n {\n pressText: 'A stylish electric SUV.',\n _hash: '',\n },\n {\n pressText: 'Combines performance with sustainability.',\n _hash: '',\n },\n ],\n _hash: '',\n },\n {\n brand: 'Audi',\n type: 'Q6 E-tron',\n doors: 5,\n energyConsumption: 16.0,\n units: {\n energy: 'kWh/100km',\n _hash: '',\n },\n serviceIntervals: [20000, 40000, 60000],\n isElectric: true,\n meta: [\n {\n pressText: 'A premium electric SUV with advanced features.',\n _hash: '',\n },\n {\n pressText: 'Offers a blend of luxury and eco-friendliness.',\n _hash: '',\n },\n ],\n _hash: '',\n },\n {\n brand: 'BMW',\n type: 'i4',\n doors: 5,\n energyConsumption: 19.5,\n units: {\n energy: 'kWh/100km',\n _hash: '',\n },\n serviceIntervals: [20000, 40000, 60000],\n isElectric: true,\n meta: [\n {\n pressText: 'A sporty electric sedan.',\n _hash: '',\n },\n {\n pressText: 'Delivers dynamic performance with zero emissions.',\n _hash: '',\n },\n ],\n _hash: '',\n },\n {\n brand: 'BMW',\n type: '3 Series',\n doors: 4,\n energyConsumption: 5.8,\n units: {\n energy: 'l/100km',\n _hash: '',\n },\n serviceIntervals: [15000, 30000, 45000],\n isElectric: false,\n meta: {\n pressText: 'A classic executive car.',\n _hash: '',\n },\n _hash: '',\n },\n {\n brand: 'Tesla',\n type: 'Model 3',\n doors: 4,\n energyConsumption: 15.0,\n units: {\n energy: 'kWh/100km',\n _hash: '',\n },\n serviceIntervals: [25000, 50000, 75000],\n isElectric: true,\n meta: {\n pressText: 'A revolutionary electric sedan.',\n _hash: '',\n },\n _hash: '',\n },\n {\n brand: 'Tesla',\n type: 'Model Y',\n doors: 5,\n energyConsumption: 16.5,\n units: {\n energy: 'kWh/100km',\n _hash: '',\n },\n serviceIntervals: [25000, 50000, 75000],\n isElectric: true,\n meta: {\n pressText: 'A versatile electric SUV.',\n _hash: '',\n },\n _hash: '',\n },\n {\n brand: 'Ford',\n type: 'Mustang Mach-E',\n doors: 5,\n energyConsumption: 17.0,\n units: {\n energy: 'kWh/100km',\n _hash: '',\n },\n serviceIntervals: [20000, 40000, 60000],\n isElectric: true,\n meta: {\n pressText: 'An electric SUV with Mustang heritage.',\n _hash: '',\n },\n _hash: '',\n },\n {\n brand: 'Chevrolet',\n type: 'Bolt EV',\n doors: 5,\n energyConsumption: 14.0,\n units: {\n energy: 'kWh/100km',\n _hash: '',\n },\n serviceIntervals: [20000, 40000, 60000],\n isElectric: true,\n meta: {\n pressText: 'An affordable electric hatchback.',\n _hash: '',\n },\n _hash: '',\n },\n {\n brand: 'Nissan',\n type: 'Leaf',\n doors: 5,\n energyConsumption: 15.5,\n units: {\n energy: 'kWh/100km',\n _hash: '',\n },\n serviceIntervals: [20000, 40000, 60000],\n isElectric: true,\n meta: {\n pressText: 'A pioneering electric vehicle.',\n _hash: '',\n },\n _hash: '',\n },\n {\n brand: 'Hyundai',\n type: 'Kona Electric',\n doors: 5,\n energyConsumption: 14.5,\n units: {\n energy: 'kWh/100km',\n _hash: '',\n },\n serviceIntervals: [20000, 40000, 60000],\n isElectric: true,\n meta: {\n pressText: 'A compact electric SUV.',\n _hash: '',\n },\n _hash: '',\n },\n ],\n _hash: '',\n }) as ComponentsTable<CarGeneral>;\n\n //CarDimensions\n //................................................................\n const carDimensionsTableCfg = hip<any>({\n key: 'carDimensions',\n type: 'components',\n columns: [\n { key: '_hash', type: 'string' },\n { key: 'height', type: 'number' },\n { key: 'width', type: 'number' },\n { key: 'length', type: 'number' },\n ],\n isHead: false,\n isRoot: false,\n isShared: true,\n }) as TableCfg;\n\n const carDimensions = hip<any>({\n _tableCfg: carDimensionsTableCfg._hash,\n _type: 'components',\n _data: [\n {\n height: 1400,\n width: 1800,\n length: 4000,\n _hash: '',\n },\n {\n height: 1450,\n width: 1850,\n length: 4100,\n _hash: '',\n },\n {\n height: 1600,\n width: 1900,\n length: 4500,\n _hash: '',\n },\n {\n height: 1650,\n width: 1950,\n length: 4700,\n _hash: '',\n },\n {\n height: 1500,\n width: 1820,\n length: 4200,\n _hash: '',\n },\n {\n height: 1550,\n width: 1880,\n length: 4300,\n _hash: '',\n },\n {\n height: 1450,\n width: 1830,\n length: 4150,\n _hash: '',\n },\n {\n height: 1700,\n width: 2000,\n length: 4800,\n _hash: '',\n },\n {\n height: 1350,\n width: 1750,\n length: 3900,\n _hash: '',\n },\n {\n height: 1750,\n width: 2050,\n length: 4900,\n _hash: '',\n },\n {\n height: 1600,\n width: 1920,\n length: 4600,\n _hash: '',\n },\n ],\n _hash: '',\n } as ComponentsTable<CarDimension>) as ComponentsTable<CarDimension>;\n\n //CarTechnical\n //................................................................\n const carTechnicalTableCfg = hip<any>({\n key: 'carTechnical',\n type: 'components',\n columns: [\n { key: '_hash', type: 'string' },\n { key: 'engine', type: 'string' },\n { key: 'transmission', type: 'string' },\n { key: 'gears', type: 'number' },\n {\n key: 'dimensions',\n type: 'jsonValue',\n ref: {\n tableKey: 'carDimensions',\n type: 'components',\n },\n } as ColumnCfg,\n { key: 'repairedByWorkshop', type: 'string' },\n ],\n isHead: false,\n isRoot: false,\n isShared: true,\n }) as TableCfg;\n\n const carTechnical = hip<any>({\n _tableCfg: carTechnicalTableCfg._hash,\n _type: 'components',\n _data: [\n {\n engine: 'Diesel',\n transmission: 'Manual',\n gears: 6,\n dimensions: carDimensions._data[0]._hash,\n _hash: '',\n },\n {\n engine: 'Petrol',\n transmission: 'Automatic',\n gears: 7,\n dimensions: carDimensions._data[1]._hash,\n repairedByWorkshop: 'Workshop A',\n _hash: '',\n },\n {\n engine: 'Electric',\n transmission: 'Single-Speed',\n gears: 1,\n dimensions: [\n carDimensions._data[1]._hash,\n carDimensions._data[2]._hash,\n ],\n _hash: '',\n },\n {\n engine: 'Electric',\n transmission: 'Single-Speed',\n gears: 1,\n dimensions: carDimensions._data[3]._hash,\n repairedByWorkshop: 'Workshop B',\n _hash: '',\n },\n {\n engine: 'Electric',\n transmission: 'Single-Speed',\n gears: 1,\n dimensions: carDimensions._data[4]._hash,\n _hash: '',\n },\n {\n engine: 'Petrol',\n transmission: 'Manual',\n gears: 6,\n dimensions: carDimensions._data[5]._hash,\n repairedByWorkshop: 'Workshop A',\n _hash: '',\n },\n {\n engine: 'Electric',\n transmission: 'Single-Speed',\n gears: 1,\n dimensions: carDimensions._data[6]._hash,\n _hash: '',\n },\n {\n engine: 'Electric',\n transmission: 'Single-Speed',\n gears: 1,\n dimensions: carDimensions._data[7]._hash,\n repairedByWorkshop: 'Workshop C',\n _hash: '',\n },\n {\n engine: 'Electric',\n transmission: 'Single-Speed',\n gears: 1,\n dimensions: carDimensions._data[8]._hash,\n _hash: '',\n },\n {\n engine: 'Electric',\n transmission: 'Single-Speed',\n gears: 1,\n dimensions: carDimensions._data[9]._hash,\n repairedByWorkshop: 'Workshop B',\n _hash: '',\n },\n {\n engine: 'Electric',\n transmission: 'Single-Speed',\n gears: 1,\n dimensions: carDimensions._data[10]._hash,\n _hash: '',\n },\n ],\n _hash: '',\n }) as ComponentsTable<Json>;\n\n //CarColor\n //................................................................\n const carColorTableCfg = hip<any>({\n key: 'carColor',\n type: 'components',\n columns: [\n { key: '_hash', type: 'string' },\n { key: 'sides', type: 'string' },\n { key: 'roof', type: 'string' },\n { key: 'highlights', type: 'string' },\n ],\n isHead: false,\n isRoot: false,\n isShared: true,\n }) as TableCfg;\n\n const carColor = hip<any>({\n _tableCfg: carColorTableCfg._hash,\n _type: 'components',\n _data: [\n {\n sides: 'green',\n roof: 'white',\n highlights: 'chrome',\n _hash: '',\n },\n {\n sides: 'blue',\n roof: 'black',\n highlights: 'chrome',\n _hash: '',\n },\n {\n sides: 'red',\n roof: 'red',\n highlights: 'black',\n _hash: '',\n },\n {\n sides: 'silver',\n roof: 'silver',\n highlights: 'chrome',\n _hash: '',\n },\n {\n sides: 'black',\n roof: 'black',\n highlights: 'black',\n _hash: '',\n },\n {\n sides: 'white',\n roof: 'white',\n highlights: 'chrome',\n _hash: '',\n },\n {\n sides: 'grey',\n roof: 'black',\n highlights: 'chrome',\n _hash: '',\n },\n {\n sides: 'red',\n roof: 'white',\n highlights: 'black',\n _hash: '',\n },\n ],\n _hash: '',\n }) as ComponentsTable<Json>;\n\n //CarLayers and CarCake\n //................................................................\n const carGeneralLayerTableCfg = hip<TableCfg>(\n createLayerTableCfg('carGeneralLayer'),\n ) as TableCfg;\n\n const carGeneralLayerData: Array<Layer> = [\n {\n add: {\n VIN1: carGeneral._data[0]._hash,\n VIN2: carGeneral._data[1]._hash,\n VIN3: carGeneral._data[2]._hash,\n VIN4: carGeneral._data[3]._hash,\n VIN5: carGeneral._data[4]._hash,\n VIN6: carGeneral._data[5]._hash,\n VIN7: carGeneral._data[6]._hash,\n VIN8: carGeneral._data[7]._hash,\n _hash: '',\n },\n sliceIdsTable: 'carSliceId',\n sliceIdsTableRow: carSliceId._data[0]._hash as string,\n componentsTable: 'carGeneral',\n _hash: '',\n } as Layer,\n {\n add: {\n VIN9: carGeneral._data[8]._hash,\n VIN10: carGeneral._data[9]._hash,\n _hash: '',\n },\n sliceIdsTable: 'carSliceId',\n sliceIdsTableRow: carSliceId._data[1]._hash as string,\n componentsTable: 'carGeneral',\n _hash: '',\n },\n {\n add: {\n VIN11: carGeneral._data[10]._hash,\n VIN12: carGeneral._data[11]._hash,\n _hash: '',\n },\n sliceIdsTable: 'carSliceId',\n sliceIdsTableRow: carSliceId._data[2]._hash as string,\n componentsTable: 'carGeneral',\n _hash: '',\n },\n ].map((layer) => hsh<Layer>(layer as Layer));\n\n const carGeneralLayer = hip<any>({\n _tableCfg: carGeneralLayerTableCfg._hash,\n _type: 'layers',\n _data: chainLayers(carGeneralLayerData),\n _hash: '',\n }) as LayersTable;\n\n const carTechnicalLayerTableCfg = hip<TableCfg>(\n createLayerTableCfg('carTechnicalLayer'),\n ) as TableCfg;\n\n const carTechnicalLayerData: Array<Layer> = [\n {\n add: {\n VIN1: carTechnical._data[0]._hash,\n VIN2: carTechnical._data[1]._hash,\n VIN3: carTechnical._data[2]._hash,\n VIN4: carTechnical._data[2]._hash,\n VIN5: carTechnical._data[4]._hash,\n VIN6: carTechnical._data[5]._hash,\n VIN7: carTechnical._data[6]._hash,\n VIN8: carTechnical._data[2]._hash,\n _hash: '',\n },\n sliceIdsTable: 'carSliceId',\n sliceIdsTableRow: carSliceId._data[0]._hash,\n componentsTable: 'carTechnical',\n _hash: '',\n } as Layer,\n {\n add: {\n VIN9: carTechnical._data[7]._hash,\n VIN10: carTechnical._data[8]._hash,\n _hash: '',\n },\n sliceIdsTable: 'carSliceId',\n sliceIdsTableRow: carSliceId._data[1]._hash,\n componentsTable: 'carTechnical',\n _hash: '',\n } as Layer,\n {\n add: {\n VIN11: carTechnical._data[9]._hash,\n VIN12: carTechnical._data[10]._hash,\n _hash: '',\n },\n sliceIdsTable: 'carSliceId',\n sliceIdsTableRow: carSliceId._data[2]._hash,\n componentsTable: 'carTechnical',\n _hash: '',\n } as Layer,\n ].map((layer) => hsh<Layer>(layer as Layer));\n\n const carTechnicalLayer = hip<any>({\n _tableCfg: carTechnicalLayerTableCfg._hash,\n _type: 'layers',\n _data: chainLayers(carTechnicalLayerData),\n _hash: '',\n }) as LayersTable;\n\n const carColorLayerTableCfg = hip<TableCfg>(\n createLayerTableCfg('carColorLayer'),\n ) as TableCfg;\n\n const carColorLayerData: Array<Layer> = [\n {\n add: {\n VIN1: carColor._data[0]._hash,\n VIN2: carColor._data[1]._hash,\n VIN3: carColor._data[2]._hash,\n VIN4: carColor._data[3]._hash,\n VIN5: carColor._data[4]._hash,\n VIN6: carColor._data[5]._hash,\n VIN7: carColor._data[6]._hash,\n VIN8: carColor._data[7]._hash,\n _hash: '',\n },\n sliceIdsTable: 'carSliceId',\n sliceIdsTableRow: carSliceId._data[0]._hash,\n componentsTable: 'carColor',\n _hash: '',\n } as Layer,\n {\n add: {\n VIN9: carColor._data[3]._hash,\n VIN10: carColor._data[3]._hash,\n _hash: '',\n },\n sliceIdsTable: 'carSliceId',\n sliceIdsTableRow: carSliceId._data[1]._hash,\n componentsTable: 'carColor',\n _hash: '',\n } as Layer,\n {\n add: {\n VIN11: carColor._data[7]._hash,\n VIN12: carColor._data[4]._hash,\n _hash: '',\n },\n sliceIdsTable: 'carSliceId',\n sliceIdsTableRow: carSliceId._data[2]._hash,\n componentsTable: 'carColor',\n _hash: '',\n } as Layer,\n ].map((layer) => hsh<Layer>(layer as Layer));\n\n const carColorLayer = hip<any>({\n _tableCfg: carColorLayerTableCfg._hash,\n _type: 'layers',\n _data: chainLayers(carColorLayerData),\n _hash: '',\n }) as LayersTable;\n\n const carCakeTableCfg = hip<TableCfg>(\n createCakeTableCfg('carCake'),\n ) as TableCfg;\n\n const carCake = hip<any>({\n _tableCfg: carCakeTableCfg._hash,\n _type: 'cakes',\n _data: [\n {\n sliceIdsTable: 'carSliceId',\n sliceIdsRow: carSliceId._data[0]._hash,\n layers: {\n carGeneralLayer: carGeneralLayer._data[0]._hash,\n carTechnicalLayer: carTechnicalLayer._data[0]._hash,\n carColorLayer: carColorLayer._data[0]._hash,\n },\n },\n {\n sliceIdsTable: 'carSliceId',\n sliceIdsRow: carSliceId._data[1]._hash,\n layers: {\n carGeneralLayer: carGeneralLayer._data[1]._hash,\n carTechnicalLayer: carTechnicalLayer._data[1]._hash,\n carColorLayer: carColorLayer._data[1]._hash,\n },\n },\n {\n sliceIdsTable: 'carSliceId',\n sliceIdsRow: carSliceId._data[2]._hash,\n layers: {\n carGeneralLayer: carGeneralLayer._data[2]._hash,\n carTechnicalLayer: carTechnicalLayer._data[2]._hash,\n carColorLayer: carColorLayer._data[2]._hash,\n },\n },\n ],\n }) as CakesTable;\n\n //CarCakeHead\n //................................................................\n const carCakeHeadTableCfg = hip<TableCfg>(\n createHeadsTableCfg('carCake'),\n ) as TableCfg;\n\n const carCakeHeads = hip<any>({\n _tableCfg: carCakeHeadTableCfg._hash,\n _type: 'head' as ContentType,\n _data: [\n {\n timeId: '1764756756311:jkCG',\n cakeRef: carCake._data[0]._hash,\n },\n {\n timeId: '1764756756312:1AGV',\n cakeRef: carCake._data[1]._hash,\n },\n {\n timeId: '1764756756312:g8nh',\n cakeRef: carCake._data[2]._hash,\n },\n ],\n }) as CakesTable;\n\n //................................................................\n //Series Data Tables\n //................................................................\n\n //SeriesSliceId\n //................................................................\n\n const seriesSliceIdTableCfg = hip<TableCfg>(\n createSliceIdsTableCfg('seriesSliceId'),\n ) as TableCfg;\n\n const seriesSliceIdData: Array<SliceIds> = [\n {\n add: ['Serie0', 'Serie1', 'Serie2', 'Serie3'],\n _hash: '',\n } as SliceIds,\n {\n add: ['Serie4', 'Serie5', 'Serie6', 'Serie7'],\n _hash: '',\n } as SliceIds,\n {\n add: ['Serie8', 'Serie9', 'Serie10', 'Serie11'],\n _hash: '',\n } as SliceIds,\n ].map((sliceIds) => hsh<SliceIds>(sliceIds as SliceIds));\n\n const seriesSliceId = hip<any>({\n _tableCfg: seriesSliceIdTableCfg._hash,\n _type: 'sliceIds',\n _data: chainSliceIds(seriesSliceIdData),\n _hash: '',\n }) as SliceIdsTable;\n\n //SeriesGeneral\n //................................................................\n const seriesGeneralTableCfg = hip<TableCfg>({\n key: 'seriesGeneral',\n type: 'components',\n columns: [\n { key: '_hash', type: 'string', titleShort: 'Hash', titleLong: 'Hash' },\n { key: 'name', type: 'string', titleShort: 'Name', titleLong: 'Name' },\n ] as ColumnCfg[],\n isHead: false,\n isRoot: false,\n isShared: true,\n } as TableCfg);\n\n const seriesGeneral = hip<ComponentsTable<Json>>({\n _tableCfg: seriesGeneralTableCfg._hash as string,\n _type: 'components',\n _data: [\n {\n name: 'Polo',\n _hash: '',\n },\n {\n name: 'Golf',\n _hash: '',\n },\n {\n name: 'Q4',\n _hash: '',\n },\n {\n name: 'Q6',\n _hash: '',\n },\n {\n name: 'i4',\n _hash: '',\n },\n {\n name: '3',\n _hash: '',\n },\n {\n name: 'Model 3',\n _hash: '',\n },\n {\n name: 'Model Y',\n _hash: '',\n },\n {\n name: 'Mustang',\n _hash: '',\n },\n {\n name: 'Bolt',\n _hash: '',\n },\n {\n name: 'Leaf',\n _hash: '',\n },\n {\n name: 'Kona',\n _hash: '',\n },\n ],\n _hash: '',\n }) as ComponentsTable<Json>;\n\n //................................................................\n //SeriesCars\n\n const seriesCarsTableCfg = hip<TableCfg>({\n key: 'seriesCars',\n type: 'components',\n columns: [\n { key: '_hash', type: 'string', titleShort: 'Hash', titleLong: 'Hash' },\n {\n key: 'cars',\n type: 'jsonArray',\n titleShort: 'Cars',\n titleLong: 'Cars References',\n ref: {\n tableKey: 'carCake',\n type: 'cakes',\n },\n } as ColumnCfg,\n ] as ColumnCfg[],\n isHead: false,\n isRoot: false,\n isShared: true,\n } as TableCfg);\n\n const seriesCars = hip<\n ComponentsTable<{ _hash: string; cars: CakeReference[] }>\n >({\n _tableCfg: seriesCarsTableCfg._hash as string,\n _type: 'components',\n _data: [\n {\n cars: [\n {\n ref: carCake._data[2]._hash as string,\n sliceIds: ['VIN1'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n cars: [\n {\n ref: carCake._data[2]._hash as string,\n sliceIds: ['VIN2'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n cars: [\n {\n ref: carCake._data[0]._hash as string,\n sliceIds: ['VIN3'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n cars: [\n {\n ref: carCake._data[0]._hash as string,\n sliceIds: ['VIN4'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n cars: [\n {\n ref: carCake._data[1]._hash as string,\n sliceIds: ['VIN5'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n cars: [\n {\n ref: carCake._data[1]._hash as string,\n sliceIds: ['VIN6'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n cars: [\n {\n ref: carCake._data[2]._hash as string,\n sliceIds: ['VIN7'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n cars: [\n {\n ref: carCake._data[2]._hash as string,\n sliceIds: ['VIN8'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n cars: [\n {\n ref: carCake._data[2]._hash as string,\n sliceIds: ['VIN9'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n cars: [\n {\n ref: carCake._data[2]._hash as string,\n sliceIds: ['VIN10'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n cars: [\n {\n ref: carCake._data[2]._hash as string,\n sliceIds: ['VIN11'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n cars: [\n {\n ref: carCake._data[2]._hash as string,\n sliceIds: ['VIN12'] as SliceId[],\n },\n ],\n _hash: '',\n },\n ],\n _hash: '',\n });\n\n //SeriesLayers and SeriesCake\n //................................................................\n\n const seriesGeneralLayerTableCfg = hip<TableCfg>(\n createLayerTableCfg('seriesGeneralLayer'),\n ) as TableCfg;\n\n const seriesGeneralLayerData: Array<Layer> = [\n {\n add: {\n Serie0: seriesGeneral._data[0]._hash,\n Serie1: seriesGeneral._data[1]._hash,\n Serie2: seriesGeneral._data[2]._hash,\n Serie3: seriesGeneral._data[3]._hash,\n _hash: '',\n },\n sliceIdsTable: 'seriesSliceId',\n sliceIdsTableRow: seriesSliceId._data[0]._hash as string,\n componentsTable: 'seriesGeneral',\n _hash: '',\n } as Layer,\n {\n add: {\n Serie4: seriesGeneral._data[4]._hash,\n Serie5: seriesGeneral._data[5]._hash,\n Serie6: seriesGeneral._data[6]._hash,\n Serie7: seriesGeneral._data[7]._hash,\n _hash: '',\n },\n sliceIdsTable: 'seriesSliceId',\n sliceIdsTableRow: seriesSliceId._data[1]._hash as string,\n componentsTable: 'seriesGeneral',\n _hash: '',\n },\n {\n add: {\n Serie8: seriesGeneral._data[8]._hash,\n Serie9: seriesGeneral._data[9]._hash,\n Serie10: seriesGeneral._data[10]._hash,\n Serie11: seriesGeneral._data[11]._hash,\n _hash: '',\n },\n sliceIdsTable: 'seriesSliceId',\n sliceIdsTableRow: seriesSliceId._data[2]._hash as string,\n componentsTable: 'seriesGeneral',\n _hash: '',\n },\n ].map((layer) => hsh<Layer>(layer as Layer));\n\n const seriesGeneralLayer = hip<any>({\n _tableCfg: seriesGeneralLayerTableCfg._hash,\n _type: 'layers',\n _data: chainLayers(seriesGeneralLayerData),\n _hash: '',\n }) as LayersTable;\n\n const seriesCarsLayerTableCfg = hip<TableCfg>(\n createLayerTableCfg('seriesCarsLayer'),\n ) as TableCfg;\n\n const seriesCarsLayerData: Array<Layer> = [\n {\n add: {\n Serie0: seriesCars._data[0]._hash,\n Serie1: seriesCars._data[1]._hash,\n Serie2: seriesCars._data[2]._hash,\n Serie3: seriesCars._data[3]._hash,\n _hash: '',\n },\n sliceIdsTable: 'seriesSliceId',\n sliceIdsTableRow: seriesSliceId._data[0]._hash,\n componentsTable: 'seriesCars',\n _hash: '',\n } as Layer,\n {\n add: {\n Serie4: seriesCars._data[4]._hash,\n Serie5: seriesCars._data[5]._hash,\n Serie6: seriesCars._data[6]._hash,\n Serie7: seriesCars._data[7]._hash,\n _hash: '',\n },\n sliceIdsTable: 'seriesSliceId',\n sliceIdsTableRow: seriesSliceId._data[1]._hash,\n componentsTable: 'seriesCars',\n _hash: '',\n } as Layer,\n {\n add: {\n Serie8: seriesCars._data[8]._hash,\n Serie9: seriesCars._data[9]._hash,\n Serie10: seriesCars._data[10]._hash,\n Serie11: seriesCars._data[11]._hash,\n _hash: '',\n },\n sliceIdsTable: 'seriesSliceId',\n sliceIdsTableRow: seriesSliceId._data[2]._hash,\n componentsTable: 'seriesCars',\n _hash: '',\n } as Layer,\n ].map((layer) => hsh<Layer>(layer as Layer));\n\n const seriesCarsLayer = hip<any>({\n _tableCfg: seriesCarsLayerTableCfg._hash,\n _type: 'layers',\n _data: chainLayers(seriesCarsLayerData),\n });\n\n const seriesCakeTableCfg = hip<TableCfg>(\n createCakeTableCfg('seriesCake'),\n ) as TableCfg;\n\n const seriesCake = hip<any>({\n _tableCfg: seriesCakeTableCfg._hash,\n _type: 'cakes',\n _data: [\n {\n sliceIdsTable: 'seriesSliceId',\n sliceIdsRow: seriesSliceId._data[0]._hash,\n layers: {\n seriesGeneralLayer: seriesGeneralLayer._data[0]._hash,\n seriesCarsLayer: seriesCarsLayer._data[0]._hash,\n },\n },\n {\n sliceIdsTable: 'seriesSliceId',\n sliceIdsRow: seriesSliceId._data[1]._hash,\n layers: {\n seriesGeneralLayer: seriesGeneralLayer._data[1]._hash,\n seriesCarsLayer: seriesCarsLayer._data[1]._hash,\n },\n },\n {\n sliceIdsTable: 'seriesSliceId',\n sliceIdsRow: seriesSliceId._data[2]._hash,\n layers: {\n seriesGeneralLayer: seriesGeneralLayer._data[2]._hash,\n seriesCarsLayer: seriesCarsLayer._data[2]._hash,\n },\n },\n ],\n }) as CakesTable;\n\n //SeriesCakeHead\n //................................................................\n const seriesCakeHeadTableCfg = hip<TableCfg>(\n createHeadsTableCfg('seriesCake'),\n ) as TableCfg;\n\n const seriesCakeHeads = hip<any>({\n _tableCfg: seriesCakeHeadTableCfg._hash,\n _type: 'head' as ContentType,\n _data: [\n {\n timeId: '1764756756315:L14y',\n cakeRef: seriesCake._data[0]._hash,\n },\n {\n timeId: '1764756756315:xCXT',\n cakeRef: seriesCake._data[1]._hash,\n },\n {\n timeId: '1764756756315:fZwA',\n cakeRef: seriesCake._data[2]._hash,\n },\n ],\n }) as CakesTable;\n\n //................................................................\n //Series Data Tables\n //................................................................\n\n //SeriesSliceId\n //................................................................\n\n const catalogSliceIdTableCfg = hip<TableCfg>(\n createSliceIdsTableCfg('catalogSliceId'),\n ) as TableCfg;\n\n const catalogSliceIdData: Array<SliceIds> = [\n {\n add: ['Catalog0', 'Catalog1'],\n _hash: '',\n } as SliceIds,\n ].map((sliceIds) => hsh<SliceIds>(sliceIds as SliceIds));\n\n const catalogSliceId = hip<any>({\n _tableCfg: catalogSliceIdTableCfg._hash,\n _type: 'sliceIds',\n _data: chainSliceIds(catalogSliceIdData),\n _hash: '',\n }) as SliceIdsTable;\n\n //CatalogSeries\n //................................................................\n const catalogSeriesTableCfg = hip<TableCfg>({\n key: 'catalogSeries',\n type: 'components',\n columns: [\n { key: '_hash', type: 'string', titleShort: 'Hash', titleLong: 'Hash' },\n {\n key: 'series',\n type: 'jsonArray',\n titleShort: 'Series',\n titleLong: 'Series References',\n ref: {\n tableKey: 'seriesCake',\n type: 'cakes',\n },\n } as ColumnCfg,\n ] as ColumnCfg[],\n isHead: false,\n isRoot: false,\n isShared: true,\n } as TableCfg);\n\n const catalogSeries = hip<\n ComponentsTable<{ _hash: string; series: CakeReference[] }>\n >({\n _tableCfg: catalogSeriesTableCfg._hash as string,\n _type: 'components',\n _data: [\n {\n series: [\n {\n ref: seriesCake._data[0]._hash as string,\n sliceIds: ['Serie0', 'Serie1', 'Serie2', 'Serie3'] as SliceId[],\n },\n {\n ref: seriesCake._data[1]._hash as string,\n sliceIds: ['Serie4', 'Serie5', 'Serie6', 'Serie7'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n series: [\n {\n ref: seriesCake._data[2]._hash as string,\n },\n ],\n _hash: '',\n },\n ],\n _hash: '',\n });\n\n //CatalogLayers and CatalogCake\n //................................................................\n\n const catalogSeriesLayerTableCfg = hip<TableCfg>(\n createLayerTableCfg('catalogSeriesLayer'),\n ) as TableCfg;\n\n const catalogSeriesLayerData: Array<Layer> = [\n {\n add: {\n Catalog0: catalogSeries._data[0]._hash,\n Catalog1: catalogSeries._data[1]._hash,\n _hash: '',\n },\n sliceIdsTable: 'catalogSliceId',\n sliceIdsTableRow: catalogSliceId._data[0]._hash as string,\n componentsTable: 'catalogSeries',\n _hash: '',\n } as Layer,\n ].map((layer) => hsh<Layer>(layer as Layer));\n\n const catalogSeriesLayer = hip<any>({\n _tableCfg: catalogSeriesLayerTableCfg._hash,\n _type: 'layers',\n _data: chainLayers(catalogSeriesLayerData),\n _hash: '',\n }) as LayersTable;\n\n const catalogCakeTableCfg = hip<TableCfg>(\n createCakeTableCfg('catalogCake'),\n ) as TableCfg;\n\n const catalogCake = hip<any>({\n _tableCfg: catalogCakeTableCfg._hash,\n _type: 'cakes',\n _data: [\n {\n sliceIdsTable: 'catalogSliceId',\n sliceIdsRow: catalogSliceId._data[0]._hash,\n layers: {\n catalogSeriesLayer: catalogSeriesLayer._data[0]._hash,\n },\n },\n ],\n }) as CakesTable;\n\n //SeriesCakeHead\n //................................................................\n const catalogCakeHeadTableCfg = hip<TableCfg>(\n createHeadsTableCfg('catalogCake'),\n ) as TableCfg;\n\n const catalogCakeHeads = hip<any>({\n _tableCfg: catalogCakeHeadTableCfg._hash,\n _type: 'head' as ContentType,\n _data: [\n {\n timeId: '1764756756317:5UTy',\n cakeRef: catalogCake._data[0]._hash,\n },\n ],\n }) as CakesTable;\n\n //................................................................\n //TablesCfg\n //................................................................\n const tableCfgs = {\n _data: [\n carSliceIdTableCfg,\n carGeneralTableCfg,\n carDimensionsTableCfg,\n carTechnicalTableCfg,\n carColorTableCfg,\n carGeneralLayerTableCfg,\n carTechnicalLayerTableCfg,\n carColorLayerTableCfg,\n carCakeTableCfg,\n carCakeHeadTableCfg,\n seriesSliceIdTableCfg,\n seriesGeneralTableCfg,\n seriesCarsTableCfg,\n seriesGeneralLayerTableCfg,\n seriesCarsLayerTableCfg,\n seriesCakeTableCfg,\n seriesCakeHeadTableCfg,\n catalogSliceIdTableCfg,\n catalogSeriesTableCfg,\n catalogSeriesLayerTableCfg,\n catalogCakeTableCfg,\n catalogCakeHeadTableCfg,\n ],\n } as TablesCfgTable;\n\n const staticExample = {\n carSliceId,\n carGeneral,\n carDimensions,\n carTechnical,\n carColor,\n carGeneralLayer,\n carTechnicalLayer,\n carColorLayer,\n carCake,\n carCakeHeads,\n seriesSliceId,\n seriesGeneral,\n seriesCars,\n seriesGeneralLayer,\n seriesCarsLayer,\n seriesCake,\n seriesCakeHeads,\n catalogSliceId,\n catalogSeries,\n catalogSeriesLayer,\n catalogCake,\n catalogCakeHeads,\n tableCfgs,\n };\n\n return staticExample;\n};\n"],"names":["SliceIds","i","tree","cell","result","rljson","sliceIds","timeId","processor","staticExample"],"mappings":";;;;;;AAcO,MAAM,UAAU;AAAA,EASrB,YACmB,KACA,QACA,SACjB;AAHiB,SAAA,MAAA;AACA,SAAA,SAAA;AACA,SAAA,UAAA;AAEjB,SAAK,UAAU,OAAA;AAEf,SAAK,MAAA;AAAA,EACP;AAAA,EAhBQ;AAAA,EACA,aAAkC,CAAA;AAAA,EAElC,eAAwB;AAAA,EAExB,gCAA6B,IAAA;AAAA,EAC7B,oCAAiC,IAAA;AAAA,EAYzC,KAAK,KAAa;AAChB,QAAI,KAAK,UAAU,IAAI,GAAG,KAAK,KAAK,cAAc,IAAI,GAAG,EAAG;AAE5D,SAAK,UAAU,IAAI,GAAG;AAEtB,SAAK,OAAO,KAAK,KAAK,MAAM,MAAM;AAAA,MAChC,GAAG,KAAK;AAAA,M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C,iBAAgB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAGF,SAAOA;AACT;"}
1
+ {"version":3,"file":"db.js","sources":["/Users/maximilianheller/Documents/Development/rljson-db/src/connector/connector.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/controller/base-controller.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/controller/cake-controller.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/controller/component-controller.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/controller/slice-id-controller.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/controller/layer-controller.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/controller/tree-controller.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/controller/controller.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/core.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/tools/inject.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/tools/isolate.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/tools/merge-trees.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/join/selection/column-selection.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/join/filter/boolean-filter.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/join/filter/boolean-filter-processor.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/join/filter/number-filter.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/join/filter/number-filter-processor.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/join/filter/string-filter.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/join/filter/string-filter-processor.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/join/filter/column-filter-processor.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/join/filter/row-filter-processor.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/join/join.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/notify.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/tools/make-unique.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/db.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/edit/edit-action.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/join/sort/row-sort.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/edit/multi-edit-processor.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/edit/multi-edit-manager.ts","/Users/maximilianheller/Documents/Development/rljson-db/src/example-static/example-static.ts"],"sourcesContent":["// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { Socket } from '@rljson/io';\nimport { Route, timeId } from '@rljson/rljson';\n\nimport { Db } from '../db.ts';\n\nexport type ConnectorPayload = { o: string; r: string };\nexport type ConnectorCallback = (ref: string) => Promise<any>;\n\nexport class Connector {\n private _origin: string;\n private _callbacks: ConnectorCallback[] = [];\n\n private _isListening: boolean = false;\n\n private _sentRefs: Set<string> = new Set();\n private _receivedRefs: Set<string> = new Set();\n\n constructor(\n private readonly _db: Db,\n private readonly _route: Route,\n private readonly _socket: Socket,\n ) {\n this._origin = timeId();\n\n this._init();\n }\n\n send(ref: string) {\n if (this._sentRefs.has(ref) || this._receivedRefs.has(ref)) return;\n\n this._sentRefs.add(ref);\n\n this.socket.emit(this.route.flat, {\n o: this._origin,\n r: ref,\n } as ConnectorPayload);\n }\n\n listen(callback: (editHistoryRef: string) => Promise<void>) {\n this._socket.on(this._route.flat, async (payload: ConnectorPayload) => {\n /* v8 ignore next -- @preserve */\n try {\n await callback(payload.r);\n } catch (error) {\n console.error('Error in connector listener callback:', error);\n }\n });\n }\n\n private _init() {\n this._registerSocketObserver();\n this._registerDbObserver();\n\n this._isListening = true;\n }\n\n public teardown() {\n this._socket.removeAllListeners(this._route.flat);\n this._db.unregisterAllObservers(this._route);\n\n this._isListening = false;\n }\n\n private _notifyCallbacks(ref: string) {\n /* v8 ignore next -- @preserve */\n Promise.all(this._callbacks.map((cb) => cb(ref))).catch((err) => {\n console.error(`Error notifying connector callbacks for ref ${ref}:`, err);\n });\n }\n\n private _registerSocketObserver() {\n this.socket.on(this.route.flat, (p: ConnectorPayload) => {\n if (p.o === this._origin) {\n return;\n }\n\n const ref = p.r;\n /* v8 ignore next -- @preserve */\n if (this._receivedRefs.has(ref)) {\n return;\n }\n\n this._receivedRefs.add(p.r);\n\n this._notifyCallbacks(p.r);\n });\n }\n\n private _registerDbObserver() {\n this._db.registerObserver(this._route, (ins) => {\n return new Promise<void>((resolve) => {\n const ref = (ins as any)[this.route.root.tableKey + 'Ref'] as string;\n /* v8 ignore next -- @preserve */\n if (this._sentRefs.has(ref)) {\n resolve();\n return;\n }\n this.send(ref);\n resolve();\n });\n });\n }\n\n get socket() {\n return this._socket;\n }\n\n get route() {\n return this._route;\n }\n\n get origin() {\n return this._origin;\n }\n\n get isListening() {\n return this._isListening;\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { equals, Json, JsonValue } from '@rljson/json';\nimport {\n ContentType, InsertHistoryRow, Ref, Rljson, TableCfg, TableKey, TableType\n} from '@rljson/rljson';\n\nimport { Core } from '../core.ts';\n\nimport { CakeControllerCommands } from './cake-controller.ts';\nimport { Controller, ControllerChildProperty, ControllerRefs } from './controller.ts';\n\n\nexport abstract class BaseController<T extends TableType, C extends JsonValue>\n implements Controller<T, C, string>\n{\n protected _contentType?: ContentType;\n protected _tableCfg?: TableCfg;\n\n constructor(\n protected readonly _core: Core,\n protected readonly _tableKey: TableKey,\n ) {}\n\n // ...........................................................................\n abstract insert(\n command: CakeControllerCommands,\n value: C,\n origin?: Ref,\n refs?: ControllerRefs,\n ): Promise<InsertHistoryRow<any>[]>;\n\n // ...........................................................................\n abstract init(): Promise<void>;\n\n // ...........................................................................\n abstract getChildRefs(\n where: string | Json,\n filter?: Json,\n ): Promise<ControllerChildProperty[]>;\n\n // ...........................................................................\n abstract filterRow(\n row: Json,\n key: string,\n value: JsonValue,\n ): Promise<boolean>;\n\n // ...........................................................................\n /**\n * Retrieves the current state of the table.\n * @returns A promise that resolves to the current state of the table.\n */\n async table(): Promise<T> {\n const rljson = await this._core.dumpTable(this._tableKey);\n return rljson[this._tableKey] as T;\n }\n\n // ...........................................................................\n /**\n * Fetches a specific entry from the table by its reference or by a partial match.\n * @param where A string representing the reference of the entry to fetch, or an object representing a partial match.\n * @returns A promise that resolves to an array of entries matching the criteria, or null if no entries are found.\n */\n async get(where: string | Json, filter?: Json): Promise<Rljson> {\n if (typeof where === 'string') {\n return this._getByHash(where, filter);\n } else if (typeof where === 'object' && where !== null) {\n // If where is an object with only _hash property\n if (\n Object.keys(where).length === 1 &&\n '_hash' in where &&\n typeof where['_hash'] === 'string'\n ) {\n return this._getByHash(where['_hash'], filter);\n }\n\n // If where is an object, we assume it's a partial match\n return this._getByWhere(where, filter);\n } else {\n return Promise.resolve({});\n }\n }\n\n // ...........................................................................\n /**\n * Fetches a specific entry from the table by its reference.\n * @param hash A string representing the reference of the entry to fetch.\n * @returns A promise that resolves to the entry matching the reference, or null if no entry is found.\n */\n protected async _getByHash(hash: string, filter?: Json): Promise<Rljson> {\n let result: Rljson = {};\n\n if (!filter || equals(filter, {})) {\n result = await this._core.readRow(this._tableKey, hash);\n } else {\n result = await this._core.readRows(this._tableKey, {\n _hash: hash,\n ...filter,\n } as { [column: string]: JsonValue });\n }\n\n return result;\n }\n\n // ...........................................................................\n /**\n * Fetches entries from the table that match the specified criteria.\n * @param where An object representing the criteria to match.\n * @returns A promise that resolves to an array of entries matching the criteria, or null if no entries are found.\n */\n protected async _getByWhere(where: Json, filter?: Json): Promise<Rljson> {\n const rows = await this._core.readRows(this._tableKey, {\n ...where,\n ...filter,\n } as { [column: string]: JsonValue });\n return rows;\n }\n\n // ...........................................................................\n /**\n * Gets the content type of the controller.\n * @returns The content type managed by the controller.\n */\n /* v8 ignore next -- @preserve */\n contentType(): ContentType {\n return this._contentType ?? 'components';\n }\n\n // ...........................................................................\n /**\n * Gets the table configuration of the controller.\n * @returns The table configuration managed by the controller.\n */\n tableCfg(): TableCfg {\n /* v8 ignore next -- @preserve */\n if (!this._tableCfg) {\n throw new Error(\n `TableCfg for controller ${this._tableKey} is not initialized.`,\n );\n }\n return this._tableCfg;\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\nimport { hsh, rmhsh } from '@rljson/hash';\nimport { Json, JsonValue } from '@rljson/json';\n// found in the LICENSE file in the root of this package.\nimport {\n Cake,\n CakesTable,\n InsertHistoryRow,\n LayerRef,\n Ref,\n Rljson,\n SliceIdsRef,\n TableKey,\n timeId,\n} from '@rljson/rljson';\n\nimport { Core } from '../core.ts';\n\nimport { BaseController } from './base-controller.ts';\nimport {\n Controller,\n ControllerChildProperty,\n ControllerCommands,\n ControllerRefs,\n} from './controller.ts';\n\nexport interface CakeValue extends Json {\n layers: {\n [layerTable: TableKey]: LayerRef;\n };\n id?: string;\n}\n\nexport type CakeControllerCommands = ControllerCommands | `add@${string}`;\n\nexport interface CakeControllerRefs extends Partial<Cake> {\n sliceIdsTable: TableKey;\n sliceIdsRow: SliceIdsRef;\n base?: Ref;\n}\n\nexport class CakeController<N extends string, C extends Cake>\n extends BaseController<CakesTable, C>\n implements Controller<CakesTable, C, N>\n{\n constructor(\n protected readonly _core: Core,\n protected readonly _tableKey: TableKey,\n private _refs?: CakeControllerRefs,\n ) {\n super(_core, _tableKey);\n this._contentType = 'cakes';\n }\n\n private _baseLayers: { [layerTable: string]: string } = {};\n\n async init() {\n // Validate Table\n\n // TableKey must end with 'Cake'\n if (this._tableKey.endsWith('Cake') === false) {\n throw new Error(\n `Table ${this._tableKey} is not supported by CakeController.`,\n );\n }\n\n // Table must be of type cakes\n const contentType = await this._core.contentType(this._tableKey);\n if (contentType !== 'cakes') {\n throw new Error(`Table ${this._tableKey} is not of type cakes.`);\n }\n\n //Get TableCfg\n this._tableCfg = await this._core.tableCfg(this._tableKey);\n\n // Validate refs or try to read them from the first row of the table\n if (\n this._refs &&\n this._refs.base &&\n this._refs.base !== undefined &&\n this._refs.base.length > 0\n ) {\n // Validate base cake exists\n const {\n [this._tableKey]: { _data: baseCakes },\n } = await this._core.readRow(this._tableKey, this._refs.base);\n\n // Base cake must exist\n if (baseCakes.length === 0) {\n throw new Error(`Base cake ${this._refs.base} does not exist.`);\n }\n\n const baseCake = baseCakes[0] as Cake;\n\n // Store base layers from base cake\n this._baseLayers = rmhsh(baseCake.layers);\n }\n }\n\n async getChildRefs(\n where: string | Json,\n filter?: Json,\n ): Promise<ControllerChildProperty[]> {\n const childRefs: ControllerChildProperty[] = [];\n const { [this._tableKey]: table } = await this.get(where, filter);\n\n const cakes = table._data as Cake[];\n for (const cake of cakes) {\n for (const layerTable of Object.keys(cake.layers)) {\n if (layerTable.startsWith('_')) continue; // Skip internal keys\n childRefs.push({\n tableKey: layerTable as TableKey,\n ref: cake.layers[layerTable],\n });\n }\n }\n\n return childRefs;\n }\n\n async insert(\n command: CakeControllerCommands,\n value: C,\n origin?: Ref,\n refs?: ControllerRefs,\n ): Promise<InsertHistoryRow<any>[]> {\n // Validate command\n if (!command.startsWith('add')) {\n throw new Error(`Command ${command} is not supported by CakeController.`);\n }\n\n /* v8 ignore next -- @preserve */\n if (this._refs?.base) delete this._refs.base; // Remove base ref to avoid conflicts\n\n const normalizedValue: { [layerTable: string]: string } = {};\n for (const [layerTable, layerRef] of Object.entries(\n value.layers as { [layerTable: string]: string },\n )) {\n /* v8 ignore next -- @preserve */\n if (Array.isArray(layerRef) && layerRef.length > 1) {\n throw new Error(\n `CakeController insert: Layer ref for table ${layerTable} cannot be an array of size > 1. No 1:n relations supported.`,\n );\n }\n\n /* v8 ignore next -- @preserve */\n normalizedValue[layerTable] = Array.isArray(layerRef)\n ? layerRef[0]\n : layerRef;\n }\n\n // Overwrite base layers with given layers\n const cake = {\n ...value,\n layers: { ...this._baseLayers, ...normalizedValue },\n ...(refs || this._refs),\n };\n\n const rlJson = { [this._tableKey]: { _data: [cake] } } as Rljson;\n\n //Write component to io\n await this._core.import(rlJson);\n\n //Create InsertHistoryRow\n const result = {\n //Ref to component\n [this._tableKey + 'Ref']: hsh(cake as Json)._hash as string,\n\n //Data from edit\n route: '',\n origin,\n\n //Unique id/timestamp\n timeId: timeId(),\n } as InsertHistoryRow<any>;\n\n return [result];\n }\n\n async get(where: string | Json, filter?: Json): Promise<Rljson> {\n if (typeof where === 'string') {\n return this._getByHash(where, filter);\n } else if (typeof where === 'object' && where !== null) {\n return this._getByWhere(where, filter);\n } else {\n return Promise.resolve({});\n }\n }\n\n async filterRow(row: Json, key: string, value: JsonValue): Promise<boolean> {\n const cake = row as Cake;\n for (const [layerKey, layerRef] of Object.entries(cake.layers)) {\n if (layerKey === key && layerRef === value) {\n return true;\n }\n }\n return false;\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\nimport { hsh } from '@rljson/hash';\n// Use of this source code is governed by terms that can be\nimport { equals, Json, JsonValue, merge } from '@rljson/json';\n// found in the LICENSE file in the root of this package.\nimport {\n CakeReference,\n ColumnCfg,\n ComponentsTable,\n ContentType,\n InsertHistoryRow,\n Ref,\n Rljson,\n TableKey,\n timeId,\n} from '@rljson/rljson';\n\nimport { Core } from '../core.ts';\n\nimport { BaseController } from './base-controller.ts';\nimport {\n Controller,\n ControllerChildProperty,\n ControllerCommands,\n ControllerRefs,\n} from './controller.ts';\n\nexport class ComponentController<\n N extends string,\n C extends Json,\n T extends Json,\n >\n extends BaseController<ComponentsTable<T>, C>\n implements Controller<ComponentsTable<T>, C, N>\n{\n private _allowedContentTypes: ContentType[] = [\n 'components',\n 'edits',\n 'editHistory',\n 'multiEdits',\n 'insertHistory',\n ];\n\n private _resolvedColumns: {\n base: ColumnCfg[];\n references: Record<TableKey, ColumnCfg[]>;\n } | null = null;\n private _refTableKeyToColumnKeyMap: Record<TableKey, string[]> | null = null;\n\n constructor(\n protected readonly _core: Core,\n protected readonly _tableKey: TableKey,\n private _refs?: ControllerRefs,\n ) {\n super(_core, _tableKey);\n this._contentType = 'components';\n }\n\n async init() {\n // Validate Table\n if (!!this._refs && !this._refs.base) {\n // No specific refs required for components table\n throw new Error(`Refs are not required on ComponentController.`);\n }\n\n // Table must be of allowed type\n const contentType = await this._core.contentType(this._tableKey);\n if (this._allowedContentTypes.indexOf(contentType) === -1) {\n throw new Error(`Table ${this._tableKey} is not of type components.`);\n }\n\n //Get TableCfg\n this._tableCfg = await this._core.tableCfg(this._tableKey);\n\n this._resolvedColumns = await this._resolveReferenceColumns({\n base: this._tableCfg.columns,\n });\n this._refTableKeyToColumnKeyMap = this._createRefTableKeyToColumnKeyMap();\n }\n\n async insert(\n command: ControllerCommands,\n value: Json,\n origin?: Ref,\n refs?: ControllerRefs,\n ): Promise<InsertHistoryRow<N>[]> {\n // Validate command\n if (!command.startsWith('add')) {\n throw new Error(\n `Command ${command} is not supported by ComponentController.`,\n );\n }\n /* v8 ignore else -- @preserve */\n if (!!refs) {\n throw new Error(`Refs are not supported on ComponentController.`);\n }\n\n const component = value as JsonValue & { _hash?: string };\n\n //Remove internal flags\n delete (component as any)._somethingToInsert;\n\n const rlJson = { [this._tableKey]: { _data: [component] } } as Rljson;\n\n //Write component to io\n await this._core.import(rlJson);\n\n return [\n {\n //Ref to component\n [this._tableKey + 'Ref']: hsh(component as Json)._hash as string,\n\n //Data from edit\n route: '',\n origin,\n //Unique id/timestamp\n timeId: timeId(),\n },\n ] as any as InsertHistoryRow<N>[];\n }\n\n // ...........................................................................\n /**\n * Retrieves references to child entries in related tables based on a condition.\n * @param where - The condition to filter the data.\n * @param filter - Optional filter to apply to the data.\n * @returns\n */\n async getChildRefs(\n where: string | Json,\n filter?: Json,\n ): Promise<ControllerChildProperty[]> {\n const { [this._tableKey]: table } = await this.get(where, filter);\n const { columns } = await this._core.tableCfg(this._tableKey);\n\n //Unique child refs\n const childRefs: Map<string, ControllerChildProperty> = new Map();\n\n for (const colCfg of columns) {\n if (!colCfg.ref || colCfg.ref === undefined) continue;\n\n const propertyKey = colCfg.key;\n const childRefTableKey = colCfg.ref.tableKey;\n\n for (const row of table._data) {\n const refValue = (row as any)[propertyKey];\n\n //Plain hashes given, reference table from columnCfg\n if (typeof refValue === 'string') {\n childRefs.set(`${childRefTableKey}|${propertyKey}|${refValue}`, {\n tableKey: childRefTableKey,\n columnKey: propertyKey,\n ref: refValue,\n } as ControllerChildProperty);\n continue;\n }\n\n /* v8 ignore if -- @preserve */\n if (Array.isArray(refValue)) {\n for (const refItem of refValue) {\n //Plain hashes given, reference table from columnCfg\n if (typeof refItem === 'string') {\n childRefs.set(`${childRefTableKey}|${propertyKey}|${refItem}`, {\n tableKey: childRefTableKey,\n columnKey: propertyKey,\n ref: refItem,\n } as ControllerChildProperty);\n continue;\n }\n\n //CakeRef: Object with ref and sliceIds given\n if (typeof refItem === 'object' && refItem !== null) {\n const cakeReference = refItem as CakeReference;\n childRefs.set(\n `${childRefTableKey}|${propertyKey}|${\n cakeReference.ref\n }|${cakeReference.sliceIds?.join(',')}`,\n {\n tableKey: childRefTableKey,\n columnKey: propertyKey,\n ref: cakeReference.ref,\n sliceIds: cakeReference.sliceIds,\n } as ControllerChildProperty,\n );\n continue;\n }\n }\n continue;\n }\n }\n }\n\n return Array.from(childRefs.values());\n }\n\n // ...........................................................................\n /**\n * Fetches a specific entry from the table by a partial match. Resolves references as needed.\n * @param where - An object representing a partial match.\n * @returns A promise that resolves to an array of entries matching the criteria, or null if no entries are found.\n */\n protected async _getByWhere(where: Json, filter?: Json): Promise<Rljson> {\n // If reference columns are present, resolve them\n // Check if where clause contains reference columns\n const consolidatedWheres: Json[] = [];\n const consolidatedRows: Map<string, Json> = new Map();\n const hasReferenceColumns = this._hasReferenceColumns(where);\n if (hasReferenceColumns) {\n const resolvedReferences: Record<TableKey, Ref[]> =\n await this._resolveReferences(this._getWhereReferences(where));\n const refWhereClauses =\n this._referencesToWhereClauses(resolvedReferences);\n for (const refWhere of refWhereClauses) {\n consolidatedWheres.push({\n ...this._getWhereBase(where),\n ...refWhere,\n });\n\n /* ....................................................................\n 1:1 reference resolution\n const {\n [this._tableKey]: { _data: refRows },\n } = await this._core.readRows(this._tableKey, {\n ...refWhere,\n ...filter,\n } as { [column: string]: JsonValue });\n .................................................................... */\n\n const {\n [this._tableKey]: { _data: tableData },\n } = await this._core.dumpTable(this._tableKey);\n\n const column = Object.keys(refWhere)[0];\n const refValue = refWhere[column]!;\n for (const row of tableData as Json[]) {\n if (await this.filterRow(row, column, refValue)) {\n consolidatedRows.set((row as any)._hash, row);\n }\n }\n }\n } else {\n const {\n [this._tableKey]: { _data: rows },\n } = await this._core.readRows(this._tableKey, {\n ...where,\n ...filter,\n } as { [column: string]: JsonValue });\n\n for (const row of rows as Json[]) {\n consolidatedRows.set((row as any)._hash, row);\n }\n }\n\n // Return result\n return {\n [this._tableKey]: {\n _data: Array.from(consolidatedRows.values()),\n _type: 'components',\n } as ComponentsTable<T>,\n };\n }\n\n private _referencesToWhereClauses(\n references: Record<TableKey, Ref[]>,\n ): Json[] {\n const whereClauses: Json[] = [];\n for (const [tableKey, refs] of Object.entries(references)) {\n const wherePropertyKeys =\n this._refTableKeyToColumnKeyMap?.[tableKey as TableKey];\n for (const propKey of wherePropertyKeys!) {\n for (const ref of refs) {\n whereClauses.push({ [propKey]: ref });\n }\n }\n }\n return whereClauses;\n }\n\n private _createRefTableKeyToColumnKeyMap(): Record<TableKey, string[]> {\n const map: Record<TableKey, string[]> = {};\n const columns = this._tableCfg?.columns;\n\n for (const colCfg of columns!) {\n if (colCfg.ref) {\n const tableKey = colCfg.ref.tableKey;\n /* v8 ignore if -- @preserve */\n if (!map[tableKey]) {\n map[tableKey] = [];\n }\n map[tableKey].push(colCfg.key);\n }\n }\n return map;\n }\n\n // ...........................................................................\n /**\n * Extracts reference columns from the where clause.\n * @param where - The condition to filter the data.\n * @returns An object representing only the reference columns in the where clause.\n */\n private _getWhereReferences(where: Json): Json {\n const whereRefs: Json = {};\n for (const colCfg of this._referenceColumns) {\n if (colCfg.key in where) {\n whereRefs[colCfg.key] = where[colCfg.key];\n }\n }\n return whereRefs;\n }\n\n // ...........................................................................\n /**\n * Removes reference columns from the where clause.\n * @param where - The condition to filter the data.\n * @returns An object representing the where clause without reference columns.\n */\n private _getWhereBase(where: Json): Json {\n const whereWithoutRefs: Json = { ...where };\n for (const colCfg of this._referenceColumns) {\n if (colCfg.key in whereWithoutRefs) {\n delete whereWithoutRefs[colCfg.key];\n }\n }\n return whereWithoutRefs;\n }\n\n // ...........................................................................\n /**\n * Retrieves all reference columns from the resolved columns.\n * @returns An array of ColumnCfg representing the reference columns.\n */\n private get _referenceColumns(): ColumnCfg[] {\n /* v8 ignore next -- @preserve */\n if (!this._resolvedColumns) {\n throw new Error(\n `Resolved columns are not available for table ${this._tableKey}. You must call init() first.`,\n );\n }\n const references: ColumnCfg[] = [];\n for (const refCols of Object.values(this._resolvedColumns.references)) {\n references.push(...refCols);\n }\n return references;\n }\n\n // ...........................................................................\n /**\n * Checks if the where clause contains any reference columns.\n * @param where - The condition to filter the data.\n * @returns A promise that resolves to true if reference columns are present, false otherwise.\n */\n private _hasReferenceColumns(where: Json): boolean {\n /* v8 ignore next -- @preserve */\n if (!this._resolvedColumns) {\n throw new Error(\n `Resolved columns are not available for table ${this._tableKey}. You must call init() first.`,\n );\n }\n\n for (const colCfg of this._referenceColumns) {\n if (colCfg.key in where) {\n return true;\n }\n }\n return false;\n }\n\n // ...........................................................................\n /**\n * Resolves reference columns in the where clause.\n * @param columns - The columns to resolve.\n * @returns A promise that resolves to an object containing base and reference columns.\n */\n private async _resolveReferenceColumns(columns: {\n base: ColumnCfg[];\n references?: Record<TableKey, ColumnCfg[]>;\n }): Promise<{\n base: ColumnCfg[];\n references: Record<TableKey, ColumnCfg[]>;\n }> {\n const base: ColumnCfg[] = [];\n const references: Record<TableKey, ColumnCfg[]> = {};\n\n for (const col of columns.base) {\n // If column has a ref, fetch referenced table columns\n if (!!col.ref) {\n const refTableKey = col.ref.tableKey;\n const { columns: refColumns } = await this._core.tableCfg(refTableKey);\n\n /* v8 ignore if -- @preserve */\n if (!references[refTableKey]) {\n references[refTableKey] = [];\n }\n\n // Check if referenced columns have refs themselves and resolve them too\n const refsHaveRefs = refColumns.some((c) => !!c.ref);\n /*v8 ignore next -- @preserve */\n if (refsHaveRefs) {\n const resolvedRefColumns = await this._resolveReferenceColumns({\n base: refColumns,\n });\n references[refTableKey].push(...resolvedRefColumns.base);\n }\n\n references[refTableKey].push(...refColumns);\n } else {\n base.push(col);\n }\n }\n\n return { base, references };\n }\n\n // ...........................................................................\n /**\n * Resolves references based on the where clause.\n * @param where - The condition to filter the data.\n * @returns - A promise that resolves to an object containing resolved references.\n */\n private async _resolveReferences(\n where: Json,\n ): Promise<Record<TableKey, Ref[]>> {\n /* v8 ignore next -- @preserve */\n if (!this._resolvedColumns) {\n throw new Error(\n `Resolved columns are not available for table ${this._tableKey}. You must call init() first.`,\n );\n }\n\n const resolvedReferences: Record<TableKey, Ref[]> = {};\n const references = this._resolvedColumns.references;\n for (const [tableKey, refColumns] of Object.entries(references)) {\n const whereForTable: Json = {};\n for (const colCfg of refColumns) {\n if (colCfg.key in where) {\n whereForTable[colCfg.key] = where[colCfg.key];\n }\n }\n\n /* v8 ignore next -- @preserve */\n if (Object.keys(whereForTable).length === 0) {\n continue; // No where clause for this table\n }\n\n const refRows = await this._readRowsWithReferences(\n tableKey as TableKey,\n whereForTable as { [column: string]: JsonValue },\n );\n\n const refs: Ref[] = refRows[tableKey as TableKey]._data.map(\n (r) => (r as any)._hash,\n );\n\n resolvedReferences[tableKey as TableKey] = refs;\n }\n\n return resolvedReferences;\n }\n\n private async _readRowsWithReferences(\n table: string,\n where: { [column: string]: JsonValue },\n ): Promise<Rljson> {\n //Split where clauses with array values into multiple queries\n const splitted: { [column: string]: JsonValue }[] = [];\n for (const [key, value] of Object.entries(where)) {\n if (Array.isArray(value)) {\n for (const v of value) {\n splitted.push({ ...where, ...{ [key]: v as JsonValue } });\n }\n }\n }\n\n //If we have multiple where clauses, merge the results\n if (splitted.length > 0) {\n const results = [];\n for (const s of splitted) {\n results.push(await this._core.readRows(table, s));\n }\n return merge(...results) as Rljson;\n } else {\n return this._core.readRows(table, where);\n }\n }\n\n async filterRow(row: Json, key: string, value: JsonValue): Promise<boolean> {\n for (const [propertyKey, propertyValue] of Object.entries(row)) {\n if (propertyKey === key && equals(propertyValue, value)) {\n return true;\n } else if (Array.isArray(propertyValue)) {\n for (const item of propertyValue) {\n if (equals(item, value)) {\n return true;\n }\n }\n }\n }\n return false;\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\nimport { hsh } from '@rljson/hash';\nimport { Json, JsonValue } from '@rljson/json';\n// found in the LICENSE file in the root of this package.\nimport {\n InsertCommand,\n InsertHistoryRow,\n Ref,\n Rljson,\n SliceId,\n SliceIds,\n SliceIdsRef,\n SliceIdsTable,\n TableKey,\n timeId,\n} from '@rljson/rljson';\n\nimport { Core } from '../core.ts';\n\nimport { BaseController } from './base-controller.ts';\nimport {\n Controller,\n ControllerChildProperty,\n ControllerRefs,\n} from './controller.ts';\n\nexport interface SliceIdControllerRefs extends Partial<SliceIds> {\n base?: SliceIdsRef;\n}\n\nexport class SliceIdController<N extends string, C extends SliceId[]>\n extends BaseController<SliceIdsTable, C>\n implements Controller<SliceIdsTable, C, N>\n{\n constructor(\n protected readonly _core: Core,\n protected readonly _tableKey: TableKey,\n private _refs?: SliceIdControllerRefs,\n ) {\n super(_core, _tableKey);\n this._contentType = 'sliceIds';\n }\n\n async init() {\n // Validate Table\n\n // TableKey must end with 'SliceId'\n if (this._tableKey.endsWith('SliceId') === false) {\n throw new Error(\n `Table ${this._tableKey} is not supported by SliceIdController.`,\n );\n }\n\n // Table must be of type sliceIds\n const contentType = await this._core.contentType(this._tableKey);\n /* v8 ignore next -- @preserve */\n if (contentType !== 'sliceIds') {\n throw new Error(`Table ${this._tableKey} is not of type sliceIds.`);\n }\n\n //Get TableCfg\n this._tableCfg = await this._core.tableCfg(this._tableKey);\n\n // Validate refs or try to read them from the first row of the table\n if (this._refs && this._refs.base) {\n // Validate base sliceId exists\n const {\n [this._tableKey]: { _data: SliceIds },\n } = await this._core.readRow(this._tableKey, this._refs.base);\n\n // Base sliceId must exist\n if (SliceIds.length === 0) {\n throw new Error(`Base sliceId ${this._refs.base} does not exist.`);\n }\n }\n }\n\n async insert(\n command: InsertCommand,\n value: SliceId[],\n origin?: Ref,\n refs?: ControllerRefs,\n ): Promise<InsertHistoryRow<any>[]> {\n // Validate command\n if (!command.startsWith('add') && !command.startsWith('remove')) {\n throw new Error(\n `Command ${command} is not supported by SliceIdController.`,\n );\n }\n\n // sliceIds to add/remove\n const sliceIds =\n command.startsWith('add') === true\n ? ({\n add: value,\n ...(refs || this._refs),\n } as SliceIds & { _hash?: string })\n : ({\n add: [],\n remove: value,\n ...(refs || this._refs),\n } as SliceIds & { _hash?: string });\n\n const rlJson = { [this._tableKey]: { _data: [sliceIds] } } as Rljson;\n\n //Write component to io\n await this._core.import(rlJson);\n\n //Create InsertHistoryRow\n const result = {\n //Ref to component\n [this._tableKey + 'Ref']: hsh(sliceIds as Json)._hash as string,\n\n //Data from edit\n route: '',\n origin,\n\n //Unique id/timestamp\n timeId: timeId(),\n } as InsertHistoryRow<any>;\n\n return [result];\n }\n\n async get(where: string | Json, filter?: Json): Promise<Rljson> {\n if (typeof where === 'string') {\n return this._getByHash(where, filter);\n } else {\n return this._getByWhere(where, filter);\n }\n }\n\n async resolveBaseSliceIds(sliceIds: SliceIds): Promise<{\n add: SliceId[];\n }> {\n const add = new Set<SliceId>();\n const remove = new Set<SliceId>();\n\n if (!!sliceIds.base) {\n const baseSliceIds = await this.get(sliceIds.base);\n\n /* v8 ignore next -- @preserve */\n if (!baseSliceIds[this._tableKey]?._data?.[0]) {\n throw new Error(`Base sliceIds ${sliceIds.base} does not exist.`);\n }\n /* v8 ignore next -- @preserve */\n if (baseSliceIds[this._tableKey]._data.length > 1) {\n throw new Error(\n `Base sliceIds ${sliceIds.base} has more than one entry.`,\n );\n }\n\n const baseSliceId = baseSliceIds[this._tableKey]._data[0] as SliceIds;\n const resolvedBaseSliceIds = await this.resolveBaseSliceIds(baseSliceId);\n\n for (const sliceId of resolvedBaseSliceIds.add) {\n add.add(sliceId);\n }\n }\n\n for (const sliceId of sliceIds.add) {\n add.add(sliceId);\n }\n\n /* v8 ignore next -- @preserve */\n if (!!sliceIds.remove)\n for (const sliceId of sliceIds.remove) {\n remove.add(sliceId);\n }\n\n // Remove sliceIds that are both in add and remove\n /* v8 ignore next -- @preserve */\n for (const sliceId of remove.values()) {\n if (add.has(sliceId)) {\n add.delete(sliceId);\n }\n }\n\n return { add: Array.from(add) };\n }\n\n /* v8 ignore next -- @preserve */\n async getChildRefs(): Promise<ControllerChildProperty[]> {\n return [];\n }\n\n async filterRow(row: Json, _: string, value: JsonValue): Promise<boolean> {\n const sliceIds = row as SliceIds;\n const sliceId = value as SliceId;\n\n for (const sId of Object.values(sliceIds.add)) {\n if (sliceId === sId) {\n return true;\n }\n }\n\n return false;\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\nimport { hsh, rmhsh } from '@rljson/hash';\nimport { Json, JsonValue } from '@rljson/json';\n// found in the LICENSE file in the root of this package.\nimport {\n ComponentRef,\n InsertCommand,\n InsertHistoryRow,\n Layer,\n LayerRef,\n LayersTable,\n Ref,\n Rljson,\n SliceId,\n SliceIds,\n SliceIdsRef,\n TableKey,\n timeId,\n} from '@rljson/rljson';\n\nimport { Core } from '../core.ts';\n\nimport { BaseController } from './base-controller.ts';\nimport {\n Controller,\n ControllerChildProperty,\n ControllerRefs,\n} from './controller.ts';\nimport { SliceIdController } from './slice-id-controller.ts';\n\nexport interface LayerControllerRefs extends Partial<Layer> {\n base?: LayerRef;\n sliceIdsTable: TableKey;\n sliceIdsTableRow: SliceIdsRef;\n componentsTable: TableKey;\n}\n\nexport class LayerController<N extends string, C extends Layer>\n extends BaseController<LayersTable, C>\n implements Controller<LayersTable, C, N>\n{\n constructor(\n protected readonly _core: Core,\n protected readonly _tableKey: TableKey,\n private _refs?: LayerControllerRefs,\n ) {\n super(_core, _tableKey);\n this._contentType = 'layers';\n }\n\n async init() {\n // Validate Table\n\n // TableKey must end with 'Layer'\n if (this._tableKey.endsWith('Layer') === false) {\n throw new Error(\n `Table ${this._tableKey} is not supported by LayerController.`,\n );\n }\n\n // Table must be of type layers\n const contentType = await this._core.contentType(this._tableKey);\n if (contentType !== 'layers') {\n throw new Error(`Table ${this._tableKey} is not of type layers.`);\n }\n\n //Get TableCfg\n this._tableCfg = await this._core.tableCfg(this._tableKey);\n\n // Validate refs or try to read them from the first row of the table\n if (this._refs && this._refs.base) {\n // Validate base layer exists\n const {\n [this._tableKey]: { _data: baseLayers },\n } = await this._core.readRow(this._tableKey, this._refs.base);\n\n // Base layer must exist\n if (baseLayers.length === 0) {\n throw new Error(`Base layer ${this._refs.base} does not exist.`);\n }\n\n const baseLayer = baseLayers[0] as Layer;\n\n // Try to read sliceIds from base layer if not provided directly\n /* v8 ignore next if -- @preserve */\n if (\n !this._refs.sliceIdsTable ||\n !this._refs.sliceIdsRow ||\n !this._refs.componentsTable\n ) {\n this._refs = {\n sliceIdsTable: baseLayer.sliceIdsTable,\n sliceIdsTableRow: baseLayer.sliceIdsTableRow,\n componentsTable: baseLayer.componentsTable,\n };\n }\n }\n }\n\n async insert(\n command: InsertCommand,\n value: C,\n origin?: Ref,\n refs?: ControllerRefs,\n ): Promise<InsertHistoryRow<any>[]> {\n // Validate command\n if (!command.startsWith('add') && !command.startsWith('remove')) {\n throw new Error(\n `Command ${command} is not supported by LayerController.`,\n );\n }\n const isAdd = command.startsWith('add');\n\n const normalizedValue: Record<SliceId, ComponentRef> = {};\n for (const [sliceId, compRef] of isAdd\n ? Object.entries(value.add as Record<string, any>)\n : Object.entries(value.remove as Record<string, any>)) {\n /* v8 ignore next -- @preserve */\n if (Array.isArray(compRef) && compRef.length > 1) {\n throw new Error(\n `LayerController insert: Component ref for slice ${sliceId} cannot be an array of size > 1. No 1:n relations supported.`,\n );\n }\n /* v8 ignore next -- @preserve */\n normalizedValue[sliceId] = Array.isArray(compRef)\n ? compRef[0]\n : (compRef as ComponentRef);\n }\n\n // layer to add/remove\n const layer = isAdd\n ? {\n ...value,\n ...{\n add: normalizedValue as Record<SliceId, ComponentRef>,\n remove: {},\n },\n ...refs,\n }\n : {\n ...value,\n ...{\n remove: normalizedValue as Record<SliceId, ComponentRef>,\n add: {},\n },\n ...refs,\n };\n\n const rlJson = { [this._tableKey]: { _data: [layer] } } as Rljson;\n\n //Write component to io\n await this._core.import(rlJson);\n\n //Create InsertHistoryRow\n const result = {\n //Ref to component\n [this._tableKey + 'Ref']: hsh(layer as Json)._hash as string,\n\n //Data from edit\n route: '',\n origin,\n\n //Unique id/timestamp\n timeId: timeId(),\n } as InsertHistoryRow<any>;\n\n return [result];\n }\n\n async get(where: string | Json, filter?: Json): Promise<Rljson> {\n if (typeof where === 'string') {\n return this._getByHash(where, filter);\n } else {\n return this._getByWhere(where, filter);\n }\n }\n\n async resolveBaseLayer(layer: Layer): Promise<{\n add: Record<string, string>;\n sliceIds: SliceId[];\n }> {\n const add = new Map<string, string>();\n const sliceIds: Set<SliceId> = new Set<SliceId>();\n\n if (!!layer.base) {\n // Get base layer first\n const baseLayer = await this.get(layer.base);\n\n /* v8 ignore next -- @preserve */\n if (!baseLayer[this._tableKey]?._data?.[0]) {\n throw new Error(`Base layer ${layer.base} does not exist.`);\n }\n /* v8 ignore next -- @preserve */\n if (baseLayer[this._tableKey]._data.length > 1) {\n throw new Error(\n `Base layer ${layer.base} resolving not possible. Not unique.`,\n );\n }\n\n // Get base layer chained layers recursively\n const baseLayerData = rmhsh(baseLayer[this._tableKey]._data[0]) as Layer;\n const baseLayerResolved = await this.resolveBaseLayer(baseLayerData);\n\n // Merge base layer's add components\n for (const [sliceId, compRef] of Object.entries(baseLayerResolved.add)) {\n /* v8 ignore next -- @preserve */\n if (sliceId.startsWith('_')) continue;\n\n add.set(sliceId, compRef);\n }\n\n // Merge base layer's sliceIds\n for (const sliceId of baseLayerResolved.sliceIds) {\n sliceIds.add(sliceId);\n }\n\n // Get sliceIds from base layer's sliceIds\n const baseLayerSliceIdsTable = baseLayerData.sliceIdsTable;\n const baseLayerSliceIdsRow = baseLayerData.sliceIdsTableRow;\n\n // Get sliceIds from base layer's sliceIds table\n const {\n [baseLayerSliceIdsTable]: { _data: baseLayerSliceIds },\n } = await this._core.readRow(\n baseLayerSliceIdsTable,\n baseLayerSliceIdsRow,\n );\n\n // Resolve base layer sliceIds recursively\n for (const sIds of baseLayerSliceIds as SliceIds[]) {\n //Resolve base SliceIds\n const sliceIdController = new SliceIdController(\n this._core,\n baseLayerSliceIdsTable,\n );\n const resolvedSliceIds = await sliceIdController.resolveBaseSliceIds(\n sIds,\n );\n\n // Merge resolved sliceIds\n for (const sId of resolvedSliceIds.add) {\n /* v8 ignore next -- @preserve */\n if (sId.startsWith('_')) continue;\n\n sliceIds.add(sId);\n }\n }\n }\n\n // Get sliceIds from current layer's sliceIds table\n const {\n [layer.sliceIdsTable]: { _data: layerSliceIds },\n } = await this._core.readRow(layer.sliceIdsTable, layer.sliceIdsTableRow);\n\n /* v8 ignore next -- @preserve */\n if (!layerSliceIds || layerSliceIds.length === 0) {\n throw new Error(\n `Layer sliceIds ${layer.sliceIdsTableRow} does not exist.`,\n );\n }\n /* v8 ignore next -- @preserve */\n if (layerSliceIds.length > 1) {\n throw new Error(\n `Layer sliceIds ${layer.sliceIdsTableRow} has more than one entry.`,\n );\n }\n\n const layerSliceId = layerSliceIds[0] as SliceIds;\n\n for (const sId of layerSliceId.add) {\n /* v8 ignore next -- @preserve */\n if (sId.startsWith('_')) continue;\n\n sliceIds.add(sId);\n }\n\n /* v8 ignore next -- @preserve */\n if (!!layerSliceId.remove)\n for (const sId of Object.keys(layerSliceId.remove)) {\n if (sliceIds.has(sId)) {\n sliceIds.delete(sId);\n }\n }\n\n for (const [sliceId, compRef] of Object.entries(layer.add)) {\n if (sliceId.startsWith('_')) continue;\n\n add.set(sliceId, compRef);\n }\n\n // Remove sliceIds that are both in add and remove\n /* v8 ignore next -- @preserve */\n if (!!layer.remove)\n for (const sliceId of Object.keys(layer.remove)) {\n if (add.has(sliceId)) {\n add.delete(sliceId);\n }\n }\n\n return { add: Object.fromEntries(add), sliceIds: Array.from(sliceIds) };\n }\n\n async getChildRefs(\n where: string | Json,\n filter?: Json,\n ): Promise<ControllerChildProperty[]> {\n const { [this._tableKey]: table } = await this.get(where, filter);\n const childRefs: ControllerChildProperty[] = [];\n\n for (const row of table._data) {\n const layer = row as Layer;\n const resolvedLayer = await this.resolveBaseLayer(layer);\n\n for (const [sliceId, ref] of Object.entries(resolvedLayer.add)) {\n /* v8 ignore next -- @preserve */ /* v8 ignore next -- @preserve */\n if (sliceId.startsWith('_')) continue;\n\n childRefs.push({\n tableKey: layer.componentsTable,\n ref,\n sliceIds: [sliceId],\n });\n }\n }\n\n return childRefs;\n }\n\n async filterRow(row: Json, _: string, value: JsonValue): Promise<boolean> {\n const layer = row as Layer;\n const compRef = value as ComponentRef;\n const resolvedLayer = await this.resolveBaseLayer(layer);\n\n for (const componentRef of Object.values(resolvedLayer.add)) {\n if (componentRef === compRef) {\n return true;\n }\n }\n\n return false;\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\nimport { hsh } from '@rljson/hash';\nimport { Json } from '@rljson/json';\n// found in the LICENSE file in the root of this package.\nimport {\n InsertCommand, InsertHistoryRow, Ref, Rljson, Route, TableKey, timeId, Tree, TreesTable,\n TreeWithHash\n} from '@rljson/rljson';\n\nimport { Core } from '../core.ts';\nimport { Cell } from '../db.ts';\n\nimport { BaseController } from './base-controller.ts';\nimport { Controller, ControllerChildProperty } from './controller.ts';\n\n\nexport class TreeController<N extends string, C extends Tree>\n extends BaseController<TreesTable, C>\n implements Controller<TreesTable, C, N>\n{\n constructor(\n protected readonly _core: Core,\n protected readonly _tableKey: TableKey,\n ) {\n super(_core, _tableKey);\n this._contentType = 'trees';\n }\n\n async init() {\n // Validate Table\n\n // TableKey must end with 'Tree'\n if (this._tableKey.endsWith('Tree') === false) {\n throw new Error(\n `Table ${this._tableKey} is not supported by TreeController.`,\n );\n }\n\n // Table must be of type trees\n const contentType = await this._core.contentType(this._tableKey);\n /* v8 ignore next -- @preserve */\n if (contentType !== 'trees') {\n throw new Error(`Table ${this._tableKey} is not of type trees.`);\n }\n\n //Get TableCfg\n this._tableCfg = await this._core.tableCfg(this._tableKey);\n }\n\n async insert(\n command: InsertCommand,\n value: Tree,\n origin?: Ref,\n ): Promise<InsertHistoryRow<any>[]> {\n // Validate command\n /* v8 ignore next -- @preserve */\n if (!command.startsWith('add') && !command.startsWith('remove')) {\n throw new Error(`Command ${command} is not supported by TreeController.`);\n }\n\n const rlJson = { [this._tableKey]: { _data: [value] } } as Rljson;\n\n //Write component to io\n await this._core.import(rlJson);\n\n //Create InsertHistoryRow\n const result = {\n //Ref to component\n [this._tableKey + 'Ref']: hsh(value as Json)._hash as string,\n\n //Data from edit\n route: '',\n origin,\n\n //Unique id/timestamp\n timeId: timeId(),\n } as InsertHistoryRow<any>;\n\n return [result];\n }\n\n async get(\n where: string | Json,\n filter?: Json,\n path?: string,\n ): Promise<Rljson> {\n const {\n [this._tableKey]: { _data: trees },\n } =\n typeof where === 'string'\n ? await this._getByHash(where, filter)\n : await this._getByWhere(where, filter);\n\n if (trees.length === 0) {\n return { [this._tableKey]: { _data: [], _type: 'trees' } } as Rljson;\n }\n if (trees.length > 1) {\n throw new Error(\n `Multiple trees found for where clause. Please specify a more specific query.`,\n );\n }\n\n const treeRoute = Route.fromFlat(path || '');\n /* v8 ignore next -- @preserve */\n const treeId =\n treeRoute.segments.length > 0 ? treeRoute.top.tableKey : null;\n const tree = (trees as Tree[])[0];\n\n /* v8 ignore next -- @preserve */\n if (treeId && treeId !== tree.id) {\n return { [this._tableKey]: { _data: [], _type: 'trees' } } as Rljson;\n }\n\n const children: any[] = [];\n for (const childRef of tree.children ?? []) {\n const child = await this.get(\n childRef,\n undefined,\n treeRoute.deeper().flat,\n );\n const childData = child[this._tableKey]._data;\n children.push(...childData);\n }\n return {\n [this._tableKey]: {\n _data: [...children, tree],\n _type: 'trees',\n },\n } as Rljson;\n }\n\n async buildTreeFromTrees(trees: Tree[]): Promise<Json> {\n if (trees.length === 0) {\n return {};\n }\n\n // Create a map of hash to tree for quick lookup\n const treeMap = new Map<string, Tree>();\n for (const tree of trees) {\n treeMap.set((tree as TreeWithHash)._hash, tree);\n }\n\n // Recursive function to build object from tree\n const buildObject = (tree: Tree): any => {\n // Leaf node - return meta value\n if (!tree.isParent || !tree.children || tree.children.length === 0) {\n return tree;\n }\n\n // Parent node - build object from children\n const result: any = {};\n for (const childHash of tree.children) {\n const childTree = treeMap.get(childHash as string);\n /* v8 ignore else -- @preserve */\n if (childTree && childTree.id) {\n result[childTree.id] = buildObject(childTree);\n }\n }\n return result;\n };\n\n // Find root nodes (not referenced by any other tree)\n const referencedHashes = new Set<string>();\n for (const tree of trees) {\n if (tree.children) {\n for (const childHash of tree.children) {\n referencedHashes.add(childHash);\n }\n }\n }\n\n const rootTrees = trees.filter(\n (tree) => !referencedHashes.has((tree as TreeWithHash)._hash),\n );\n\n /* v8 ignore next -- @preserve */\n if (rootTrees.length === 0) {\n return {};\n }\n\n // If single root, return its object directly\n if (rootTrees.length === 1) {\n const rootTree = rootTrees[0];\n /* v8 ignore else -- @preserve */\n if (rootTree.id) {\n return { [rootTree.id]: buildObject(rootTree) };\n }\n /*v8 ignore next -- @preserve */\n return buildObject(rootTree);\n }\n\n // Multiple roots - combine into single object\n const result: any = {};\n for (const rootTree of rootTrees) {\n /* v8 ignore else -- @preserve */\n if (rootTree.id) {\n result[rootTree.id] = buildObject(rootTree);\n }\n }\n return result;\n }\n\n async buildCellsFromTree(trees: Tree[]): Promise<Cell[]> {\n const cells: Cell[] = [];\n\n if (trees.length === 0) {\n return cells;\n }\n\n // Create maps for quick lookup\n const treeMap = new Map<string, Tree>();\n const childToParentMap = new Map<string, string>();\n\n for (const tree of trees) {\n const treeHash = (tree as TreeWithHash)._hash;\n treeMap.set(treeHash, tree);\n\n if (tree.children) {\n for (const childHash of tree.children) {\n childToParentMap.set(childHash as string, treeHash);\n }\n }\n }\n\n // Find all hashes present in trees array\n const availableHashes = new Set<string>();\n for (const tree of trees) {\n availableHashes.add((tree as TreeWithHash)._hash);\n }\n\n // Find leaf nodes (whose children are not in the trees array)\n const leafNodes = trees.filter((tree) => {\n if (!tree.children || tree.children.length === 0) {\n return true;\n }\n const hasChildInTrees = tree.children.some((childHash) =>\n availableHashes.has(childHash as string),\n );\n return !hasChildInTrees;\n });\n\n // For each leaf, build path from root to leaf\n for (const leaf of leafNodes) {\n const pathIds: string[] = [];\n let currentHash = (leaf as TreeWithHash)._hash;\n\n // Build path backwards from leaf to root\n while (currentHash) {\n const current = treeMap.get(currentHash);\n /* v8 ignore next -- @preserve */\n if (!current) break;\n\n /* v8 ignore else -- @preserve */\n if (current.id) {\n pathIds.unshift(current.id);\n }\n\n const parentHash = childToParentMap.get(currentHash);\n if (!parentHash) break;\n currentHash = parentHash;\n }\n\n // Create route from path\n const routeStr = '/' + pathIds.join('/');\n const route = Route.fromFlat(routeStr);\n\n // Create cell\n cells.push({\n route,\n value: leaf,\n row: leaf,\n path: [[this._tableKey, '_data', 0, ...pathIds]],\n });\n }\n\n return cells;\n }\n\n async getChildRefs(\n where: string | Json,\n filter?: Json,\n ): Promise<ControllerChildProperty[]> {\n const childRefs: ControllerChildProperty[] = [];\n const { [this._tableKey]: table } = await this.get(where, filter);\n\n const trees = table._data as TreeWithHash[];\n for (const tree of trees) {\n for (const treeChildRef of tree.children ?? []) {\n childRefs.push({\n tableKey: this._tableKey,\n ref: treeChildRef as string,\n });\n }\n }\n\n return childRefs;\n }\n\n /* v8 ignore next -- @preserve */\n async filterRow(): Promise<boolean> {\n return false;\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { Json, JsonValue } from '@rljson/json';\nimport {\n ContentType,\n InsertCommand,\n InsertHistoryRow,\n Ref,\n Rljson,\n SliceId,\n TableCfg,\n TableKey,\n TableType,\n} from '@rljson/rljson';\n\nimport { Core } from '../core.ts';\n\nimport { CakeController, CakeControllerRefs } from './cake-controller.ts';\nimport { ComponentController } from './component-controller.ts';\nimport { LayerController, LayerControllerRefs } from './layer-controller.ts';\nimport {\n SliceIdController,\n SliceIdControllerRefs,\n} from './slice-id-controller.ts';\nimport { TreeController } from './tree-controller.ts';\n\nexport type ControllerRefs = CakeControllerRefs | LayerControllerRefs;\n\nexport type ControllerCommands = InsertCommand;\n\nexport type ControllerRunFn<N extends string, C extends JsonValue> = (\n command: ControllerCommands,\n value: C,\n origin?: Ref,\n refs?: ControllerRefs,\n) => Promise<InsertHistoryRow<N>[]>;\n\nexport type ControllerChildProperty = {\n tableKey: TableKey;\n columnKey?: string;\n ref: Ref;\n sliceIds?: SliceId[];\n};\n\n// ...........................................................................\n/**\n * Generic interface for a controller that manages a specific table in the database.\n * @template T The type of the table being managed.\n * @template C The type of the Insert.\n * @template N The name of the table being managed.\n * @property {ControllerRunFn<N>} insert - Function to execute a command on the table.\n * @property {() => Promise<void>} init - Initializes the controller.\n * @property {() => Promise<T>} table - Retrieves the current state of the table.\n * @property {(where: string | { [column: string]: JsonValue }, filter: Json | undefined, path: string | undefined) => Promise<Rljson>} get - Fetches data from the table based on a condition.\n * @property {(where: string | Json, filter?: Json) => Promise<Array<{ tableKey: TableKey; ref: Ref }>>} getChildRefs - Retrieves references to child entries in related tables based on a condition.\n * @param {string | Json }} where - The condition to filter the data.\n * @returns {Promise<Json[] | null>} A promise that resolves to an array of JSON objects or null if no data is found.\n * @throws {Error} If the data is invalid.\n */\nexport interface Controller<\n T extends TableType,\n C extends JsonValue,\n N extends string,\n> {\n insert: ControllerRunFn<N, C>;\n init(): Promise<void>;\n table(): Promise<T>;\n get(where: string | Json, filter?: Json, path?: string): Promise<Rljson>;\n getChildRefs(\n where: string | Json,\n filter?: Json,\n ): Promise<ControllerChildProperty[]>;\n filterRow(row: Json, key: string, value: JsonValue): Promise<boolean>;\n contentType(): ContentType;\n tableCfg(): TableCfg;\n}\n\n// ...........................................................................\n/**\n * Factory function to create a controller based on the content type.\n * @param {ContentType} type - The type of content (e.g., 'layers', 'components', 'cakes').\n * @param {Core} core - The core instance managing the database.\n * @param {TableKey} tableKey - The key identifying the table to be managed.\n * @param {ControllerRefs} [refs] - Optional references for the controller.\n * @returns {Promise<Controller<any, string>>} A promise that resolves to the created controller.\n * @throws {Error} If the controller for the specified type is not implemented.\n */\nexport const createController = async (\n type: ContentType,\n core: Core,\n tableKey: TableKey,\n refs?: ControllerRefs,\n): Promise<Controller<TableType, any, string>> => {\n let ctrl: Controller<TableType, any, string>;\n switch (type) {\n case 'layers':\n ctrl = new LayerController(core, tableKey, refs as LayerControllerRefs);\n break;\n case 'components':\n case 'edits':\n case 'editHistory':\n case 'multiEdits':\n case 'insertHistory':\n ctrl = new ComponentController(core, tableKey, refs as ControllerRefs);\n break;\n case 'cakes':\n ctrl = new CakeController(core, tableKey, refs as CakeControllerRefs);\n break;\n case 'sliceIds':\n ctrl = new SliceIdController(\n core,\n tableKey,\n refs as SliceIdControllerRefs,\n );\n break;\n case 'trees':\n ctrl = new TreeController(core, tableKey);\n break;\n default:\n throw new Error(`Controller for type ${type} is not implemented yet.`);\n }\n\n await ctrl.init();\n return ctrl;\n};\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { Io, IoMem } from '@rljson/io';\nimport { JsonValue } from '@rljson/json';\nimport {\n BaseValidator,\n ContentType,\n createInsertHistoryTableCfg,\n Rljson,\n TableCfg,\n Validate,\n} from '@rljson/rljson';\n\n/** Implements core functionalities like importing data, setting tables */\nexport class Core {\n // ...........................................................................\n constructor(private readonly _io: Io) {}\n\n static example = async () => {\n return new Core(await IoMem.example());\n };\n\n // ...........................................................................\n /**\n * Creates a table and an insertHistory for the table\n * @param tableCfg TableCfg of table to create\n */\n async createTableWithInsertHistory(tableCfg: TableCfg): Promise<void> {\n await this.createTable(tableCfg);\n await this.createInsertHistory(tableCfg);\n }\n\n /**\n * Creates a table\n * @param tableCfg TableCfg of table to create\n */\n async createTable(tableCfg: TableCfg): Promise<void> {\n return this._io.createOrExtendTable({ tableCfg });\n }\n /**\n * Creates an insertHistory table for a given table\n * @param tableCfg TableCfg of table\n */\n async createInsertHistory(tableCfg: TableCfg): Promise<void> {\n const cfg = createInsertHistoryTableCfg(tableCfg);\n await this.createTable(cfg);\n }\n\n // ...........................................................................\n /**\n * Returns a dump of the database\n */\n dump(): Promise<Rljson> {\n return this._io.dump();\n }\n\n /**\n * Returns a dump of a table.\n * @returns a dump of a table.\n * @throws when table name does not exist\n */\n async dumpTable(table: string): Promise<Rljson> {\n return await this._io.dumpTable({ table });\n }\n\n // ...........................................................................\n /**\n * Imports data into the memory.\n * @param data - The rljson data to import.\n * @throws {Error} If the data is invalid.\n */\n async import(data: Rljson): Promise<void> {\n // Throw an error if the data is invalid\n const validate = new Validate();\n validate.addValidator(new BaseValidator());\n\n const result = await validate.run(data);\n // If there are errors and they are not refsNotFound, throw an error\n // refsNotFound can be ignored because we dont check against existing data\n // when importing new data\n if (\n (result.hasErrors || (result.base && result.base.hasErrors)) &&\n !result.base.refsNotFound &&\n !result.base.layerBasesNotFound\n ) {\n throw new Error(\n 'The imported rljson data is not valid:\\n' +\n JSON.stringify(result, null, 2),\n );\n }\n\n // Write data\n await this._io.write({ data });\n }\n\n // ...........................................................................\n async tables(): Promise<Rljson> {\n return await this._io.dump();\n }\n\n // ...........................................................................\n async hasTable(table: string): Promise<boolean> {\n return await this._io.tableExists(table);\n }\n\n // ...........................................................................\n async contentType(table: string): Promise<ContentType> {\n const contentType = await this._io.contentType({ table });\n return contentType;\n }\n\n // ...........................................................................\n async tableCfg(table: string): Promise<TableCfg> {\n const tableCfgs = await this._io.rawTableCfgs();\n const tableCfg = tableCfgs.find((tc) => tc.key === table) as TableCfg;\n return tableCfg;\n }\n\n // ...........................................................................\n /** Reads a specific row from a database table */\n async readRow(table: string, rowHash: string): Promise<Rljson> {\n return await this._io.readRows({ table, where: { _hash: rowHash } });\n }\n\n // ...........................................................................\n async readRows(\n table: string,\n where: { [column: string]: JsonValue },\n ): Promise<Rljson> {\n return await this._io.readRows({ table, where });\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\n/* v8 ignore next -- @preserve */\nexport const inject = (tree: any, path: (string | number)[], value: any) => {\n for (let i = 0; i < path.length; i++) {\n const segment = path[i];\n if (i === path.length - 1) {\n tree[segment] = value;\n delete tree['_hash'];\n } else {\n if (!tree[segment] || typeof tree[segment] !== 'object') {\n tree[segment] = {};\n }\n tree = tree[segment];\n }\n }\n};\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\n/* v8 ignore next -- @preserve */\nexport const isolate = (\n tree: any,\n path: (string | number)[],\n preservedKeys: string[] = [],\n): any => {\n // Handle empty path - return empty object/array based on tree type\n if (path.length === 0) {\n return Array.isArray(tree) ? [] : {};\n }\n\n // Handle null/undefined tree\n if (tree == null) {\n return null;\n }\n\n const [currentKey, ...remainingPath] = path;\n\n // Create new container based on tree type\n const result = Array.isArray(tree) ? [] : {};\n\n // Preserve properties with keys starting with \"_\" and any keys in preservedKeys array\n if (!Array.isArray(tree)) {\n for (const key in tree) {\n if (\n (typeof key === 'string' && key.startsWith('_')) ||\n preservedKeys.includes(key)\n ) {\n (result as any)[key] = tree[key];\n }\n }\n }\n\n // Check if current key exists in tree\n if (!(currentKey in tree)) {\n return result;\n }\n\n const currentValue = tree[currentKey];\n\n // If this is the last key in path, include the full value\n if (remainingPath.length === 0) {\n if (Array.isArray(result)) {\n // For arrays, preserve the original index\n (result as any[])[currentKey as number] = currentValue;\n } else {\n (result as any)[currentKey] = currentValue;\n }\n } else {\n // Recursively isolate the remaining path, passing down preservedKeys\n const isolatedChild = isolate(currentValue, remainingPath, preservedKeys);\n\n // Only include the key if the isolated child has content\n const hasContent = Array.isArray(isolatedChild)\n ? isolatedChild.length > 0\n : Object.keys(isolatedChild).length > 0;\n\n if (hasContent || isolatedChild === null) {\n if (Array.isArray(result)) {\n // For arrays, preserve the original index\n (result as any[])[currentKey as number] = isolatedChild;\n } else {\n (result as any)[currentKey] = isolatedChild;\n }\n }\n }\n\n return result;\n};\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { Json } from '@rljson/json';\n\n/* v8 ignore next -- @preserve */\nexport const mergeTrees = (\n trees: {\n tree: Json;\n path: Array<string | number>;\n }[],\n): Json => {\n // Handle empty trees array\n if (!trees || trees.length === 0) {\n return {};\n }\n\n // First, merge all tree structures to preserve all properties along all paths\n let result: Json = {};\n\n for (const { tree } of trees) {\n if (tree != null) {\n result = mergeStructures(result, tree);\n }\n }\n\n // Extract values at each specified path\n const pathValues: { path: Array<string | number>; value: Json }[] = [];\n\n for (const { tree, path } of trees) {\n if (tree == null) continue;\n\n let current: any = tree;\n let pathExists = true;\n\n // Navigate through the path\n for (const key of path) {\n if (current == null || !(key in current)) {\n pathExists = false;\n break;\n }\n current = current[key];\n }\n\n // If we successfully navigated the path, store the path and value\n if (pathExists && current != null) {\n pathValues.push({ path, value: current });\n }\n }\n\n // Group values by their paths\n const pathGroups = new Map<string, Json[]>();\n\n for (const { path, value } of pathValues) {\n const pathKey = JSON.stringify(path);\n if (!pathGroups.has(pathKey)) {\n pathGroups.set(pathKey, []);\n }\n pathGroups.get(pathKey)!.push(value);\n }\n\n // Merge values for each unique path and set them in the result\n for (const [pathKey, values] of pathGroups) {\n const path = JSON.parse(pathKey) as Array<string | number>;\n\n // Merge all values at this path\n let mergedValue: Json | undefined = undefined;\n for (const value of values) {\n if (value == null) continue;\n\n if (mergedValue === undefined) {\n mergedValue = value;\n continue;\n }\n\n if (Array.isArray(mergedValue) && Array.isArray(value)) {\n mergedValue = [...mergedValue, ...value] as unknown as Json;\n } else if (!Array.isArray(mergedValue) && !Array.isArray(value)) {\n mergedValue = {\n ...(mergedValue as any),\n ...(value as any),\n } as unknown as Json;\n }\n // If types mismatch, keep the existing mergedValue\n }\n\n // Set the merged value at the path in the result\n let current: any = result;\n for (let i = 0; i < path.length - 1; i++) {\n const key = path[i];\n if (current == null || !(key in current)) {\n // Path doesn't exist in result, create it\n current[key] = typeof path[i + 1] === 'number' ? [] : {};\n }\n current = current[key];\n }\n\n if (path.length > 0) {\n current[path[path.length - 1]] = mergedValue;\n }\n }\n\n return result;\n};\n\n// Helper function to recursively merge two tree structures\n/* v8 ignore next -- @preserve */\nfunction mergeStructures(target: Json, source: Json): Json {\n if (source == null) return target;\n if (target == null) return source;\n\n // If both are arrays, merge them\n if (Array.isArray(target) && Array.isArray(source)) {\n const result = [...target];\n for (let i = 0; i < source.length; i++) {\n if (result[i] === undefined) {\n result[i] = source[i];\n } else {\n result[i] = mergeStructures(result[i], source[i]);\n }\n }\n return result as unknown as Json;\n }\n\n // If both are objects, merge their properties\n if (\n typeof target === 'object' &&\n typeof source === 'object' &&\n !Array.isArray(target) &&\n !Array.isArray(source) &&\n target !== null &&\n source !== null\n ) {\n const result = { ...target } as any;\n\n for (const key in source) {\n if (key in result) {\n result[key] = mergeStructures(result[key], (source as any)[key]);\n } else {\n result[key] = (source as any)[key];\n }\n }\n\n return result;\n }\n\n // For primitive values or type mismatches, return source\n return source;\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { Hash, hip } from '@rljson/hash';\nimport { ColumnCfgWithRoute, Ref, Route } from '@rljson/rljson';\n\n\nexport type ColumnRoute = string | string[] | number;\n\nexport interface ColumnInfo extends ColumnCfgWithRoute {\n alias: string;\n routeHash?: Ref;\n index?: number;\n value?: any;\n}\n\nexport class ColumnSelection {\n constructor(columns: ColumnInfo[]) {\n this._throwOnWrongAlias(columns);\n\n this.routes = columns.map((column) => column.route);\n this.routeHashes = this.routes.map(ColumnSelection.calcHash);\n\n this.aliases = columns.map((column) => column.alias);\n this.columns = this._initColumns(columns);\n\n ColumnSelection.check(this.aliases, this.routes);\n }\n\n // ...........................................................................\n /**\n * Returns unique routes from a list of routes\n * @param routes - The list of routes\n * @returns Unique routes\n */\n static uniqueRoutes(routes: Route[]): Route[] {\n return Array.from(new Set(routes.map((r) => r.flat))).map((flat) =>\n Route.fromFlat(flat),\n );\n }\n\n // ...........................................................................\n /**\n * Returns a ColumnSelection from a list of route segments\n * @param routeSegmentsList - A list of route segments\n * @returns A ColumnSelection object\n */\n static fromRoutes(routes: Route[]): ColumnSelection {\n const definition: ColumnInfo[] = [];\n const aliasCountMap: Record<string, number> = {};\n\n for (const route of this.uniqueRoutes(routes)) {\n const alias = route.root.tableKey;\n let uniqueAlias = alias;\n const aliasCount = aliasCountMap[alias] ?? 0;\n if (aliasCount > 0) {\n uniqueAlias = `${alias}${aliasCount}`;\n }\n aliasCountMap[alias] = aliasCount + 1;\n\n definition.push({\n key: uniqueAlias,\n type: 'jsonValue',\n alias: uniqueAlias,\n route: route.flat.slice(1),\n titleLong: '',\n titleShort: '',\n });\n }\n\n return new ColumnSelection(definition);\n }\n\n // ...........................................................................\n readonly columns: ColumnInfo[];\n readonly routes: string[];\n readonly aliases: string[];\n\n readonly routeHashes: string[];\n\n metadata(key: string): any[] {\n return this.columns.map((column) => column[key]);\n }\n\n // ...........................................................................\n static merge(columnSelections: ColumnSelection[]): ColumnSelection {\n //Flatten all routes from all selections\n const routes = columnSelections.map((selection) => selection.routes).flat();\n\n //Store strings here, because Set does not allow duplicates (on basic types)\n const routesWithoutDuplicates = Array.from(new Set(routes));\n\n //Create Route objects from flat (unique) strings\n return ColumnSelection.fromRoutes(\n routesWithoutDuplicates.map((route) => Route.fromFlat(route)),\n );\n }\n\n // ...........................................................................\n static calcHash(str: string): string {\n return Hash.default.calcHash(str);\n }\n\n route(aliasRouteOrHash: ColumnRoute): string {\n return this.column(aliasRouteOrHash).route;\n }\n\n // ...........................................................................\n alias(aliasRouteOrHash: ColumnRoute): string {\n return this.column(aliasRouteOrHash).alias;\n }\n\n // ...........................................................................\n columnIndex(\n hashAliasOrRoute: ColumnRoute,\n throwIfNotExisting: boolean = true,\n ): number {\n if (typeof hashAliasOrRoute === 'number') {\n return hashAliasOrRoute;\n }\n\n const str = Array.isArray(hashAliasOrRoute)\n ? hashAliasOrRoute.join('/')\n : hashAliasOrRoute;\n\n const hashIndex = this.routeHashes.indexOf(str);\n if (hashIndex >= 0) {\n return hashIndex;\n }\n\n const aliasIndex = this.aliases.indexOf(str);\n if (aliasIndex >= 0) {\n return aliasIndex;\n }\n\n const routeIndex = this.routes.indexOf(str);\n\n if (routeIndex < 0) {\n if (throwIfNotExisting) {\n throw new Error(`Unknown column alias or route: ${str}`);\n }\n return -1;\n }\n\n return routeIndex;\n }\n\n /***\n * Returns the column config for a specific alias, route or hash.\n */\n column(aliasRouteOrHash: ColumnRoute): ColumnInfo {\n const index = this.columnIndex(aliasRouteOrHash);\n return this.columns[index];\n }\n\n // ...........................................................................\n get count(): number {\n return this.aliases.length;\n }\n\n // ...........................................................................\n addedColumns(columnSelection: ColumnSelection): string[] {\n const a = this.routes.filter(\n (route) => !columnSelection.routes.includes(route),\n );\n\n return a;\n }\n\n // ...........................................................................\n static check(aliases: string[], routes: string[]) {\n // Make shure all keys are lowercase camel case\n // Numbers are not allowed at the beginning\n const camelCaseRegex = /^[a-z][a-zA-Z0-9]*$/;\n const invalidKeys = aliases.filter((key) => !camelCaseRegex.test(key));\n if (invalidKeys.length > 0) {\n throw new Error(\n `Invalid alias \"${invalidKeys[0]}\". ` +\n 'Aliases must be lower camel case.',\n );\n }\n\n // Values must only be letters, numbers and slashes\n const validValueRegex = /^[a-zA-Z0-9/]*$/;\n const invalidValues = routes.filter(\n (value) => !validValueRegex.test(value),\n );\n if (invalidValues.length > 0) {\n throw new Error(\n `Invalid route \"${invalidValues}\". ` +\n 'Routes must only contain letters, numbers and slashes.',\n );\n }\n\n // All path parts must be lower camel case\n const pathParts = routes.map((value) => value.split('/')).flat();\n const invalidPathParts = pathParts.filter(\n (part) => !camelCaseRegex.test(part),\n );\n\n if (invalidPathParts.length > 0) {\n throw new Error(\n `Invalid route segment \"${invalidPathParts[0]}\". ` +\n 'Route segments must be lower camel case.',\n );\n }\n\n // Routes must not occur more than once\n const routeCountMap: Record<string, number> = {};\n routes.forEach((value) => {\n routeCountMap[value] = (routeCountMap[value] ?? 0) + 1;\n });\n\n const duplicateRoutes = Object.entries(routeCountMap)\n .filter(([, count]) => count > 1)\n .map(([route]) => route);\n\n if (duplicateRoutes.length > 0) {\n throw new Error(\n `Duplicate route ${duplicateRoutes[0]}. A column must only occur once.`,\n );\n }\n }\n\n // ######################\n // Private\n // ######################\n\n private _throwOnWrongAlias(columns: ColumnInfo[]): void {\n const aliases = new Set<string>();\n for (const column of columns) {\n if (aliases.has(column.alias)) {\n throw new Error(`Duplicate alias: ${column.alias}`);\n }\n aliases.add(column.alias);\n }\n }\n\n private _initColumns(columns: ColumnInfo[]): ColumnInfo[] {\n let i = 0;\n return columns.map((column) =>\n hip({\n ...column,\n routeHash: this.routeHashes[i],\n index: i++,\n _hash: '',\n }),\n );\n }\n\n // ######################\n // Example\n // ######################\n\n static example(): ColumnSelection {\n return new ColumnSelection([\n {\n key: 'stringCol',\n alias: 'stringCol',\n route: 'basicTypes/stringsRef/value',\n type: 'string',\n titleLong: 'String values',\n titleShort: 'Strings',\n },\n {\n key: 'intCol',\n alias: 'intCol',\n route: 'basicTypes/numbersRef/intsRef/value',\n type: 'number',\n titleLong: 'Int values',\n titleShort: 'Ints',\n },\n {\n key: 'floatCol',\n alias: 'floatCol',\n route: 'basicTypes/numbersRef/floatsRef/value',\n type: 'number',\n titleLong: 'Float values',\n titleShort: 'Floats',\n },\n {\n key: 'booleanCol',\n alias: 'booleanCol',\n route: 'basicTypes/booleansRef/value',\n type: 'boolean',\n titleLong: 'Boolean values',\n titleShort: 'Booleans',\n },\n {\n key: 'jsonObjectCol',\n alias: 'jsonObjectCol',\n route: 'complexTypes/jsonObjectsRef/value',\n type: 'json',\n titleLong: 'Json objects',\n titleShort: 'JO',\n },\n {\n key: 'jsonArrayCol',\n alias: 'jsonArrayCol',\n route: 'complexTypes/jsonArraysRef/value',\n type: 'jsonArray',\n titleLong: 'Array values',\n titleShort: 'JA',\n },\n {\n key: 'jsonValueCol',\n alias: 'jsonValueCol',\n route: 'complexTypes/jsonValuesRef/value',\n type: 'jsonValue',\n titleLong: 'Json values',\n titleShort: 'JV',\n },\n ]);\n }\n\n static exampleBroken(): ColumnInfo[] {\n return [\n {\n key: 'stringCol',\n alias: 'stringCol',\n route: 'basicTypes/stringsRef/value',\n type: 'string',\n titleLong: 'String values',\n titleShort: 'Strings',\n },\n {\n key: 'stringCol2',\n alias: 'stringCol', // ⚠️ Duplicate alias\n route: 'basicTypes/stringsRef/value',\n type: 'string',\n titleLong: 'String values',\n titleShort: 'Strings',\n },\n ];\n }\n\n static exampleCarsColumnSelection(): ColumnSelection {\n return new ColumnSelection([\n {\n key: 'brand',\n route: 'carCake/carGeneralLayer/carGeneral/brand',\n alias: 'brand',\n titleLong: 'Car Brand',\n titleShort: 'Brand',\n type: 'string',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'type',\n route: 'carCake/carGeneralLayer/carGeneral/type',\n alias: 'type',\n titleLong: 'Car Type',\n titleShort: 'Type',\n type: 'string',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'serviceIntervals',\n route: 'carCake/carGeneralLayer/carGeneral/serviceIntervals',\n alias: 'serviceIntervals',\n titleLong: 'Car Service Intervals',\n titleShort: 'Service Intervals',\n type: 'jsonValue',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'isElectric',\n route: 'carCake/carGeneralLayer/carGeneral/isElectric',\n alias: 'isElectric',\n titleLong: 'Is Electric Car',\n titleShort: 'Electric',\n type: 'boolean',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'carDimensions/height',\n route: 'carCake/carTechnicalLayer/carTechnical/carDimensions/height',\n alias: 'height',\n titleLong: 'Car Height',\n titleShort: 'Height',\n type: 'number',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'carDimensions/width',\n route: 'carCake/carTechnicalLayer/carTechnical/carDimensions/width',\n alias: 'width',\n titleLong: 'Car Width',\n titleShort: 'Width',\n type: 'number',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'carDimensions/length',\n route: 'carCake/carTechnicalLayer/carTechnical/carDimensions/length',\n alias: 'length',\n titleLong: 'Car Length',\n titleShort: 'Length',\n type: 'number',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'engine',\n route: 'carCake/carTechnicalLayer/carTechnical/engine',\n alias: 'engine',\n titleLong: 'Car Engine',\n titleShort: 'Engine',\n type: 'string',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'repairedByWorkshop',\n route: 'carCake/carTechnicalLayer/carTechnical/repairedByWorkshop',\n alias: 'repairedByWorkshop',\n titleLong: 'Was Repaired By Workshop',\n titleShort: 'Repaired By Workshop',\n type: 'boolean',\n _hash: '',\n } as ColumnInfo,\n ]);\n }\n\n static exampleCarsDeeplyNestedColumnSelection(): ColumnSelection {\n return new ColumnSelection([\n {\n key: 'brand',\n route:\n 'catalogCake/catalogSeriesLayer/catalogSeries/seriesCake/seriesCarsLayer/seriesCars/carCake/carGeneralLayer/carGeneral/brand',\n alias: 'brand',\n titleLong: 'Car Brand',\n titleShort: 'Brand',\n type: 'string',\n _hash: '',\n } as ColumnInfo,\n ]);\n }\n\n static exampleCarsColumnSelectionOnlySomeColumns(): ColumnSelection {\n return new ColumnSelection([\n {\n key: 'brand',\n route: 'carCake/carGeneralLayer/carGeneral/brand',\n alias: 'brand',\n titleLong: 'Car Brand',\n titleShort: 'Brand',\n type: 'string',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'type',\n route: 'carCake/carGeneralLayer/carGeneral/type',\n alias: 'type',\n titleLong: 'Car Type',\n titleShort: 'Type',\n type: 'string',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'serviceIntervals',\n route: 'carCake/carGeneralLayer/carGeneral/serviceIntervals',\n alias: 'serviceIntervals',\n titleLong: 'Car Service Intervals',\n titleShort: 'Service Intervals',\n type: 'jsonValue',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'isElectric',\n route: 'carCake/carGeneralLayer/carGeneral/isElectric',\n alias: 'isElectric',\n titleLong: 'Is Electric Car',\n titleShort: 'Electric',\n type: 'boolean',\n _hash: '',\n } as ColumnInfo,\n {\n key: 'carDimensions/length',\n route: 'carCake/carTechnicalLayer/carTechnical/carDimensions/length',\n alias: 'length',\n titleLong: 'Car Length',\n titleShort: 'Length',\n type: 'number',\n _hash: '',\n } as ColumnInfo,\n ]);\n }\n\n // ...........................................................................\n static empty(): ColumnSelection {\n return new ColumnSelection([]);\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { hip } from '@rljson/hash';\n\nimport { BoolOperator } from './boolean-filter-processor.ts';\nimport { ColumnFilter } from './column-filter.ts';\n\nexport interface BooleanFilter extends ColumnFilter<boolean> {\n type: 'boolean';\n operator: BoolOperator;\n}\n\nexport const trueValues = ['t', 'j', 'y'];\nexport const falseValues = ['n', 'f'];\n\n/**\n * Parses a boolean search\n * @param search The search value to be parsed\n * @returns the parse result\n */\nexport const parseBooleanSearch = (search: any): boolean | null => {\n if (typeof search == 'undefined' || search == null) {\n return null;\n }\n\n if (typeof search == 'boolean') {\n return search;\n }\n\n if (typeof search == 'number') {\n return search != 0;\n }\n\n if (typeof search == 'string') {\n const val = search.toLowerCase();\n\n for (const trueValue of trueValues) {\n if (val.startsWith(trueValue)) {\n return true;\n }\n }\n\n for (const falseValue of falseValues) {\n if (val.startsWith(falseValue)) {\n return false;\n }\n }\n\n const containsOnlyNumbers = /^\\d+$/.test(search);\n /* v8 ignore if -- @preserve */\n if (containsOnlyNumbers) {\n return parseInt(search) != 0;\n }\n }\n\n return false;\n};\n\n// ..............................................................................\n\nexport const exampleBooleanFilter = (): BooleanFilter =>\n hip<BooleanFilter>({\n column: 'basicTypes/booleansRef/value',\n operator: 'equals',\n type: 'boolean',\n search: true,\n _hash: '',\n });\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport {\n BooleanFilter,\n exampleBooleanFilter,\n parseBooleanSearch,\n} from './boolean-filter.ts';\nimport { ColumnFilterProcessor } from './column-filter-processor.ts';\n\nexport class BooleanFilterProcessor implements ColumnFilterProcessor {\n constructor(\n public readonly operator: BoolOperator,\n\n search: boolean | string | number | null,\n ) {\n this.search =\n search === null\n ? null\n : typeof search === 'boolean'\n ? search\n : parseBooleanSearch(search);\n }\n\n search: boolean | null;\n\n // ...........................................................................\n static fromModel(model: BooleanFilter): BooleanFilterProcessor {\n return new BooleanFilterProcessor(model.operator, model.search);\n }\n\n // ...........................................................................\n equals(other: ColumnFilterProcessor): boolean {\n return (\n other instanceof BooleanFilterProcessor &&\n this.operator === other.operator &&\n this.search === other.search\n );\n }\n\n // ...........................................................................\n static readonly allOperators: BoolOperator[] = ['equals', 'notEquals'];\n\n // ...........................................................................\n matches(cellValue: any): boolean {\n if (this.search === null || this.search === undefined) {\n return true;\n }\n\n if (cellValue === null || cellValue === undefined) {\n return false;\n }\n\n if (typeof cellValue == 'number') {\n cellValue = cellValue != 0;\n }\n\n if (typeof cellValue == 'string') {\n const val = cellValue.toLowerCase();\n cellValue = val === 'true' || val === 'yes' || '1';\n }\n\n switch (this.operator) {\n case 'equals':\n return cellValue === this.search;\n case 'notEquals':\n return cellValue !== this.search;\n }\n }\n\n // ...........................................................................\n static get example(): BooleanFilterProcessor {\n const model: BooleanFilter = exampleBooleanFilter();\n const filterProcessor = BooleanFilterProcessor.fromModel(model);\n return filterProcessor;\n }\n}\n\nexport type BoolOperator = 'equals' | 'notEquals';\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { hip } from '@rljson/hash';\n\nimport { ColumnFilter } from './column-filter.ts';\nimport { NumberOperator } from './number-filter-processor.ts';\n\nexport interface NumberFilter extends ColumnFilter<number> {\n type: 'number';\n operator: NumberOperator;\n}\n\n// ..............................................................................\n\nexport const exampleNumberFilter = (): NumberFilter =>\n hip<NumberFilter>({\n column: 'basicTypes/numbersRef/intsRef/value',\n operator: 'greaterThanOrEquals',\n type: 'number',\n search: 1000,\n _hash: '',\n });\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { compileExpression } from 'filtrex';\n\nimport { ColumnFilterProcessor } from './column-filter-processor.ts';\nimport { exampleNumberFilter, NumberFilter } from './number-filter.ts';\n\n// #############################################################################\nexport class NumberFilterProcessor implements ColumnFilterProcessor {\n constructor(\n public readonly operator: NumberOperator,\n\n search: number | string,\n ) {\n if (operator === 'filtrex') {\n this.search = search;\n this._initFiltrex();\n } else {\n this.search = typeof search == 'string' ? parseFloat(search) : search;\n }\n }\n\n // ...........................................................................\n static fromModel(model: NumberFilter): NumberFilterProcessor {\n return new NumberFilterProcessor(model.operator, model.search);\n }\n\n equals(other: ColumnFilterProcessor): boolean {\n return (\n other instanceof NumberFilterProcessor &&\n this.operator === other.operator &&\n this.search === other.search\n );\n }\n\n // ...........................................................................\n static readonly allOperators: NumberOperator[] = [\n 'equals',\n 'notEquals',\n 'greaterThan',\n 'greaterThanOrEquals',\n 'lessThan',\n 'lessThanOrEquals',\n 'filtrex',\n ];\n\n // ...........................................................................\n matches(cellValue: any): boolean {\n if (!this.search && this.search !== 0) {\n return true;\n }\n\n if (cellValue === null || cellValue === undefined) {\n return false;\n }\n\n switch (this.operator) {\n case 'equals':\n return cellValue === this.search;\n case 'notEquals':\n return cellValue !== this.search;\n case 'greaterThan':\n return cellValue > this.search;\n case 'lessThan':\n return cellValue < this.search;\n case 'greaterThanOrEquals':\n return cellValue >= this.search;\n case 'lessThanOrEquals':\n return cellValue <= this.search;\n case 'filtrex':\n return this?._evalExpression(cellValue);\n }\n }\n\n search: number | string = '';\n\n static get example(): NumberFilterProcessor {\n return NumberFilterProcessor.fromModel(exampleNumberFilter());\n }\n\n // ######################\n // Private\n // ######################\n\n private _expression: any = null;\n\n // ..........................................................................\n private _initFiltrex() {\n // If search is empty, no expression is needed\n if (this.search === '') {\n return;\n }\n\n // If search is a number, we can use it directly\n if (typeof this.search === 'number') {\n return;\n }\n\n // Check if this contains only numbers\n const isNumber = /^\\d+$/.test(this.search);\n if (isNumber) {\n this.search = parseInt(this.search);\n return;\n }\n\n // Try to compile the expression\n try {\n this._expression = compileExpression(this.search);\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (_) {\n // As long as the expression is not valid,\n // the searched value must equal the cell value\n this._expression = '';\n }\n }\n\n // ...........................................................................\n private _evalExpression(cellValue: any): boolean {\n return this._expression\n ? // result can also contain errors which could be sent to the outside here\n this._expression({ v: cellValue }) == true\n : cellValue == this.search;\n }\n}\n\nexport type NumberOperator =\n | 'equals'\n | 'notEquals'\n | 'greaterThan'\n | 'greaterThanOrEquals'\n | 'lessThan'\n | 'lessThanOrEquals'\n | 'filtrex';\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { hip } from '@rljson/hash';\n\nimport { ColumnFilter } from './column-filter.ts';\nimport { StringOperator } from './string-filter-processor.ts';\n\nexport interface StringFilter extends ColumnFilter<string> {\n type: 'string';\n operator: StringOperator;\n matchCase?: boolean;\n}\n\n// ..............................................................................\n\nexport const exampleStringFilter = (): StringFilter =>\n hip<StringFilter>({\n type: 'string',\n column: 'basicTypes/stringsRef/value',\n operator: 'startsWith',\n search: 't',\n matchCase: false,\n _hash: '',\n });\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { ColumnFilterProcessor } from './column-filter-processor.ts';\nimport { exampleStringFilter, StringFilter } from './string-filter.ts';\n\nexport class StringFilterProcessor implements ColumnFilterProcessor {\n constructor(\n public readonly operator: StringOperator,\n\n search: string,\n public readonly matchCase: boolean = false,\n ) {\n this.search = (matchCase ? search : search.toLowerCase()).replaceAll(\n ' ',\n '',\n );\n\n /* v8 ignore start */\n try {\n this.regExp = operator === 'regExp' ? new RegExp(search) : null;\n } catch {}\n /* v8 ignore stop */\n }\n\n // ...........................................................................\n static fromModel(model: StringFilter): StringFilterProcessor {\n return new StringFilterProcessor(\n model.operator,\n model.search,\n model.matchCase,\n );\n }\n\n // ...........................................................................\n search: string;\n regExp: RegExp | null = null;\n\n // ...........................................................................\n equals(other: ColumnFilterProcessor): boolean {\n return (\n other instanceof StringFilterProcessor &&\n this.operator === other.operator &&\n this.search === other.search &&\n this.matchCase === other.matchCase\n );\n }\n\n // ...........................................................................\n static readonly allOperators: StringOperator[] = [\n 'contains',\n 'equals',\n 'notEquals',\n 'startsWith',\n 'notContains',\n 'endsWith',\n 'regExp',\n ];\n\n // ...........................................................................\n matches(cellValue: any): boolean {\n if (!this.search) {\n return true;\n }\n\n if (cellValue === null || cellValue === undefined) {\n return false;\n }\n\n if (typeof cellValue !== 'string') {\n cellValue = `${cellValue}`;\n }\n\n if (!this.matchCase) {\n cellValue = cellValue.toLowerCase();\n }\n\n cellValue = cellValue.replaceAll(' ', '');\n\n switch (this.operator) {\n case 'equals':\n return cellValue === this.search;\n case 'notEquals':\n return cellValue !== this.search;\n case 'startsWith':\n return cellValue.startsWith(this.search);\n case 'contains':\n return cellValue.includes(this.search);\n case 'endsWith':\n return cellValue.endsWith(this.search);\n /* v8 ignore next -- @preserve */\n case 'regExp':\n return this.regExp?.test(cellValue) ?? false;\n\n case 'notContains':\n return !cellValue.includes(this.search);\n }\n }\n\n // ...........................................................................\n static get example(): StringFilterProcessor {\n const result = StringFilterProcessor.fromModel(exampleStringFilter());\n return result;\n }\n}\n\nexport type StringOperator =\n | 'startsWith'\n | 'contains'\n | 'endsWith'\n | 'equals'\n | 'notEquals'\n | 'notContains'\n | 'regExp';\n","/* eslint-disable @typescript-eslint/no-unused-vars */\n\n// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { BooleanFilterProcessor } from './boolean-filter-processor.ts';\nimport { BooleanFilter } from './boolean-filter.ts';\nimport { ColumnFilter } from './column-filter.ts';\nimport { NumberFilterProcessor } from './number-filter-processor.ts';\nimport { NumberFilter } from './number-filter.ts';\nimport { StringFilterProcessor } from './string-filter-processor.ts';\nimport { StringFilter } from './string-filter.ts';\n\nexport class ColumnFilterProcessor {\n /* v8 ignore next -- @preserve */\n matches(_cellValue: string): boolean {\n /* v8 ignore next -- @preserve */\n return true;\n }\n\n equals(_other: ColumnFilterProcessor): boolean {\n return this === _other;\n }\n\n // ...........................................................................\n static fromModel(model: ColumnFilter<any>): ColumnFilterProcessor {\n switch (model.type) {\n case 'string':\n return StringFilterProcessor.fromModel(model as StringFilter);\n case 'number':\n return NumberFilterProcessor.fromModel(model as NumberFilter);\n case 'boolean':\n return BooleanFilterProcessor.fromModel(model as BooleanFilter);\n /* v8 ignore next -- @preserve */\n default:\n return StringFilterProcessor.fromModel(model as StringFilter);\n }\n }\n\n // ...........................................................................\n /* v8 ignore stop */\n static operatorsForType(type: string): string[] {\n switch (type) {\n case 'string':\n return StringFilterProcessor.allOperators;\n case 'number':\n return NumberFilterProcessor.allOperators;\n case 'boolean':\n return BooleanFilterProcessor.allOperators;\n default:\n return StringFilterProcessor.allOperators;\n }\n }\n\n static translationsForType(type: string, language: 'de' | 'en'): string[] {\n const operators = ColumnFilterProcessor.operatorsForType(type);\n const translations = [];\n\n for (const operator of operators) {\n translations.push(\n ColumnFilterProcessor.translateOperator(operator, language),\n );\n }\n\n return translations;\n }\n\n static translateOperator(operator: string, language: 'de' | 'en') {\n const translations: Record<string, Record<string, string>> = {\n equals: { en: 'Equals', de: 'Gleich' },\n notEquals: { en: 'Not equals', de: 'Ungleich' },\n greaterThan: { en: 'Greater than', de: 'Größer' },\n greaterThanOrEquals: {\n en: 'Greater than or Equals',\n de: 'Größer oder gleich',\n },\n lessThan: { en: 'Less than', de: 'Kleiner als' },\n lessThanOrEquals: {\n en: 'Less than or equals',\n de: 'Kleiner gleich',\n },\n startsWith: { en: 'Starts with', de: 'Beginnt mit' },\n contains: { en: 'Contains', de: 'Enthält' },\n notContains: { en: 'Not contains', de: 'Enthält nicht' },\n endsWith: { en: 'Ends with', de: 'Endet mit' },\n regExp: { en: 'Regular expression', de: 'Regulärer Ausdruck' },\n filtrex: { en: 'Expression', de: 'Ausdruck' },\n };\n\n return translations[operator][language];\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { Route } from '@rljson/rljson';\n\nimport { Join, JoinRowsHashed } from '../join.ts';\nimport { ColumnSelection } from '../selection/column-selection.ts';\n\nimport { ColumnFilterProcessor } from './column-filter-processor.ts';\nimport { RowFilter } from './row-filter.ts';\n\n// #############################################################################\nexport class RowFilterProcessor {\n // ...........................................................................\n constructor(\n columnFilters: Record<string, ColumnFilterProcessor>,\n public readonly operator: 'and' | 'or' = 'and',\n ) {\n this._columnFilters = this._initColumnFilters(columnFilters);\n }\n\n // ...........................................................................\n static fromModel(model: RowFilter) {\n const operator = model.operator;\n const columnFilters: Record<string, ColumnFilterProcessor> = {};\n for (const columnFilter of model.columnFilters) {\n const key = columnFilter.column;\n const processor = ColumnFilterProcessor.fromModel(columnFilter);\n columnFilters[key] = processor;\n }\n\n return new RowFilterProcessor(columnFilters, operator);\n }\n\n // ...........................................................................\n get processors(): ColumnFilterProcessor[] {\n return Object.values(this._columnFilters).map((item) => item.processor);\n }\n\n // ...........................................................................\n /// Returns an empty filter\n static get empty(): RowFilterProcessor {\n return new RowFilterProcessor({}, 'and');\n }\n\n // ...........................................................................\n /// Checks if two filters are equal\n equals(other: RowFilterProcessor): boolean {\n if (this.operator !== other.operator) {\n return false;\n }\n\n const thisKeys = Object.keys(this._columnFilters);\n const otherKeys = Object.keys(other._columnFilters);\n\n if (thisKeys.length !== otherKeys.length) {\n return false;\n }\n\n for (const key of thisKeys) {\n const a = this._columnFilters[key];\n const b = other._columnFilters[key];\n if (a?.processor.equals(b?.processor) === false) {\n return false;\n }\n }\n\n return true;\n }\n\n // ...........................................................................\n applyTo(join: Join): JoinRowsHashed {\n if (join.rowCount === 0) {\n return join.data;\n }\n\n // Throw when filter specifies non existent column routes\n this._throwOnWrongRoutes(join.columnSelection);\n\n // Generate an array of filters\n const columnCount = join.columnCount;\n const columnHashes = join.columnSelection.routeHashes;\n\n const filterArray: ColumnFilterProcessor[] = new Array(columnCount).fill(\n null,\n );\n\n let hasFilters = false;\n for (let c = 0; c < columnCount; c++) {\n const hash = columnHashes[c];\n const filter = this._columnFilters[hash];\n if (filter) {\n filterArray[c] = filter.processor;\n hasFilters = true;\n }\n }\n\n // No filters set? Return unchanged indices.\n if (!hasFilters) {\n return join.data;\n }\n\n // Apply the filters\n let rowIndices: number[] = [];\n switch (this.operator) {\n case 'and':\n rowIndices = this._filterRowsAnd(join, filterArray);\n break;\n case 'or':\n rowIndices = this._filterRowsOr(join, filterArray);\n break;\n }\n\n // Build the resulting data\n const result: JoinRowsHashed = {};\n const rowIndexSet = new Set(rowIndices);\n let idx = 0;\n for (const [sliceId, row] of Object.entries(join.data)) {\n if (rowIndexSet.has(idx)) {\n result[sliceId] = row;\n }\n idx++;\n }\n return result;\n }\n\n // ######################\n // Private\n // ######################\n\n // ...........................................................................\n private readonly _columnFilters: Record<string, _ColumnFilterItem>;\n\n // ...........................................................................\n private _initColumnFilters(\n columnFilters: Record<string, ColumnFilterProcessor>,\n ) {\n const result: Record<string, _ColumnFilterItem> = {};\n\n const columnKeys = Object.keys(columnFilters);\n const columnRoutes = columnKeys.map((k) => Route.fromFlat(k));\n const columnSelection = ColumnSelection.fromRoutes(columnRoutes);\n\n const { routeHashes, routes } = columnSelection;\n\n for (let i = 0; i < routeHashes.length; i++) {\n const routeHash = routeHashes[i];\n const route = routes[i];\n const processor = columnFilters[route]!;\n\n result[routeHash] = {\n processor,\n routeHash,\n route,\n };\n }\n\n return result;\n }\n\n // ...........................................................................\n private _filterRowsAnd(\n join: Join,\n filters: ColumnFilterProcessor[],\n ): number[] {\n // Fill the array with all row indices\n const rowCount = join.rowCount;\n let remainingIndices: number[] = new Array(rowCount);\n for (let i = 0; i < rowCount; i++) {\n remainingIndices[i] = i;\n }\n\n const columnCount = join.columnCount;\n\n for (let c = 0; c < columnCount; c++) {\n remainingIndices = this._filterColumnAnd(\n join,\n c,\n remainingIndices,\n filters,\n );\n }\n\n return remainingIndices;\n }\n\n // ...........................................................................\n private _filterColumnAnd(\n join: Join,\n columnIndex: number,\n remainingIndices: number[],\n filters: ColumnFilterProcessor[],\n ): number[] {\n const result: number[] = [];\n const filter = filters[columnIndex];\n if (filter == null) {\n return remainingIndices;\n }\n\n for (const i of remainingIndices) {\n const cellValues = join.value(i, columnIndex);\n\n for (const cellValue of cellValues) {\n if (filter.matches(cellValue as string)) {\n result.push(i);\n }\n }\n }\n\n return result;\n }\n\n // ...........................................................................\n private _filterRowsOr(\n join: Join,\n filters: ColumnFilterProcessor[],\n ): number[] {\n // Fill the array with all row indices\n const applyTo: boolean[] = new Array(join.rowCount).fill(false);\n\n const columnCount = join.columnCount;\n\n for (let c = 0; c < columnCount; c++) {\n this._filterColumnOr(join, c, applyTo, filters);\n }\n\n let rowCount = 0;\n for (let r = 0; r < applyTo.length; r++) {\n if (applyTo[r]) {\n rowCount++;\n }\n }\n\n const result: number[] = new Array(rowCount);\n let resultIndex = 0;\n for (let r = 0; r < applyTo.length; r++) {\n if (applyTo[r]) {\n result[resultIndex] = r;\n resultIndex++;\n }\n }\n\n return result;\n }\n\n // ...........................................................................\n private _filterColumnOr(\n join: Join,\n columnIndex: number,\n applyTo: boolean[],\n filters: ColumnFilterProcessor[],\n ) {\n const filter = filters[columnIndex];\n if (filter == null) {\n return;\n }\n\n for (let r = 0; r < join.rowCount; r++) {\n if (applyTo[r]) {\n continue;\n }\n\n const cellValues = join.value(r, columnIndex);\n\n for (const cellValue of cellValues) {\n if (filter.matches(cellValue as string)) {\n applyTo[r] = true;\n }\n }\n }\n }\n\n // ...........................................................................\n private _throwOnWrongRoutes(columnSelection: ColumnSelection) {\n const availableRoutes = columnSelection.routes;\n for (const item of Object.values(this._columnFilters)) {\n const route = item.route;\n if (availableRoutes.includes(route) === false) {\n throw new Error(\n `RowFilterProcessor: Error while applying filter to join: ` +\n `There is a column filter for route \"${route}\", but the join ` +\n `does not have a column with this route.\\n\\nAvailable routes:\\n` +\n `${availableRoutes.map((a) => `- ${a}`).join('\\n')}`,\n );\n }\n }\n }\n}\n\n// #############################################################################\ninterface _ColumnFilterItem {\n processor: ColumnFilterProcessor;\n routeHash: string;\n\n route: string;\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { Hash } from '@rljson/hash';\nimport { Json, JsonValue, JsonValueType } from '@rljson/json';\nimport { Ref, Route, SliceId } from '@rljson/rljson';\n\nimport { traverse } from 'object-traversal';\n\nimport { Container } from '../db.ts';\nimport { inject } from '../tools/inject.ts';\nimport { isolate } from '../tools/isolate.ts';\nimport { mergeTrees } from '../tools/merge-trees.ts';\n\nimport { RowFilterProcessor } from './filter/row-filter-processor.ts';\nimport { RowFilter } from './filter/row-filter.ts';\nimport { ColumnSelection } from './selection/column-selection.ts';\nimport { SetValue } from './set-value/set-value.ts';\nimport { RowSort } from './sort/row-sort.ts';\n\nexport const joinPreserveKeys = [\n 'sliceIdsTable',\n 'sliceIdsRow',\n /*'base',*/\n 'sliceIdsTable',\n 'sliceIdsTableRow',\n 'componentsTable',\n];\n\nexport type JoinProcessType = 'filter' | 'setValue' | 'selection' | 'sort';\n\nexport type JoinProcess = {\n type: JoinProcessType;\n instance: RowFilter | SetValue | ColumnSelection | RowSort;\n data: JoinRowsHashed;\n columnSelection: ColumnSelection;\n};\n\nexport interface JoinColumn {\n route: Route;\n value: Container;\n inserts: Container[] | null;\n}\n\nexport type JoinRow = JoinColumn[];\nexport type JoinRows = Record<SliceId, JoinRow>;\n\nexport type JoinRowHashed = {\n rowHash: Ref;\n columns: JoinColumn[];\n};\nexport type JoinRowsHashed = Record<SliceId, JoinRowHashed>;\n\nexport class Join {\n private _base: JoinRowsHashed = {};\n private _baseColumnSelection: ColumnSelection;\n\n private _processes: JoinProcess[] = [];\n\n constructor(rows: JoinRows, columnSelection: ColumnSelection) {\n // Hash the rows\n this._base = this._hashedRows(rows);\n\n this._baseColumnSelection = columnSelection;\n }\n\n // ...........................................................................\n /**\n * Applies a filter to the join and returns the filtered view\n *\n * @param filter The filter to apply\n */\n filter(filter: RowFilter): Join {\n const proc = RowFilterProcessor.fromModel(filter);\n\n const data = proc.applyTo(this);\n\n // Create the process entry\n const process: JoinProcess = {\n type: 'filter',\n instance: filter,\n data,\n columnSelection: this.columnSelection,\n };\n\n // Store the process\n this._processes.push(process);\n\n return this;\n }\n\n // ...........................................................................\n /**\n * Applies a set value action to the join and returns the edited join\n *\n * @param setValue The set value action to apply\n */\n setValue(setValue: SetValue): Join {\n const data: JoinRowsHashed = {};\n\n for (const [sliceId, joinRowH] of Object.entries(this.data)) {\n const cols = [...joinRowH.columns];\n const insertCols = [];\n for (const col of cols) {\n const insertCol = {\n ...col,\n //inserts: col.inserts ? [...col.inserts] : [],\n };\n\n /*v8 ignore else -- @preserve */\n if (Route.fromFlat(setValue.route).equalsWithoutRefs(col.route)) {\n for (const cell of col.value.cell) {\n /* v8 ignore next -- @preserve */\n if (cell.path.length === 0) {\n throw new Error(\n `Join: Error while applying SetValue: ` +\n `Cannot set value for column without paths. ` +\n `Route: ${setValue.route.toString()}.`,\n );\n }\n\n /* v8 ignore next -- @preserve */\n if (cell.path.length > 1) {\n throw new Error(\n `Join: Error while applying SetValue: ` +\n `Cannot set value for multiple paths in one cell. ` +\n `Found paths: [${cell.path.join(', ')}] for route: ` +\n `${setValue.route.toString()}.`,\n );\n }\n\n const cellInsertTree = isolate(\n { ...col.value.tree },\n cell.path[0],\n joinPreserveKeys,\n );\n inject(cellInsertTree, cell.path[0], setValue.value);\n\n const propertyKey = cell.path[0].slice(-1)[0];\n const insert: Container = {\n cell: [\n {\n ...cell,\n ...{ value: setValue.value },\n ...{\n row: {\n ...(cell.row as Json),\n ...{ [propertyKey]: setValue.value },\n } as any,\n },\n },\n ],\n tree: cellInsertTree,\n rljson: col.value.rljson,\n };\n\n /* v8 ignore next -- @preserve */\n if (insert) {\n if (insertCol.inserts) insertCol.inserts.push(insert);\n else insertCol.inserts = [insert];\n }\n }\n }\n insertCols.push(insertCol);\n }\n\n data[sliceId] = {\n rowHash: Hash.default.calcHash(\n insertCols.map((col) =>\n col.value.cell.flatMap((c) => c.value),\n ) as any[],\n ),\n columns: insertCols,\n };\n }\n\n // Create the process entry\n const process: JoinProcess = {\n type: 'setValue',\n instance: setValue,\n data,\n columnSelection: this.columnSelection,\n };\n\n // Store the process\n this._processes.push(process);\n\n return this;\n }\n\n // ...........................................................................\n /**\n * Applies multiple set value actions to the join and returns the edited join\n *\n * @param setValues The set value actions to apply\n */\n setValues(setValues: SetValue[]): Join {\n // Apply the set values one by one to a copy of this join\n let result: Join = this.clone();\n\n for (const setValue of setValues) {\n result = result.setValue(setValue);\n }\n\n return result;\n }\n\n // ...........................................................................\n /**\n * Selects columns from the join and returns the resulting join\n *\n * @param columnSelection The column selection to apply\n */\n select(columnSelection: ColumnSelection): Join {\n const columnCount = columnSelection.count;\n const masterColumnIndices = new Array(columnCount);\n\n // Map selected columns to master column indices\n let i = 0;\n for (const hash of columnSelection.routeHashes) {\n const index = this.columnSelection.columnIndex(hash);\n masterColumnIndices[i] = index;\n i++;\n }\n\n // Select the columns\n const data: JoinRowsHashed = {};\n for (let i = 0; i < this.rowCount; i++) {\n const [sliceId, row] = Object.entries(this.data)[i];\n const cols: JoinColumn[] = [];\n // Select only the requested columns\n for (let j = 0; j < masterColumnIndices.length; j++) {\n cols.push(row.columns[masterColumnIndices[j]]);\n }\n // Store the selected columns\n data[sliceId] = {\n rowHash: Hash.default.calcHash(\n cols.map((col) => col.value.cell.flatMap((c) => c.value)) as any[],\n ),\n columns: cols,\n };\n }\n\n // Create the process entry\n const process: JoinProcess = {\n type: 'selection',\n instance: columnSelection,\n data,\n columnSelection,\n };\n\n // Store the process\n this._processes.push(process);\n\n return this;\n }\n\n // ...........................................................................\n /**\n * Sorts the join rows and returns the sorted join\n *\n * @param rowSort The row sort to apply\n */\n sort(rowSort: RowSort): Join {\n const sortedIndices = rowSort.applyTo(this);\n\n const data: JoinRowsHashed = {};\n for (let i = 0; i < sortedIndices.length; i++) {\n const sliceId = sortedIndices[i];\n data[sliceId] = this.data[sliceId];\n }\n\n // Create the process entry\n const process: JoinProcess = {\n type: 'sort',\n instance: rowSort,\n data,\n columnSelection: this.columnSelection,\n };\n\n // Store the process\n this._processes.push(process);\n\n return this;\n }\n\n // ...........................................................................\n /**\n * Returns insert Object of the join\n */\n insert(): {\n route: Route;\n tree: Json;\n }[] {\n const inserts: {\n route: Route;\n tree: Json;\n }[] = [];\n\n for (let i = 0; i < this.columnCount; i++) {\n const colInserts: {\n route: Route;\n tree: Json;\n path: Array<string | number>;\n }[] = [];\n for (const row of Object.values(this.data)) {\n const col = row.columns[i];\n if (col.inserts && col.inserts.length > 0) {\n for (const insert of col.inserts) {\n for (const cell of insert.cell) {\n const tree = insert.tree;\n const path = cell.path;\n\n // Inject the value at the path, inject complete row\n inject(tree, path[0].slice(0, -1), cell.row);\n\n colInserts.push({\n route: col.route,\n tree,\n path: path[0],\n });\n }\n }\n }\n }\n\n if (colInserts.length === 0) continue;\n\n //Merge all insert trees into one\n const routes = colInserts.map((ins) => ins.route.flat);\n const uniqueRoute = Array.from(new Set(routes));\n\n /* v8 ignore if -- @preserve */\n if (uniqueRoute.length > 1) {\n throw new Error(\n `Join: Error while generating insert: ` +\n `Multiple different routes found in inserts: ` +\n `${uniqueRoute.map((r) => r.toString()).join(', ')}. ` +\n `Cannot generate single insert object.`,\n );\n }\n\n const merged = mergeTrees(\n colInserts.map((ins) => ({\n tree: ins.tree,\n path: ins.path.slice(0, -1),\n })),\n );\n\n //Delete _hash and filter null values from _data arrays\n traverse(merged, ({ parent, key, value }) => {\n if (key == '_hash') {\n //delete parent![key];\n }\n if (key == '_data' && Array.isArray(value) && value.length > 0) {\n parent![key] = value.filter((v) => !!v);\n }\n });\n\n inserts.push({\n route: Route.fromFlat(uniqueRoute[0]).toRouteWithProperty(),\n tree: merged,\n });\n }\n\n return inserts;\n }\n\n // ...........................................................................\n /**\n * Returns the value at the given row and column index\n *\n * @param row The row index\n * @param column The column index\n * @returns The value at the given row and column\n */\n value(row: number, column: number): JsonValue[] {\n return this.rows[row][column];\n }\n\n // ...........................................................................\n /**\n * Clones the join\n *\n * @returns The cloned join\n */\n clone(): Join {\n const cloned = Object.create(this);\n cloned._data = this._base;\n cloned._processes = [...this._processes];\n return cloned;\n }\n\n // ...........................................................................\n /**\n * Returns all component routes of the join\n */\n get componentRoutes(): Route[] {\n return Array.from(\n new Set(\n Object.values(this.columnSelection.columns).map(\n (c) => Route.fromFlat(c.route).upper().flatWithoutRefs,\n ),\n ),\n ).map((r) => Route.fromFlat(r));\n }\n\n // ...........................................................................\n /**\n * Returns all layer routes of the join\n */\n get layerRoutes(): Route[] {\n return Array.from(\n new Set(\n Object.values(this.columnSelection.columns)\n .map((c) => [\n Route.fromFlat(c.route).top,\n Route.fromFlat(c.route).deeper(1).top,\n ])\n .map((segments) => new Route(segments).flat),\n ),\n ).map((r) => Route.fromFlat(r));\n }\n\n // ...........................................................................\n /**\n * Returns the cake route of the join\n */\n get cakeRoute(): Route {\n const cakeRoute = Array.from(\n new Set(\n Object.values(this.columnSelection.columns).map(\n (c) => Route.fromFlat(c.route).top.tableKey,\n ),\n ),\n ).map((r) => Route.fromFlat(r));\n\n /* v8 ignore if -- @preserve */\n if (cakeRoute.length !== 1) {\n throw new Error(\n `Join: Error while getting cake route: ` +\n `The join has ${cakeRoute.length} different cake routes. ` +\n `Cannot determine a single cake route.`,\n );\n }\n return cakeRoute[0];\n }\n\n // ...........................................................................\n /**\n * Returns the number of rows in the join\n */\n get rowCount(): number {\n return Object.keys(this.data).length;\n }\n\n // ...........................................................................\n /**\n * Returns the number of columns in the join\n */\n get columnCount(): number {\n return this.columnSelection.count;\n }\n\n // ...........................................................................\n /**\n * Returns the row indices (sliceIds) of the join\n */\n get rowIndices(): SliceId[] {\n return Object.keys(this.data);\n }\n\n // ...........................................................................\n /**\n * Returns the join row for the given slice id\n *\n * @param sliceId - The slice id\n * @returns The join row\n */\n row(sliceId: SliceId): JoinRow {\n return this.data[sliceId].columns;\n }\n\n // ...........................................................................\n /**\n * Returns the data of the join\n */\n get data(): JoinRowsHashed {\n if (this._processes.length > 0) {\n return this._processes[this._processes.length - 1].data;\n }\n return this._base;\n }\n\n // ...........................................................................\n /**\n * Returns the column types of the join\n */\n get columnTypes(): JsonValueType[] {\n return this.columnSelection.columns.map((col) => col.type);\n }\n\n // ...........................................................................\n /**\n * Returns the column selection of the join\n */\n get columnSelection(): ColumnSelection {\n if (this._processes.length > 0) {\n return this._processes[this._processes.length - 1].columnSelection;\n }\n return this._baseColumnSelection;\n }\n\n // ...........................................................................\n /**\n * Returns all rows of the join w/ nulled missing values\n *\n * @return The rows of the join\n */\n get rows(): any[][] {\n const result: any[][] = [];\n const sliceIds = Object.keys(this.data);\n for (const sliceId of sliceIds) {\n const dataColumns = (this.data[sliceId] as JoinRowHashed).columns;\n const row: any[] = [];\n for (const colInfo of this.columnSelection.columns) {\n const joinCol = dataColumns.find((dataCol) => {\n const colInfoRoute = Route.fromFlat(colInfo.route);\n const dataColRoute = dataCol.route;\n\n return colInfoRoute.equalsWithoutRefs(dataColRoute);\n });\n /* v8 ignore next -- @preserve */\n const insertValue =\n joinCol && joinCol.inserts\n ? joinCol.inserts.flatMap((con) =>\n con.cell.flatMap((c) => c.value),\n ) ?? null\n : null;\n /* v8 ignore next -- @preserve */\n const baseValue =\n joinCol && joinCol.value.cell\n ? joinCol.value.cell.flatMap((c) => c.value) ?? null\n : null;\n\n row.push(insertValue ?? baseValue);\n }\n result.push(row);\n }\n return result;\n }\n\n static empty(): Join {\n return new Join({}, ColumnSelection.empty());\n }\n\n // ...........................................................................\n /**\n * Hashes the given join rows. If insert value is present, it is used for hashing.\n *\n * @param rows The join rows to hash\n * @returns The hashed join rows\n */\n private _hashedRows(rows: JoinRows) {\n const sliceIds = Object.keys(rows);\n const hashedRows: JoinRowsHashed = {};\n for (const sliceId of sliceIds) {\n const cols = rows[sliceId];\n /* v8 ignore next -- @preserve */\n const rowHash = Hash.default.calcHash(\n cols.map((col) =>\n col.inserts?.flatMap((con) => con.cell.flatMap((c) => c.value)) ??\n col.value.cell\n ? col.value.cell.flatMap((c) => c.value)\n : [],\n ) as any[],\n );\n hashedRows[sliceId] = {\n rowHash,\n columns: cols,\n };\n }\n return hashedRows;\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { InsertHistoryRow, Route } from '@rljson/rljson';\n\nexport type NotifyCallback<N extends string> = (\n InsertHistoryRow: InsertHistoryRow<N>,\n) => Promise<any>;\n\n// ...........................................................................\n/**\n * Notification system to manage callbacks for specific routes and notify them with edit protocol rows.\n */\nexport class Notify {\n private _callbacks: Map<string, NotifyCallback<any>[]> = new Map();\n\n // ...........................................................................\n constructor() {}\n\n // ...........................................................................\n /**\n * Registers a callback for a specific route.\n * @param route The route to register the callback for.\n * @param callback The callback function to be invoked when a notification is sent.\n */\n register(route: Route, callback: NotifyCallback<any>) {\n this._callbacks.set(route.flat, [\n ...(this._callbacks.get(route.flat) || []),\n callback,\n ]);\n }\n\n // ...........................................................................\n /**\n * Unregisters a callback for a specific route.\n * @param route The route to unregister the callback from.\n * @param callback The callback function to be removed.\n */\n unregister(route: Route, callback: NotifyCallback<any>) {\n const callbacks = this._callbacks.get(route.flat);\n /*v8 ignore else -- @preserve */\n if (callbacks) {\n this._callbacks.set(\n route.flat,\n callbacks.filter((cb) => cb !== callback),\n );\n }\n }\n\n // ...........................................................................\n /**\n * Unregisters all callbacks for a specific route.\n * @param route The route to unregister all callbacks from.\n */\n unregisterAll(route: Route) {\n this._callbacks.delete(route.flat);\n }\n\n // ...........................................................................\n /**\n * Notifies all registered callbacks for a specific route with the provided edit protocol row.\n * @param route The route to notify callbacks for.\n * @param insertHistoryRow The edit protocol row to pass to the callbacks.\n */\n notify<N extends string>(\n route: Route,\n insertHistoryRow: InsertHistoryRow<N>,\n ) {\n const callbacks = this._callbacks.get(route.flat);\n if (callbacks) {\n /*v8 ignore next -- @preserve */\n Promise.all(callbacks.map((cb) => cb(insertHistoryRow))).catch((err) => {\n console.error(\n `Error notifying callbacks for route ${route.flat}:`,\n err,\n );\n });\n }\n }\n\n // ...........................................................................\n /**\n * Returns the current map of registered callbacks.\n * @returns A map where keys are route strings and values are arrays of callback functions.\n */\n get callbacks() {\n return this._callbacks;\n }\n\n // ...........................................................................\n /**\n * Retrieves the list of callbacks registered for a specific route.\n * @param route The route to get callbacks for.\n * @returns An array of callback functions registered for the specified route.\n */\n getCallBacksForRoute(route: Route) {\n return this._callbacks.get(route.flat) || [];\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { JsonH } from '@rljson/json';\nimport { Rljson } from '@rljson/rljson';\n\nimport { traverse } from 'object-traversal';\n\nexport const makeUniqueArrayByHash = <T extends JsonH>(arr: T[]): T[] => {\n const seen = new Map<string, T>();\n const result: T[] = [];\n for (const item of arr) {\n if (!seen.has(item._hash)) {\n seen.set(item._hash, item);\n result.push(item);\n }\n }\n return result;\n};\n\nexport const makeUnique = (rljson: Rljson): Rljson => {\n traverse(rljson, ({ parent, key, value }) => {\n if (key == '_data' && Array.isArray(value)) {\n parent![key] = makeUniqueArrayByHash<JsonH>(value);\n }\n });\n return rljson;\n};\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { hsh, rmhsh } from '@rljson/hash';\nimport { Io } from '@rljson/io';\nimport { Json, JsonValue, merge } from '@rljson/json';\nimport {\n Cake,\n CakesTable,\n ComponentRef,\n ComponentsTable,\n ContentType,\n Edit,\n EditHistory,\n EditHistoryTable,\n EditsTable,\n getTimeIdTimestamp,\n InsertHistoryRow,\n InsertHistoryTimeId,\n isTimeId,\n Layer,\n LayersTable,\n MultiEdit,\n MultiEditsTable,\n Ref,\n Rljson,\n Route,\n RouteSegment,\n SliceId,\n SliceIds,\n TableType,\n Tree,\n treeFromObject,\n} from '@rljson/rljson';\n\nimport {\n Controller,\n ControllerChildProperty,\n ControllerRefs,\n ControllerRunFn,\n createController,\n} from './controller/controller.ts';\nimport { SliceIdController } from './controller/slice-id-controller.ts';\nimport { TreeController } from './controller/tree-controller.ts';\nimport { Core } from './core.ts';\nimport { Join, JoinColumn, JoinRow, JoinRows } from './join/join.ts';\nimport { ColumnSelection } from './join/selection/column-selection.ts';\nimport { Notify, NotifyCallback } from './notify.ts';\nimport { makeUnique } from './tools/make-unique.ts';\n\nexport type Cell = {\n route: Route;\n value: JsonValue | JsonValue[] | null;\n row: JsonValue | JsonValue[] | null;\n path: Array<Array<string | number>>;\n};\n\nexport type Container = {\n rljson: Rljson;\n tree: Json;\n cell: Cell[];\n};\n\nexport type GetOptions = {\n skipRljson?: boolean;\n skipTree?: boolean;\n skipCell?: boolean;\n};\n\nexport type ContainerWithControllers = Container & {\n controllers: Record<string, Controller<any, any, any>>;\n};\n\n/**\n * Access Rljson data\n */\nexport class Db {\n /**\n * Constructor\n * @param _io - The Io instance used to read and write data\n */\n constructor(private readonly _io: Io) {\n this.core = new Core(this._io);\n this.notify = new Notify();\n }\n\n /**\n * Core functionalities like importing data, setting and getting tables\n */\n readonly core: Core;\n\n /**\n * Notification system to register callbacks on data changes\n */\n readonly notify: Notify;\n\n private _cache: Map<string, Container> = new Map();\n\n // ...........................................................................\n /**\n * Get data from a route with optional filtering\n * @param route - The route to get data from\n * @param where - Optional filter to apply to the data\n * @param filter - Optional filter to apply to child entries in related tables\n * @param sliceIds - Optional slice IDs to filter the data\n * @returns An array of Rljson objects matching the route and filter\n * @throws {Error} If the route is not valid or if any controller cannot be created\n */\n async get(\n route: Route,\n where: string | Json,\n filter?: ControllerChildProperty[],\n sliceIds?: SliceId[],\n options?: GetOptions,\n ): Promise<ContainerWithControllers> {\n // Validate Route\n if (!route.isValid) throw new Error(`Route ${route.flat} is not valid.`);\n\n //Isolate Property Key\n const isolatedRoute = await this.isolatePropertyKeyFromRoute(route);\n\n // Get Controllers\n const controllers = await this.indexedControllers(isolatedRoute);\n\n // Fetch Data\n const data = await this._get(\n isolatedRoute,\n where,\n controllers,\n filter,\n sliceIds,\n undefined,\n options,\n );\n\n const dataWithControllers: ContainerWithControllers = {\n ...data,\n ...{ controllers },\n };\n return dataWithControllers;\n }\n\n // ...........................................................................\n /**\n * Resolves the route and returns corresponding data for any segment of the route,\n * matching recursive filters and where clauses\n *\n * @param route - The route to get data from\n * @param where - The recursive filtering key/value pairs to apply to the data\n * @param controllers - The controllers to use for fetching data\n * @param filter - Optional filter to apply to the data at the current route segment\n * @param sliceIds - Optional slice IDs to filter the data at the current route segment\n * @param routeAccumulator - The accumulated route up to the current segment\n * @param options - Additional options for fetching data\n * @returns - An Rljson object matching the route and filters\n */\n async _get(\n route: Route,\n where: string | Json,\n controllers: Record<string, Controller<any, any, any>>,\n filter?: ControllerChildProperty[],\n sliceIds?: SliceId[],\n routeAccumulator?: Route,\n options?: GetOptions,\n ): Promise<Container> {\n // Default options\n const opts = options ?? {};\n\n //Check if cacheable\n const routeHasRefs = route.flat != route.flatWithoutRefs;\n const hasFilter = filter !== undefined && filter.length > 0;\n const cacheable = !!routeHasRefs || !!hasFilter;\n let cacheHash = '';\n\n if (cacheable) {\n //Activate Cache\n const params = {\n route: route.flat,\n where,\n filter,\n sliceIds,\n routeAccumulator: routeAccumulator ? routeAccumulator.flat : '',\n options: opts,\n };\n cacheHash = (hsh(rmhsh(params)) as any)._hash as string;\n\n const isCached = this._cache.has(cacheHash);\n if (isCached) {\n return this._cache.get(cacheHash)!;\n }\n }\n\n const nodeTableKey = route.top.tableKey;\n const nodeRoute = route;\n const nodeRouteRef = await this._getReferenceOfRouteSegment(nodeRoute.top);\n const nodeController = controllers[nodeTableKey];\n\n const nodeSliceIds = nodeRoute.top.sliceIds ?? sliceIds;\n\n let nodeWhere = typeof where === 'object' ? { ...where } : where;\n\n // If not root, remove child prompts from where\n if (!route.isRoot && typeof nodeWhere === 'object') {\n delete nodeWhere[nodeRoute.deeper().top.tableKey];\n }\n\n // Add ref to where\n /* v8 ignore next -- @preserve */\n nodeWhere = nodeWhere\n ? typeof nodeWhere === 'string'\n ? { _hash: nodeWhere }\n : nodeWhere\n : {};\n\n // Add route ref to where\n if (nodeRouteRef && nodeRouteRef.length > 0)\n nodeWhere = { _hash: nodeRouteRef };\n\n // Delete internal flags\n delete (nodeWhere as Json)['_through'];\n delete (nodeWhere as Json)['_tableKey'];\n\n // Fetch Node Data (actual access to underlying data model)\n const {\n [nodeTableKey]: { _data: nodeRows, _type: nodeType, _hash: nodeHash },\n } = await nodeController.get(nodeWhere, undefined, route.propertyKey);\n const nodeColumnCfgs = nodeController.tableCfg().columns;\n\n const filterActive = filter && filter.length > 0;\n const sliceIdActive = nodeSliceIds && nodeSliceIds.length > 0;\n\n // Pre-build filter map for O(1) lookups instead of O(n) searches\n const filterMap = filterActive\n ? new Map<string, ControllerChildProperty[]>()\n : null;\n\n if (filterActive) {\n for (const f of filter) {\n if (f.tableKey === nodeTableKey) {\n if (!filterMap!.has(f.ref)) {\n filterMap!.set(f.ref, []);\n }\n filterMap!.get(f.ref)!.push(f);\n }\n }\n }\n\n // Batch resolve all sliceIds at once instead of awaiting sequentially\n const sliceIdResolvePromises = new Map<string, Promise<SliceId[]>>();\n const nodeSliceIdSet = sliceIdActive ? new Set(nodeSliceIds) : null;\n\n if (sliceIdActive) {\n for (const nodeRow of nodeRows) {\n if (nodeType === 'cakes') {\n const cake = nodeRow as Cake;\n const key = `${cake.sliceIdsTable}:${cake.sliceIdsRow}`;\n /* v8 ignore next -- @preserve */\n if (!sliceIdResolvePromises.has(key)) {\n sliceIdResolvePromises.set(\n key,\n this._resolveSliceIds(cake.sliceIdsTable, cake.sliceIdsRow),\n );\n }\n } else if (nodeType === 'layers') {\n const layer = nodeRow as Layer;\n const key = `${layer.sliceIdsTable}:${layer.sliceIdsTableRow}`;\n /* v8 ignore next -- @preserve */\n if (!sliceIdResolvePromises.has(key)) {\n sliceIdResolvePromises.set(\n key,\n this._resolveSliceIds(\n layer.sliceIdsTable,\n layer.sliceIdsTableRow,\n ),\n );\n }\n }\n }\n }\n\n // Wait for all sliceId resolutions in parallel\n const resolvedSliceIds = new Map<string, Set<SliceId>>();\n if (sliceIdResolvePromises.size > 0) {\n const entries = Array.from(sliceIdResolvePromises.entries());\n const results = await Promise.all(entries.map(([, p]) => p));\n entries.forEach(([key], idx) => {\n resolvedSliceIds.set(key, new Set(results[idx]));\n });\n }\n\n const nodeRowsFiltered: Json[] = [];\n for (const nodeRow of nodeRows) {\n if (!filterActive && !sliceIdActive) {\n nodeRowsFiltered.push(nodeRow);\n continue;\n }\n\n // Apply Filters\n let filterResult = false;\n const filterProperties: ControllerChildProperty[] = [];\n if (filterActive) {\n const rowFilters = filterMap!.get(nodeRow._hash);\n if (rowFilters) {\n filterProperties.push(...rowFilters);\n filterResult = true;\n }\n } else {\n filterResult = true;\n }\n\n // Apply SliceIds\n let sliceIdResult = false;\n if (sliceIdActive) {\n switch (nodeType) {\n case 'cakes':\n const cake = nodeRow as Cake;\n const cakeKey = `${cake.sliceIdsTable}:${cake.sliceIdsRow}`;\n const cakeSliceIdSet = resolvedSliceIds.get(cakeKey)!;\n // Use Set intersection for O(n) instead of filter+includes O(n*m)\n for (const sId of nodeSliceIdSet!) {\n if (cakeSliceIdSet.has(sId)) {\n sliceIdResult = true;\n break;\n }\n }\n break;\n\n case 'layers':\n const layer = nodeRow as Layer;\n const layerKey = `${layer.sliceIdsTable}:${layer.sliceIdsTableRow}`;\n const layerSliceIdSet = resolvedSliceIds.get(layerKey)!;\n for (const sId of nodeSliceIdSet!) {\n if (layerSliceIdSet.has(sId)) {\n sliceIdResult = true;\n break;\n }\n }\n break;\n case 'components':\n if (filterProperties.length > 0) {\n // Use Set for faster lookups\n const componentSliceIdSet = new Set(\n filterProperties.flatMap((f) => f.sliceIds),\n );\n for (const sId of nodeSliceIdSet!) {\n if (componentSliceIdSet.has(sId)) {\n sliceIdResult = true;\n break;\n }\n }\n }\n break;\n /* v8 ignore next -- @preserve */\n default:\n sliceIdResult = true;\n break;\n }\n } else {\n sliceIdResult = true;\n }\n\n if (filterResult && sliceIdResult) nodeRowsFiltered.push(nodeRow);\n }\n\n // Construct Node w/ only filtered rows\n const node = {\n [nodeTableKey]: {\n _data: nodeRowsFiltered,\n _type: nodeType,\n _hash: nodeHash,\n },\n } as Rljson;\n\n // Return if is root node (deepest level, base case)\n if (route.isRoot) {\n // Pre-compute common route string to avoid repeated concatenation\n const baseRouteStr =\n (routeAccumulator ? routeAccumulator.flat : nodeTableKey) +\n (nodeHash ? `@${nodeHash}` : '');\n\n if (route.hasPropertyKey) {\n /* v8 ignore next -- @preserve */\n const isolatedNode = opts.skipRljson\n ? ({} as Rljson)\n : this.isolatePropertyFromComponents(node, route.propertyKey!);\n\n /* v8 ignore next -- @preserve */\n const routeWithProperty = opts.skipCell\n ? null\n : Route.fromFlat(\n baseRouteStr + `/${route.propertyKey}`,\n ).toRouteWithProperty();\n\n let result: Container;\n\n if (nodeType === 'trees') {\n const rljson = node;\n /* v8 ignore next -- @preserve */\n const tree = opts.skipTree\n ? ({} as Json)\n : {\n [nodeTableKey]: {\n _data: [\n await (\n nodeController as TreeController<string, Tree>\n ).buildTreeFromTrees(nodeRows as Tree[]),\n ],\n _type: 'trees',\n },\n };\n /* v8 ignore next -- @preserve */\n const cell = opts.skipCell\n ? ([] as Cell[])\n : await (\n nodeController as TreeController<string, Tree>\n ).buildCellsFromTree(nodeRows as Tree[]);\n\n result = {\n rljson,\n tree,\n cell,\n };\n } else {\n /* v8 ignore next -- @preserve */\n const tree = opts.skipTree\n ? ({} as Json)\n : { [nodeTableKey]: node[nodeTableKey] };\n\n /* v8 ignore next -- @preserve */\n const cell = opts.skipCell\n ? ([] as Cell[])\n : (nodeRowsFiltered.map(\n (v, idx) =>\n ({\n value: v[route.propertyKey!] ?? null,\n row: v,\n route: routeWithProperty,\n path: [[nodeTableKey, '_data', idx, route.propertyKey]],\n } as Cell),\n ) as Cell[]);\n\n result = {\n rljson: isolatedNode,\n tree,\n cell,\n };\n }\n\n //Set Cache\n this._cache.set(cacheHash, result);\n\n return result;\n }\n\n const routeObj = opts.skipCell ? null : Route.fromFlat(baseRouteStr);\n\n /* v8 ignore next -- @preserve */\n const rljson = opts.skipRljson ? ({} as Rljson) : node;\n /* v8 ignore next -- @preserve */\n const tree = opts.skipTree\n ? ({} as Json)\n : { [nodeTableKey]: node[nodeTableKey] };\n /* v8 ignore next -- @preserve */\n const cell = opts.skipCell\n ? ([] as Cell[])\n : (nodeRowsFiltered.map(\n (v, idx) =>\n ({\n value: v[route.propertyKey!] ?? null,\n row: v,\n route: routeObj,\n path: [[nodeTableKey, '_data', idx]],\n } as Cell),\n ) as Cell[]);\n\n const result = {\n rljson,\n tree,\n cell,\n };\n\n if (cacheable) {\n //Set Cache\n this._cache.set(cacheHash, result);\n }\n\n return result;\n }\n\n // Fetch Children Data\n const childrenRoute = route.deeper();\n const childrenTableKey = childrenRoute.top.tableKey;\n /* v8 ignore next -- @preserve */\n const childrenWhere = (\n typeof where === 'object' ? where[childrenTableKey] ?? {} : {}\n ) as Json | string;\n\n const childrenThroughProperty = (childrenWhere as any)?._through;\n\n const nodeChildrenArray = [];\n\n const nodeRowsMatchingChildrenRefs = new Map<\n string,\n {\n rljson: Json;\n tree: Json;\n cell: Cell[];\n }\n >();\n\n // Pre-build column reference map outside the loop\n const columnReferenceMap =\n nodeType === 'components'\n ? nodeColumnCfgs\n .filter((c) => c.ref?.tableKey === childrenTableKey)\n .filter(\n (c) => c.ref && ['components', 'cakes'].includes(c.ref.type),\n )\n .reduce((acc, curr) => {\n acc.set(curr.key, curr.ref!.tableKey);\n return acc;\n }, new Map<string, string>())\n : null;\n\n // Batch fetch all childRefs in parallel for better performance\n const childRefsPromises = nodeRowsFiltered.map((nodeRow) =>\n nodeController.getChildRefs((nodeRow as any)._hash),\n );\n const allChildRefs = await Promise.all(childRefsPromises);\n\n // Iterate over Node Rows to get Children\n for (let i = 0; i < nodeRowsFiltered.length; i++) {\n const nodeRow = nodeRowsFiltered[i];\n const nodeRowHash = (nodeRow as any)._hash;\n\n // Child References of this Node Row = Filter for Children\n const childrenRefs = allChildRefs[i];\n\n // If cake is referenced, we have to collect all sliceIds from\n // childrenRefs and switch to them\n const childrenRefTypes = new Map<string, string>();\n const childrenRefSliceIds = new Set<SliceId>();\n\n for (const cr of childrenRefs) {\n if (!!cr.columnKey) {\n const childrenRefColumnCfg = nodeColumnCfgs.find(\n (c) => c.key === cr.columnKey,\n );\n\n /* v8 ignore else -- @preserve */\n if (childrenRefColumnCfg) {\n /* v8 ignore next -- @preserve */\n childrenRefTypes.set(\n childrenRefColumnCfg.key,\n childrenRefColumnCfg.ref?.type ?? '',\n );\n }\n\n if (cr.sliceIds && cr.sliceIds.length > 0) {\n //Cake is referenced, switch sliceIds\n for (const sId of cr.sliceIds) {\n childrenRefSliceIds.add(sId);\n }\n }\n }\n }\n\n const childrenRefTypesSet = new Set<string>([\n ...childrenRefTypes.values(),\n ]);\n\n /* v8 ignore next -- @preserve */\n if (childrenRefTypesSet.size > 1) {\n throw new Error(\n `Db._get: Multiple reference types found for children of node table \"${nodeTableKey}\" and row \"${nodeRowHash}\". Found types: ${[\n ...childrenRefTypesSet,\n ].join(', ')}.`,\n );\n }\n\n const childrenRefType =\n childrenRefTypesSet.size > 0 ? [...childrenRefTypesSet][0] : null;\n\n const cakeIsReferenced =\n childrenRefTypes.size > 0 && childrenRefType === 'cakes';\n\n const componentIsReferenced =\n childrenRefTypes.size > 0 &&\n nodeType === 'components' &&\n childrenRefType === 'components';\n\n const childrenSliceIds = cakeIsReferenced\n ? [...childrenRefSliceIds]\n : componentIsReferenced\n ? undefined\n : nodeSliceIds;\n\n const {\n rljson: rowChildrenRljson,\n tree: rowChildrenTree,\n cell: rowChildrenCell,\n } = await this._get(\n childrenRoute,\n childrenWhere,\n controllers,\n childrenRefs,\n childrenSliceIds,\n Route.fromFlat(\n (routeAccumulator ? routeAccumulator.flat : nodeTableKey) +\n (nodeHash ? `@${nodeHash}` : '') +\n '/' +\n childrenTableKey,\n ),\n opts,\n );\n\n // No Children found for where + route => skip\n if (\n !rowChildrenRljson[childrenTableKey] ||\n rowChildrenRljson[childrenTableKey]._data.length === 0\n )\n continue;\n\n nodeChildrenArray.push(rowChildrenRljson);\n\n // Skip expensive tree/cell processing if not needed\n /* v8 ignore next -- @preserve */\n if (opts.skipTree && opts.skipCell) {\n nodeRowsMatchingChildrenRefs.set(nodeRowHash, {\n rljson: nodeRow,\n tree: {},\n cell: [],\n });\n continue;\n }\n\n // Create nodeRowObj only when needed for tree/cell\n const nodeRowObj = { ...nodeRow } as Json;\n\n if (cakeIsReferenced) {\n const refKey = [...childrenRefTypes.keys()][0] as string;\n nodeRowObj[refKey] = rowChildrenTree;\n }\n\n // Add Children as ThroughProperty value to Object representation\n if (childrenThroughProperty) {\n const resolvedChildrenHashesSet = new Set(\n rowChildrenRljson[childrenTableKey]._data.map(\n (rc) => rc._hash as string,\n ),\n );\n\n for (const nr of nodeRowsFiltered) {\n const throughHashesInRowCouldBeArray = (nr as any)[\n childrenThroughProperty\n ];\n const throughHashesInRow = Array.isArray(\n throughHashesInRowCouldBeArray,\n )\n ? throughHashesInRowCouldBeArray\n : [throughHashesInRowCouldBeArray];\n\n for (const th of throughHashesInRow) {\n if (resolvedChildrenHashesSet.has(th)) {\n //Add Child as ThroughProperty value\n nodeRowObj[childrenThroughProperty] = {\n ...(rowChildrenTree as any)[childrenTableKey],\n _tableKey: childrenTableKey,\n };\n break; // Exit early once matched\n }\n }\n }\n }\n\n const resolvedChildren = rowChildrenRljson[childrenTableKey]\n ._data as Json[];\n\n const childrenRefsOfRow = childrenRefs.filter(\n (cr) => cr.tableKey == childrenTableKey,\n );\n\n // Build hash set for faster lookups\n const resolvedChildrenHashSet = new Set(\n resolvedChildren.map((ch) => ch._hash),\n );\n\n const matchingChildrenRefs = childrenRefsOfRow.filter((cr) =>\n resolvedChildrenHashSet.has(cr.ref),\n );\n\n // Build ref map for O(1) lookups\n const matchingRefsMap = new Map(\n matchingChildrenRefs.map((cr) => [cr.ref, cr]),\n );\n\n // If Layer, construct layer objects with sliceIds relations\n /* v8 ignore else -- @preserve */\n if (nodeType === 'layers') {\n const compChildrenTrees = (\n (rowChildrenTree as any)[childrenTableKey]! as ComponentsTable<Json>\n )._data;\n const compChildrenPaths = rowChildrenCell.map((c) => c.path);\n\n const components = compChildrenTrees.map((c, idx) => {\n return {\n tree: c,\n path: compChildrenPaths.filter((p) => p[0][2] == idx),\n };\n });\n\n const layerTreesAndPaths = components.map(({ tree: comp, path }) => {\n const matchedRef = matchingRefsMap.get(comp._hash as string);\n const sliceIds = matchedRef?.sliceIds;\n\n /* v8 ignore next -- @preserve */\n if (!sliceIds || sliceIds.length === 0) {\n throw new Error(\n `Db._get: No sliceIds found for component ${\n comp._hash\n } of layer ${(nodeRow as any)._hash}.`,\n );\n }\n /* v8 ignore next -- @preserve */\n if (sliceIds.length > 1) {\n throw new Error(\n `Db._get: Multiple sliceIds found for component ${\n comp._hash\n } of layer ${(nodeRow as any)._hash}.`,\n );\n }\n\n const sliceId = sliceIds[0];\n\n const pathsForSliceId = path.map((p) => {\n const newPath = [...p[0]];\n newPath[2] = 0;\n return ['add', sliceId, ...newPath];\n });\n\n return {\n [sliceId]: {\n tree: {\n [childrenTableKey]: {\n _data: [comp],\n _type: 'components',\n },\n },\n path: pathsForSliceId,\n },\n };\n });\n\n const layer: Record<string, any> = {};\n const paths: any[] = [];\n\n for (const ltap of layerTreesAndPaths) {\n for (const [sliceId, value] of Object.entries(ltap)) {\n layer[sliceId] = value.tree;\n /* v8 ignore next -- @preserve */\n if (!opts.skipCell) {\n paths.push(value.path);\n }\n }\n }\n\n const rljson = nodeRow;\n\n /* v8 ignore next -- @preserve */\n const tree = opts.skipTree\n ? {}\n : {\n ...nodeRowObj,\n add: { ...(nodeRowObj.add as Json), ...layer },\n };\n\n /* v8 ignore next -- @preserve */\n const cell = opts.skipCell\n ? []\n : rowChildrenCell.map(\n (c, idx) =>\n ({\n ...c,\n path: [paths.flat()[idx]],\n } as Cell),\n );\n\n nodeRowsMatchingChildrenRefs.set(nodeRowHash, {\n rljson,\n tree,\n cell,\n });\n } else if (nodeType === 'cakes') {\n nodeRowsMatchingChildrenRefs.set(nodeRowHash, {\n rljson: nodeRow,\n tree: opts.skipTree\n ? {}\n : {\n ...nodeRowObj,\n layers: { ...(nodeRowObj.layers as Json), ...rowChildrenTree },\n },\n cell: opts.skipCell\n ? []\n : rowChildrenCell.map((c) => ({\n ...c,\n path: c.path.map((p) => ['layers', ...p]),\n })),\n });\n } else if (nodeType === 'components') {\n /* v8 ignore else -- @preserve */\n if (rowChildrenTree && Object.keys(rowChildrenTree).length > 0) {\n const resolvedProperties: Record<string, Json> = {};\n const allCells: Cell[] = [];\n\n for (const [colKey, childTableKey] of columnReferenceMap!) {\n if (!opts.skipTree) {\n resolvedProperties[colKey] = {\n ...(rowChildrenTree[childTableKey] as Json),\n _tableKey: childTableKey,\n };\n }\n\n if (!opts.skipCell) {\n const cell = rowChildrenCell.map((c) => ({\n ...c,\n path: c.path\n .filter((p) => p[0] === childTableKey)\n .map((p) => [colKey, ...p.slice(1)]),\n }));\n allCells.push(...cell);\n }\n }\n\n nodeRowsMatchingChildrenRefs.set(nodeRowHash, {\n rljson: nodeRow,\n tree: opts.skipTree\n ? {}\n : {\n ...nodeRowObj,\n ...resolvedProperties,\n },\n cell: allCells,\n });\n } else {\n nodeRowsMatchingChildrenRefs.set(nodeRowHash, {\n rljson: nodeRow,\n tree: { ...nodeRowObj },\n cell: rowChildrenCell,\n });\n }\n } else {\n throw new Error(\n `Db._get: Unsupported node type ${nodeType} for getting children.`,\n );\n }\n }\n\n // Merge Children Data - skip if not needed\n /* v8 ignore next -- @preserve */\n const nodeChildren = opts.skipRljson\n ? ({} as Rljson)\n : makeUnique(merge(...(nodeChildrenArray as Rljson[])) as Rljson);\n\n // Return Node with matched Children\n const matchedNodeRows = Array.from(nodeRowsMatchingChildrenRefs.values());\n\n /* v8 ignore next -- @preserve */\n const rljson = opts.skipRljson\n ? ({} as Rljson)\n : ({\n ...node,\n [nodeTableKey]: {\n _data: matchedNodeRows.map((mr) => mr.rljson),\n _type: nodeType,\n ...(nodeHash ? { _hash: nodeHash } : {}),\n },\n ...nodeChildren,\n } as Rljson);\n /* v8 ignore next -- @preserve */\n const tree = opts.skipTree\n ? ({} as Json)\n : {\n [nodeTableKey]: {\n _data: matchedNodeRows.map((mr) => mr.tree),\n _type: nodeType,\n ...(nodeHash ? { _hash: nodeHash } : {}),\n },\n };\n /* v8 ignore next -- @preserve */\n const cell = opts.skipCell\n ? []\n : (() => {\n // Pre-calculate total size and build array directly\n let totalSize = 0;\n for (const mr of matchedNodeRows) {\n totalSize += mr.cell.length;\n }\n const cells: Cell[] = new Array(totalSize);\n let cellIdx = 0;\n for (let rowIdx = 0; rowIdx < matchedNodeRows.length; rowIdx++) {\n const mr = matchedNodeRows[rowIdx];\n for (const c of mr.cell) {\n cells[cellIdx++] = {\n ...c,\n path: c.path.map((p) => [nodeTableKey, '_data', rowIdx, ...p]),\n };\n }\n }\n return cells;\n })();\n\n const result = {\n rljson,\n tree,\n cell,\n };\n //Set Cache\n this._cache.set(cacheHash, result);\n\n return result;\n }\n\n // ...........................................................................\n /**\n * Get the reference (hash) of a route segment, considering default refs and insertHistory refs\n * @param segment - The route segment to get the reference for\n * @returns\n */\n private async _getReferenceOfRouteSegment(\n segment: RouteSegment<any>,\n ): Promise<string | null> {\n if (Route.segmentHasRef(segment)) {\n if (Route.segmentHasDefaultRef(segment)) {\n // Use given ref\n return Route.segmentRef(segment)!;\n } else {\n // Get ref from insertHistory\n return (await this.getRefOfTimeId(\n segment.tableKey,\n Route.segmentRef(segment)!,\n ))!;\n }\n }\n return null;\n }\n\n // ...........................................................................\n /**\n * Joins data from layers in an Rljson into a single dataset\n * @param rljson - The Rljson to join data for\n */\n async join(\n columnSelection: ColumnSelection,\n cakeKey: string,\n cakeRef: Ref,\n ): Promise<Join> {\n const {\n tree: { [cakeKey]: cakesTable },\n } = await this.get(\n Route.fromFlat(`${cakeKey}@${cakeRef}`),\n {},\n undefined,\n undefined,\n { skipCell: true, skipRljson: true },\n );\n\n const cakes = (cakesTable as CakesTable)._data;\n\n /* v8 ignore next -- @preserve */\n if (cakes.length === 0) {\n throw new Error(\n `Db.join: Cake with ref \"${cakeRef}\" not found in cake table \"${cakeKey}\".`,\n );\n }\n /* v8 ignore next -- @preserve */\n if (cakes.length > 1) {\n throw new Error(\n `Db.join: Multiple cakes with ref \"${cakeRef}\" found in cake table \"${cakeKey}\".`,\n );\n }\n const cake = cakes[0] as Cake;\n\n const sliceIds = await this._resolveSliceIds(\n (cake as Cake).sliceIdsTable,\n (cake as Cake).sliceIdsRow,\n );\n const rows: JoinRows = {};\n for (const sliceId of sliceIds) {\n const row: JoinRow = [];\n\n for (const columnInfo of columnSelection.columns) {\n const columnRoute = Route.fromFlat(\n columnInfo.route,\n ).toRouteWithProperty();\n\n const columnContainer = await this.get(\n columnRoute,\n cakeRef,\n undefined,\n [sliceId],\n );\n\n const column: JoinColumn = {\n route: columnRoute,\n value: columnContainer,\n inserts: null,\n };\n row.push(column);\n }\n\n rows[sliceId] = row;\n }\n\n // Return Join\n return new Join(rows, columnSelection);\n }\n\n // ...........................................................................\n private async _resolveSliceIds(\n sliceIdTable: string,\n sliceIdRow: string,\n ): Promise<SliceId[]> {\n const sliceIdController: SliceIdController<any, any> =\n new SliceIdController(this.core, sliceIdTable);\n sliceIdController.init();\n\n const resolvedSliceIds: Set<SliceId> = new Set();\n\n const {\n [sliceIdTable]: { _data: sliceIds },\n } = await sliceIdController.get(sliceIdRow);\n\n for (const sliceId of sliceIds) {\n const baseSliceIds = await sliceIdController.resolveBaseSliceIds(\n sliceId as SliceIds,\n );\n for (const sId of baseSliceIds.add) {\n resolvedSliceIds.add(sId);\n }\n }\n\n return Array.from(resolvedSliceIds);\n }\n\n // ...........................................................................\n /**\n * Runs an Insert by executing the appropriate controller(s) based on the Insert's route\n * @param Insert - The Insert to run\n * @returns The result of the Insert as an InsertHistoryRow\n * @throws {Error} If the Insert is not valid or if any controller cannot be created\n */\n async insert(\n route: Route,\n tree: Json,\n options?: { skipNotification?: boolean; skipHistory?: boolean },\n ): Promise<InsertHistoryRow<any>[]> {\n const controllers = await this.indexedControllers(\n Route.fromFlat(route.flatWithoutRefs),\n );\n const runFns: Record<string, ControllerRunFn<any, any>> = {};\n for (const [tableKey, controller] of Object.entries(controllers)) {\n runFns[tableKey] = controller.insert.bind(controller);\n }\n const insertHistoryRow = await this._insert(route, tree, runFns, options);\n\n //Write insertHistory\n if (!options?.skipHistory)\n await this._writeInsertHistory(route.top.tableKey, insertHistoryRow[0]);\n\n return insertHistoryRow;\n }\n\n // ...........................................................................\n /**\n * Recursively runs controllers based on the route of the Insert\n * @param insert - The Insert to run\n * @param route - The route of the Insert\n * @param runFns - A record of controller run functions, keyed by table name\n * @returns The result of the Insert\n * @throws {Error} If the route is not valid or if any controller cannot be created\n */\n private async _insert(\n route: Route,\n tree: Json,\n runFns: Record<string, ControllerRunFn<any, any>>,\n options?: { skipNotification?: boolean; skipHistory?: boolean },\n ): Promise<InsertHistoryRow<any>[]> {\n const results: InsertHistoryRow<any>[] = [];\n\n //Run parent controller with child refs as value\n const nodeRoute = route;\n const nodeSegment = nodeRoute.segment(0);\n const nodeTableKey = nodeSegment.tableKey;\n const nodeTree = (tree[nodeTableKey] as TableType)!;\n const nodeType = nodeTree._type as ContentType;\n\n /* v8 ignore next -- @preserve */\n if (nodeTree._data.length === 0) {\n throw new Error(\n `Db._insert: No data found for table \"${nodeTableKey}\" in route \"${route.flat}\".`,\n );\n }\n\n const previousHash = (nodeSegment as any)[nodeTableKey + 'Ref'] ?? null;\n const previousTimeId: string | null =\n (nodeSegment as any)[nodeTableKey + 'InsertHistoryRef'] ?? null;\n\n const previous: InsertHistoryTimeId[] = previousHash\n ? await this.getTimeIdsForRef(nodeTableKey, previousHash as string)\n : previousTimeId\n ? [previousTimeId]\n : [];\n\n //If not root, run nested controllers first\n if (!nodeRoute.isRoot && nodeType != 'trees') {\n //Run nested controller first\n const childRoute = nodeRoute.deeper(1);\n const childTableKey = childRoute.top.tableKey;\n\n if (nodeType === 'cakes') {\n const cakes = (nodeTree as CakesTable)._data;\n\n /* v8 ignore next -- @preserve */\n if (cakes.length > 1) {\n // throw new Error(\n // `Db._insert: Multiple cakes found for cake table \"${nodeTableKey}\" when inserting into child table \"${childTableKey}\". Only single cake inserts are supported.`,\n // );\n }\n\n //Check if there is no cake or no childTree --> Add new one\n const cake = cakes[0] as Cake;\n const childTree = (cake.layers as Json)[childTableKey] as TableType;\n const childResults = await this._insert(\n childRoute,\n { [childTableKey]: childTree },\n runFns,\n );\n\n /* v8 ignore next -- @preserve */\n if (childResults.length > 1) {\n throw new Error(\n `Db._insert: Multiple inserts returned for child table \"${childTableKey}\" when inserting into cake table \"${nodeTableKey}\". Only single child inserts are supported.`,\n );\n }\n\n const childResult = childResults[0];\n\n const insertValue = {\n ...(cake as any as Json),\n ...{\n layers: {\n ...cake.layers,\n ...{\n [childTableKey]: (childResult as any)[childTableKey + 'Ref'],\n },\n },\n },\n };\n const runFn = runFns[nodeTableKey];\n const result = await runFn('add', rmhsh(insertValue), 'db.insert');\n results.push(\n ...result.map((r) => ({\n ...r,\n ...{ previous },\n ...{ route: route.flat },\n })),\n );\n }\n if (nodeType === 'layers') {\n const layers = (nodeTree as LayersTable)._data;\n for (const layer of layers) {\n const layerInsert: Record<SliceId, ComponentRef> = {};\n\n //Check what if there is no layer or no compomentTree --> Add new one\n\n for (const [sliceId, componentTree] of Object.entries(layer.add)) {\n if (sliceId === '_hash') continue;\n\n const writtenComponents = await this._insert(\n childRoute,\n componentTree as any,\n runFns,\n );\n\n /* v8 ignore next -- @preserve */\n if (writtenComponents.length > 1) {\n throw new Error(\n `Db._insert: Multiple components written for layer \"${\n (layer as any)._hash\n }\" and sliceId \"${sliceId}\" is currently not supported.`,\n );\n }\n\n const writtenComponent = writtenComponents[0];\n\n /* v8 ignore next -- @preserve */\n if (\n !writtenComponent ||\n !(writtenComponent as any)[childTableKey + 'Ref']\n ) {\n throw new Error(\n `Db._insert: No component reference returned for layer \"${\n (layer as any)._hash\n }\" and sliceId \"${sliceId}\".`,\n );\n }\n\n layerInsert[sliceId] = (writtenComponent as any)[\n childTableKey + 'Ref'\n ];\n }\n const runFn = runFns[nodeTableKey];\n const result = await runFn(\n 'add',\n rmhsh({\n ...layer,\n ...{ add: layerInsert },\n }),\n 'db.insert',\n );\n results.push(\n ...result.map((r) => ({\n ...r,\n ...{ previous },\n ...{ route: route.flat },\n })),\n );\n }\n }\n if (\n (\n [\n 'components',\n 'edits',\n 'multiEdits',\n 'editHistory',\n 'head',\n ] as ContentType[]\n ).includes(nodeType)\n ) {\n const runFn = runFns[nodeTableKey];\n const components = (nodeTree as ComponentsTable<Json>)._data;\n for (const component of components) {\n const resolvedComponent = { ...component } as Json;\n for (const [property, value] of Object.entries(component)) {\n if (\n (value as any).hasOwnProperty('_tableKey') &&\n (value as any)._tableKey === childTableKey\n ) {\n const writtenReferences = await this._insert(\n childRoute,\n { [childTableKey]: value as any },\n runFns,\n );\n resolvedComponent[property] = writtenReferences.map(\n (wr) => (wr as any)[childTableKey + 'Ref'],\n );\n }\n }\n\n const result = await runFn(\n 'add',\n rmhsh(resolvedComponent),\n 'db.insert',\n );\n results.push(\n ...result.map((r) => ({\n ...r,\n ...{ previous },\n ...{ route: route.flat },\n })),\n );\n }\n }\n } else {\n //Run root controller\n const runFn = runFns[nodeTableKey];\n\n if (\n (\n [\n 'components',\n 'edits',\n 'multiEdits',\n 'editHistory',\n 'head',\n ] as ContentType[]\n ).includes(nodeType)\n ) {\n const components = rmhsh(\n (tree as any)[nodeTableKey],\n ) as ComponentsTable<Json>;\n\n for (const component of components._data) {\n /* v8 ignore next -- @preserve */\n if (!component) continue;\n\n delete (component as any)._tableKey;\n delete (component as any)._type;\n\n const result = await runFn('add', component, 'db.insert');\n results.push(\n ...result.map((r) => ({\n ...r,\n ...{ previous },\n ...{ route: route.flat },\n })),\n );\n }\n }\n if (nodeType === 'layers') {\n const layers = rmhsh((tree as any)[nodeTableKey]);\n for (const layer of (layers as LayersTable)._data) {\n const result = await runFn('add', layer, 'db.insert');\n\n results.push(\n ...result.map((r) => ({\n ...r,\n ...{ previous },\n ...{ route: route.flat },\n })),\n );\n }\n }\n if (nodeType === 'cakes') {\n const cakes = rmhsh((tree as any)[nodeTableKey]);\n for (const cake of (cakes as CakesTable)._data) {\n const result = await runFn('add', cake, 'db.insert');\n\n results.push(\n ...result.map((r) => ({\n ...r,\n ...{ previous },\n ...{ route: route.flat },\n })),\n );\n }\n }\n if (nodeType === 'trees') {\n const treeObject = (tree[nodeTableKey] as any)._data[0];\n /* v8 ignore next -- @preserve */\n if (!treeObject) {\n throw new Error(\n `Db._insert: No tree data found for table \"${nodeTableKey}\" in route \"${route.flat}\".`,\n );\n }\n const trees = treeFromObject(treeObject);\n\n const writePromises = trees.map((tree) =>\n runFn('add', tree, 'db.insert'),\n );\n const writeResults = await Promise.all(writePromises);\n\n // Only add the root item (last tree) to results if anything was written\n const lastResult = writeResults[writeResults.length - 1];\n /* v8 ignore else -- @preserve */\n if (lastResult && lastResult.length > 0) {\n results.push(\n ...lastResult.map((r) => ({\n ...r,\n ...{ previous },\n ...{ route: route.flat },\n })),\n );\n }\n }\n }\n\n for (const result of results) {\n //Notify listeners\n if (!options?.skipNotification)\n this.notify.notify(Route.fromFlat(result.route), result);\n }\n\n return results;\n }\n\n // ...........................................................................\n /**\n * Registers a callback to be called when an Insert is made on the given route\n * @param route - The route to register the callback on\n * @param callback - The callback to be called when an Insert is made\n */\n registerObserver(route: Route, callback: NotifyCallback<any>) {\n this.notify.register(route, callback);\n }\n\n // ...........................................................................\n /**\n * Unregisters a callback from the given route\n * @param route - The route to unregister the callback from\n * @param callback - The callback to be unregistered\n */\n unregisterObserver(route: Route, callback: NotifyCallback<any>) {\n this.notify.unregister(route, callback);\n }\n\n // ...........................................................................\n /**\n * Unregisters all observers from all routes\n */\n unregisterAllObservers(route: Route) {\n this.notify.unregisterAll(route);\n }\n\n // ...........................................................................\n /**\n * Get a controller for a specific table\n * @param tableKey - The key of the table to get the controller for\n * @param refs - Optional references required by some controllers\n * @returns A controller for the specified table\n * @throws {Error} If the table does not exist or if the table type is not supported\n */\n async getController(tableKey: string, refs?: ControllerRefs) {\n // Validate Table\n const hasTable = await this.core.hasTable(tableKey);\n if (!hasTable) {\n throw new Error(`Db.getController: Table ${tableKey} does not exist.`);\n }\n\n // Get Content Type of Table\n const contentType = await this.core.contentType(tableKey);\n\n // Create Controller\n return createController(contentType, this.core, tableKey, refs);\n }\n\n // ...........................................................................\n public async indexedControllers(\n route: Route,\n ): Promise<Record<string, Controller<any, any, any>>> {\n // Create Controllers\n const controllers: Record<string, Controller<any, any, any>> = {};\n const isolatedRoute = await this.isolatePropertyKeyFromRoute(route);\n\n for (let i = 0; i < isolatedRoute.segments.length; i++) {\n const segment = isolatedRoute.segments[i];\n const tableKey = segment.tableKey;\n //Base is helpful for cake and layer controllers. It contains the ref of\n // the base cake for taking over default layers definitions\n const segmentRef = Route.segmentRef(segment);\n const base = segmentRef\n ? isTimeId(segmentRef)\n ? await this.getRefOfTimeId(tableKey, segmentRef)\n : segmentRef\n : null;\n\n controllers[tableKey] ??= await this.getController(\n tableKey,\n base ? ({ base } as ControllerRefs) : undefined,\n );\n }\n\n return controllers;\n }\n\n // ...........................................................................\n /**\n * Adds an InsertHistory row to the InsertHistory table of a table\n * @param table - The table the Insert was made on\n * @param InsertHistoryRow - The InsertHistory row to add\n * @throws {Error} If the InsertHistory table does not exist\n */\n private async _writeInsertHistory(\n table: string,\n insertHistoryRow: InsertHistoryRow<any>,\n ): Promise<void> {\n const insertHistoryTable = table + 'InsertHistory';\n\n //Write InsertHistory row to io\n await this.core.import({\n [insertHistoryTable]: {\n _data: [insertHistoryRow],\n _type: 'insertHistory',\n },\n });\n }\n\n // ...........................................................................\n /**\n * Add a multiEdit\n * @param cakeKey - The cake table key\n * @param multiEdit - The multiEdit to add\n */\n public async addMultiEdit(cakeKey: string, multiEdit: MultiEdit) {\n return this.insert(\n Route.fromFlat(cakeKey + 'MultiEdits'),\n {\n [cakeKey + 'MultiEdits']: {\n _data: [multiEdit],\n _type: 'multiEdits' as ContentType,\n } as MultiEditsTable,\n },\n { skipHistory: true },\n );\n }\n\n // ...........................................................................\n /**\n * Get multiEdits\n * @param cakeKey - The cake table key\n * @param where - The where clause to filter multiEdits\n */\n public async getMultiEdits(\n cakeKey: string,\n where: string | Json,\n ): Promise<MultiEdit[]> {\n const multiEditController = await this.getController(\n cakeKey + 'MultiEdits',\n );\n const { [cakeKey + 'MultiEdits']: result } = await multiEditController.get(\n where,\n );\n return result._data as MultiEdit[];\n }\n\n // ...........................................................................\n /**\n * Add an edit\n * @param cakeKey - The cake table key\n * @param edit - The edit to add\n */\n public async addEdit(cakeKey: string, edit: Edit) {\n return this.insert(\n Route.fromFlat(cakeKey + 'Edits'),\n {\n [cakeKey + 'Edits']: {\n _data: [edit],\n _type: 'edits' as ContentType,\n } as EditsTable,\n },\n { skipHistory: true },\n );\n }\n\n // ...........................................................................\n /**\n * Get edits\n * @param cakeKey - The cake table key\n * @param where - The where clause to filter edits\n */\n public async getEdits(\n cakeKey: string,\n where: string | Json,\n ): Promise<Edit[]> {\n const editController = await this.getController(cakeKey + 'Edits');\n const { [cakeKey + 'Edits']: result } = await editController.get(where);\n return result._data as Edit[];\n }\n\n // ...........................................................................\n /**\n * Add an edit history entry\n * @param cakeKey - The cake table key\n * @param editHistory - The edit history entry to add\n */\n public async addEditHistory(cakeKey: string, editHistory: EditHistory) {\n return this.insert(\n Route.fromFlat(cakeKey + 'EditHistory'),\n {\n [cakeKey + 'EditHistory']: {\n _data: [editHistory],\n _type: 'editHistory' as ContentType,\n } as EditHistoryTable,\n },\n { skipHistory: true },\n );\n }\n\n // ...........................................................................\n /**\n * Get edit history entries\n * @param cakeKey - The cake table key\n * @param where - The where clause to filter edit history entries\n */\n public async getEditHistories(\n cakeKey: string,\n where: string | Json,\n ): Promise<EditHistory[]> {\n const editHistoryController = await this.getController(\n cakeKey + 'EditHistory',\n );\n\n const { [cakeKey + 'EditHistory']: result } =\n await editHistoryController.get(where);\n\n /* v8 ignore next -- @preserve */\n return result._data.sort(\n (h1, h2) =>\n getTimeIdTimestamp(h2.timeId)! - getTimeIdTimestamp(h1.timeId)!,\n ) as EditHistory[];\n }\n\n // ...........................................................................\n /**\n * Get the InsertHistory of a table\n * @param table - The table to get the InsertHistory for\n * @throws {Error} If the InsertHistory table does not exist\n */\n async getInsertHistory(\n table: string,\n options?: { sorted?: boolean; ascending?: boolean },\n ): Promise<Rljson> {\n const insertHistoryTable = table + 'InsertHistory';\n const hasTable = await this.core.hasTable(insertHistoryTable);\n if (!hasTable) {\n throw new Error(`Db.getInsertHistory: Table ${table} does not exist`);\n }\n\n if (options === undefined) {\n options = { sorted: false, ascending: true };\n }\n\n if (options.sorted) {\n const dumpedTable = await this.core.dumpTable(insertHistoryTable);\n const tableData = dumpedTable[insertHistoryTable]\n ._data as InsertHistoryRow<any>[];\n\n //Sort table\n tableData.sort((a, b) =>\n options!.ascending\n ? a.timeId.localeCompare(b.timeId)\n : b.timeId.localeCompare(a.timeId),\n );\n\n return {\n [insertHistoryTable]: { _data: tableData, _type: 'insertHistory' },\n };\n }\n\n return this.core.dumpTable(insertHistoryTable);\n }\n\n // ...........................................................................\n /**\n * Get a specific InsertHistory row from a table\n * @param table - The table to get the InsertHistory row from\n * @param ref - The reference of the InsertHistory row to get\n * @returns The InsertHistory row or null if it does not exist\n * @throws {Error} If the Inserts table does not exist\n */\n async getInsertHistoryRowsByRef(\n table: string,\n ref: string,\n ): Promise<InsertHistoryRow<any>[]> {\n const insertHistoryTable = table + 'InsertHistory';\n const {\n [insertHistoryTable]: { _data: insertHistory },\n } = await this.core.readRows(insertHistoryTable, { [table + 'Ref']: ref });\n return insertHistory as InsertHistoryRow<any>[];\n }\n\n // ...........................................................................\n /**\n * Get a specific InsertHistory row from a table by its timeId\n * @param table - The table to get the InsertHistory row from\n * @param timeId - The timeId of the InsertHistory row to get\n * @returns The InsertHistory row or null if it does not exist\n * @throws {Error} If the Inserts table does not exist\n */\n async getInsertHistoryRowByTimeId(\n table: string,\n timeId: InsertHistoryTimeId,\n ): Promise<InsertHistoryRow<any>> {\n const insertHistoryTable = table + 'InsertHistory';\n const { [insertHistoryTable]: result } = await this.core.readRows(\n insertHistoryTable,\n {\n timeId,\n },\n );\n return result._data?.[0];\n }\n\n // ...........................................................................\n /**\n * Get all timeIds for a specific ref in a table\n * @param table - The table to get the timeIds from\n * @param ref - The reference to get the timeIds for\n * @returns An array of timeIds\n * @throws {Error} If the Inserts table does not exist\n */\n async getTimeIdsForRef(\n table: string,\n ref: Ref,\n ): Promise<InsertHistoryTimeId[]> {\n const insertHistoryTable = table + 'InsertHistory';\n const { [insertHistoryTable]: result } = await this.core.readRows(\n insertHistoryTable,\n {\n [table + 'Ref']: ref,\n },\n );\n return result._data?.map((r) => r.timeId);\n }\n\n // ...........................................................................\n /**\n * Get the ref for a specific timeId in a table\n * @param table - The table to get the ref from\n * @param timeId - The timeId to get the ref for\n * @returns The ref or null if it does not exist\n * @throws {Error} If the Inserts table does not exist\n */\n async getRefOfTimeId(\n table: string,\n timeId: InsertHistoryTimeId,\n ): Promise<Ref | null> {\n const insertHistoryTable = table + 'InsertHistory';\n const { [insertHistoryTable]: result } = await this.core.readRows(\n insertHistoryTable,\n {\n timeId,\n },\n );\n return (result._data?.[0] as any)?.[table + 'Ref'];\n }\n\n // ...........................................................................\n /**\n * Isolates the property key from the last segment of a route if it is a property of a component\n * @param route - The route to extract property key from\n * @returns A route with extracted property key\n */\n async isolatePropertyKeyFromRoute(route: Route): Promise<Route> {\n const segmentLength = route.segments.length;\n let propertyKey = '';\n let result: Route = route;\n for (let i = segmentLength; i > 0; i--) {\n const segment = route.segments[i - 1];\n const tableKey = segment.tableKey;\n const tableExists = await this._io.tableExists(tableKey);\n\n /* v8 ignore next -- @preserve */\n if (!tableExists) {\n propertyKey =\n propertyKey.length > 0\n ? segment.tableKey + '/' + propertyKey\n : segment.tableKey;\n result = result.upper();\n result.propertyKey = propertyKey;\n }\n }\n return result;\n }\n\n // ...........................................................................\n /**\n * Isolates a property from all components in an Rljson\n * @param rljson - The Rljson to isolate the property from\n * @param propertyKey - The property key to isolate\n * @returns A new Rljson with only the isolated property\n */\n isolatePropertyFromComponents(rljson: Rljson, propertyKey: string): Rljson {\n const result: Rljson = {};\n for (const tableKey of Object.keys(rljson)) {\n const table = rljson[tableKey];\n const newData = table._data.map((row: any) => {\n if (row.hasOwnProperty(propertyKey)) {\n return {\n [propertyKey]: row[propertyKey],\n _hash: row._hash,\n };\n } else {\n return row;\n }\n });\n result[tableKey] = {\n _type: table._type,\n _data: newData,\n };\n }\n return result;\n }\n\n // ...........................................................................\n /**\n * Clone the Db instance with a new Io instance\n * @param io - The new Io instance\n * @returns A new Db instance with the same cache as the current instance\n */\n clone(io: Io): Db {\n const newDb = new Db(io);\n newDb.setCache(new Map(this._cache));\n return newDb;\n }\n\n // ...........................................................................\n /**\n * Get the current cache of the Db instance\n */\n get cache() {\n return this._cache;\n }\n\n // ...........................................................................\n /**\n * Set the cache of the Db instance\n * @param cache - The new cache to set\n */\n setCache(cache: Map<string, Container>) {\n this._cache = cache;\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { EditAction } from '@rljson/rljson';\n\nimport { ColumnFilter } from '../join/filter/column-filter.ts';\nimport { RowFilter } from '../join/filter/row-filter.ts';\nimport {\n ColumnInfo,\n ColumnSelection,\n} from '../join/selection/column-selection.ts';\nimport { SetValue } from '../join/set-value/set-value.ts';\nimport { RowSortType } from '../join/sort/row-sort.ts';\n\nexport interface EditActionColumnSelection extends EditAction {\n type: 'selection';\n data: {\n columns: ColumnInfo[];\n };\n}\n\nexport interface EditActionRowFilter extends EditAction {\n type: 'filter';\n data: RowFilter;\n}\n\nexport interface EditActionSetValue extends EditAction {\n type: 'setValue';\n data: SetValue;\n}\n\nexport interface EditActionRowSort extends EditAction {\n type: 'sort';\n data: RowSortType;\n}\n\n//..................................................................................\n\n/**\n * Example EditAction of type 'selection'\n * @returns An example EditAction representing a column selection\n */\nexport const exampleEditActionColumnSelection =\n (): EditActionColumnSelection => ({\n name: 'Car Selection',\n type: 'selection',\n data: {\n columns: ColumnSelection.exampleCarsColumnSelection().columns,\n },\n _hash: '',\n });\n\n//..................................................................................\n\n/**\n * Example EditAction of type 'selection' with only some columns\n * @returns An example EditAction representing a column selection with limited columns\n */\nexport const exampleEditActionColumnSelectionOnlySomeColumns =\n (): EditActionColumnSelection => ({\n name: 'Car Selection - Some Columns',\n type: 'selection',\n data: {\n columns:\n ColumnSelection.exampleCarsColumnSelectionOnlySomeColumns().columns,\n },\n _hash: '',\n });\n\n//..................................................................................\n\n/**\n * Example EditAction of type 'filter'\n * @returns An example EditAction representing a row filter\n */\nexport const exampleEditActionRowFilter = (): EditActionRowFilter => ({\n name: 'Electric Cars Filter',\n type: 'filter',\n data: {\n columnFilters: [\n {\n type: 'boolean',\n column: 'carCake/carGeneralLayer/carGeneral/isElectric',\n operator: 'equals',\n search: true,\n _hash: '',\n },\n {\n type: 'number',\n column: 'carCake/carTechnicalLayer/carTechnical/carDimensions/length',\n operator: 'greaterThan',\n search: 4000,\n _hash: '',\n },\n ] as ColumnFilter<any>[],\n operator: 'and',\n value: true,\n _hash: '',\n },\n _hash: '',\n});\n\n/**\n * Example EditAction of type 'setValue'\n * @returns An example EditAction representing a set value action\n */\n\nexport const exampleEditActionSetValue = (): EditActionSetValue => ({\n name: 'Set: Service Intervals to [15000, 30000, 45000, 60000]',\n type: 'setValue',\n data: {\n route: 'carCake/carGeneralLayer/carGeneral/serviceIntervals',\n value: [15000, 30000, 45000, 60000],\n _hash: '',\n },\n _hash: '',\n});\n\n/**\n * Example EditAction of type 'setValue' for a referenced column\n * @returns An example EditAction representing a set value action for a referenced column\n */\nexport const exampleEditSetValueReferenced = (): EditActionSetValue => ({\n name: 'Set: Length to 4200',\n type: 'setValue',\n data: {\n route: 'carCake/carTechnicalLayer/carTechnical/carDimensions/length',\n value: 4800,\n _hash: '',\n },\n _hash: '',\n});\n\n/**\n * Example EditAction of type 'sort'\n * @returns An example EditAction representing a row sort action\n */\nexport const exampleEditActionRowSort = (): EditActionRowSort => ({\n name: 'Sort By Brand Edit',\n type: 'sort',\n data: {\n ['carCake/carGeneralLayer/carGeneral/brand']: 'asc',\n },\n _hash: '',\n});\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { Route, RouteRef, SliceId } from '@rljson/rljson';\n\nimport { Join } from '../join.ts';\nimport { ColumnSelection } from '../selection/column-selection.ts';\n\nexport type RowSortOrder = 'asc' | 'desc';\nexport type RowSortType = Record<RouteRef, RowSortOrder>;\n\n/// Sort configuration for catalog data\nexport class RowSort {\n constructor(columnSorts: Record<string, 'asc' | 'desc'>) {\n this._columnSorts = this._initColumnSorts(columnSorts);\n }\n\n // ...........................................................................\n /**\n * Sorts the rows of a join according to the sort configuration.\n * @param join - The join to be sorted\n * @returns Returns the row indices in a sorted manner\n */\n applyTo(join: Join): SliceId[] {\n if (join.rowCount === 0) {\n return join.rowIndices;\n }\n\n // Throw when filter specifies non existent column routes\n this._throwOnWrongRoutes(join);\n\n const routeHashes = join.columnSelection.routeHashes;\n\n // Generate an array of sort operators\n const sortIndices: number[] = [];\n const sortOrders: Array<'asc' | 'desc'> = [];\n\n let hasSorts = false;\n for (const item of this._columnSorts) {\n const index = routeHashes.indexOf(item.routeHash);\n sortIndices.push(index);\n sortOrders.push(item.order);\n\n hasSorts = true;\n }\n\n // No filters set? Return unchanged rows.\n if (!hasSorts) {\n return join.rowIndices;\n }\n\n // Apply the filters\n return this._sortRows(join, sortIndices, sortOrders);\n }\n\n // ...........................................................................\n /* v8 ignore next -- @preserve */\n get columnSorts(): Record<string, 'asc' | 'desc'> {\n const result: Record<string, 'asc' | 'desc'> = {};\n for (const sort of this._columnSorts) {\n result[sort.route] = sort.order;\n }\n\n return result;\n }\n\n // ######################\n // Private\n // ######################\n\n private readonly _columnSorts: _SortItem[];\n\n // ...........................................................................\n private _initColumnSorts(\n columnSorts: Record<string, 'asc' | 'desc'>,\n ): _SortItem[] {\n const result: _SortItem[] = [];\n const columns = Object.keys(columnSorts);\n const columnSelection = ColumnSelection.fromRoutes(\n columns.map((c) => Route.fromFlat(c)),\n );\n\n const routes = columnSelection.routes;\n const routeHashes = columnSelection.routeHashes;\n\n for (let i = 0; i < routes.length; i++) {\n const route = routes[i];\n const routeHash = routeHashes[i];\n result.push({\n route,\n routeHash,\n order: columnSorts[route],\n });\n }\n\n return result;\n }\n\n // ...........................................................................\n private _sortRows(\n join: Join,\n sortIndices: number[],\n sortOrders: Array<'asc' | 'desc'>,\n ): SliceId[] {\n const result = [...join.rowIndices];\n\n // Sort\n return result.sort((a, b) => {\n const rowA = join.row(a);\n const rowB = join.row(b);\n\n let i = 0;\n for (const index of sortIndices) {\n const sort = sortOrders[i++];\n //TODO: Make cells holding several values sortable\n\n /* v8 ignore next -- @preserve */\n const rowAInsertValues = rowA[index].inserts\n ? Array.isArray(rowA[index].inserts![0].cell[0].value)\n ? rowA[index].inserts![0].cell[0].value!\n : [rowA[index].inserts![0].cell[0].value!]\n : null;\n /* v8 ignore next -- @preserve */\n const rowAValue = rowA[index].value.cell[0].value\n ? Array.isArray(rowA[index].value?.cell[0].value)\n ? rowA[index].value.cell[0].value!\n : [rowA[index].value.cell[0].value!]\n : null;\n /* v8 ignore next -- @preserve */\n const rowBInsertValues = rowB[index].inserts\n ? Array.isArray(rowB[index].inserts![0].cell[0].value)\n ? rowB[index].inserts![0].cell[0].value!\n : [rowB[index].inserts![0].cell[0].value!]\n : null;\n /* v8 ignore next -- @preserve */\n const rowBValue = rowB[index].value.cell[0].value\n ? Array.isArray(rowB[index].value?.cell[0].value)\n ? rowB[index].value.cell[0].value!\n : [rowB[index].value.cell[0].value!]\n : null;\n /* v8 ignore next -- @preserve */\n const vA =\n rowAInsertValues && rowAInsertValues[0]\n ? rowAInsertValues[0]\n : rowAValue\n ? rowAValue[0]\n : null;\n /* v8 ignore next -- @preserve */\n const vB =\n rowBInsertValues && rowBInsertValues[0]\n ? rowBInsertValues[0]\n : rowBValue\n ? rowBValue[0]\n : null;\n\n if (vA === vB) {\n continue;\n }\n if (sort === 'asc') {\n return vA! < vB! ? -1 : 1;\n } else {\n return vA! < vB! ? 1 : -1;\n }\n }\n\n return 0;\n });\n }\n\n // ...........................................................................\n private _throwOnWrongRoutes(join: Join) {\n const availableRoutes = join.columnSelection.routes;\n for (const item of Object.values(this._columnSorts)) {\n const route = item.route;\n if (availableRoutes.includes(route) === false) {\n throw new Error(\n `RowFilterProcessor: Error while applying sort to join: ` +\n `There is a sort entry for route \"${route}\", but the join ` +\n `does not have a column with this route.\\n\\nAvailable routes:\\n` +\n `${availableRoutes.map((a: string) => `- ${a}`).join('\\n')}`,\n );\n }\n }\n }\n}\n\n// #############################################################################\ninterface _SortItem {\n order: 'asc' | 'desc';\n routeHash: string;\n\n route: string;\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { hip, rmhsh } from '@rljson/hash';\nimport { Edit, EditHistory, MultiEdit, Route } from '@rljson/rljson';\n\nimport { Db } from '../db.ts';\nimport { RowFilter } from '../join/filter/row-filter.ts';\nimport { Join, JoinRowsHashed } from '../join/join.ts';\nimport {\n ColumnInfo,\n ColumnSelection,\n} from '../join/selection/column-selection.ts';\nimport { SetValue } from '../join/set-value/set-value.ts';\nimport { RowSort, RowSortType } from '../join/sort/row-sort.ts';\n\nimport {\n EditColumnSelection,\n EditRowFilter,\n EditRowSort,\n EditSetValue,\n} from './edit.ts';\n\nexport type MultiEditColumnSelection = ColumnSelection;\nexport type MultiEditRowHashed = JoinRowsHashed;\nexport type MultiEditRows = any[][];\n\nexport class MultiEditProcessor {\n private _multiEdit: MultiEdit | null = null;\n private _edits: Edit[] = [];\n private _join: Join | null = null;\n\n constructor(\n private readonly _db: Db,\n private readonly _cakeKey: string,\n private readonly _cakeRef: string,\n ) {\n // Initialization code can go here\n }\n\n //...........................................................................\n /**\n * Create MultiEditProcessor from EditHistory\n * @param db - Db instance\n * @param cakeKey - Cake key\n * @param editHistory - EditHistory\n * @returns MultiEditProcessor\n */\n static async fromEditHistory(\n db: Db,\n cakeKey: string,\n editHistory: EditHistory,\n ): Promise<MultiEditProcessor> {\n /* v8 ignore if -- @preserve */\n if (!editHistory || !editHistory.multiEditRef) {\n throw new Error('MultiEditProcessor: Invalid EditHistory provided.');\n }\n\n const cakeRef = editHistory.dataRef;\n const multiEdits = await db.getMultiEdits(\n cakeKey,\n editHistory.multiEditRef,\n );\n\n /* v8 ignore if -- @preserve */\n if (!multiEdits || multiEdits.length === 0) {\n throw new Error(\n `MultiEditProcessor: MultiEdit not found for ref ${editHistory.multiEditRef}`,\n );\n }\n\n /* v8 ignore if -- @preserve */\n if (multiEdits.length > 1) {\n throw new Error(\n `MultiEditProcessor: Multiple MultiEdits found for ref ${editHistory.multiEditRef}`,\n );\n }\n\n const multiEdit = multiEdits[0];\n\n return MultiEditProcessor.fromMultiEdit(db, cakeKey, cakeRef, multiEdit);\n }\n\n //...........................................................................\n /**\n * Create MultiEditProcessor from MultiEdit\n * @param db - Db instance\n * @param cakeKey - Cake key\n * @param cakeRef - Cake ref\n * @param multiEdit - MultiEdit\n * @returns MultiEditProcessor\n */\n static async fromMultiEdit(\n db: Db,\n cakeKey: string,\n cakeRef: string,\n multiEdit: MultiEdit,\n ): Promise<MultiEditProcessor> {\n const processor = new MultiEditProcessor(db, cakeKey, cakeRef);\n await processor._resolve(multiEdit);\n await processor._processAll();\n return processor;\n }\n\n get join(): Join {\n /* v8 ignore if -- @preserve */\n if (!this._join) {\n throw new Error('MultiEditProcessor: Join not processed yet.');\n }\n return this._join;\n }\n\n get multiEdit(): MultiEdit {\n /* v8 ignore if -- @preserve */\n if (!this._multiEdit) {\n throw new Error('MultiEditProcessor: MultiEdit not resolved yet.');\n }\n return this._multiEdit;\n }\n\n get cakeRef(): string {\n return this._cakeRef;\n }\n\n //...........................................................................\n /**\n * Apply an Edit to the MultiEditProcessor\n * @param edit - Edit to apply\n * @returns MultiEditProcessor\n */\n async edit(edit: Edit): Promise<MultiEditProcessor> {\n this._edits.push(edit);\n this._join = await this._process(edit);\n /* v8 ignore next -- @preserve */\n this._multiEdit = hip<MultiEdit>({\n _hash: '',\n edit: edit._hash,\n previous: this.multiEdit ? this.multiEdit._hash : null,\n });\n return this;\n }\n\n async applyEditHistory(\n editHistory: EditHistory,\n ): Promise<MultiEditProcessor> {\n /* v8 ignore if -- @preserve */\n if (!editHistory || !editHistory.multiEditRef) {\n throw new Error('MultiEditProcessor: Invalid EditHistory provided.');\n }\n\n const multiEdits = await this._db.getMultiEdits(\n this._cakeKey,\n editHistory.multiEditRef,\n );\n\n /* v8 ignore if -- @preserve */\n if (!multiEdits || multiEdits.length === 0) {\n throw new Error(\n `MultiEditProcessor: MultiEdit not found for ref ${editHistory.multiEditRef}`,\n );\n }\n\n /* v8 ignore if -- @preserve */\n if (multiEdits.length > 1) {\n throw new Error(\n `MultiEditProcessor: Multiple MultiEdits found for ref ${editHistory.multiEditRef}`,\n );\n }\n\n const multiEdit = multiEdits[0];\n\n await this._resolve(multiEdit);\n await this._processAll();\n\n return this;\n }\n\n //...........................................................................\n /**\n * Publish the MultiEditProcessor. Inserts the resulting Join as new data,\n * updates the head revision, and saves the resulting MultiEdit.\n * @param options - Publish options\n * @returns MultiEditProcessor\n */\n async publish(options?: {\n skipHeadUpdate?: boolean;\n skipSaveMultiEdit?: boolean;\n }): Promise<MultiEditProcessor> {\n const inserts = this.join.insert();\n\n /* v8 ignore if -- @preserve */\n if (inserts.length === 0) {\n throw new Error('MultiEditProcessor: No inserts to publish.');\n }\n\n /* v8 ignore if -- @preserve */\n if (inserts.length > 1) {\n throw new Error(\n 'MultiEditProcessor: Multiple inserts not supported yet.',\n );\n }\n\n const insert = inserts[0];\n const inserteds = await this._db.insert(insert.route, insert.tree);\n\n /* v8 ignore if -- @preserve */\n if (inserteds.length === 0) {\n throw new Error('MultiEditProcessor: No rows inserted.');\n }\n /* v8 ignore if -- @preserve */\n if (inserteds.length > 1) {\n throw new Error(\n 'MultiEditProcessor: Multiple inserted rows not supported yet.',\n );\n }\n\n const inserted = inserteds[0];\n const writtenCakeRef = (inserted as any)[this._cakeKey + 'Ref'] as string;\n\n /* v8 ignore else -- @preserve */\n if (!options?.skipSaveMultiEdit) {\n await this._db.addMultiEdit(this._cakeKey, this._multiEdit!);\n }\n\n return new MultiEditProcessor(this._db, this._cakeKey, writtenCakeRef);\n }\n\n //...........................................................................\n /**\n * Clone the MultiEditProcessor\n * @returns Cloned MultiEditProcessor\n */\n clone(): MultiEditProcessor {\n const clone = new MultiEditProcessor(\n this._db,\n this._cakeKey,\n this._cakeRef,\n );\n clone._multiEdit = this._multiEdit;\n clone._edits = [...this._edits];\n clone._join = this._join;\n return clone;\n }\n\n //...........................................................................\n /**\n * Resolve MultiEdit chain recursively\n * @param multiEdit - MultiEdit to resolve\n * @returns Promise<void>\n */\n private async _resolve(multiEdit: MultiEdit): Promise<void> {\n this._multiEdit = multiEdit;\n\n const edits = await this._db.getEdits(this._cakeKey, multiEdit.edit);\n\n /* v8 ignore if -- @preserve */\n if (edits.length === 0) {\n throw new Error(\n `MultiEditProcessor: Edit not found for ref ${multiEdit.edit}`,\n );\n }\n\n /* v8 ignore if -- @preserve */\n if (edits.length > 1) {\n throw new Error(\n `MultiEditProcessor: Multiple Edits found for ref ${multiEdit.edit}`,\n );\n }\n\n const edit = edits[0];\n\n this._edits.push(edit);\n\n if (multiEdit.previous) {\n const previousMultiEdits = await this._db.getMultiEdits(\n this._cakeKey,\n multiEdit.previous!,\n );\n\n const previousMultiEdit = previousMultiEdits[0];\n\n const previousEditFromMultiEdit = previousMultiEdit.edit;\n const previousEdit = this._edits[this._edits.length - 2]\n ? this._edits[this._edits.length - 2]._hash\n : null;\n\n if (previousEdit !== previousEditFromMultiEdit) {\n return await this._resolve(previousMultiEdit);\n }\n }\n }\n\n //...........................................................................\n /**\n * Process all Edits in the MultiEditProcessor\n * @returns Resulting Join\n */\n private async _processAll(): Promise<Join> {\n for (let i = this._edits.length - 1; i >= 0; i--) {\n const edit = this._edits[i];\n this._join = await this._process(edit);\n }\n\n return this._join!;\n }\n\n //...........................................................................\n /**\n * Process a single Edit and update the Join\n * @param edit - Edit to process\n * @returns Resulting Join\n */\n private async _process(edit: Edit): Promise<Join> {\n const action = edit.action;\n if (!this._join) {\n switch (action.type) {\n case 'selection':\n const editColInfos = (edit as EditColumnSelection).action.data\n .columns as ColumnInfo[];\n const editColSelection = new ColumnSelection(editColInfos);\n this._join = await this._db.join(\n editColSelection,\n this._cakeKey,\n this._cakeRef,\n );\n break;\n case 'setValue':\n const editSetValue = (edit as EditSetValue).action.data as SetValue;\n const editSetValueKey = Route.fromFlat(editSetValue.route).segment()\n .tableKey;\n const editSetValueColumnInfo: ColumnInfo = {\n key: editSetValueKey,\n route: editSetValue.route,\n alias: editSetValueKey,\n titleLong: '',\n titleShort: '',\n type: 'jsonValue',\n _hash: '',\n };\n const editSetValueColSelection = new ColumnSelection([\n editSetValueColumnInfo,\n ]);\n this._join = (\n await this._db.join(\n editSetValueColSelection,\n this._cakeKey,\n this._cakeRef,\n )\n ).setValue(editSetValue);\n break;\n case 'sort':\n const editRowSort = rmhsh(edit as EditRowSort).action.data;\n const editRowSortColumnInfos: ColumnInfo[] = [];\n for (const routeStr of Object.keys(editRowSort)) {\n const route = Route.fromFlat(routeStr);\n const tableKey = route.segment().tableKey;\n const columnInfo: ColumnInfo = {\n key: tableKey,\n route: routeStr,\n alias: tableKey,\n titleLong: '',\n titleShort: '',\n type: 'jsonValue',\n _hash: '',\n };\n editRowSortColumnInfos.push(columnInfo);\n }\n const editRowSortColSelection = new ColumnSelection(\n editRowSortColumnInfos,\n );\n this._join = (\n await this._db.join(\n editRowSortColSelection,\n this._cakeKey,\n this._cakeRef,\n )\n ).sort(new RowSort(editRowSort));\n break;\n case 'filter':\n const editRowFilter = (edit as EditRowFilter).action.data;\n const editRowFilterColumnInfos: ColumnInfo[] = [];\n for (const colFilter of editRowFilter.columnFilters) {\n const route = Route.fromFlat(colFilter.column);\n const tableKey = route.segment().tableKey;\n const columnInfo: ColumnInfo = {\n key: tableKey,\n route: colFilter.column,\n alias: tableKey,\n titleLong: '',\n titleShort: '',\n type: 'jsonValue',\n _hash: '',\n };\n editRowFilterColumnInfos.push(columnInfo);\n }\n const editRowFilterColSelection = new ColumnSelection(\n editRowFilterColumnInfos,\n );\n this._join = (\n await this._db.join(\n editRowFilterColSelection,\n this._cakeKey,\n this._cakeRef,\n )\n ).filter(editRowFilter);\n break;\n /* v8 ignore next -- @preserve */\n default:\n break;\n }\n } else {\n switch (action.type) {\n case 'selection':\n const editColInfos = (edit as EditColumnSelection).action.data\n .columns as ColumnInfo[];\n const editColSelection = new ColumnSelection(editColInfos);\n this._join = this._join.select(editColSelection);\n break;\n case 'setValue':\n const editSetValue = rmhsh(\n (edit as EditSetValue).action.data as SetValue,\n );\n this._join = this._join.setValue(editSetValue);\n break;\n case 'sort':\n const editRowSort = rmhsh(\n (edit as EditRowSort).action.data,\n ) as RowSortType;\n this._join = this._join.sort(new RowSort(editRowSort));\n break;\n case 'filter':\n const editRowFilter = rmhsh(\n (edit as EditRowFilter).action.data,\n ) as RowFilter;\n this._join = this._join.filter(editRowFilter);\n break;\n /* v8 ignore next -- @preserve */\n default:\n break;\n }\n }\n\n return this._join!;\n }\n\n //...........................................................................\n /**\n * Get the list of Edits applied in this MultiEditProcessor\n * @returns Array of Edits\n */\n get edits(): Edit[] {\n return this._edits;\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { hsh } from '@rljson/hash';\nimport { Edit, EditHistory, InsertHistoryRow, MultiEdit, Route, timeId } from '@rljson/rljson';\n\nimport { Db } from '../db.ts';\nimport { Join } from '../join/join.ts';\n\nimport { MultiEditProcessor } from './multi-edit-processor.ts';\n\n\nexport class MultiEditManager {\n private _head: {\n editHistoryRef: string;\n processor: MultiEditProcessor;\n } | null = null;\n private _headListener: ((editHistoryRef: string) => Promise<void>)[] = [];\n private _processors: Map<string, MultiEditProcessor> = new Map();\n private _isListening: boolean = false;\n\n constructor(private readonly _cakeKey: string, private readonly _db: Db) {}\n\n init() {\n const editHistoryKey = `${this._cakeKey}EditHistory`;\n this._db.registerObserver(\n Route.fromFlat(editHistoryKey),\n (ins: InsertHistoryRow<string>) => {\n const editHistoryRef = (ins as any)[editHistoryKey + 'Ref'] as string;\n return this.editHistoryRef(editHistoryRef);\n },\n );\n this._isListening = true;\n }\n\n tearDown() {\n const editHistoryKey = `${this._cakeKey}EditHistory`;\n this._db.unregisterAllObservers(Route.fromFlat(editHistoryKey));\n this._isListening = false;\n }\n\n async edit(edit: Edit, cakeRef?: string) {\n /* v8 ignore next -- @preserve */\n if (!this.head && !cakeRef) {\n throw new Error(\n 'No head MultiEditProcessor available. Provide a cakeRef.',\n );\n }\n /* v8 ignore next -- @preserve */\n if (this.head && cakeRef) {\n throw new Error(\n 'Head MultiEditProcessor already exists. Do not provide a cakeRef.',\n );\n }\n\n // Store the new Edit\n await this._persistEdit(edit);\n\n let multiEditProc: MultiEditProcessor;\n if (!this.head) {\n const multiEdit: MultiEdit = {\n _hash: '',\n edit: hsh(edit)._hash,\n previous: null,\n };\n\n await this._persistMultiEdit(multiEdit);\n\n multiEditProc = await MultiEditProcessor.fromMultiEdit(\n this._db,\n this._cakeKey,\n cakeRef!,\n multiEdit,\n );\n } else {\n multiEditProc = await this.head.processor.edit(edit);\n }\n\n // Store the new MultiEdit\n const multiEditRef = await this._persistMultiEdit(multiEditProc.multiEdit);\n\n // Create and store the new EditHistory pointing to the new MultiEdit\n const editHistoryRef = await this._persistEditHistory({\n _hash: '',\n dataRef: multiEditProc.cakeRef,\n multiEditRef: await multiEditRef,\n timeId: timeId(),\n previous:\n !!this.head && this.head.editHistoryRef\n ? [this.head.editHistoryRef]\n : null,\n } as EditHistory);\n\n // Update internal state\n this._processors.set(editHistoryRef, multiEditProc);\n this._head = {\n editHistoryRef,\n processor: multiEditProc,\n };\n\n // Notify listeners about head change\n await this._notifyHeadListener(editHistoryRef);\n }\n\n async publish() {\n if (!this.head) {\n throw new Error('No head MultiEditProcessor available.');\n }\n return await this.head.processor.publish();\n }\n\n listenToHeadChanges(callback: (editHistoryRef: string) => Promise<void>) {\n this._headListener.push(callback);\n }\n\n private _notifyHeadListener(editHistoryRef: string) {\n /* v8 ignore next -- @preserve */\n return Promise.all(\n this._headListener.map((cb) => cb(editHistoryRef)),\n ).catch((err) => {\n console.error(\n `Error notifying head observers for editHistoryRef ${editHistoryRef}:`,\n err,\n );\n });\n }\n\n async editHistoryRef(editHistoryRef: string): Promise<MultiEditProcessor> {\n const editHistories = await this._db.getEditHistories(\n this._cakeKey,\n editHistoryRef,\n );\n\n /* v8 ignore if -- @preserve */\n if (editHistories.length === 0) {\n throw new Error(`EditHistory with ref ${editHistoryRef} not found.`);\n }\n\n /* v8 ignore if -- @preserve */\n if (editHistories.length > 1) {\n throw new Error(\n `Multiple EditHistories with ref ${editHistoryRef} found.`,\n );\n }\n\n const editHistory = editHistories[0];\n\n // Check if processor already exists\n if (this._processors.has(editHistoryRef)) {\n const processor = this._processors.get(editHistoryRef)!;\n this._head = {\n editHistoryRef,\n processor,\n };\n await this._notifyHeadListener(editHistoryRef);\n return processor;\n }\n\n // Handle case with previous edit history\n if (editHistory.previous && editHistory.previous.length > 0) {\n /* v8 ignore if -- @preserve */\n if (editHistory.previous.length > 1) {\n throw new Error(\n `EditHistory with ref ${editHistoryRef} has multiple previous refs. Not supported.`,\n );\n }\n\n const previousEditHistoryRef = editHistory.previous[0];\n const previousProcessor = await this.editHistoryRef(\n previousEditHistoryRef,\n );\n const previousProcessorCloned = previousProcessor.clone();\n\n const processor = await previousProcessorCloned.applyEditHistory(\n editHistory,\n );\n\n this._processors.set(editHistoryRef, processor);\n this._head = {\n editHistoryRef,\n processor,\n };\n await this._notifyHeadListener(editHistoryRef);\n return processor;\n }\n\n // Handle case without previous edit history (base case)\n const processor = await MultiEditProcessor.fromEditHistory(\n this._db,\n this._cakeKey,\n editHistory,\n );\n\n this._processors.set(editHistoryRef, processor);\n this._head = {\n editHistoryRef,\n processor,\n };\n await this._notifyHeadListener(editHistoryRef);\n return processor;\n }\n\n private async _persistEdit(edit: Edit): Promise<string> {\n // Store the new Edit\n const { [this._cakeKey + 'EditsRef']: editRef } = (\n await this._db.addEdit(this._cakeKey, edit)\n )[0] as any;\n\n /* v8 ignore next -- @preserve */\n if (!editRef) {\n throw new Error('MultiEditManager: Failed to create EditRef.');\n }\n return editRef;\n }\n\n private async _persistMultiEdit(multiEdit: MultiEdit): Promise<string> {\n // Create and store the new MultiEdit\n const { [this._cakeKey + 'MultiEditsRef']: multiEditRef } = (\n await this._db.addMultiEdit(this._cakeKey, multiEdit)\n )[0] as any;\n /* v8 ignore next -- @preserve */\n if (!multiEditRef) {\n throw new Error('MultiEditManager: Failed to create MultiEditRef.');\n }\n return multiEditRef;\n }\n\n private async _persistEditHistory(editHistory: EditHistory): Promise<string> {\n // Create and store the new EditHistory pointing to the new MultiEdit\n const { [this._cakeKey + 'EditHistoryRef']: editHistoryRef } = (\n await this._db.addEditHistory(this._cakeKey, editHistory)\n )[0] as any;\n /* v8 ignore next -- @preserve */\n if (!editHistoryRef) {\n throw new Error('MultiEditManager: Failed to create EditHistoryRef.');\n }\n return editHistoryRef;\n }\n\n get processors() {\n return this._processors;\n }\n\n get head() {\n return this._head;\n }\n\n get join(): Join {\n if (!this.head) {\n throw new Error('No head MultiEditProcessor available.');\n }\n return this.head.processor.join;\n }\n\n get isListening() {\n return this._isListening;\n }\n}\n","// @license\n// Copyright (c) 2025 Rljson\n//\n// Use of this source code is governed by terms that can be\n// found in the LICENSE file in the root of this package.\n\nimport { hip, hsh, rmhsh } from '@rljson/hash';\nimport { Json, JsonH, JsonValueH } from '@rljson/json';\nimport {\n CakeReference,\n CakesTable,\n ColumnCfg,\n ComponentsTable,\n createCakeTableCfg,\n createLayerTableCfg,\n createSliceIdsTableCfg,\n Layer,\n LayersTable,\n Rljson,\n SliceId,\n SliceIds,\n SliceIdsTable,\n TableCfg,\n TablesCfgTable,\n} from '@rljson/rljson';\n\n//Corporate Group\n//Companies\n//Branches\n//Sites\n\nexport interface StaticExample extends Rljson {\n carSliceId: SliceIdsTable;\n carGeneral: ComponentsTable<CarGeneral>;\n carTechnical: ComponentsTable<Json>;\n carColor: ComponentsTable<Json>;\n carDimensions: ComponentsTable<CarDimension>;\n carGeneralLayer: LayersTable;\n carTechnicalLayer: LayersTable;\n carColorLayer: LayersTable;\n carCake: CakesTable;\n seriesSliceId: SliceIdsTable;\n seriesGeneral: ComponentsTable<Json>;\n seriesCars: ComponentsTable<Json>;\n seriesGeneralLayer: LayersTable;\n seriesCarsLayer: LayersTable;\n seriesCake: CakesTable;\n catalogSliceId: SliceIdsTable;\n catalogSeries: ComponentsTable<Json>;\n catalogSeriesLayer: LayersTable;\n catalogCake: CakesTable;\n tableCfgs: TablesCfgTable;\n}\n\nexport interface CarGeneral extends JsonH {\n brand: string;\n type: string;\n doors: number;\n energyConsumption: number;\n units: JsonValueH;\n serviceIntervals: number[];\n isElectric: boolean;\n}\n\nexport interface CarDimension extends JsonH {\n height: number;\n width: number;\n length: number;\n}\n\nexport interface CarTechnical extends JsonH {\n engine: string;\n transmission: string;\n gears: number;\n carDimensionsRef: string;\n}\n\nconst chainLayers = (layers: Layer[]): Layer[] => {\n const chainedLayers: Layer[] = [];\n for (let i = 0; i < layers.length; i++) {\n const newLayer = { ...rmhsh(layers[i]) };\n if (i == 0) {\n chainedLayers.push(hsh<Layer>(newLayer));\n continue;\n }\n\n /* v8 ignore else -- @preserve */\n if (chainedLayers[i - 1]._hash) {\n newLayer.base = chainedLayers[i - 1]._hash as string;\n }\n chainedLayers.push(hsh<Layer>(newLayer));\n }\n return chainedLayers;\n};\n\nconst chainSliceIds = (sliceIds: SliceIds[]): SliceIds[] => {\n const chainedSliceIds: SliceIds[] = [];\n for (let i = 0; i < sliceIds.length; i++) {\n const newSliceIds = { ...rmhsh(sliceIds[i]) };\n /* v8 ignore else -- @preserve */\n if (i == 0) {\n chainedSliceIds.push(hsh<SliceIds>(newSliceIds));\n continue;\n }\n /* v8 ignore else -- @preserve */\n if (chainedSliceIds[i - 1]._hash) {\n newSliceIds.base = chainedSliceIds[i - 1]._hash as string;\n }\n chainedSliceIds.push(hsh<SliceIds>(newSliceIds));\n }\n return chainedSliceIds;\n};\n\nexport const staticExample = (): StaticExample => {\n //................................................................\n //Car Data Tables\n //................................................................\n\n //CarSliceId\n //................................................................\n const carSliceIdTableCfg = hip<TableCfg>(\n createSliceIdsTableCfg('carSliceId'),\n ) as TableCfg;\n\n const carSliceIdData: Array<SliceIds> = [\n {\n add: ['VIN1', 'VIN2', 'VIN3', 'VIN4', 'VIN5', 'VIN6', 'VIN7', 'VIN8'],\n _hash: '',\n } as SliceIds,\n {\n add: ['VIN9', 'VIN10'],\n _hash: '',\n } as SliceIds,\n {\n add: ['VIN11', 'VIN12'],\n _hash: '',\n } as SliceIds,\n ].map((sliceIds) => hsh<SliceIds>(sliceIds as SliceIds));\n\n const carSliceId = hip<any>({\n _tableCfg: carSliceIdTableCfg._hash,\n _type: 'sliceIds',\n _data: chainSliceIds(carSliceIdData),\n _hash: '',\n }) as SliceIdsTable;\n\n //CarGeneral\n //................................................................\n const carGeneralTableCfg = hip<TableCfg>({\n key: 'carGeneral',\n type: 'components',\n columns: [\n { key: '_hash', type: 'string', titleLong: 'Hash', titleShort: 'Hash' },\n { key: 'brand', type: 'string', titleLong: 'Brand', titleShort: 'Brand' },\n { key: 'type', type: 'string', titleLong: 'Type', titleShort: 'Type' },\n { key: 'doors', type: 'number', titleLong: 'Doors', titleShort: 'Doors' },\n {\n key: 'energyConsumption',\n type: 'number',\n titleLong: 'Energy Consumption',\n titleShort: 'Energy',\n },\n {\n key: 'units',\n type: 'json',\n titleLong: 'Energy Unit',\n titleShort: 'Unit',\n },\n {\n key: 'serviceIntervals',\n type: 'jsonArray',\n titleLong: 'Service Intervals',\n titleShort: 'Intervals',\n },\n {\n key: 'isElectric',\n type: 'boolean',\n titleLong: 'Is Electric',\n titleShort: 'Electric',\n },\n {\n key: 'meta',\n type: 'jsonValue',\n titleLong: 'Meta Information',\n titleShort: 'Meta',\n },\n ] as ColumnCfg[],\n isHead: false,\n isRoot: false,\n isShared: true,\n } as TableCfg);\n\n const carGeneral = hip<ComponentsTable<CarGeneral>>({\n _tableCfg: carGeneralTableCfg._hash as string,\n _type: 'components',\n _data: [\n {\n brand: 'Volkswagen',\n type: 'Polo',\n doors: 5,\n energyConsumption: 7.4,\n units: {\n energy: 'l/100km',\n _hash: '',\n },\n serviceIntervals: [15000, 30000, 45000],\n isElectric: false,\n meta: {\n pressText: 'A popular compact car.',\n _hash: '',\n },\n _hash: '',\n },\n {\n brand: 'Volkswagen',\n type: 'Golf',\n doors: 3,\n energyConsumption: 6.2,\n units: {\n energy: 'l/100km',\n _hash: '',\n },\n serviceIntervals: [15000, 30000, 45000],\n isElectric: false,\n meta: {\n pressText: 'A well-known hatchback.',\n _hash: '',\n },\n _hash: '',\n },\n {\n brand: 'Audi',\n type: 'Q4 E-tron',\n doors: 5,\n energyConsumption: 18.0,\n units: {\n energy: 'kWh/100km',\n _hash: '',\n },\n serviceIntervals: [20000, 40000, 60000],\n isElectric: true,\n meta: [\n {\n pressText: 'A stylish electric SUV.',\n _hash: '',\n },\n {\n pressText: 'Combines performance with sustainability.',\n _hash: '',\n },\n ],\n _hash: '',\n },\n {\n brand: 'Audi',\n type: 'Q6 E-tron',\n doors: 5,\n energyConsumption: 16.0,\n units: {\n energy: 'kWh/100km',\n _hash: '',\n },\n serviceIntervals: [20000, 40000, 60000],\n isElectric: true,\n meta: [\n {\n pressText: 'A premium electric SUV with advanced features.',\n _hash: '',\n },\n {\n pressText: 'Offers a blend of luxury and eco-friendliness.',\n _hash: '',\n },\n ],\n _hash: '',\n },\n {\n brand: 'BMW',\n type: 'i4',\n doors: 5,\n energyConsumption: 19.5,\n units: {\n energy: 'kWh/100km',\n _hash: '',\n },\n serviceIntervals: [20000, 40000, 60000],\n isElectric: true,\n meta: [\n {\n pressText: 'A sporty electric sedan.',\n _hash: '',\n },\n {\n pressText: 'Delivers dynamic performance with zero emissions.',\n _hash: '',\n },\n ],\n _hash: '',\n },\n {\n brand: 'BMW',\n type: '3 Series',\n doors: 4,\n energyConsumption: 5.8,\n units: {\n energy: 'l/100km',\n _hash: '',\n },\n serviceIntervals: [15000, 30000, 45000],\n isElectric: false,\n meta: {\n pressText: 'A classic executive car.',\n _hash: '',\n },\n _hash: '',\n },\n {\n brand: 'Tesla',\n type: 'Model 3',\n doors: 4,\n energyConsumption: 15.0,\n units: {\n energy: 'kWh/100km',\n _hash: '',\n },\n serviceIntervals: [25000, 50000, 75000],\n isElectric: true,\n meta: {\n pressText: 'A revolutionary electric sedan.',\n _hash: '',\n },\n _hash: '',\n },\n {\n brand: 'Tesla',\n type: 'Model Y',\n doors: 5,\n energyConsumption: 16.5,\n units: {\n energy: 'kWh/100km',\n _hash: '',\n },\n serviceIntervals: [25000, 50000, 75000],\n isElectric: true,\n meta: {\n pressText: 'A versatile electric SUV.',\n _hash: '',\n },\n _hash: '',\n },\n {\n brand: 'Ford',\n type: 'Mustang Mach-E',\n doors: 5,\n energyConsumption: 17.0,\n units: {\n energy: 'kWh/100km',\n _hash: '',\n },\n serviceIntervals: [20000, 40000, 60000],\n isElectric: true,\n meta: {\n pressText: 'An electric SUV with Mustang heritage.',\n _hash: '',\n },\n _hash: '',\n },\n {\n brand: 'Chevrolet',\n type: 'Bolt EV',\n doors: 5,\n energyConsumption: 14.0,\n units: {\n energy: 'kWh/100km',\n _hash: '',\n },\n serviceIntervals: [20000, 40000, 60000],\n isElectric: true,\n meta: {\n pressText: 'An affordable electric hatchback.',\n _hash: '',\n },\n _hash: '',\n },\n {\n brand: 'Nissan',\n type: 'Leaf',\n doors: 5,\n energyConsumption: 15.5,\n units: {\n energy: 'kWh/100km',\n _hash: '',\n },\n serviceIntervals: [20000, 40000, 60000],\n isElectric: true,\n meta: {\n pressText: 'A pioneering electric vehicle.',\n _hash: '',\n },\n _hash: '',\n },\n {\n brand: 'Hyundai',\n type: 'Kona Electric',\n doors: 5,\n energyConsumption: 14.5,\n units: {\n energy: 'kWh/100km',\n _hash: '',\n },\n serviceIntervals: [20000, 40000, 60000],\n isElectric: true,\n meta: {\n pressText: 'A compact electric SUV.',\n _hash: '',\n },\n _hash: '',\n },\n ],\n _hash: '',\n }) as ComponentsTable<CarGeneral>;\n\n //CarDimensions\n //................................................................\n const carDimensionsTableCfg = hip<any>({\n key: 'carDimensions',\n type: 'components',\n columns: [\n { key: '_hash', type: 'string' },\n { key: 'height', type: 'number' },\n { key: 'width', type: 'number' },\n { key: 'length', type: 'number' },\n ],\n isHead: false,\n isRoot: false,\n isShared: true,\n }) as TableCfg;\n\n const carDimensions = hip<any>({\n _tableCfg: carDimensionsTableCfg._hash,\n _type: 'components',\n _data: [\n {\n height: 1400,\n width: 1800,\n length: 4000,\n _hash: '',\n },\n {\n height: 1450,\n width: 1850,\n length: 4100,\n _hash: '',\n },\n {\n height: 1600,\n width: 1900,\n length: 4500,\n _hash: '',\n },\n {\n height: 1650,\n width: 1950,\n length: 4700,\n _hash: '',\n },\n {\n height: 1500,\n width: 1820,\n length: 4200,\n _hash: '',\n },\n {\n height: 1550,\n width: 1880,\n length: 4300,\n _hash: '',\n },\n {\n height: 1450,\n width: 1830,\n length: 4150,\n _hash: '',\n },\n {\n height: 1700,\n width: 2000,\n length: 4800,\n _hash: '',\n },\n {\n height: 1350,\n width: 1750,\n length: 3900,\n _hash: '',\n },\n {\n height: 1750,\n width: 2050,\n length: 4900,\n _hash: '',\n },\n {\n height: 1600,\n width: 1920,\n length: 4600,\n _hash: '',\n },\n ],\n _hash: '',\n } as ComponentsTable<CarDimension>) as ComponentsTable<CarDimension>;\n\n //CarTechnical\n //................................................................\n const carTechnicalTableCfg = hip<any>({\n key: 'carTechnical',\n type: 'components',\n columns: [\n { key: '_hash', type: 'string' },\n { key: 'engine', type: 'string' },\n { key: 'transmission', type: 'string' },\n { key: 'gears', type: 'number' },\n {\n key: 'dimensions',\n type: 'jsonValue',\n ref: {\n tableKey: 'carDimensions',\n type: 'components',\n },\n } as ColumnCfg,\n { key: 'repairedByWorkshop', type: 'string' },\n ],\n isHead: false,\n isRoot: false,\n isShared: true,\n }) as TableCfg;\n\n const carTechnical = hip<any>({\n _tableCfg: carTechnicalTableCfg._hash,\n _type: 'components',\n _data: [\n {\n engine: 'Diesel',\n transmission: 'Manual',\n gears: 6,\n dimensions: carDimensions._data[0]._hash,\n _hash: '',\n },\n {\n engine: 'Petrol',\n transmission: 'Automatic',\n gears: 7,\n dimensions: carDimensions._data[1]._hash,\n repairedByWorkshop: 'Workshop A',\n _hash: '',\n },\n {\n engine: 'Electric',\n transmission: 'Single-Speed',\n gears: 1,\n dimensions: [\n carDimensions._data[1]._hash,\n carDimensions._data[2]._hash,\n ],\n _hash: '',\n },\n {\n engine: 'Electric',\n transmission: 'Single-Speed',\n gears: 1,\n dimensions: carDimensions._data[3]._hash,\n repairedByWorkshop: 'Workshop B',\n _hash: '',\n },\n {\n engine: 'Electric',\n transmission: 'Single-Speed',\n gears: 1,\n dimensions: carDimensions._data[4]._hash,\n _hash: '',\n },\n {\n engine: 'Petrol',\n transmission: 'Manual',\n gears: 6,\n dimensions: carDimensions._data[5]._hash,\n repairedByWorkshop: 'Workshop A',\n _hash: '',\n },\n {\n engine: 'Electric',\n transmission: 'Single-Speed',\n gears: 1,\n dimensions: carDimensions._data[6]._hash,\n _hash: '',\n },\n {\n engine: 'Electric',\n transmission: 'Single-Speed',\n gears: 1,\n dimensions: carDimensions._data[7]._hash,\n repairedByWorkshop: 'Workshop C',\n _hash: '',\n },\n {\n engine: 'Electric',\n transmission: 'Single-Speed',\n gears: 1,\n dimensions: carDimensions._data[8]._hash,\n _hash: '',\n },\n {\n engine: 'Electric',\n transmission: 'Single-Speed',\n gears: 1,\n dimensions: carDimensions._data[9]._hash,\n repairedByWorkshop: 'Workshop B',\n _hash: '',\n },\n {\n engine: 'Electric',\n transmission: 'Single-Speed',\n gears: 1,\n dimensions: carDimensions._data[10]._hash,\n _hash: '',\n },\n ],\n _hash: '',\n }) as ComponentsTable<Json>;\n\n //CarColor\n //................................................................\n const carColorTableCfg = hip<any>({\n key: 'carColor',\n type: 'components',\n columns: [\n { key: '_hash', type: 'string' },\n { key: 'sides', type: 'string' },\n { key: 'roof', type: 'string' },\n { key: 'highlights', type: 'string' },\n ],\n isHead: false,\n isRoot: false,\n isShared: true,\n }) as TableCfg;\n\n const carColor = hip<any>({\n _tableCfg: carColorTableCfg._hash,\n _type: 'components',\n _data: [\n {\n sides: 'green',\n roof: 'white',\n highlights: 'chrome',\n _hash: '',\n },\n {\n sides: 'blue',\n roof: 'black',\n highlights: 'chrome',\n _hash: '',\n },\n {\n sides: 'red',\n roof: 'red',\n highlights: 'black',\n _hash: '',\n },\n {\n sides: 'silver',\n roof: 'silver',\n highlights: 'chrome',\n _hash: '',\n },\n {\n sides: 'black',\n roof: 'black',\n highlights: 'black',\n _hash: '',\n },\n {\n sides: 'white',\n roof: 'white',\n highlights: 'chrome',\n _hash: '',\n },\n {\n sides: 'grey',\n roof: 'black',\n highlights: 'chrome',\n _hash: '',\n },\n {\n sides: 'red',\n roof: 'white',\n highlights: 'black',\n _hash: '',\n },\n ],\n _hash: '',\n }) as ComponentsTable<Json>;\n\n //CarLayers and CarCake\n //................................................................\n const carGeneralLayerTableCfg = hip<TableCfg>(\n createLayerTableCfg('carGeneralLayer'),\n ) as TableCfg;\n\n const carGeneralLayerData: Array<Layer> = [\n {\n add: {\n VIN1: carGeneral._data[0]._hash,\n VIN2: carGeneral._data[1]._hash,\n VIN3: carGeneral._data[2]._hash,\n VIN4: carGeneral._data[3]._hash,\n VIN5: carGeneral._data[4]._hash,\n VIN6: carGeneral._data[5]._hash,\n VIN7: carGeneral._data[6]._hash,\n VIN8: carGeneral._data[7]._hash,\n _hash: '',\n },\n sliceIdsTable: 'carSliceId',\n sliceIdsTableRow: carSliceId._data[0]._hash as string,\n componentsTable: 'carGeneral',\n _hash: '',\n } as Layer,\n {\n add: {\n VIN9: carGeneral._data[8]._hash,\n VIN10: carGeneral._data[9]._hash,\n _hash: '',\n },\n sliceIdsTable: 'carSliceId',\n sliceIdsTableRow: carSliceId._data[1]._hash as string,\n componentsTable: 'carGeneral',\n _hash: '',\n },\n {\n add: {\n VIN11: carGeneral._data[10]._hash,\n VIN12: carGeneral._data[11]._hash,\n _hash: '',\n },\n sliceIdsTable: 'carSliceId',\n sliceIdsTableRow: carSliceId._data[2]._hash as string,\n componentsTable: 'carGeneral',\n _hash: '',\n },\n ].map((layer) => hsh<Layer>(layer as Layer));\n\n const carGeneralLayer = hip<any>({\n _tableCfg: carGeneralLayerTableCfg._hash,\n _type: 'layers',\n _data: chainLayers(carGeneralLayerData),\n _hash: '',\n }) as LayersTable;\n\n const carTechnicalLayerTableCfg = hip<TableCfg>(\n createLayerTableCfg('carTechnicalLayer'),\n ) as TableCfg;\n\n const carTechnicalLayerData: Array<Layer> = [\n {\n add: {\n VIN1: carTechnical._data[0]._hash,\n VIN2: carTechnical._data[1]._hash,\n VIN3: carTechnical._data[2]._hash,\n VIN4: carTechnical._data[2]._hash,\n VIN5: carTechnical._data[4]._hash,\n VIN6: carTechnical._data[5]._hash,\n VIN7: carTechnical._data[6]._hash,\n VIN8: carTechnical._data[2]._hash,\n _hash: '',\n },\n sliceIdsTable: 'carSliceId',\n sliceIdsTableRow: carSliceId._data[0]._hash,\n componentsTable: 'carTechnical',\n _hash: '',\n } as Layer,\n {\n add: {\n VIN9: carTechnical._data[7]._hash,\n VIN10: carTechnical._data[8]._hash,\n _hash: '',\n },\n sliceIdsTable: 'carSliceId',\n sliceIdsTableRow: carSliceId._data[1]._hash,\n componentsTable: 'carTechnical',\n _hash: '',\n } as Layer,\n {\n add: {\n VIN11: carTechnical._data[9]._hash,\n VIN12: carTechnical._data[10]._hash,\n _hash: '',\n },\n sliceIdsTable: 'carSliceId',\n sliceIdsTableRow: carSliceId._data[2]._hash,\n componentsTable: 'carTechnical',\n _hash: '',\n } as Layer,\n ].map((layer) => hsh<Layer>(layer as Layer));\n\n const carTechnicalLayer = hip<any>({\n _tableCfg: carTechnicalLayerTableCfg._hash,\n _type: 'layers',\n _data: chainLayers(carTechnicalLayerData),\n _hash: '',\n }) as LayersTable;\n\n const carColorLayerTableCfg = hip<TableCfg>(\n createLayerTableCfg('carColorLayer'),\n ) as TableCfg;\n\n const carColorLayerData: Array<Layer> = [\n {\n add: {\n VIN1: carColor._data[0]._hash,\n VIN2: carColor._data[1]._hash,\n VIN3: carColor._data[2]._hash,\n VIN4: carColor._data[3]._hash,\n VIN5: carColor._data[4]._hash,\n VIN6: carColor._data[5]._hash,\n VIN7: carColor._data[6]._hash,\n VIN8: carColor._data[7]._hash,\n _hash: '',\n },\n sliceIdsTable: 'carSliceId',\n sliceIdsTableRow: carSliceId._data[0]._hash,\n componentsTable: 'carColor',\n _hash: '',\n } as Layer,\n {\n add: {\n VIN9: carColor._data[3]._hash,\n VIN10: carColor._data[3]._hash,\n _hash: '',\n },\n sliceIdsTable: 'carSliceId',\n sliceIdsTableRow: carSliceId._data[1]._hash,\n componentsTable: 'carColor',\n _hash: '',\n } as Layer,\n {\n add: {\n VIN11: carColor._data[7]._hash,\n VIN12: carColor._data[4]._hash,\n _hash: '',\n },\n sliceIdsTable: 'carSliceId',\n sliceIdsTableRow: carSliceId._data[2]._hash,\n componentsTable: 'carColor',\n _hash: '',\n } as Layer,\n ].map((layer) => hsh<Layer>(layer as Layer));\n\n const carColorLayer = hip<any>({\n _tableCfg: carColorLayerTableCfg._hash,\n _type: 'layers',\n _data: chainLayers(carColorLayerData),\n _hash: '',\n }) as LayersTable;\n\n const carCakeTableCfg = hip<TableCfg>(\n createCakeTableCfg('carCake'),\n ) as TableCfg;\n\n const carCake = hip<any>({\n _tableCfg: carCakeTableCfg._hash,\n _type: 'cakes',\n _data: [\n {\n sliceIdsTable: 'carSliceId',\n sliceIdsRow: carSliceId._data[0]._hash,\n layers: {\n carGeneralLayer: carGeneralLayer._data[0]._hash,\n carTechnicalLayer: carTechnicalLayer._data[0]._hash,\n carColorLayer: carColorLayer._data[0]._hash,\n },\n },\n {\n sliceIdsTable: 'carSliceId',\n sliceIdsRow: carSliceId._data[1]._hash,\n layers: {\n carGeneralLayer: carGeneralLayer._data[1]._hash,\n carTechnicalLayer: carTechnicalLayer._data[1]._hash,\n carColorLayer: carColorLayer._data[1]._hash,\n },\n },\n {\n sliceIdsTable: 'carSliceId',\n sliceIdsRow: carSliceId._data[2]._hash,\n layers: {\n carGeneralLayer: carGeneralLayer._data[2]._hash,\n carTechnicalLayer: carTechnicalLayer._data[2]._hash,\n carColorLayer: carColorLayer._data[2]._hash,\n },\n },\n ],\n }) as CakesTable;\n\n //................................................................\n //Series Data Tables\n //................................................................\n\n //SeriesSliceId\n //................................................................\n\n const seriesSliceIdTableCfg = hip<TableCfg>(\n createSliceIdsTableCfg('seriesSliceId'),\n ) as TableCfg;\n\n const seriesSliceIdData: Array<SliceIds> = [\n {\n add: ['Serie0', 'Serie1', 'Serie2', 'Serie3'],\n _hash: '',\n } as SliceIds,\n {\n add: ['Serie4', 'Serie5', 'Serie6', 'Serie7'],\n _hash: '',\n } as SliceIds,\n {\n add: ['Serie8', 'Serie9', 'Serie10', 'Serie11'],\n _hash: '',\n } as SliceIds,\n ].map((sliceIds) => hsh<SliceIds>(sliceIds as SliceIds));\n\n const seriesSliceId = hip<any>({\n _tableCfg: seriesSliceIdTableCfg._hash,\n _type: 'sliceIds',\n _data: chainSliceIds(seriesSliceIdData),\n _hash: '',\n }) as SliceIdsTable;\n\n //SeriesGeneral\n //................................................................\n const seriesGeneralTableCfg = hip<TableCfg>({\n key: 'seriesGeneral',\n type: 'components',\n columns: [\n { key: '_hash', type: 'string', titleShort: 'Hash', titleLong: 'Hash' },\n { key: 'name', type: 'string', titleShort: 'Name', titleLong: 'Name' },\n ] as ColumnCfg[],\n isHead: false,\n isRoot: false,\n isShared: true,\n } as TableCfg);\n\n const seriesGeneral = hip<ComponentsTable<Json>>({\n _tableCfg: seriesGeneralTableCfg._hash as string,\n _type: 'components',\n _data: [\n {\n name: 'Polo',\n _hash: '',\n },\n {\n name: 'Golf',\n _hash: '',\n },\n {\n name: 'Q4',\n _hash: '',\n },\n {\n name: 'Q6',\n _hash: '',\n },\n {\n name: 'i4',\n _hash: '',\n },\n {\n name: '3',\n _hash: '',\n },\n {\n name: 'Model 3',\n _hash: '',\n },\n {\n name: 'Model Y',\n _hash: '',\n },\n {\n name: 'Mustang',\n _hash: '',\n },\n {\n name: 'Bolt',\n _hash: '',\n },\n {\n name: 'Leaf',\n _hash: '',\n },\n {\n name: 'Kona',\n _hash: '',\n },\n ],\n _hash: '',\n }) as ComponentsTable<Json>;\n\n //................................................................\n //SeriesCars\n\n const seriesCarsTableCfg = hip<TableCfg>({\n key: 'seriesCars',\n type: 'components',\n columns: [\n { key: '_hash', type: 'string', titleShort: 'Hash', titleLong: 'Hash' },\n {\n key: 'cars',\n type: 'jsonArray',\n titleShort: 'Cars',\n titleLong: 'Cars References',\n ref: {\n tableKey: 'carCake',\n type: 'cakes',\n },\n } as ColumnCfg,\n ] as ColumnCfg[],\n isHead: false,\n isRoot: false,\n isShared: true,\n } as TableCfg);\n\n const seriesCars = hip<\n ComponentsTable<{ _hash: string; cars: CakeReference[] }>\n >({\n _tableCfg: seriesCarsTableCfg._hash as string,\n _type: 'components',\n _data: [\n {\n cars: [\n {\n ref: carCake._data[2]._hash as string,\n sliceIds: ['VIN1'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n cars: [\n {\n ref: carCake._data[2]._hash as string,\n sliceIds: ['VIN2'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n cars: [\n {\n ref: carCake._data[0]._hash as string,\n sliceIds: ['VIN3'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n cars: [\n {\n ref: carCake._data[0]._hash as string,\n sliceIds: ['VIN4'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n cars: [\n {\n ref: carCake._data[1]._hash as string,\n sliceIds: ['VIN5'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n cars: [\n {\n ref: carCake._data[1]._hash as string,\n sliceIds: ['VIN6'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n cars: [\n {\n ref: carCake._data[2]._hash as string,\n sliceIds: ['VIN7'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n cars: [\n {\n ref: carCake._data[2]._hash as string,\n sliceIds: ['VIN8'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n cars: [\n {\n ref: carCake._data[2]._hash as string,\n sliceIds: ['VIN9'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n cars: [\n {\n ref: carCake._data[2]._hash as string,\n sliceIds: ['VIN10'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n cars: [\n {\n ref: carCake._data[2]._hash as string,\n sliceIds: ['VIN11'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n cars: [\n {\n ref: carCake._data[2]._hash as string,\n sliceIds: ['VIN12'] as SliceId[],\n },\n ],\n _hash: '',\n },\n ],\n _hash: '',\n });\n\n //SeriesLayers and SeriesCake\n //................................................................\n\n const seriesGeneralLayerTableCfg = hip<TableCfg>(\n createLayerTableCfg('seriesGeneralLayer'),\n ) as TableCfg;\n\n const seriesGeneralLayerData: Array<Layer> = [\n {\n add: {\n Serie0: seriesGeneral._data[0]._hash,\n Serie1: seriesGeneral._data[1]._hash,\n Serie2: seriesGeneral._data[2]._hash,\n Serie3: seriesGeneral._data[3]._hash,\n _hash: '',\n },\n sliceIdsTable: 'seriesSliceId',\n sliceIdsTableRow: seriesSliceId._data[0]._hash as string,\n componentsTable: 'seriesGeneral',\n _hash: '',\n } as Layer,\n {\n add: {\n Serie4: seriesGeneral._data[4]._hash,\n Serie5: seriesGeneral._data[5]._hash,\n Serie6: seriesGeneral._data[6]._hash,\n Serie7: seriesGeneral._data[7]._hash,\n _hash: '',\n },\n sliceIdsTable: 'seriesSliceId',\n sliceIdsTableRow: seriesSliceId._data[1]._hash as string,\n componentsTable: 'seriesGeneral',\n _hash: '',\n },\n {\n add: {\n Serie8: seriesGeneral._data[8]._hash,\n Serie9: seriesGeneral._data[9]._hash,\n Serie10: seriesGeneral._data[10]._hash,\n Serie11: seriesGeneral._data[11]._hash,\n _hash: '',\n },\n sliceIdsTable: 'seriesSliceId',\n sliceIdsTableRow: seriesSliceId._data[2]._hash as string,\n componentsTable: 'seriesGeneral',\n _hash: '',\n },\n ].map((layer) => hsh<Layer>(layer as Layer));\n\n const seriesGeneralLayer = hip<any>({\n _tableCfg: seriesGeneralLayerTableCfg._hash,\n _type: 'layers',\n _data: chainLayers(seriesGeneralLayerData),\n _hash: '',\n }) as LayersTable;\n\n const seriesCarsLayerTableCfg = hip<TableCfg>(\n createLayerTableCfg('seriesCarsLayer'),\n ) as TableCfg;\n\n const seriesCarsLayerData: Array<Layer> = [\n {\n add: {\n Serie0: seriesCars._data[0]._hash,\n Serie1: seriesCars._data[1]._hash,\n Serie2: seriesCars._data[2]._hash,\n Serie3: seriesCars._data[3]._hash,\n _hash: '',\n },\n sliceIdsTable: 'seriesSliceId',\n sliceIdsTableRow: seriesSliceId._data[0]._hash,\n componentsTable: 'seriesCars',\n _hash: '',\n } as Layer,\n {\n add: {\n Serie4: seriesCars._data[4]._hash,\n Serie5: seriesCars._data[5]._hash,\n Serie6: seriesCars._data[6]._hash,\n Serie7: seriesCars._data[7]._hash,\n _hash: '',\n },\n sliceIdsTable: 'seriesSliceId',\n sliceIdsTableRow: seriesSliceId._data[1]._hash,\n componentsTable: 'seriesCars',\n _hash: '',\n } as Layer,\n {\n add: {\n Serie8: seriesCars._data[8]._hash,\n Serie9: seriesCars._data[9]._hash,\n Serie10: seriesCars._data[10]._hash,\n Serie11: seriesCars._data[11]._hash,\n _hash: '',\n },\n sliceIdsTable: 'seriesSliceId',\n sliceIdsTableRow: seriesSliceId._data[2]._hash,\n componentsTable: 'seriesCars',\n _hash: '',\n } as Layer,\n ].map((layer) => hsh<Layer>(layer as Layer));\n\n const seriesCarsLayer = hip<any>({\n _tableCfg: seriesCarsLayerTableCfg._hash,\n _type: 'layers',\n _data: chainLayers(seriesCarsLayerData),\n });\n\n const seriesCakeTableCfg = hip<TableCfg>(\n createCakeTableCfg('seriesCake'),\n ) as TableCfg;\n\n const seriesCake = hip<any>({\n _tableCfg: seriesCakeTableCfg._hash,\n _type: 'cakes',\n _data: [\n {\n sliceIdsTable: 'seriesSliceId',\n sliceIdsRow: seriesSliceId._data[0]._hash,\n layers: {\n seriesGeneralLayer: seriesGeneralLayer._data[0]._hash,\n seriesCarsLayer: seriesCarsLayer._data[0]._hash,\n },\n },\n {\n sliceIdsTable: 'seriesSliceId',\n sliceIdsRow: seriesSliceId._data[1]._hash,\n layers: {\n seriesGeneralLayer: seriesGeneralLayer._data[1]._hash,\n seriesCarsLayer: seriesCarsLayer._data[1]._hash,\n },\n },\n {\n sliceIdsTable: 'seriesSliceId',\n sliceIdsRow: seriesSliceId._data[2]._hash,\n layers: {\n seriesGeneralLayer: seriesGeneralLayer._data[2]._hash,\n seriesCarsLayer: seriesCarsLayer._data[2]._hash,\n },\n },\n ],\n }) as CakesTable;\n\n //................................................................\n //Series Data Tables\n //................................................................\n\n //SeriesSliceId\n //................................................................\n\n const catalogSliceIdTableCfg = hip<TableCfg>(\n createSliceIdsTableCfg('catalogSliceId'),\n ) as TableCfg;\n\n const catalogSliceIdData: Array<SliceIds> = [\n {\n add: ['Catalog0', 'Catalog1'],\n _hash: '',\n } as SliceIds,\n ].map((sliceIds) => hsh<SliceIds>(sliceIds as SliceIds));\n\n const catalogSliceId = hip<any>({\n _tableCfg: catalogSliceIdTableCfg._hash,\n _type: 'sliceIds',\n _data: chainSliceIds(catalogSliceIdData),\n _hash: '',\n }) as SliceIdsTable;\n\n //CatalogSeries\n //................................................................\n const catalogSeriesTableCfg = hip<TableCfg>({\n key: 'catalogSeries',\n type: 'components',\n columns: [\n { key: '_hash', type: 'string', titleShort: 'Hash', titleLong: 'Hash' },\n {\n key: 'series',\n type: 'jsonArray',\n titleShort: 'Series',\n titleLong: 'Series References',\n ref: {\n tableKey: 'seriesCake',\n type: 'cakes',\n },\n } as ColumnCfg,\n ] as ColumnCfg[],\n isHead: false,\n isRoot: false,\n isShared: true,\n } as TableCfg);\n\n const catalogSeries = hip<\n ComponentsTable<{ _hash: string; series: CakeReference[] }>\n >({\n _tableCfg: catalogSeriesTableCfg._hash as string,\n _type: 'components',\n _data: [\n {\n series: [\n {\n ref: seriesCake._data[0]._hash as string,\n sliceIds: ['Serie0', 'Serie1', 'Serie2', 'Serie3'] as SliceId[],\n },\n {\n ref: seriesCake._data[1]._hash as string,\n sliceIds: ['Serie4', 'Serie5', 'Serie6', 'Serie7'] as SliceId[],\n },\n ],\n _hash: '',\n },\n {\n series: [\n {\n ref: seriesCake._data[2]._hash as string,\n },\n ],\n _hash: '',\n },\n ],\n _hash: '',\n });\n\n //CatalogLayers and CatalogCake\n //................................................................\n\n const catalogSeriesLayerTableCfg = hip<TableCfg>(\n createLayerTableCfg('catalogSeriesLayer'),\n ) as TableCfg;\n\n const catalogSeriesLayerData: Array<Layer> = [\n {\n add: {\n Catalog0: catalogSeries._data[0]._hash,\n Catalog1: catalogSeries._data[1]._hash,\n _hash: '',\n },\n sliceIdsTable: 'catalogSliceId',\n sliceIdsTableRow: catalogSliceId._data[0]._hash as string,\n componentsTable: 'catalogSeries',\n _hash: '',\n } as Layer,\n ].map((layer) => hsh<Layer>(layer as Layer));\n\n const catalogSeriesLayer = hip<any>({\n _tableCfg: catalogSeriesLayerTableCfg._hash,\n _type: 'layers',\n _data: chainLayers(catalogSeriesLayerData),\n _hash: '',\n }) as LayersTable;\n\n const catalogCakeTableCfg = hip<TableCfg>(\n createCakeTableCfg('catalogCake'),\n ) as TableCfg;\n\n const catalogCake = hip<any>({\n _tableCfg: catalogCakeTableCfg._hash,\n _type: 'cakes',\n _data: [\n {\n sliceIdsTable: 'catalogSliceId',\n sliceIdsRow: catalogSliceId._data[0]._hash,\n layers: {\n catalogSeriesLayer: catalogSeriesLayer._data[0]._hash,\n },\n },\n ],\n }) as CakesTable;\n\n //................................................................\n //TablesCfg\n //................................................................\n const tableCfgs = {\n _data: [\n carSliceIdTableCfg,\n carGeneralTableCfg,\n carDimensionsTableCfg,\n carTechnicalTableCfg,\n carColorTableCfg,\n carGeneralLayerTableCfg,\n carTechnicalLayerTableCfg,\n carColorLayerTableCfg,\n carCakeTableCfg,\n seriesSliceIdTableCfg,\n seriesGeneralTableCfg,\n seriesCarsTableCfg,\n seriesGeneralLayerTableCfg,\n seriesCarsLayerTableCfg,\n seriesCakeTableCfg,\n catalogSliceIdTableCfg,\n catalogSeriesTableCfg,\n catalogSeriesLayerTableCfg,\n catalogCakeTableCfg,\n ],\n } as TablesCfgTable;\n\n const staticExample = {\n carSliceId,\n carGeneral,\n carDimensions,\n carTechnical,\n carColor,\n carGeneralLayer,\n carTechnicalLayer,\n carColorLayer,\n carCake,\n seriesSliceId,\n seriesGeneral,\n seriesCars,\n seriesGeneralLayer,\n seriesCarsLayer,\n seriesCake,\n catalogSliceId,\n catalogSeries,\n catalogSeriesLayer,\n catalogCake,\n tableCfgs,\n };\n\n return staticExample;\n};\n"],"names":["SliceIds","result","i","rljson","tree","cell","sliceIds","timeId","processor","staticExample"],"mappings":";;;;;;AAcO,MAAM,UAAU;AAAA,EASrB,YACmB,KACA,QACA,SACjB;AAHiB,SAAA,MAAA;AACA,SAAA,SAAA;AACA,SAAA,UAAA;AAEjB,SAAK,UAAU,OAAA;AAEf,SAAK,MAAA;AAAA,EACP;AAAA,EAhBQ;AAAA,EACA,aAAkC,CAAA;AAAA,EAElC,eAAwB;AAAA,EAExB,gCAA6B,IAAA;AAAA,EAC7B,oCAAiC,IAAA;AAAA,EAYzC,KAAK,KAAa;AAChB,QAAI,KAAK,UAAU,IAAI,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