import { type HashbrownType, type Infer } from './base';
/**
* The Standard Typed interface. This is a base type extended by other specs.
*/
export interface StandardTypedV1 {
/** The Standard properties. */
readonly '~standard': StandardTypedV1.Props;
}
export declare namespace StandardTypedV1 {
/** The Standard Typed properties interface. */
interface Props {
/** The version number of the standard. */
readonly version: 1;
/** The vendor name of the schema library. */
readonly vendor: string;
/** Inferred types associated with the schema. */
readonly types?: Types | undefined;
}
/** The Standard Typed types interface. */
interface Types {
/** The input type of the schema. */
readonly input: Input;
/** The output type of the schema. */
readonly output: Output;
}
/** Infers the input type of a Standard Typed. */
type InferInput = NonNullable['input'];
/** Infers the output type of a Standard Typed. */
type InferOutput = NonNullable['output'];
}
/**
* The Standard JSON Schema interface.
*/
export interface StandardJSONSchemaV1 {
/** The Standard JSON Schema properties. */
readonly '~standard': StandardJSONSchemaV1.Props;
}
export declare namespace StandardJSONSchemaV1 {
/** The Standard JSON Schema properties interface. */
interface Props extends StandardTypedV1.Props {
/** Methods for generating the input/output JSON Schema. */
readonly jsonSchema: StandardJSONSchemaV1.Converter;
}
/** The Standard JSON Schema converter interface. */
interface Converter {
/** Converts the input type to JSON Schema. May throw if conversion is not supported. */
readonly input: (options: StandardJSONSchemaV1.Options) => Record;
/** Converts the output type to JSON Schema. May throw if conversion is not supported. */
readonly output: (options: StandardJSONSchemaV1.Options) => Record;
}
/**
* The target version of the generated JSON Schema.
*
* It is *strongly recommended* that implementers support `"draft-2020-12"` and `"draft-07"`, as they are both in wide use. All other targets can be implemented on a best-effort basis. Libraries should throw if they don't support a specified target.
*
* The `"openapi-3.0"` target is intended as a standardized specifier for OpenAPI 3.0 which is a superset of JSON Schema `"draft-04"`.
*/
type Target = 'draft-2020-12' | 'draft-07' | 'openapi-3.0' | ({} & string);
/** The options for the input/output methods. */
interface Options {
/** Specifies the target version of the generated JSON Schema. Support for all versions is on a best-effort basis. If a given version is not supported, the library should throw. */
readonly target: Target;
/** Explicit support for additional vendor-specific parameters, if needed. */
readonly libraryOptions?: Record | undefined;
}
/** The Standard types interface. */
interface Types extends StandardTypedV1.Types {
}
/** Infers the input type of a Standard. */
type InferInput = StandardTypedV1.InferInput;
/** Infers the output type of a Standard. */
type InferOutput = StandardTypedV1.InferOutput;
}
/**
* Schema inputs accepted by Hashbrown APIs that take input schemas (tools,
* component props, etc.).
*
* @public
*/
export type SchemaInput = HashbrownType | StandardJSONSchemaV1 | object;
/**
* Schema inputs accepted by Hashbrown APIs that produce structured outputs.
*
* @public
*/
export type SchemaOutput = HashbrownType | StandardJSONSchemaV1;
/**
* Infers the input type for a schema-like value.
*
* @public
*/
export type InferSchemaInput = Schema extends HashbrownType ? Infer : Schema extends StandardJSONSchemaV1 ? StandardJSONSchemaV1.InferInput : unknown;
/**
* Infers the output type for a schema-like value.
*
* @public
*/
export type InferSchemaOutput = Schema extends HashbrownType ? Infer : Schema extends StandardJSONSchemaV1 ? StandardJSONSchemaV1.InferOutput : unknown;
/**
* Checks whether a value is a Standard JSON Schema object.
*
* @param schema - The value to inspect.
* @returns True when the value is a Standard JSON Schema object.
* @throws If a `~standard` property exists but is missing `jsonSchema` or its
* required `input`/`output` methods.
* @public
*/
export declare function isStandardJsonSchema(schema: unknown): schema is StandardJSONSchemaV1;
/**
* Converts a Standard JSON Schema object into a Skillet schema.
*
* @typeParam Schema - The Standard JSON Schema type.
* @param schema - The Standard JSON Schema object to convert.
* @param options - Conversion options.
* @returns A Skillet schema derived from the Standard JSON Schema.
* @throws If the Standard JSON Schema object is malformed or if conversion
* fails.
* @public
*/
export declare function fromStandardJsonSchema(schema: Schema, options: {
mode: 'input';
}): HashbrownType>;
/**
* Converts a Standard JSON Schema object into a Skillet schema.
*
* @typeParam Schema - The Standard JSON Schema type.
* @param schema - The Standard JSON Schema object to convert.
* @param options - Conversion options.
* @returns A Skillet schema derived from the Standard JSON Schema.
* @throws If the Standard JSON Schema object is malformed or if conversion
* fails.
* @public
*/
export declare function fromStandardJsonSchema(schema: Schema, options: {
mode: 'output';
}): HashbrownType>;
/**
* Normalizes an input schema into a Skillet schema when possible.
*
* @param schema - The schema to normalize.
* @returns A Skillet schema for Skillet or Standard JSON Schema inputs, or the
* original raw JSON Schema object.
* @throws If the schema advertises `~standard` metadata but is missing required
* Standard JSON Schema fields.
* @public
*/
export declare function normalizeSchemaInput(schema: SchemaInput): HashbrownType | object;
/**
* Normalizes an output schema into a Skillet schema.
*
* @param schema - The schema to normalize.
* @returns A Skillet schema derived from the input.
* @throws If the schema is not a Skillet schema or a valid Standard JSON Schema
* object.
* @public
*/
export declare function normalizeSchemaOutput(schema: SchemaOutput): HashbrownType;
//# sourceMappingURL=standard-json-schema.d.ts.map