import type * as T from '@traversable/registry'; import type { Integer, Label, Natural as NaturalNumber, SchemaOptions as Options, TypeError, Unknown } from '@traversable/registry'; import { symbol, URI } from '@traversable/registry'; import type { Guard, Predicate as AnyPredicate, Typeguard, ValidateTuple } from './types.js'; export declare const isPredicate: (got: unknown) => got is { (): boolean; (x: S): x is T; }; export type Source = T extends (_: infer S) => unknown ? S : unknown; export type Target = never | S extends (_: any) => _ is infer T ? T : S; export type Inline = never | of>; export type Predicate = AnyPredicate | Schema; export type Force = never | { -readonly [K in keyof T]: T[K]; }; export type Optional = never | string extends K ? string : K extends K ? S[K] extends bottom | optional ? K : never : never; export type FirstOptionalItem = S extends readonly [infer H, ...infer T] ? optional extends H ? Offset['length'] : FirstOptionalItem : never; export type Required = never | string extends K ? string : K extends K ? S[K] extends bottom | optional ? never : K : never; export type Entry = [Schema] extends [S] ? Schema : S extends { def: unknown; } ? S : S extends Guard ? of : S extends globalThis.BooleanConstructor ? nonnullable : S extends (() => infer _ extends boolean) ? BoolLookup[`${_}`] : S; export type BoolLookup = never | { true: top; false: bottom; boolean: unknown_; }; export type IntersectType = Todo extends readonly [infer H, ...infer T] ? IntersectType : Out; export type TupleType = never | optional extends T[number & keyof T] ? T extends readonly [infer Head, ...infer Tail] ? [Head] extends [optional] ? Label<{ [ix in keyof Out]: Out[ix]['_type' & keyof Out[ix]]; }, { [ix in keyof T]: T[ix]['_type' & keyof T[ix]]; }> : TupleType : never : { [ix in keyof T]: T[ix]['_type' & keyof T[ix]]; }; export type typeOf = never | _; export interface LowerBound { readonly _type?: T; (got: Unknown): got is T; (got: unknown): got is T; tag?: string; def?: unknown; } export interface Schema { readonly _type?: Fn['_type']; (got: Unknown): got is Fn['_type']; (got: unknown): got is Fn['_type']; tag?: Fn['tag']; def?: Fn['def']; } export type Type = F; export type Unary = eq | ref | array | record | optional | union | intersect | tuple | object_<{ [x: string]: Unary; }>; export type F = Leaf | eq | ref | array | record | optional | union | intersect | tuple | object_<{ [x: string]: T; }>; export type Fixpoint = Leaf | Unary; export interface Free extends T.HKT { [-1]: F; } export interface of { readonly _type: Target; (got: this['_type'] | Unknown): got is this['_type']; (got: unknown): got is this['_type']; tag: URI.inline; def: S; } export declare function of(typeguard: S): Entry; export declare function of(typeguard: S): of>; export declare namespace of { let prototype: { tag: "@traversable/schema/URI::inline"; }; type type> = never | T; function def(guard: T): of; } export interface top { readonly _type: unknown; tag: URI.top; def: unknown; } export interface bottom { readonly _type: never; tag: URI.bottom; def: never; } export interface invalid<_Err> extends TypeError<''>, never_ { } export { void_ as void }; interface void_ { readonly _type: void; (got: this['_type'] | Unknown): got is void; (got: unknown): got is void; tag: URI.void; def: void; } declare const void_: void_; export { never_ as never }; interface never_ { readonly _type: never; (got: unknown): got is never; tag: URI.never; def: never; } declare const never_: never_; export { unknown_ as unknown }; interface unknown_ { readonly _type: unknown; (got: unknown): got is unknown; tag: URI.unknown; def: unknown; } declare const unknown_: unknown_; export { any_ as any }; interface any_ { readonly _type: any; (got: unknown): got is any; tag: URI.any; def: any; } declare const any_: any_; export { null_ as null }; interface null_ { readonly _type: null; (got: null | Unknown): got is null; (got: unknown): got is null; tag: URI.null; def: this['_type']; } declare const null_: null_; export { undefined_ as undefined }; interface undefined_ { readonly _type: undefined; (got: undefined | Unknown): got is undefined; (got: unknown): got is undefined; tag: URI.undefined; def: undefined; } declare const undefined_: undefined_; export { symbol_ as symbol }; interface symbol_ { readonly _type: symbol; (got: symbol | Unknown): got is symbol; (got: unknown): got is symbol; tag: URI.symbol; def: symbol; } declare const symbol_: symbol_; export { boolean_ as boolean }; interface boolean_ { readonly _type: boolean; (got: boolean | Unknown): got is boolean; (got: unknown): got is boolean; tag: URI.boolean; def: boolean; } declare const boolean_: boolean_; export { integer }; interface integer extends integer.methods { readonly _type: number; (got: number | Unknown): got is number; (got: unknown): got is number; tag: URI.integer; def: this['_type']; minimum?: number; maximum?: number; } declare namespace integer { type Min = [Self] extends [{ maximum: number; }] ? integer.between<[min: X, max: Self['maximum']]> : integer.min; type Max = [Self] extends [{ minimum: number; }] ? integer.between<[min: Self['minimum'], max: X]> : integer.max; interface methods { min>(minimum: Min): integer.Min; max>(maximum: Max): integer.Max; between, Max extends Integer>(minimum: Min, maximum: Max): integer.between<[min: Min, max: Max]>; } interface min extends integer { minimum: Min; } interface max extends integer { maximum: Max; } interface between extends integer { minimum: Bounds[0]; maximum: Bounds[1]; } } declare const integer: integer; export { bigint_ as bigint }; interface bigint_ extends bigint_.methods { readonly _type: bigint; (got: bigint | Unknown): got is bigint; (got: unknown): got is bigint; tag: URI.bigint; def: this['_type']; minimum?: bigint; maximum?: bigint; } declare namespace bigint_ { type Min = [Self] extends [{ maximum: bigint; }] ? bigint_.between<[min: X, max: Self['maximum']]> : bigint_.min; type Max = [Self] extends [{ minimum: bigint; }] ? bigint_.between<[min: Self['minimum'], max: X]> : bigint_.max; interface methods extends Typeguard { min(minimum: Min): bigint_.Min; max(maximum: Max): bigint_.Max; between(minimum: Min, maximum: Max): bigint_.between<[min: Min, max: Max]>; } interface min extends bigint_ { minimum: Min; } interface max extends bigint_ { maximum: Max; } interface between extends bigint_ { minimum: Bounds[0]; maximum: Bounds[1]; } } declare const bigint_: bigint_; export { number_ as number }; interface number_ extends number_.methods { readonly _type: number; (got: number | Unknown): got is number; (got: unknown): got is number; tag: URI.number; def: number; minimum?: number; maximum?: number; exclusiveMinimum?: number; exclusiveMaximum?: number; } declare namespace number_ { interface methods { min(minimum: Min): number_.Min; max(maximum: Max): number_.Max; moreThan(moreThan: Min): ExclusiveMin; lessThan(lessThan: Max): ExclusiveMax; between(minimum: Min, maximum: Max): number_.between<[min: Min, max: Max]>; } type Min = [Self] extends [{ exclusiveMaximum: number; }] ? number_.minStrictMax<[min: X, lessThan: Self['exclusiveMaximum']]> : [Self] extends [{ maximum: number; }] ? number_.between<[min: X, max: Self['maximum']]> : number_.min; type Max = [Self] extends [{ exclusiveMinimum: number; }] ? number_.maxStrictMin<[moreThan: Self['exclusiveMinimum'], max: X]> : [Self] extends [{ minimum: number; }] ? number_.between<[min: Self['minimum'], max: X]> : number_.max; type ExclusiveMin = [Self] extends [{ exclusiveMaximum: number; }] ? number_.strictlyBetween<[moreThan: X, lessThan: Self['exclusiveMaximum']]> : [Self] extends [{ maximum: number; }] ? number_.maxStrictMin<[moreThan: X, max: Self['maximum']]> : number_.moreThan; type ExclusiveMax = [Self] extends [{ exclusiveMinimum: number; }] ? number_.strictlyBetween<[moreThan: Self['exclusiveMinimum'], lessThan: X]> : [Self] extends [{ minimum: number; }] ? number_.minStrictMax<[min: Self['minimum'], lessThan: X]> : number_.lessThan; interface min extends number_ { minimum: Min; } interface max extends number_ { maximum: Max; } interface moreThan extends number_ { exclusiveMinimum: Min; } interface lessThan extends number_ { exclusiveMaximum: Max; } interface between extends number_ { minimum: Bounds[0]; maximum: Bounds[1]; } interface minStrictMax extends number_ { minimum: Bounds[0]; exclusiveMaximum: Bounds[1]; } interface maxStrictMin extends number_ { maximum: Bounds[1]; exclusiveMinimum: Bounds[0]; } interface strictlyBetween extends number_ { exclusiveMinimum: Bounds[0]; exclusiveMaximum: Bounds[1]; } } declare const number_: number_; export { string_ as string }; interface string_ extends string_.methods { _type: string; (got: string | Unknown): got is string; (got: unknown): got is string; tag: URI.string; def: this['_type']; minLength?: number; maxLength?: number; } declare namespace string_ { interface methods { min>(minLength: Min): string_.Min; max>(maxLength: Max): string_.Max; between, Max extends NaturalNumber>(minLength: Min, maxLength: Max): string_.between<[min: Min, max: Max]>; } type Min = [Self] extends [{ maxLength: number; }] ? string_.between<[min: Min, max: Self['maxLength']]> : string_.min; type Max = [Self] extends [{ minLength: number; }] ? string_.between<[min: Self['minLength'], max: Max]> : string_.max; interface min extends string_ { minLength: Min; } interface max extends string_ { maxLength: Max; } interface between extends string_ { minLength: Bounds[0]; maxLength: Bounds[1]; } } declare const string_: string_; export { nonnullable }; interface nonnullable extends Typeguard<{}> { readonly _type: {}; (got: {} | Unknown): got is {}; (got: unknown): got is {}; tag: URI.nonnullable; def: {}; } declare const nonnullable: nonnullable; export declare function eq>(value: V, options?: Options): eq>; export declare function eq(value: V, options?: Options): eq; export interface eq { readonly _type: V; (got: V | Unknown): got is V; (got: unknown): got is V; tag: URI.eq; def: V; } export declare namespace eq { let prototype: { tag: "@traversable/schema/URI::eq"; }; function def(value: T, options?: Options): eq; } export declare function optional(schema: S): optional; export declare function optional(schema: S): optional>; export interface optional { readonly _type: undefined | S['_type' & keyof S]; (got: this['_type'] | Unknown): got is this['_type']; (got: unknown): got is this['_type']; tag: URI.optional; def: S; [symbol.optional]: number; } export declare namespace optional { let prototype: { tag: "@traversable/schema/URI::optional"; }; type type = never | T; function def(x: T): optional; const is: (got: unknown) => got is optional; } export interface ref { readonly _type: S['_type' & keyof S]; (got: this['_type'] | Unknown): got is this['_type']; (got: Unknown): got is this['_type']; tag: URI.ref; id: Id; def: S; toString(): Id; } export declare function ref(schema: S, id: Id): ref; export declare namespace ref { let prototype: { tag: string; }; function def(schema: S, id: Id): ref; } export declare function array(schema: S, readonly: 'readonly'): ReadonlyArray; export declare function array(schema: S): array; export declare function array(schema: S): array>; export interface array extends array.methods { readonly _type: S['_type' & keyof S][]; (got: this['_type'] | Unknown): got is this['_type']; (got: unknown): got is this['_type']; tag: URI.array; def: S; minLength?: number; maxLength?: number; } export declare namespace array { interface methods { min>(minLength: Min): array.Min; max>(maxLength: Max): array.Max; between, Max extends NaturalNumber>(minLength: Min, maxLength: Max): array.between<[min: Min, max: Max], S>; } type Min = [Self] extends [{ maxLength: number; }] ? array.between<[min: Min, max: Self['maxLength']], Self['def' & keyof Self]> : array.min; type Max = [Self] extends [{ minLength: number; }] ? array.between<[min: Self['minLength'], max: Max], Self['def' & keyof Self]> : array.max; interface min extends array { minLength: Min; } interface max extends array { maxLength: Max; } interface between extends array { minLength: Bounds[0]; maxLength: Bounds[1]; } type type = never | S['_type' & keyof S][]; } export declare namespace array { let prototype: array; function def(x: S, prev?: array): array; function def(x: S, prev?: unknown): array; function def(x: S, prev?: array): array; } export declare const readonlyArray: { (schema: S, readonly: 'readonly'): ReadonlyArray; (schema: S): ReadonlyArray>; }; export interface ReadonlyArray { readonly _type: readonly S['_type' & keyof S][]; (got: this['_type'] | Unknown): got is this['_type']; (got: unknown): got is this['_type']; tag: URI.array; def: S; } export declare function record(schema: S): record; export declare function record(schema: S): record>; export interface record { readonly _type: Record; (got: this['_type'] | Unknown): got is this['_type']; (got: unknown): got is this['_type']; tag: URI.record; def: S; } export declare namespace record { let prototype: record; type type> = never | T; function def(x: T): record; } export declare function union(...schemas: S): union; export declare function union; }>(...schemas: S): union; export interface union { readonly _type: S[number & keyof S]['_type' & keyof S[number & keyof S]]; (got: this['_type'] | Unknown): got is this['_type']; (got: unknown): got is this['_type']; tag: URI.union; def: S; } export declare namespace union { let prototype: union; type type = never | T; function def(xs: T): union; } export declare function intersect(...schemas: S): intersect; export declare function intersect; }>(...schemas: S): intersect; export interface intersect { _type: IntersectType; (got: this['_type'] | Unknown): got is this['_type']; (got: unknown): got is this['_type']; tag: URI.intersect; def: S; } export declare namespace intersect { let prototype: intersect; type type> = never | T; function def(xs: readonly [...T]): intersect; } export { tuple }; declare function tuple; }>(...schemas: tuple.validate): tuple, T>>; declare function tuple(...schemas: tuple.validate): tuple, S>>; declare function tuple; }>(...args: [...schemas: tuple.validate, options: Options]): tuple, T>>; declare function tuple(...args: [...schemas: tuple.validate, options: Options]): tuple, S>>; declare function tuple; }>(...schemas: tuple.validate): tuple, T>>; declare function tuple(...schemas: tuple.validate): tuple, S>>; interface tuple { readonly _type: TupleType; (got: this['_type'] | Unknown): got is this['_type']; (got: unknown): got is this['_type']; tag: URI.tuple; def: S; opt: FirstOptionalItem; } declare namespace tuple { let prototype: tuple; function def(xs: readonly [...T], $?: Options, opt_?: number): tuple; } declare namespace tuple { type type = never | TupleType; type validate = ValidateTuple>; type from = TypeError extends V[number] ? { [I in keyof V]: V[I] extends TypeError ? invalid> : V[I]; } : T; type InternalOptions = { minLength?: number; }; } export { object_ as object }; declare function object_; }>(schemas: S, options?: Options): object_; declare function object_; }>(schemas: S, options?: Options): object_; interface object_ { readonly _type: object_.type; (got: this['_type'] | Unknown): got is this['_type']; (got: unknown): got is this['_type']; tag: URI.object; def: S; opt: Optional[]; req: Required[]; } declare namespace object_ { let prototype: object_; type Opt = symbol.optional extends keyof S[K] ? never : K; type Req = symbol.optional extends keyof S[K] ? K : never; type type = Force<{ [K in keyof S as Opt]-?: S[K]['_type' & keyof S[K]]; } & { [K in keyof S as Req]+?: S[K]['_type' & keyof S[K]]; }>; function def(xs: T, $?: Options, opt?: string[]): object_; function def(xs: T, $?: Options, opt?: string[]): object_; } export type Leaf = typeof leaves[number]; export type LeafTag = Leaf['tag']; export type Nullary = typeof nullaries[number]; export type NullaryTag = Nullary['tag']; export type Boundable = typeof boundables[number]; export type BoundableTag = Boundable['tag']; export type Tag = typeof tags[number]; export type TypeName = T.TypeName; export type UnaryTag = typeof unaryTags[number]; export type UnaryTypeName = T.TypeName; export declare const nullaries: (unknown_ | never_ | any_ | void_ | undefined_ | null_ | symbol_ | boolean_)[]; export declare const nullaryTags: ("@traversable/schema/URI::boolean" | "@traversable/schema/URI::unknown" | "@traversable/schema/URI::never" | "@traversable/schema/URI::any" | "@traversable/schema/URI::void" | "@traversable/schema/URI::undefined" | "@traversable/schema/URI::null" | "@traversable/schema/URI::symbol")[]; export declare const isNullaryTag: (got: unknown) => got is NullaryTag; export declare const isNullary: (got: unknown) => got is Nullary; export declare const boundables: (integer | bigint_ | number_ | string_)[]; export declare const boundableTags: ("@traversable/schema/URI::string" | "@traversable/schema/URI::integer" | "@traversable/schema/URI::bigint" | "@traversable/schema/URI::number")[]; export declare const isBoundableTag: (got: unknown) => got is BoundableTag; export declare const isBoundable: (got: unknown) => got is Boundable; export declare const leaves: (unknown_ | never_ | any_ | void_ | undefined_ | null_ | symbol_ | boolean_ | integer | bigint_ | number_ | string_)[]; export declare const leafTags: ("@traversable/schema/URI::boolean" | "@traversable/schema/URI::unknown" | "@traversable/schema/URI::never" | "@traversable/schema/URI::any" | "@traversable/schema/URI::void" | "@traversable/schema/URI::undefined" | "@traversable/schema/URI::null" | "@traversable/schema/URI::symbol" | "@traversable/schema/URI::string" | "@traversable/schema/URI::integer" | "@traversable/schema/URI::bigint" | "@traversable/schema/URI::number")[]; export declare const isLeaf: (got: unknown) => got is Leaf; export declare const unaryTags: readonly ["@traversable/schema/URI::optional", "@traversable/schema/URI::eq", "@traversable/schema/URI::ref", "@traversable/schema/URI::array", "@traversable/schema/URI::record", "@traversable/schema/URI::tuple", "@traversable/schema/URI::union", "@traversable/schema/URI::intersect", "@traversable/schema/URI::object"]; export declare const tags: ("@traversable/schema/URI::boolean" | "@traversable/schema/URI::unknown" | "@traversable/schema/URI::never" | "@traversable/schema/URI::any" | "@traversable/schema/URI::void" | "@traversable/schema/URI::undefined" | "@traversable/schema/URI::null" | "@traversable/schema/URI::symbol" | "@traversable/schema/URI::string" | "@traversable/schema/URI::integer" | "@traversable/schema/URI::bigint" | "@traversable/schema/URI::number" | "@traversable/schema/URI::eq" | "@traversable/schema/URI::optional" | "@traversable/schema/URI::ref" | "@traversable/schema/URI::array" | "@traversable/schema/URI::record" | "@traversable/schema/URI::union" | "@traversable/schema/URI::intersect" | "@traversable/schema/URI::tuple" | "@traversable/schema/URI::object")[]; export declare const isUnary: (got: unknown) => got is Unary; export type AnyCoreSchema = Schema | Nullary | Boundable; export declare const isCore: (got: unknown) => got is Schema; export declare const defaultIndex: { path: (string | number | symbol)[]; depth: number; }; export type Index = { path: (keyof any)[]; depth: number; }; export declare namespace Functor { export { Index }; } export declare const Functor: T.Functor; export type IndexedFunctor = T.Functor.Ix; export declare const IndexedFunctor: IndexedFunctor; export declare const unfold: (coalgebra: T.Coalgebra) => >>(expr: S) => F; export declare const fold: (g: (src: F, ix: Index, x: Schema>) => T) => { (src: F, ix?: Index | undefined): T; (src: Schema>, ix?: Index | undefined): T; (src: F, ix?: Index | undefined): T; }; export declare const foldWithIndex: (algebra: T.IndexedAlgebra) => >>(term: S, ix: Index) => T; //# sourceMappingURL=schema.d.ts.map