// Generated by dts-bundle-generator v9.5.1

import { Replacer } from '@surrealdb/cbor';
import { UUID } from 'uuidv7';

declare class Feature {
	#private;
	constructor(name: string, since?: string, until?: string);
	get name(): string;
	get sinceVersion(): string | undefined;
	get untilVersion(): string | undefined;
	supports(version: string): boolean;
}
type OnFulfilled<T, TResult> = ((value: T) => TResult | PromiseLike<TResult>) | null | undefined;
type OnRejected<TResult> = ((reason: unknown) => TResult | PromiseLike<TResult>) | null | undefined;
declare abstract class DispatchedPromise<T> extends Promise<T> {
	#private;
	protected abstract dispatch(): Promise<T>;
	constructor();
	then<TResult1 = T, TResult2 = never>(onfulfilled?: OnFulfilled<T, TResult1>, onrejected?: OnRejected<TResult2>): Promise<TResult1 | TResult2>;
	catch<TResult = never>(onrejected?: OnRejected<TResult>): Promise<T | TResult>;
	finally(onfinally?: (() => void) | undefined | null): Promise<T>;
	static get [Symbol.species](): PromiseConstructor;
	get [Symbol.toStringTag](): string;
}
/**
 * A bound query represents a query string combined with bindings.
 */
export declare class BoundQuery<R extends unknown[] = unknown[]> {
	#private;
	/**
	 * Creates a new empty BoundQuery instance.
	 */
	constructor();
	/**
	 * Creates a new BoundQuery instance by cloning an existing instance.
	 *
	 * @param origin The BoundQuery to clone
	 */
	constructor(origin: BoundQuery<R>);
	/**
	 * Creates a new BoundQuery instance.
	 *
	 * @param query The initial query string
	 * @param bindings The initial bindings object
	 */
	constructor(query: string, bindings?: Record<string, unknown>);
	/**
	 * Retrieves the query string.
	 */
	get query(): string;
	/**
	 * Retrieves a copy of the configured bindings.
	 */
	get bindings(): Record<string, unknown>;
	/**
	 * Append another BoundQuery to this one, ensuring no duplicate parameters.
	 *
	 * @param other The BoundQuery to append
	 * @returns The current BoundQuery instance
	 */
	append(other: BoundQuery<R>): this;
	/**
	 * Append a query string and bindings to this one, ensuring no duplicate parameters.
	 *
	 * @param query The query string to append
	 * @param bindings The bindings to append
	 * @returns The current BoundQuery instance
	 */
	append(query: string, bindings?: Record<string, unknown>): this;
	/**
	 * Append a query string and bindings through a template literal tags.
	 * Interpolated values are automatically stored as bindings with unique names.
	 *
	 * @param strings The template string segments
	 * @param values The interpolated values
	 * @returns The current BoundQuery instance
	 */
	append(strings: TemplateStringsArray, ...values: unknown[]): this;
}
/**
 * The channel iterator is a utility class that allows you to submit values to an async iterator.
 */
export declare class ChannelIterator<T> implements AsyncIterable<T>, AsyncIterator<T> {
	#private;
	constructor(cleanup?: () => void);
	next(): Promise<IteratorResult<T>>;
	return(): Promise<IteratorResult<T>>;
	throw(error?: unknown): Promise<IteratorResult<T>>;
	[Symbol.asyncIterator](): this;
	submit(value: T): void;
	cancel(): void;
}
/**
 * Recursively compare supported SurrealQL values for equality.
 *
 * @param x The first value to compare
 * @param y The second value to compare
 * @returns Whether the two values are recursively equal
 */
export declare function equals(x: unknown, y: unknown): boolean;
/**
 * A complex SurrealQL value type
 */
export declare abstract class Value {
	/**
	 * Compare equality with another value.
	 */
	abstract equals(other: unknown): boolean;
	/**
	 * Convert this value to a serializable string
	 */
	abstract toJSON(): unknown;
	/**
	 * Convert this value to a string representation
	 */
	abstract toString(): string;
}
type DurationTuple = [
	number | bigint,
	number | bigint
] | [
	number | bigint
] | [
];
/**
 * A SurrealQL duration value with support for parsing, formatting, arithmetic, and nanosecond precision.
 */
export declare class Duration extends Value {
	#private;
	/**
	 * Constructs a new Duration by cloning an existing duration
	 *
	 * @param input Duration input
	 */
	constructor(input: Duration);
	/**
	 * Constructs a new Duration from a tuple representation
	 *
	 * @param input Second and nanosecond tuple
	 */
	constructor(input: DurationTuple);
	/**
	 * Constructs a new Duration from a human-readable string, e.g. "1h30m"
	 *
	 * @param input Duration string
	 */
	constructor(input: string);
	equals(other: unknown): boolean;
	toJSON(): string;
	/**
	 * @returns Human readable duration string
	 */
	toString(): string;
	/**
	 * Converts the duration to a tuple
	 */
	toCompact(): [
		bigint,
		bigint
	] | [
		bigint
	] | [
	];
	/**
	 * Parses a duration string like "1h30m"
	 *
	 * @param input Input string
	 * @returns [seconds, nanoseconds]
	 */
	static parseString(input: string): [
		bigint,
		bigint
	];
	/**
	 * Adds two durations together
	 *
	 * @param other The duration to add
	 * @returns The resulting duration
	 */
	add(other: Duration): Duration;
	/**
	 * Subtracts another duration from this one
	 *
	 * @param other The duration to subtract
	 * @returns The resulting duration
	 */
	sub(other: Duration): Duration;
	/**
	 * Multiplies the duration by a scalar
	 *
	 * @param factor The factor to multiply by
	 * @returns The resulting duration
	 */
	mul(factor: number | bigint): Duration;
	/**
	 * Divides the duration
	 *
	 * @param divisor The duration or scalar to divide by
	 * @returns A new Duration or ratio (unitless bigint)
	 */
	div(divisor: Duration): bigint;
	div(divisor: number | bigint): Duration;
	/**
	 * Computes the remainder after division
	 *
	 * @param mod The divisor
	 * @returns The remainder duration
	 */
	mod(mod: Duration): Duration;
	/**
	 * Total nanoseconds in this duration
	 */
	get nanoseconds(): bigint;
	/**
	 * Total microseconds
	 */
	get microseconds(): bigint;
	/**
	 * Total milliseconds
	 */
	get milliseconds(): bigint;
	/**
	 * Whole seconds in the duration
	 */
	get seconds(): bigint;
	/**
	 * Total whole minutes in the duration
	 */
	get minutes(): bigint;
	/**
	 * Total whole hours in the duration
	 */
	get hours(): bigint;
	/**
	 * Total whole days in the duration
	 */
	get days(): bigint;
	/**
	 * Total whole weeks in the duration
	 */
	get weeks(): bigint;
	/**
	 * Total whole years in the duration
	 */
	get years(): bigint;
	/**
	 * Creates a Duration from nanoseconds
	 *
	 * @param ns Nanoseconds value
	 * @returns The resulting duration
	 */
	static nanoseconds(ns: number | bigint): Duration;
	/**
	 * Creates a Duration from microseconds
	 *
	 * @param µs Microseconds value
	 * @returns The resulting duration
	 */
	static microseconds(µs: number | bigint): Duration;
	/**
	 * Creates a Duration from milliseconds
	 *
	 * @param ms Milliseconds value
	 * @returns The resulting duration
	 */
	static milliseconds(ms: number | bigint): Duration;
	/**
	 * Creates a Duration from seconds
	 *
	 * @param s Seconds value
	 * @returns The resulting duration
	 */
	static seconds(s: number | bigint): Duration;
	/**
	 * Creates a Duration from minutes
	 *
	 * @param m Minutes value
	 * @returns The resulting duration
	 */
	static minutes(m: number | bigint): Duration;
	/**
	 * Creates a Duration from hours
	 *
	 * @param h Hours value
	 * @returns The resulting duration
	 */
	static hours(h: number | bigint): Duration;
	/**
	 * Creates a Duration from days
	 *
	 * @param d Days value
	 * @returns The resulting duration
	 */
	static days(d: number | bigint): Duration;
	/**
	 * Creates a Duration from weeks
	 *
	 * @param w Weeks value
	 * @returns The resulting duration
	 */
	static weeks(w: number | bigint): Duration;
	/**
	 * Creates a Duration from years
	 *
	 * @param y Years value
	 * @returns The resulting duration
	 */
	static years(y: number | bigint): Duration;
	/**
	 * Parses a duration from a float string with a single time unit, e.g. "1.998487792s", "1.5m", "500.0ms"
	 *
	 * @param input Float duration string
	 * @returns The resulting duration
	 */
	static parseFloat(input: string): Duration;
	/**
	 * Measures the elapsed time since the function was called
	 * If the Performance API is available, it uses it to measure the elapsed time in nanoseconds
	 *
	 * @returns A function that returns the elapsed time as a Duration
	 */
	static measure(): () => Duration;
}
type DateTimeTuple = [
	number | bigint,
	number | bigint
];
/**
 * A SurrealQL datetime value with support for parsing, formatting, arithmetic, and nanosecond precision.
 */
export declare class DateTime extends Value {
	#private;
	private static loadHr;
	/**
	 * Constructs a new DateTime with the current time, equivalent to `DateTime.now()`
	 */
	constructor();
	/**
	 * Constructs a new DateTime by cloning an existing datetime
	 *
	 * @param input DateTime input
	 */
	constructor(input: DateTime);
	/**
	 * Constructs a new DateTime from a JavaScript Date object
	 *
	 * @param input Date input
	 */
	constructor(input: Date);
	/**
	 * Constructs a new DateTime from a tuple representation
	 *
	 * @param input Second and nanosecond tuple
	 */
	constructor(input: DateTimeTuple);
	/**
	 * Constructs a new DateTime from an ISO String
	 *
	 * @param input ISO String string
	 */
	constructor(input: string);
	/**
	 * Constructs a new DateTime from a number or bigint
	 *
	 * @param input Number or bigint input
	 */
	constructor(input: number | bigint);
	equals(other: unknown): boolean;
	toJSON(): string;
	/**
	 * @returns The ISO 8601 string representation of the datetime
	 */
	toString(): string;
	/**
	 * Converts the datetime to a tuple
	 */
	toCompact(): [
		bigint,
		bigint
	];
	/**
	 * Formats the datetime as an ISO 8601 string
	 */
	toISOString(): string;
	/**
	 * Converts to JavaScript Date object
	 */
	toDate(): Date;
	/**
	 * Parses a datetime string
	 *
	 * @param input Input string (ISO 8601 format)
	 * @returns [seconds, nanoseconds] tuple
	 */
	static parseString(input: string): [
		bigint,
		bigint
	];
	/**
	 * Adds a duration to this datetime
	 *
	 * @param duration The duration to add
	 * @returns The new datetime instance
	 */
	add(duration: Duration): DateTime;
	/**
	 * Subtracts a duration from this datetime
	 *
	 * @param duration The duration to subtract
	 * @returns The new datetime instance
	 */
	sub(duration: Duration): DateTime;
	/**
	 * Calculates the duration between two datetimes
	 *
	 * @param other The other datetime
	 */
	diff(other: DateTime): Duration;
	/**
	 * Compares this DateTime with another
	 *
	 * @param other The DateTime to compare with
	 * @returns -1 if other is before, 0 if equal, 1 if other is after
	 */
	compare(other: DateTime): number;
	/**
	 * Total nanoseconds since Unix epoch
	 */
	get nanoseconds(): bigint;
	/**
	 * Total microseconds since Unix epoch
	 */
	get microseconds(): bigint;
	/**
	 * Total milliseconds since Unix epoch
	 */
	get milliseconds(): number;
	/**
	 * Seconds since Unix epoch
	 */
	get seconds(): number;
	/**
	 * Creates a DateTime from nanoseconds since Unix epoch
	 *
	 * @param ns Nanoseconds value
	 */
	static fromEpochNanoseconds(ns: number | bigint): DateTime;
	/**
	 * Creates a DateTime from microseconds since Unix epoch
	 *
	 * @param µs Microseconds value
	 */
	static fromEpochMicroseconds(µs: number | bigint): DateTime;
	/**
	 * Creates a DateTime from milliseconds since Unix epoch
	 *
	 * @param ms Milliseconds value
	 */
	static fromEpochMilliseconds(ms: number | bigint): DateTime;
	/**
	 * Creates a DateTime from seconds since Unix epoch
	 *
	 * @param s Seconds value
	 */
	static fromEpochSeconds(s: number | bigint): DateTime;
	/**
	 * Returns a new DateTime representing the current time
	 */
	static now(): DateTime;
	/**
	 * Returns a new DateTime representing the Unix epoch (1970-01-01T00:00:00Z)
	 */
	static epoch(): DateTime;
}
type DecimalTuple = [
	bigint,
	bigint,
	number
];
/**
 * A SurrealQL decimal number value with support for parsing, formatting, arithmetic, and high precision.
 */
export declare class Decimal extends Value {
	#private;
	/**
	 * Constructs a new Decimal by cloning an existing Decimal
	 *
	 * @param input Decimal input
	 */
	constructor(input: Decimal);
	/**
	 * Constructs a new Decimal from a scientific notation string
	 *
	 * @param input String input
	 */
	constructor(input: string);
	/**
	 * Constructs a new Decimal from a number or bigint
	 *
	 * @param input Number or bigint input
	 */
	constructor(input: number | bigint);
	/**
	 * Constructs a new Decimal from a tuple [int, frac, scale]
	 *
	 * @param input Tuple input
	 */
	constructor(input: DecimalTuple);
	equals(other: unknown): boolean;
	toJSON(): string;
	/**
	 * @returns The canonical string representation of the decimal with
	 * trailing zeros in fractional part trimmed
	 */
	toString(): string;
	/** Returns the integer part of the number */
	get int(): bigint;
	/** Returns the fractional part of the number */
	get frac(): bigint;
	/** Returns the scale (number of decimal places) */
	get scale(): number;
	/**
	 * Adds another Decimal to this one
	 *
	 * @param other The Decimal to add
	 * @returns A new Decimal representing the sum
	 */
	add(other: Decimal): Decimal;
	/**
	 * Subtracts another Decimal from this one
	 *
	 * @param other The Decimal to subtract
	 * @returns A new Decimal representing the difference
	 */
	sub(other: Decimal): Decimal;
	/**
	 * Multiplies this Decimal by another
	 *
	 * @param other The Decimal to multiply by
	 * @returns A new Decimal representing the product
	 */
	mul(other: Decimal): Decimal;
	/**
	 * Divides this Decimal by another, with fixed precision
	 *
	 * @param other The Decimal to divide by
	 * @returns A new Decimal representing the quotient
	 */
	div(other: Decimal): Decimal;
	/**
	 * Computes the remainder of this Decimal divided by another
	 *
	 * @param other The divisor Decimal
	 * @returns A new Decimal representing the remainder
	 */
	mod(other: Decimal): Decimal;
	/**
	 * Returns the absolute value of this Decimal
	 * @returns A new Decimal with non-negative components
	 */
	abs(): Decimal;
	/**
	 * Returns the negated value of this Decimal
	 * @returns A new Decimal with inverted sign
	 */
	neg(): Decimal;
	/**
	 * Checks if the value is exactly zero
	 * @returns True if both int and frac parts are zero
	 */
	isZero(): boolean;
	/**
	 * Checks if the value is negative
	 * @returns True if negative
	 */
	isNegative(): boolean;
	/**
	 * Compares this Decimal with another
	 *
	 * @param other The Decimal to compare with
	 * @returns -1 if less, 0 if equal, 1 if greater
	 */
	compare(other: Decimal): number;
	/**
	 * Rounds the Decimal to a fixed number of decimal places
	 *
	 * @param precision Number of digits to keep after the decimal point
	 * @returns The new decimal instance
	 */
	round(precision: number): Decimal;
	/**
	 * Converts the number to fixed-point notation string
	 *
	 * @param precision Number of digits after the decimal point
	 */
	toFixed(precision: number): string;
	/**
	 * Converts the Decimal to a native JavaScript number
	 * @returns A number approximation (may lose precision)
	 */
	toFloat(): number;
	/**
	 * Converts to bigint by truncating the fractional part
	 * @returns An bigint approximation (may lose precision)
	 */
	toBigInt(): bigint;
	/**
	 * Returns the raw parts of the Decimal
	 * @returns An object with int, frac, and scale
	 */
	toParts(): {
		int: bigint;
		frac: bigint;
		scale: number;
	};
	/**
	 * Converts to scientific notation string (e.g., "1.23e4")
	 */
	toScientific(): string;
	/**
	 * Parses a number in scientific notation into a Decimal
	 *
	 * @param input The scientific notation string
	 */
	static fromScientificNotation(input: string): Decimal;
	private toBigIntWithScale;
}
/**
 * A SurrealQL file reference value.
 */
