@rljson/db 0.0.10 → 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.
@@ -19,7 +19,6 @@ export declare class CakeController<N extends string, C extends Cake> extends Ba
19
19
  protected readonly _core: Core;
20
20
  protected readonly _tableKey: TableKey;
21
21
  private _refs?;
22
- private _table;
23
22
  constructor(_core: Core, _tableKey: TableKey, _refs?: CakeControllerRefs | undefined);
24
23
  private _baseLayers;
25
24
  init(): Promise<void>;
@@ -20,7 +20,7 @@ export type ControllerChildProperty = {
20
20
  * @property {ControllerRunFn<N>} insert - Function to execute a command on the table.
21
21
  * @property {() => Promise<void>} init - Initializes the controller.
22
22
  * @property {() => Promise<T>} table - Retrieves the current state of the table.
23
- * @property {(where: string | { [column: string]: JsonValue }) => Promise<Rljson>} get - Fetches data from the table based on a condition.
23
+ * @property {(where: string | { [column: string]: JsonValue }, filter: Json | undefined, path: string | undefined) => Promise<Rljson>} get - Fetches data from the table based on a condition.
24
24
  * @property {(where: string | Json, filter?: Json) => Promise<Array<{ tableKey: TableKey; ref: Ref }>>} getChildRefs - Retrieves references to child entries in related tables based on a condition.
25
25
  * @param {string | Json }} where - The condition to filter the data.
26
26
  * @returns {Promise<Json[] | null>} A promise that resolves to an array of JSON objects or null if no data is found.
@@ -30,7 +30,7 @@ export interface Controller<T extends TableType, C extends JsonValue, N extends
30
30
  insert: ControllerRunFn<N, C>;
31
31
  init(): Promise<void>;
32
32
  table(): Promise<T>;
33
- get(where: string | Json, filter?: Json): Promise<Rljson>;
33
+ get(where: string | Json, filter?: Json, path?: string): Promise<Rljson>;
34
34
  getChildRefs(where: string | Json, filter?: Json): Promise<ControllerChildProperty[]>;
35
35
  filterRow(row: Json, key: string, value: JsonValue): Promise<boolean>;
36
36
  contentType(): ContentType;
@@ -0,0 +1,18 @@
1
+ import { Json } from '@rljson/json';
2
+ import { InsertCommand, InsertHistoryRow, Ref, Rljson, TableKey, Tree, TreesTable } from '@rljson/rljson';
3
+ import { Core } from '../core.ts';
4
+ import { Cell } from '../db.ts';
5
+ import { BaseController } from './base-controller.ts';
6
+ import { Controller, ControllerChildProperty } from './controller.ts';
7
+ export declare class TreeController<N extends string, C extends Tree> extends BaseController<TreesTable, C> implements Controller<TreesTable, C, N> {
8
+ protected readonly _core: Core;
9
+ protected readonly _tableKey: TableKey;
10
+ constructor(_core: Core, _tableKey: TableKey);
11
+ init(): Promise<void>;
12
+ insert(command: InsertCommand, value: Tree, origin?: Ref): Promise<InsertHistoryRow<any>[]>;
13
+ get(where: string | Json, filter?: Json, path?: string): Promise<Rljson>;
14
+ buildTreeFromTrees(trees: Tree[]): Promise<Json>;
15
+ buildCellsFromTree(trees: Tree[]): Promise<Cell[]>;
16
+ getChildRefs(where: string | Json, filter?: Json): Promise<ControllerChildProperty[]>;
17
+ filterRow(): Promise<boolean>;
18
+ }
package/dist/db.d.ts CHANGED
@@ -17,6 +17,11 @@ export type Container = {
17
17
  tree: Json;
18
18
  cell: Cell[];
19
19
  };
20
+ export type GetOptions = {
21
+ skipRljson?: boolean;
22
+ skipTree?: boolean;
23
+ skipCell?: boolean;
24
+ };
20
25
  export type ContainerWithControllers = Container & {
21
26
  controllers: Record<string, Controller<any, any, any>>;
22
27
  };
@@ -48,7 +53,7 @@ export declare class Db {
48
53
  * @returns An array of Rljson objects matching the route and filter
49
54
  * @throws {Error} If the route is not valid or if any controller cannot be created
50
55
  */
51
- get(route: Route, where: string | Json, filter?: ControllerChildProperty[], sliceIds?: SliceId[]): Promise<ContainerWithControllers>;
56
+ get(route: Route, where: string | Json, filter?: ControllerChildProperty[], sliceIds?: SliceId[], options?: GetOptions): Promise<ContainerWithControllers>;
52
57
  /**
53
58
  * Resolves the route and returns corresponding data for any segment of the route,
54
59
  * matching recursive filters and where clauses
@@ -58,9 +63,11 @@ export declare class Db {
58
63
  * @param controllers - The controllers to use for fetching data
59
64
  * @param filter - Optional filter to apply to the data at the current route segment
60
65
  * @param sliceIds - Optional slice IDs to filter the data at the current route segment
66
+ * @param routeAccumulator - The accumulated route up to the current segment
67
+ * @param options - Additional options for fetching data
61
68
  * @returns - An Rljson object matching the route and filters
62
69
  */
63
- _get(route: Route, where: string | Json, controllers: Record<string, Controller<any, any, any>>, filter?: ControllerChildProperty[], sliceIds?: SliceId[], routeAccumulator?: Route): Promise<Container>;
70
+ _get(route: Route, where: string | Json, controllers: Record<string, Controller<any, any, any>>, filter?: ControllerChildProperty[], sliceIds?: SliceId[], routeAccumulator?: Route, options?: GetOptions): Promise<Container>;
64
71
  /**
65
72
  * Get the reference (hash) of a route segment, considering default refs and insertHistory refs
66
73
  * @param segment - The route segment to get the reference for
@@ -124,12 +131,6 @@ export declare class Db {
124
131
  * @throws {Error} If the InsertHistory table does not exist
125
132
  */
126
133
  private _writeInsertHistory;
127
- /**
128
- * Add a head revision for a cake
129
- * @param cakeKey - The cake table key
130
- * @param cakeRef - The cake reference
131
- */
132
- addHeadRevision(cakeKey: string, cakeRef: Ref): Promise<InsertHistoryRow<string>[]>;
133
134
  /**
134
135
  * Add a multiEdit
135
136
  * @param cakeKey - The cake table key