@rljson/rljson 0.0.65 → 0.0.67

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.
@@ -25,6 +25,13 @@ export interface ColumnCfg extends Json {
25
25
  * An optional short title of the column
26
26
  */
27
27
  titleShort: string;
28
+ /**
29
+ * Defines if the column is reference column to another table (foreign key)
30
+ */
31
+ ref?: {
32
+ tableKey: TableKey;
33
+ columnKey?: ColumnKey;
34
+ };
28
35
  }
29
36
  /**
30
37
  * A column configuration with route
@@ -4,7 +4,7 @@ import { CakesTable } from '../content/cake.ts';
4
4
  import { ComponentsTable } from '../content/components.ts';
5
5
  import { LayersTable } from '../content/layer.ts';
6
6
  import { SliceIdsTable } from '../content/slice-ids.ts';
7
- import { History } from '../history/history.ts';
7
+ import { InsertHistory } from '../insertHistory/insertHistory.ts';
8
8
  import { Rljson } from '../rljson.ts';
9
9
  import { Ref } from '../typedefs.ts';
10
10
  export interface Ingredient extends Json {
@@ -32,6 +32,6 @@ export interface Bakery extends Rljson {
32
32
  recipeIngredients: ComponentsTable<RecipIngredient>;
33
33
  ingredients: ComponentsTable<Ingredient>;
34
34
  nutritionalValues: ComponentsTable<NutritionalValues>;
35
- ingredientsHistory: History<'Ingredients'>;
35
+ ingredientsInsertHistory: InsertHistory<'Ingredients'>;
36
36
  }
37
37
  export declare const bakeryExample: () => Bakery;
package/dist/example.d.ts CHANGED
@@ -7,11 +7,9 @@ export declare class Example {
7
7
  singleRow: () => Rljson;
8
8
  multipleRows: () => Rljson;
9
9
  singleRef: () => Rljson;
10
+ multiRef: () => Rljson;
10
11
  singleSliceIdRef: () => Rljson;
11
12
  multiSliceIdRef: () => Rljson;
12
- singleNamedRef: () => Rljson;
13
- multiRef: () => Rljson;
14
- multiMixedRef: () => Rljson;
15
13
  complete: () => Rljson;
16
14
  };
17
15
  static readonly broken: {
@@ -24,7 +22,6 @@ export declare class Example {
24
22
  missingData: () => Rljson;
25
23
  dataNotBeingAnArray: () => Rljson;
26
24
  missingRef: () => Rljson;
27
- missingNamedRef: () => Rljson;
28
25
  missingMultiRef: () => Rljson;
29
26
  missingReferencedTable: () => Rljson;
30
27
  missingSliceId: () => Rljson;
package/dist/index.d.ts CHANGED
@@ -7,9 +7,9 @@ export * from './content/slice-ids.ts';
7
7
  export * from './content/table-cfg.ts';
8
8
  export * from './example.ts';
9
9
  export * from './example/bakery-example.ts';
10
- export * from './history/history.ts';
11
10
  export * from './insert/insert-validator.ts';
12
11
  export * from './insert/insert.ts';
12
+ export * from './insertHistory/insertHistory.ts';
13
13
  export * from './rljson.ts';
14
14
  export * from './route/route.ts';
15
15
  export * from './tools/remove-duplicates.ts';
@@ -0,0 +1,24 @@
1
+ import { TableCfg } from '../content/table-cfg.ts';
2
+ import { RljsonTable } from '../rljson.ts';
3
+ import { RouteRef } from '../route/route.ts';
4
+ import { Ref } from '../typedefs.ts';
5
+ export type InsertHistoryTimeId = string;
6
+ export type InsertHistoryRow<Str extends string> = {
7
+ [key in Str as `${Uncapitalize<string & key>}Ref`]: string;
8
+ } & {
9
+ timeId: InsertHistoryTimeId;
10
+ route: RouteRef;
11
+ origin?: Ref;
12
+ previous?: InsertHistoryTimeId[];
13
+ };
14
+ export type InsertHistory<Str extends string> = RljsonTable<InsertHistoryRow<Str>, 'insertHistory'>;
15
+ /**
16
+ * Creates a TableCfg for a InsertHistory table for the given table configuration
17
+ * @param tableCfg - The table configuration to create the InsertHistory table for
18
+ * @returns The TableCfg for the InsertHistory table
19
+ */
20
+ export declare const createInsertHistoryTableCfg: (tableCfg: TableCfg) => TableCfg;
21
+ /**
22
+ * Provides an example insertHistory table for test purposes
23
+ */
24
+ export declare const exampleInsertHistoryTable: () => InsertHistory<any>;
package/dist/rljson.d.ts CHANGED
@@ -6,14 +6,14 @@ import { LayersTable } from './content/layer.ts';
6
6
  import { RevisionsTable } from './content/revision.ts';
7
7
  import { SliceIdsTable } from './content/slice-ids.ts';
8
8
  import { TableCfgRef, TablesCfgTable } from './content/table-cfg.ts';
9
- import { History } from './history/history.ts';
9
+ import { InsertHistory } from './insertHistory/insertHistory.ts';
10
10
  import { ContentType, Ref, TableKey } from './typedefs.ts';
11
11
  export declare const reservedFieldNames: string[];
12
12
  export declare const reservedTableKeys: string[];
13
13
  /**
14
14
  * One of the supported Rljson table types
15
15
  */
16
- export type TableType = BuffetsTable | ComponentsTable<any> | LayersTable | SliceIdsTable | CakesTable | RevisionsTable | TablesCfgTable | History<any>;
16
+ export type TableType = BuffetsTable | ComponentsTable<any> | LayersTable | SliceIdsTable | CakesTable | RevisionsTable | TablesCfgTable | InsertHistory<any>;
17
17
  /** The rljson data format */
18
18
  export interface Rljson extends Json {
19
19
  [tableId: TableKey]: TableType;