export declare class FileRef extends Value {
	#private;
	constructor(bucket: string, key: string);
	get bucket(): string;
	get key(): string;
	equals(other: unknown): boolean;
	toJSON(): string;
	toString(): string;
}
/**
 * An uncomputed SurrealQL future value.
 *
 * @deprecated Futures were removed in SurrealDB 3.0
 */
export declare class Future extends Value {
	#private;
	constructor(body: string);
	equals(other: unknown): boolean;
	toJSON(): string;
	/**
	 * @returns The uncomputed future notation
	 */
	toString(): string;
	/**
	 * The body of the future
	 */
	get body(): string;
}
/**
 * A SurrealQL geometry value.
 */
export declare abstract class Geometry extends Value {
	abstract toJSON(): GeoJson;
	abstract is(geometry: Geometry): boolean;
	abstract clone(): Geometry;
	equals(other: unknown): boolean;
	toString(): string;
}
/**
 * A SurrealQL point geometry value.
 */
export declare class GeometryPoint extends Geometry {
	readonly point: [
		number,
		number
	];
	constructor(point: [
		number | Decimal,
		number | Decimal
	] | GeometryPoint);
	toJSON(): GeoJsonPoint;
	get coordinates(): GeoJsonPoint["coordinates"];
	is(geometry: Geometry): geometry is GeometryPoint;
	clone(): GeometryPoint;
}
/**
 * A SurrealQL line geometry value.
 */
export declare class GeometryLine extends Geometry {
	readonly line: [
		GeometryPoint,
		GeometryPoint,
		...GeometryPoint[]
	];
	constructor(line: [
		GeometryPoint,
		GeometryPoint,
		...GeometryPoint[]
	] | GeometryLine);
	toJSON(): GeoJsonLineString;
	get coordinates(): GeoJsonLineString["coordinates"];
	close(): void;
	is(geometry: Geometry): geometry is GeometryLine;
	clone(): GeometryLine;
}
/**
 * A SurrealQL polygon geometry value.
 */
export declare class GeometryPolygon extends Geometry {
	readonly polygon: [
		GeometryLine,
		...GeometryLine[]
	];
	constructor(polygon: [
		GeometryLine,
		...GeometryLine[]
	] | GeometryPolygon);
	toJSON(): GeoJsonPolygon;
	get coordinates(): GeoJsonPolygon["coordinates"];
	is(geometry: Geometry): geometry is GeometryPolygon;
	clone(): GeometryPolygon;
}
/**
 * A SurrealQL multi-point geometry value.
 */
export declare class GeometryMultiPoint extends Geometry {
	readonly points: [
		GeometryPoint,
		...GeometryPoint[]
	];
	constructor(points: [
		GeometryPoint,
		...GeometryPoint[]
	] | GeometryMultiPoint);
	toJSON(): GeoJsonMultiPoint;
	get coordinates(): GeoJsonMultiPoint["coordinates"];
	is(geometry: Geometry): geometry is GeometryMultiPoint;
	clone(): GeometryMultiPoint;
}
/**
 * A SurrealQL multi-line geometry value.
 */
export declare class GeometryMultiLine extends Geometry {
	readonly lines: [
		GeometryLine,
		...GeometryLine[]
	];
	constructor(lines: [
		GeometryLine,
		...GeometryLine[]
	] | GeometryMultiLine);
	toJSON(): GeoJsonMultiLineString;
	get coordinates(): GeoJsonMultiLineString["coordinates"];
	is(geometry: Geometry): geometry is GeometryMultiLine;
	clone(): GeometryMultiLine;
}
/**
 * A SurrealQL multi-polygon geometry value.
 */
export declare class GeometryMultiPolygon extends Geometry {
	readonly polygons: [
		GeometryPolygon,
		...GeometryPolygon[]
	];
	constructor(polygons: [
		GeometryPolygon,
		...GeometryPolygon[]
	] | GeometryMultiPolygon);
	toJSON(): GeoJsonMultiPolygon;
	get coordinates(): GeoJsonMultiPolygon["coordinates"];
	is(geometry: Geometry): geometry is GeometryMultiPolygon;
	clone(): GeometryMultiPolygon;
}
/**
 * A SurrealQL geometry collection value.
 */
export declare class GeometryCollection extends Geometry {
	readonly collection: [
		Geometry,
		...Geometry[]
	];
	constructor(collection: [
		Geometry,
		...Geometry[]
	] | GeometryCollection);
	toJSON(): GeoJsonCollection;
	get geometries(): GeoJsonCollection["geometries"];
	is(geometry: Geometry): geometry is GeometryCollection;
	clone(): GeometryCollection;
}
type GeoJson = GeoJsonPoint | GeoJsonLineString | GeoJsonPolygon | GeoJsonMultiPoint | GeoJsonMultiLineString | GeoJsonMultiPolygon | GeoJsonCollection;
type GeoJsonPoint = {
	type: "Point";
	coordinates: [
		number,
		number
	];
};
type GeoJsonLineString = {
	type: "LineString";
	coordinates: [
		GeoJsonPoint["coordinates"],
		GeoJsonPoint["coordinates"],
		...GeoJsonPoint["coordinates"][]
	];
};
type GeoJsonPolygon = {
	type: "Polygon";
	coordinates: [
		GeoJsonLineString["coordinates"],
		...GeoJsonLineString["coordinates"][]
	];
};
type GeoJsonMultiPoint = {
	type: "MultiPoint";
	coordinates: [
		GeoJsonPoint["coordinates"],
		...GeoJsonPoint["coordinates"][]
	];
};
type GeoJsonMultiLineString = {
	type: "MultiLineString";
	coordinates: [
		GeoJsonLineString["coordinates"],
		...GeoJsonLineString["coordinates"][]
	];
};
type GeoJsonMultiPolygon = {
	type: "MultiPolygon";
	coordinates: [
		GeoJsonPolygon["coordinates"],
		...GeoJsonPolygon["coordinates"][]
	];
};
type GeoJsonCollection = {
	type: "GeometryCollection";
	geometries: GeoJson[];
};
/**
 * Represents a range bound which includes the value within the range
 */
export declare class BoundIncluded<T> {
	readonly value: T;
	constructor(value: T);
}
/**
 * Represents a range bound which excludes the value from the range
 */
export declare class BoundExcluded<T> {
	readonly value: T;
	constructor(value: T);
}
/**
 * Represents a Bound which can represent the start or end of a range
 */
export type Bound<T> = BoundIncluded<T> | BoundExcluded<T> | undefined;
/**
 * A SurrealQL range value.
 */
declare class Range$1<Beg, End> extends Value {
	#private;
	constructor(beg: Bound<Beg>, end: Bound<End>);
	equals(other: unknown): boolean;
	toJSON(): string;
	/**
	 * @returns The escaped range string
	 */
	toString(): string;
	/**
	 * The range bound beginning
	 */
	get begin(): Bound<Beg>;
	/**
	 * The range bound ending
	 */
	get end(): Bound<End>;
}
type Prettify<T> = {
	[K in keyof T]: T[K];
} & {};
type Field<I> = keyof I | (string & {});
type Selection$1 = "value" | "fields" | "diff";
type WidenRecordIdValue<T> = T extends string ? string : T extends number ? number : T extends bigint ? bigint : T;
/**
 * A SurrealQL table value.
 */
export declare class Table<Tb extends string = string> extends Value {
	#private;
	constructor(tb: Tb);
	equals(other: unknown): boolean;
	toJSON(): string;
	/**
	 * @returns The escaped table name
	 */
	toString(): string;
	/**
	 * The unescaped table name
	 */
	get name(): Tb;
}
/**
 * A SurrealQL UUID value.
 */
export declare class Uuid extends Value {
	#private;
	/**
	 * Constructs a new Uuid by cloning an existing uuid
	 *
	 * @param input Uuid input
	 */
	constructor(uuid: Uuid | UUID);
	/**
	 * Constructs a new Uuid from a string representation
	 *
	 * @param uuid String input
	 */
	constructor(uuid: string);
	/**
	 * Constructs a new Uuid from a binary representation
	 *
	 * @param uuid ArrayBuffer or Uint8Array input
	 */
	constructor(uuid: ArrayBuffer | Uint8Array);
	equals(other: unknown): boolean;
	toJSON(): string;
	/**
	 * @returns The string representation of the UUID
	 */
	toString(): string;
	/**
	 * Converts the UUID to a Uint8Array
	 */
	toUint8Array(): Uint8Array;
	/**
	 * Converts the UUID to a ArrayBuffer
	 */
	toBuffer(): ArrayBufferLike;
	/**
	 * Generate a new UUID v4
	 */
	static v4(): Uuid;
	/**
	 * Generate a new UUID v7
	 */
	static v7(): Uuid;
}
export type RecordIdValue = string | number | Uuid | bigint | unknown[] | Record<string, unknown>;
declare class RecordId<Tb extends string = string, Id extends RecordIdValue = RecordIdValue> extends Value {
	#private;
	constructor(table: Tb | Table<Tb>, id: Id);
	equals(other: unknown): boolean;
	toJSON(): string;
	/**
	 * @returns The escaped record ID string including the table name
	 */
	toString(): string;
	/**
	 * The table part value
	 */
	get table(): Table<Tb>;
	/**
	 * The ID part value
	 */
	get id(): Id;
}
interface RecordIdConstructor {
	new <T extends string = string, I extends RecordIdValue = RecordIdValue>(table: T | Table<T>, id: I): RecordId<T, WidenRecordIdValue<I>>;
	new <R extends RecordId<string, RecordIdValue>>(table: R["table"]["name"], id: R["id"]): RecordId<R["table"]["name"], R["id"]>;
}
/**
 * A SurrealQL record ID value.
 */
type _RecordId<Tb extends string = string, Id extends RecordIdValue = RecordIdValue> = RecordId<Tb, Id>;
declare const _RecordId: RecordIdConstructor;
declare class RecordIdRange<Tb extends string = string, Id extends RecordIdValue = RecordIdValue> extends Value {
	#private;
	constructor(table: Tb | Table<Tb>, beg: Bound<Id>, end: Bound<Id>);
	equals(other: unknown): boolean;
	toJSON(): string;
	/**
	 * @returns The escaped record ID range string
	 */
	toString(): string;
	/**
	 * The table part value
	 */
	get table(): Table<Tb>;
	/**
	 * The range bound beginning
	 */
	get begin(): Bound<Id>;
	/**
	 * The range bound ending
	 */
	get end(): Bound<Id>;
}
interface RecordIdRangeConstructor {
	new <T extends string = string, I extends RecordIdValue = RecordIdValue>(table: T | Table<T>, beg: Bound<I>, end: Bound<I>): RecordIdRange<T, WidenRecordIdValue<I>>;
	new <R extends RecordIdRange<string, RecordIdValue>>(table: R["table"]["name"], beg: R["begin"], end: R["end"]): RecordIdRange<R["table"]["name"], R["begin"] extends Bound<infer I> ? (I extends RecordIdValue ? I : never) : never>;
}
/**
 * A SurrealQL record ID range value.
 */
type _RecordIdRange<Tb extends string = string, Id extends RecordIdValue = RecordIdValue> = RecordIdRange<Tb, Id>;
declare const _RecordIdRange: RecordIdRangeConstructor;
/**
 * A SurrealQL string-represented record ID value.
 */
export declare class StringRecordId extends Value {
	#private;
	constructor(rid: string | StringRecordId | _RecordId);
	equals(other: unknown): boolean;
	toJSON(): string;
	/**
	 * @returns The string representation of the record ID
	 */
	toString(): string;
}
/**
 * Escape a given string to be used as a valid SurrealQL ident
 *
 * @param str - The string to escape
 * @returns Optionally escaped string
 */
export declare function escapeIdent(str: string): string;
/**
 * Escape a number to be used as a valid SurrealQL ident
 *
 * @param num - The number to escape
 * @returns Optionally escaped number
 */
export declare function escapeNumber(num: number | bigint): string;
/**
 * Escape a record id value part
 *
 * @param id The record id value part
 * @returns The escaped record id value part
 */
export declare function escapeIdPart(id: RecordIdValue): string;
/**
 * Escape a range bound value
 *
 * @param bound The range bound containing a value
 * @returns The escaped range bound
 */
export declare function escapeRangeBound<T>(bound: Bound<T>): string;
/**
 * Parse a SurrealQL expression to a BoundQuery
 *
 * @param expr The SurrealQL expression
 * @returns A BoundQuery instance
 */
export declare function expr(expr: ExprLike): BoundQuery;
/**
 * Represents a raw SurrealQL expression
 *
 * **IMPORTANT**: This function should only be used when no other operator is applicable.
 * Incorrect use of this function will risk exposing queries to SQL injection.
 *
 * @param s The raw value
 */
export declare const raw: (s: string) => Expr;
/**
 * Represents a equality comparison operation (=)
 *
 * @param field The field name
 * @param v The value to compare against
 */
export declare const eq: (field: string, v: unknown) => Expr;
/**
 * Represents an exact equality comparison operation (==)
 *
 * @param field The field name
 * @param v The value to compare against
 */
export declare const eeq: (field: string, v: unknown) => Expr;
/**
 * Represents a not equal comparison operation (!=)
 *
 * @param field The field name
 * @param v The value to compare against
 */
export declare const ne: (field: string, v: unknown) => Expr;
/**
 * Represents a greater than comparison operation (>)
 *
 * @param field The field name
 * @param v The value to compare against
 */
export declare const gt: (field: string, v: unknown) => Expr;
/**
 * Represents a greater than or equal to comparison operation (>=)
 *
 * @param field The field name
 * @param v The value to compare against
 */
export declare const gte: (field: string, v: unknown) => Expr;
/**
 * Represents a less than comparison operation (<)
 *
 * @param field The field name
 * @param v The value to compare against
 */
export declare const lt: (field: string, v: unknown) => Expr;
/**
 * Represents a less than or equal to comparison operation (<=)
 *
 * @param field The field name
 * @param v The value to compare against
 */
export declare const lte: (field: string, v: unknown) => Expr;
/**
 * Represents a contains operation (CONTAINS)
 *
 * @param field The field name
 * @param v The value to compare against
 */
export declare const contains: (field: string, v: unknown) => Expr;
/**
 * Represents a contains any operation (CONTAINSANY)
 *
 * @param field The field name
 * @param v The value to compare against
 */
export declare const containsAny: (field: string, v: unknown) => Expr;
/**
 * Represents a contains all operation (CONTAINSALL)
 *
 * @param field The field name
 * @param v The value to compare against
 */
export declare const containsAll: (field: string, v: unknown) => Expr;
/**
 * Represents a contains none operation (CONTAINSNONE)
 *
 * @param field The field name
 * @param v The value to compare against
 */
export declare const containsNone: (field: string, v: unknown) => Expr;
/**
 * Represents an inside operation (INSIDE)
 *
 * @param field The field name
 * @param v The value to compare against
 */
export declare const inside: (field: string, v: unknown) => Expr;
/**
 * Represents a geometry outside operation (OUTSIDE)
 *
 * @param field The field name
 * @param g The value to compare against
 */
export declare const outside: (field: string, g: unknown) => Expr;
/**
 * Represents a geometry intersects operation (INTERSECTS)
 *
 * @param field The field name
 * @param g The value to compare against
 */
export declare const intersects: (field: string, g: unknown) => Expr;
/**
 * Represents a full-text search match operation (@@)
 *
 * @param field The field name
 * @param q The value to compare against
 * @param ref The optional reference number
 */
