UNPKG

@pgxsinkit/pgwasm

Version:
76 lines • 3.84 kB
import type { ParserOptions } from "./interface"; /** Built-in type OIDs. */ export declare const BOOL = 16, BYTEA = 17, CHAR = 18, INT8 = 20, INT2 = 21, INT4 = 23, REGPROC = 24, TEXT = 25, OID = 26, TID = 27, XID = 28, CID = 29, JSON = 114, XML = 142, PG_NODE_TREE = 194, SMGR = 210, PATH = 602, POLYGON = 604, CIDR = 650, FLOAT4 = 700, FLOAT8 = 701, ABSTIME = 702, RELTIME = 703, TINTERVAL = 704, CIRCLE = 718, MACADDR8 = 774, MONEY = 790, MACADDR = 829, INET = 869, ACLITEM = 1033, BPCHAR = 1042, VARCHAR = 1043, DATE = 1082, TIME = 1083, TIMESTAMP = 1114, TIMESTAMPTZ = 1184, INTERVAL = 1186, TIMETZ = 1266, BIT = 1560, VARBIT = 1562, NUMERIC = 1700, REFCURSOR = 1790, REGPROCEDURE = 2202, REGOPER = 2203, REGOPERATOR = 2204, REGCLASS = 2205, REGTYPE = 2206, UUID = 2950, TXID_SNAPSHOT = 2970, PG_LSN = 3220, PG_NDISTINCT = 3361, PG_DEPENDENCIES = 3402, TSVECTOR = 3614, TSQUERY = 3615, GTSVECTOR = 3642, REGCONFIG = 3734, REGDICTIONARY = 3769, JSONB = 3802, REGNAMESPACE = 4089, REGROLE = 4096; /** Turns a value's text representation into a JS value. */ export type Parser = (value: string, typeId?: number) => unknown; /** Turns a JS value into its text representation. */ export type Serializer = (value: unknown) => string; declare function serializeString(value: unknown): string; declare function serializeBoolean(value: unknown): string; declare function serializeDate(value: unknown): string; declare function serializeBytea(value: unknown): string; declare function parseBytea(value: string): Uint8Array; declare function parseBigint(value: string): number | bigint; declare function serializeJson(value: unknown): string; /** The default handlers, by the name pgwasm has always used for each family. */ export declare const types: { string: { to: number; from: number[]; serialize: typeof serializeString; parse: (x: string) => string; }; number: { to: number; from: number[]; serialize: typeof toText; parse: (x: string) => number; }; bigint: { to: number; from: number[]; serialize: typeof toText; parse: typeof parseBigint; }; json: { to: number; from: number[]; serialize: typeof serializeJson; parse: (x: string) => unknown; }; boolean: { to: number; from: number[]; serialize: typeof serializeBoolean; parse: (x: string) => x is "t"; }; date: { to: number; from: number[]; serialize: typeof serializeDate; parse: (x: string) => Date; }; bytea: { to: number; from: number[]; serialize: typeof serializeBytea; parse: typeof parseBytea; }; }; /** The default parsers, by OID (and by family name). */ export declare const parsers: Record<string | number, Parser>; /** The default serializers, by OID (and by family name). */ export declare const serializers: Record<string | number, Serializer>; /** * The text form of a value that has no serializer for its type: the value's own `toString()`, which * for a primitive is its usual text. */ export declare function toText(value: unknown): string; /** Parse one text value of the given type OID (`null` stays `null`; an unknown type stays text). */ export declare function parseType(value: string | null, type: number, overrides?: ParserOptions): unknown; /** Serialize a (nested) JS array to a Postgres array literal. A non-array is returned as it is. */ export declare function arraySerializer(xs: unknown, serializer: Serializer | undefined, typarray: number): string; /** Parse a Postgres array literal, applying `parser` to each element. */ export declare function arrayParser(x: string, parser: Parser | undefined, typarray: number): unknown; export {}; //# sourceMappingURL=types.d.ts.map