@redhat-cloud-services/frontend-components-config-utilities 4.14.1 → 4.14.3
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/feo/feo-types.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
var jsVarName_1 = __importDefault(require("../jsVarName"));
|
|
18
18
|
function moduleInterceptor(moduleRegistry, frontendCRD) {
|
|
19
19
|
var _a;
|
|
20
|
-
var moduleName = (0, jsVarName_1.default)(frontendCRD.objects[0].metadata.name);
|
|
20
|
+
var moduleName = frontendCRD.objects[0].spec.module.moduleID || (0, jsVarName_1.default)(frontendCRD.objects[0].metadata.name);
|
|
21
21
|
var cdnPath = frontendCRD.objects[0].spec.frontend.paths[0];
|
|
22
22
|
return __assign(__assign({}, moduleRegistry), (_a = {}, _a[moduleName] = __assign(__assign({}, frontendCRD.objects[0].spec.module), { cdnPath: cdnPath }), _a));
|
|
23
23
|
}
|
|
@@ -730,15 +730,27 @@
|
|
|
730
730
|
"type": "boolean"
|
|
731
731
|
},
|
|
732
732
|
"locales": {
|
|
733
|
+
"$comment": "Mirrors the LocaleCatalogs/LocaleMessages/LocaleMessage validation in api/v1alpha1/locale_types.go of RedHatInsights/frontend-operator, which is the source of truth. Keep these rules in sync with the operator CRD, and the messages in validate-frontend-crd.ts with its XValidation messages.",
|
|
733
734
|
"type": "object",
|
|
734
735
|
"description": "Generated translations keyed by locale and stable message ID",
|
|
736
|
+
"maxProperties": 32,
|
|
735
737
|
"propertyNames": {
|
|
736
|
-
"
|
|
738
|
+
"pattern": "^[a-z]{2,3}(-[A-Z][a-z]{3})?(-([A-Z]{2}|[0-9]{3}))?$",
|
|
739
|
+
"maxLength": 16,
|
|
740
|
+
"not": {
|
|
741
|
+
"const": "en"
|
|
742
|
+
}
|
|
737
743
|
},
|
|
738
744
|
"additionalProperties": {
|
|
739
745
|
"type": "object",
|
|
746
|
+
"maxProperties": 2048,
|
|
747
|
+
"propertyNames": {
|
|
748
|
+
"pattern": "^[A-Za-z0-9][A-Za-z0-9_-]*([.][A-Za-z0-9][A-Za-z0-9_-]*)*$",
|
|
749
|
+
"maxLength": 256
|
|
750
|
+
},
|
|
740
751
|
"additionalProperties": {
|
|
741
|
-
"type": "string"
|
|
752
|
+
"type": "string",
|
|
753
|
+
"maxLength": 4096
|
|
742
754
|
}
|
|
743
755
|
}
|
|
744
756
|
},
|
|
@@ -760,6 +772,10 @@
|
|
|
760
772
|
"manifestLocation": {
|
|
761
773
|
"type": "string"
|
|
762
774
|
},
|
|
775
|
+
"moduleID": {
|
|
776
|
+
"type": "string",
|
|
777
|
+
"description": "Name the module is registered under in fed-modules.json. Defaults to the Frontend name in camelCase."
|
|
778
|
+
},
|
|
763
779
|
"defaultDocumentTitle": {
|
|
764
780
|
"type": "string"
|
|
765
781
|
},
|
|
@@ -3,6 +3,17 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
3
3
|
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
4
|
return cooked;
|
|
5
5
|
};
|
|
6
|
+
var __assign = (this && this.__assign) || function () {
|
|
7
|
+
__assign = Object.assign || function(t) {
|
|
8
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
9
|
+
s = arguments[i];
|
|
10
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
11
|
+
t[p] = s[p];
|
|
12
|
+
}
|
|
13
|
+
return t;
|
|
14
|
+
};
|
|
15
|
+
return __assign.apply(this, arguments);
|
|
16
|
+
};
|
|
6
17
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
19
|
};
|
|
@@ -16,34 +27,71 @@ function readCrdYaml(pathToCrd) {
|
|
|
16
27
|
var data = fs_1.default.readFileSync(pathToCrd, 'utf8');
|
|
17
28
|
return (0, js_yaml_1.load)(data);
|
|
18
29
|
}
|
|
30
|
+
var LOCALE_ID_RULE = /\/locales\/propertyNames\/(pattern|maxLength|not)$/;
|
|
31
|
+
var MESSAGE_KEY_RULE = /\/locales\/additionalProperties\/propertyNames\/(pattern|maxLength)$/;
|
|
32
|
+
var LOCALE_PROPERTY_NAMES = /\/locales(\/additionalProperties)?\/propertyNames$/;
|
|
33
|
+
function describePropertyNameError(error) {
|
|
34
|
+
var where = error.instancePath;
|
|
35
|
+
var propertyName = error.propertyName;
|
|
36
|
+
if (LOCALE_ID_RULE.test(error.schemaPath)) {
|
|
37
|
+
if (error.keyword === 'not') {
|
|
38
|
+
return "".concat(where, ": locale \"").concat(propertyName, "\": English is the source language and must not be listed as a translation");
|
|
39
|
+
}
|
|
40
|
+
if (error.keyword === 'maxLength') {
|
|
41
|
+
return "".concat(where, ": locale \"").concat(propertyName, "\": locale identifiers must be at most ").concat(error.params.limit, " characters");
|
|
42
|
+
}
|
|
43
|
+
return "".concat(where, ": locale \"").concat(propertyName, "\": locale identifiers must use canonical BCP 47 casing, e.g. fr, ko, ja, zh-CN, zh-Hant-TW");
|
|
44
|
+
}
|
|
45
|
+
if (MESSAGE_KEY_RULE.test(error.schemaPath)) {
|
|
46
|
+
if (error.keyword === 'maxLength') {
|
|
47
|
+
return "".concat(where, ": message key \"").concat(propertyName, "\": message keys must be at most ").concat(error.params.limit, " characters");
|
|
48
|
+
}
|
|
49
|
+
return "".concat(where, ": message key \"").concat(propertyName, "\": message keys must be dot-separated paths of letters, digits, '_' and '-' (e.g. searchEntries.rbac-roles.title)");
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
function describeLocaleError(error) {
|
|
54
|
+
var where = error.instancePath;
|
|
55
|
+
if (error.schemaPath.endsWith('/locales/maxProperties')) {
|
|
56
|
+
return "".concat(where, ": at most ").concat(error.params.limit, " locales may be listed");
|
|
57
|
+
}
|
|
58
|
+
if (error.schemaPath.endsWith('/locales/additionalProperties/maxProperties')) {
|
|
59
|
+
return "".concat(where, ": at most ").concat(error.params.limit, " message keys may be listed per locale");
|
|
60
|
+
}
|
|
61
|
+
if (error.schemaPath.endsWith('/locales/additionalProperties/additionalProperties/maxLength')) {
|
|
62
|
+
return "".concat(where, ": message values must be at most ").concat(error.params.limit, " characters");
|
|
63
|
+
}
|
|
64
|
+
if (error.schemaPath.endsWith('/locales/additionalProperties/additionalProperties/type')) {
|
|
65
|
+
return "".concat(where, ": message values must be strings");
|
|
66
|
+
}
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
function improveLocaleErrors(errors) {
|
|
70
|
+
return errors
|
|
71
|
+
.filter(function (error) { return !(error.keyword === 'propertyNames' && LOCALE_PROPERTY_NAMES.test(error.schemaPath)); })
|
|
72
|
+
.map(function (error) {
|
|
73
|
+
var message = error.propertyName === undefined ? describeLocaleError(error) : describePropertyNameError(error);
|
|
74
|
+
return __assign(__assign({}, error), { message: message !== null && message !== void 0 ? message : error.message });
|
|
75
|
+
});
|
|
76
|
+
}
|
|
19
77
|
function validateFrontendCrd(crd) {
|
|
20
|
-
var _a
|
|
78
|
+
var _a;
|
|
21
79
|
var validator = new _2020_1.default({
|
|
22
80
|
strict: true,
|
|
23
81
|
});
|
|
24
|
-
validator.addFormat('bcp47', {
|
|
25
|
-
type: 'string',
|
|
26
|
-
validate: function (locale) {
|
|
27
|
-
try {
|
|
28
|
-
return Intl.getCanonicalLocales(locale).length === 1;
|
|
29
|
-
}
|
|
30
|
-
catch (_a) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
82
|
var crdInternal = typeof crd === 'string' ? readCrdYaml(crd) : crd;
|
|
36
83
|
delete frontend_crd_schema_json_1.default.$schema;
|
|
37
84
|
var validate = validator.compile(frontend_crd_schema_json_1.default);
|
|
38
85
|
var valid = validate(crdInternal);
|
|
39
86
|
if (!valid) {
|
|
40
|
-
(_a = validate.errors)
|
|
87
|
+
var errors = improveLocaleErrors((_a = validate.errors) !== null && _a !== void 0 ? _a : []);
|
|
88
|
+
errors.forEach(function (error) {
|
|
41
89
|
console.group();
|
|
42
90
|
console.log(chalk_1.default.red(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\nFrontend CRD validation error:\n - ", "\n ", "\n ", "\n ", ""], ["\nFrontend CRD validation error:\n - ", "\n ", "\n ", "\n ", ""])), error.message, error.instancePath, error.keyword, JSON.stringify(error.params)));
|
|
43
91
|
console.groupEnd();
|
|
44
92
|
});
|
|
45
|
-
var errorMessages =
|
|
46
|
-
throw new Error("Frontend CRD validation failed! ".concat(
|
|
93
|
+
var errorMessages = errors.map(function (error) { return error.message; }).join(', ');
|
|
94
|
+
throw new Error("Frontend CRD validation failed! ".concat(errorMessages.length > 0 ? errorMessages : 'Unable to validate frontend CRD'));
|
|
47
95
|
}
|
|
48
96
|
}
|
|
49
97
|
exports.default = validateFrontendCrd;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redhat-cloud-services/frontend-components-config-utilities",
|
|
3
|
-
"version": "4.14.
|
|
3
|
+
"version": "4.14.3",
|
|
4
4
|
"description": "Utilities for shared config used in Red Hat Cloud Services project.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"build": "tsc"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"webpack": "^5.
|
|
25
|
-
"webpack-dev-server": "^5.2.
|
|
24
|
+
"webpack": "^5.112.0",
|
|
25
|
+
"webpack-dev-server": "^5.2.7"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@openshift/dynamic-plugin-sdk-webpack": "^4.1.0",
|