export declare const matches: (field: string, q: string, ref?: number) => Expr;
/**
 * Represents a KNN nearest neighbor operation
 *
 * Supported operations include:
 * - Brute Force: <|n,metric|>, where n is the number of neighbors and metric is the metric to use
 * - MTree: <|n|>, where n is the number of neighbors
 * - HNSW: <|n,ef|>, where n is the number of neighbors and ef is the ef
 *
 * @param field The field name
 * @param v The value to compare against
 * @param neighbors The number of neighbors
 * @param metricOrEf The optional metric or ef
 */
export declare const knn: (field: string, v: unknown, neighbors: number, metricOrEf?: string | number) => Expr;
/**
 * Represents a between operation. This is a shortcut for `and(gte(field, a), lte(field, b))`
 *
 * @param field The field name
 * @param a The lower bound
 * @param b The upper bound
 */
export declare const between: (field: string, a: unknown, b: unknown) => Expr;
/**
 * Represents a logical AND operation
 *
 * @param exprs The expressions to join
 * @returns A new expression
 */
export declare const and: (...exprs: ExprLike[]) => Expr;
/**
 * Represents a logical OR operation
 *
 * @param exprs The expressions to join
 * @returns A new expression
 */
export declare const or: (...exprs: ExprLike[]) => Expr;
/**
 * Represents a logical NOT operation
 *
 * @param expr The expression to negate
 * @returns A new expression
 */
export declare const not: (expr: ExprLike) => Expr;
/**
 * Available features which may be supported by specific
 * engines or versions of SurrealDB.
 */
export declare const Features: Readonly<{
	LiveQueries: Feature;
	Sessions: Feature;
	Api: Feature;
	RefreshTokens: Feature;
	Transactions: Feature;
	ExportImportRaw: Feature;
	SurrealML: Feature;
}>;
/**
 * Represents a single query result frame frame
 */
export declare class Frame<T, J extends boolean> {
	readonly query: number;
	constructor(query: number);
	/**
	 * Returns true if the frame is associated with the given query index
	 */
	isOf<V = T>(query: number): this is Frame<V, J>;
	/**
	 * Returns true if the frame is a value frame
	 */
	isValue<V = T>(): this is ValueFrame<V, J>;
	/**
	 * Returns true if the frame is an error frame
	 */
	isError<V = T>(): this is ErrorFrame<V, J>;
	/**
	 * Returns true if the frame is a done frame
	 */
	isDone<V = T>(): this is DoneFrame<V, J>;
	/**
	 * Returns true if the frame is a value frame and associated with the given query index
	 */
	isValueOf<V = T>(query: number): this is ValueFrame<V, J>;
	/**
	 * Returns true if the frame is an error frame and associated with the given query index
	 */
	isErrorOf<V = T>(query: number): this is ErrorFrame<V, J>;
	/**
	 * Returns true if the frame is a done frame and associated with the given query index
	 */
	isDoneOf<V = T>(query: number): this is DoneFrame<V, J>;
}
/**
 * Represents a value frame in a query result. If `isSingle` is true, the frame represents a single value
 * and no further values will be returned for that specific statement.
 */
export declare class ValueFrame<T, J extends boolean> extends Frame<T, J> {
	readonly value: MaybeJsonify<T, J>;
	readonly isSingle: boolean;
	constructor(query: number, value: MaybeJsonify<T, J>, isSingle: boolean);
	isOf<V = T>(query: number): this is ValueFrame<V, J>;
}
/**
 * Represents an error frame in a query result
 */
export declare class ErrorFrame<T, J extends boolean> extends Frame<T, J> {
	readonly stats: QueryStats | undefined;
	readonly error: ServerError;
	constructor(query: number, stats: QueryStats | undefined, error: ServerError);
	isOf<V = T>(query: number): this is ErrorFrame<V, J>;
	/**
	 * Throw the server error corresponding to this error frame
	 */
	throw(): never;
}
/**
 * Represents a done frame in a query result
 */
export declare class DoneFrame<T, J extends boolean> extends Frame<T, J> {
	readonly stats: QueryStats | undefined;
	readonly type: QueryType;
	constructor(query: number, stats: QueryStats | undefined, type: QueryType);
	isOf<V = T>(query: number): this is DoneFrame<V, J>;
}
export declare const MINIMUM_VERSION = "2.1.0";
export declare const MAXIMUM_VERSION = "4.0.0";
/**
 * Returns whether a SurrealDB version is supported by the SDK.
 *
 * @param version The SurrealDB version to check
 * @param min The minimum version to check against
 * @param until The maximum version to check against
 * @returns Whether the version is supported
 */
export declare function isVersionSupported(version: string, min?: string, until?: string): boolean;
export type Jsonify<T> = T extends Date | DateTime | Uuid | Decimal | Duration | Future | FileRef | Range$1<unknown, unknown> | StringRecordId ? string : T extends undefined ? undefined : T extends Record<string | number | symbol, unknown> | Array<unknown> ? {
	[K in keyof T]: Jsonify<T[K]>;
} : T extends Map<infer K, infer V> ? Map<K, Jsonify<V>> : T extends Set<infer V> ? Set<Jsonify<V>> : T extends Geometry ? ReturnType<T["toJSON"]> : T extends _RecordId<infer Tb> ? `${Tb}:${string}` : T extends _RecordIdRange<infer Tb> ? `${Tb}:${string}..${string}` : T extends Table<infer Tb> ? `${Tb}` : T;
/**
 * Recursively convert any supported SurrealQL value into a serializable JSON representation.
 *
 * @param input The input value
 * @returns JSON-safe representation
 */
export declare function jsonify<T>(input: T): Jsonify<T>;
interface AuthOptions {
	transaction: Uuid | undefined;
	session: Session;
	json: boolean;
}
declare class AuthPromise<T, J extends boolean = false> extends DispatchedPromise<MaybeJsonify<T, J>> {
	#private;
	constructor(connection: ConnectionController, options: AuthOptions);
	/**
	 * Configure the query to return the result as a
	 * JSON-compatible structure.
	 *
	 * This is useful when query results need to be serialized. Keep in mind
	 * that your responses will lose SurrealDB type information.
	 */
	json(): AuthPromise<T, true>;
	/**
	 * Compile this qurery into a BoundQuery
	 */
	compile(): BoundQuery<[
		T
	]>;
	/**
	 * Stream the results of the query as they are received.
	 *
	 * @returns An async iterable of query frames.
	 */
	stream(): AsyncIterable<Frame<T, J>>;
	protected dispatch(): Promise<MaybeJsonify<T, J>>;
}
interface CreateOptions {
	what: AnyRecordId | Table;
	mutation?: Mutation;
	data?: unknown;
	output?: Output;
	timeout?: Duration;
	version?: DateTime;
	transaction: Uuid | undefined;
	session: Session;
	json: boolean;
}
declare class CreatePromise<T, I, J extends boolean = false> extends DispatchedPromise<MaybeJsonify<T, J>> {
	#private;
	constructor(connection: ConnectionController, options: CreateOptions);
	/**
	 * Configure the query to return the result as a
	 * JSON-compatible structure.
	 *
	 * This is useful when query results need to be serialized. Keep in mind
	 * that your responses will lose SurrealDB type information.
	 */
	json(): CreatePromise<T, I, true>;
	/**
	 * Configure the query to set the record data
	 */
	content(data: Values<I>): CreatePromise<T, I, J>;
	/**
	 * Configure the query to patch the record data
	 */
	patch(data: Values<I>): CreatePromise<T, I, J>;
	/**
	 * Configure the output of the query
	 */
	output(output: Output): CreatePromise<T, I, J>;
	/**
	 * Configure the timeout of the query
	 */
	timeout(timeout: Duration): CreatePromise<T, I, J>;
	/**
	 * Configure a custom version of the data being created. This is used
	 * alongside version enabled storage engines such as SurrealKV.
	 */
	version(version: DateTime): CreatePromise<T, I, J>;
	/**
	 * Compile this qurery into a BoundQuery
	 */
	compile(): BoundQuery<[
		T
	]>;
	/**
	 * Stream the results of the query as they are received.
	 *
	 * @returns An async iterable of query frames.
	 */
	stream(): AsyncIterable<Frame<T, J>>;
	protected dispatch(): Promise<MaybeJsonify<T, J>>;
}
interface DeleteOptions {
	what: AnyRecordId | _RecordIdRange | Table;
	output?: Output;
	timeout?: Duration;
	version?: DateTime;
	transaction: Uuid | undefined;
	session: Session;
	json: boolean;
}
declare class DeletePromise<T, J extends boolean = false> extends DispatchedPromise<MaybeJsonify<T, J>> {
	#private;
	constructor(connection: ConnectionController, options: DeleteOptions);
	/**
	 * Configure the query to return the result as a
	 * JSON-compatible structure.
	 *
	 * This is useful when query results need to be serialized. Keep in mind
	 * that your responses will lose SurrealDB type information.
	 */
	json(): DeletePromise<T, true>;
	/**
	 * Configure the output of the query
	 */
	output(output: Output): DeletePromise<T, J>;
	/**
	 * Configure the timeout of the query
	 */
	timeout(timeout: Duration): DeletePromise<T, J>;
	/**
	 * Configure a custom version of the data being created. This is used
	 * alongside version enabled storage engines such as SurrealKV.
	 */
	version(version: DateTime): DeletePromise<T, J>;
	/**
	 * Compile this qurery into a BoundQuery
	 */
	compile(): BoundQuery<[
		T
	]>;
	/**
	 * Stream the results of the query as they are received.
	 *
	 * @returns An async iterable of query frames.
	 */
	stream(): AsyncIterable<Frame<T, J>>;
	protected dispatch(): Promise<MaybeJsonify<T, J>>;
}
interface InsertOptions {
	table: Table | undefined;
	what: unknown | unknown[];
	relation?: boolean;
	ignore?: boolean;
	output?: Output;
	timeout?: Duration;
	version?: DateTime;
	transaction: Uuid | undefined;
	session: Session;
	json: boolean;
}
declare class InsertPromise<T, J extends boolean = false> extends DispatchedPromise<MaybeJsonify<T, J>> {
	#private;
	constructor(connection: ConnectionController, options: InsertOptions);
	/**
	 * Configure the query to return the result as a
	 * JSON-compatible structure.
	 *
	 * This is useful when query results need to be serialized. Keep in mind
	 * that your responses will lose SurrealDB type information.
	 */
	json(): InsertPromise<T, true>;
	/**
	 * Configure the query to insert a relation instead of a regular record
	 */
	relation(): InsertPromise<T, J>;
	/**
	 * Configure the query to ignore records if they already exist
	 */
	ignore(): InsertPromise<T, J>;
	/**
	 * Configure the output of the query
	 */
	output(output: Output): InsertPromise<T, J>;
	/**
	 * Configure the timeout of the query
	 */
	timeout(timeout: Duration): InsertPromise<T, J>;
	/**
	 * Configure a custom version of the data being created. This is used
	 * alongside version enabled storage engines such as SurrealKV.
	 */
	version(version: DateTime): InsertPromise<T, J>;
	/**
	 * Compile this qurery into a BoundQuery
	 */
	compile(): BoundQuery<[
		T
	]>;
	/**
	 * Stream the results of the query as they are received.
	 *
	 * @returns An async iterable of query frames.
	 */
	stream(): AsyncIterable<Frame<T, J>>;
	protected dispatch(): Promise<MaybeJsonify<T, J>>;
}
interface ManagedLiveOptions {
	what: LiveResource;
	fields?: string[];
	selection?: Selection$1;
	cond?: Expr;
	fetch?: string[];
	session: Session;
}
declare class ManagedLivePromise<T> extends DispatchedPromise<LiveSubscription> {
	#private;
	constructor(connection: ConnectionController, options: ManagedLiveOptions);
	/**
	 * Configure the live subscription to return only patches (diffs)
	 * instead of the full resource on each update.
	 */
	diff(): ManagedLivePromise<T>;
	/**
	 * Configure the query to only select the specified field(s)
	 */
	fields(...fields: Field<T>[]): ManagedLivePromise<T>;
	/**
	 * Configure the query to retrieve the value of the specified field
	 */
	value(field: Field<T>): ManagedLivePromise<T>;
	/**
	 * Configure the query to fetch the record only if the condition is met.
	 *
	 * Expressions can be imported from the `surrealdb` package and combined
	 * to compose the desired condition.
	 *
	 * @see {@link https://github.com/surrealdb/surrealdb.js/blob/main/packages/sdk/src/utils/expr.ts}
	 */
	where(expr: ExprLike): ManagedLivePromise<T>;
	/**
	 * Configure the query to fetch record link contents for the specified field(s)
	 */
	fetch(...fields: Field<T>[]): ManagedLivePromise<T>;
	/**
	 * Compile this qurery into a BoundQuery
	 */
	compile(): BoundQuery<[
		T
	]>;
	protected dispatch(): Promise<LiveSubscription>;
}
interface UnmanagedLiveOptions {
	id: Uuid;
	session: Session;
}
declare class UnmanagedLivePromise extends DispatchedPromise<LiveSubscription> {
	#private;
	constructor(connection: ConnectionController, options: UnmanagedLiveOptions);
	protected dispatch(): Promise<LiveSubscription>;
}
interface QueryOptions {
	query: BoundQuery;
	transaction: Uuid | undefined;
	session: Session;
	json: boolean;
}
type Collect<T extends unknown[], J extends boolean> = T extends [
] ? unknown[] : {
	[K in keyof T]: MaybeJsonify<T[K], J>;
};
type Responses<T extends unknown[], J extends boolean> = T extends [
] ? QueryResponse[] : {
	[K in keyof T]: QueryResponse<MaybeJsonify<T[K], J>>;
};
declare class Query<R extends unknown[] = unknown[], J extends boolean = false> extends DispatchedPromise<Collect<R, J>> {
	#private;
	constructor(connection: ConnectionController, options: QueryOptions);
	/**
	 * Retrieve the inner query that will be sent to the database.
	 */
	get inner(): BoundQuery;
	/**
	 * Configure the query to return the result of each response as a
	 * JSON-compatible structure.
	 *
	 * This is useful when query results need to be serialized. Keep in mind
	 * that your responses will lose SurrealDB type information.
	 */
	json(): Query<R, true>;
	/**
	 * Collect and return the results of all queries at once. If any of the queries fail, the promise
	 * will reject.
	 *
	 * You can optionally pass a list of query indexes to collect only the results of specific queries.
	 *
	 * This is the same as awaiting the query directly, but allows specifying which queries to collect.
	 *
	 * @example
	 * ```ts
	 * const [people] = await this.query("SELECT * FROM person").collect<[Person[]]>();
	 * ```
	 *
	 * @param queries The queries to collect. If no queries are provided, all queries will be collected.
	 * @returns A promise that resolves to the results of all queries at once.
	 */
	collect<T extends unknown[] = R>(...queries: number[]): Promise<Collect<T, J>>;
	/**
	 * Stream the response frames of the query as they are received as an AsyncIterable.
	 *
	 * Each iteration yields a **value**, **error**, or **done** frame. The provided
	 * `isValue`, `isError`, and `isDone` methods can be used to check the type of frame.
	 * You can pass a query index to these functions to check if the frame is associated with a
	 * specific query.
	 *
	 * @example
	 * ```ts
	 * const stream = this.query("SELECT * FROM person").stream();
	 *
	 * for await (const frame of stream) {
	 *     if (frame.isValue<Person>(0)) {
	 *         // use frame.value
	 *     }
	 * }
	 * ```
	 *
	 * @returns An async iterable of query frames.
	 */
	stream<T = unknown>(): AsyncIterable<Frame<T, J>>;
	/**
	 * Collect and return the responses of all queries at once. Failed queries will be returned
	 * with `success: false` and the associated error, while successful queries will have
	 * `success: true` and their result.
	 *
	 * You can optionally pass a list of query indexes to collect only the results of specific responses.
	 *
	 * @example
	 * ```ts
	 * const [people] = await this.query("SELECT * FROM person").responses<[Person[]]>();
	 *
	 * people.success; // true
	 * people.result; // Person[]
	 * ```
	 *
	 * @param queries The queries to collect. If no queries are provided, all queries will be collected.
	 * @returns A promise that resolves to the responses of all queries at once.
	 */
	responses<T extends unknown[] = R>(...queries: number[]): Promise<Responses<T, J>>;
	dispatch(): Promise<Collect<R, J>>;
}
interface RelateOptions {
	from: AnyRecordId | AnyRecordId[];
	what: Table | _RecordId;
	to: AnyRecordId | AnyRecordId[];
	unique?: boolean;
	output?: Output;
	timeout?: Duration;
	version?: DateTime;
	data?: unknown;
	transaction: Uuid | undefined;
	session: Session;
	json: boolean;
}
declare class RelatePromise<T, J extends boolean = false> extends DispatchedPromise<MaybeJsonify<T, J>> {
	#private;
	constructor(connection: ConnectionController, options: RelateOptions);
	/**
	 * Configure the query to return the result as a
	 * JSON-compatible structure.
	 *
	 * This is useful when query results need to be serialized. Keep in mind
	 * that your responses will lose SurrealDB type information.
	 */
	json(): RelatePromise<T, true>;
	/**
	 * Configure the query to enforce a unique relationship
	 */
	unique(): RelatePromise<T, J>;
	/**
	 * Configure the output of the query
	 */
	output(output: Output): RelatePromise<T, J>;
	/**
	 * Configure the timeout of the query
	 */
	timeout(timeout: Duration): RelatePromise<T, J>;
	/**
	 * Configure a custom version of the data being created. This is used
	 * alongside version enabled storage engines such as SurrealKV.
	 */
	version(version: DateTime): RelatePromise<T, J>;
	/**
	 * Compile this qurery into a BoundQuery
	 */
	compile(): BoundQuery<[
		T
	]>;
	/**
	 * Stream the results of the query as they are received.
	 *
	 * @returns An async iterable of query frames.
	 */
	stream(): AsyncIterable<Frame<T, J>>;
	protected dispatch(): Promise<MaybeJsonify<T, J>>;
}
interface RunOptions {
	name: string;
	version: string | undefined;
	args: unknown[];
	transaction: Uuid | undefined;
	session: Session;
	json: boolean;
}
declare class RunPromise<T, J extends boolean = false> extends DispatchedPromise<MaybeJsonify<T, J>> {
	#private;
	constructor(connection: ConnectionController, options: RunOptions);
	/**
	 * Configure the query to return the result as a
	 * JSON-compatible structure.
	 *
	 * This is useful when query results need to be serialized. Keep in mind
	 * that your responses will lose SurrealDB type information.
	 */
	json(): RunPromise<T, true>;
	/**
	 * Compile this qurery into a BoundQuery
	 */
	compile(): BoundQuery<[
		T
	]>;
	/**
	 * Stream the results of the query as they are received.
	 *
	 * @returns An async iterable of query frames.
	 */
	stream(): AsyncIterable<Frame<T, J>>;
	protected dispatch(): Promise<MaybeJsonify<T, J>>;
}
interface SelectOptions {
	what: AnyRecordId | _RecordIdRange | Table;
	fields?: string[];
	selection?: Selection$1;
	start?: number;
	limit?: number;
	cond?: Expr;
	fetch?: string[];
	timeout?: Duration;
	version?: DateTime;
	transaction: Uuid | undefined;
	session: Session;
	json: boolean;
}
declare class SelectPromise<T, I, J extends boolean = false> extends DispatchedPromise<MaybeJsonify<T, J>> {
	#private;
	constructor(connection: ConnectionController, options: SelectOptions);
	/**
	 * Configure the query to return the result as a
	 * JSON-compatible structure.
	 *
	 * This is useful when query results need to be serialized. Keep in mind
	 * that your responses will lose SurrealDB type information.
	 */
	json(): SelectPromise<T, I, true>;
	/**
	 * Configure the query to only select the specified field(s)
	 */
	fields(...fields: Field<I>[]): SelectPromise<T, I, J>;
	/**
	 * Configure the query to retrieve the value of the specified field
	 */
	value(field: Field<I>): SelectPromise<T, I, J>;
	/**
	 * Configure the query to start at the specified index
	 */
	start(start: number): SelectPromise<T, I, J>;
	/**
	 * Configure the query to limit the number of results
	 */
	limit(limit: number): SelectPromise<T, I, J>;
	/**
	 * Configure the query to fetch only records that match the condition.
	 *
	 * Expressions can be imported from the `surrealdb` package and combined
	 * to compose the desired condition.
	 *
	 * @see {@link https://github.com/surrealdb/surrealdb.js/blob/main/packages/sdk/src/utils/expr.ts}
	 */
	where(expr: ExprLike): SelectPromise<T, I, J>;
	/**
	 * Configure the query to fetch record link contents for the specified field(s)
	 */
	fetch(...fields: Field<I>[]): SelectPromise<T, I, J>;
	/**
	 * Configure the timeout of the query
	 */
	timeout(timeout: Duration): SelectPromise<T, I, J>;
	/**
	 * Configure a custom version of the data being created. This is used
	 * alongside version enabled storage engines such as SurrealKV.
	 */
	version(version: DateTime): SelectPromise<T, I, J>;
	/**
	 * Compile this qurery into a BoundQuery
	 */
	compile(): BoundQuery<[
		T
	]>;
	/**
	 * Stream the results of the query as they are received.
	 *
	 * @returns An async iterable of query frames.
	 */
	stream(): AsyncIterable<Frame<T, J>>;
	protected dispatch(): Promise<MaybeJsonify<T, J>>;
}
interface UpdateOptions {
	what: AnyRecordId | _RecordIdRange | Table;
	mutation?: Mutation;
	data?: unknown;
	cond?: Expr;
	output?: Output;
	timeout?: Duration;
	transaction: Uuid | undefined;
	session: Session;
	json: boolean;
}
declare class UpdatePromise<T, I, J extends boolean = false> extends DispatchedPromise<MaybeJsonify<T, J>> {
	#private;
	constructor(connection: ConnectionController, options: UpdateOptions);
	/**
	 * Configure the query to return the result as a
	 * JSON-compatible structure.
	 *
	 * This is useful when query results need to be serialized. Keep in mind
	 * that your responses will lose SurrealDB type information.
	 */
	json(): UpdatePromise<T, I, true>;
	/**
	 * Configure the query to set the record data
	 */
	content(data: Values<I>): UpdatePromise<T, I, J>;
	/**
	 * Configure the query to merge the record data
	 */
	merge(data: Values<I>): UpdatePromise<T, I, J>;
	/**
	 * Configure the query to replace the record data
	 */
	replace(data: Values<I>): UpdatePromise<T, I, J>;
	/**
	 * Configure the query to patch the record data
	 */
	patch(data: Values<I>): UpdatePromise<T, I, J>;
	/**
	 * Configure the query to update the record only if the condition is met.
	 *
	 * Expressions can be imported from the `surrealdb` package and combined
	 * to compose the desired condition.
	 *
	 * @see {@link https://github.com/surrealdb/surrealdb.js/blob/main/packages/sdk/src/utils/expr.ts}
	 */
	where(expr: ExprLike): UpdatePromise<T, I, J>;
	/**
	 * Configure the output of the query
	 */
	output(output: Output): UpdatePromise<T, I, J>;
	/**
	 * Configure the timeout of the query
	 */
	timeout(timeout: Duration): UpdatePromise<T, I, J>;
	/**
	 * Compile this qurery into a BoundQuery
	 */
	compile(): BoundQuery<[
		T
	]>;
	/**
	 * Stream the results of the query as they are received.
	 *
	 * @returns An async iterable of query frames.
	 */
	stream(): AsyncIterable<Frame<T, J>>;
	protected dispatch(): Promise<MaybeJsonify<T, J>>;
}
interface UpsertOptions {
	what: AnyRecordId | _RecordIdRange | Table;
	mutation?: Mutation;
	data?: unknown;
	cond?: Expr;
	output?: Output;
	timeout?: Duration;
	transaction: Uuid | undefined;
	session: Session;
	json: boolean;
}
declare class UpsertPromise<T, I, J extends boolean = false> extends DispatchedPromise<MaybeJsonify<T, J>> {
	#private;
	constructor(connection: ConnectionController, options: UpsertOptions);
	/**
	 * Configure the query to return the result as a
	 * JSON-compatible structure.
	 *
	 * This is useful when query results need to be serialized. Keep in mind
	 * that your responses will lose SurrealDB type information.
	 */
	json(): UpsertPromise<T, I, true>;
	/**
	 * Configure the query to set the record data
	 */
	content(data: Values<I>): UpsertPromise<T, I, J>;
	/**
	 * Configure the query to merge the record data
	 */
	merge(data: Values<I>): UpsertPromise<T, I, J>;
	/**
	 * Configure the query to replace the record data
	 */
	replace(data: Values<I>): UpsertPromise<T, I, J>;
	/**
	 * Configure the query to patch the record data
	 */
	patch(data: Values<I>): UpsertPromise<T, I, J>;
	/**
	 * Configure the query to upsert the record only if the condition is met.
	 *
	 * Expressions can be imported from the `surrealdb` package and combined
	 * to compose the desired condition.
	 *
	 * @see {@link https://github.com/surrealdb/surrealdb.js/blob/main/packages/sdk/src/utils/expr.ts}
	 */
	where(expr: ExprLike): UpsertPromise<T, I, J>;
	/**
	 * Configure the output of the query
	 */
	output(output: Output): UpsertPromise<T, I, J>;
	/**
	 * Configure the timeout of the query
	 */
	timeout(timeout: Duration): UpsertPromise<T, I, J>;
	/**
	 * Compile this qurery into a BoundQuery
	 */
	compile(): BoundQuery<[
		T
	]>;
	/**
	 * Stream the results of the query as they are received.
	 *
	 * @returns An async iterable of query frames.
	 */
	stream(): AsyncIterable<Frame<T, J>>;
	protected dispatch(): Promise<MaybeJsonify<T, J>>;
}
/**
 * Represents a subscription to a LIVE SELECT query
 */
