import { CommandSchema, ExampleMeta } from "../schema/command.mjs"; import "../schema/index.mjs"; import { CLISchema } from "../cli/index.mjs"; //#region src/core/json-schema/index.d.ts /** * Options for JSON Schema generation. * * Both {@link generateSchema} and {@link generateInputSchema} accept these * options to control which parts of the CLI schema are included in the output. */ interface JsonSchemaOptions { /** * Include commands marked as hidden. * * When `true` (default), hidden commands appear in the output with * `hidden: true` (definition schema) or as valid branches (input schema). * When `false`, hidden commands and their entire subtrees are excluded. * * @defaultValue `true` */ readonly includeHidden?: boolean; /** * Include prompt configuration on flags. * * When `false`, prompt configs are omitted even if defined on flags. * Useful for producing a schema focused on the non-interactive CLI * surface only. * * Only affects {@link generateSchema} output — prompt configs are never * included in {@link generateInputSchema} output. * * @defaultValue `true` */ readonly includePrompts?: boolean; } /** * Generate a definition metadata document describing the CLI's structure. * * Walks the full command tree and produces a plain JSON-serializable object * representing all commands, subcommands, flags, args, and metadata. * Non-serializable runtime values (parse functions, middleware handlers, * interactive resolvers) are omitted. * * @param schema - The CLI schema from `CLIBuilder.schema`. * @param options - Generation options. * @param meta - Program name/version for function-form examples; defaults to * the CLI schema's own `name`/`version`. * @returns A plain object suitable for `JSON.stringify()`. * * @example * ```ts * const app = cli('myapp').version('1.0.0').command(deploy); * const definition = generateSchema(app.schema); * writeFileSync('cli-schema.json', JSON.stringify(definition, null, 2)); * ``` */ declare function generateSchema(schema: CLISchema, options?: JsonSchemaOptions, meta?: ExampleMeta): Record; /** * Generate the definition metadata document for a single command. * * The per-command counterpart of {@link generateSchema}: the same * JSON-serializable shape as one entry of its `commands` array (flags, args, * subcommands, examples). Powers `--help` in `--json` mode and is useful for * embedding one command's definition into custom tooling. * * @param schema - The command schema to serialize. * @param options - Generation options. * @param meta - Program name/version for function-form examples; defaults to * the command's own name with no version. * @returns A plain object suitable for `JSON.stringify()`. */ declare function generateCommandSchema(schema: CommandSchema, options?: JsonSchemaOptions, meta?: ExampleMeta): Record; /** * Generate a JSON Schema (draft 2020-12) for validating CLI input as JSON. * * Accepts either a full {@link CLISchema} (producing a discriminated union * across all commands) or a single {@link CommandSchema} (producing a flat * object schema for that command's flags and args). * * **Single command** — produces an object schema where flag/arg names are * properties with appropriate JSON Schema types. * * **Multi-command CLI** — produces a `oneOf` discriminated union with a * `command` property identifying each branch. Nested subcommands use * dot-delimited paths (e.g. `"deploy.rollback"`). * * Only commands with action handlers are included (group commands without * actions are not directly invocable and are skipped). * * @param schema - A CLI schema or a single command schema. * @param options - Generation options. * @returns A JSON Schema object suitable for `JSON.stringify()`. * * @example * ```ts * // Validate a config file against the CLI's input shape * const inputSchema = generateInputSchema(app.schema); * writeFileSync('input-schema.json', JSON.stringify(inputSchema, null, 2)); * ``` */ declare function generateInputSchema(schema: CLISchema | CommandSchema, options?: JsonSchemaOptions): Record; /** * JSON Schema (draft 2020-12) that validates the output of {@link generateSchema}. * * Hosted at {@link DEFINITION_SCHEMA_URL} for `$schema` resolution. Also * exported so tooling can validate definition documents without a network * round-trip. * * @example * ```ts * import Ajv from 'ajv/dist/2020'; * import { definitionMetaSchema, generateSchema } from '@kjanat/dreamcli'; * * const ajv = new Ajv(); * const validate = ajv.compile(definitionMetaSchema); * const valid = validate(generateSchema(myCli.schema)); * ``` */ declare const definitionMetaSchema: Record; //#endregion export { type JsonSchemaOptions, definitionMetaSchema, generateCommandSchema, generateInputSchema, generateSchema };