feat: persistent per-application config with GET/PUT endpoints
Add application_config table (V4 migration), repository, and REST
controller. GET /api/v1/config/{app} returns config, PUT saves and
pushes CONFIG_UPDATE to all LIVE agents via SSE. UI tracing toggle
now uses config API instead of direct SET_TRACED_PROCESSORS command.
Tracing store syncs with server config on load.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,51 @@
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api } from '../client'
|
||||
|
||||
// ── Application Config ────────────────────────────────────────────────────
|
||||
|
||||
export interface ApplicationConfig {
|
||||
application: string
|
||||
version: number
|
||||
updatedAt?: string
|
||||
engineLevel?: string
|
||||
payloadCaptureMode?: string
|
||||
metricsEnabled: boolean
|
||||
samplingRate: number
|
||||
tracedProcessors: Record<string, string>
|
||||
}
|
||||
|
||||
export function useApplicationConfig(application: string | undefined) {
|
||||
return useQuery({
|
||||
queryKey: ['applicationConfig', application],
|
||||
queryFn: async () => {
|
||||
const res = await fetch(`/api/v1/config/${application}`)
|
||||
if (!res.ok) throw new Error('Failed to fetch config')
|
||||
return res.json() as Promise<ApplicationConfig>
|
||||
},
|
||||
enabled: !!application,
|
||||
})
|
||||
}
|
||||
|
||||
export function useUpdateApplicationConfig() {
|
||||
const queryClient = useQueryClient()
|
||||
return useMutation({
|
||||
mutationFn: async (config: ApplicationConfig) => {
|
||||
const res = await fetch(`/api/v1/config/${config.application}`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(config),
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to update config')
|
||||
return res.json() as Promise<ApplicationConfig>
|
||||
},
|
||||
onSuccess: (saved) => {
|
||||
queryClient.setQueryData(['applicationConfig', saved.application], saved)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// ── Generic Group Command (kept for non-config commands) ──────────────────
|
||||
|
||||
interface SendGroupCommandParams {
|
||||
group: string
|
||||
type: string
|
||||
|
||||
Reference in New Issue
Block a user