chore: deprecatedKeys

This commit is contained in:
lisonge
2023-10-24 15:13:49 +08:00
parent 0410162897
commit c4635e2fc4
2 changed files with 15 additions and 0 deletions

View File

@@ -88,8 +88,18 @@ export const validSnapshotUrl = (s: string) => {
export const checkConfig = (newConfig: SubscriptionConfig) => { export const checkConfig = (newConfig: SubscriptionConfig) => {
// check duplicated group key // check duplicated group key
newConfig.apps?.forEach((app) => { newConfig.apps?.forEach((app) => {
const deprecatedKeys = app.deprecatedKeys || [];
const keys = new Set<number>(); const keys = new Set<number>();
app.groups?.forEach((g) => { app.groups?.forEach((g) => {
if (deprecatedKeys.includes(g.key)) {
console.error({
configName: newConfig.name,
appId: app.id,
groupName: g.name,
groupKey: g.key,
});
throw new Error('invalid deprecated group key');
}
if (keys.has(g.key)) { if (keys.has(g.key)) {
console.error({ console.error({
configName: newConfig.name, configName: newConfig.name,

View File

@@ -103,6 +103,11 @@ export type AppConfig = {
*/ */
name: string; name: string;
groups?: GroupConfig[]; groups?: GroupConfig[];
/**
* 某些规则组被移除不使用时, 为了避免 key 在后续被复用, 需要将已经删除的规则组的 key 填入此数组做校验使用
*/
deprecatedKeys?: number[];
} & CommonProps; } & CommonProps;
export type AppConfigMudule = { export type AppConfigMudule = {