// http://jsforce.github.io/jsforce/doc/Query.html
import { Readable } from "stream";
import { RecordResult } from "./record-result";
export interface ExecuteOptions {
autoFetch?: boolean | undefined;
maxFetch?: number | undefined;
headers?: object | undefined;
scanAll?: boolean | undefined;
}
export interface QueryResult {
done: boolean;
nextRecordsUrl?: string | undefined;
totalSize: number;
records: T[];
}
// Unfortunately because TypeScript wants you to believe JS has classical inheritance,
// you can't say that Query "extends Readable" because `filter` and `map` disagree with Readable's own.
// That can only be fixed by a breaking change in Query's filter and map methods. Your call.
export class Query extends Readable implements Promise {
end(): Query;
// @ts-ignore conflicts with built-in Readable.filter
filter(filter: Object): Query;
include(include: string): Query;
hint(hint: Object): Query;
limit(value: number): Query;
maxFetch(value: number): Query;
offset(value: number): Query;
skip(value: number): Query;
sort(keyOrList: string | Object[] | Object, direction?: "ASC" | "DESC" | number): Query;
run(options?: ExecuteOptions, callback?: (err: Error, records: T[]) => void): Query;
execute(options?: ExecuteOptions, callback?: (err: Error, records: T[]) => void): Query;
exec(options?: ExecuteOptions, callback?: (err: Error, records: T[]) => void): Query;
del(type?: string, callback?: (err: Error, ret: RecordResult) => void): any;
del(callback?: (err: Error, ret: RecordResult) => void): any;
delete(type?: string, callback?: (err: Error, ret: RecordResult) => void): any;
delete(callback?: (err: Error, ret: RecordResult) => void): any;
destroy(type?: string, callback?: (err: Error, ret: RecordResult) => void): Promise;
destroy(callback?: (err: Error, ret: RecordResult) => void): Promise;
destroy(error?: Error): this;
explain(callback?: (err: Error, info: ExplainInfo) => void): Promise;
// @ts-ignore conflicts with built-in Readable.map
map(callback: (currentValue: Object) => void): Promise;
scanAll(value: boolean): Query;
select(fields: Object | string[] | string): Query;
thenCall(callback?: (err: Error, records: T) => void): Query;
toSOQL(callback: (err: Error, soql: string) => void): Promise;
update(
mapping: any,
type: string,
callback?: (err: Error, records: RecordResult[]) => void,
): Promise;
update(mapping: any, callback?: (err: Error, records: RecordResult[]) => void): Promise;
where(conditions: Object | string): Query;
finally(): Promise;
[Symbol.toStringTag]: "Promise";
catch(onrejected?: (reason: any) => PromiseLike | TResult): Promise;
then(
onfulfilled?: (value: T) => PromiseLike | TResult1,
onrejected?: (reason: any) => PromiseLike | TResult2,
): Promise;
}
export class ExplainInfo {}