adminforth 1.3.54-next.18 → 1.3.54-next.19
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.
|
@@ -12,6 +12,7 @@ import fs from 'fs';
|
|
|
12
12
|
import path from 'path';
|
|
13
13
|
import { guessLabelFromName, suggestIfTypo } from './utils.js';
|
|
14
14
|
import crypto from 'crypto';
|
|
15
|
+
import { AdminForthSortDirections } from "adminforth/index.js";
|
|
15
16
|
export default class ConfigValidator {
|
|
16
17
|
constructor(adminforth, config) {
|
|
17
18
|
this.adminforth = adminforth;
|
|
@@ -222,6 +223,22 @@ export default class ConfigValidator {
|
|
|
222
223
|
all: true,
|
|
223
224
|
};
|
|
224
225
|
}
|
|
226
|
+
if (res.options.defaultSort) {
|
|
227
|
+
const colName = res.options.defaultSort.columnName;
|
|
228
|
+
const col = res.columns.find((c) => c.name === colName);
|
|
229
|
+
if (!col) {
|
|
230
|
+
const similar = suggestIfTypo(res.columns.map((c) => c.name), colName);
|
|
231
|
+
errors.push(`Resource "${res.resourceId}" defaultSort.columnName column "${colName}" not found in columns. ${similar ? `Did you mean "${similar}"?` : ''}`);
|
|
232
|
+
}
|
|
233
|
+
const dir = res.options.defaultSort.direction;
|
|
234
|
+
if (!dir) {
|
|
235
|
+
errors.push(`Resource "${res.resourceId}" defaultSort.direction is missing`);
|
|
236
|
+
}
|
|
237
|
+
// AdminForthSortDirections is enum
|
|
238
|
+
if (!Object.values(AdminForthSortDirections).includes(dir)) {
|
|
239
|
+
errors.push(`Resource "${res.resourceId}" defaultSort.direction "${dir}" is invalid, allowed values are ${Object.values(AdminForthSortDirections).join(', ')}`);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
225
242
|
if (Object.keys(res.options.allowedActions).includes('all')) {
|
|
226
243
|
if (Object.keys(res.options.allowedActions).length > 1) {
|
|
227
244
|
errors.push(`Resource "${res.resourceId}" allowedActions cannot have "all" and other keys at same time: ${Object.keys(res.options.allowedActions).join(', ')}`);
|
|
@@ -14,6 +14,7 @@ import path from 'path';
|
|
|
14
14
|
import { guessLabelFromName, suggestIfTypo } from './utils.js';
|
|
15
15
|
|
|
16
16
|
import crypto from 'crypto';
|
|
17
|
+
import { AdminForthSortDirections } from "adminforth/index.js";
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
|
|
@@ -249,6 +250,22 @@ export default class ConfigValidator implements IConfigValidator {
|
|
|
249
250
|
};
|
|
250
251
|
}
|
|
251
252
|
|
|
253
|
+
if (res.options.defaultSort) {
|
|
254
|
+
const colName = res.options.defaultSort.columnName;
|
|
255
|
+
const col = res.columns.find((c) => c.name === colName);
|
|
256
|
+
if (!col) {
|
|
257
|
+
const similar = suggestIfTypo(res.columns.map((c) => c.name), colName);
|
|
258
|
+
errors.push(`Resource "${res.resourceId}" defaultSort.columnName column "${colName}" not found in columns. ${similar ? `Did you mean "${similar}"?` : ''}`);
|
|
259
|
+
}
|
|
260
|
+
const dir = res.options.defaultSort.direction;
|
|
261
|
+
if (!dir) {
|
|
262
|
+
errors.push(`Resource "${res.resourceId}" defaultSort.direction is missing`);
|
|
263
|
+
}
|
|
264
|
+
// AdminForthSortDirections is enum
|
|
265
|
+
if (!(Object.values(AdminForthSortDirections) as string[]).includes(dir)) {
|
|
266
|
+
errors.push(`Resource "${res.resourceId}" defaultSort.direction "${dir}" is invalid, allowed values are ${Object.values(AdminForthSortDirections).join(', ')}`);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
252
269
|
|
|
253
270
|
if (Object.keys(res.options.allowedActions).includes('all')) {
|
|
254
271
|
if (Object.keys(res.options.allowedActions).length > 1) {
|