@rljson/rljson 0.0.42 → 0.0.44

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.
@@ -38,11 +38,6 @@ export interface TableCfg extends Json {
38
38
  * The previous version of the table
39
39
  */
40
40
  previous?: TableCfgRef;
41
- /**
42
- * The version of the table.
43
- * Needs to be increased when new columns are added.
44
- */
45
- version: number;
46
41
  /**
47
42
  * Head tables serve as versioning entry points.
48
43
  *
@@ -72,6 +67,11 @@ export interface TableCfg extends Json {
72
67
  * A table containing columns
73
68
  */
74
69
  export type TablesCfgTable = RljsonTable<TableCfg, 'ingredients'>;
70
+ /**
71
+ * Throws an error if the table configuration is not valid.
72
+ * @param tableCfg - The table configuration to check
73
+ */
74
+ export declare const throwOnInvalidTableCfg: (tableCfg: TableCfg) => void;
75
75
  /**
76
76
  * Example matching allTypesRow
77
77
  */
package/dist/rljson.js CHANGED
@@ -533,12 +533,39 @@ __publicField(_Example, "broken", {
533
533
  });
534
534
  let Example = _Example;
535
535
  // @license
536
+ const throwOnInvalidTableCfg = (tableCfg) => {
537
+ if (tableCfg.columns.length < 2) {
538
+ throw new Error(
539
+ `Invalid table configuration: Table "${tableCfg.key}" must have at least a _hash and a second column`
540
+ );
541
+ }
542
+ if (tableCfg.columns[0].key !== "_hash") {
543
+ throw new Error(
544
+ `Invalid table configuration: The first column of table "${tableCfg.key}" must be "_hash"`
545
+ );
546
+ }
547
+ if (tableCfg.columns[0].type !== "string") {
548
+ throw new Error(
549
+ `Invalid table configuration: The first _hash column of table "${tableCfg.key}" must be of type "string"`
550
+ );
551
+ }
552
+ for (const column of tableCfg.columns) {
553
+ if (!jsonValueTypes.includes(column.type)) {
554
+ throw new Error(
555
+ `Invalid table configuration: Column "${column.key}" of table "${tableCfg.key}" has an unsupported type "${column.type}"`
556
+ );
557
+ }
558
+ }
559
+ };
536
560
  const exampleTableCfgTable = () => Example.ok.singleRow().tableCfgs;
537
561
  const exampleTableCfg = (tableCfg = void 0) => {
538
562
  return {
539
563
  key: (tableCfg == null ? void 0 : tableCfg.key) ?? "table",
540
- version: 1,
541
564
  columns: (tableCfg == null ? void 0 : tableCfg.columns) ?? [
565
+ {
566
+ key: "_hash",
567
+ type: "string"
568
+ },
542
569
  {
543
570
  key: "a",
544
571
  type: "string"
@@ -1521,5 +1548,6 @@ export {
1521
1548
  iterateTablesSync,
1522
1549
  reservedFieldNames,
1523
1550
  reservedTableKeys,
1524
- rljsonIndexed
1551
+ rljsonIndexed,
1552
+ throwOnInvalidTableCfg
1525
1553
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rljson/rljson",
3
- "version": "0.0.42",
3
+ "version": "0.0.44",
4
4
  "packageManager": "pnpm@10.6.3",
5
5
  "description": "The RLJSON data format specification",
6
6
  "homepage": "https://github.com/rljson/rljson",
@@ -29,9 +29,9 @@
29
29
  "updateGoldens": "cross-env UPDATE_GOLDENS=true npm test"
30
30
  },
31
31
  "devDependencies": {
32
- "@types/node": "^22.15.2",
33
- "@typescript-eslint/eslint-plugin": "^8.31.0",
34
- "@typescript-eslint/parser": "^8.31.0",
32
+ "@types/node": "^22.15.3",
33
+ "@typescript-eslint/eslint-plugin": "^8.31.1",
34
+ "@typescript-eslint/parser": "^8.31.1",
35
35
  "@vitest/coverage-v8": "^3.1.2",
36
36
  "cross-env": "^7.0.3",
37
37
  "eslint": "^9.25.1",
@@ -41,7 +41,7 @@
41
41
  "jsdoc": "^4.0.4",
42
42
  "read-pkg": "^9.0.1",
43
43
  "typescript": "~5.8.3",
44
- "typescript-eslint": "^8.31.0",
44
+ "typescript-eslint": "^8.31.1",
45
45
  "vite": "^6.3.3",
46
46
  "vite-node": "^3.1.2",
47
47
  "vite-plugin-dts": "^4.5.3",