@rljson/rljson 0.0.12 → 0.0.15

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/example.d.ts CHANGED
@@ -1,31 +1,44 @@
1
1
  import { Rljson } from './rljson.ts';
2
- /**
3
- * Provides Rljson examples
4
- */
5
2
  export declare class Example {
6
- /**
7
- * Returns the Rljson bakery example
8
- */
9
- static bakery(): Rljson;
10
- /**
11
- * Returns an Rljson object with one row containing all JSON types
12
- */
13
- static withAllJsonTypes(): Rljson;
14
- /**
15
- * Returns an empty Rljson object
16
- */
17
- static empty(): Rljson;
18
- /**
19
- * Returns an Rljson with a table containing all combinations of true and
20
- * false. This is useful for testing search operators.
21
- */
22
- static binary(): Rljson;
23
- /**
24
- * An more complex example containing an table with multiple rows
25
- */
26
- static multiRow(): Rljson;
27
- /**
28
- * Returns an Rljson object with a broken table name
29
- */
30
- static withBrokenTableName(): Rljson;
3
+ static readonly ok: {
4
+ bakery: () => Rljson;
5
+ empty: () => Rljson;
6
+ binary: () => Rljson;
7
+ singleRow: () => Rljson;
8
+ multipleRows: () => Rljson;
9
+ singleRef: () => Rljson;
10
+ complete: () => Rljson;
11
+ };
12
+ static readonly broken: {
13
+ base: {
14
+ brokenTableName: () => {
15
+ brok$en: {
16
+ _type: string;
17
+ _data: never[];
18
+ };
19
+ };
20
+ missingData: () => Rljson;
21
+ dataNotBeingAnArray: () => Rljson;
22
+ missingRef: () => Rljson;
23
+ missingReferencedTable: () => Rljson;
24
+ };
25
+ tableCfg: {
26
+ wrongType: () => import('@rljson/hash').Hashed<Rljson>;
27
+ };
28
+ collections: {
29
+ missingBase: () => Rljson;
30
+ missingIdSet: () => Rljson;
31
+ missingAssignedPropertyTable: () => Rljson;
32
+ missingAssignedProperty: () => Rljson;
33
+ };
34
+ cakes: {
35
+ missingIdSet: () => Rljson;
36
+ missingCollectionsTable: () => Rljson;
37
+ missingLayerCollection: () => Rljson;
38
+ };
39
+ buffets: {
40
+ missingTable: () => Rljson;
41
+ missingItems: () => Rljson;
42
+ };
43
+ };
31
44
  }
package/dist/index.d.ts CHANGED
@@ -4,5 +4,6 @@ export * from './content/collection.ts';
4
4
  export * from './content/id-set.ts';
5
5
  export * from './content/properties.ts';
6
6
  export * from './example.ts';
7
+ export * from './rljson-indexed.ts';
7
8
  export * from './rljson.ts';
8
9
  export * from './typedefs.ts';
@@ -0,0 +1,19 @@
1
+ import { Json } from '@rljson/json';
2
+ import { Rljson } from './rljson.ts';
3
+ /**
4
+ * An Rljson object where all tables' rows are indexed by their hash.
5
+ */
6
+ export interface RljsonIndexed {
7
+ [tableName: string]: {
8
+ _data: {
9
+ [rowHash: string]: Json;
10
+ };
11
+ };
12
+ [key: `_${string}`]: any;
13
+ }
14
+ /**
15
+ * Returns an rljson where all tables' rows are indexed by their hash.
16
+ * @param rljson - The Rljson object to index
17
+ * @returns The indexed Rljson object
18
+ */
19
+ export declare const rljsonIndexed: (rljson: Rljson) => RljsonIndexed;
package/dist/rljson.d.ts CHANGED
@@ -4,7 +4,8 @@ import { CakesTable } from './content/cake.ts';
4
4
  import { CollectionsTable } from './content/collection.ts';
5
5
  import { IdSetsTable } from './content/id-set.ts';
6
6
  import { PropertiesTable } from './content/properties.ts';
7
- import { ContentType, TableName } from './typedefs.ts';
7
+ import { TableCfgRef, TablesCfgTable } from './content/table-cfg.ts';
8
+ import { ContentType, Ref, TableName } from './typedefs.ts';
8
9
  export declare const reservedFieldNames: string[];
9
10
  export declare const reservedTableNames: string[];
10
11
  /**
@@ -12,8 +13,33 @@ export declare const reservedTableNames: string[];
12
13
  */
13
14
  export type TableType = BuffetsTable | PropertiesTable<any> | CollectionsTable | IdSetsTable | CakesTable;
14
15
  /** The rljson data format */
15
- export type Rljson = {
16
+ export interface Rljson extends Json {
16
17
  [tableId: TableName]: TableType;
18
+ }
19
+ /**
20
+ * Rljson set with private fields
21
+ */
22
+ export type RljsonPrivate = {
23
+ /**
24
+ * The hash of the Rljson object
25
+ */
26
+ _hash: string;
27
+ /**
28
+ * Contains id sets used accross the Rljson object
29
+ */
30
+ _idSet?: IdSetsTable;
31
+ /**
32
+ * References that are not part of the Rljson object
33
+ */
34
+ _externalRefs?: Ref[];
35
+ /**
36
+ * Referenced tables that are not part of the Rljson object
37
+ */
38
+ _externalTables?: Ref[];
39
+ /**
40
+ * Column configurations used accross the Rljson object
41
+ */
42
+ _tableCfgs?: TablesCfgTable;
17
43
  };
18
44
  /** An example rljson object */
19
45
  export declare const exampleRljson: () => Rljson;
@@ -21,6 +47,15 @@ export declare const exampleRljson: () => Rljson;
21
47
  export interface RljsonTable<Data extends Json, Type extends ContentType> extends Json {
22
48
  /** The data rows of the table */
23
49
  _data: Data[];
24
- /** The type of the table */
50
+ /** The type of the table. If not set, the type is "properties" */
25
51
  _type: Type;
52
+ /** The columns configuration of the table */
53
+ _tableCfg?: TableCfgRef;
26
54
  }
55
+ /**
56
+ * Iterates over all tables of an Rljson object.
57
+ * Skips private members starting with _
58
+ * @param rljson - The Rljson object to iterate
59
+ * @param callback - The callback to call for each table
60
+ */
61
+ export declare const iterateTables: (rljson: Rljson, callback: (tableName: string, table: TableType) => void) => void;