@tai-kun/surrealdb
Version:
The SurrealDB SDK for JavaScript
46 lines • 2.2 kB
TypeScript
import { type ProcessEndpointOptions } from "@tai-kun/surrealdb/engine";
import type { Formatter } from "@tai-kun/surrealdb/formatter";
import type { Jwt } from "@tai-kun/surrealdb/standard-client";
import type { RpcParams, RpcResultMapping } from "@tai-kun/surrealdb/types";
import type { UnionToIntersection, ValueOf } from "type-fest";
export type InlineRpcFetcherRequestInit = {
method: "POST";
headers: {
"Content-Type": string;
"Surreal-DB"?: string;
"Surreal-NS"?: string;
Accept: string;
Authorization?: string;
};
body: string | Uint8Array;
signal: AbortSignal;
};
export type InlineRpcFetcher = (input: string, init: InlineRpcFetcherRequestInit) => Response | PromiseLike<Response>;
export type InlineRpcOptions = ProcessEndpointOptions & {
readonly formatter?: Formatter | undefined;
readonly namespace?: string | undefined;
readonly database?: string | undefined;
readonly token?: string | Jwt | undefined;
readonly fetch?: InlineRpcFetcher | undefined;
readonly signal?: AbortSignal | undefined;
};
export type InlineRpcMethod = "authenticate" | "create" | "delete" | "info" | "insert" | "insert_relation" | "invalidate" | "merge" | "patch" | "ping" | "query" | "relate" | "run" | "graphql" | "select" | "signin" | "signup" | "unset" | "update" | "upsert" | "version";
interface RpcWithRequiredParams<TMethod extends InlineRpcMethod> {
/**
* @experimental
*/
<T extends RpcResultMapping[TMethod]>(endpoint: string | URL, method: TMethod, options: InlineRpcOptions & {
readonly params: RpcParams<TMethod>;
}): Promise<T>;
}
interface RpcWithOptionalParams<TMethod extends InlineRpcMethod> {
/**
* @experimental
*/
<T extends RpcResultMapping[TMethod]>(endpoint: string | URL, method: TMethod, options?: (InlineRpcOptions & {
readonly params?: RpcParams<TMethod>;
}) | undefined): Promise<T>;
}
declare const _default: UnionToIntersection<ValueOf<{ [TMethod in InlineRpcMethod]: undefined extends RpcParams<TMethod> ? RpcWithOptionalParams<TMethod> : RpcWithRequiredParams<TMethod>; }>>;
export default _default;
//# sourceMappingURL=rpc.d.ts.map