UNPKG

@tai-kun/surrealdb

Version:

The SurrealDB SDK for JavaScript

250 lines 9.24 kB
export declare const MT_UNSIGNED_INTEGER: 0; export declare const MT_NEGATIVE_INTEGER: 1; export declare const MT_BYTE_STRING: 2; export declare const MT_UTF8_STRING: 3; export declare const MT_ARRAY: 4; export declare const MT_MAP: 5; export declare const MT_TAG: 6; export declare const MT_SIMPLE_FLOAT: 7; export declare const AI_SIMPLE_FALSE: 20; export declare const AI_SIMPLE_TRUE: 21; export declare const AI_SIMPLE_NULL: 22; export declare const AI_SIMPLE_UNDEFINED: 23; export declare const AI_ONE_BYTE: 24; export declare const AI_TWO_BYTES: 25; export declare const AI_FOUR_BYTES: 26; export declare const AI_EIGHT_BYTES: 27; export declare const AI_INDEFINITE_NUM_BYTES: 31; export declare const BREAK: unique symbol; export declare const CBOR_MAX_UNSIGNED_INTEGER = 18446744073709551615n; export declare const CBOR_MIN_NEGATIVE_INTEGER = -18446744073709551616n; export declare const JS_MAX_SAFE_UNSIGNED_INTEGER = 9007199254740991; export declare const JS_MAX_SAFE_UNSIGNED_BIG_INTEGER = 9007199254740991n; export declare const HEADER_FLOAT_HALF = 249; export declare const HEADER_FLOAT_DOUBLE = 251; export declare const HEADER_FALSE = 244; export declare const HEADER_TRUE = 245; export declare const HEADER_NULL = 246; export declare const HEADER_UNDEFINED = 247; /** * [API Reference](https://tai-kun.github.io/surrealdb.js/v2/api/cbor/simple/) */ export declare class Simple { /** * 0 ~ 19, 32 ~ 255 * @see https://www.rfc-editor.org/rfc/rfc8949.html#name-simple-values */ value: number; constructor(value: number); } /** 3 Bits (0 ~ 7) */ export type MajorType = typeof MT_UNSIGNED_INTEGER | typeof MT_NEGATIVE_INTEGER | typeof MT_BYTE_STRING | typeof MT_UTF8_STRING | typeof MT_ARRAY | typeof MT_MAP | typeof MT_TAG | typeof MT_SIMPLE_FLOAT; export declare namespace AdditionalInfo { type Value = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23; type NumBytes = typeof AI_ONE_BYTE | typeof AI_TWO_BYTES | typeof AI_FOUR_BYTES | typeof AI_EIGHT_BYTES; type ReservedForFuture = 28 | 29 | 30; type Indefinite = typeof AI_INDEFINITE_NUM_BYTES; } /** 5 Bits (0 ~ 31) */ export type AdditionalInfo = AdditionalInfo.Value | AdditionalInfo.NumBytes | AdditionalInfo.ReservedForFuture | AdditionalInfo.Indefinite; export type DataItemValue = number | bigint | string | Uint8Array | boolean | null | undefined | typeof BREAK | Simple; export declare namespace DataItem { namespace UnsignedInteger { interface Tiny { mt: typeof MT_UNSIGNED_INTEGER; ai: AdditionalInfo.Value; /** 0 ~ 23 */ value: number; } interface OneByte { mt: typeof MT_UNSIGNED_INTEGER; ai: typeof AI_ONE_BYTE; /** 24 ~ 2^8-1 */ value: number; } interface TwoBytes { mt: typeof MT_UNSIGNED_INTEGER; ai: typeof AI_TWO_BYTES; /** 2^8 ~ 2^16-1 */ value: number; } interface FourBytes { mt: typeof MT_UNSIGNED_INTEGER; ai: typeof AI_FOUR_BYTES; /** 2^16 ~ 2^32-1 */ value: number; } interface EightBytes { mt: typeof MT_UNSIGNED_INTEGER; ai: typeof AI_EIGHT_BYTES; /** 2^32 ~ 2^64-1 */ value: number | bigint; } } type UnsignedInteger = UnsignedInteger.Tiny | UnsignedInteger.OneByte | UnsignedInteger.TwoBytes | UnsignedInteger.FourBytes | UnsignedInteger.EightBytes; namespace NegativeInteger { interface Tiny { mt: typeof MT_NEGATIVE_INTEGER; ai: AdditionalInfo.Value; /** -24 ~ -1 */ value: number; } interface OneByte { mt: typeof MT_NEGATIVE_INTEGER; ai: typeof AI_ONE_BYTE; /** -(2^8) ~ -25 */ value: number; } interface TwoBytes { mt: typeof MT_NEGATIVE_INTEGER; ai: typeof AI_TWO_BYTES; /** -(2^16) ~ -(2^8+1) */ value: number; } interface FourBytes { mt: typeof MT_NEGATIVE_INTEGER; ai: typeof AI_FOUR_BYTES; /** -(2^32) ~ -(2^16+1) */ value: number; } interface EightBytes { mt: typeof MT_NEGATIVE_INTEGER; ai: typeof AI_EIGHT_BYTES; /** -(2^64) ~ -(2^32+1) */ value: number | bigint; } } type NegativeInteger = NegativeInteger.Tiny | NegativeInteger.OneByte | NegativeInteger.TwoBytes | NegativeInteger.FourBytes | NegativeInteger.EightBytes; namespace ByteString { interface FixedLength { mt: typeof MT_BYTE_STRING; ai: AdditionalInfo.Value | AdditionalInfo.NumBytes; value: Uint8Array; } interface IndefiniteLength { mt: typeof MT_BYTE_STRING; ai: AdditionalInfo.Indefinite; /** +Infinity */ value: number; } } type ByteString = ByteString.FixedLength | ByteString.IndefiniteLength; namespace Utf8String { interface FixedLength { mt: typeof MT_UTF8_STRING; ai: AdditionalInfo.Value | AdditionalInfo.NumBytes; value: string; } interface IndefiniteLength { mt: typeof MT_UTF8_STRING; ai: AdditionalInfo.Indefinite; /** +Infinity */ value: number; } } type Utf8String = Utf8String.FixedLength | Utf8String.IndefiniteLength; namespace Array { interface FixedLength { mt: typeof MT_ARRAY; ai: AdditionalInfo.Value | AdditionalInfo.NumBytes; /** 0 ~ 2^53 - 1 */ value: number; } interface IndefiniteLength { mt: typeof MT_ARRAY; ai: AdditionalInfo.Indefinite; /** +Infinity */ value: number; } } type Array = Array.FixedLength | Array.IndefiniteLength; namespace Map { interface FixedLength { mt: typeof MT_MAP; ai: AdditionalInfo.Value | AdditionalInfo.NumBytes; /** 0 ~ Finite positive integer */ value: number; } interface IndefiniteLength { mt: typeof MT_MAP; ai: AdditionalInfo.Indefinite; /** +Infinity */ value: number; } } type Map = Map.FixedLength | Map.IndefiniteLength; interface Tag { mt: typeof MT_TAG; ai: AdditionalInfo.Value | AdditionalInfo.NumBytes; value: number | bigint; } namespace SimpleFloat { namespace Unassigned { interface Tiny { mt: typeof MT_SIMPLE_FLOAT; ai: Exclude<AdditionalInfo.Value, (False | True | Null | Undefined)["ai"]>; /** * 0 ~ 19 * @see https://www.rfc-editor.org/rfc/rfc8949.html#name-simple-values */ value: Simple; } interface Short { mt: typeof MT_SIMPLE_FLOAT; ai: typeof AI_ONE_BYTE; /** * 32 ~ 255 * @see https://www.rfc-editor.org/rfc/rfc8949.html#name-simple-values */ value: Simple; } } type Unassigned = Unassigned.Tiny | Unassigned.Short; interface False { mt: typeof MT_SIMPLE_FLOAT; ai: typeof AI_SIMPLE_FALSE; value: false; } interface True { mt: typeof MT_SIMPLE_FLOAT; ai: typeof AI_SIMPLE_TRUE; value: true; } interface Null { mt: typeof MT_SIMPLE_FLOAT; ai: typeof AI_SIMPLE_NULL; value: null; } interface Undefined { mt: typeof MT_SIMPLE_FLOAT; ai: typeof AI_SIMPLE_UNDEFINED; value: undefined; } namespace Float { interface Half { mt: typeof MT_SIMPLE_FLOAT; ai: typeof AI_TWO_BYTES; value: number; } interface Single { mt: typeof MT_SIMPLE_FLOAT; ai: typeof AI_FOUR_BYTES; value: number; } interface Double { mt: typeof MT_SIMPLE_FLOAT; ai: typeof AI_EIGHT_BYTES; value: number; } } type Float = Float.Half | Float.Single | Float.Double; interface Break { mt: typeof MT_SIMPLE_FLOAT; ai: typeof AI_INDEFINITE_NUM_BYTES; value: typeof BREAK; } } type SimpleFloat = SimpleFloat.Unassigned | SimpleFloat.False | SimpleFloat.True | SimpleFloat.Null | SimpleFloat.Undefined | SimpleFloat.Float | SimpleFloat.Break; } export type DataItem = DataItem.UnsignedInteger | DataItem.NegativeInteger | DataItem.ByteString | DataItem.Utf8String | DataItem.Array | DataItem.Map | DataItem.Tag | DataItem.SimpleFloat; //# sourceMappingURL=spec.d.ts.map