@rljson/rljson 0.0.47 → 0.0.49
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/content/buffet.d.ts +1 -1
- package/dist/content/cake.d.ts +1 -1
- package/dist/content/ingredients.d.ts +1 -1
- package/dist/content/layer.d.ts +1 -1
- package/dist/content/revision.d.ts +1 -1
- package/dist/content/slice-ids.d.ts +1 -1
- package/dist/content/table-cfg.d.ts +1 -1
- package/dist/rljson.d.ts +2 -4
- package/dist/rljson.js +4 -52
- package/dist/validate/base-validator.d.ts +0 -1
- package/package.json +1 -1
package/dist/content/buffet.d.ts
CHANGED
package/dist/content/cake.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type IngredientsRef = Ref;
|
|
|
8
8
|
/**
|
|
9
9
|
* A table containing ingredients
|
|
10
10
|
*/
|
|
11
|
-
export type IngredientsTable<T extends JsonWithId> = RljsonTable<T
|
|
11
|
+
export type IngredientsTable<T extends JsonWithId> = RljsonTable<T>;
|
|
12
12
|
/**
|
|
13
13
|
* Provides an example ingredients table for test purposes
|
|
14
14
|
*/
|
package/dist/content/layer.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export interface Revision extends Json {
|
|
|
30
30
|
/**
|
|
31
31
|
* A table containing revisions
|
|
32
32
|
*/
|
|
33
|
-
export type RevisionsTable = RljsonTable<Revision
|
|
33
|
+
export type RevisionsTable = RljsonTable<Revision>;
|
|
34
34
|
/**
|
|
35
35
|
* Example revision object for test purposes
|
|
36
36
|
*/
|
|
@@ -25,7 +25,7 @@ export interface SliceIds extends Json {
|
|
|
25
25
|
/**
|
|
26
26
|
* A table containing slice ids
|
|
27
27
|
*/
|
|
28
|
-
export type SliceIdsTable = RljsonTable<SliceIds
|
|
28
|
+
export type SliceIdsTable = RljsonTable<SliceIds>;
|
|
29
29
|
/**
|
|
30
30
|
* Returns one of the layers of the example cake
|
|
31
31
|
*/
|
|
@@ -66,7 +66,7 @@ export interface TableCfg extends Json {
|
|
|
66
66
|
/**
|
|
67
67
|
* A table containing columns
|
|
68
68
|
*/
|
|
69
|
-
export type TablesCfgTable = RljsonTable<TableCfg
|
|
69
|
+
export type TablesCfgTable = RljsonTable<TableCfg>;
|
|
70
70
|
/**
|
|
71
71
|
* Throws an error if the table configuration is not valid.
|
|
72
72
|
* @param tableCfg - The table configuration to check
|
package/dist/rljson.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ 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 {
|
|
9
|
+
import { Ref, TableKey } from './typedefs.ts';
|
|
10
10
|
export declare const reservedFieldNames: string[];
|
|
11
11
|
export declare const reservedTableKeys: string[];
|
|
12
12
|
/**
|
|
@@ -45,11 +45,9 @@ export type RljsonPrivate = {
|
|
|
45
45
|
/** An example rljson object */
|
|
46
46
|
export declare const exampleRljson: () => Rljson;
|
|
47
47
|
/** A table in the rljson format */
|
|
48
|
-
export interface RljsonTable<Data extends Json
|
|
48
|
+
export interface RljsonTable<Data extends Json> extends Json {
|
|
49
49
|
/** The data rows of the table */
|
|
50
50
|
_data: Data[];
|
|
51
|
-
/** The type of the table. If not set, the type is "ingredients" */
|
|
52
|
-
_type: Type;
|
|
53
51
|
/** The columns configuration of the table */
|
|
54
52
|
_tableCfg?: TableCfgRef;
|
|
55
53
|
}
|
package/dist/rljson.js
CHANGED
|
@@ -573,6 +573,10 @@ const validateRljsonAgainstTableCfg = (rows, tableCfg) => {
|
|
|
573
573
|
continue;
|
|
574
574
|
}
|
|
575
575
|
const expectedType = columnCfg.type;
|
|
576
|
+
const value = row[columnKey];
|
|
577
|
+
if (value === void 0 || value === null) {
|
|
578
|
+
continue;
|
|
579
|
+
}
|
|
576
580
|
const actualType = jsonValueType(row[columnKey]);
|
|
577
581
|
if (expectedType !== actualType) {
|
|
578
582
|
errors.push(
|
|
@@ -747,14 +751,12 @@ class _BaseValidator {
|
|
|
747
751
|
() => this._columnNamesNotLowerCamelCase(),
|
|
748
752
|
() => this._dataNotFound(),
|
|
749
753
|
() => this._dataHasWrongType(),
|
|
750
|
-
() => this._invalidTableTypes(),
|
|
751
754
|
// Check table cfg
|
|
752
755
|
() => this._tableCfgsReferencedTableKeyNotFound(),
|
|
753
756
|
() => this._tableCfgsHaveWrongType(),
|
|
754
757
|
() => this._tableCfgNotFound(),
|
|
755
758
|
() => this._missingColumnConfigs(),
|
|
756
759
|
() => this._dataDoesNotMatchColumnConfig(),
|
|
757
|
-
() => this._tableTypesDoNotMatch(),
|
|
758
760
|
() => this._tableCfgHasRootHeadSharedError(),
|
|
759
761
|
() => this._rootOrHeadTableHasNoIdColumn(),
|
|
760
762
|
// Check references
|
|
@@ -1037,35 +1039,6 @@ class _BaseValidator {
|
|
|
1037
1039
|
}
|
|
1038
1040
|
}
|
|
1039
1041
|
// ...........................................................................
|
|
1040
|
-
_tableTypesDoNotMatch() {
|
|
1041
|
-
const rljson = this.rljson;
|
|
1042
|
-
const tablesWithTypeMissmatch = [];
|
|
1043
|
-
for (const tableKey of this.tableKeys) {
|
|
1044
|
-
const table = rljson[tableKey];
|
|
1045
|
-
const cfgRef = table._tableCfg;
|
|
1046
|
-
if (!cfgRef) {
|
|
1047
|
-
continue;
|
|
1048
|
-
}
|
|
1049
|
-
const cfg = this.rljsonIndexed.tableCfgs._data[cfgRef];
|
|
1050
|
-
const typeShould = cfg.type;
|
|
1051
|
-
const typeIs = table._type;
|
|
1052
|
-
if (typeShould !== typeIs) {
|
|
1053
|
-
tablesWithTypeMissmatch.push({
|
|
1054
|
-
table: tableKey,
|
|
1055
|
-
typeInTable: typeIs,
|
|
1056
|
-
typeInConfig: typeShould,
|
|
1057
|
-
tableCfg: cfgRef
|
|
1058
|
-
});
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
if (tablesWithTypeMissmatch.length > 0) {
|
|
1062
|
-
this.errors.tableTypesDoNotMatch = {
|
|
1063
|
-
error: "Table types do not match table config",
|
|
1064
|
-
tables: tablesWithTypeMissmatch
|
|
1065
|
-
};
|
|
1066
|
-
}
|
|
1067
|
-
}
|
|
1068
|
-
// ...........................................................................
|
|
1069
1042
|
_tableCfgHasRootHeadSharedError() {
|
|
1070
1043
|
const rljson = this.rljson;
|
|
1071
1044
|
const inconsistentTableCfgs = [];
|
|
@@ -1154,27 +1127,6 @@ class _BaseValidator {
|
|
|
1154
1127
|
}
|
|
1155
1128
|
}
|
|
1156
1129
|
// ...........................................................................
|
|
1157
|
-
_invalidTableTypes() {
|
|
1158
|
-
const rljson = this.rljson;
|
|
1159
|
-
const tablesWithWrongType = [];
|
|
1160
|
-
for (const tableKey of this.tableKeys) {
|
|
1161
|
-
const table = rljson[tableKey];
|
|
1162
|
-
const type = table._type;
|
|
1163
|
-
if (contentTypes.indexOf(type) === -1) {
|
|
1164
|
-
tablesWithWrongType.push({
|
|
1165
|
-
table: tableKey,
|
|
1166
|
-
type,
|
|
1167
|
-
allowedTypes: contentTypes.join(" | ")
|
|
1168
|
-
});
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
if (tablesWithWrongType.length > 0) {
|
|
1172
|
-
this.errors.invalidTableTypes = {
|
|
1173
|
-
error: "Tables with invalid types",
|
|
1174
|
-
tables: tablesWithWrongType
|
|
1175
|
-
};
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
1130
|
_refsNotFound() {
|
|
1179
1131
|
const missingRefs = [];
|
|
1180
1132
|
iterateTablesSync(this.rljson, (tableKey, table) => {
|
|
@@ -9,7 +9,6 @@ export interface BaseErrors extends Errors {
|
|
|
9
9
|
hashesNotValid?: Json;
|
|
10
10
|
dataNotFound?: Json;
|
|
11
11
|
dataHasWrongType?: Json;
|
|
12
|
-
invalidTableTypes?: Json;
|
|
13
12
|
tableCfgsReferencedTableKeyNotFound?: Json;
|
|
14
13
|
columnsHaveWrongType?: Json;
|
|
15
14
|
tableCfgReferencedNotFound?: Json;
|