import { type FixDeepFunctionInfer, type IsEqual, type NeverCoalescing } from "../../../common"; import { type DataParser, type DataParserDefinition } from "../../base"; import { type DataParserError } 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"; import { type DataParserDefinitionNumber, type DataParserNumber } from "../number"; import { type DataParserString } from "../string"; import { type DataParserTemplateLiteral } from "../templateLiteral"; import { type DataParserDefinitionLiteral, type DataParserLiteral } from "../literal"; import { type DataParserDefinitionUnion, type DataParserUnion } from "../union"; export * from "./findRecordRequiredKey"; export type DataParserRecordKey = (DataParserString | DataParserTemplateLiteral | DataParserLiteral & { readonly value: readonly string[]; }> | DataParserNumber & { readonly coerce: true; }> | DataParserUnion & { readonly options: readonly [DataParserRecordKey, ...DataParserRecordKey[]]; }>); export type DataParserRecordCheckers = Record> = GetEligibleChecker; export interface DataParserDefinitionRecord = Record> extends DataParserDefinition> { readonly key: DataParserRecordKey; readonly value: DataParser; readonly baseData: Partial>; } export declare const recordKind: import("../../../common").KindHandler>; export type DataParserRecordShapeOutput = Extract extends infer InferredKey extends string | number ? `${InferredKey}` : never, Output extends infer InferredValue ? InferredValue : never> extends infer InferredResult extends Record ? IsEqual, never> extends true ? InferredResult : Partial : never, any>; export type DataParserRecordShapeInput = Extract extends infer InferredKey extends string | number ? `${InferredKey}` : never, Input extends infer InferredValue ? InferredValue : never> extends infer InferredResult extends Record ? IsEqual, never> extends true ? InferredResult : Partial : never, any>; declare const DataParserRecord_base: import("../..").DataParserBaseInit>>; export declare class DataParserRecord extends DataParserRecord_base, GenericDefinition>, ApplyRefinementOfDefinition, GenericDefinition>> { get classConstructor(): typeof DataParserRecord & import("../..").CheckedConstructorKind; addChecker: >, ...DataParserChecker>[] ]>(...args: FixDeepFunctionInfer>, ...DataParserChecker>[] ], GenericChecker>) => DataParserRecord>; static execParse(self: DataParserRecord, data: unknown, error: DataParserError): unknown; static dataParserIsAsynchronous(self: DataParserRecord): boolean; static prepareDefinition(key: DataParserRecordKey, value: DataParser, definition?: Partial>): DataParserDefinitionRecord; /** * Creates a data parser for records with key and value parsers. * * **Supported call styles:** * - Classic: `DP.record(key, value, definition?)` -> returns a record parser * - Curried: not available * * Validates that the input is an object and parses each key and value with the provided parsers. * * ```ts * const parser = DP.record(DP.string(), DP.number()); * const result = parser.parse({ * aKey: 1, * bKey: 2, * }); * if (E.isRight(result)) { * const value = unwrap(result); * // value: Record * } * * const keyUnion = DP.union([DP.literal("xPos"), DP.literal("yPos")]); * const strictKeys = DP.record(keyUnion, DP.boolean()); * const strictResult = strictKeys.parse({ * xPos: true, * yPos: false, * }); * * const withCheckers = DP.record(DP.string(), DP.string(), { * checkers: [DP.checkerRefine((value) => Object.keys(value).length > 0)], * }); * ``` * * @see https://utils.duplojs.dev/en/v1/api/dataParser/record * * @namespace DP * */ static create>, "key" | "value" | "baseData"> = never>(key: GenericDataParserKey, value: GenericDataParserValue, definition?: FixDeepFunctionInfer>, "key" | "value" | "baseData">, GenericDefinition>): DataParserRecord & { key: GenericDataParserKey; value: GenericDataParserValue; }>>; } /** * Creates a data parser for records with key and value parsers. * * **Supported call styles:** * - Classic: `DP.record(key, value, definition?)` -> returns a record parser * - Curried: not available * * Validates that the input is an object and parses each key and value with the provided parsers. * * ```ts * const parser = DP.record(DP.string(), DP.number()); * const result = parser.parse({ * aKey: 1, * bKey: 2, * }); * if (E.isRight(result)) { * const value = unwrap(result); * // value: Record * } * * const keyUnion = DP.union([DP.literal("xPos"), DP.literal("yPos")]); * const strictKeys = DP.record(keyUnion, DP.boolean()); * const strictResult = strictKeys.parse({ * xPos: true, * yPos: false, * }); * * const withCheckers = DP.record(DP.string(), DP.string(), { * checkers: [DP.checkerRefine((value) => Object.keys(value).length > 0)], * }); * ``` * * @see https://utils.duplojs.dev/en/v1/api/dataParser/record * * @namespace DP * */ export declare const record: typeof DataParserRecord.create;