import { Binary, Dict } from 'cosmokit'; import type { StandardSchemaV1 } from '@standard-schema/spec'; declare const kSchema: unique symbol; declare global { namespace Schemastery { type From = X extends string | number | boolean ? Schema : X extends Schema ? X : X extends typeof String ? Schema : X extends typeof Number ? Schema : X extends typeof Boolean ? Schema : X extends typeof Function ? Schema any> : X extends Constructor ? Schema : never; type TypeS1 = X extends Schema ? S : never; type Inverse = X extends Schema ? (arg: Y) => void : never; type TypeS = TypeS1>; type TypeT = ReturnType>; type Resolve = (data: any, schema: Schema, options: Options, strict?: boolean) => [any, any?]; type IntersectS = From extends Schema ? S : never; type IntersectT = Inverse> extends ((arg: infer T) => void) ? T : never; type TupleS = X extends readonly [infer L, ...infer R] ? [TypeS?, ...TupleS] : any[]; type TupleT = X extends readonly [infer L, ...infer R] ? [TypeT?, ...TupleT] : any[]; type ObjectS = { [K in keyof X]?: TypeS | null; } & Dict; type ObjectT = { [K in keyof X]: TypeT; } & Dict; type Constructor = new (...args: any[]) => T; interface Static { (options: Partial>): Schema; new (options: Partial>): Schema; prototype: Schema; resolve: Resolve; from(source?: X): From; extend(type: string, resolve: Resolve): void; any(): Schema; never(): Schema; const(value: T): Schema; string(): Schema; number(): Schema; natural(): Schema; percent(): Schema; boolean(): Schema; date(): Schema; regExp(flag?: string): Schema; arrayBuffer(): Schema; arrayBuffer(encoding: 'hex' | 'base64'): Schema; bitset(bits: Partial>): Schema; function(): Schema any>; is(constructor: string): Schema; is(constructor: Constructor): Schema; array(inner: X): Schema[], TypeT[]>; dict = Schema>(inner: X, sKey?: Y): Schema, TypeS>, Dict, TypeT>>; tuple(list: X): Schema, TupleT>; object(dict: X): Schema, ObjectT>; union(list: readonly X[]): Schema, TypeT>; intersect(list: readonly X[]): Schema, IntersectT>; transform(inner: X, callback: (value: TypeS, options: Schemastery.Options) => T, preserve?: boolean): Schema, T>; lazy(callback: () => X): X; ValidationError: typeof ValidationError; } interface Options { autofix?: boolean; ignore?(data: any, schema: Schema): boolean; path?: (keyof any)[]; } interface Meta { default?: T extends {} ? Partial : T; required?: boolean; disabled?: boolean; collapse?: boolean; badges?: { text: string; type: string; }[]; hidden?: boolean; loose?: boolean; role?: string; extra?: any; link?: string; description?: string | Dict; comment?: string; pattern?: { source: string; flags?: string; }; max?: number; min?: number; step?: number; } } interface Schemastery { (data?: S | null, options?: Schemastery.Options): T; new (data?: S | null, options?: Schemastery.Options): T; [kSchema]: true; uid: number; meta: Schemastery.Meta; type: string; sKey?: Schema; inner?: Schema; list?: Schema[]; dict?: Dict; bits?: Dict; callback?: Function; constructor?: string | Function; builder?: Function; value?: T; refs?: Dict; preserve?: boolean; '~standard': StandardSchemaV1.Props; toString(inline?: boolean): string; toJSON(): Schema; required(value?: boolean): Schema; hidden(value?: boolean): Schema; loose(value?: boolean): Schema; role(text: string, extra?: any): Schema; link(link: string): Schema; default(value: T): Schema; comment(text: string): Schema; description(text: string): Schema; disabled(value?: boolean): Schema; collapse(value?: boolean): Schema; deprecated(): Schema; experimental(): Schema; pattern(regexp: RegExp): Schema; max(value: number): Schema; min(value: number): Schema; step(value: number): Schema; set(key: string, value: Schema): Schema; push(value: Schema): Schema; simplify(value?: any): any; i18n(messages: Dict): Schema; extra(key: K, value: Schemastery.Meta[K]): Schema; } } declare class ValidationError extends TypeError { options: Schemastery.Options; name: string; constructor(message: string, options: Schemastery.Options); static is(error: any): error is ValidationError; } type Schema = Schemastery; declare const Schema: Schemastery.Static; export = Schema;