import { type AnyTuple, type FixDeepFunctionInfer, type NeverCoalescing, type SimplifyTopLevel } from "../../../common"; import { type DataParserDefinition } from "../../base"; import { type DataParserError, type 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"; import { type DataParserDefinitionString, type DataParserString } from "../string"; import { type DataParserDefinitionNumber, type DataParserNumber } from "../number"; import { type DataParserDefinitionBigInt, type DataParserBigInt } from "../bigint"; import { type DataParserDefinitionLiteral, type DataParserLiteral } from "../literal"; import { type DataParserDefinitionEmpty, type DataParserEmpty } from "../empty"; import { type DataParserDefinitionNil, type DataParserNil } from "../nil"; import { type DataParserDefinitionBoolean, type DataParserBoolean } from "../boolean"; import { type DataParserDefinitionUnion, type DataParserUnion } from "../union"; export * from "./createTemplateLiteralPattern"; export type TemplateLiteralPrimitiveParts = (string | number | null | undefined | bigint | boolean); export type TemplateLiteralParts = (TemplateLiteralPrimitiveParts | DataParserString & { readonly checkers: readonly []; }>> | DataParserNumber & { readonly checkers: readonly []; }>> | DataParserBigInt & { readonly checkers: readonly []; }>> | DataParserBoolean & { readonly checkers: readonly []; }>> | DataParserLiteral & { readonly checkers: readonly []; }>> | DataParserEmpty & { readonly checkers: readonly []; }>> | DataParserNil & { readonly checkers: readonly []; }>> | DataParserTemplateLiteral & { readonly checkers: readonly []; }>> | DataParserUnion & { readonly options: AnyTuple>; readonly checkers: readonly []; }>>); export type TemplateLiteralShape = readonly [TemplateLiteralParts, ...TemplateLiteralParts[]]; export type TemplateLiteralShapeOutput = GenericTemplate extends readonly [ infer InferredFirst extends TemplateLiteralParts, ...infer InferredRest extends TemplateLiteralParts[] ] ? (`${GenericLastResult}${(InferredFirst extends TemplateLiteralPrimitiveParts ? InferredFirst : Output>) extends infer InferredPrimitiveResult extends TemplateLiteralPrimitiveParts ? InferredPrimitiveResult extends bigint ? `${InferredPrimitiveResult}n` : InferredPrimitiveResult : never}`) extends infer InferredResult extends string ? InferredRest extends readonly [] ? InferredResult : InferredRest extends TemplateLiteralShape ? TemplateLiteralShapeOutput : never : never : never; export type TemplateLiteralShapeInput = GenericTemplate extends readonly [ infer InferredFirst extends TemplateLiteralParts, ...infer InferredRest extends TemplateLiteralParts[] ] ? (`${GenericLastResult}${(InferredFirst extends TemplateLiteralPrimitiveParts ? InferredFirst : Input>) extends infer InferredPrimitiveResult extends TemplateLiteralPrimitiveParts ? InferredPrimitiveResult extends bigint ? `${InferredPrimitiveResult}n` : InferredPrimitiveResult : never}`) extends infer InferredResult extends string ? InferredRest extends readonly [] ? InferredResult : InferredRest extends TemplateLiteralShape ? TemplateLiteralShapeInput : never : never : never; export type DataParserTemplateLiteralCheckers = GetEligibleChecker; export interface DataParserDefinitionTemplateLiteral extends DataParserDefinition> { readonly template: TemplateLiteralShape; readonly pattern: RegExp; } export declare const templateLiteralKind: import("../../../common").KindHandler>; declare const DataParserTemplateLiteral_base: import("../..").DataParserBaseInit>>; export declare class DataParserTemplateLiteral extends DataParserTemplateLiteral_base, string>, GenericDefinition>, ApplyRefinementOfDefinition, string>, GenericDefinition>> { get classConstructor(): typeof DataParserTemplateLiteral & import("../..").CheckedConstructorKind; addChecker: >, ...DataParserChecker>[] ]>(...args: FixDeepFunctionInfer>, ...DataParserChecker>[] ], GenericChecker>) => DataParserTemplateLiteral>; static execParse(self: DataParserTemplateLiteral, data: unknown, error: DataParserError): string | typeof SymbolDataParserError; static dataParserIsAsynchronous(self: DataParserTemplateLiteral): boolean; static prepareDefinition(template: TemplateLiteralShape, definition?: Partial>): DataParserDefinitionTemplateLiteral; /** * Creates a data parser for deterministic template literal strings. * * **Supported call styles:** * - Classic: `DP.templateLiteral(template, definition?)` -> returns a template literal parser * - Curried: not available * * Validates that the input matches the provided template literal shape and pattern. Nested sub-parsers must not include their own checkers; add template-level `checkerRefine` rules when needed. * * ```ts * const parser = DP.templateLiteral(["user-", DP.number()]); * const result = parser.parse("user-42"); * if (E.isRight(result)) { * const value = unwrap(result); * // value: string * } * * const orderParser = DP.templateLiteral(["order-", DP.literal("vip"), "-", DP.number()]); * const orderResult = orderParser.parse("order-vip-12"); * * const withCheckers = DP.templateLiteral(["id-", DP.number()], { * checkers: [DP.checkerRefine((value) => value.endsWith("0"))], * }); * ``` * * @see https://utils.duplojs.dev/en/v1/api/dataParser/templateLiteral * * @namespace DP * */ static create>, "template" | "pattern"> = never>(template: GenericTemplate, definition?: FixDeepFunctionInfer>, "template" | "pattern">, GenericDefinition>): DataParserTemplateLiteral & { template: GenericTemplate; }>>; } /** * Creates a data parser for deterministic template literal strings. * * **Supported call styles:** * - Classic: `DP.templateLiteral(template, definition?)` -> returns a template literal parser * - Curried: not available * * Validates that the input matches the provided template literal shape and pattern. Nested sub-parsers must not include their own checkers; add template-level `checkerRefine` rules when needed. * * ```ts * const parser = DP.templateLiteral(["user-", DP.number()]); * const result = parser.parse("user-42"); * if (E.isRight(result)) { * const value = unwrap(result); * // value: string * } * * const orderParser = DP.templateLiteral(["order-", DP.literal("vip"), "-", DP.number()]); * const orderResult = orderParser.parse("order-vip-12"); * * const withCheckers = DP.templateLiteral(["id-", DP.number()], { * checkers: [DP.checkerRefine((value) => value.endsWith("0"))], * }); * ``` * * @see https://utils.duplojs.dev/en/v1/api/dataParser/templateLiteral * * @namespace DP * */ export declare const templateLiteral: typeof DataParserTemplateLiteral.create;