@rljson/rljson 0.0.38 → 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.
@@ -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: Record<ColumnKey, ColumnCfg>;
32
+ columns: ColumnCfg[];
29
33
  /**
30
34
  * The content type of the table
31
35
  */
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
- int: {
194
+ columns: [
195
+ {
196
+ key: "int",
196
197
  type: "number"
197
198
  },
198
- double: {
199
+ {
200
+ key: "double",
199
201
  type: "number"
200
202
  },
201
- string: {
203
+ {
204
+ key: "string",
202
205
  type: "string"
203
206
  },
204
- boolean: {
207
+ {
208
+ key: "boolean",
205
209
  type: "boolean"
206
210
  },
207
- null: {
211
+ {
212
+ key: "null",
208
213
  type: "null"
209
214
  },
210
- jsonArray: {
215
+ {
216
+ key: "jsonArray",
211
217
  type: "jsonArray"
212
218
  },
213
- json: {
219
+ {
220
+ key: "json",
214
221
  type: "json"
215
222
  },
216
- jsonValue: {
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 tableCfg = result.tableCfgs._data[0];
431
- tableCfg.columns["int"].type = "numberBroken";
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
@@ -529,14 +538,16 @@ const exampleTableCfg = (tableCfg = void 0) => {
529
538
  return {
530
539
  key: (tableCfg == null ? void 0 : tableCfg.key) ?? "table",
531
540
  version: 1,
532
- columns: (tableCfg == null ? void 0 : tableCfg.columns) ?? {
533
- a: {
541
+ columns: (tableCfg == null ? void 0 : tableCfg.columns) ?? [
542
+ {
543
+ key: "a",
534
544
  type: "string"
535
545
  },
536
- b: {
546
+ {
547
+ key: "b",
537
548
  type: "number"
538
549
  }
539
- },
550
+ ],
540
551
  type: (tableCfg == null ? void 0 : tableCfg.type) ?? "ingredients",
541
552
  isHead: true,
542
553
  isRoot: true,
@@ -825,16 +836,14 @@ class _BaseValidator {
825
836
  }
826
837
  const brokenCfgs = [];
827
838
  for (const item of tableCfgs._data) {
828
- for (const columnKey in item.columns) {
829
- if (columnKey.startsWith("_")) {
830
- continue;
831
- }
832
- const column = item.columns[columnKey];
833
- 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) {
834
843
  brokenCfgs.push({
835
844
  brokenTableCfg: item._hash,
836
845
  brokenColumnKey: columnKey,
837
- brokenColumnType: column.type
846
+ brokenColumnType: columnType
838
847
  });
839
848
  }
840
849
  }
@@ -891,7 +900,10 @@ class _BaseValidator {
891
900
  );
892
901
  for (const columnKey of newColumnKey) {
893
902
  const columns = tableCfgData.columns;
894
- if (!columns[columnKey]) {
903
+ const columnConfig = columns.find(
904
+ (column) => column.key === columnKey
905
+ );
906
+ if (!columnConfig) {
895
907
  missingColumnConfigs.push({
896
908
  tableCfg: tableCfgRef,
897
909
  row: row._hash,
@@ -926,7 +938,7 @@ class _BaseValidator {
926
938
  );
927
939
  for (const columnKey of columnKeys) {
928
940
  const columns = tableCfgData.columns;
929
- const columnConfig = columns[columnKey];
941
+ const columnConfig = columns.find((e) => e.key === columnKey);
930
942
  const value = row[columnKey];
931
943
  if (value == null || value == void 0) {
932
944
  continue;
@@ -1034,7 +1046,7 @@ class _BaseValidator {
1034
1046
  continue;
1035
1047
  }
1036
1048
  const columns = cfg.columns;
1037
- const idField = columns["id"];
1049
+ const idField = columns.find((e) => e.key === "id");
1038
1050
  if (!idField) {
1039
1051
  rootOrHeadTablesWithoutIdColumns.push({
1040
1052
  table: tableKey,
@@ -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
- int: {
55
+ columns: [
56
+ {
57
+ key: 'int',
57
58
  type: 'number',
58
59
  },
59
- double: {
60
+ {
61
+ key: 'double',
60
62
  type: 'number',
61
63
  },
62
- string: {
64
+ {
65
+ key: 'string',
63
66
  type: 'string',
64
67
  },
65
- boolean: {
68
+ {
69
+ key: 'boolean',
66
70
  type: 'boolean',
67
71
  },
68
- null: {
72
+ {
73
+ key: 'null',
69
74
  type: 'null',
70
75
  },
71
- jsonArray: {
76
+ {
77
+ key: 'jsonArray',
72
78
  type: 'jsonArray',
73
79
  },
74
- json: {
80
+ {
81
+ key: 'json',
75
82
  type: 'json',
76
83
  },
77
- jsonValue: {
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 tableCfg = result.tableCfgs._data[0];
309
- tableCfg.columns['int'].type = 'numberBroken'; // Break one of the types
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.38",
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.13.17",
33
- "@typescript-eslint/eslint-plugin": "^8.29.0",
34
- "@typescript-eslint/parser": "^8.29.0",
35
- "@vitest/coverage-v8": "^3.1.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.23.0",
38
- "eslint-plugin-jsdoc": "^50.6.9",
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
- "typescript": "~5.8.2",
44
- "typescript-eslint": "^8.29.0",
45
- "vite": "^6.2.4",
46
- "vite-node": "^3.1.1",
43
+ "typescript": "~5.8.3",
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.1",
49
+ "vitest": "^3.1.2",
50
50
  "vitest-dom": "^0.1.1"
51
51
  },
52
52
  "dependencies": {