export declare abstract class LiveSubscription implements AsyncIterable<LiveMessage> {
	/**
	 * The ID of the live subscription. Note that this id might change after
	 * a live query has been restarted.
	 */
	abstract get id(): Uuid;
	/**
	 * Returns whether this LiveQuery is managed by the driver and may be automatically
	 * restarted once the connection is re-established.
	 */
	abstract get isManaged(): boolean;
	/**
	 * The live resource that this subscription is tracking, if any.
	 */
	abstract get resource(): LiveResource | undefined;
	/**
	 * Whether the LiveQuery is considered alive. Although the connection may be
	 * disconnected, the LiveQuery may still be alive if it is managed by the driver.
	 */
	abstract get isAlive(): boolean;
	/**
	 * Kill the live subscription and stop receiving updates
	 */
	abstract kill(): Promise<void>;
	/**
	 * The async iterator for the live subscription
	 */
	abstract [Symbol.asyncIterator](): AsyncIterator<LiveMessage>;
	/**
	 * Subscribe to the live subscription and return an unsubscribe function
	 */
	subscribe(handler: (message: LiveMessage) => void): () => void;
}
/**
 * A managed live subscription that is automatically restarted when the connection
 * is re-established.
 */
export declare class ManagedLiveSubscription extends LiveSubscription {
	#private;
	constructor(controller: ConnectionController, resource: LiveResource, session: Session, query: Query);
	get id(): Uuid;
	get isManaged(): boolean;
	get resource(): LiveResource;
	get isAlive(): boolean;
	kill(): Promise<void>;
	[Symbol.asyncIterator](): AsyncIterator<LiveMessage>;
}
/**
 * An unmanaged live subscription which is constructed with only
 * a known pre-existing ID. This subscription will not be automatically
 * restarted when the connection is re-established.
 */
export declare class UnmanagedLiveSubscription extends LiveSubscription {
	#private;
	constructor(controller: ConnectionController, session: Session, id: Uuid);
	get id(): Uuid;
	get isManaged(): boolean;
	get resource(): undefined;
	get isAlive(): boolean;
	kill(): Promise<void>;
	[Symbol.asyncIterator](): AsyncIterator<LiveMessage>;
}
export type EventPayload = Record<string | number | symbol, unknown[]>;
export interface EventPublisher<EventMap extends EventPayload> {
	/**
	 * Subscribe to an event, invoking the provided listener when the event is emitted.
	 *
	 * @param event The event to subscribe to
	 * @param listener The listener to invoke when the event is emitted
	 * @returns A function to unsubscribe from the event
	 */
	subscribe<K extends keyof EventMap>(event: K, listener: (...payload: EventMap[K]) => void): () => void;
}
export declare class Publisher<T extends EventPayload> implements EventPublisher<T> {
	#private;
	subscribe<K extends keyof T>(event: K, listener: (...event: T[K]) => void): () => void;
	subscribeFirst<K extends keyof T>(...events: K[]): Promise<T[K]>;
	publish<K extends keyof T>(event: K, ...payload: T[K]): void;
}
/**
 * A template literal tag function for parsing a string type.
 *
 * @param string The string to parse
 * @param values The interpolated values
 * @returns The parsed string
 */
export declare function s(string: string[] | TemplateStringsArray, ...values: unknown[]): string;
/**
 * A template literal tag function for parsing a string into a Date.
 *
 * @param string The string to parse
 * @param values The interpolated values
 * @returns The parsed Date
 */
export declare function d(string: string[] | TemplateStringsArray, ...values: unknown[]): DateTime;
/**
 * A template literal tag function for parsing a string into a StringRecordId.
 *
 * @param string The string to parse
 * @param values The interpolated values
 * @returns The parsed StringRecordId
 */
export declare function r(string: string[] | TemplateStringsArray, ...values: unknown[]): StringRecordId;
/**
 * A template literal tag function for parsing a string into a Uuid.
 *
 * @param string The string to parse
 * @param values The interpolated values
 * @returns The parsed Uuid
 */
export declare function u(string: string[] | TemplateStringsArray, ...values: unknown[]): Uuid;
/**
 * A template literal tag function for creating BoundQuery instances from query strings.
 * Interpolated values are automatically stored as bindings with unique names.
 *
 * @param strings The template string segments
 * @param values The interpolated values
 * @example const query = surql`SELECT * FROM users WHERE name = ${name}`;
 * @returns A BoundQuery instance
 */
export declare function surql(strings: TemplateStringsArray, ...values: unknown[]): BoundQuery;
/**
 * Recursively convert any supported SurrealQL value into a string representation.
 *
 * @param input The input value
 * @returns Stringified SurrealQL representation
 */
export declare function toSurqlString(input: unknown): string;
type MaybeJsonify<T, J extends boolean> = J extends true ? Jsonify<T> : T;
interface ApiResponse<T> {
	body?: T;
	headers?: Record<string, string>;
	status?: number;
}
type Result<Res, V extends boolean> = V extends true ? Res : ApiResponse<Res>;
type Collect$1<Res, V extends boolean, J extends boolean> = MaybeJsonify<Result<Res, V>, J>;
interface ApiOptions<Req> {
	path: string;
	body?: Req;
	method: string;
	headers: Record<string, string>;
	query: Record<string, string>;
	transaction: Uuid | undefined;
	session: Session;
	value: boolean;
	json: boolean;
}
declare class ApiPromise<Req, Res, V extends boolean = false, J extends boolean = false> extends DispatchedPromise<Collect$1<Res, V, J>> {
	#private;
	constructor(connection: ConnectionController, options: ApiOptions<Req>);
	/**
	 * Configure the query to return the result as a
	 * JSON-compatible structure.
	 *
	 * This is useful when query results need to be serialized. Keep in mind
	 * that your responses will lose SurrealDB type information.
	 */
	json(): ApiPromise<Req, Res, true>;
	/**
	 * Append a header to the api request.
	 *
	 * @param name The name of the header to append.
	 * @param value The value of the header to append.
	 */
	header(name: string, value: string): ApiPromise<Req, Res, J>;
	/**
	 * Append a query parameter to the api request.
	 *
	 * @param name The name of the query parameter to append.
	 * @param value The value of the query parameter to append.
	 * @returns A new ApiPromise instance.
	 */
	query(name: string, value: string): ApiPromise<Req, Res, J>;
	/**
	 * Configure the query to return the response body value
	 * as the result. If the response status is not 200, the promise will reject.
	 */
	value(): ApiPromise<Req, Res, true, J>;
	/**
	 * Compile this qurery into a BoundQuery
	 */
	compile(): BoundQuery<[
		ApiResponse<Res>
	]>;
	/**
	 * Stream the results of the query as they are received.
	 *
	 * @returns An async iterable of query frames.
	 */
	stream(): AsyncIterable<Frame<ApiResponse<Res>, J>>;
	protected dispatch(): Promise<Collect$1<Res, V, J>>;
}
export declare class SurrealError extends Error {
}
/**
 * Thrown when a call has been terminated because the connection was closed
 */
