/** * **This module is experimental** * * Experimental features are published in order to get early feedback from the community, see these tracking * [issues](https://github.com/gcanti/io-ts/issues?q=label%3Av2.2+) for further discussions and enhancements. * * A feature tagged as _Experimental_ is in a high state of flux, you're at risk of it changing without notice. * * @since 2.2.3 */ import { Refinement } from 'fp-ts/es6/function' import { Invariant3 } from 'fp-ts/es6/Invariant' import * as D from './Decoder' import * as E from './Encoder' import * as S from './Schemable' /** * Laws: * * 1. `pipe(codec.decode(u), E.fold(() => u, codec.encode)) = u` for all `u` in `unknown` * 2. `codec.decode(codec.encode(a)) = E.right(a)` for all `a` in `A` * * @category model * @since 2.2.3 */ export interface Codec extends D.Decoder, E.Encoder {} /** * @category constructors * @since 2.2.3 */ export declare function make(decoder: D.Decoder, encoder: E.Encoder): Codec /** * @category constructors * @since 2.2.3 */ export declare function fromDecoder(decoder: D.Decoder): Codec /** * @category constructors * @since 2.2.3 */ export declare function literal], L extends S.Literal = S.Literal>( ...values: A ): Codec /** * @category primitives * @since 2.2.3 */ export declare const string: Codec /** * @category primitives * @since 2.2.3 */ export declare const number: Codec /** * @category primitives * @since 2.2.3 */ export declare const boolean: Codec /** * @category primitives * @since 2.2.3 */ export declare const UnknownArray: Codec, Array> /** * @category primitives * @since 2.2.3 */ export declare const UnknownRecord: Codec, Record> /** * @category combinators * @since 2.2.3 */ export declare const mapLeftWithInput: ( f: (i: I, e: D.DecodeError) => D.DecodeError ) => (codec: Codec) => Codec /** * @category combinators * @since 2.2.3 */ export declare const refine: ( refinement: Refinement, id: string ) => (from: Codec) => Codec /** * @category combinators * @since 2.2.3 */ export declare function nullable(or: Codec): Codec /** * @category combinators * @since 2.2.15 */ export declare function fromStruct

>>( properties: P ): Codec< { [K in keyof P]: InputOf }, { [K in keyof P]: OutputOf }, { [K in keyof P]: TypeOf } > /** * Use `fromStruct` instead. * * @category combinators * @since 2.2.8 * @deprecated */ export declare const fromType: typeof fromStruct /** * @category combinators * @since 2.2.15 */ export declare function struct

>>( properties: P ): Codec< unknown, { [K in keyof P]: OutputOf }, { [K in keyof P]: TypeOf } > /** * Use `struct` instead. * * @category combinators * @since 2.2.3 * @deprecated */ export declare const type: typeof struct /** * @category combinators * @since 2.2.8 */ export declare function fromPartial

>>( properties: P ): Codec< Partial< { [K in keyof P]: InputOf } >, Partial< { [K in keyof P]: OutputOf } >, Partial< { [K in keyof P]: TypeOf } > > /** * @category combinators * @since 2.2.3 */ export declare function partial

>>( properties: P ): Codec< unknown, Partial< { [K in keyof P]: OutputOf } >, Partial< { [K in keyof P]: TypeOf } > > /** * @category combinators * @since 2.2.3 */ export declare function fromArray(item: Codec): Codec, Array, Array> /** * @category combinators * @since 2.2.3 */ export declare function array(item: Codec): Codec, Array> /** * @category combinators * @since 2.2.3 */ export declare function fromRecord( codomain: Codec ): Codec, Record, Record> /** * @category combinators * @since 2.2.3 */ export declare function record( codomain: Codec ): Codec, Record> /** * @category combinators * @since 2.2.8 */ export declare const fromTuple: []>( ...components: C ) => Codec< { [K in keyof C]: import('./Kleisli').InputOf<'Either', C[K]> }, { [K_1 in keyof C]: E.OutputOf }, { [K_2 in keyof C]: E.TypeOf } > /** * @category combinators * @since 2.2.3 */ export declare function tuple>>( ...components: C ): Codec< unknown, { [K in keyof C]: OutputOf }, { [K in keyof C]: TypeOf } > /** * @category combinators * @since 2.2.3 */ export declare const intersect: ( right: Codec ) => (left: Codec) => Codec /** * @category combinators * @since 2.2.8 */ export declare const fromSum: ( tag: T ) => >>( members: MS ) => Codec, E.OutputOf, E.TypeOf> /** * @category combinators * @since 2.2.3 */ export declare function sum( tag: T ): >>( members: M ) => Codec, TypeOf> /** * @category combinators * @since 2.2.3 */ export declare function lazy(id: string, f: () => Codec): Codec /** * @category combinators * @since 2.2.16 */ export declare const readonly: (codec: Codec) => Codec> /** * @category combinators * @since 2.2.8 */ export declare const compose: ( to: Codec ) => (from: Codec) => Codec /** * @category Invariant * @since 2.2.3 */ export declare const imap: (f: (a: A) => B, g: (b: B) => A) => (fa: Codec) => Codec /** * @category instances * @since 2.2.3 */ export declare const URI = 'io-ts/Codec' /** * @category instances * @since 2.2.3 */ export declare type URI = typeof URI declare module 'fp-ts/es6/HKT' { interface URItoKind3 { readonly [URI]: Codec } } /** * @category instances * @since 2.2.8 */ export declare const Invariant: Invariant3 /** * @since 2.2.8 */ export declare type InputOf = D.InputOf /** * @since 2.2.3 */ export declare type OutputOf = E.OutputOf /** * @since 2.2.3 */ export declare type TypeOf = E.TypeOf