Files
Vector/apps/web/src/lib/queryKeys.ts
T
josh a2b088463d
CI / Lint · Typecheck · Test · Build (push) Successful in 46s
CI / Playwright (smoke) (push) Has been skipped
CI / Build & push images (push) Successful in 1m6s
feat(categories): detail page with fleet insights
Clicking a category anywhere in the app now opens /categories/:id with
MPN breakdown, manufacturer mix, failures by MPN, and past-EOL exposure
— a dual of the manufacturer detail page.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-17 15:41:47 -04:00

106 lines
4.2 KiB
TypeScript

// Hierarchical query keys for TanStack Query. Consumers should import this factory rather than
// hard-coding tuples inline so invalidations can be surgical (e.g. invalidate everything under
// `parts.list()` without touching `parts.detail(id)`).
export const queryKeys = {
auth: {
all: ['auth'] as const,
me: () => [...queryKeys.auth.all, 'me'] as const,
},
parts: {
all: ['parts'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.parts.all, 'list', filters ?? {}] as const,
detail: (id: string) => [...queryKeys.parts.all, 'detail', id] as const,
events: (id: string, filters?: Record<string, unknown>) =>
[...queryKeys.parts.all, 'events', id, filters ?? {}] as const,
},
manufacturers: {
all: ['manufacturers'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.manufacturers.all, 'list', filters ?? {}] as const,
detail: (id: string) => [...queryKeys.manufacturers.all, 'detail', id] as const,
insights: (id: string) => [...queryKeys.manufacturers.all, 'insights', id] as const,
},
sites: {
all: ['sites'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.sites.all, 'list', filters ?? {}] as const,
detail: (id: string) => [...queryKeys.sites.all, 'detail', id] as const,
},
rooms: {
all: ['rooms'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.rooms.all, 'list', filters ?? {}] as const,
},
bins: {
all: ['bins'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.bins.all, 'list', filters ?? {}] as const,
detail: (id: string) => [...queryKeys.bins.all, 'detail', id] as const,
},
users: {
all: ['users'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.users.all, 'list', filters ?? {}] as const,
},
hosts: {
all: ['hosts'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.hosts.all, 'list', filters ?? {}] as const,
detail: (id: string) => [...queryKeys.hosts.all, 'detail', id] as const,
deployedParts: (id: string) => [...queryKeys.hosts.all, 'deployed-parts', id] as const,
timeline: (id: string, filters?: Record<string, unknown>) =>
[...queryKeys.hosts.all, 'timeline', id, filters ?? {}] as const,
},
fms: {
all: ['fms'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.fms.all, 'list', filters ?? {}] as const,
detail: (id: string) => [...queryKeys.fms.all, 'detail', id] as const,
},
repairs: {
all: ['repairs'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.repairs.all, 'list', filters ?? {}] as const,
detail: (id: string) => [...queryKeys.repairs.all, 'detail', id] as const,
},
custody: {
all: ['custody'] as const,
mine: (filters?: Record<string, unknown>) =>
[...queryKeys.custody.all, 'mine', filters ?? {}] as const,
},
partModels: {
all: ['part-models'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.partModels.all, 'list', filters ?? {}] as const,
detail: (id: string) => [...queryKeys.partModels.all, 'detail', id] as const,
insights: (id: string) => [...queryKeys.partModels.all, 'insights', id] as const,
},
tags: {
all: ['tags'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.tags.all, 'list', filters ?? {}] as const,
},
categories: {
all: ['categories'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.categories.all, 'list', filters ?? {}] as const,
detail: (id: string) => [...queryKeys.categories.all, 'detail', id] as const,
insights: (id: string) => [...queryKeys.categories.all, 'insights', id] as const,
},
webhooks: {
all: ['webhooks'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.webhooks.all, 'list', filters ?? {}] as const,
},
savedViews: {
all: ['savedViews'] as const,
list: (resource: string) => [...queryKeys.savedViews.all, resource] as const,
},
analytics: {
all: ['analytics'] as const,
dashboard: () => [...queryKeys.analytics.all, 'dashboard'] as const,
},
} as const;