/** * A transcoder is a data-type that `decode`s from unknown type of an expected input shape * to an output type, and `encode`s from an output type to the expected input shape. Can * be represented as printer/parsers, and transformations. * * Lawful transcoders must be idempotent, and all derivable transcoders exported by * schemata (unless otherwise specified) are lawful. * * @since 2.0.0 */ import { type Const } from 'fp-ts/Const'; import { type Invariant2 } from 'fp-ts/Invariant'; import type * as RNEA from 'fp-ts/ReadonlyNonEmptyArray'; import { type Either } from 'schemata-ts/internal/either'; import { type Schema } from 'schemata-ts/Schema'; import * as TE from 'schemata-ts/TranscodeError'; /** * @since 2.0.0 * @category Model */ export interface Transcoder { readonly decode: (u: unknown) => Either, O>; readonly encode: (o: O) => Either, I>; } /** * @since 2.0.0 * @category Constructors */ export declare const success: (a: A) => Either; /** * @since 2.0.0 * @category Constructors */ export declare const failure: (e: TE.TranscodeErrors) => Either; /** * A collection of failure cases * * @since 2.0.0 * @category Constructors */ export declare const transcodeErrors: (...errors: RNEA.ReadonlyNonEmptyArray) => TE.TranscodeErrors; /** * A failure case for a value that does not match the expected type * * @since 2.0.0 * @category Constructors */ export declare const typeMismatch: (...args: ConstructorParameters) => TE.TranscodeError; /** * A failure case for an unexpected value * * @since 2.0.0 * @category Constructors */ export declare const unexpectedValue: (...errors: ConstructorParameters) => TE.TranscodeError; /** * A failure case for a serialization or deserialization error * * @since 2.0.0 * @category Constructors */ export declare const serializationError: (...args: ConstructorParameters) => TE.TranscodeError; /** * A failure case at a specific index * * @since 2.0.0 * @category Constructors */ export declare const errorAtIndex: (index: number, ...errors: RNEA.ReadonlyNonEmptyArray) => TE.TranscodeError; /** * A failure case at a specific key * * @since 2.0.0 * @category Constructors */ export declare const errorAtKey: (key: string, ...errors: RNEA.ReadonlyNonEmptyArray) => TE.TranscodeError; /** * A failure case for a union member * * @since 2.0.0 * @category Constructors */ export declare const errorAtUnionMember: (member: string | number, ...errors: RNEA.ReadonlyNonEmptyArray) => TE.TranscodeError; /** * @since 2.0.0 * @category Destructors */ export declare const drawErrorTree: (...params: Parameters) => string; /** * Interprets a schema as a decoder * * @since 2.0.0 * @category Interpreters */ export declare const deriveTranscoder: (schema: Schema) => Transcoder; /** * @since 2.0.0 * @category URI */ export declare const URI = "schemata-ts/Transcoder"; /** * @since 2.0.0 * @category URI */ export type URI = typeof URI; declare module 'fp-ts/lib/HKT' { interface URItoKind2 { readonly [URI]: Transcoder; } } /** * @since 2.0.0 * @category Instance Methods */ export declare const imap: (f: (a: A) => B, g: (b: B) => A) => (fa: Transcoder) => Transcoder; /** * @since 2.0.0 * @category Instances */ export declare const Invariant: Invariant2; //# sourceMappingURL=Transcoder.d.ts.map