@rljson/rljson 0.0.39 → 0.0.40
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/table-cfg.d.ts +5 -12
- package/dist/rljson.js +38 -41
- package/dist/src/example.ts +22 -13
- package/package.json +11 -11
|
@@ -9,6 +9,10 @@ export type TableCfgRef = Ref;
|
|
|
9
9
|
* A column configuration
|
|
10
10
|
*/
|
|
11
11
|
export interface ColumnCfg extends Json {
|
|
12
|
+
/**
|
|
13
|
+
* The technical lower camel case json identifier of the column
|
|
14
|
+
*/
|
|
15
|
+
key: ColumnKey;
|
|
12
16
|
/**
|
|
13
17
|
* The type of the column
|
|
14
18
|
*/
|
|
@@ -25,7 +29,7 @@ export interface TableCfg extends Json {
|
|
|
25
29
|
/**
|
|
26
30
|
* A short description of the table
|
|
27
31
|
*/
|
|
28
|
-
columns:
|
|
32
|
+
columns: ColumnCfg[];
|
|
29
33
|
/**
|
|
30
34
|
* The content type of the table
|
|
31
35
|
*/
|
|
@@ -68,17 +72,6 @@ export interface TableCfg extends Json {
|
|
|
68
72
|
* A table containing columns
|
|
69
73
|
*/
|
|
70
74
|
export type TablesCfgTable = RljsonTable<TableCfg, 'ingredients'>;
|
|
71
|
-
/**
|
|
72
|
-
* Offers tools for working with table configurations
|
|
73
|
-
*/
|
|
74
|
-
export declare class TableCfgTools {
|
|
75
|
-
readonly tableCfg: TableCfg;
|
|
76
|
-
constructor(tableCfg: TableCfg);
|
|
77
|
-
/**
|
|
78
|
-
* Returns all column keys
|
|
79
|
-
*/
|
|
80
|
-
get columnKeys(): ColumnKey[];
|
|
81
|
-
}
|
|
82
75
|
/**
|
|
83
76
|
* Example matching allTypesRow
|
|
84
77
|
*/
|
package/dist/rljson.js
CHANGED
|
@@ -191,32 +191,40 @@ __publicField(_Example, "ok", {
|
|
|
191
191
|
isHead: false,
|
|
192
192
|
isRoot: false,
|
|
193
193
|
isShared: true,
|
|
194
|
-
columns:
|
|
195
|
-
|
|
194
|
+
columns: [
|
|
195
|
+
{
|
|
196
|
+
key: "int",
|
|
196
197
|
type: "number"
|
|
197
198
|
},
|
|
198
|
-
|
|
199
|
+
{
|
|
200
|
+
key: "double",
|
|
199
201
|
type: "number"
|
|
200
202
|
},
|
|
201
|
-
|
|
203
|
+
{
|
|
204
|
+
key: "string",
|
|
202
205
|
type: "string"
|
|
203
206
|
},
|
|
204
|
-
|
|
207
|
+
{
|
|
208
|
+
key: "boolean",
|
|
205
209
|
type: "boolean"
|
|
206
210
|
},
|
|
207
|
-
|
|
211
|
+
{
|
|
212
|
+
key: "null",
|
|
208
213
|
type: "null"
|
|
209
214
|
},
|
|
210
|
-
|
|
215
|
+
{
|
|
216
|
+
key: "jsonArray",
|
|
211
217
|
type: "jsonArray"
|
|
212
218
|
},
|
|
213
|
-
|
|
219
|
+
{
|
|
220
|
+
key: "json",
|
|
214
221
|
type: "json"
|
|
215
222
|
},
|
|
216
|
-
|
|
223
|
+
{
|
|
224
|
+
key: "jsonValue",
|
|
217
225
|
type: "jsonValue"
|
|
218
226
|
}
|
|
219
|
-
|
|
227
|
+
]
|
|
220
228
|
}
|
|
221
229
|
]
|
|
222
230
|
});
|
|
@@ -427,8 +435,9 @@ __publicField(_Example, "broken", {
|
|
|
427
435
|
tableCfg: {
|
|
428
436
|
wrongType: () => {
|
|
429
437
|
const result = _Example.ok.singleRow();
|
|
430
|
-
const
|
|
431
|
-
|
|
438
|
+
const columns = result.tableCfgs._data[0].columns;
|
|
439
|
+
const intColumn = columns.find((c) => c.key === "int");
|
|
440
|
+
intColumn.type = "numberBroken";
|
|
432
441
|
return hip(result, {
|
|
433
442
|
updateExistingHashes: true,
|
|
434
443
|
throwOnWrongHashes: false
|
|
@@ -524,33 +533,21 @@ __publicField(_Example, "broken", {
|
|
|
524
533
|
});
|
|
525
534
|
let Example = _Example;
|
|
526
535
|
// @license
|
|
527
|
-
class TableCfgTools {
|
|
528
|
-
constructor(tableCfg) {
|
|
529
|
-
this.tableCfg = tableCfg;
|
|
530
|
-
}
|
|
531
|
-
/**
|
|
532
|
-
* Returns all column keys
|
|
533
|
-
*/
|
|
534
|
-
get columnKeys() {
|
|
535
|
-
const columnNames = Object.keys(this.tableCfg.columns).filter(
|
|
536
|
-
(e) => !e.startsWith("_")
|
|
537
|
-
);
|
|
538
|
-
return columnNames;
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
536
|
const exampleTableCfgTable = () => Example.ok.singleRow().tableCfgs;
|
|
542
537
|
const exampleTableCfg = (tableCfg = void 0) => {
|
|
543
538
|
return {
|
|
544
539
|
key: (tableCfg == null ? void 0 : tableCfg.key) ?? "table",
|
|
545
540
|
version: 1,
|
|
546
|
-
columns: (tableCfg == null ? void 0 : tableCfg.columns) ??
|
|
547
|
-
|
|
541
|
+
columns: (tableCfg == null ? void 0 : tableCfg.columns) ?? [
|
|
542
|
+
{
|
|
543
|
+
key: "a",
|
|
548
544
|
type: "string"
|
|
549
545
|
},
|
|
550
|
-
|
|
546
|
+
{
|
|
547
|
+
key: "b",
|
|
551
548
|
type: "number"
|
|
552
549
|
}
|
|
553
|
-
|
|
550
|
+
],
|
|
554
551
|
type: (tableCfg == null ? void 0 : tableCfg.type) ?? "ingredients",
|
|
555
552
|
isHead: true,
|
|
556
553
|
isRoot: true,
|
|
@@ -839,16 +836,14 @@ class _BaseValidator {
|
|
|
839
836
|
}
|
|
840
837
|
const brokenCfgs = [];
|
|
841
838
|
for (const item of tableCfgs._data) {
|
|
842
|
-
for (const
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
const column = item.columns[columnKey];
|
|
847
|
-
if (jsonValueTypes.indexOf(column.type) === -1) {
|
|
839
|
+
for (const columnCfg of item.columns) {
|
|
840
|
+
const columnKey = columnCfg.key;
|
|
841
|
+
const columnType = columnCfg.type;
|
|
842
|
+
if (jsonValueTypes.indexOf(columnType) === -1) {
|
|
848
843
|
brokenCfgs.push({
|
|
849
844
|
brokenTableCfg: item._hash,
|
|
850
845
|
brokenColumnKey: columnKey,
|
|
851
|
-
brokenColumnType:
|
|
846
|
+
brokenColumnType: columnType
|
|
852
847
|
});
|
|
853
848
|
}
|
|
854
849
|
}
|
|
@@ -905,7 +900,10 @@ class _BaseValidator {
|
|
|
905
900
|
);
|
|
906
901
|
for (const columnKey of newColumnKey) {
|
|
907
902
|
const columns = tableCfgData.columns;
|
|
908
|
-
|
|
903
|
+
const columnConfig = columns.find(
|
|
904
|
+
(column) => column.key === columnKey
|
|
905
|
+
);
|
|
906
|
+
if (!columnConfig) {
|
|
909
907
|
missingColumnConfigs.push({
|
|
910
908
|
tableCfg: tableCfgRef,
|
|
911
909
|
row: row._hash,
|
|
@@ -940,7 +938,7 @@ class _BaseValidator {
|
|
|
940
938
|
);
|
|
941
939
|
for (const columnKey of columnKeys) {
|
|
942
940
|
const columns = tableCfgData.columns;
|
|
943
|
-
const columnConfig = columns
|
|
941
|
+
const columnConfig = columns.find((e) => e.key === columnKey);
|
|
944
942
|
const value = row[columnKey];
|
|
945
943
|
if (value == null || value == void 0) {
|
|
946
944
|
continue;
|
|
@@ -1048,7 +1046,7 @@ class _BaseValidator {
|
|
|
1048
1046
|
continue;
|
|
1049
1047
|
}
|
|
1050
1048
|
const columns = cfg.columns;
|
|
1051
|
-
const idField = columns
|
|
1049
|
+
const idField = columns.find((e) => e.key === "id");
|
|
1052
1050
|
if (!idField) {
|
|
1053
1051
|
rootOrHeadTablesWithoutIdColumns.push({
|
|
1054
1052
|
table: tableKey,
|
|
@@ -1504,7 +1502,6 @@ class Validate {
|
|
|
1504
1502
|
export {
|
|
1505
1503
|
BaseValidator,
|
|
1506
1504
|
Example,
|
|
1507
|
-
TableCfgTools,
|
|
1508
1505
|
Validate,
|
|
1509
1506
|
bakeryExample,
|
|
1510
1507
|
contentTypes,
|
package/dist/src/example.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { Cake, CakesTable } from './content/cake.ts';
|
|
|
12
12
|
import { IngredientsTable } from './content/ingredients.ts';
|
|
13
13
|
import { Layer, LayersTable } from './content/layer.ts';
|
|
14
14
|
import { SliceIdsTable } from './content/slice-ids.ts';
|
|
15
|
-
import { TablesCfgTable } from './content/table-cfg.ts';
|
|
15
|
+
import { ColumnCfg, TablesCfgTable } from './content/table-cfg.ts';
|
|
16
16
|
import { bakeryExample } from './example/bakery-example.ts';
|
|
17
17
|
import { Rljson } from './rljson.ts';
|
|
18
18
|
|
|
@@ -52,32 +52,40 @@ export class Example {
|
|
|
52
52
|
isHead: false,
|
|
53
53
|
isRoot: false,
|
|
54
54
|
isShared: true,
|
|
55
|
-
columns:
|
|
56
|
-
|
|
55
|
+
columns: [
|
|
56
|
+
{
|
|
57
|
+
key: 'int',
|
|
57
58
|
type: 'number',
|
|
58
59
|
},
|
|
59
|
-
|
|
60
|
+
{
|
|
61
|
+
key: 'double',
|
|
60
62
|
type: 'number',
|
|
61
63
|
},
|
|
62
|
-
|
|
64
|
+
{
|
|
65
|
+
key: 'string',
|
|
63
66
|
type: 'string',
|
|
64
67
|
},
|
|
65
|
-
|
|
68
|
+
{
|
|
69
|
+
key: 'boolean',
|
|
66
70
|
type: 'boolean',
|
|
67
71
|
},
|
|
68
|
-
|
|
72
|
+
{
|
|
73
|
+
key: 'null',
|
|
69
74
|
type: 'null',
|
|
70
75
|
},
|
|
71
|
-
|
|
76
|
+
{
|
|
77
|
+
key: 'jsonArray',
|
|
72
78
|
type: 'jsonArray',
|
|
73
79
|
},
|
|
74
|
-
|
|
80
|
+
{
|
|
81
|
+
key: 'json',
|
|
75
82
|
type: 'json',
|
|
76
83
|
},
|
|
77
|
-
|
|
84
|
+
{
|
|
85
|
+
key: 'jsonValue',
|
|
78
86
|
type: 'jsonValue',
|
|
79
87
|
},
|
|
80
|
-
|
|
88
|
+
],
|
|
81
89
|
},
|
|
82
90
|
],
|
|
83
91
|
});
|
|
@@ -305,8 +313,9 @@ export class Example {
|
|
|
305
313
|
tableCfg: {
|
|
306
314
|
wrongType: () => {
|
|
307
315
|
const result = Example.ok.singleRow();
|
|
308
|
-
const
|
|
309
|
-
|
|
316
|
+
const columns = result.tableCfgs._data[0].columns as ColumnCfg[];
|
|
317
|
+
const intColumn = columns.find((c) => c.key === 'int')!;
|
|
318
|
+
intColumn.type = 'numberBroken' as any; // Break one of the types
|
|
310
319
|
return hip(result, {
|
|
311
320
|
updateExistingHashes: true,
|
|
312
321
|
throwOnWrongHashes: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rljson/rljson",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.40",
|
|
4
4
|
"packageManager": "pnpm@10.6.3",
|
|
5
5
|
"description": "The RLJSON data format specification",
|
|
6
6
|
"homepage": "https://github.com/rljson/rljson",
|
|
@@ -29,24 +29,24 @@
|
|
|
29
29
|
"updateGoldens": "cross-env UPDATE_GOLDENS=true npm test"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/node": "^22.
|
|
33
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
34
|
-
"@typescript-eslint/parser": "^8.
|
|
35
|
-
"@vitest/coverage-v8": "^3.1.
|
|
32
|
+
"@types/node": "^22.15.2",
|
|
33
|
+
"@typescript-eslint/eslint-plugin": "^8.31.0",
|
|
34
|
+
"@typescript-eslint/parser": "^8.31.0",
|
|
35
|
+
"@vitest/coverage-v8": "^3.1.2",
|
|
36
36
|
"cross-env": "^7.0.3",
|
|
37
|
-
"eslint": "^9.25.
|
|
38
|
-
"eslint-plugin-jsdoc": "^50.6.
|
|
37
|
+
"eslint": "^9.25.1",
|
|
38
|
+
"eslint-plugin-jsdoc": "^50.6.11",
|
|
39
39
|
"eslint-plugin-tsdoc": "^0.4.0",
|
|
40
40
|
"globals": "^16.0.0",
|
|
41
41
|
"jsdoc": "^4.0.4",
|
|
42
42
|
"read-pkg": "^9.0.1",
|
|
43
43
|
"typescript": "~5.8.3",
|
|
44
|
-
"typescript-eslint": "^8.
|
|
45
|
-
"vite": "^6.3.
|
|
46
|
-
"vite-node": "^3.1.
|
|
44
|
+
"typescript-eslint": "^8.31.0",
|
|
45
|
+
"vite": "^6.3.3",
|
|
46
|
+
"vite-node": "^3.1.2",
|
|
47
47
|
"vite-plugin-dts": "^4.5.3",
|
|
48
48
|
"vite-tsconfig-paths": "^5.1.4",
|
|
49
|
-
"vitest": "^3.1.
|
|
49
|
+
"vitest": "^3.1.2",
|
|
50
50
|
"vitest-dom": "^0.1.1"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|