@rljson/rljson 0.0.43 → 0.0.45
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 +8 -5
- package/dist/rljson.js +15 -1
- package/package.json +5 -5
|
@@ -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
|
*
|
|
@@ -77,6 +72,14 @@ export type TablesCfgTable = RljsonTable<TableCfg, 'ingredients'>;
|
|
|
77
72
|
* @param tableCfg - The table configuration to check
|
|
78
73
|
*/
|
|
79
74
|
export declare const throwOnInvalidTableCfg: (tableCfg: TableCfg) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Add columns to table config
|
|
77
|
+
* @param tableCfg - The table configuration to add columns to
|
|
78
|
+
* @param columns - The columns to add
|
|
79
|
+
* @returns The updated table configuration
|
|
80
|
+
* @throws Error if the columns already exist in the table configuration
|
|
81
|
+
*/
|
|
82
|
+
export declare const addColumnsToTableCfg: (tableCfg: TableCfg, columns: ColumnCfg[]) => TableCfg;
|
|
80
83
|
/**
|
|
81
84
|
* Example matching allTypesRow
|
|
82
85
|
*/
|
package/dist/rljson.js
CHANGED
|
@@ -557,11 +557,24 @@ const throwOnInvalidTableCfg = (tableCfg) => {
|
|
|
557
557
|
}
|
|
558
558
|
}
|
|
559
559
|
};
|
|
560
|
+
const addColumnsToTableCfg = (tableCfg, columns) => {
|
|
561
|
+
const existingKeys = new Set(tableCfg.columns.map((c) => c.key));
|
|
562
|
+
const duplicates = columns.filter((col) => existingKeys.has(col.key));
|
|
563
|
+
if (duplicates.length > 0) {
|
|
564
|
+
const keys = duplicates.map((d) => d.key).join(", ");
|
|
565
|
+
throw new Error(
|
|
566
|
+
`The following columns already exist in the table "${tableCfg.key}": ${keys}`
|
|
567
|
+
);
|
|
568
|
+
}
|
|
569
|
+
return hsh({
|
|
570
|
+
...tableCfg,
|
|
571
|
+
columns: [...tableCfg.columns, ...columns]
|
|
572
|
+
});
|
|
573
|
+
};
|
|
560
574
|
const exampleTableCfgTable = () => Example.ok.singleRow().tableCfgs;
|
|
561
575
|
const exampleTableCfg = (tableCfg = void 0) => {
|
|
562
576
|
return {
|
|
563
577
|
key: (tableCfg == null ? void 0 : tableCfg.key) ?? "table",
|
|
564
|
-
version: 1,
|
|
565
578
|
columns: (tableCfg == null ? void 0 : tableCfg.columns) ?? [
|
|
566
579
|
{
|
|
567
580
|
key: "_hash",
|
|
@@ -1532,6 +1545,7 @@ export {
|
|
|
1532
1545
|
BaseValidator,
|
|
1533
1546
|
Example,
|
|
1534
1547
|
Validate,
|
|
1548
|
+
addColumnsToTableCfg,
|
|
1535
1549
|
bakeryExample,
|
|
1536
1550
|
contentTypes,
|
|
1537
1551
|
exampleBuffetsTable,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rljson/rljson",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.45",
|
|
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.
|
|
33
|
-
"@typescript-eslint/eslint-plugin": "^8.31.
|
|
34
|
-
"@typescript-eslint/parser": "^8.31.
|
|
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.
|
|
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",
|