@ultipa-graph/ultipa-driver
Version:
NodeJS SDK for ultipa-server 5.2
113 lines (112 loc) • 4.29 kB
TypeScript
/// <reference types="node" />
import * as grpc from "@grpc/grpc-js";
import { RequestType } from "../../types";
import { UQLMAKER } from "../../utils";
import { AuthenticateType, RequestConfig, Response, UltipaConfig, JobResponse } from "../../types/types";
/**
* GrpcClientInfo Class
* Used to manage basic information and metadata required for gRPC client connections
*
* Main responsibilities:
* 1. Store connection information (host address, username, password, certificate)
* 2. Generate metadata required for gRPC calls
* 3. Get/cache gRPC client instances
*/
declare class GrpcClientInfo {
host: string;
username: string;
password: string;
crt: Buffer;
constructor(host: string, username: string, password: string, crt?: Buffer);
getMetadata(graphSetName: string, timezone: string, timezoneOffset: string): grpc.Metadata;
getClient(): import("../network.manager").UltipaClientAio;
}
export declare const RAFT_GLOBAL = "global";
/**
* ConnectionBase Class
*
* Base connection class that provides core functionality for communicating with Ultipa database
*
* Main features:
* - Manages gRPC client connections
* - Contains query base api uql() & gql()
* - Provides connection testing capabilities
*/
export declare class ConnectionBase {
grpcClintInfo: GrpcClientInfo;
protected host: string;
protected username: string;
protected password: string;
protected crt: Buffer;
defaultConfig: UltipaConfig;
constructor(host: string, username: string, password: string, crt?: Buffer, defaultConfig?: UltipaConfig, isMd5?: boolean);
setDefaultConfig(config?: UltipaConfig): void;
protected getGraphSetName(currentGraphName: string, uql?: string, isGlobal?: boolean): string;
protected getTimeout(timeout: number): number;
protected getClientInfo(params: {
graphSetName?: string;
uql?: string;
isGlobal?: boolean;
useHost?: string;
forceRefresh?: boolean;
timezone: string;
timezoneOffset: string;
}): Promise<{
client: import("../network.manager").UltipaClientAio;
host: string;
metadata: grpc.Metadata;
goGraphName: string;
}>;
auth(authType: AuthenticateType, queryText?: string, config?: RequestConfig): Promise<Response>;
/**
* Login
*/
login(config?: RequestConfig): Promise<boolean>;
/**
* Test connect
*/
test(): Promise<boolean>;
/**
* Test message
*/
test_has_message(config?: RequestConfig): Promise<{
connect: boolean;
msg: string;
}>;
/**
* Executes a UQL query on the current graphset or the database and returns the result.
* @param uql
* @param config
* @returns Response
*/
uql(uql: string, config?: RequestConfig): Promise<Response>;
/**
* Executes a UQL query on the current graphset or the database and returns the result incrementally, allowing handling of large datasets without loading everything into memory at once.
* @param uql
* @param cb QueryResponseListener
* @param config
*/
uqlStream(uql: string, cb: RequestType.QueryResponseListener, config?: RequestConfig): Promise<void>;
/**
* Executes a GQL query on the current graphset or the database and returns the result.
* @param gql
* @param config
* @returns Response
*/
gql(gql: string, config?: RequestConfig): Promise<Response>;
/**
* Executes a GQL query on the current graphset or the database and returns the result incrementally, allowing handling of large datasets without loading everything into memory at once.
* @param gql
* @param stream
* @param config
*/
gqlStream(gql: string, cb: RequestType.QueryResponseListener, config?: RequestConfig): Promise<void>;
/**
* Execute UQL
*/
private _query_without_catch;
protected uqlSingle(uqlMaker: UQLMAKER): Promise<Response>;
protected uqlResponse(uqlMaker: UQLMAKER, config?: RequestConfig): Promise<Response>;
protected uqlJobResponse(uqlMaker: UQLMAKER, config?: RequestConfig): Promise<JobResponse>;
}
export {};