///
import { Parameterized, SQLClauseOperation } from '../../lib/data-query/index';
import { CacheLayerStoreFormatType, IncomingHttpHeaders, Profile } from '../index';
import { Readable } from 'stream';
import { ExtensionBase } from './base';
export interface ExportOptions {
sql: string;
directory: string;
profileName: string;
options?: any;
type: CacheLayerStoreFormatType | string;
}
export interface ImportOptions {
tableName: string;
directory: string;
profileName: string;
schema: string;
type: CacheLayerStoreFormatType | string;
indexes?: Record;
}
export interface RequestParameter {
/** The index (starts from 1) of parameters, it's useful to generate parameter id like $1, $2 ...etc. */
parameterIndex: number;
/** The raw value (not name) */
value: any;
profileName: string;
}
export declare type BindParameters = Map;
export declare type DataColumn = {
name: string;
type: string;
};
export interface DataResult {
getColumns: () => DataColumn[];
getData: () => Readable;
}
export interface ExecuteOptions {
statement: string;
/** For core version >= 0.3.0, operations.limit and operation.offset must be handled */
operations: Partial>;
/** The parameter bindings, we guarantee the order of the keys in the map is the same as the order when they were used in queries. */
bindParams: BindParameters;
profileName: string;
headers?: IncomingHttpHeaders;
}
export declare type PrepareParameterFunc = {
(param: RequestParameter): Promise;
};
export declare abstract class DataSource> extends ExtensionBase {
private profiles;
constructor(config: C, moduleName: string, profiles?: Profile[]);
abstract execute(options: ExecuteOptions): Promise;
abstract prepare(param: RequestParameter): Promise;
/**
* Export query result data to cache file for cache layer loader used
*/
export(options: ExportOptions): Promise;
/**
* Import data to create table from cache file for cache layer loader used
*/
import(options: ImportOptions): Promise;
/** Get all the profiles which belong to this data source */
protected getProfiles(): Map>;
protected getProfile(name: string): Profile;
}