import Base, { type ClientRpcOptions } from "@tai-kun/surrealdb/basic-client"; import type { Auth, LivePayload, Patch, PreparedQueryLike, QueryResult, ReadonlyPatch, RecordAccessAuth, RpcGraphqlRequest, RpcResultMapping, SlotLike } from "@tai-kun/surrealdb/types"; import { type TaskListener } from "@tai-kun/surrealdb/utils"; import type { Simplify, UnionToIntersection } from "type-fest"; import type { DataType } from "../../surreal/data-types"; import Jwt from "./jwt"; export type * from "@tai-kun/surrealdb/basic-client"; type Override = Simplify & U>; export type InferSlotVars = UnionToIntersection<{ [TName in TSlot["name"]]: TSlot extends SlotLike ? TRequired extends false ? { readonly [_ in TName]?: TValue; } : { readonly [_ in TName]: TValue; } : never; }[TSlot["name"]]>; export interface LiveOptions extends ClientRpcOptions { readonly diff?: boolean | undefined; } export type LiveHandler = LivePayload> = TaskListener<[payload: TPayload]>; export type InferLivePayload = RecordData, TPatch extends Patch[] = Patch[]> = TUuid extends { __diff: false; } ? LivePayload.Data : TUuid extends { __diff: true; } ? LivePayload.Diff : LivePayload; export type ActionResult = RecordData> = [Extract] extends [never] ? ({ id: DataType.Thing | string; } & TData) : TData; type _In = [Extract] extends [never] ? ({ in: DataType.Thing | string; } & T) : T; type _Out = [Extract] extends [never] ? ({ out: DataType.Thing | string; } & T) : T; export type RelateResult = RecordData> = ActionResult<_In<_Out>>; export interface PatchOptions extends ClientRpcOptions { readonly diff?: boolean | undefined; } export interface RunOptions extends ClientRpcOptions { readonly version?: string | undefined; } export interface GraphqlOptions extends ClientRpcOptions, NonNullable { } type RecordData = { [p: string]: unknown; }; type NormalRecord = { id: DataType.Thing | string; [p: string]: unknown; }; export default class Client extends Base { ping(options?: ClientRpcOptions | undefined): Promise; use(ns: string | null | undefined, options?: ClientRpcOptions | undefined): Promise; use(ns: string | null | undefined, db?: string | null | undefined, options?: ClientRpcOptions | undefined): Promise; use(target: [ns: string | null | undefined, db?: string | null | undefined], options?: ClientRpcOptions | undefined): Promise; use(target: { readonly ns?: string | null | undefined; readonly db?: string | null | undefined; }, options?: ClientRpcOptions | undefined): Promise; use(target: { readonly namespace?: string | null | undefined; readonly database?: string | null | undefined; }, options?: ClientRpcOptions | undefined): Promise; info(options?: ClientRpcOptions | undefined): Promise; /** * [API Reference](https://tai-kun.github.io/surrealdb.js/v2/guides/connecting/#signup) */ signup(auth: RecordAccessAuth, options?: ClientRpcOptions | undefined): Promise; /** * [API Reference](https://tai-kun.github.io/surrealdb.js/v2/guides/connecting/#signin) */ signin(auth: Auth, options?: ClientRpcOptions | undefined): Promise; /** * [API Reference](https://tai-kun.github.io/surrealdb.js/v2/guides/connecting/#authenticate) */ authenticate(token: string | Jwt, options?: ClientRpcOptions | undefined): Promise; /** * [API Reference](https://tai-kun.github.io/surrealdb.js/v2/guides/connecting/#invalidate) */ invalidate(options?: ClientRpcOptions | undefined): Promise; live(table: DataType.Table | string, options: ClientRpcOptions & { readonly diff: true; }): Promise; live(table: DataType.Table | string, options?: (ClientRpcOptions & { readonly diff?: false | undefined; }) | undefined): Promise; live(table: DataType.Table | string, options?: LiveOptions | undefined): Promise; subscribe = InferLivePayload>(queryUuid: TUuid, callback: LiveHandler): void; unsubscribe(queryUuid: DataType.Uuid | string, callback: LiveHandler): void; kill(queryUuid: DataType.Uuid | string | readonly (DataType.Uuid | string)[], options?: ClientRpcOptions | undefined): Promise; /** * [API Reference](https://tai-kun.github.io/surrealdb.js/v2/guides/querying/#queryraw) */ queryRaw(surql: string | PreparedQueryLike, vars?: Readonly | undefined, options?: ClientRpcOptions | undefined): Promise; /** * [API Reference](https://tai-kun.github.io/surrealdb.js/v2/guides/querying/#query) */ query(surql: string, vars?: Readonly | undefined, options?: ClientRpcOptions | undefined): Promise; /** * [API Reference](https://tai-kun.github.io/surrealdb.js/v2/guides/querying/#query) */ query(surql: Override[]; readonly __type: TResult; }>, vars?: Readonly | undefined, options?: ClientRpcOptions | undefined): Promise; /** * [API Reference](https://tai-kun.github.io/surrealdb.js/v2/guides/querying/#query) */ query(surql: Override, vars: Simplify> & Readonly, options?: ClientRpcOptions | undefined): Promise; let(name: string, value: unknown, options?: ClientRpcOptions | undefined): Promise; unset(name: string, options?: ClientRpcOptions | undefined): Promise; select = RecordData>(table: DataType.Table | string, options?: ClientRpcOptions | undefined): Promise[]>; select = RecordData>(thing: DataType.Thing, options?: ClientRpcOptions | undefined): Promise>; create = RecordData, TData extends Readonly = TResult>(table: DataType.Table | string, data?: TData | undefined, options?: ClientRpcOptions | undefined): Promise>; create = RecordData, TData extends Readonly = TResult>(thing: DataType.Thing, data?: TData | undefined, options?: ClientRpcOptions | undefined): Promise>; insert = RecordData, TData extends Readonly = TResult>(table: DataType.Table | string, data?: TData | readonly TData[] | undefined, options?: ClientRpcOptions | undefined): Promise[]>; insert = RecordData, TData extends Readonly = (TResult extends { readonly id: any; } ? TResult : ({ id: DataType.Thing | string; } & TResult))>(table: DataType.Table | string | null | undefined, data?: TData | readonly TData[] | undefined, options?: ClientRpcOptions | undefined): Promise[]>; insert = RecordData, TData extends Readonly = (TResult extends { readonly id: any; } ? TResult : ({ id: DataType.Thing | string; } & TResult))>(data: TData | readonly TData[], options?: ClientRpcOptions | undefined): Promise[]>; insert_relation = RecordData, TData extends Readonly = TResult>(table: DataType.Table | string, data?: TData | readonly TData[] | undefined, options?: ClientRpcOptions | undefined): Promise[]>; insert_relation = RecordData, TData extends Readonly = (TResult extends { readonly id: any; } ? TResult : ({ id: DataType.Thing | string; } & TResult))>(table: DataType.Table | string | null | undefined, data?: TData | readonly TData[] | undefined, options?: ClientRpcOptions | undefined): Promise[]>; insert_relation = RecordData, TData extends Readonly = (TResult extends { readonly id: any; } ? TResult : ({ id: DataType.Thing | string; } & TResult))>(data: TData | readonly TData[], options?: ClientRpcOptions | undefined): Promise[]>; update = RecordData, TData extends Readonly = TResult>(table: DataType.Table | string, data?: TData | undefined, options?: ClientRpcOptions | undefined): Promise[]>; update = RecordData, TData extends Readonly = TResult>(thing: DataType.Thing, data?: TData | undefined, options?: ClientRpcOptions | undefined): Promise>; upsert = RecordData, TData extends Readonly = TResult>(table: DataType.Table | string, data?: TData | undefined, options?: ClientRpcOptions | undefined): Promise[]>; upsert = RecordData, TData extends Readonly = TResult>(thing: DataType.Thing, data?: TData | undefined, options?: ClientRpcOptions | undefined): Promise>; merge = RecordData, TData extends Readonly = TResult>(table: DataType.Table | string, data: TData, options?: ClientRpcOptions | undefined): Promise[]>; merge = RecordData, TData extends Readonly = TResult>(thing: DataType.Thing, data: TData, options?: ClientRpcOptions | undefined): Promise>; patch = RecordData>(table: DataType.Table | string, patches: readonly ReadonlyPatch[], options?: (ClientRpcOptions & { readonly diff?: false | undefined; }) | undefined): Promise[]>; patch = RecordData>(thing: DataType.Thing, patches: readonly ReadonlyPatch[], options?: (ClientRpcOptions & { readonly diff?: false | undefined; }) | undefined): Promise>; patch(table: DataType.Table | string, patches: readonly ReadonlyPatch[], options: ClientRpcOptions & { readonly diff: true; }): Promise; patch(thing: DataType.Thing, patches: readonly ReadonlyPatch[], options: ClientRpcOptions & { readonly diff: true; }): Promise; delete = RecordData>(table: DataType.Table | string, options?: ClientRpcOptions | undefined): Promise[]>; delete = RecordData>(thing: DataType.Thing, options?: ClientRpcOptions | undefined): Promise>; version(options?: ClientRpcOptions | undefined): Promise; run(funcName: string, options?: RunOptions | undefined): Promise; run(funcName: string, args?: readonly unknown[] | undefined, options?: RunOptions | undefined): Promise; /** * @experimental */ graphql(query: string | { readonly query: string; readonly vars?: Readonly | undefined; readonly operation?: string | undefined; } | { readonly query: string; readonly vars?: Readonly | undefined; readonly operationName?: string | undefined; } | { readonly query: string; readonly variables?: Readonly | undefined; readonly operation?: string | undefined; } | { readonly query: string; readonly variables?: Readonly | undefined; readonly operationName?: string | undefined; }, options?: GraphqlOptions | undefined): Promise; relate = RecordData, TData extends Readonly = TResult>(from: DataType.Thing | string | readonly (DataType.Thing | string)[], thing: string, to: DataType.Thing | string | readonly (DataType.Thing | string)[], data?: TData | undefined, options?: ClientRpcOptions | undefined): Promise[]>; relate = RecordData, TData extends Readonly = TResult>(from: DataType.Thing | string | readonly (DataType.Thing | string)[], thing: DataType.Thing, to: DataType.Thing | string | readonly (DataType.Thing | string)[], data?: TData | undefined, options?: ClientRpcOptions | undefined): Promise>; } //# sourceMappingURL=client.d.ts.map