UNPKG

seamless-cloud

Version:

JavaScript client for Seamless.cloud (web and node)

57 lines (56 loc) 1.52 kB
/** * Seamless.cloud client */ export declare type SeamlessClientConfig = { account: string; apiKey: string; project: string; region?: string; debug?: boolean; }; export declare type SeamlessQuery = { querySql: string; queryVars?: { [key: string]: any; }; }; export declare type SeamlessQueryResult = { meta: { success: boolean; statusCode: number; dtResponse: string; }; data: { results?: any[]; rowCount?: number; timeMs?: number; }; }; export interface ISeamlessClient { cfg: SeamlessClientConfig; fetchFn: any; debug: boolean; } export declare class SeamlessClient implements ISeamlessClient { cfg: SeamlessClientConfig; fetchFn: any; debug: boolean; constructor(cfg: SeamlessClientConfig, fetchFn: any); getBaseUrl(): string; /** * Find and return a single row. No result throws Error with optional custom message. */ findOneOrThrow(queryKey: string, query: SeamlessQuery, errorMsg?: string): Promise<any>; /** * Find and return a single row. No result returns boolean false. */ findOne(queryKey: string, query: SeamlessQuery): Promise<any | boolean>; /** * Find many rows (Always returns an array. No results = empty array) */ findMany(queryKey: string, query: SeamlessQuery): Promise<Array<any>>; /** * Run SQL Query */ query(queryKey: string, queryObject: SeamlessQuery): Promise<SeamlessQueryResult>; }