export declare class CallTerminatedError extends SurrealError {
	name: string;
	message: string;
}
/**
 * Thrown when reconnect attempts have been exhausted
 */
export declare class ReconnectExhaustionError extends SurrealError {
	name: string;
	message: string;
}
/**
 * Thrown when a reconnect iterator fails to iterate
 */
export declare class ReconnectIterationError extends SurrealError {
	name: string;
	message: string;
}
/**
 * Thrown when an unexpected server response is received
 */
export declare class UnexpectedServerResponseError extends SurrealError {
	name: string;
	readonly response: unknown;
	constructor(response: unknown);
}
/**
 * Thrown when an unexpected connection error occurs
 */
export declare class UnexpectedConnectionError extends SurrealError {
	name: string;
	message: string;
	constructor(cause: unknown);
}
/**
 * Thrown when an engine is not supported
 */
export declare class UnsupportedEngineError extends SurrealError {
	name: string;
	readonly engine: string;
	constructor(engine: string);
}
/**
 * Thrown when there is no connection available
 */
export declare class ConnectionUnavailableError extends SurrealError {
	name: string;
	message: string;
}
/**
 * Thrown when there is no namespace and/or database selected
 */
export declare class MissingNamespaceDatabaseError extends SurrealError {
	name: string;
	message: string;
}
/**
 * Thrown when a connection to the server fails
 */
export declare class HttpConnectionError extends SurrealError {
	name: string;
	readonly status: number;
	readonly statusText: string;
	readonly buffer: ArrayBuffer;
	constructor(message: string, status: number, statusText: string, buffer: ArrayBuffer);
}
/**
 * Known error kinds returned by the SurrealDB server.
 * Use these constants for matching against `ServerError.kind`.
 */
export declare const ErrorKind: {
	readonly Validation: "Validation";
	readonly Configuration: "Configuration";
	readonly Thrown: "Thrown";
	readonly Query: "Query";
	readonly Serialization: "Serialization";
	readonly NotAllowed: "NotAllowed";
	readonly NotFound: "NotFound";
	readonly AlreadyExists: "AlreadyExists";
	readonly Connection: "Connection";
	readonly Internal: "Internal";
};
/**
 * Union type of all known error kinds. The `kind` property on `ServerError`
 * is typed as `string` (not `ErrorKind`) to allow unknown kinds from newer
 * servers to pass through without loss.
 */
export type ErrorKind = (typeof ErrorKind)[keyof typeof ErrorKind];
export interface ServerErrorOptions {
	kind: string;
	code?: number;
	message: string;
	details?: Record<string, unknown> | null;
	cause?: ServerError | null;
}
/**
 * Base shape for error details on the wire. All detail objects
 * follow the `{ kind, details? }` pattern.
 */
export interface ErrorDetail {
	readonly kind: string;
	readonly details?: Record<string, unknown>;
}
/** Auth failure details, nested inside `NotAllowedErrorDetail`. */
export type AuthErrorDetail = {
	readonly kind: "TokenExpired";
} | {
	readonly kind: "SessionExpired";
} | {
	readonly kind: "InvalidAuth";
} | {
	readonly kind: "UnexpectedAuth";
} | {
	readonly kind: "MissingUserOrPass";
} | {
	readonly kind: "NoSigninTarget";
} | {
	readonly kind: "InvalidPass";
} | {
	readonly kind: "TokenMakingFailed";
} | {
	readonly kind: "InvalidSignup";
} | {
	readonly kind: "InvalidRole";
	readonly details: {
		readonly name: string;
	};
} | {
	readonly kind: "NotAllowed";
	readonly details: {
		readonly actor: string;
		readonly action: string;
		readonly resource: string;
	};
};
/** Validation error details. */
export type ValidationErrorDetail = {
	readonly kind: "Parse";
} | {
	readonly kind: "InvalidRequest";
} | {
	readonly kind: "InvalidParams";
} | {
	readonly kind: "NamespaceEmpty";
} | {
	readonly kind: "DatabaseEmpty";
} | {
	readonly kind: "InvalidParameter";
	readonly details: {
		readonly name: string;
	};
} | {
	readonly kind: "InvalidContent";
	readonly details: {
		readonly value: string;
	};
} | {
	readonly kind: "InvalidMerge";
	readonly details: {
		readonly value: string;
	};
};
/** Configuration error details. */
export type ConfigurationErrorDetail = {
	readonly kind: "LiveQueryNotSupported";
} | {
	readonly kind: "BadLiveQueryConfig";
} | {
	readonly kind: "BadGraphqlConfig";
};
/** Query error details. */
export type QueryErrorDetail = {
	readonly kind: "NotExecuted";
} | {
	readonly kind: "TimedOut";
	readonly details: {
		readonly duration: {
			readonly secs: number;
			readonly nanos: number;
		};
	};
} | {
	readonly kind: "Cancelled";
};
/** Serialization error details. */
export type SerializationErrorDetail = {
	readonly kind: "Serialization";
} | {
	readonly kind: "Deserialization";
};
/** Not-allowed error details. */
export type NotAllowedErrorDetail = {
	readonly kind: "Scripting";
} | {
	readonly kind: "Auth";
	readonly details: AuthErrorDetail;
} | {
	readonly kind: "Method";
	readonly details: {
		readonly name: string;
	};
} | {
	readonly kind: "Function";
	readonly details: {
		readonly name: string;
	};
} | {
	readonly kind: "Target";
	readonly details: {
		readonly name: string;
	};
};
/** Not-found error details. */
export type NotFoundErrorDetail = {
	readonly kind: "Method";
	readonly details: {
		readonly name: string;
	};
} | {
	readonly kind: "Session";
	readonly details: {
		readonly id: string | null;
	};
} | {
	readonly kind: "Table";
	readonly details: {
		readonly name: string;
	};
} | {
	readonly kind: "Record";
	readonly details: {
		readonly id: string;
	};
} | {
	readonly kind: "Namespace";
	readonly details: {
		readonly name: string;
	};
} | {
	readonly kind: "Database";
	readonly details: {
		readonly name: string;
	};
} | {
	readonly kind: "Transaction";
};
/** Already-exists error details. */
export type AlreadyExistsErrorDetail = {
	readonly kind: "Session";
	readonly details: {
		readonly id: string;
	};
} | {
	readonly kind: "Table";
	readonly details: {
		readonly name: string;
	};
} | {
	readonly kind: "Record";
	readonly details: {
		readonly id: string;
	};
} | {
	readonly kind: "Namespace";
	readonly details: {
		readonly name: string;
	};
} | {
	readonly kind: "Database";
	readonly details: {
		readonly name: string;
	};
};
/** Connection error details. */
export type ConnectionErrorDetail = {
	readonly kind: "Uninitialised";
} | {
	readonly kind: "AlreadyConnected";
};
/**
 * Base class for all errors originating from the SurrealDB server.
 * Replaces the former `ResponseError` class.
 *
 * Server errors carry structured information:
 * - `kind` — the error category (e.g. `"NotAllowed"`, `"NotFound"`)
 * - `code` — legacy JSON-RPC numeric error code (0 when unavailable)
 * - `details` — kind-specific structured details from the server (`{ kind, details? }` format)
 * - `cause` — optional inner `ServerError` forming a recursive error chain
 *
 * The `cause` field mirrors Rust's `Option<Box<Error>>` — each error can
 * optionally wrap an inner error, creating a stack of structured errors.
 * It is set as the native `Error.cause` so that standard JS tooling
 * (Node.js, Chrome DevTools, debuggers) displays the full chain
 * automatically using the `[cause]:` format.
 *
 * Use `instanceof` on subclasses (e.g. `NotFoundError`, `NotAllowedError`)
 * for type-safe matching, or check the `kind` property directly.
 */
export declare class ServerError extends SurrealError {
	get name(): string;
	/** The structured error kind (e.g. "NotAllowed", "NotFound", "Internal") */
	readonly kind: string;
	/** Legacy JSON-RPC error code. 0 when not available (e.g. query result errors). */
	readonly code: number;
	/**
	 * Kind-specific structured details using the `{ kind, details? }` wire format.
	 * `undefined` when not provided by the server. Subclasses narrow this type
	 * to their specific detail union (e.g. `NotAllowedErrorDetail`).
	 */
	readonly details: ErrorDetail | undefined;
	/**
	 * The inner server error that caused this one, if any.
	 * Forms a recursive chain matching Rust's `cause: Option<Box<Error>>`.
	 * Set as the native `Error.cause` for standard JS error chaining.
	 */
	readonly cause: ServerError | undefined;
	constructor(options: ServerErrorOptions);
}
/**
 * Server error: validation failure (parse error, invalid request/params, bad input).
 */
export declare class ValidationError extends ServerError {
	readonly kind: "Validation";
	readonly details: ValidationErrorDetail | undefined;
	get name(): string;
	/** True if this is a SurrealQL parse error. */
	get isParseError(): boolean;
	/** The name of the invalid parameter, if applicable. */
	get parameterName(): string | undefined;
}
/**
 * Server error: feature or configuration not supported (live queries, GraphQL).
 */
export declare class ConfigurationError extends ServerError {
	readonly kind: "Configuration";
	readonly details: ConfigurationErrorDetail | undefined;
	get name(): string;
	/** True if live queries are not supported by the server configuration. */
	get isLiveQueryNotSupported(): boolean;
}
/**
 * Server error: user-thrown error via THROW in SurrealQL.
 */
export declare class ThrownError extends ServerError {
	readonly kind: "Thrown";
	get name(): string;
}
/**
 * Server error: query execution failure (timeout, cancelled, not executed).
 */
export declare class QueryError extends ServerError {
	readonly kind: "Query";
	readonly details: QueryErrorDetail | undefined;
	get name(): string;
	/** True if the query was not executed (e.g. due to a prior error in the batch). */
	get isNotExecuted(): boolean;
	/** True if the query timed out. */
	get isTimedOut(): boolean;
	/** True if the query was cancelled. */
	get isCancelled(): boolean;
	/** The timeout duration, if this is a timeout error. Returns `{ secs, nanos }` or undefined. */
	get timeout(): {
		secs: number;
		nanos: number;
	} | undefined;
}
/**
 * Server error: serialization or deserialization failure.
 */
export declare class SerializationError extends ServerError {
	readonly kind: "Serialization";
	readonly details: SerializationErrorDetail | undefined;
	get name(): string;
	/** True if this is a deserialization error (as opposed to serialization). */
	get isDeserialization(): boolean;
}
/**
 * Server error: permission denied, method not allowed, function/scripting blocked.
 */
export declare class NotAllowedError extends ServerError {
	readonly kind: "NotAllowed";
	readonly details: NotAllowedErrorDetail | undefined;
	get name(): string;
	/** True if the auth token has expired. */
	get isTokenExpired(): boolean;
	/** True if authentication credentials are invalid. */
	get isInvalidAuth(): boolean;
	/** True if scripting is blocked. */
	get isScriptingBlocked(): boolean;
	/** The method name that is not allowed, if applicable. */
	get methodName(): string | undefined;
	/** The function name that is not allowed, if applicable. */
	get functionName(): string | undefined;
}
/**
 * Server error: resource not found (table, record, namespace, method, etc.).
 */
export declare class NotFoundError extends ServerError {
	readonly kind: "NotFound";
	readonly details: NotFoundErrorDetail | undefined;
	get name(): string;
	/** The table name that was not found, if applicable. */
	get tableName(): string | undefined;
	/** The record ID that was not found, if applicable. */
	get recordId(): string | undefined;
	/** The RPC method name that was not found, if applicable. */
	get methodName(): string | undefined;
	/** The namespace name that was not found, if applicable. */
	get namespaceName(): string | undefined;
	/** The database name that was not found, if applicable. */
	get databaseName(): string | undefined;
}
/**
 * Server error: duplicate resource (record, table, namespace, etc.).
 */
export declare class AlreadyExistsError extends ServerError {
	readonly kind: "AlreadyExists";
	readonly details: AlreadyExistsErrorDetail | undefined;
	get name(): string;
	/** The record ID that already exists, if applicable. */
	get recordId(): string | undefined;
	/** The table name that already exists, if applicable. */
	get tableName(): string | undefined;
}
/**
 * Server error: unexpected or unknown internal error.
 * Also used as the fallback for unrecognized `kind` strings from newer servers.
 */
export declare class InternalError extends ServerError {
	readonly kind: "Internal";
	get name(): string;
}
/**
 * @deprecated Use `ServerError` instead. This alias exists for backward compatibility.
 */
export declare const ResponseError: typeof ServerError;
/**
 * Thrown when authentication fails
 */
export declare class AuthenticationError extends SurrealError {
	name: string;
	message: string;
	constructor(cause: unknown);
}
/**
 * Thrown when a live subscription fails to listen
 */
export declare class LiveSubscriptionError extends SurrealError {
	name: string;
	constructor(messageOrCause?: string | unknown);
}
/**
 * Thrown when the version of the remote datastore is not supported
 */
export declare class UnsupportedVersionError extends SurrealError {
	name: string;
	readonly version: string;
	readonly minimum: string;
	readonly maximum: string;
	constructor(version: string, minimum: string, maximum: string);
}
/**
 * Thrown when a SurrealQL expression fails to compute
 */
export declare class ExpressionError extends SurrealError {
	name: string;
	constructor(messageOrCause?: string | unknown);
}
/**
 * Thrown when one or more subscribers throw an error
 */
export declare class PublishError extends SurrealError {
	#private;
	name: string;
	message: string;
	readonly causes: unknown[];
	constructor(causes: unknown[]);
}
/**
 * Thrown when a parsed date or datetime is invalid
 */
export declare class InvalidDateError extends SurrealError {
	name: string;
	constructor(dateOrMessage: Date | string);
}
/**
 * Thrown when a feature is not supported by the current engine
 */
export declare class UnsupportedFeatureError extends SurrealError {
	name: string;
	readonly feature: Feature;
	constructor(feature: Feature);
}
/**
 * Thrown when a feature is not available in the used version of SurrealDB
 */
export declare class UnavailableFeatureError extends SurrealError {
	name: string;
	readonly feature: Feature;
	readonly version: string;
	constructor(feature: Feature, version: string);
}
/**
 * Thrown when a session is invalid
 */
export declare class InvalidSessionError extends SurrealError {
	name: string;
	message: string;
	readonly session: Session;
	constructor(session: Session);
}
/**
 * Thrown when an API request was unsuccessful
 */
export declare class UnsuccessfulApiError extends SurrealError {
	name: string;
	readonly path: string;
	readonly method: string;
	readonly response: ApiResponse<unknown>;
	constructor(path: string, method: string, response: ApiResponse<unknown>);
}
/**
 * Thrown when a RecordId or RecordIdRange is constructed with invalid parts
 */
export declare class InvalidRecordIdError extends SurrealError {
	name: string;
}
/**
 * Thrown when a Duration string cannot be parsed or a duration operation is invalid
 */
export declare class InvalidDurationError extends SurrealError {
	name: string;
}
/**
 * Thrown when a Decimal operation fails (division by zero, invalid input, etc.)
 */
export declare class InvalidDecimalError extends SurrealError {
	name: string;
}
/**
 * Thrown when a Table or StringRecordId is constructed with an invalid value
 */
