fix(alerts): отклонять запись устаревшего снимка правил

This commit is contained in:
Denozordec committed 2026-10-03 18:41:48 +07:00
1 parent c5c1c2812d
commit 382e318b97
23 files changed
+126 -43

No files matched your search

+3 -2
View File
@@ -102,8 +102,9 @@ function validConfig(value:{groups:{id:string}[];rules:{id:string;groupId:string
const groups=new Set(value.groups.map(row=>row.id)),rules=new Set(value.rules.map(row=>row.id))
return groups.size===value.groups.length&&rules.size===value.rules.length&&value.rules.every(row=>row.groupId===null||groups.has(row.groupId))
}
export const alertsResponseSchema = z.object({telegram:telegramPublicSchema,...alertsConfigResponseShape,history:z.array(alertHistoryResponseSchema),meta:alertsMetaResponseSchema}).strict().refine(validConfig,"Повторяющиеся ID или неизвестная группа правила")
export const alertsRulesReceiptSchema = z.object({ok:z.literal(true),...alertsConfigResponseShape}).strict().refine(validConfig,"Повторяющиеся ID или неизвестная группа правила")
export const alertsRevisionSchema=z.string().regex(/^[a-f0-9]{64}$/)
export const alertsResponseSchema = z.object({revision:alertsRevisionSchema,telegram:telegramPublicSchema,...alertsConfigResponseShape,history:z.array(alertHistoryResponseSchema),meta:alertsMetaResponseSchema}).strict().refine(validConfig,"Повторяющиеся ID или неизвестная группа правила")
export const alertsRulesReceiptSchema = z.object({ok:z.literal(true),revision:alertsRevisionSchema,...alertsConfigResponseShape}).strict().refine(validConfig,"Повторяющиеся ID или неизвестная группа правила")
export const telegramSettingsReceiptSchema = z.object({ok:z.literal(true),telegram:telegramPublicSchema}).strict()
export const telegramTestReceiptSchema = z.object({ok:z.literal(true)}).strict()
export type AlertsResponse = z.output<typeof alertsResponseSchema>