From c4635e2fc4b5ef3e56d472647d6daa7d96372ab5 Mon Sep 17 00:00:00 2001 From: lisonge Date: Tue, 24 Oct 2023 15:13:49 +0800 Subject: [PATCH] chore: deprecatedKeys --- src/file.ts | 10 ++++++++++ src/types.ts | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/src/file.ts b/src/file.ts index 6cec0b3a..f4276382 100644 --- a/src/file.ts +++ b/src/file.ts @@ -88,8 +88,18 @@ export const validSnapshotUrl = (s: string) => { export const checkConfig = (newConfig: SubscriptionConfig) => { // check duplicated group key newConfig.apps?.forEach((app) => { + const deprecatedKeys = app.deprecatedKeys || []; const keys = new Set(); 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)) { console.error({ configName: newConfig.name, diff --git a/src/types.ts b/src/types.ts index bd02f9a2..e9b885af 100644 --- a/src/types.ts +++ b/src/types.ts @@ -103,6 +103,11 @@ export type AppConfig = { */ name: string; groups?: GroupConfig[]; + + /** + * 某些规则组被移除不使用时, 为了避免 key 在后续被复用, 需要将已经删除的规则组的 key 填入此数组做校验使用 + */ + deprecatedKeys?: number[]; } & CommonProps; export type AppConfigMudule = {