export declare class InvalidTableError extends SurrealError {
	name: string;
}
declare class ReconnectContext {
	#private;
	readonly options: ReconnectOptions;
	constructor(input: undefined | Partial<ReconnectOptions> | boolean);
	get attempts(): number;
	get enabled(): boolean;
	get allowed(): boolean;
	reset(): void;
	propagate(error: Error): void;
	iterate(): Promise<void>;
}
export type Version = `${number}.${number}.${number}`;
export type Values<T> = Partial<T> & Record<string, unknown>;
export type Output = "none" | "null" | "diff" | "before" | "after";
export type Mutation = "content" | "merge" | "replace" | "patch";
export type Nullable<T> = {
	[K in keyof T]: T[K] | null;
};
export type AnyRecordId<Tb extends string = string, Id extends RecordIdValue = RecordIdValue> = _RecordId<Tb, Id> | StringRecordId;
export declare const LIVE_ACTIONS: readonly [
	"CREATE",
	"UPDATE",
	"DELETE",
	"KILLED"
];
export type LiveResource = Table;
export type LiveAction = (typeof LIVE_ACTIONS)[number];
export type LiveMessage = {
	queryId: Uuid;
	action: LiveAction;
	recordId: _RecordId;
	value: Record<string, unknown>;
};
export type Session = Uuid | undefined;
export type CodecType = "cbor" | "flatbuffer" | (string & {});
export type QueryResponseKind = "single" | "batched" | "batched-final";
export type ConnectionStatus = "disconnected" | "connecting" | "reconnecting" | "connected";
export type EngineFactory = (context: DriverContext) => SurrealEngine;
export type Engines = Record<string, EngineFactory>;
export type CodecFactory = (options: CodecOptions) => ValueCodec;
export type Codecs = Partial<Record<CodecType, CodecFactory>>;
export type CodecRegistry = Record<CodecType, ValueCodec>;
export type DataStream = string | ReadableStream;
export type QueryType = "live" | "kill" | "other";
/**
 * The communication contract between the SDK and a SurrealDB datastore.
 *
 * @see https://github.com/surrealdb/surrealdb-protocol
 */
export interface SurrealProtocol {
	health(): Promise<void>;
	version(): Promise<VersionInfo>;
	sessions(): Promise<Uuid[]>;
	attach(session: Uuid): Promise<void>;
	detach(session: Uuid): Promise<void>;
	use(what: Nullable<NamespaceDatabase>, session: Session): Promise<NamespaceDatabase>;
	signup(auth: AccessRecordAuth, session: Session): Promise<Tokens>;
	signin(auth: AnyAuth, session: Session): Promise<Tokens>;
	authenticate(token: Token, session: Session): Promise<void>;
	set(name: string, value: unknown, session: Session): Promise<void>;
	unset(name: string, session: Session): Promise<void>;
	refresh(tokens: Tokens, session: Session): Promise<Tokens>;
	revoke(tokens: Tokens, session: Session): Promise<void>;
	invalidate(session: Session): Promise<void>;
	reset(session: Session): Promise<void>;
	begin(session: Session): Promise<Uuid>;
	commit(txn: Uuid, session: Session): Promise<void>;
	cancel(txn: Uuid, session: Session): Promise<void>;
	importSql(data: string | Blob | ReadableStream): Promise<void>;
	exportSql(options: Partial<SqlExportOptions>): Promise<Response | string>;
	exportMlModel(options: MlExportOptions): Promise<Response | Uint8Array>;
	query<T>(query: BoundQuery, session: Session, txn?: Uuid): AsyncIterable<QueryChunk<T>>;
	liveQuery(id: Uuid): AsyncIterable<LiveMessage>;
}
/**
 * An engine responsible for communicating to a SurrealDB datastore
 */
export interface SurrealEngine extends SurrealProtocol, EventPublisher<EngineEvents> {
	features: Set<Feature>;
	open(state: ConnectionState): void;
	close(): Promise<void>;
	ready(): void;
}
/**
 * The events emitted by a SurrealDB engine
 */
export type EngineEvents = {
	connected: [
	];
	reconnecting: [
	];
	disconnected: [
	];
	error: [
		Error
	];
};
/**
 * Options used to configure behavior of the SurrealDB driver
 */
export interface DriverOptions {
	engines?: Engines;
	codecs?: Codecs;
	codecOptions?: CodecOptions;
	websocketImpl?: typeof WebSocket;
	fetchImpl?: typeof fetch;
}
/**
 * Options used to customize a specific connection to a SurrealDB datastore
 */
export interface ConnectOptions {
	/**
	 * The namespace to use for this connection.
	 */
	namespace?: string;
	/**
	 * The database to use for this connection.
	 */
	database?: string;
	/**
	 * Authentication details to use when connecting as a system user or with a token. You can provide a static value,
	 * or a function which is called to compute the authentication details. Unlike when using the `.signin()` method,
	 * the provided authentication details may be used for all sessions and will be reused when a session expires.
	 *
	 * When a callback is specified returning a Promise, the SDK will wait with signaling the connection as connected
	 * until the Promise is resolved.
	 *
	 * When `.signin()`, `.signup()`, or `.authenticate()` is used this property will be ignored for the duration of the session.
	 */
	authentication?: AuthProvider;
	/**
	 * Automatically check for version compatibility on connect. When the version is not supported,
	 * an error will be thrown and the connection will not be established.
	 *
	 * @default true
	 */
	versionCheck?: boolean;
	/**
	 * Automatically invalidate sessions when the access token expires.
	 *
	 * When set to `false` (the default), the driver will attempt to renew the session through a
	 * series of steps:
	 *
	 * 1. Attempt to reuse the previous access token
	 * 2. Attempt to issue a new access token using the refresh token
	 * 3. Attempt to invoke the authentication provider
	 *
	 * If none of these steps succeed, the session will be invalidated regardless.
	 *
	 * @default false
	 */
	invalidateOnExpiry?: boolean;
	/**
	 * Configure reconnect behavior for supported engines (WebSocket).
	 *
	 * - When set to `false`, the driver will remain disconnected after a connection is lost.
	 * - When set to `true`, the driver will attempt to reconnect using default options.
	 * - When set to an object, the driver will attempt to reconnect using the provided options.
	 *
	 * @default true
	 */
	reconnect?: boolean | Partial<ReconnectOptions>;
}
/**
 * Options to configure reconnect behavior
 */
export interface ReconnectOptions {
	/** Reconnect after a connection has unexpectedly dropped */
	enabled: boolean;
	/** How many attempts will be made at reconnecting, -1 for unlimited */
	attempts: number;
	/** The minimum amount of time in milliseconds to wait before reconnecting */
	retryDelay: number;
	/** The maximum amount of time in milliseconds to wait before reconnecting */
	retryDelayMax: number;
	/** The amount to multiply the delay by after each failed attempt */
	retryDelayMultiplier: number;
	/** A float percentage to randomly offset each delay by  */
	retryDelayJitter: number;
	/** Handle errors caught during reconnecting */
	catch?: (error: Error) => boolean;
}
export interface ConnectionSession {
	id: Session;
	namespace: string | undefined;
	database: string | undefined;
	accessToken: string | undefined;
	refreshToken: string | undefined;
	variables: Record<string, unknown>;
	authRenewal: ReturnType<typeof setTimeout> | undefined;
	authOverriden: boolean;
}
/**
 * The current state of a connection to a SurrealDB datastore
 */
export interface ConnectionState {
	url: URL;
	reconnect: ReconnectContext;
	rootSession: ConnectionSession;
	sessions: Map<Uuid, ConnectionSession>;
}
/**
 * Options used to configure the value codec
 */
export interface CodecOptions {
	/** Use native `Date` objects instead of custom `DateTime` objects. Using `Date` objects will result in a loss of nanosecond precision. */
	useNativeDates?: boolean;
	/** Specify a custom visitor function to process encode values. */
	valueEncodeVisitor?: (value: unknown) => unknown;
	/** Specify a custom visitor function to process decode values. */
	valueDecodeVisitor?: (value: unknown) => unknown;
}
/**
 * A codec for encoding and decoding SurrealQL values
 */
export interface ValueCodec {
	encode: <T>(data: T) => Uint8Array;
	decode: <T>(data: Uint8Array) => T;
}
/**
 * Context information passed to each controller and engine
 */
export interface DriverContext {
	options: DriverOptions;
	uniqueId: () => string;
	codecs: CodecRegistry;
}
/**
 * Represents a record response
 */
export type RecordResult<T> = Prettify<T extends object ? T extends {
	id: infer Id;
} ? Id extends _RecordId ? T : Id extends RecordIdValue ? {
	id: _RecordId<string, Id>;
} & Omit<T, "id"> : {
	id: _RecordId;
} & Omit<T, "id"> : {
	id: _RecordId;
} & T : {
	id: _RecordId;
}>;
/**
 * SurrealDB version information
 */
export interface VersionInfo {
	version: string;
}
/**
 * A combination of namespace and database
 */
export interface NamespaceDatabase {
	namespace?: string;
	database?: string;
}
/**
 * SurrealQL exporting options
 */
export interface SqlExportOptions {
	users: boolean;
	accesses: boolean;
	params: boolean;
	functions: boolean;
	analyzers: boolean;
	tables: boolean | string[];
	versions: boolean;
	records: boolean;
	sequences: boolean;
	v3: boolean;
}
/**
 * SurrealML model exporting options
 */
export interface MlExportOptions {
	name: string;
	version: string;
}
/**
 * Query statistics
 */
export interface QueryStats {
	recordsReceived: number;
	bytesReceived: number;
	recordsScanned: number;
	bytesScanned: number;
	duration: Duration;
}
/**
 * A single chunk returned from a query stream
 */
export interface QueryChunk<T> {
	query: number;
	batch: number;
	kind: QueryResponseKind;
	stats?: QueryStats;
	result?: T[];
	type?: QueryType;
	error?: ServerError;
}
/**
 * A single successful response from a query
 */
export type QueryResponseSuccess<T = unknown> = {
	success: true;
	stats?: QueryStats;
	type: "live" | "kill" | "other";
	result: T;
};
/**
 * A single failure response from a query
 */
export type QueryResponseFailure = {
	success: false;
	stats?: QueryStats;
	error: ServerError;
};
/**
 * A single response from a query
 */
export type QueryResponse<T = unknown> = QueryResponseSuccess<T> | QueryResponseFailure;
export type RootAuth = {
	username: string;
	password: string;
};
export type NamespaceAuth = {
	namespace: string;
	username: string;
	password: string;
};
export type DatabaseAuth = {
	namespace: string;
	database: string;
	username: string;
	password: string;
};
export type AccessSystemAuth = {
	namespace?: string;
	database?: string;
	username: string;
	password: string;
	access: string;
};
export type AccessBearerAuth = {
	namespace?: string;
	database?: string;
	access: string;
	key: string;
};
export type AccessRecordAuth = {
	namespace?: string;
	database?: string;
	access: string;
	variables: {
		ns?: never;
		db?: never;
		ac?: never;
		[K: string]: unknown;
	};
};
export type SystemAuth = RootAuth | NamespaceAuth | DatabaseAuth;
export type AccessAuth = AccessSystemAuth | AccessBearerAuth | AccessRecordAuth;
export type AnyAuth = SystemAuth | AccessAuth;
export type Token = string;
export type AuthOrToken = AnyAuth | Token;
export type ProvidedAuth = SystemAuth | Token | null;
export type AuthCallable = (session: Session) => ProvidedAuth | Promise<ProvidedAuth>;
export type AuthProvider = ProvidedAuth | AuthCallable;
export type Tokens = {
	access: Token;
	refresh?: Token;
};
type AuthVariant = "system_user" | "token" | "record_access" | "bearer_access";
type SessionInfo = {
	session: Session;
};
type OpenInfo = {
	url: URL;
};
type AuthInfo = {
	variant: AuthVariant;
};
type UseInfo = {
	requested: Nullable<NamespaceDatabase>;
};
type SetInfo = {
	name: string;
	value: unknown;
};
type UnsetInfo = {
	name: string;
};
type LiveQueryInfo = {
	id: Uuid;
	message?: LiveMessage;
};
type TransactionInfo = {
	txn: Uuid;
};
type QueryInfo = {
	query: string;
	params: Record<string, unknown>;
	transaction?: Uuid;
	chunk?: QueryChunk<unknown>;
};
type DiagnosticMap = {
	query: QueryInfo & SessionInfo;
	liveQuery: LiveQueryInfo;
	version: VersionInfo;
	signup: AuthInfo & SessionInfo;
	signin: AuthInfo & SessionInfo;
	authenticate: AuthInfo & SessionInfo;
	open: OpenInfo;
	close: undefined;
	health: undefined;
	use: UseInfo & SessionInfo;
	set: SetInfo & SessionInfo;
	unset: UnsetInfo & SessionInfo;
	refresh: SessionInfo;
	revoke: SessionInfo;
	invalidate: SessionInfo;
	reset: SessionInfo;
	begin: SessionInfo;
	commit: TransactionInfo & SessionInfo;
	cancel: TransactionInfo & SessionInfo;
	sessions: Uuid[];
	attach: undefined;
	detach: undefined;
	importSql: undefined;
	exportSql: undefined;
	exportMlModel: undefined;
};
export type DiagnosticKey = keyof DiagnosticMap;
export type DiagnosticResult<T extends DiagnosticKey> = DiagnosticMap[T];
export type DiagnosticEvent<T extends DiagnosticKey> = {
	type: T;
	key: Uuid;
	phase: "before";
} | {
	type: T;
	key: Uuid;
	phase: "progress";
	result: DiagnosticResult<T>;
} | {
	type: T;
	key: Uuid;
	phase: "after";
	duration: Duration;
	success: false;
	error: Error;
} | {
	type: T;
	key: Uuid;
	phase: "after";
	duration: Duration;
	success: true;
	result: DiagnosticResult<T>;
};
export type Diagnostic = {
	[K in keyof DiagnosticMap]: DiagnosticEvent<K>;
}[keyof DiagnosticMap];
/**
 * The context for building SurrealQL expressions
 */
export interface ExprCtx {
	def: (value: unknown) => string;
}
/**
 * Represents a single SurrealQL expression
 */
export interface Expr {
	toSQL(ctx: ExprCtx): string;
}
/**
 * Any value which may represent an expression
 */
export type ExprLike = Expr | null | undefined | false;
type BasePatch<T = string> = {
	path: T;
};
export type AddPatch<T = string, U = unknown> = BasePatch<T> & {
	op: "add";
	value: U;
};
export type RemovePatch<T = string> = BasePatch<T> & {
	op: "remove";
};
export type ReplacePatch<T = string, U = unknown> = BasePatch<T> & {
	op: "replace";
	value: U;
};
export type ChangePatch<T = string, U = string> = BasePatch<T> & {
	op: "change";
	value: U;
};
export type CopyPatch<T = string, U = string> = BasePatch<T> & {
	op: "copy";
	from: U;
};
export type MovePatch<T = string, U = string> = BasePatch<T> & {
	op: "move";
	from: U;
};
export type TestPatch<T = string, U = unknown> = BasePatch<T> & {
	op: "test";
	value: U;
};
export type Patch = AddPatch | RemovePatch | ReplacePatch | ChangePatch | CopyPatch | MovePatch | TestPatch;
/**
 * Recursive cause shape on the wire. Mirrors Rust's `cause: Option<Box<Error>>`.
 */
export interface RpcErrorCause {
	kind?: string;
	message: string;
	details?: Record<string, unknown> | null;
	cause?: RpcErrorCause | null;
}
/**
 * Raw error object shape from the server (RPC-level errors).
 */
export interface RpcErrorObject {
	code: number;
	message: string;
	kind?: string;
	details?: Record<string, unknown> | null;
	cause?: RpcErrorCause | null;
}
/**
 * Parse an RPC-level error object into a `ServerError` (or subclass).
 * Handles both old format (`{ code, message }`) and new format
 * (`{ code, kind, message, details? }`).
 */
