@useorbis/db-sdk
Version:
Orbis' Typescript SDK for building open-data experiences.
117 lines (116 loc) • 2.9 kB
TypeScript
import { OrbisConfig } from "../index.js";
type ModelMapping = {
[modelId: string]: string;
};
type NodeInformation = {
version: string;
models: Array<{
name: string;
stream_id: string;
}>;
models_mapping: ModelMapping;
plugins: Array<{
id: string;
name: string;
hooks: Array<string>;
}>;
};
type NodeContext = {
gateway: string;
isPrimary: boolean;
env?: string;
key?: string;
metadata?: NodeInformation;
};
export declare function queryDatabase<T = Record<string, any>>(node: NodeContext, jsonQuery: Record<string, any>, env?: string): Promise<{
columns: Array<string>;
rows: Array<T>;
}>;
export declare class OrbisNode {
node: NodeContext;
constructor(node: NodeContext);
get env(): string | undefined;
query<T = Record<string, any>>(jsonQuery: Record<string, any>, env?: string): Promise<{
columns: Array<string>;
rows: Array<T>;
}>;
fetch(route: string, opts?: RequestInit): Promise<Response>;
ping(): Promise<{
pong: boolean;
node: NodeContext;
}>;
metadata(forceRefresh?: boolean): Promise<{
metadata: NodeInformation;
node: {
gateway: string;
isPrimary: boolean;
env?: string;
key?: string;
};
} | {
metadata: null;
node: NodeContext;
}>;
models(): Promise<{
models: {
name: string;
stream_id: string;
}[] | undefined;
node: {
node: {
gateway: string;
isPrimary: boolean;
env?: string;
key?: string;
};
} | {
node: NodeContext;
};
}>;
plugins(): Promise<{
plugins: {
id: string;
name: string;
hooks: Array<string>;
}[] | undefined;
node: {
node: {
gateway: string;
isPrimary: boolean;
env?: string;
key?: string;
};
} | {
node: NodeContext;
};
}>;
getTableName(id: string): Promise<{
tableName: string | undefined;
node: {
node: {
gateway: string;
isPrimary: boolean;
env?: string;
key?: string;
};
} | {
node: NodeContext;
};
}>;
getTableModelId(tableName: string): Promise<{
modelId: string | undefined;
node: {
gateway: string;
isPrimary: boolean;
env?: string;
key?: string;
};
}>;
}
export declare class OrbisNodeManager {
#private;
constructor(nodes: OrbisConfig["nodes"]);
get nodes(): OrbisNode[];
get active(): OrbisNode;
}
export {};