import { Json } from "./json.js"; import { OneOf } from "./oneof.js"; import { Record as RecordBuilder } from "./record.js"; import { Union } from "./union.js"; import { validate } from "./validate.js"; import type { JsonValue, JsonValueSchema } from "./json.js"; import type { JsonSchemaDocument, JsonSchemaDocumentOptions } from "./json-schema-document.js"; import type { OneOfSchema } from "./oneof.js"; import type { RecordSchema } from "./record.js"; import type { UnionSchema } from "./union.js"; import type { ValidationIssue, ValidationResult } from "./validate.js"; type JsonSchemaType = "string" | "number" | "integer" | "boolean" | "array" | "object"; type SchemaKind = "string" | "number" | "boolean" | "enum" | "array" | "object" | "optional" | "oneOf" | "union" | "record" | "json"; type EnumValue = string | number | boolean; type JsonSchemaEnumValue = EnumValue | null; type NumberJsonType = "number" | "integer"; type NonEmptyReadonlyArray = readonly [T, ...T[]]; type ObjectShape = Record; type EmptyOptions = Record; type SchemaScope = "cli" | "mcp" | "sdk"; export type CliOutputMode = "rich" | "md" | "json"; export interface CliMissingParameterChoice { label: string; value: TValue; } export interface CliMissingParameterContext { commandPath: string; params: Readonly>; output: CliOutputMode; stdinTTY: boolean; stdoutTTY: boolean; } export interface CliMissingParameterResolution { choices: readonly CliMissingParameterChoice[]; message?: string; } export interface CliSchemaOptions { resolveMissing?: (context: CliMissingParameterContext) => CliMissingParameterResolution | undefined | Promise | undefined>; } type StringMetadata = { format?: string; maxLength?: number; minLength?: number; pattern?: string; secret?: boolean; }; type NumberMetadata = { maximum?: number; minimum?: number; secret?: boolean; }; type ArrayMetadata = { maxItems?: number; minItems?: number; }; type ObjectMetadata = { additionalProperties?: boolean; }; type OptionalKeys = { [TKey in keyof TShape]: TShape[TKey] extends OptionalSchema ? TKey : never; }[keyof TShape]; type RequiredKeys = Exclude>; type PropertyStatic = TSchema extends OptionalSchema ? Static : Static; type InferObject = { [TKey in RequiredKeys]: PropertyStatic; } & { [TKey in OptionalKeys]?: PropertyStatic; }; type SchemaOptions = { cli?: CliSchemaOptions; description?: string; cliDescription?: string; cliAliases?: readonly string[]; default?: TDefault; nullable?: boolean; requiredScopes?: readonly SchemaScope[]; short?: string; scope?: readonly SchemaScope[]; global?: boolean; }; type WithNullable = TOptions extends { readonly nullable: true; } ? TSchema & { readonly nullable: true; } : TSchema; export interface SchemaBase { readonly kind: TKind; readonly cli?: CliSchemaOptions; readonly description?: string; readonly cliDescription?: string; readonly cliAliases?: readonly string[]; readonly default?: TStatic; readonly nullable?: boolean; readonly requiredScopes?: readonly SchemaScope[]; readonly short?: string; readonly scope?: readonly SchemaScope[]; readonly global?: boolean; readonly __static?: TStatic; } export interface JsonSchema { additionalProperties?: boolean | JsonSchema; type?: JsonSchemaType; description?: string; default?: unknown; enum?: ReadonlyArray; format?: string; items?: JsonSchema; maxItems?: number; maximum?: number; maxLength?: number; minItems?: number; minimum?: number; minLength?: number; nullable?: boolean; oneOf?: JsonSchema[]; pattern?: string; properties?: Record; required?: string[]; } export interface StringSchema extends SchemaBase<"string", string>, StringMetadata { } export interface NumberSchema extends SchemaBase<"number", number>, NumberMetadata { readonly jsonType?: NumberJsonType; } export type BooleanSchema = SchemaBase<"boolean", boolean>; export interface EnumSchema> extends SchemaBase<"enum", TValues[number]> { readonly values: TValues; readonly jsonType?: "integer"; readonly labels?: Partial>; readonly loadOptions?: (() => Array<{ label: string; value: string; }>) | (() => Promise>); } export interface ArraySchema extends SchemaBase<"array", Array>>, ArrayMetadata { readonly item: TItem; } export interface ObjectSchema extends SchemaBase<"object", InferObject>, ObjectMetadata { readonly shape: TShape; } export interface OptionalSchema extends SchemaBase<"optional", Static | undefined> { readonly inner: TInner; } export type AnySchema = StringSchema | NumberSchema | BooleanSchema | EnumSchema> | ArraySchema | ObjectSchema | OptionalSchema | OneOfSchema>, string> | UnionSchema[]> | RecordSchema | JsonValueSchema; export type Static = TSchema extends { readonly nullable: true; } ? TSchema extends SchemaBase ? TStatic | null : never : TSchema extends SchemaBase ? TStatic : never; export declare const S: { readonly String: & StringMetadata = EmptyOptions>(options?: TOptions) => WithNullable; readonly Number: & NumberMetadata & { jsonType?: NumberJsonType; } = EmptyOptions>(options?: TOptions) => WithNullable; readonly Boolean: = EmptyOptions>(options?: TOptions) => WithNullable; readonly Enum: , const TOptions extends SchemaOptions & { jsonType?: "integer"; labels?: Partial>; loadOptions?: (() => Array<{ label: string; value: string; }>) | (() => Promise>); } = EmptyOptions>(values: TValues, options?: TOptions) => WithNullable, TOptions>; readonly Array: >> & ArrayMetadata = EmptyOptions>(item: TItem, options?: TOptions) => WithNullable, TOptions>; readonly Object: > & ObjectMetadata = EmptyOptions>(shape: TShape, options?: TOptions) => WithNullable, TOptions>; readonly Optional: (inner: TInner) => OptionalSchema; readonly OneOf: typeof OneOf; readonly Union: typeof Union; readonly Record: typeof RecordBuilder; readonly Json: typeof Json; }; export declare function toJsonSchema(schema: AnySchema): JsonSchema; export declare function toJsonSchemaDocument(schema: AnySchema, options?: JsonSchemaDocumentOptions): JsonSchemaDocument; export { Json, OneOf, RecordBuilder as Record, Union, validate }; export { compileJsonSchema, formatIssues } from "./json-schema/index.js"; export type { CompileJsonSchemaOptions, CompiledJsonSchema } from "./json-schema/index.js"; export type { JsonSchemaDocument, JsonSchemaDocumentOptions } from "./json-schema-document.js"; export type { JsonValue, JsonValueSchema, OneOfSchema, RecordSchema, UnionSchema, ValidationIssue, ValidationResult };