@rljson/rljson 0.0.44 → 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 -0
- package/dist/rljson.js +15 -0
- package/package.json +1 -1
|
@@ -72,6 +72,14 @@ export type TablesCfgTable = RljsonTable<TableCfg, 'ingredients'>;
|
|
|
72
72
|
* @param tableCfg - The table configuration to check
|
|
73
73
|
*/
|
|
74
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;
|
|
75
83
|
/**
|
|
76
84
|
* Example matching allTypesRow
|
|
77
85
|
*/
|
package/dist/rljson.js
CHANGED
|
@@ -557,6 +557,20 @@ 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 {
|
|
@@ -1531,6 +1545,7 @@ export {
|
|
|
1531
1545
|
BaseValidator,
|
|
1532
1546
|
Example,
|
|
1533
1547
|
Validate,
|
|
1548
|
+
addColumnsToTableCfg,
|
|
1534
1549
|
bakeryExample,
|
|
1535
1550
|
contentTypes,
|
|
1536
1551
|
exampleBuffetsTable,
|