export declare function parseRpcError(raw: RpcErrorObject): ServerError;
export type RpcQueryResult<T = unknown> = RpcQueryResultOk<T> | RpcQueryResultErr;
export type RpcQueryResultOk<T> = {
	status: "OK";
	time: string;
	result: T;
	type: QueryType;
};
export type RpcQueryResultErr = {
	status: "ERR";
	time: string;
	result: string;
	kind?: string;
	details?: Record<string, unknown> | null;
};
export type RpcRequest<Method extends string = string, Params extends unknown[] | undefined = unknown[]> = {
	method: Method;
	session?: Session;
	params?: Params;
	txn?: Uuid;
};
export type RpcResponse<Result = unknown> = RpcSuccessResponse<Result> | RpcErrorResponse;
export type RpcSuccessResponse<Result = unknown> = {
	result: Result;
	error?: never;
};
export type RpcErrorResponse = {
	result?: never;
	error: RpcErrorObject;
};
type ConnectionEvents = {
	connecting: [
	];
	connected: [
		string
	];
	disconnected: [
	];
	reconnecting: [
	];
	error: [
		Error
	];
	auth: [
		Tokens | null,
		Session
	];
	using: [
		NamespaceDatabase,
		Session
	];
};
declare class ConnectionController implements SurrealProtocol, EventPublisher<ConnectionEvents> {
	#private;
	subscribe<K extends keyof ConnectionEvents>(event: K, listener: (...payload: ConnectionEvents[K]) => void): () => void;
	constructor(context: DriverContext);
	get state(): ConnectionState | undefined;
	get status(): ConnectionStatus;
	propagateError(error: Error): void;
	connect(url: URL, options: ConnectOptions): Promise<true>;
	disconnect(): Promise<true>;
	ready(): Promise<void>;
	assertFeature(feature: Feature): void;
	health(): Promise<void>;
	version(): Promise<VersionInfo>;
	sessions(): Promise<Uuid[]>;
	attach(session: Uuid): Promise<void>;
	detach(session: Uuid): Promise<void>;
	signup(auth: AccessRecordAuth, session: Session, skipOverride?: boolean): Promise<Tokens>;
	signin(auth: AnyAuth, session: Session, skipOverride?: boolean): Promise<Tokens>;
	authenticate(token: Token, session: Session, skipOverride?: boolean): Promise<void>;
	refresh(tokens: Tokens, session: Session, skipOverride?: boolean): Promise<Tokens>;
	revoke(tokens: Tokens, session: Session): Promise<void>;
	use(what: Nullable<NamespaceDatabase>, session: Session): Promise<NamespaceDatabase>;
	set(name: string, value: unknown, session: Session): Promise<void>;
	unset(name: string, session: Session): Promise<void>;
	invalidate(session: Session): Promise<void>;
	reset(session: Session): Promise<void>;
	begin(session: Session): Promise<Uuid>;
	commit(txn: Uuid, session: Session): Promise<void>;
	cancel(txn: Uuid, session: Session): Promise<void>;
	importSql(data: string | Blob | ReadableStream): Promise<void>;
	exportSql(options: Partial<SqlExportOptions>): Promise<Response | string>;
	exportMlModel(options: MlExportOptions): Promise<Response | Uint8Array>;
	query<T>(query: BoundQuery, session: Session, txn?: Uuid): AsyncIterable<QueryChunk<T>>;
	liveQuery(id: Uuid): AsyncIterable<LiveMessage>;
	hasSession(session: Session): boolean;
	getSession(session: Session): ConnectionSession;
	createSession(clone: Session | null): Promise<Session>;
	destroySession(session: Session): Promise<void>;
}
/**
 * The request information for an api request.
 */
export interface ApiRequest<T> {
	body?: T;
	method?: string;
	headers?: Record<string, string>;
	query?: Record<string, string>;
}
type HttpMethod = "get" | "post" | "put" | "delete" | "patch" | "trace";
type MethodDef = [
	unknown,
	unknown
] | [
];
type ValidPaths<TPaths, M extends HttpMethod> = {
	[K in Extract<keyof TPaths, string>]: M extends keyof TPaths[K] ? K : never;
}[Extract<keyof TPaths, string>];
/** A definition for a single API path */
export type PathDef = Partial<Record<HttpMethod, MethodDef>>;
/** Default paths type - allows any string with unknown bodies */
export type DefaultPaths = {
	[path: string]: PathDef;
};
type ExtractMethod<TPaths, P extends string, M extends HttpMethod> = P extends keyof TPaths ? M extends keyof TPaths[P] ? TPaths[P][M] : never : never;
type RequestBody<TPaths, P extends string, M extends HttpMethod> = ExtractMethod<TPaths, P, M> extends [
	infer Req,
	unknown
] ? Req : unknown;
type ResponseBody<TPaths, P extends string, M extends HttpMethod> = ExtractMethod<TPaths, P, M> extends [
	unknown,
	infer Res
] ? Res : unknown;
/**
 * Exposes a set of methods to interact with user defined APIs.
 *
 * @example
 * ```ts
 * type MyPaths = {
 *     "/users": { get: [void, User[]] };
 *     "/projects": { get: [void, Project[]] };
 *     [K: `/users/${number}`]: { get: [void, User] };
 * };
 *
 * const api = db.api<MyPaths>();
 * api.get("/users");  // Returns ApiPromise<void, User[]>
 * ```
 */
export declare class SurrealApi<TPaths = DefaultPaths> {
	#private;
	constructor(connection: ConnectionController, session: Session, transaction?: Uuid, prefix?: string);
	/**
	 * Configure a header for all requests sent by this API instance.
	 *
	 * This is useful for setting a common header for all requests sent by this API instance.
	 *
	 * @param name The name of the header to configure.
	 * @param value The value of the header to configure, or null to remove the header.
	 */
	header(name: string, value: string | null): void;
	/**
	 * Invoke a user defined API initialized with a request object.
	 *
	 * Prefer the method specific functions for a more type-safe experience.
	 *
	 * @param path The path of the API to invoke.
	 * @param request The request to send to the API.
	 * @returns The response from the API.
	 */
	invoke<Req = unknown, Res = unknown>(path: string, request?: ApiRequest<Req>): ApiPromise<Req, Res>;
	/**
	 * Invoke a user defined GET API.
	 *
	 * @param path The path of the API to invoke.
	 * @returns The response from the API.
	 */
	get<P extends ValidPaths<TPaths, "get">>(path: P): ApiPromise<void, ResponseBody<TPaths, P, "get">>;
	/**
	 * Invoke a user defined POST API.
	 *
	 * @param path The path of the API to invoke.
	 * @param body The request body to send to the API.
	 * @returns The response from the API.
	 */
	post<P extends ValidPaths<TPaths, "post">>(path: P, body?: RequestBody<TPaths, P, "post">): ApiPromise<RequestBody<TPaths, P, "post">, ResponseBody<TPaths, P, "post">>;
	/**
	 * Invoke a user defined PUT API.
	 *
	 * @param path The path of the API to invoke.
	 * @param body The request body to send to the API.
	 * @returns The response from the API.
	 */
	put<P extends ValidPaths<TPaths, "put">>(path: P, body?: RequestBody<TPaths, P, "put">): ApiPromise<RequestBody<TPaths, P, "put">, ResponseBody<TPaths, P, "put">>;
	/**
	 * Invoke a user defined DELETE API.
	 *
	 * @param path The path of the API to invoke.
	 * @param body The request body to send to the API.
	 * @returns The response from the API.
	 */
	delete<P extends ValidPaths<TPaths, "delete">>(path: P, body?: RequestBody<TPaths, P, "delete">): ApiPromise<RequestBody<TPaths, P, "delete">, ResponseBody<TPaths, P, "delete">>;
	/**
	 * Invoke a user defined PATCH API.
	 *
	 * @param path The path of the API to invoke.
	 * @param body The request body to send to the API.
	 * @returns The response from the API.
	 */
	patch<P extends ValidPaths<TPaths, "patch">>(path: P, body?: RequestBody<TPaths, P, "patch">): ApiPromise<RequestBody<TPaths, P, "patch">, ResponseBody<TPaths, P, "patch">>;
	/**
	 * Invoke a user defined TRACE API.
	 *
	 * @param path The path of the API to invoke.
	 * @param body The request body to send to the API.
	 * @returns The response from the API.
	 */
	trace<P extends ValidPaths<TPaths, "trace">>(path: P, body?: RequestBody<TPaths, P, "trace">): ApiPromise<RequestBody<TPaths, P, "trace">, ResponseBody<TPaths, P, "trace">>;
}
type ExportResult<T, R extends boolean> = R extends true ? Response : T;
/**
 * A configurable `Promise` for export operations.
 */
export declare class ExportPromise<R extends boolean = false> extends DispatchedPromise<ExportResult<string, R>> {
	#private;
	constructor(connection: ConnectionController, options: Partial<SqlExportOptions>, raw: boolean);
	/**
	 * Configure the export to return the raw `Response` instead of
	 * a SurrealQL string. This is useful when you may receive a
	 * large amount of data and need to handle the response stream
	 * directly.
	 */
	raw(): ExportPromise<true>;
	protected dispatch(): Promise<ExportResult<string, R>>;
}
/**
 * A configurable `Promise` for model export operations.
 */
export declare class ExportModelPromise<R extends boolean = false> extends DispatchedPromise<ExportResult<Uint8Array, R>> {
	#private;
	constructor(connection: ConnectionController, options: MlExportOptions, raw: boolean);
	/**
	 * Configure the export to return the raw `Response` instead of
	 * a `Uint8Array`. This is useful when you may receive a large
	 * amount of data and need to handle the response stream directly.
	 */
	raw(): ExportModelPromise<true>;
	protected dispatch(): Promise<ExportResult<Uint8Array, R>>;
}
/**
 * Represents a scope capable of executing SurrealDB queries.
 */
export declare abstract class SurrealQueryable {
	#private;
	constructor(connection: ConnectionController, session: Session, transaction?: Uuid);
	/**
	 * Access user defined APIs defined on the database.
	 *
	 * Path types can be passed to this method in order to
	 * provide type safety when invoking APIs.
	 *
	 * An optional prefix can be provided to prepend to API paths.
	 *
	 * @example
	 * ```ts
	 * type MyPaths = {
	 *     "/users": { get: [void, User[]] };
	 *     [K: `/users/${number}`]: { get: [void, User] };
	 * };
	 *
	 * // Type-safe path and response
	 * const api = db.api<MyPaths>();
	 * api.get("/users"); // User[]
	 *
	 * // Prefix to invoke GET /users/:id
	 * const usersApi = db.api<MyPaths>("/users");
	 * api.get(userId); // User
	 * ```
	 *
	 * @param prefix An optional path prefix to prepend to API paths.
	 * @returns A new `SurrealApi` instance.
	 */
	api<TPaths = DefaultPaths>(prefix?: string): SurrealApi<TPaths>;
	/**
	 * Runs a set of SurrealQL statements against the database.
	 *
	 * The resulting `Query` instance can be awaited to execute the query, however you will
	 * need to use the `.collect()` or `.stream()` methods to process result values.
	 *
	 * @param query Specifies the SurrealQL statements
	 * @param bindings Assigns variables which can be used in the query
	 * @returns A `Query` instance which can be used to execute or configure the query
	 */
	query<R extends unknown[] = unknown[]>(query: string, bindings?: Record<string, unknown>): Query<R>;
	/**
	 * Runs a set of SurrealQL statements against the database.
	 *
	 * The resulting `Query` instance can be awaited to execute the query, however you will
	 * need to use the `.collect()` or `.stream()` methods to process result values.
	 *
	 * @param query The BoundQuery instance
	 * @returns A `Query` instance which can be used to execute or configure the query
	 */
	query<R extends unknown[] = unknown[]>(query: BoundQuery<R>): Query<R>;
	/**
	 * Returns the record representing the currently authenticated record user by
	 * selecting the [$auth parameter](https://surrealdb.com/docs/surrealql/parameters#auth).
	 *
	 * Make sure the user actually has the permission to select their own record, otherwise you'll get back an empty result
	 *
	 * @return The record linked to the record ID used for authentication
	 */
	auth<T>(): AuthPromise<RecordResult<T> | undefined>;
	/**
	 * Create a new live subscription to a specific table, record id, or record id range
	 *
	 * @param what The table to subscribe to
	 * @returns A new live subscription object
	 */
	live<T>(what: LiveResource): ManagedLivePromise<T>;
	/**
	 * Manually subscribe to an existing live subscription using the provided ID
	 *
	 * **NOTE:** This function is for use with live select queries that are not managed by the driver.
	 *
	 * @param id The ID of the live subscription to subscribe to
	 * @returns A new unmanaged live subscription object
	 */
	liveOf(id: Uuid): UnmanagedLivePromise;
	/**
	 * Select the contents of a specific record based on the provied Record ID
	 *
	 * @param recordId The record ID to select
	 */
	select<T>(recordId: AnyRecordId): SelectPromise<RecordResult<T> | undefined, T>;
	/**
	 * Select all records based on the provided Record ID range
	 *
	 * @param range The range of record IDs to select
	 */
	select<T>(range: _RecordIdRange): SelectPromise<RecordResult<T>[], T>;
	/**
	 * Select all records present in the specified table
	 *
	 * @param recordId The record ID to select
	 */
	select<T>(table: Table): SelectPromise<RecordResult<T>[], T>;
	/**
	 * Create a new record in the database
	 *
	 * @param recordId The record id of the record to create
	 */
	create<T>(recordId: AnyRecordId): CreatePromise<RecordResult<T>, T>;
	/**
	 * Create a new record in the specified table
	 *
	 * @param table The table to create a record in
	 */
	create<T>(table: Table): CreatePromise<RecordResult<T>[], T>;
	/**
	 * Create a graph edge between the from record and the to record using the specified edge
	 *
	 * @param from The in property on the edge record
	 * @param edge The id or table of the edge record
	 * @param to  The out property on the edge record
	 * @param data The optional record data to store on the edge
	 */
	relate<T>(from: AnyRecordId, edge: Table | _RecordId, to: AnyRecordId, data?: Values<T>): RelatePromise<T>;
	/**
	 * Create multiple graph edges between the from records and the to records using the specified edge
	 *
	 * @param from The in properties on the edge records
	 * @param edge The edge table to create the relation in
	 * @param to  The out property on the edge record
	 * @param data The optional record data to store on the edge
	 */
	relate<T>(from: AnyRecordId[], edge: Table, to: AnyRecordId[], data?: Partial<T>): RelatePromise<T[]>;
	/**
	 * Inserts one or multiple records into the database
	 *
	 * @param data One or more records to insert
	 */
	insert<T>(data: Values<T> | Values<T>[]): InsertPromise<RecordResult<T>[]>;
	/**
	 * Inserts one or multiple records into the database
	 *
	 * @param table The table to insert the record into
	 * @param data One or more records to insert
	 */
	insert<T>(table: Table, data: Values<T> | Values<T>[]): InsertPromise<RecordResult<T>[]>;
	/**
	 * Updates a single record based on the provided Record ID
	 *
	 * @param recordId The record ID to update
	 */
	update<T>(recordId: AnyRecordId): UpdatePromise<RecordResult<T>, T>;
	/**
	 * Updates all records based on the provided Record ID range
	 *
	 * @param range The range of record IDs to update
	 */
	update<T>(range: _RecordIdRange): UpdatePromise<RecordResult<T>[], T>;
	/**
	 * Updates all records present in the specified table
	 *
	 * @param table The table to update
	 */
	update<T>(table: Table): UpdatePromise<RecordResult<T>[], T>;
	/**
	 * Upserts a single record based on the provided Record ID
	 *
	 * **NOTE**: This function replaces the existing record data with the specified data**
	 *
	 * @param recordId The record ID to upsert
	 * @param data The record data to upsert
	 */
	upsert<T>(recordId: AnyRecordId): UpsertPromise<RecordResult<T>, T>;
	/**
	 * Upserts all records based on the provided Record ID range
	 *
	 * **NOTE**: This function replaces the existing record data with the specified data**
	 *
	 * @param range The range of record IDs to upsert
	 * @param data The record data to upsert
	 */
	upsert<T>(range: _RecordIdRange): UpsertPromise<RecordResult<T>[], T>;
	/**
	 * Upserts all records present in the specified table
	 *
	 * **NOTE**: This function replaces the existing record data with the specified data**
	 *
	 * @param table The table to upsert
	 * @param data The record data to upsert
	 */
	upsert<T>(table: Table): UpsertPromise<RecordResult<T>[], T>;
	/**
	 * Deletes a single record from the database based on the provided Record ID
	 *
	 * @param recordId The record ID to delete
	 */
	delete<T>(recordId: AnyRecordId): DeletePromise<RecordResult<T>>;
	/**
	 * Deletes all records based on the provided Record ID range
	 *
	 * @param range The range of record IDs to delete
	 */
	delete<T>(range: _RecordIdRange): DeletePromise<RecordResult<T>[]>;
	/**
	 * Deletes all records present in the specified table
	 *
	 * @param table The table to delete
	 */
	delete<T>(table: Table): DeletePromise<RecordResult<T>[]>;
	/**
	 * Run a SurrealQL function and return the result
	 *
	 * @param name The full name of the function to run
	 * @param args The arguments supplied to the function
	 */
	run<T>(name: string, args?: unknown[]): RunPromise<T>;
	/**
	 * Run a SurrealML function with the specified version and return the result
	 *
	 * @param name The full name of the function to run
	 * @param version The version of the function to use
	 * @param args The arguments supplied to the function
	 */
	run<T>(name: string, version: string, args?: unknown[]): RunPromise<T>;
}
/**
 * A query transaction scoped to a session used to execute multiple queries atomically.
 *
 * When the desired queries have been executed, call `commit()` to apply the changes to the database.
 * If the transaction is no longer needed, call `cancel()` to discard the changes.
 */
