@rljson/rljson 0.0.23 → 0.0.25

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.
@@ -1,6 +1,6 @@
1
1
  import { Json } from '@rljson/json';
2
2
  import { RljsonTable } from '../rljson.ts';
3
- import { ItemId, Ref, TableName } from '../typedefs.ts';
3
+ import { ItemId, Ref, TableKey } from '../typedefs.ts';
4
4
  /**
5
5
  * A buffet id is a name or id of a buffet
6
6
  */
@@ -17,7 +17,7 @@ export interface Buffet extends Json {
17
17
  /**
18
18
  * The table the item is taken from
19
19
  */
20
- table: TableName;
20
+ table: TableKey;
21
21
  /**
22
22
  * The hash of the item in the able
23
23
  */
@@ -1,6 +1,6 @@
1
1
  import { Json } from '@rljson/json';
2
2
  import { RljsonTable } from '../rljson.ts';
3
- import { ItemId, TableName } from '../typedefs.ts';
3
+ import { ItemId, TableKey } from '../typedefs.ts';
4
4
  import { CollectionRef } from './collection.ts';
5
5
  import { IdSetRef } from './id-set.ts';
6
6
  /**
@@ -22,7 +22,7 @@ export interface Cake extends Json {
22
22
  /**
23
23
  * The table containing the item collections defining the layers
24
24
  */
25
- collections: TableName;
25
+ collections: TableKey;
26
26
  /**
27
27
  * Assigns a collection to each layer of the cake.
28
28
  */
@@ -1,6 +1,6 @@
1
1
  import { Json } from '@rljson/json';
2
2
  import { RljsonTable } from '../rljson.ts';
3
- import { ItemId, Ref, TableName } from '../typedefs.ts';
3
+ import { ItemId, Ref, TableKey } from '../typedefs.ts';
4
4
  import { IdSetRef } from './id-set.ts';
5
5
  import { PropertiesRef } from './properties.ts';
6
6
  /**
@@ -24,7 +24,7 @@ export interface Collection extends Json {
24
24
  * The table containing the properties that are assigned to the items
25
25
  * with the assign property below
26
26
  */
27
- properties: TableName;
27
+ properties: TableKey;
28
28
  /**
29
29
  * Assign properties to each item of the collection.
30
30
  */
@@ -1,6 +1,6 @@
1
- import { Json, JsonKey, JsonValueType } from '@rljson/json';
1
+ import { Json, JsonValueType } from '@rljson/json';
2
2
  import { RljsonTable } from '../rljson.ts';
3
- import { ContentType, Ref } from '../typedefs.ts';
3
+ import { ColumnKey, ContentType, Ref, TableKey } from '../typedefs.ts';
4
4
  /**
5
5
  * A ColumnsRef is a hash pointing to columns metadata
6
6
  */
@@ -10,9 +10,9 @@ export type TableCfgRef = Ref;
10
10
  */
11
11
  export interface ColumnCfg extends Json {
12
12
  /**
13
- * The jsonKey of the column used in data
13
+ * The key of the column used in data
14
14
  */
15
- jsonKey: JsonKey;
15
+ key: ColumnKey;
16
16
  /**
17
17
  * The type of the column
18
18
  */
@@ -25,15 +25,19 @@ export interface TableCfg extends Json {
25
25
  /**
26
26
  * Technical lower camel case json identifier of the table
27
27
  */
28
- jsonKey: JsonKey;
28
+ key: TableKey;
29
29
  /**
30
30
  * A short description of the table
31
31
  */
32
- columns: Record<JsonKey, ColumnCfg>;
32
+ columns: Record<ColumnKey, ColumnCfg>;
33
33
  /**
34
34
  * The content type of the table
35
35
  */
36
36
  type: ContentType;
37
+ /**
38
+ * The previous version of the table
39
+ */
40
+ previous?: TableCfgRef;
37
41
  }
38
42
  /**
39
43
  * A table containing columns
package/dist/example.d.ts CHANGED
@@ -11,7 +11,7 @@ export declare class Example {
11
11
  };
12
12
  static readonly broken: {
13
13
  base: {
14
- brokenTableName: () => {
14
+ brokenTableKey: () => {
15
15
  brok$en: {
16
16
  _type: string;
17
17
  _data: never[];
@@ -4,7 +4,7 @@ import { Rljson } from './rljson.ts';
4
4
  * An Rljson object where all tables' rows are indexed by their hash.
5
5
  */
6
6
  export interface RljsonIndexed {
7
- [tableName: string]: {
7
+ [tableKey: string]: {
8
8
  _data: {
9
9
  [rowHash: string]: Json;
10
10
  };
package/dist/rljson.d.ts CHANGED
@@ -5,16 +5,16 @@ import { CollectionsTable } from './content/collection.ts';
5
5
  import { IdSetsTable } from './content/id-set.ts';
6
6
  import { PropertiesTable } from './content/properties.ts';
7
7
  import { TableCfgRef, TablesCfgTable } from './content/table-cfg.ts';
8
- import { ContentType, Ref, TableName } from './typedefs.ts';
8
+ import { ContentType, Ref, TableKey } from './typedefs.ts';
9
9
  export declare const reservedFieldNames: string[];
10
- export declare const reservedTableNames: string[];
10
+ export declare const reservedTableKeys: string[];
11
11
  /**
12
12
  * One of the supported Rljson table types
13
13
  */
14
14
  export type TableType = BuffetsTable | PropertiesTable<any> | CollectionsTable | IdSetsTable | CakesTable;
15
15
  /** The rljson data format */
16
16
  export interface Rljson extends Json {
17
- [tableId: TableName]: TableType;
17
+ [tableId: TableKey]: TableType;
18
18
  }
19
19
  /**
20
20
  * Rljson set with private fields
@@ -58,4 +58,4 @@ export interface RljsonTable<Data extends Json, Type extends ContentType> extend
58
58
  * @param rljson - The Rljson object to iterate
59
59
  * @param callback - The callback to call for each table
60
60
  */
61
- export declare const iterateTables: (rljson: Rljson, callback: (tableName: string, table: TableType) => void) => void;
61
+ export declare const iterateTables: (rljson: Rljson, callback: (tableKey: string, table: TableType) => void) => void;
package/dist/rljson.js CHANGED
@@ -163,39 +163,39 @@ __publicField(_Example, "ok", {
163
163
  _data: [
164
164
  {
165
165
  _hash: "",
166
- jsonKey: "table",
166
+ key: "table",
167
167
  type: "properties",
168
168
  columns: {
169
169
  int: {
170
- jsonKey: "int",
170
+ key: "int",
171
171
  type: "number"
172
172
  },
173
173
  double: {
174
- jsonKey: "double",
174
+ key: "double",
175
175
  type: "number"
176
176
  },
177
177
  string: {
178
- jsonKey: "string",
178
+ key: "string",
179
179
  type: "string"
180
180
  },
181
181
  boolean: {
182
- jsonKey: "boolean",
182
+ key: "boolean",
183
183
  type: "boolean"
184
184
  },
185
185
  null: {
186
- jsonKey: "null",
186
+ key: "null",
187
187
  type: "null"
188
188
  },
189
189
  jsonArray: {
190
- jsonKey: "jsonArray",
190
+ key: "jsonArray",
191
191
  type: "jsonArray"
192
192
  },
193
193
  json: {
194
- jsonKey: "json",
194
+ key: "json",
195
195
  type: "json"
196
196
  },
197
197
  jsonValue: {
198
- jsonKey: "jsonValue",
198
+ key: "jsonValue",
199
199
  type: "jsonValue"
200
200
  }
201
201
  }
@@ -341,7 +341,7 @@ __publicField(_Example, "ok", {
341
341
  });
342
342
  __publicField(_Example, "broken", {
343
343
  base: {
344
- brokenTableName: () => {
344
+ brokenTableKey: () => {
345
345
  return {
346
346
  brok$en: {
347
347
  _type: "properties",
@@ -502,15 +502,15 @@ const rljsonIndexed = (rljson) => {
502
502
  };
503
503
  // @license
504
504
  const reservedFieldNames = ["_type", "_data"];
505
- const reservedTableNames = ["_hash", "idSets", "tableCfgs"];
505
+ const reservedTableKeys = ["_hash", "idSets", "tableCfgs"];
506
506
  const exampleRljson = () => Example.ok.singleRow();
507
507
  const iterateTables = (rljson, callback) => {
508
- for (const tableName in rljson) {
509
- const value = rljson[tableName];
508
+ for (const tableKey in rljson) {
509
+ const value = rljson[tableKey];
510
510
  if (typeof value !== "object" || !Array.isArray(value._data)) {
511
511
  continue;
512
512
  }
513
- callback(tableName, rljson[tableName]);
513
+ callback(tableKey, rljson[tableKey]);
514
514
  }
515
515
  };
516
516
  // @license
@@ -525,7 +525,7 @@ const exampleTypedefs = () => {
525
525
  return {
526
526
  ref: "ref",
527
527
  itemId: "itemId",
528
- tableName: "tableName",
528
+ tableKey: "tableKey",
529
529
  contentType: "collections"
530
530
  };
531
531
  };
@@ -550,10 +550,10 @@ class _BaseValidator {
550
550
  // ######################
551
551
  // Private
552
552
  // ######################
553
- __publicField(this, "tableNames");
553
+ __publicField(this, "tableKeys");
554
554
  __publicField(this, "rljsonIndexed");
555
555
  this.rljson = rljson;
556
- this.tableNames = Object.keys(this.rljson).filter(
556
+ this.tableKeys = Object.keys(this.rljson).filter(
557
557
  (table) => !table.startsWith("_")
558
558
  );
559
559
  this.rljsonIndexed = rljsonIndexed(rljson);
@@ -565,14 +565,14 @@ class _BaseValidator {
565
565
  const steps = [
566
566
  // Base checks
567
567
  () => this._writeAndValidHashes(),
568
- () => this._tableNamesNotLowerCamelCase(),
569
- () => this._tableNamesDoNotEndWithRef(),
568
+ () => this._tableKeysNotLowerCamelCase(),
569
+ () => this._tableKeysDoNotEndWithRef(),
570
570
  () => this._columnNamesNotLowerCamelCase(),
571
571
  () => this._dataNotFound(),
572
572
  () => this._dataHasWrongType(),
573
573
  () => this._invalidTableTypes(),
574
574
  // Check table cfg
575
- () => this._tableCfgsReferencedTableNameNotFound(),
575
+ () => this._tableCfgsReferencedTableKeyNotFound(),
576
576
  () => this._tableCfgsHaveWrongType(),
577
577
  () => this._tableCfgNotFound(),
578
578
  () => this._missingColumnConfigs(),
@@ -599,32 +599,32 @@ class _BaseValidator {
599
599
  this.errors.hasErrors = this.hasErrors;
600
600
  return this.errors;
601
601
  }
602
- _tableNamesNotLowerCamelCase() {
603
- const invalidTableNames = [];
604
- for (const tableName of this.tableNames) {
605
- if (!BaseValidator.isValidFieldName(tableName)) {
606
- invalidTableNames.push(tableName);
602
+ _tableKeysNotLowerCamelCase() {
603
+ const invalidTableKeys = [];
604
+ for (const tableKey of this.tableKeys) {
605
+ if (!BaseValidator.isValidFieldName(tableKey)) {
606
+ invalidTableKeys.push(tableKey);
607
607
  }
608
608
  }
609
- if (invalidTableNames.length > 0) {
610
- this.errors.tableNamesNotLowerCamelCase = {
609
+ if (invalidTableKeys.length > 0) {
610
+ this.errors.tableKeysNotLowerCamelCase = {
611
611
  error: "Table names must be lower camel case",
612
- invalidTableNames
612
+ invalidTableKeys
613
613
  };
614
614
  }
615
615
  }
616
616
  // ...........................................................................
617
- _tableNamesDoNotEndWithRef() {
618
- const invalidTableNames = [];
619
- for (const tableName of this.tableNames) {
620
- if (tableName.endsWith("Ref")) {
621
- invalidTableNames.push(tableName);
617
+ _tableKeysDoNotEndWithRef() {
618
+ const invalidTableKeys = [];
619
+ for (const tableKey of this.tableKeys) {
620
+ if (tableKey.endsWith("Ref")) {
621
+ invalidTableKeys.push(tableKey);
622
622
  }
623
623
  }
624
- if (invalidTableNames.length > 0) {
625
- this.errors.tableNamesDoNotEndWithRef = {
624
+ if (invalidTableKeys.length > 0) {
625
+ this.errors.tableKeysDoNotEndWithRef = {
626
626
  error: 'Table names must not end with "Ref"',
627
- invalidTableNames
627
+ invalidTableKeys
628
628
  };
629
629
  }
630
630
  }
@@ -632,8 +632,8 @@ class _BaseValidator {
632
632
  _columnNamesNotLowerCamelCase() {
633
633
  const invalidColumnNames = {};
634
634
  let hadErrors = false;
635
- for (const tableName of this.tableNames) {
636
- const table = this.rljson[tableName];
635
+ for (const tableKey of this.tableKeys) {
636
+ const table = this.rljson[tableKey];
637
637
  if (!table._data || !Array.isArray(table._data)) {
638
638
  continue;
639
639
  }
@@ -643,8 +643,8 @@ class _BaseValidator {
643
643
  continue;
644
644
  }
645
645
  if (!BaseValidator.isValidFieldName(columnName)) {
646
- invalidColumnNames[tableName] ?? (invalidColumnNames[tableName] = []);
647
- invalidColumnNames[tableName].push(columnName);
646
+ invalidColumnNames[tableKey] ?? (invalidColumnNames[tableKey] = []);
647
+ invalidColumnNames[tableKey].push(columnName);
648
648
  hadErrors = true;
649
649
  }
650
650
  }
@@ -682,7 +682,7 @@ class _BaseValidator {
682
682
  _dataNotFound() {
683
683
  const rljson = this.rljson;
684
684
  const tablesWithMissingData = [];
685
- for (const table of this.tableNames) {
685
+ for (const table of this.tableKeys) {
686
686
  const tableData = rljson[table];
687
687
  const items = tableData["_data"];
688
688
  if (items == null) {
@@ -697,23 +697,23 @@ class _BaseValidator {
697
697
  }
698
698
  }
699
699
  // ...........................................................................
700
- _tableCfgsReferencedTableNameNotFound() {
700
+ _tableCfgsReferencedTableKeyNotFound() {
701
701
  const tableCfgs = this.rljson.tableCfgs;
702
702
  if (!tableCfgs) {
703
703
  return;
704
704
  }
705
705
  const brokenCfgs = [];
706
706
  for (const item of tableCfgs._data) {
707
- const table = this.rljson[item.jsonKey];
707
+ const table = this.rljson[item.key];
708
708
  if (!table) {
709
709
  brokenCfgs.push({
710
710
  brokenTableCfg: item._hash,
711
- tableNameNotFound: item.jsonKey
711
+ tableKeyNotFound: item.key
712
712
  });
713
713
  }
714
714
  }
715
715
  if (brokenCfgs.length > 0) {
716
- this.errors.tableCfgsReferencedTableNameNotFound = {
716
+ this.errors.tableCfgsReferencedTableKeyNotFound = {
717
717
  error: "Tables referenced in tableCfgs not found",
718
718
  brokenCfgs
719
719
  };
@@ -752,7 +752,7 @@ class _BaseValidator {
752
752
  _tableCfgNotFound() {
753
753
  const tableCfgs = this.rljsonIndexed.tableCfgs;
754
754
  const tableCfgNotFound = [];
755
- iterateTables(this.rljson, (tableName, table) => {
755
+ iterateTables(this.rljson, (tableKey, table) => {
756
756
  const tableCfgRef = table._tableCfg;
757
757
  if (!tableCfgRef) {
758
758
  return;
@@ -760,7 +760,7 @@ class _BaseValidator {
760
760
  const tableCfgData = tableCfgs._data[tableCfgRef];
761
761
  if (!tableCfgData) {
762
762
  tableCfgNotFound.push({
763
- tableWithBrokenTableCfgRef: tableName,
763
+ tableWithBrokenTableCfgRef: tableKey,
764
764
  brokenTableCfgRef: tableCfgRef
765
765
  });
766
766
  return;
@@ -777,7 +777,7 @@ class _BaseValidator {
777
777
  _missingColumnConfigs() {
778
778
  const tableCfgs = this.rljsonIndexed.tableCfgs;
779
779
  const missingColumnConfigs = [];
780
- iterateTables(this.rljson, (tableName, table) => {
780
+ iterateTables(this.rljson, (tableKey, table) => {
781
781
  const tableCfgRef = table._tableCfg;
782
782
  if (!tableCfgRef) {
783
783
  return;
@@ -798,7 +798,7 @@ class _BaseValidator {
798
798
  tableCfg: tableCfgRef,
799
799
  row: row._hash,
800
800
  column: columnKey,
801
- table: tableName
801
+ table: tableKey
802
802
  });
803
803
  }
804
804
  processedColumnKeys.push(columnKey);
@@ -816,7 +816,7 @@ class _BaseValidator {
816
816
  _dataDoesNotMatchColumnConfig() {
817
817
  const tableCfgs = this.rljsonIndexed.tableCfgs;
818
818
  const brokenValues = [];
819
- iterateTables(this.rljson, (tableName, table) => {
819
+ iterateTables(this.rljson, (tableKey, table) => {
820
820
  const tableCfgRef = table._tableCfg;
821
821
  if (!tableCfgRef) {
822
822
  return;
@@ -836,7 +836,7 @@ class _BaseValidator {
836
836
  const typeShould = columnConfig.type;
837
837
  if (!jsonValueMatchesType(value, typeShould)) {
838
838
  brokenValues.push({
839
- table: tableName,
839
+ table: tableKey,
840
840
  row: row._hash,
841
841
  column: columnKey,
842
842
  tableCfg: tableCfgRef
@@ -856,8 +856,8 @@ class _BaseValidator {
856
856
  _tableTypesDoNotMatch() {
857
857
  const rljson = this.rljson;
858
858
  const tablesWithTypeMissmatch = [];
859
- for (const tableName of this.tableNames) {
860
- const table = rljson[tableName];
859
+ for (const tableKey of this.tableKeys) {
860
+ const table = rljson[tableKey];
861
861
  const cfgRef = table._tableCfg;
862
862
  if (!cfgRef) {
863
863
  continue;
@@ -867,7 +867,7 @@ class _BaseValidator {
867
867
  const typeIs = table._type;
868
868
  if (typeShould !== typeIs) {
869
869
  tablesWithTypeMissmatch.push({
870
- table: tableName,
870
+ table: tableKey,
871
871
  typeInTable: typeIs,
872
872
  typeInConfig: typeShould,
873
873
  tableCfg: cfgRef
@@ -885,11 +885,11 @@ class _BaseValidator {
885
885
  _dataHasWrongType() {
886
886
  const rljson = this.rljson;
887
887
  const tablesWithWrongType = [];
888
- for (const tableName of this.tableNames) {
889
- const tableData = rljson[tableName];
888
+ for (const tableKey of this.tableKeys) {
889
+ const tableData = rljson[tableKey];
890
890
  const items = tableData["_data"];
891
891
  if (!Array.isArray(items)) {
892
- tablesWithWrongType.push(tableName);
892
+ tablesWithWrongType.push(tableKey);
893
893
  }
894
894
  }
895
895
  if (tablesWithWrongType.length > 0) {
@@ -903,12 +903,12 @@ class _BaseValidator {
903
903
  _invalidTableTypes() {
904
904
  const rljson = this.rljson;
905
905
  const tablesWithWrongType = [];
906
- for (const tableName of this.tableNames) {
907
- const table = rljson[tableName];
906
+ for (const tableKey of this.tableKeys) {
907
+ const table = rljson[tableKey];
908
908
  const type = table._type;
909
909
  if (contentTypes.indexOf(type) === -1) {
910
910
  tablesWithWrongType.push({
911
- table: tableName,
911
+ table: tableKey,
912
912
  type,
913
913
  allowedTypes: contentTypes.join(" | ")
914
914
  });
@@ -923,35 +923,35 @@ class _BaseValidator {
923
923
  }
924
924
  _refsNotFound() {
925
925
  const missingRefs = [];
926
- iterateTables(this.rljson, (tableName, table) => {
926
+ iterateTables(this.rljson, (tableKey, table) => {
927
927
  const tableData = table._data;
928
928
  for (const item of tableData) {
929
929
  for (const key of Object.keys(item)) {
930
930
  if (key.endsWith("Ref")) {
931
931
  const targetItemHash = item[key];
932
- const targetTableName = key.substring(0, key.length - 3);
932
+ const targetTableKey = key.substring(0, key.length - 3);
933
933
  const itemHash = item._hash;
934
- if (this.tableNames.indexOf(targetTableName) === -1) {
934
+ if (this.tableKeys.indexOf(targetTableKey) === -1) {
935
935
  missingRefs.push({
936
- error: `Target table "${targetTableName}" not found.`,
937
- sourceTable: tableName,
936
+ error: `Target table "${targetTableKey}" not found.`,
937
+ sourceTable: tableKey,
938
938
  sourceKey: key,
939
939
  sourceItemHash: itemHash,
940
940
  targetItemHash,
941
- targetTable: targetTableName
941
+ targetTable: targetTableKey
942
942
  });
943
943
  continue;
944
944
  }
945
- const targetTableIndexed = this.rljsonIndexed[targetTableName];
945
+ const targetTableIndexed = this.rljsonIndexed[targetTableKey];
946
946
  const referencedItem = targetTableIndexed._data[targetItemHash];
947
947
  if (referencedItem === void 0) {
948
948
  missingRefs.push({
949
- sourceTable: tableName,
949
+ sourceTable: tableKey,
950
950
  sourceItemHash: itemHash,
951
951
  sourceKey: key,
952
952
  targetItemHash,
953
- targetTable: targetTableName,
954
- error: `Table "${targetTableName}" has no item with hash "${targetItemHash}"`
953
+ targetTable: targetTableKey,
954
+ error: `Table "${targetTableKey}" has no item with hash "${targetItemHash}"`
955
955
  });
956
956
  }
957
957
  }
@@ -967,11 +967,11 @@ class _BaseValidator {
967
967
  }
968
968
  _collectionBasesNotFound() {
969
969
  const brokenCollections = [];
970
- iterateTables(this.rljson, (tableName, table) => {
970
+ iterateTables(this.rljson, (tableKey, table) => {
971
971
  if (table._type !== "collections") {
972
972
  return;
973
973
  }
974
- const collectionsIndexed = this.rljsonIndexed[tableName];
974
+ const collectionsIndexed = this.rljsonIndexed[tableKey];
975
975
  const collectionsTable = table;
976
976
  for (const collection of collectionsTable._data) {
977
977
  const baseRef = collection.base;
@@ -981,7 +981,7 @@ class _BaseValidator {
981
981
  const baseCollection = collectionsIndexed._data[baseRef];
982
982
  if (!baseCollection) {
983
983
  brokenCollections.push({
984
- collectionsTable: tableName,
984
+ collectionsTable: tableKey,
985
985
  brokenCollection: collection._hash,
986
986
  missingBaseCollection: baseRef
987
987
  });
@@ -997,7 +997,7 @@ class _BaseValidator {
997
997
  }
998
998
  _collectionIdSetsExist() {
999
999
  const brokenCollections = [];
1000
- iterateTables(this.rljson, (tableName, table) => {
1000
+ iterateTables(this.rljson, (tableKey, table) => {
1001
1001
  if (table._type !== "collections") {
1002
1002
  return;
1003
1003
  }
@@ -1011,7 +1011,7 @@ class _BaseValidator {
1011
1011
  const idSet = idSets._data[idSetRef];
1012
1012
  if (!idSet) {
1013
1013
  brokenCollections.push({
1014
- collectionsTable: tableName,
1014
+ collectionsTable: tableKey,
1015
1015
  collectionHash: collection._hash,
1016
1016
  missingIdSet: idSetRef
1017
1017
  });
@@ -1028,19 +1028,19 @@ class _BaseValidator {
1028
1028
  _collectionPropertyAssignmentsNotFound() {
1029
1029
  const missingPropertyTables = [];
1030
1030
  const brokenAssignments = [];
1031
- iterateTables(this.rljson, (tableName, table) => {
1031
+ iterateTables(this.rljson, (tableKey, table) => {
1032
1032
  if (table._type !== "collections") {
1033
1033
  return;
1034
1034
  }
1035
1035
  const collectionsTable = table;
1036
1036
  for (const collection of collectionsTable._data) {
1037
- const propertyTableName = collection.properties;
1038
- const propertiesTable = this.rljsonIndexed[propertyTableName];
1037
+ const propertyTableKey = collection.properties;
1038
+ const propertiesTable = this.rljsonIndexed[propertyTableKey];
1039
1039
  if (!propertiesTable) {
1040
1040
  missingPropertyTables.push({
1041
1041
  brokenCollection: collection._hash,
1042
- collectionsTable: tableName,
1043
- missingPropertyTable: propertyTableName
1042
+ collectionsTable: tableKey,
1043
+ missingPropertyTable: propertyTableKey
1044
1044
  });
1045
1045
  continue;
1046
1046
  }
@@ -1052,9 +1052,9 @@ class _BaseValidator {
1052
1052
  const propertyHash = assignments[itemId];
1053
1053
  if (!propertiesTable._data[propertyHash]) {
1054
1054
  brokenAssignments.push({
1055
- collectionsTable: tableName,
1055
+ collectionsTable: tableKey,
1056
1056
  brokenCollection: collection._hash,
1057
- referencedPropertyTable: propertyTableName,
1057
+ referencedPropertyTable: propertyTableKey,
1058
1058
  brokenAssignment: itemId,
1059
1059
  missingProperty: propertyHash
1060
1060
  });
@@ -1077,7 +1077,7 @@ class _BaseValidator {
1077
1077
  }
1078
1078
  _cakeIdSetsNotFound() {
1079
1079
  const brokenCakes = [];
1080
- iterateTables(this.rljson, (tableName, table) => {
1080
+ iterateTables(this.rljson, (tableKey, table) => {
1081
1081
  if (table._type !== "cakes") {
1082
1082
  return;
1083
1083
  }
@@ -1091,7 +1091,7 @@ class _BaseValidator {
1091
1091
  const idSet = idSets._data[idSetRef];
1092
1092
  if (!idSet) {
1093
1093
  brokenCakes.push({
1094
- cakeTable: tableName,
1094
+ cakeTable: tableKey,
1095
1095
  brokenCake: cake._hash,
1096
1096
  missingIdSet: idSetRef
1097
1097
  });
@@ -1108,19 +1108,19 @@ class _BaseValidator {
1108
1108
  _cakeCollectionTablesNotFound() {
1109
1109
  const missingCollectionTables = [];
1110
1110
  const missingLayerCollections = [];
1111
- iterateTables(this.rljson, (tableName, table) => {
1111
+ iterateTables(this.rljson, (tableKey, table) => {
1112
1112
  if (table._type !== "cakes") {
1113
1113
  return;
1114
1114
  }
1115
1115
  const cakesTable = table;
1116
1116
  for (const cake of cakesTable._data) {
1117
- const collectionsTableName = cake.collections;
1118
- const collectionsTable = this.rljsonIndexed[collectionsTableName];
1117
+ const collectionsTableKey = cake.collections;
1118
+ const collectionsTable = this.rljsonIndexed[collectionsTableKey];
1119
1119
  if (!collectionsTable) {
1120
1120
  missingCollectionTables.push({
1121
- cakeTable: tableName,
1121
+ cakeTable: tableKey,
1122
1122
  brokenCake: cake._hash,
1123
- missingCollectionsTable: collectionsTableName
1123
+ missingCollectionsTable: collectionsTableKey
1124
1124
  });
1125
1125
  continue;
1126
1126
  }
@@ -1132,10 +1132,10 @@ class _BaseValidator {
1132
1132
  const collection = collectionsTable._data[collectionRef];
1133
1133
  if (!collection) {
1134
1134
  missingLayerCollections.push({
1135
- cakeTable: tableName,
1135
+ cakeTable: tableKey,
1136
1136
  brokenCake: cake._hash,
1137
1137
  brokenLayerName: layer,
1138
- collectionsTable: collectionsTableName,
1138
+ collectionsTable: collectionsTableKey,
1139
1139
  missingCollection: collectionRef
1140
1140
  });
1141
1141
  }
@@ -1158,20 +1158,20 @@ class _BaseValidator {
1158
1158
  _buffetReferencedTableNotFound() {
1159
1159
  const missingTables = [];
1160
1160
  const missingItems = [];
1161
- iterateTables(this.rljson, (tableName, table) => {
1161
+ iterateTables(this.rljson, (tableKey, table) => {
1162
1162
  if (table._type !== "buffets") {
1163
1163
  return;
1164
1164
  }
1165
1165
  const buffetsTable = table;
1166
1166
  for (const buffet of buffetsTable._data) {
1167
1167
  for (const item of buffet.items) {
1168
- const itemTableName = item.table;
1169
- const itemTable = this.rljsonIndexed[itemTableName];
1168
+ const itemTableKey = item.table;
1169
+ const itemTable = this.rljsonIndexed[itemTableKey];
1170
1170
  if (!itemTable) {
1171
1171
  missingTables.push({
1172
- buffetTable: tableName,
1172
+ buffetTable: tableKey,
1173
1173
  brokenBuffet: buffet._hash,
1174
- missingItemTable: itemTableName
1174
+ missingItemTable: itemTableKey
1175
1175
  });
1176
1176
  continue;
1177
1177
  }
@@ -1179,9 +1179,9 @@ class _BaseValidator {
1179
1179
  const referencedItem = itemTable._data[ref];
1180
1180
  if (!referencedItem) {
1181
1181
  missingItems.push({
1182
- buffetTable: tableName,
1182
+ buffetTable: tableKey,
1183
1183
  brokenBuffet: buffet._hash,
1184
- itemTable: itemTableName,
1184
+ itemTable: itemTableKey,
1185
1185
  missingItem: ref
1186
1186
  });
1187
1187
  }
@@ -1257,6 +1257,6 @@ export {
1257
1257
  isValidFieldName,
1258
1258
  iterateTables,
1259
1259
  reservedFieldNames,
1260
- reservedTableNames,
1260
+ reservedTableKeys,
1261
1261
  rljsonIndexed
1262
1262
  };
@@ -11,7 +11,6 @@ import { TablesCfgTable } from './content/table-cfg.ts';
11
11
  import { bakeryExample } from './example/bakery-example.ts';
12
12
  import { Rljson } from './rljson.ts';
13
13
 
14
-
15
14
  export class Example {
16
15
  static readonly ok = {
17
16
  bakery: (): Rljson => bakeryExample(),
@@ -41,39 +40,39 @@ export class Example {
41
40
  _data: [
42
41
  {
43
42
  _hash: '',
44
- jsonKey: 'table',
43
+ key: 'table',
45
44
  type: 'properties',
46
45
  columns: {
47
46
  int: {
48
- jsonKey: 'int',
47
+ key: 'int',
49
48
  type: 'number',
50
49
  },
51
50
  double: {
52
- jsonKey: 'double',
51
+ key: 'double',
53
52
  type: 'number',
54
53
  },
55
54
  string: {
56
- jsonKey: 'string',
55
+ key: 'string',
57
56
  type: 'string',
58
57
  },
59
58
  boolean: {
60
- jsonKey: 'boolean',
59
+ key: 'boolean',
61
60
  type: 'boolean',
62
61
  },
63
62
  null: {
64
- jsonKey: 'null',
63
+ key: 'null',
65
64
  type: 'null',
66
65
  },
67
66
  jsonArray: {
68
- jsonKey: 'jsonArray',
67
+ key: 'jsonArray',
69
68
  type: 'jsonArray',
70
69
  },
71
70
  json: {
72
- jsonKey: 'json',
71
+ key: 'json',
73
72
  type: 'json',
74
73
  },
75
74
  jsonValue: {
76
- jsonKey: 'jsonValue',
75
+ key: 'jsonValue',
77
76
  type: 'jsonValue',
78
77
  },
79
78
  },
@@ -230,7 +229,7 @@ export class Example {
230
229
 
231
230
  static readonly broken = {
232
231
  base: {
233
- brokenTableName: () => {
232
+ brokenTableKey: () => {
234
233
  return {
235
234
  brok$en: {
236
235
  _type: 'properties',
@@ -1,3 +1,4 @@
1
+ import { JsonKey } from '@rljson/json';
1
2
  /**
2
3
  * A ref is a hash that references to another element
3
4
  */
@@ -11,7 +12,11 @@ export type ItemId = string;
11
12
  * A table id reference to a table. The table ids are used as keys in the top
12
13
  * level structure of an Rljson data object.
13
14
  */
14
- export type TableName = ItemId;
15
+ export type TableKey = JsonKey;
16
+ /**
17
+ * A column key is a key that references a column in a table
18
+ */
19
+ export type ColumnKey = JsonKey;
15
20
  /**
16
21
  * Types of tables that can be stored in an Rljson object
17
22
  *
@@ -29,6 +34,6 @@ export type ContentType = (typeof contentTypes)[number];
29
34
  export declare const exampleTypedefs: () => {
30
35
  ref: Ref;
31
36
  itemId: ItemId;
32
- tableName: TableName;
37
+ tableKey: TableKey;
33
38
  contentType: ContentType;
34
39
  };
@@ -2,15 +2,15 @@ import { Json } from '@rljson/json';
2
2
  import { Rljson } from '../rljson.ts';
3
3
  import { Errors, Validator } from './validate.ts';
4
4
  export interface BaseErrors extends Errors {
5
- tableNamesNotLowerCamelCase?: Json;
5
+ tableKeysNotLowerCamelCase?: Json;
6
6
  columnNamesNotLowerCamelCase?: Json;
7
- tableNamesDoNotStartWithANumber?: Json;
8
- tableNamesDoNotEndWithRef?: Json;
7
+ tableKeysDoNotStartWithANumber?: Json;
8
+ tableKeysDoNotEndWithRef?: Json;
9
9
  hashesNotValid?: Json;
10
10
  dataNotFound?: Json;
11
11
  dataHasWrongType?: Json;
12
12
  invalidTableTypes?: Json;
13
- tableCfgsReferencedTableNameNotFound?: Json;
13
+ tableCfgsReferencedTableKeyNotFound?: Json;
14
14
  columnsHaveWrongType?: Json;
15
15
  tableCfgReferencedNotFound?: Json;
16
16
  columnConfigNotFound?: Json;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rljson/rljson",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "packageManager": "pnpm@10.6.3",
5
5
  "description": "The RLJSON data format specification",
6
6
  "homepage": "https://github.com/rljson/rljson",