umwd-components 0.1.837 → 0.1.838
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.
|
@@ -44,38 +44,55 @@ function validateConfig(config) {
|
|
|
44
44
|
if (!config || typeof config !== "object") {
|
|
45
45
|
return {
|
|
46
46
|
isValid: false,
|
|
47
|
-
errors: [
|
|
47
|
+
errors: [
|
|
48
|
+
{ field: "root", message: "Configuration must be a valid object" },
|
|
49
|
+
],
|
|
48
50
|
};
|
|
49
51
|
}
|
|
50
52
|
if (!config.modules || typeof config.modules !== "object") {
|
|
51
|
-
errors.push({
|
|
53
|
+
errors.push({
|
|
54
|
+
field: "modules",
|
|
55
|
+
message: "modules field is required and must be an object",
|
|
56
|
+
});
|
|
52
57
|
}
|
|
53
58
|
else {
|
|
54
59
|
// Validate required modules
|
|
55
60
|
const requiredModules = ["pageBuilder", "ecommerce"];
|
|
56
61
|
for (const module of requiredModules) {
|
|
57
62
|
if (!config.modules[module]) {
|
|
58
|
-
errors.push({
|
|
63
|
+
errors.push({
|
|
64
|
+
field: `modules.${module}`,
|
|
65
|
+
message: `${module} module configuration is required`,
|
|
66
|
+
});
|
|
59
67
|
}
|
|
60
68
|
else if (typeof config.modules[module] !== "object") {
|
|
61
|
-
errors.push({
|
|
69
|
+
errors.push({
|
|
70
|
+
field: `modules.${module}`,
|
|
71
|
+
message: `${module} module must be an object`,
|
|
72
|
+
});
|
|
62
73
|
}
|
|
63
74
|
else if (typeof config.modules[module].enabled !== "boolean") {
|
|
64
|
-
errors.push({
|
|
75
|
+
errors.push({
|
|
76
|
+
field: `modules.${module}.enabled`,
|
|
77
|
+
message: `${module}.enabled must be a boolean`,
|
|
78
|
+
});
|
|
65
79
|
}
|
|
66
80
|
}
|
|
67
81
|
// Validate optional features within modules
|
|
68
|
-
Object.keys(config.modules).forEach(moduleName => {
|
|
82
|
+
Object.keys(config.modules).forEach((moduleName) => {
|
|
69
83
|
const module = config.modules[moduleName];
|
|
70
84
|
if (module && module.features && typeof module.features !== "object") {
|
|
71
|
-
errors.push({
|
|
85
|
+
errors.push({
|
|
86
|
+
field: `modules.${moduleName}.features`,
|
|
87
|
+
message: `${moduleName}.features must be an object`,
|
|
88
|
+
});
|
|
72
89
|
}
|
|
73
90
|
else if (module && module.features) {
|
|
74
|
-
Object.keys(module.features).forEach(featureName => {
|
|
91
|
+
Object.keys(module.features).forEach((featureName) => {
|
|
75
92
|
if (typeof module.features[featureName] !== "boolean") {
|
|
76
93
|
errors.push({
|
|
77
94
|
field: `modules.${moduleName}.features.${featureName}`,
|
|
78
|
-
message: `${moduleName}.features.${featureName} must be a boolean
|
|
95
|
+
message: `${moduleName}.features.${featureName} must be a boolean`,
|
|
79
96
|
});
|
|
80
97
|
}
|
|
81
98
|
});
|
|
@@ -84,7 +101,7 @@ function validateConfig(config) {
|
|
|
84
101
|
}
|
|
85
102
|
return {
|
|
86
103
|
isValid: errors.length === 0,
|
|
87
|
-
errors
|
|
104
|
+
errors,
|
|
88
105
|
};
|
|
89
106
|
}
|
|
90
107
|
/**
|
|
@@ -100,7 +117,9 @@ function loadConfig(useCache = true) {
|
|
|
100
117
|
const config = JSON.parse(configContent);
|
|
101
118
|
const validation = validateConfig(config);
|
|
102
119
|
if (!validation.isValid) {
|
|
103
|
-
const errorMessages = validation.errors
|
|
120
|
+
const errorMessages = validation.errors
|
|
121
|
+
.map((error) => `${error.field}: ${error.message}`)
|
|
122
|
+
.join(", ");
|
|
104
123
|
throw new Error(`Invalid UMWD configuration: ${errorMessages}`);
|
|
105
124
|
}
|
|
106
125
|
cachedConfig = config;
|
|
@@ -169,7 +188,7 @@ function getFullConfig() {
|
|
|
169
188
|
*/
|
|
170
189
|
function getEnabledModules() {
|
|
171
190
|
const config = loadConfig();
|
|
172
|
-
return Object.keys(config.modules).filter(moduleName => {
|
|
191
|
+
return Object.keys(config.modules).filter((moduleName) => {
|
|
173
192
|
const moduleConfig = config.modules[moduleName];
|
|
174
193
|
return moduleConfig && moduleConfig.enabled;
|
|
175
194
|
});
|
|
@@ -187,7 +206,12 @@ function validateCurrentConfig() {
|
|
|
187
206
|
catch (error) {
|
|
188
207
|
return {
|
|
189
208
|
isValid: false,
|
|
190
|
-
errors: [
|
|
209
|
+
errors: [
|
|
210
|
+
{
|
|
211
|
+
field: "file",
|
|
212
|
+
message: error instanceof Error ? error.message : "Unknown error",
|
|
213
|
+
},
|
|
214
|
+
],
|
|
191
215
|
};
|
|
192
216
|
}
|
|
193
217
|
}
|
|
@@ -33,7 +33,7 @@ function filterNavigationByModules(navigation) {
|
|
|
33
33
|
if (item.children) {
|
|
34
34
|
return {
|
|
35
35
|
...item,
|
|
36
|
-
children: filterNavigationByModules(item.children)
|
|
36
|
+
children: filterNavigationByModules(item.children),
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
return item;
|
|
@@ -50,9 +50,9 @@ function isECommerceRoute(href) {
|
|
|
50
50
|
"/user/profile",
|
|
51
51
|
"/cart",
|
|
52
52
|
"/checkout",
|
|
53
|
-
"/check-out"
|
|
53
|
+
"/check-out",
|
|
54
54
|
];
|
|
55
|
-
return ecommercePatterns.some(pattern => href.startsWith(pattern));
|
|
55
|
+
return ecommercePatterns.some((pattern) => href.startsWith(pattern));
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
export { filterNavigationByModules };
|