import { Equatable } from "@fncts/base/data/Equatable"; import { Maybe } from "@fncts/base/data/Maybe/definition"; import { Vector } from "@fncts/base/collection/immutable/Vector"; import { ParseResult } from "@fncts/schema/ParseResult"; import { ParseError } from "@fncts/schema/ParseError"; import type { Validation as ValidationType } from "@fncts/base/data/Branded"; import type { EqualsContext } from "@fncts/base/data/Equatable"; import { ASTAnnotation } from "./ASTAnnotation.js"; import { ASTAnnotationMap } from "./ASTAnnotationMap.js"; export declare const ASTTypeId: unique symbol; export type ASTTypeId = typeof ASTTypeId; export declare abstract class Annotated { readonly annotations: ASTAnnotationMap; } /** * @tsplus type fncts.schema.AST * @tsplus companion fncts.schema.ASTOps */ export declare abstract class AST extends Annotated implements Equatable { readonly [ASTTypeId]: ASTTypeId; abstract clone(newProperties: Partial): AST; abstract [Symbol.equals](that: unknown, context: EqualsContext): boolean; toString(verbose?: boolean): string; } export declare namespace AST { interface Compiler { (ast: AST): A; } type Match = { [K in Concrete["_tag"]]: (ast: Extract, compile: Compiler) => A; }; } export declare const enum ASTTag { Declaration = 0, Literal = 1, UniqueSymbol = 2, UndefinedKeyword = 3, VoidKeyword = 4, NeverKeyword = 5, UnknownKeyword = 6, AnyKeyword = 7, StringKeyword = 8, NumberKeyword = 9, BooleanKeyword = 10, BigIntKeyword = 11, SymbolKeyword = 12, ObjectKeyword = 13, Enum = 14, TemplateLiteral = 15, Tuple = 16, TypeLiteral = 17, Union = 18, Lazy = 19, Refinement = 20, Transform = 21, Validation = 22 } export type Concrete = Declaration | Literal | UniqueSymbol | UndefinedKeyword | VoidKeyword | NeverKeyword | UnknownKeyword | AnyKeyword | StringKeyword | NumberKeyword | BooleanKeyword | BigIntKeyword | SymbolKeyword | ObjectKeyword | Enum | TemplateLiteral | Tuple | TypeLiteral | Union | Lazy | Refinement | Transform | Validation; /** * @tsplus static fncts.schema.ASTOps concrete * @tsplus macro remove * @tsplus location "@fncts/schema/AST" */ export declare function concrete(_: AST): asserts _ is Concrete; export declare function isAST(u: unknown): u is AST; export declare function getAnnotations(key: ASTAnnotation): (self: Annotated) => Maybe; /** * @tsplus type fncts.schema.AST.Declaration */ export declare class Declaration extends AST implements Equatable { readonly typeParameters: Vector; readonly decode: (...typeParameters: ReadonlyArray) => (input: any, options?: ParseOptions) => ParseResult; readonly encode: (...typeParameters: ReadonlyArray) => (input: any, options?: ParseOptions) => ParseResult; readonly annotations: ASTAnnotationMap; readonly _tag = ASTTag.Declaration; constructor(typeParameters: Vector, decode: (...typeParameters: ReadonlyArray) => (input: any, options?: ParseOptions) => ParseResult, encode: (...typeParameters: ReadonlyArray) => (input: any, options?: ParseOptions) => ParseResult, annotations?: ASTAnnotationMap); clone(newProperties: Partial): AST; [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus static fncts.schema.ASTOps createDeclaration * @tsplus location "@fncts/schema/AST" */ export declare function createDeclaration(typeParameters: Vector, decode: (...typeParameters: ReadonlyArray) => (input: any, options?: ParseOptions) => ParseResult, encode: (...typeParameters: ReadonlyArray) => (input: any, options?: ParseOptions) => ParseResult, annotations?: ASTAnnotationMap): Declaration; /** * @tsplus fluent fncts.schema.AST isDeclaration * @tsplus location "@fncts/schema/AST" */ export declare function isDeclaration(self: AST): self is Declaration; export type LiteralValue = string | number | boolean | null | bigint; export declare class Literal extends AST implements Equatable { readonly literal: LiteralValue; readonly annotations: ASTAnnotationMap; readonly _tag = ASTTag.Literal; constructor(literal: LiteralValue, annotations?: ASTAnnotationMap); clone(newProperties: Partial): AST; [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus static fncts.schema.ASTOps createLiteral * @tsplus location "@fncts/schema/AST" */ export declare function createLiteral(literal: LiteralValue, annotations?: ASTAnnotationMap): Literal; /** * @tsplus fluent fncts.schema.AST isLiteral * @tsplus location "@fncts/schema/AST" */ export declare function isLiteral(self: AST): self is Literal; export declare class UniqueSymbol extends AST implements Equatable { readonly symbol: symbol; readonly annotations: ASTAnnotationMap; readonly _tag = ASTTag.UniqueSymbol; constructor(symbol: symbol, annotations?: ASTAnnotationMap); clone(newProperties: Partial): AST; [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus static fncts.schema.ASTOps createUniqueSymbol * @tsplus location "@fncts/schema/AST" */ export declare function createUniqueSymbol(symbol: symbol, annotations?: ASTAnnotationMap): UniqueSymbol; /** * @tsplus fluent fncts.schema.AST isUniqueSymbol * @tsplus location "@fncts/schema/AST" */ export declare function isUniqueSymbol(self: AST): self is UniqueSymbol; export declare class UndefinedKeyword extends AST implements Equatable { readonly annotations: ASTAnnotationMap; readonly _tag = ASTTag.UndefinedKeyword; constructor(annotations?: ASTAnnotationMap); clone(newProperties: Partial): AST; [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus static fncts.schema.ASTOps undefinedKeyword * @tsplus location "@fncts/schema/AST" */ export declare const undefinedKeyword: UndefinedKeyword; export declare class VoidKeyword extends AST implements Equatable { readonly annotations: ASTAnnotationMap; readonly _tag = ASTTag.VoidKeyword; constructor(annotations?: ASTAnnotationMap); clone(newProperties: Partial): AST; [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus static fncts.schema.ASTOps voidKeyword * @tsplus location "@fncts/schema/AST" */ export declare const voidKeyword: VoidKeyword; export declare class NeverKeyword extends AST implements Equatable { readonly annotations: ASTAnnotationMap; readonly _tag = ASTTag.NeverKeyword; constructor(annotations?: ASTAnnotationMap); clone(newProperties: Partial): AST; [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus static fncts.schema.ASTOps neverKeyword * @tsplus location "@fncts/schema/AST" */ export declare const neverKeyword: NeverKeyword; export declare class UnknownKeyword extends AST implements Equatable { readonly annotations: ASTAnnotationMap; readonly _tag = ASTTag.UnknownKeyword; constructor(annotations?: ASTAnnotationMap); clone(newProperties: Partial): AST; [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus static fncts.schema.ASTOps unknownKeyword * @tsplus location "@fncts/schema/AST" */ export declare const unknownKeyword: UnknownKeyword; export declare class AnyKeyword extends AST implements Equatable { readonly annotations: ASTAnnotationMap; readonly _tag = ASTTag.AnyKeyword; constructor(annotations?: ASTAnnotationMap); clone(newProperties: Partial): AST; [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus static fncts.schema.ASTOps anyKeyword * @tsplus location "@fncts/schema/AST" */ export declare const anyKeyword: AnyKeyword; export declare class StringKeyword extends AST implements Equatable { readonly annotations: ASTAnnotationMap; readonly _tag = ASTTag.StringKeyword; constructor(annotations?: ASTAnnotationMap); clone(newProperties: Partial): AST; [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus static fncts.schema.ASTOps stringKeyword * @tsplus location "@fncts/schema/AST" */ export declare const stringKeyword: StringKeyword; /** * @tsplus fluent fncts.schema.AST isStringKeyword * @tsplus location "@fncts/schema/AST" */ export declare function isStringKeyword(self: AST): self is StringKeyword; export declare class NumberKeyword extends AST implements Equatable { readonly annotations: ASTAnnotationMap; readonly _tag = ASTTag.NumberKeyword; constructor(annotations?: ASTAnnotationMap); clone(newProperties: Partial): AST; [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus static fncts.schema.ASTOps numberKeyword * @tsplus location "@fncts/schema/AST" */ export declare const numberKeyword: NumberKeyword; /** * @tsplus fluent fncts.schema.AST isNumberKeyword * @tsplus location "@fncts/schema/AST" */ export declare function isNumberKeyword(self: AST): self is NumberKeyword; export declare class BooleanKeyword extends AST implements Equatable { readonly annotations: ASTAnnotationMap; readonly _tag = ASTTag.BooleanKeyword; constructor(annotations?: ASTAnnotationMap); clone(newProperties: Partial): AST; [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus static fncts.schema.ASTOps booleanKeyword * @tsplus location "@fncts/schema/AST" */ export declare const booleanKeyword: BooleanKeyword; /** * @tsplus fluent fncts.schema.AST isBooleanKeyword * @tsplus location "@fncts/schema/AST" */ export declare function isBooleanKeyword(self: AST): self is BooleanKeyword; export declare class BigIntKeyword extends AST implements Equatable { readonly annotations: ASTAnnotationMap; readonly _tag = ASTTag.BigIntKeyword; constructor(annotations?: ASTAnnotationMap); clone(newProperties: Partial): AST; [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus static fncts.schema.ASTOps bigIntKeyword * @tsplus location "@fncts/schema/AST" */ export declare const bigIntKeyword: BigIntKeyword; /** * @tsplus fluent fncts.schema.AST isBigIntKeyword * @tsplus location "@fncts/schema/AST" */ export declare function isBigIntKeyword(self: AST): self is BigIntKeyword; export declare class SymbolKeyword extends AST implements Equatable { readonly annotations: ASTAnnotationMap; readonly _tag = ASTTag.SymbolKeyword; constructor(annotations?: ASTAnnotationMap); clone(newProperties: Partial): AST; [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus static fncts.schema.ASTOps symbolKeyword * @tsplus location "@fncts/schema/AST" */ export declare const symbolKeyword: SymbolKeyword; /** * @tsplus fluent fncts.schema.AST isSymbolKeyword * @tsplus location "@fncts/schema/AST" */ export declare function isSymbolKeyword(self: AST): self is SymbolKeyword; export declare class ObjectKeyword extends AST implements Equatable { readonly annotations: ASTAnnotationMap; readonly _tag = ASTTag.ObjectKeyword; constructor(annotations?: ASTAnnotationMap); clone(newProperties: Partial): AST; [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus static fncts.schema.ASTOps objectKeyword * @tsplus location "@fncts/schema/AST" */ export declare const objectKeyword: ObjectKeyword; export declare class Enum extends AST implements Equatable { readonly enums: Vector; readonly annotations: ASTAnnotationMap; readonly _tag = ASTTag.Enum; constructor(enums: Vector, annotations?: ASTAnnotationMap); clone(newProperties: Partial): AST; [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus static fncts.schema.ASTOps createEnum * @tsplus location "@fncts/schema/AST" */ export declare function createEnum(enums: Vector, annotations?: ASTAnnotationMap): Enum; export declare class TemplateLiteralSpan implements Equatable { readonly type: StringKeyword | NumberKeyword; readonly literal: string; constructor(type: StringKeyword | NumberKeyword, literal: string); [Symbol.equals](that: unknown, context: EqualsContext): boolean; toString(): "${number}" | "${string}"; } export declare class TemplateLiteral extends AST implements Equatable { readonly head: string; readonly spans: Vector; readonly annotations: ASTAnnotationMap; readonly _tag = ASTTag.TemplateLiteral; constructor(head: string, spans: Vector, annotations?: ASTAnnotationMap); clone(newProperties: Partial): AST; [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus static fncts.schema.ASTOps createTemplateLiteral * @tsplus location "@fncts/schema/AST" */ export declare function createTemplateLiteral(head: string, spans: Vector, annotations?: ASTAnnotationMap): TemplateLiteral | Literal; export declare class Element implements Equatable { readonly type: AST; readonly isOptional: boolean; constructor(type: AST, isOptional: boolean); [Symbol.equals](that: unknown, context: EqualsContext): boolean; toString(): string; } /** * @tsplus static fncts.schema.ASTOps createElement * @tsplus location "@fncts/schema/AST" */ export declare function createElement(type: AST, isOptional: boolean): Element; export declare class Tuple extends AST implements Equatable { readonly elements: Vector; readonly rest: Maybe>; readonly isReadonly: boolean; readonly annotations: ASTAnnotationMap; readonly _tag = ASTTag.Tuple; constructor(elements: Vector, rest: Maybe>, isReadonly: boolean, annotations?: ASTAnnotationMap); clone(newProperties: Partial): AST; [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus static fncts.schema.ASTOps createTuple * @tsplus location "@fncts/schema/AST" */ export declare function createTuple(elements: Vector, rest: Maybe>, isReadonly: boolean, annotations?: ASTAnnotationMap): Tuple; /** * @tsplus static fncts.schema.ASTOps unknownArray * @tsplus location "@fncts/schema/AST" */ export declare const unknownArray: Tuple; export declare class PropertySignature implements Equatable { readonly name: PropertyKey; readonly type: AST; readonly isOptional: boolean; readonly isReadonly: boolean; readonly annotations: ASTAnnotationMap; constructor(name: PropertyKey, type: AST, isOptional: boolean, isReadonly: boolean, annotations?: ASTAnnotationMap); clone(newProperties: Partial): PropertySignature; [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus static fncts.schema.ASTOps createPropertySignature * @tsplus location "@fncts/schema/AST" */ export declare function createPropertySignature(name: PropertyKey, type: AST, isOptional: boolean, isReadonly: boolean, annotations?: ASTAnnotationMap): PropertySignature; export declare class IndexSignature implements Equatable { readonly parameter: StringKeyword | SymbolKeyword | TemplateLiteral | NumberKeyword | Refinement; readonly type: AST; readonly isReadonly: boolean; constructor(parameter: StringKeyword | SymbolKeyword | TemplateLiteral | NumberKeyword | Refinement, type: AST, isReadonly: boolean); [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus static fncts.schema.ASTOps createIndexSignature * @tsplus location "@fncts/schema/AST" */ export declare function createIndexSignature(parameter: StringKeyword | SymbolKeyword | TemplateLiteral | NumberKeyword | Refinement, type: AST, isReadonly: boolean): IndexSignature; export declare class TypeLiteral extends AST implements Equatable { readonly annotations: ASTAnnotationMap; readonly _tag = ASTTag.TypeLiteral; readonly propertySignatures: Vector; readonly indexSignatures: Vector; constructor(propertySignatures: Vector, indexSignatures: Vector, annotations?: ASTAnnotationMap); clone(newProperties: Partial): AST; [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus static fncts.schema.ASTOps isTypeLiteral * @tsplus fluent fncts.schema.AST isTypeLiteral * @tsplus location "@fncts/schema/AST" */ export declare function isTypeLiteral(self: AST): self is TypeLiteral; /** * @tsplus static fncts.schema.ASTOps createTypeLiteral * @tsplus location "@fncts/schema/AST" */ export declare function createTypeLiteral(propertySignatures: Vector, indexSignatures: Vector, annotations?: ASTAnnotationMap): TypeLiteral; /** * @tsplus static fncts.schema.ASTOps unknownRecord * @tsplus location "@fncts/schema/AST" */ export declare const unknownRecord: TypeLiteral; export declare class Union extends AST implements Equatable { readonly types: Vector; readonly annotations: ASTAnnotationMap; readonly _tag = ASTTag.Union; constructor(types: Vector, annotations?: ASTAnnotationMap); clone(newProperties: Partial): AST; [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus fluent fncts.schema.AST isUnion * @tsplus location "@fncts/schema/AST" */ export declare function isUnion(self: AST): self is Union; /** * @tsplus static fncts.schema.ASTOps createUnion * @tsplus location "@fncts/schema/AST" */ export declare function createUnion(candidates: Vector, annotations?: ASTAnnotationMap): AST; export declare class Lazy extends AST implements Equatable { readonly getAST: () => AST; readonly annotations: ASTAnnotationMap; readonly _tag = ASTTag.Lazy; constructor(getAST: () => AST, annotations?: ASTAnnotationMap); clone(newProperties: Partial): AST; [Symbol.equals](that: unknown): boolean; } /** * @tsplus static fncts.schema.ASTOps createLazy * @tsplus location "@fncts/schema/AST" */ export declare function createLazy(getAST: () => AST, annotations?: ASTAnnotationMap): Lazy; /** * @tsplus fluent fncts.schema.AST isLazy * @tsplus location "@fncts/schema/AST" */ export declare function isLazy(self: AST): self is Lazy; export declare class Refinement extends AST implements Equatable { readonly from: AST; readonly predicate: (input: any) => boolean; readonly annotations: ASTAnnotationMap; readonly _tag = ASTTag.Refinement; constructor(from: AST, predicate: (input: any) => boolean, annotations?: ASTAnnotationMap); decode(input: any, options?: ParseOptions): ParseResult; clone(newProperties: Partial): AST; [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus static fncts.schema.ASTOps createRefinement * @tsplus location "@fncts/schema/AST" */ export declare function createRefinement(from: AST, predicate: (input: any) => boolean, annotations?: ASTAnnotationMap): Refinement; export declare function isRefinement(self: AST): self is Refinement; export interface ParseOptions { readonly isUnexpectedAllowed?: boolean; readonly allErrors?: boolean; } export declare class Transform extends AST implements Equatable { readonly from: AST; readonly to: AST; readonly decode: (input: any, options?: ParseOptions) => ParseResult; readonly encode: (input: any, options?: ParseOptions) => ParseResult; readonly annotations: ASTAnnotationMap; readonly _tag = ASTTag.Transform; constructor(from: AST, to: AST, decode: (input: any, options?: ParseOptions) => ParseResult, encode: (input: any, options?: ParseOptions) => ParseResult, annotations?: ASTAnnotationMap); clone(newProperties: Partial): AST; [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus static fncts.schema.ASTOps createTransform * @tsplus location "@fncts/schema/AST" */ export declare function createTransform(from: AST, to: AST, decode: (input: any, options?: ParseOptions) => ParseResult, encode: (input: any, options?: ParseOptions) => ParseResult, annotations?: ASTAnnotationMap): Transform; export declare class Validation extends AST implements Equatable { readonly from: AST; readonly validation: Vector>; readonly annotations: ASTAnnotationMap; readonly _tag = ASTTag.Validation; constructor(from: AST, validation: Vector>, annotations?: ASTAnnotationMap); clone(newProperties: Partial): AST; [Symbol.equals](that: unknown, context: EqualsContext): boolean; } /** * @tsplus static fncts.schema.ASTOps createValidation * @tsplus location "@fncts/schema/AST" */ export declare function createValidation(from: AST, validation: Vector>, annotations?: ASTAnnotationMap): Validation; /** * @tsplus tailRec */ export declare function getCardinality(ast: AST): number; export type Weight = readonly [number, number, number]; export declare function getWeight(ast: AST): Weight; /** * @tsplus pipeable fncts.schema.AST combineAnnotations * @tsplus location "@fncts/schema/AST" */ export declare function combineAnnotations(annotations: ASTAnnotationMap): (self: AST) => AST; /** * @tsplus pipeable fncts.schema.AST setAnnotation * @tsplus location "@fncts/schema/AST" */ export declare function setAnnotation(annotation: ASTAnnotation, value: A): (self: AST) => AST; /** * @tsplus pipeable fncts.schema.AST appendRestElement * @tsplus location "@fncts/schema/AST" */ export declare function appendRestElement(restElement: AST): (self: Tuple) => Tuple; /** * @tsplus pipeable fncts.schema.AST appendElement * @tsplus location "@fncts/schema/AST" */ export declare function appendElement(element: Element): (self: Tuple) => Tuple; export declare function getParameter(x: IndexSignature["parameter"]): StringKeyword | NumberKeyword | SymbolKeyword | TemplateLiteral; /** * @tsplus getter fncts.schema.AST getPropertySignatures * @tsplus location "@fncts/schema/AST" */ export declare function getPropertySignatures(self: AST): Vector; /** * @tsplus getter fncts.schema.AST keysof * @tsplus location "@fncts/schema/AST" */ export declare function keysOf(ast: AST): Vector; /** * @tsplus getter fncts.schema.AST keyof * @tsplus location "@fncts/schema/AST" */ export declare function keyof(self: AST): AST; /** * @tsplus static fncts.schema.ASTOps createRecord * @tsplus location "@fncts/schema/AST" */ export declare function createRecord(key: AST, value: AST, isReadonly: boolean): TypeLiteral; /** * @tsplus pipeable fncts.schema.AST pick * @tsplus location "@fncts/schema/AST" */ export declare function pick(keys: Vector): (self: AST) => TypeLiteral; /** * @tsplus pipeable fncts.schema.AST omit * @tsplus location "@fncts/schema/AST" */ export declare function omit(keys: Vector): (self: AST) => TypeLiteral; /** * @tsplus getter fncts.schema.AST partial * @tsplus location "@fncts/schema/AST" */ export declare function partial(self: AST): AST; /** * @tsplus static fncts.schema.AST createKey * @tsplus location "@fncts/schema/AST" */ export declare function createKey(key: PropertyKey): AST; /** * @tsplus getter fncts.schema.AST getFrom * @tsplus location "@fncts/schema/AST" */ export declare function getFrom(ast: AST): AST; /** * @tsplus getter fncts.schema.AST getTo * @tsplus location "@fncts/schema/AST" */ export declare function getTo(ast: AST): AST; /** * @tsplus static fncts.schema.AST getCompiler * @tsplus location "@fncts/schema/AST" */ export declare function getCompiler(match: AST.Match): AST.Compiler; export declare function getLiterals(ast: AST, isDecoding: boolean): ReadonlyArray<[PropertyKey, Literal]>; export declare function getSearchTree(members: Vector, isDecoding: boolean): { keys: { readonly [key: PropertyKey]: { buckets: { [literal: string]: ReadonlyArray; }; literals: ReadonlyArray; ast: AST; }; }; otherwise: ReadonlyArray; }; /** * @tsplus pipeable fncts.schema.AST getFormattedExpected * @tsplus location "@fncts/schema/AST" */ export declare function getFormattedExpected(verbose?: boolean): (self: AST) => Maybe;