import type { FromSchema, JSONSchema } from 'json-schema-to-ts'; import type { UseInvestigationThroughLensOptions, UseInvestigationThroughLensResult } from './types'; /** * Derives a structured, LLM-generated view of an investigation's report, * shaped by a caller-provided JSON Schema. Declarative: generation runs on * mount and whenever the schema or investigation changes; results are cached * by the Grafana Assistant plugin per (investigation, schema, report * content), so remounts don't regenerate for an unchanged report. * * Field `description`s are per-field instructions to the model — that is the * steering mechanism. Deterministic facts (ids, titles, statuses, timestamps, * links) are provided to the model verbatim and copied through rather than * generated, so reserve schema fields for genuine synthesis from the report. * * Declare the schema with `as const` to get a fully typed `data` inferred * from the schema (via `json-schema-to-ts`): * * @example * ```typescript * const schema = { * type: 'object', * properties: { * headline: { * type: 'string', * description: 'One sentence describing the incident for an executive audience, max 80 characters.', * }, * followUps: { * type: 'array', * description: 'Concrete follow-up actions to prevent recurrence.', * items: { * type: 'object', * properties: { * action: { type: 'string' }, * urgency: { type: 'string', enum: ['now', 'this-week', 'backlog'] }, * }, * required: ['action', 'urgency'], * additionalProperties: false, * }, * }, * }, * required: ['headline', 'followUps'], * additionalProperties: false, * } as const; * * function IncidentReview({ investigationId }: { investigationId: string }) { * const lens = useInvestigationThroughLens(schema, investigationId, { * origin: 'grafana-irm/incident-review', * }); * * if (lens.status === 'loading') return ; * if (lens.status === 'error') return {lens.error.message}; * // lens.data.followUps[0].urgency is 'now' | 'this-week' | 'backlog' * return

{lens.data.headline}

; * } * ``` * * Requires the Grafana Assistant plugin; when it is missing or outdated the * hook resolves to an `error` state with code `unavailable` — it never throws * into the host's render. * * Note on `enabled` gating: re-enabling serves cached results by default. If * the report may have changed while the hook was disabled — e.g. `enabled` * gates on the report streaming — set `refreshOnEnable: true` so the fetch * triggered by the false → true transition bypasses the caches once. */ export declare function useInvestigationThroughLens>(schema: S, investigationId: string, options: UseInvestigationThroughLensOptions): UseInvestigationThroughLensResult; //# sourceMappingURL=useInvestigationThroughLens.d.ts.map