@admin-layout/client 12.0.16-alpha.59 → 12.0.16-alpha.62
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settingsDifference.d.ts","sourceRoot":"","sources":["../../src/utils/settingsDifference.ts"],"names":[],"mappings":"AAkLA;;;GAGG;AACH,eAAO,MAAM,iCAAiC,GAAI,iBAAiB,GAAG,EAAE,iBAAiB,GAAG,
|
|
1
|
+
{"version":3,"file":"settingsDifference.d.ts","sourceRoot":"","sources":["../../src/utils/settingsDifference.ts"],"names":[],"mappings":"AAkLA;;;GAGG;AACH,eAAO,MAAM,iCAAiC,GAAI,iBAAiB,GAAG,EAAE,iBAAiB,GAAG,QA6D3F,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {cloneDeep,
|
|
1
|
+
import {cloneDeep,isObject,isEqual,transform}from'lodash-es';/**
|
|
2
2
|
* Gets the deep differences between two objects
|
|
3
3
|
* Returns only the values that differ from obj2
|
|
4
4
|
*/
|
|
@@ -63,84 +63,6 @@ const getDifference = (obj1, obj2) => {
|
|
|
63
63
|
// Return undefined if the resulting object is empty
|
|
64
64
|
return Object.keys(result).length > 0 ? result : undefined;
|
|
65
65
|
};
|
|
66
|
-
/**
|
|
67
|
-
* Special handler for route settings differences with improved nested comparison
|
|
68
|
-
*/
|
|
69
|
-
const getRouteSettingsDifferences = (currentRouteSettings, defaultRouteSettings) => {
|
|
70
|
-
const differences = {};
|
|
71
|
-
// Get the default route template (typically from '/')
|
|
72
|
-
const defaultRouteTemplate = defaultRouteSettings['/'] || Object.values(defaultRouteSettings)[0];
|
|
73
|
-
if (!defaultRouteTemplate) {
|
|
74
|
-
console.warn('No default route template found for comparison');
|
|
75
|
-
return currentRouteSettings;
|
|
76
|
-
}
|
|
77
|
-
// Compare each route's settings
|
|
78
|
-
Object.keys(currentRouteSettings).forEach((route) => {
|
|
79
|
-
const currentRouteConfig = currentRouteSettings[route];
|
|
80
|
-
// Use the specific route config if it exists, otherwise use the default template
|
|
81
|
-
const defaultRouteConfig = defaultRouteSettings[route] || defaultRouteTemplate;
|
|
82
|
-
// Compare each section separately (layout, regions, etc)
|
|
83
|
-
const routeDiff = {};
|
|
84
|
-
Object.keys(currentRouteConfig).forEach((section) => {
|
|
85
|
-
if (section === 'layout' || section === 'regions') {
|
|
86
|
-
const sectionDiff = {};
|
|
87
|
-
// Compare desktop and mobile separately
|
|
88
|
-
['desktop', 'mobile'].forEach((device) => {
|
|
89
|
-
if (!currentRouteConfig[section][device]) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
// For regions section with header/footer/background
|
|
93
|
-
if (section === 'regions') {
|
|
94
|
-
const regionsDiff = {};
|
|
95
|
-
['header', 'footer', 'background'].forEach((region) => {
|
|
96
|
-
if (!currentRouteConfig[section][device][region]) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
// Get default path for comparison
|
|
100
|
-
const defaultRegionPath = `${section}.${device}.${region}`;
|
|
101
|
-
const defaultRegion = get(defaultRouteConfig, defaultRegionPath);
|
|
102
|
-
if (defaultRegion) {
|
|
103
|
-
const regionDiff = getDifference(currentRouteConfig[section][device][region], defaultRegion);
|
|
104
|
-
if (regionDiff !== undefined &&
|
|
105
|
-
(Array.isArray(regionDiff) || Object.keys(regionDiff).length > 0)) {
|
|
106
|
-
regionsDiff[region] = regionDiff;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
if (Object.keys(regionsDiff).length > 0) {
|
|
111
|
-
sectionDiff[device] = regionsDiff;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
// For other sections (like layout)
|
|
116
|
-
const defaultDevicePath = `${section}.${device}`;
|
|
117
|
-
const defaultDevice = get(defaultRouteConfig, defaultDevicePath);
|
|
118
|
-
if (defaultDevice) {
|
|
119
|
-
const deviceDiff = getDifference(currentRouteConfig[section][device], defaultDevice);
|
|
120
|
-
if (deviceDiff !== undefined && Object.keys(deviceDiff).length > 0) {
|
|
121
|
-
sectionDiff[device] = deviceDiff;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
if (Object.keys(sectionDiff).length > 0) {
|
|
127
|
-
routeDiff[section] = sectionDiff;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
const sectionDiff = getDifference(currentRouteConfig[section], defaultRouteConfig[section]);
|
|
132
|
-
if (sectionDiff !== undefined && Object.keys(sectionDiff).length > 0) {
|
|
133
|
-
routeDiff[section] = sectionDiff;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
// Only include the route if there are actual differences
|
|
138
|
-
if (Object.keys(routeDiff).length > 0) {
|
|
139
|
-
differences[route] = routeDiff;
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
return Object.keys(differences).length > 0 ? differences : undefined;
|
|
143
|
-
};
|
|
144
66
|
/**
|
|
145
67
|
* Compares settings objects and saves only the differences
|
|
146
68
|
* @returns An object containing only the differences, or an empty object on error
|
|
@@ -154,39 +76,46 @@ const compareAndSaveSettingsDifferences = (currentSettings, defaultSettings) =>
|
|
|
154
76
|
// Make deep clones to avoid modifying the original objects
|
|
155
77
|
const current = cloneDeep(currentSettings);
|
|
156
78
|
const defaults = cloneDeep(defaultSettings);
|
|
157
|
-
//
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
79
|
+
// Extract overrides (bracket keys) from current settings
|
|
80
|
+
const overrides = {};
|
|
81
|
+
Object.keys(current).forEach((key) => {
|
|
82
|
+
if (key.startsWith('[') && key.endsWith(']')) {
|
|
83
|
+
overrides[key] = current[key];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
// Get differences for non-override settings (base settings)
|
|
87
|
+
const currentBase = { ...current };
|
|
88
|
+
const defaultBase = { ...defaults };
|
|
89
|
+
// Remove all bracket keys from both objects
|
|
90
|
+
Object.keys(currentBase).forEach((key) => {
|
|
91
|
+
if (key.startsWith('[') && key.endsWith(']')) {
|
|
92
|
+
delete currentBase[key];
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
Object.keys(defaultBase).forEach((key) => {
|
|
96
|
+
if (key.startsWith('[') && key.endsWith(']')) {
|
|
97
|
+
delete defaultBase[key];
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
const baseSettingsDiff = getDifference(currentBase, defaultBase);
|
|
101
|
+
// Combine base settings differences with overrides
|
|
169
102
|
const diffSettings = {};
|
|
170
|
-
// Add
|
|
171
|
-
if (
|
|
172
|
-
Object.assign(diffSettings,
|
|
173
|
-
}
|
|
174
|
-
// Add route settings differences if any exist
|
|
175
|
-
if (routeSettingsDiff && Object.keys(routeSettingsDiff).length > 0) {
|
|
176
|
-
diffSettings.routeSettings = routeSettingsDiff;
|
|
103
|
+
// Add base settings differences if any exist
|
|
104
|
+
if (baseSettingsDiff && Object.keys(baseSettingsDiff).length > 0) {
|
|
105
|
+
Object.assign(diffSettings, baseSettingsDiff);
|
|
177
106
|
}
|
|
107
|
+
// Add all overrides (they are always different from defaults)
|
|
108
|
+
Object.assign(diffSettings, overrides);
|
|
178
109
|
// If there are no differences at all, return early
|
|
179
110
|
if (Object.keys(diffSettings).length === 0) {
|
|
180
111
|
return {};
|
|
181
112
|
}
|
|
182
113
|
// Remove empty objects from the diff
|
|
183
|
-
// This helps prevent unnecessary properties in the payload
|
|
184
114
|
const cleanDiffSettings = removeEmptyObjects(diffSettings);
|
|
185
115
|
return cleanDiffSettings;
|
|
186
116
|
}
|
|
187
117
|
catch (error) {
|
|
188
118
|
console.error('Error comparing settings differences:', error);
|
|
189
|
-
// Return empty object instead of null to avoid downstream errors
|
|
190
119
|
return {};
|
|
191
120
|
}
|
|
192
121
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settingsDifference.js","sources":["../../src/utils/settingsDifference.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAqLG;AACH
|
|
1
|
+
{"version":3,"file":"settingsDifference.js","sources":["../../src/utils/settingsDifference.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAqLG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@admin-layout/client",
|
|
3
|
-
"version": "12.0.16-alpha.
|
|
3
|
+
"version": "12.0.16-alpha.62",
|
|
4
4
|
"description": "Sample client for higher packages to depend on",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"typescript": {
|
|
45
45
|
"definition": "lib/index.d.ts"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "0f34e34fa56ef415cd32998b67df42ab784af9a1"
|
|
48
48
|
}
|