feat: add TapDefinition, extend ApplicationConfig, and add API hooks
- Add TapDefinition interface for tap configuration - Extend ApplicationConfig with taps, tapVersion, routeRecording, compressSuccess - Add useTestExpression mutation hook (manual fetch to new endpoint) - Add useReplayExchange mutation hook (uses api client, targets single agent) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,18 @@ import { useAuthStore } from '../../auth/auth-store'
|
|||||||
|
|
||||||
// ── Application Config ────────────────────────────────────────────────────
|
// ── Application Config ────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export interface TapDefinition {
|
||||||
|
tapId: string
|
||||||
|
processorId: string
|
||||||
|
target: 'INPUT' | 'OUTPUT' | 'BOTH'
|
||||||
|
expression: string
|
||||||
|
language: string
|
||||||
|
attributeName: string
|
||||||
|
attributeType: 'BUSINESS_OBJECT' | 'CORRELATION' | 'EVENT' | 'CUSTOM'
|
||||||
|
enabled: boolean
|
||||||
|
version: number
|
||||||
|
}
|
||||||
|
|
||||||
export interface ApplicationConfig {
|
export interface ApplicationConfig {
|
||||||
application: string
|
application: string
|
||||||
version: number
|
version: number
|
||||||
@@ -14,6 +26,10 @@ export interface ApplicationConfig {
|
|||||||
metricsEnabled: boolean
|
metricsEnabled: boolean
|
||||||
samplingRate: number
|
samplingRate: number
|
||||||
tracedProcessors: Record<string, string>
|
tracedProcessors: Record<string, string>
|
||||||
|
taps: TapDefinition[]
|
||||||
|
tapVersion: number
|
||||||
|
routeRecording: Record<string, boolean>
|
||||||
|
compressSuccess: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Authenticated fetch using the JWT from auth store */
|
/** Authenticated fetch using the JWT from auth store */
|
||||||
@@ -87,3 +103,61 @@ export function useSendGroupCommand() {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Test Expression ───────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export function useTestExpression() {
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: async ({
|
||||||
|
application,
|
||||||
|
expression,
|
||||||
|
language,
|
||||||
|
body,
|
||||||
|
target,
|
||||||
|
}: {
|
||||||
|
application: string
|
||||||
|
expression: string
|
||||||
|
language: string
|
||||||
|
body: string
|
||||||
|
target: string
|
||||||
|
}) => {
|
||||||
|
const res = await authFetch(
|
||||||
|
`/api/v1/config/${encodeURIComponent(application)}/test-expression`,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ expression, language, body, target }),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
if (!res.ok) {
|
||||||
|
if (res.status === 404) throw new Error('No live agent available')
|
||||||
|
if (res.status === 504) throw new Error('Expression test timed out')
|
||||||
|
throw new Error('Failed to test expression')
|
||||||
|
}
|
||||||
|
return res.json() as Promise<{ result?: string; error?: string }>
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Replay Exchange ───────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export function useReplayExchange() {
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: async ({
|
||||||
|
agentId,
|
||||||
|
headers,
|
||||||
|
body,
|
||||||
|
}: {
|
||||||
|
agentId: string
|
||||||
|
headers: Record<string, string>
|
||||||
|
body: string
|
||||||
|
}) => {
|
||||||
|
const { data, error } = await api.POST('/agents/{id}/commands', {
|
||||||
|
params: { path: { id: agentId } },
|
||||||
|
body: { type: 'replay', payload: { headers, body } } as any,
|
||||||
|
})
|
||||||
|
if (error) throw new Error('Failed to send replay command')
|
||||||
|
return data!
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user