import { type Adaptor, type FixDeepFunctionInfer, type IsEqual, type MaybePromise, type NeverCoalescing, type Or, type UnionContain } from "../../common"; import { type DataParser, type DataParserDefinition } from "../base"; import { type DataParserError, SymbolDataParserError } from "../../dataParser/error"; import { type DataParserChecker } from "../baseChecker"; import { type ApplyRefinementOfDefinition, type AddCheckersToDefinition, type GetEligibleChecker, type Input, type MergeDefinition, type Output, type PrepareDataParserDefinition } from "../types"; export type TupleShape = readonly [DataParser, ...DataParser[]]; export type DataParserTupleShapeOutput = IsEqual extends true ? unknown[] : GenericShape extends readonly [ infer InferredFirst extends DataParser, ...infer InferredRest extends DataParser[] ] ? [ Output, ...(Exclude extends infer InferredShapeRest extends readonly any[] ? IsEqual extends true ? [] : Output[] : []), ...(InferredRest extends TupleShape ? DataParserTupleShapeOutput : Or<[ UnionContain, IsEqual ]> extends true ? [] : Output>[]) ] : never; export type DataParserTupleShapeInput = IsEqual extends true ? unknown[] : GenericShape extends readonly [ infer InferredFirst extends DataParser, ...infer InferredRest extends DataParser[] ] ? [ Input, ...(Exclude extends infer InferredShapeRest extends readonly any[] ? IsEqual extends true ? [] : Input[] : []), ...(InferredRest extends TupleShape ? DataParserTupleShapeInput : Or<[ UnionContain, IsEqual ]> extends true ? [] : Input>[]) ] : never; export type DataParserTupleCheckers = GetEligibleChecker; export interface DataParserDefinitionTuple extends DataParserDefinition> { readonly shape: TupleShape; readonly rest: DataParser | undefined; } export declare const tupleKind: import("../../common").KindHandler>; declare const DataParserTuple_base: import("..").DataParserBaseInit>>; export declare class DataParserTuple extends DataParserTuple_base, GenericDefinition>, ApplyRefinementOfDefinition, GenericDefinition>> { get classConstructor(): typeof DataParserTuple & import("..").CheckedConstructorKind; addChecker: >, ...DataParserChecker>[] ]>(...args: FixDeepFunctionInfer>, ...DataParserChecker>[] ], GenericChecker>) => DataParserTuple>; static execParse(self: DataParserTuple, data: unknown, error: DataParserError): MaybePromise; static dataParserIsAsynchronous(self: DataParserTuple): boolean; static prepareDefinition(shape: TupleShape, definition?: Partial>): DataParserDefinitionTuple; /** * Creates a data parser for tuples with a fixed shape. * * **Supported call styles:** * - Classic: `DP.tuple(shape, definition?)` -> returns a tuple parser * - Curried: not available * * Validates array inputs against the provided tuple shape, with an optional rest parser. * * ```ts * const parser = DP.tuple([DP.string(), DP.number()]); * const result = parser.parse(["id", 42]); * if (E.isRight(result)) { * const value = unwrap(result); * // value: [string, number] * } * * const withRest = DP.tuple([DP.string()], { rest: DP.number() }); * const restResult = withRest.parse(["a", 1, 2, 3]); * ``` * * @see https://utils.duplojs.dev/en/v1/api/dataParser/tuple * * @namespace DP * */ static create>, "shape"> = never>(shape: GenericShape, definition?: FixDeepFunctionInfer>, "shape">, GenericDefinition>): DataParserTuple & { readonly shape: GenericShape; readonly rest: Or<[ IsEqual, IsEqual ]> extends true ? undefined : GenericDefinition["rest"]; }>>; } /** * Creates a data parser for tuples with a fixed shape. * * **Supported call styles:** * - Classic: `DP.tuple(shape, definition?)` -> returns a tuple parser * - Curried: not available * * Validates array inputs against the provided tuple shape, with an optional rest parser. * * ```ts * const parser = DP.tuple([DP.string(), DP.number()]); * const result = parser.parse(["id", 42]); * if (E.isRight(result)) { * const value = unwrap(result); * // value: [string, number] * } * * const withRest = DP.tuple([DP.string()], { rest: DP.number() }); * const restResult = withRest.parse(["a", 1, 2, 3]); * ``` * * @see https://utils.duplojs.dev/en/v1/api/dataParser/tuple * * @namespace DP * */ export declare const tuple: typeof DataParserTuple.create; export {};