UNPKG

histoire

Version:

A fast story book powered by Vite

57 lines (56 loc) • 2.32 kB
import { z } from 'zod/v4'; import { mcpIdSchema, mcpProjectIdSchema, mcpRelativePathSchema, mcpRevisionSchema } from './ids.js'; /** Collected variant metadata, without executable state or callbacks. */ export const mcpVariantSchema = z.strictObject({ /** Existing exact variant ID, scoped to containing story. */ id: mcpIdSchema, /** Collected display title. */ title: z.string(), }); /** Stable, explicit catalog projection; arbitrary story metadata never crosses MCP. */ export const mcpStorySchema = z.strictObject({ /** Existing exact story ID. */ id: mcpIdSchema, /** Normalized display title. */ title: z.string(), /** Navigation hierarchy. */ treePath: z.array(z.string()), /** Registered physical or virtual relative path. */ filePath: mcpRelativePathSchema, /** Ownership of the registered story file. */ fileOrigin: z.enum(['project', 'generated', 'external']).optional(), /** Existing framework support identifier. */ supportPluginId: z.string(), /** Optional navigation group. */ group: z.string().optional(), /** Documentation story without executable variant. */ docsOnly: z.boolean(), /** Explicitly projected variants. */ variants: z.array(mcpVariantSchema), /** Catalog content availability. */ docsAvailable: z.boolean(), /** Root-contained source availability. */ sourceAvailable: z.boolean(), /** Distinguishes generated virtual text from a file. */ sourceKind: z.enum(['file', 'virtual', 'unavailable']), }); /** Single-story response with canonical resource references. */ export const mcpStoryResultSchema = z.strictObject({ /** Controller identity. */ projectId: mcpProjectIdSchema, /** Captured completed revision. */ revision: mcpRevisionSchema, /** Explicit story metadata. */ story: mcpStorySchema, /** Links generated by the canonical URI codec. */ resources: z.strictObject({ story: z.string(), docs: z.string().optional(), source: z.string().optional() }), }); /** Preview links resolve exact story/variant tuple. */ export const mcpPreviewResultSchema = z.strictObject({ projectId: mcpProjectIdSchema, revision: mcpRevisionSchema, storyId: mcpIdSchema, variantId: mcpIdSchema, storyUrl: z.url(), sandboxUrl: z.url(), });