import { ArrayType, BlobType, BooleanType, DateTimeType, DictType, EastType, FloatType, IntegerType, NullType, Nullable, SetType, StringType, StructType, VariantType, ValueTypeOf } from './types'; import { JsonDecoder, JsonEncoder } from './json'; import type { Data } from '../utils/variant'; /** * Build a type including descriptions. * * @category Expressions */ export declare class TypeBuilder { description: string | undefined; constructor(); static from(type: T): AbstractTypeBuilder; /** Add a human-readable description to the type */ describe(description: string): this; null(): NullTypeBuilder; nullable AbstractTypeBuilder>(value: V): NullableTypeBuilder["type"]>; boolean(): BooleanTypeBuilder; integer(): IntegerTypeBuilder; float(): FloatTypeBuilder; datetime(): DateTimeTypeBuilder; string(): StringTypeBuilder; blob(): BlobTypeBuilder; array AbstractTypeBuilder>(values: V): ArrayTypeBuilder["type"]>; set AbstractTypeBuilder>(keys: K): SetTypeBuilder["type"]>; dict AbstractTypeBuilder, V extends (values: TypeBuilder) => AbstractTypeBuilder>(keys: K, values: V): DictTypeBuilder["type"], ReturnType["type"]>; struct) => FieldBuilder>(fields: Fields): StructTypeBuilder<{ [K in keyof ReturnType["fields"]]: ReturnType["fields"][K]["type"]; }>; variant) => CaseBuilder>(cases: Cases): VariantTypeBuilder<{ [K in keyof ReturnType["cases"]]: ReturnType["cases"][K]["type"]; }>; } /** * Build a type including descriptions. * * @category Expressions */ export declare abstract class AbstractTypeBuilder { description: string | undefined; constructor(description: string | undefined); /** Add a human-readable description to the type */ describe(description: string): void; abstract equal(): (x: any, y: any) => boolean; abstract less(): (x: any, y: any) => boolean; abstract compare(): (x: any, y: any) => -1 | 0 | 1; abstract jsonEncoder(): JsonEncoder; abstract jsonDecoder(): JsonDecoder; abstract type: T; abstract toJsonSchema(): any; } /** @internal */ declare class NullTypeBuilder extends AbstractTypeBuilder { constructor(description: string | undefined); get type(): NullType; /** Return a binary function that determines if two values of this type are equal */ equal(): (x: null, y: null) => boolean; /** Return a binary function that determines if one value of this type is less than another value of this type, according to Elara's canonical total ordering */ less(): (x: null, y: null) => boolean; /** Return a binary function that compares two values of this type, returing `-1` if the first is lesser, `0` if they are equal, and `+1` if the first is greater. Suitable for use in JavaScript methods like `Array#sort`. */ compare(): (x: null, y: null) => 0 | 1 | -1; /** Return an `JsonEncoder` that can transform an East value of this type into Elara's canonical JSON encoding */ jsonEncoder(): JsonEncoder; /** Return an `JsonDecoder` that can transform Elara's canonical JSON encoding into an East value of this type */ jsonDecoder(): JsonDecoder; toJsonSchema(): { type: string; description?: string; }; } /** @internal */ declare class NullableTypeBuilder extends AbstractTypeBuilder { private value; constructor(description: string | undefined, value: AbstractTypeBuilder); get type(): Nullable; /** Return a binary function that determines if two values of this type are equal */ equal(): (x: ValueTypeOf>, y: ValueTypeOf>) => boolean; /** Return a binary function that determines if one value of this type is less than another value of this type, according to Elara's canonical total ordering */ less(): (x: ValueTypeOf>, y: ValueTypeOf>) => boolean; /** Return a binary function that compares two values of this type, returing `-1` if the first is lesser, `0` if they are equal, and `+1` if the first is greater. Suitable for use in JavaScript methods like `Array#sort`. */ compare(): (x: ValueTypeOf>, y: ValueTypeOf>) => 0 | 1 | -1; /** Return an `JsonEncoder` that can transform an East value of this type into Elara's canonical JSON encoding */ jsonEncoder(): JsonEncoder>; /** Return an `JsonDecoder` that can transform Elara's canonical JSON encoding into an East value of this type */ jsonDecoder(): JsonDecoder>; toJsonSchema(): { oneOf: any[]; description?: string; }; } /** @internal */ declare class BooleanTypeBuilder extends AbstractTypeBuilder { constructor(description: string | undefined); get type(): BooleanType; /** Return a binary function that determines if two values of this type are equal */ equal(): (x: boolean, y: boolean) => boolean; /** Return a binary function that determines if one value of this type is less than another value of this type, according to Elara's canonical total ordering */ less(): (x: boolean, y: boolean) => boolean; /** Return a binary function that compares two values of this type, returing `-1` if the first is lesser, `0` if they are equal, and `+1` if the first is greater. Suitable for use in JavaScript methods like `Array#sort`. */ compare(): (x: boolean, y: boolean) => 0 | 1 | -1; /** Return an `JsonEncoder` that can transform an East value of this type into Elara's canonical JSON encoding */ jsonEncoder(): JsonEncoder; /** Return an `JsonDecoder` that can transform Elara's canonical JSON encoding into an East value of this type */ jsonDecoder(): JsonDecoder; toJsonSchema(): { type: string; description?: string; }; } /** @internal */ declare class IntegerTypeBuilder extends AbstractTypeBuilder { constructor(description: string | undefined); get type(): IntegerType; /** Return a binary function that determines if two values of this type are equal */ equal(): (x: bigint, y: bigint) => boolean; /** Return a binary function that determines if one value of this type is less than another value of this type, according to Elara's canonical total ordering */ less(): (x: bigint, y: bigint) => boolean; /** Return a binary function that compares two values of this type, returing `-1` if the first is lesser, `0` if they are equal, and `+1` if the first is greater. Suitable for use in JavaScript methods like `Array#sort`. */ compare(): (x: bigint, y: bigint) => 0 | 1 | -1; /** Return an `JsonEncoder` that can transform an East value of this type into Elara's canonical JSON encoding */ jsonEncoder(): JsonEncoder; /** Return an `JsonDecoder` that can transform Elara's canonical JSON encoding into an East value of this type */ jsonDecoder(): JsonDecoder; toJsonSchema(): { type: string; description?: string; }; } /** @internal */ declare class FloatTypeBuilder extends AbstractTypeBuilder { constructor(description: string | undefined); get type(): FloatType; /** Return a binary function that determines if two values of this type are equal */ equal(): (x: number, y: number) => boolean; /** Return a binary function that determines if one value of this type is less than another value of this type, according to Elara's canonical total ordering */ less(): (x: number, y: number) => boolean; /** Return a binary function that compares two values of this type, returing `-1` if the first is lesser, `0` if they are equal, and `+1` if the first is greater. Suitable for use in JavaScript methods like `Array#sort`. */ compare(): (x: number, y: number) => 0 | 1 | -1; /** Return an `JsonEncoder` that can transform an East value of this type into Elara's canonical JSON encoding */ jsonEncoder(): JsonEncoder; /** Return an `JsonDecoder` that can transform Elara's canonical JSON encoding into an East value of this type */ jsonDecoder(): JsonDecoder; toJsonSchema(): { type: string; description?: string; }; } /** @internal */ declare class DateTimeTypeBuilder extends AbstractTypeBuilder { constructor(description: string | undefined); get type(): DateTimeType; /** Return a binary function that determines if two values of this type are equal */ equal(): (x: Date, y: Date) => boolean; /** Return a binary function that determines if one value of this type is less than another value of this type, according to Elara's canonical total ordering */ less(): (x: Date, y: Date) => boolean; /** Return a binary function that compares two values of this type, returing `-1` if the first is lesser, `0` if they are equal, and `+1` if the first is greater. Suitable for use in JavaScript methods like `Array#sort`. */ compare(): (x: Date, y: Date) => 0 | 1 | -1; /** Return an `JsonEncoder` that can transform an East value of this type into Elara's canonical JSON encoding */ jsonEncoder(): JsonEncoder; /** Return an `JsonDecoder` that can transform Elara's canonical JSON encoding into an East value of this type */ jsonDecoder(): JsonDecoder; toJsonSchema(): { type: string; pattern: string; description?: string; }; } /** @internal */ declare class StringTypeBuilder extends AbstractTypeBuilder { constructor(description: string | undefined); get type(): StringType; /** Return a binary function that determines if two values of this type are equal */ equal(): (x: string, y: string) => boolean; /** Return a binary function that determines if one value of this type is less than another value of this type, according to Elara's canonical total ordering */ less(): (x: string, y: string) => boolean; /** Return a binary function that compares two values of this type, returing `-1` if the first is lesser, `0` if they are equal, and `+1` if the first is greater. Suitable for use in JavaScript methods like `Array#sort`. */ compare(): (x: string, y: string) => 0 | 1 | -1; /** Return an `JsonEncoder` that can transform an East value of this type into Elara's canonical JSON encoding */ jsonEncoder(): JsonEncoder; /** Return an `JsonDecoder` that can transform Elara's canonical JSON encoding into an East value of this type */ jsonDecoder(): JsonDecoder; toJsonSchema(): { type: string; description?: string; }; } /** @internal */ declare class BlobTypeBuilder extends AbstractTypeBuilder { constructor(description: string | undefined); get type(): BlobType; /** Return a binary function that determines if two values of this type are equal */ equal(): (x: Uint8Array, y: Uint8Array) => boolean; /** Return a binary function that determines if one value of this type is less than another value of this type, according to Elara's canonical total ordering */ less(): (x: Uint8Array, y: Uint8Array) => boolean; /** Return a binary function that compares two values of this type, returing `-1` if the first is lesser, `0` if they are equal, and `+1` if the first is greater. Suitable for use in JavaScript methods like `Array#sort`. */ compare(): (x: Uint8Array, y: Uint8Array) => 0 | 1 | -1; /** Return an `JsonEncoder` that can transform an East value of this type into Elara's canonical JSON encoding */ jsonEncoder(): JsonEncoder; /** Return an `JsonDecoder` that can transform Elara's canonical JSON encoding into an East value of this type */ jsonDecoder(): JsonDecoder; toJsonSchema(): { type: string; items: { type: string; minimum: number; maximum: number; }; description?: string; }; } /** @internal */ declare class ArrayTypeBuilder extends AbstractTypeBuilder> { private values; constructor(description: string | undefined, values: AbstractTypeBuilder); /** Return a binary function that determines if two values of this type are equal */ equal(): (x: ValueTypeOf[], y: ValueTypeOf[]) => boolean; /** Return a binary function that determines if one value of this type is less than another value of this type, according to Elara's canonical total ordering */ less(): (x: ValueTypeOf[], y: ValueTypeOf[]) => boolean; /** Return a binary function that compares two values of this type, returing `-1` if the first is lesser, `0` if they are equal, and `+1` if the first is greater. Suitable for use in JavaScript methods like `Array#sort`. */ compare(): (x: ValueTypeOf[], y: ValueTypeOf[]) => 0 | 1 | -1; /** Return an `JsonEncoder` that can transform an East value of this type into Elara's canonical JSON encoding */ jsonEncoder(): JsonEncoder>; /** Return an `JsonDecoder` that can transform Elara's canonical JSON encoding into an East value of this type */ jsonDecoder(): JsonDecoder>; get type(): ArrayType; toJsonSchema(): { type: string; items: any; description?: string; }; } /** @internal */ declare class SetTypeBuilder extends AbstractTypeBuilder> { private values; constructor(description: string | undefined, values: AbstractTypeBuilder); get type(): SetType; /** Return a binary function that determines if two values of this type are equal */ equal(): (x: Set>, y: Set>) => boolean; /** Return a binary function that determines if one value of this type is less than another value of this type, according to Elara's canonical total ordering */ less(): (x: Set>, y: Set>) => boolean; /** Return a binary function that compares two values of this type, returing `-1` if the first is lesser, `0` if they are equal, and `+1` if the first is greater. Suitable for use in JavaScript methods like `Array#sort`. */ compare(): (x: Set>, y: Set>) => 0 | 1 | -1; /** Return an `JsonEncoder` that can transform an East value of this type into Elara's canonical JSON encoding */ jsonEncoder(): JsonEncoder>; /** Return an `JsonDecoder` that can transform Elara's canonical JSON encoding into an East value of this type */ jsonDecoder(): JsonDecoder>; toJsonSchema(): { type: string; items: any; description?: string; }; } /** @internal */ declare class DictTypeBuilder extends AbstractTypeBuilder> { private keys; private values; constructor(description: string | undefined, keys: AbstractTypeBuilder, values: AbstractTypeBuilder); get type(): DictType; /** Return a binary function that determines if two values of this type are equal */ equal(): (x: Map, ValueTypeOf>, y: Map, ValueTypeOf>) => boolean; /** Return a binary function that determines if one value of this type is less than another value of this type, according to Elara's canonical total ordering */ less(): (x: Map, ValueTypeOf>, y: Map, ValueTypeOf>) => boolean; /** Return a binary function that compares two values of this type, returing `-1` if the first is lesser, `0` if they are equal, and `+1` if the first is greater. Suitable for use in JavaScript methods like `Array#sort`. */ compare(): (x: Map, ValueTypeOf>, y: Map, ValueTypeOf>) => 0 | 1 | -1; /** Return an `JsonEncoder` that can transform an East value of this type into Elara's canonical JSON encoding */ jsonEncoder(): JsonEncoder>; /** Return an `JsonDecoder` that can transform Elara's canonical JSON encoding into an East value of this type */ jsonDecoder(): JsonDecoder>; toJsonSchema(): { type: string; items: { type: string; properties: { key: any; value: any; }; required: string[]; }; description?: string; }; } /** @internal */ declare class FieldBuilder> { fields: { [K in keyof Fields]: AbstractTypeBuilder; }; constructor(fields: { [K in keyof Fields]: AbstractTypeBuilder; }); field AbstractTypeBuilder, Field extends AbstractTypeBuilder | Function>(name: Name, field: Field): FieldBuilder ? Field["type"] : Field extends Function ? ReturnType["type"] : never; }>; } /** @internal */ declare class StructTypeBuilder> extends AbstractTypeBuilder> { fields: { [K in keyof Fields]: AbstractTypeBuilder; }; constructor(description: string | undefined, fields: { [K in keyof Fields]: AbstractTypeBuilder; }); get type(): StructType; /** Return a binary function that determines if two values of this type are equal */ equal(): (x: { [K in keyof Fields]: ValueTypeOf; }, y: { [K in keyof Fields]: ValueTypeOf; }) => boolean; /** Return a binary function that determines if one value of this type is less than another value of this type, according to Elara's canonical total ordering */ less(): (x: { [K in keyof Fields]: ValueTypeOf; }, y: { [K in keyof Fields]: ValueTypeOf; }) => boolean; /** Return a binary function that compares two values of this type, returing `-1` if the first is lesser, `0` if they are equal, and `+1` if the first is greater. Suitable for use in JavaScript methods like `Array#sort`. */ compare(): (x: { [K in keyof Fields]: ValueTypeOf; }, y: { [K in keyof Fields]: ValueTypeOf; }) => 0 | 1 | -1; /** Return an `JsonEncoder` that can transform an East value of this type into Elara's canonical JSON encoding */ jsonEncoder(): JsonEncoder>; /** Return an `JsonDecoder` that can transform Elara's canonical JSON encoding into an East value of this type */ jsonDecoder(): JsonDecoder>; toJsonSchema(): { type: string; properties: Record; required: string[]; description?: string; }; } /** @internal */ declare class CaseBuilder> { cases: { [K in keyof Cases]: AbstractTypeBuilder; }; constructor(cases: { [K in keyof Cases]: AbstractTypeBuilder; }); case AbstractTypeBuilder>(name: Name, variant_case: Case): CaseBuilder["type"]; }>; } /** @internal */ declare class VariantTypeBuilder> extends AbstractTypeBuilder> { cases: { [K in keyof Cases]: AbstractTypeBuilder; }; constructor(description: string | undefined, cases: { [K in keyof Cases]: AbstractTypeBuilder; }); get type(): VariantType; /** Return a binary function that determines if two values of this type are equal */ equal(): (x: { [K in keyof Cases]: { type: K; [Data]: ValueTypeOf; }; }[keyof Cases], y: { [K in keyof Cases]: { type: K; [Data]: ValueTypeOf; }; }[keyof Cases]) => boolean; /** Return a binary function that determines if one value of this type is less than another value of this type, according to Elara's canonical total ordering */ less(): (x: { [K in keyof Cases]: { type: K; [Data]: ValueTypeOf; }; }[keyof Cases], y: { [K in keyof Cases]: { type: K; [Data]: ValueTypeOf; }; }[keyof Cases]) => boolean; /** Return a binary function that compares two values of this type, returing `-1` if the first is lesser, `0` if they are equal, and `+1` if the first is greater. Suitable for use in JavaScript methods like `Array#sort`. */ compare(): (x: { [K in keyof Cases]: { type: K; [Data]: ValueTypeOf; }; }[keyof Cases], y: { [K in keyof Cases]: { type: K; [Data]: ValueTypeOf; }; }[keyof Cases]) => -1 | 0 | 1; /** Return an `JsonEncoder` that can transform an East value of this type into Elara's canonical JSON encoding */ jsonEncoder(): JsonEncoder>; /** Return an `JsonDecoder` that can transform Elara's canonical JSON encoding into an East value of this type */ jsonDecoder(): JsonDecoder>; toJsonSchema(): { oneOf: { type: string; properties: { type: { const: string; }; value: any; }; required: string[]; }[]; description?: string; }; } export {};