import type { QueryClient } from '@tanstack/react-query' const affectedRoots = { agent: ['agents', 'policy-sets', 'dashboard', 'ui-summary', 'stats-recent', 'stats-timeseries'], policy: ['policy-sets', 'agents', 'ui-summary'], list: ['lists', 'policy-sets', 'agents', 'dashboard', 'ui-summary'], settings: ['settings', 'install-context', 'integrations', 'ui-summary'], } as const /** Keep counts, assignments, derived policy previews and the shell consistent * with the resource that was changed. Inactive queries become stale without * being fetched, so closed palette catalogs stay lazy. */ export function invalidateAfterMutation(client: QueryClient, kind: keyof typeof affectedRoots) { return Promise.all(affectedRoots[kind].map((root) => client.invalidateQueries({ queryKey: [root] }))) }