UNPKG

@baqhub/sdk

Version:

The official JavaScript SDK for the BAQ federated app platform.

58 lines (57 loc) 3.31 kB
import * as t from "io-ts"; import { ExclusiveUnion } from "./type.js"; export * from "io-ts"; export interface ISODate extends t.Type<Date, string, unknown> { } export declare const isoDate: ISODate; type ReadonlyObjectType<P extends t.Props> = t.Type<{ readonly [K in keyof P]: t.TypeOf<P[K]>; }, any, any>; type PartialReadonlyObjectType<P extends t.Props> = t.Type<{ readonly [K in keyof P]?: t.TypeOf<P[K]>; }, any, any>; export declare function object<P extends t.Props>(props: P, name?: string): ReadonlyObjectType<P>; export declare function partialObject<P extends t.Props>(props: P, name?: string): PartialReadonlyObjectType<P>; export declare function dualObject<P1 extends t.Props, P2 extends t.Props>(props: P1, partialProps: P2): t.IntersectionC<[ReadonlyObjectType<P1>, PartialReadonlyObjectType<P2>]>; export declare function union<CS extends [t.Mixed, t.Mixed, ...Array<t.Mixed>]>(codecs: CS): t.UnionC<CS>; export declare function exclusiveUnion<CS extends [t.Mixed, t.Mixed, ...Array<t.Mixed>]>(codecs: CS): t.Type<ExclusiveUnion<t.TypeOf<CS[number]>>>; export declare function defaultValue<T, O>(type: t.Type<T, O>, defaultValue: T): t.Type<T, O | undefined, unknown>; export declare function arrayIgnore<C extends t.Mixed>(itemsType: C): t.Type<readonly t.TypeOf<C>[], readonly t.TypeOf<C>[], unknown>; export declare function enumRecord<C extends t.Mixed, D extends t.Mixed>(domain: C, codomain: D): t.DictionaryType<C, D, { [K in t.TypeOf<C>]?: t.TypeOf<D>; }, { [K in t.OutputOf<C>]: t.OutputOf<C>; }, unknown>; type Enum = { [key: string]: string | number; }; export declare function listEnumValues<T extends Enum>(sourceEnum: T): T[keyof T][]; export declare function enumeration<T extends Enum>(sourceEnum: T): t.Type<T[keyof T], string | number, unknown>; type StringEnum = { [key: string]: string; }; export declare function weakEnumeration<T extends StringEnum>(sourceEnum: T): t.Type<`${T[keyof T]}`, string, unknown>; interface EnumerationWithValuesOptions { isCaseSensitive: boolean; } export declare function enumerationWithValues<T extends Enum>(sourceEnum: T, values: { [K in T[keyof T]]: string; }, options?: EnumerationWithValuesOptions): t.Type<T[keyof T], string, unknown>; export declare function weakEnumerationWithValues<T extends Enum>(sourceEnum: T, values: { [K in `${T[keyof T]}`]: string; }, options?: EnumerationWithValuesOptions): t.Type<`${T[keyof T]}`, string, unknown>; declare class Base64Bytes extends t.Type<Uint8Array, string> { constructor(); } export declare const base64Bytes: Base64Bytes; declare class Utf8Bytes extends t.Type<Uint8Array, string> { constructor(); } export declare const utf8Bytes: Utf8Bytes; export type RType<T> = t.Type<T, unknown, unknown>; export declare function optional<T extends t.Any>(model: T): t.UnionC<[t.UndefinedC, T]>; export declare function clean<T>(model: t.Type<T, any, unknown>): t.Type<T, any, unknown>; export declare function validate<M extends t.Any>(model: M, value: unknown): t.TypeOf<M>; export declare function tryDecode<M extends t.Any>(model: M, value: unknown): t.TypeOf<M> | undefined; export declare function decode<M extends t.Any>(model: M, value: unknown): t.TypeOf<M>; export declare function encode<M extends t.Any>(model: M, value: t.TypeOf<M>): any;