export declare class SurrealTransaction extends SurrealQueryable {
	#private;
	constructor(connection: ConnectionController, session: Session, transaction: Uuid);
	/**
	 * Commit this transaction to the datastore.
	 */
	commit(): Promise<void>;
	/**
	 * Cancel and discard the changes made in this transaction.
	 */
	cancel(): Promise<void>;
}
export type SessionEvents = {
	auth: [
		Tokens | null
	];
	using: [
		NamespaceDatabase
	];
};
/**
 * A scoped contextual session attached to a connection to SurrealDB.
 *
 * Note that most methods in this class are dispatched once you subscribe to the
 * returned Promise and offer various chainable configuration methods before
 * making the actual request.
 *
 * You can create a new derived session by calling the `forkSession` method.
 */
export declare class SurrealSession extends SurrealQueryable {
	#private;
	subscribe<K extends keyof SessionEvents>(event: K, listener: (...payload: SessionEvents[K]) => void): () => void;
	constructor(connection: ConnectionController, session: Session);
	/**
	 * Returns the selected namespace
	 */
	get namespace(): string | undefined;
	/**
	 * Returns the selected database
	 */
	get database(): string | undefined;
	/**
	 * Returns the current authentication access token
	 */
	get accessToken(): string | undefined;
	/**
	 * Returns the parameters currently defined on the session
	 */
	get parameters(): Record<string, unknown>;
	/**
	 * Returns the ID of the current session. For the default session, undefined is returned.
	 */
	get session(): Session;
	/**
	 * Returns whether the session is valid and can be used. This is always true for the default session,
	 * however for other sessions it will be false after the session has been disposed.
	 */
	get isValid(): boolean;
	/**
	 * Create a new session by cloning the current session and return a new `SurrealSession` instance scoped to it.
	 *
	 * This session will contain its own copy of global variables, namespace, database, and authentication state.
	 * Connection related functions and event subscriptions will be shared with the original session. When the
	 * connection reconnects, the session will be automatically restored.
	 *
	 * You can invoke `reset()` on the created session to destroy it, after which it cannot be used again.
	 *
	 * The following properties are inherited by the new session:
	 * - namespace
	 * - database
	 * - variables
	 * - authentication state
	 *
	 * @returns The new session
	 */
	forkSession(): Promise<SurrealSession>;
	/**
	 * Closes the current session and disposes of it. After this method is called, the session cannot be used again,
	 * and `isValid` will return `false`.
	 */
	closeSession(): Promise<void>;
	[Symbol.asyncDispose](): Promise<void>;
	/**
	 * Create a new transaction scoped to the current session. Transactions allow you to execute
	 * multiple queries atomically. When the desired queries have been executed, call `commit()` to apply the changes to the database.
	 * If the transaction is no longer needed, call `cancel()` to discard the changes.
	 *
	 * @returns A new transaction instance
	 */
	beginTransaction(): Promise<SurrealTransaction>;
	/**
	 * Switch to the specified {@link https://surrealdb.com/docs/surrealdb/introduction/concepts/namespace|namespace}
	 * and {@link https://surrealdb.com/docs/surrealdb/introduction/concepts/database|database}
	 *
	 * Leaving the namespace or database undefined will leave the current namespace or database unchanged,
	 * while passing null will unset the selected namespace or database.
	 *
	 * @param database Switches to a specific namespace
	 * @param db Switches to a specific database
	 * @returns The newly selected namespace and database
	 */
	use(what?: Nullable<NamespaceDatabase>): Promise<NamespaceDatabase>;
	/**
	 * Sign up to the SurrealDB instance as a new
	 * {@link https://surrealdb.com/docs/surrealdb/security/authentication#record-users|record user}.
	 *
	 * When this method is called, the `authentication` property passed to `connect()`
	 * will be ignored. You will be reponsible for handling session invalidation
	 * by listening to the `auth` event.
	 *
	 * @param auth The authentication details to use.
	 * @return The authentication tokens.
	 */
	signup(auth: AccessRecordAuth): Promise<Tokens>;
	/**
	 * Authenticate with the SurrealDB using the provided authentication details.
	 *
	 * When this method is called, the `authentication` property passed to `connect()`
	 * will be ignored. You will be reponsible for handling session invalidation
	 * by listening to the `auth` event.
	 *
	 * @param auth The authentication details to use.
	 * @return The authentication tokens.
	 */
	signin(auth: AnyAuth): Promise<Tokens>;
	/**
	 * Authenticates the current connection using an existing access token or
	 * an access and refresh token combination.
	 *
	 * When authenticating with a refresh token, a new refresh token will be issued
	 * and returned.
	 *
	 * When this method is called, the `authentication` property passed to `connect()`
	 * will be ignored. You will be reponsible for handling session invalidation
	 * by listening to the `auth` event.
	 *
	 * @param token The access token or access and refresh token combination.
	 */
	authenticate(token: Token | Tokens): Promise<Tokens>;
	/**
	 * Define a global variable for the current socket connection
	 *
	 * @param key Specifies the name of the variable
	 * @param val Assigns the value to the variable name
	 */
	set(variable: string, value: unknown): Promise<void>;
	/**
	 * Remove a variable from the current socket connection
	 *
	 * @param key Specifies the name of the variable.
	 */
	unset(variable: string): Promise<void>;
	/**
	 * Invalidates the authentication for the current connection.
	 */
	invalidate(): Promise<void>;
	/**
	 * Resets the current session to its initial state, clearing
	 * authentication state, variables, and selected namespace/database.
	 */
	reset(): Promise<void>;
	/**
	 * Compose a new `SurrealSession` instance with the provided parent connection
	 * and session ID.
	 *
	 * You likely won't need to use this method directly, but it can be useful when
	 * you need to compose a new `SurrealSession` instance from an id.
	 *
	 * @param session The parent connection or session to reference
	 * @param id The ID of the session
	 * @returns A new `SurrealSession` representing the provided ID
	 */
	static of(parent: SurrealSession, id: Session): SurrealSession;
}
export type SurrealEvents = SessionEvents & {
	connecting: [
	];
	connected: [
		string
	];
	reconnecting: [
	];
	disconnected: [
	];
	error: [
		Error
	];
};
/**
 * The Surreal class provides methods to connect to a SurrealDB instance,
 * execute database queries, subscribe to events, and manage database sessions.
 *
 * Note that most methods in this class are dispatched once you subscribe to the
 * returned Promise and offer various chainable configuration methods before
 * making the actual request.
 *
 * By default the Surreal instance is scoped to a default session, however you
 * can create a new session by calling the `newSession` or `forkSession` methods.
 */
export declare class Surreal extends SurrealSession implements EventPublisher<SurrealEvents> {
	#private;
	subscribe<K extends keyof SurrealEvents>(event: K, listener: (...payload: SurrealEvents[K]) => void): () => void;
	/**
	 * Construct a new Surreal instance with the provided options
	 *
	 * @param options Driver wide configuration options
	 */
	constructor(options?: DriverOptions);
	/**
	 * Returns the status of the connection
	 */
	get status(): ConnectionStatus;
	/**
	 * Returns whether the connection is considered connected
	 *
	 * Equivalent to `this.status === "connected"`
	 */
	get isConnected(): boolean;
	/**
	 * A promise which resolves when the connection is ready, or rejects
	 * if a connection error occurs.
	 */
	get ready(): Promise<void>;
	/**
	 * Connect to a local or remote SurrealDB instance using the provided URL.
	 *
	 * Calling `connect()` will reset and dispose any existing sessions created with `newSession()`.
	 *
	 * @param url The endpoint to connect to
	 * @param opts Options to configure the connection
	 */
	connect(url: string | URL, opts?: ConnectOptions): Promise<true>;
	/**
	 * Disconnect from the active SurrealDB instance
	 */
	close(): Promise<true>;
	/**
	 * Check the health of the connected SurrealDB instance
	 *
	 * @returns The health of the connected SurrealDB instance
	 */
	health(): Promise<void>;
	/**
	 * Retrieves the version of the connected SurrealDB instance
	 *
	 * @example { version: "surrealdb-2.1.0" }
	 */
	version(): Promise<VersionInfo>;
	/**
	 * Checks whether a feature is available in the current connection
	 *
	 * @param feature The feature to check
	 */
	isFeatureSupported(feature: Feature): boolean;
	/**
	 * Lists all sessions created on the current connection.
	 *
	 * @returns A list of active session IDs
	 */
	sessions(): Promise<Uuid[]>;
	/**
	 * Create a fresh new session on this connection and return a dedicated `Surreal` instance scoped to it.
	 *
	 * This session will contain its own copy of global variables, namespace, database, and authentication state.
	 * Connection related functions and event subscriptions will be shared with the original session. When the
	 * connection reconnects, the session will be automatically restored.
	 *
	 * You can invoke `reset()` on the created session to destroy it, after which it cannot be used again.
	 *
	 * @returns The new session
	 */
	newSession(): Promise<SurrealSession>;
	/**
	 * Stop the primary session. This is equivalent to calling `close()` on the connection.
	 */
	closeSession(): Promise<void>;
	/**
	 * Import an existing export into the database
	 *
	 * @param input The data to import
	 */
	import(input: string | Blob | ReadableStream): Promise<void>;
	/**
	 * Export the database as SurrealQL.
	 *
	 * By default, the result is returned as a string. Chain `.response()`
	 * to receive the raw `Response` instead.
	 *
	 * @param options Optional export options
	 */
	export(options?: Partial<SqlExportOptions>): ExportPromise;
	/**
	 * Export a SurrealML model.
	 *
	 * By default, the result is returned as a `Uint8Array`. Chain `.response()`
	 * to receive the raw `Response` instead.
	 *
	 * @param name The name of the ML model to export
	 * @param version The version of the ML model to export
	 */
	exportModel(name: string, version: string): ExportModelPromise;
}
/**
 * A class used to encode and decode SurrealQL values using CBOR
 */
export declare class CborCodec implements ValueCodec {
	#private;
	constructor(options: CodecOptions);
	encode<T>(data: T): Uint8Array;
	decode<T>(data: Uint8Array): T;
	protected replacer: Replacer;
	protected tagged: Record<number, Replacer>;
}
type DiagnosticsCallback = (event: Diagnostic) => void;
/**
 * JSON-based engines implement the SurrealDB v1 protocol, which uses
 * JSON objects to communicate with the server.
 */
export declare abstract class RpcEngine implements SurrealProtocol {
	protected _context: DriverContext;
	protected _state: ConnectionState | undefined;
	constructor(context: DriverContext);
	health(): Promise<void>;
	version(): Promise<VersionInfo>;
	sessions(): Promise<Uuid[]>;
	attach(session: Uuid): Promise<void>;
	detach(session: Uuid): Promise<void>;
	use(what: Nullable<NamespaceDatabase>, session: Session): Promise<NamespaceDatabase>;
	signup(auth: AccessRecordAuth, session: Session): Promise<Tokens>;
	signin(auth: AnyAuth, session: Session): Promise<Tokens>;
	authenticate(token: Token, session: Session): Promise<void>;
	set(name: string, value: unknown, session: Session): Promise<void>;
	unset(name: string, session: Session): Promise<void>;
	refresh(tokens: Tokens, session: Session): Promise<Tokens>;
	revoke(tokens: Tokens, session: Session): Promise<void>;
	invalidate(session: Session): Promise<void>;
	reset(session: Session): Promise<void>;
	begin(session: Session): Promise<Uuid>;
	commit(txn: Uuid, session: Session): Promise<void>;
	cancel(txn: Uuid, session: Session): Promise<void>;
	importSql(data: string | Blob | ReadableStream): Promise<void>;
	exportSql(options: Partial<SqlExportOptions>): Promise<Response>;
	exportMlModel(options: MlExportOptions): Promise<Response>;
	query<T>(query: BoundQuery, session: Session, txn?: Uuid): AsyncIterable<QueryChunk<T>>;
	abstract liveQuery(id: Uuid): AsyncIterable<LiveMessage>;
	parseTokens(response: unknown): Tokens;
	abstract send<Method extends string, Params extends unknown[] | undefined, Result>(request: RpcRequest<Method, Params>): Promise<Result>;
}
/**
 * An engine that communicates by sending individual HTTP requests
 */
export declare class HttpEngine extends RpcEngine implements SurrealEngine {
	#private;
	features: Set<Feature>;
	subscribe<K extends keyof EngineEvents>(event: K, listener: (...payload: EngineEvents[K]) => void): () => void;
	open(state: ConnectionState): void;
	close(): Promise<void>;
	ready(): void;
	send<Method extends string, Params extends unknown[] | undefined, Result>(request: RpcRequest<Method, Params>): Promise<Result>;
	liveQuery(): AsyncIterable<LiveMessage>;
}
/**
 * An engine that communicates over WebSocket protocol
 */
export declare class WebSocketEngine extends RpcEngine implements SurrealEngine {
	#private;
	features: Set<Feature>;
	subscribe<K extends keyof EngineEvents>(event: K, listener: (...payload: EngineEvents[K]) => void): () => void;
	open(state: ConnectionState): void;
	close(): Promise<void>;
	ready(): void;
	send<Method extends string, Params extends unknown[] | undefined, Result>(request: RpcRequest<Method, Params>): Promise<Result>;
	liveQuery(id: Uuid): AsyncIterable<LiveMessage>;
	private createSocket;
	private parseBuffer;
	private handleRpcResponse;
}
/**
 * Configure the `ws`, `wss`, `http`, and `https` remote engines for the JavaScript SDK.
 *
 * When engines are not explicitly configured, the JavaScript SDK will configure the
 * remote engines by default.
 *
 * @example
 * ```ts
 * import { Surreal, createRemoteEngines } from "surrealdb";
 *
 * const db = new Surreal({
 *     engines: createRemoteEngines(),
 * });
 * ```
 */
export declare const createRemoteEngines: () => Engines;
/**
 * This utility allows you to wrap engines and listen to internal communication
 * within the SDK. Each operation is wrapped in a diagnostic event and emitted to the
 * provided callback.
 *
 * Note that use of this utility is discouraged in production environments as it may
 * hinder performance and is considered unstable, meaning diagnostic events may change between versions.
 *
 * @param engines The engine implementations to wrap.
 * @param callback The callback to emit diagnostic events to.
 * @returns The wrapped engine implementations.
 */
export declare const applyDiagnostics: (engines: Engines, callback: DiagnosticsCallback) => Engines;

export {
	Range$1 as Range,
	_RecordId as RecordId,
	_RecordIdRange as RecordIdRange,
	toSurqlString as toSurrealqlString,
};

export {};
