@tai-kun/surrealdb
Version:
The SurrealDB SDK for JavaScript
45 lines • 2.68 kB
TypeScript
import { type DecodeOptions as CborDecodeOptions, type EncodeOptions as CborEncodeOptions } from "@tai-kun/surrealdb/cbor";
import type { BoundExcludedSource, BoundIncludedSource, DatetimeSource, DecimalSource, DurationSource, FutureSource, GeometryLineSource, GeometryMultiLineSource, GeometryMultiPointSource, GeometryMultiPolygonSource, GeometryPointSource, GeometryPolygonSource, TableSource, ThingSource, UuidSource } from "@tai-kun/surrealdb/decodeonly-datatypes";
import { type Data, EncodedCBOR, type Formatter } from "@tai-kun/surrealdb/formatter";
import { type StatefulPromise } from "@tai-kun/surrealdb/utils";
export interface CborDataTypes {
readonly Uuid: new (source: UuidSource) => any;
readonly Range: new (source: readonly [any, any]) => any;
readonly Table: new (source: TableSource) => any;
readonly Thing: new (source: ThingSource) => any;
readonly Future: new (source: FutureSource) => any;
readonly Decimal: new (source: DecimalSource) => any;
readonly Datetime: new (source: DatetimeSource) => any;
readonly Duration: new (source: DurationSource) => any;
readonly GeometryLine: new (source: GeometryLineSource) => any;
readonly BoundIncluded: new (source: BoundIncludedSource) => any;
readonly BoundExcluded: new (source: BoundExcludedSource) => any;
readonly GeometryPoint: new (source: GeometryPointSource) => any;
readonly GeometryPolygon: new (source: GeometryPolygonSource) => any;
readonly GeometryMultiLine: new (source: GeometryMultiLineSource) => any;
readonly GeometryMultiPoint: new (source: GeometryMultiPointSource) => any;
readonly GeometryCollection: new (source: readonly any[]) => any;
readonly GeometryMultiPolygon: new (source: GeometryMultiPolygonSource) => any;
}
export interface EncodeOptions extends CborEncodeOptions {
}
export interface DecodeOptions extends CborDecodeOptions {
readonly streamThreshold?: number | undefined;
}
export interface CborFormatterOptions extends CborDataTypes {
readonly encode?: EncodeOptions | undefined;
readonly decode?: DecodeOptions | undefined;
}
export default class CborFormatter implements Formatter {
protected dataTypes: CborDataTypes;
protected encodeOptions: EncodeOptions;
protected decodeOptions: DecodeOptions;
contentType: string;
wsProtocols: string[];
constructor(options: CborFormatterOptions);
toEncoded<TData = unknown>(data: TData): EncodedCBOR<TData>;
encodeSync(data: unknown): Uint8Array;
decodeSync(data: Data): unknown;
decodeStream(data: ReadableStream<Uint8Array>, signal: AbortSignal): StatefulPromise<unknown>;
}
//# sourceMappingURL=formatter.d.ts.map