perf: check deprecatedKeys

This commit is contained in:
AIsouler
2024-08-06 22:09:41 +08:00
parent cd98657fb4
commit 8dd77e8729

View File

@@ -18,23 +18,22 @@ interface RawDeprecatedKeysSetting {
}
export const checkDeprecatedGroupKeys = (apps: RawApp[]) => {
apps.forEach((a) => {
appDeprecatedKeys.forEach((d) => {
if (a.id === d.id) {
a.groups.forEach((g) => {
if (d.deprecatedKeys.indexOf(g.key.valueOf()) !== -1) {
apps.forEach((app) => {
const deprecatedKeys = appDeprecatedKeysMap.get(app.id);
if (deprecatedKeys) {
app.groups.forEach(({ key, name }) => {
if (deprecatedKeys.includes(key)) {
console.error({
configName: a.name,
appId: a.id,
groupName: g.name,
groupKey: g.key,
configName: app.name,
appId: app.id,
groupName: name,
groupKey: key,
});
throw new Error('invalid deprecated group key');
}
});
}
});
});
};
const appDeprecatedKeys: RawDeprecatedKeysSetting[] = [
@@ -555,3 +554,11 @@ const appDeprecatedKeys: RawDeprecatedKeysSetting[] = [
deprecatedKeys: [2],
},
];
const map: Map<string, number[]> = new Map();
appDeprecatedKeys.forEach(({ id, deprecatedKeys }) => {
map.set(id, deprecatedKeys);
});
const appDeprecatedKeysMap = map;