/** * Query keys factory for TanStack Query * * Provides consistent, type-safe query keys across the application. * Pattern: [entity, scope, ...params] * * Examples: * - ['users'] - all users * - ['users', 'list', { role: 'admin' }] - filtered list * - ['users', 'detail', '123'] - specific user */ export const queryKeys = { // User queries users: { all: ['users'] as const, lists: () => [...queryKeys.users.all, 'list'] as const, list: (filters?: Record) => [...queryKeys.users.lists(), filters] as const, details: () => [...queryKeys.users.all, 'detail'] as const, detail: (id: string) => [...queryKeys.users.details(), id] as const, }, // Company queries companies: { all: ['companies'] as const, lists: () => [...queryKeys.companies.all, 'list'] as const, list: (filters?: Record) => [...queryKeys.companies.lists(), filters] as const, details: () => [...queryKeys.companies.all, 'detail'] as const, detail: (id: string) => [...queryKeys.companies.details(), id] as const, }, // Tenant queries tenants: { all: ['tenants'] as const, lists: () => [...queryKeys.tenants.all, 'list'] as const, list: (filters?: Record) => [...queryKeys.tenants.lists(), filters] as const, details: () => [...queryKeys.tenants.all, 'detail'] as const, detail: (id: string) => [...queryKeys.tenants.details(), id] as const, }, // InfoCenter queries infoCenter: { all: ['infoCenter'] as const, pages: (tenantId: string, params?: { page?: number; limit?: number }) => [...queryKeys.infoCenter.all, 'pages', tenantId, params] as const, analyses: (tenantId: string, params?: { skip?: number; limit?: number; reliabilityStatus?: string }) => [...queryKeys.infoCenter.all, 'analyses', tenantId, params] as const, elements: (tenantId: string) => [...queryKeys.infoCenter.all, 'elements', tenantId] as const, statistics: (tenantId: string) => [...queryKeys.infoCenter.all, 'statistics', tenantId] as const, scanStatus: (tenantId: string, jobId: string) => [...queryKeys.infoCenter.all, 'scanStatus', tenantId, jobId] as const, }, // IntegrationKeys queries integrationKeys: { all: ['integrationKeys'] as const, lists: () => [...queryKeys.integrationKeys.all, 'list'] as const, list: (tenantId: string, filters?: Record) => [...queryKeys.integrationKeys.lists(), tenantId, filters] as const, details: () => [...queryKeys.integrationKeys.all, 'detail'] as const, detail: (id: string) => [...queryKeys.integrationKeys.details(), id] as const, stats: (tenantId: string) => [...queryKeys.integrationKeys.all, 'stats', tenantId] as const, }, // Subscription queries subscription: { all: ['subscription'] as const, current: () => [...queryKeys.subscription.all, 'current'] as const, plans: () => [...queryKeys.subscription.all, 'plans'] as const, usage: () => [...queryKeys.subscription.all, 'usage'] as const, invoices: () => [...queryKeys.subscription.all, 'invoices'] as const, commandStats: () => [...queryKeys.subscription.all, 'commandStats'] as const, configurableCaps: () => [...queryKeys.subscription.all, 'configurableCaps'] as const, }, // Knowledge queries knowledge: { all: ['knowledge'] as const, lists: () => [...queryKeys.knowledge.all, 'list'] as const, list: (tenantId: string, filters?: Record) => [...queryKeys.knowledge.lists(), tenantId, filters] as const, details: () => [...queryKeys.knowledge.all, 'detail'] as const, detail: (tenantId: string, id: string) => [...queryKeys.knowledge.details(), tenantId, id] as const, stats: (tenantId: string) => [...queryKeys.knowledge.all, 'stats', tenantId] as const, documentLists: (tenantId: string) => [...queryKeys.knowledge.all, 'documents', tenantId] as const, documents: (tenantId: string, filters?: Record) => [...queryKeys.knowledge.documentLists(tenantId), 'list', filters] as const, document: (tenantId: string, id: string) => [...queryKeys.knowledge.documentLists(tenantId), 'detail', id] as const, }, // Notification queries notifications: { all: ['notifications'] as const, }, // Profile queries profile: { all: ['profile'] as const, current: () => [...queryKeys.profile.all, 'current'] as const, }, } as const;