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