import Table from './table'; import { QueryParams } from './query_params'; import { FieldSet } from './field_set'; import { Records } from './records'; declare type CallbackError = any; declare type PageCallback = (records: Records, processNextPage: () => void) => void; declare type RecordCollectionCallback = (error: CallbackError, records?: Records) => void; declare type DoneCallback = (error: CallbackError) => void; interface RecordCollectionRequestMethod { (): Promise>; (done: RecordCollectionCallback): void; } interface RecordPageIteratationMethod { (pageCallback: PageCallback): Promise; (pageCallback: PageCallback, done: DoneCallback): void; } /** * Builds a query object. Won't fetch until `firstPage` or * or `eachPage` is called. * * Params should be validated prior to being passed to Query * with `Query.validateParams`. */ declare class Query { readonly _table: Table; readonly _params: QueryParams; readonly firstPage: RecordCollectionRequestMethod; readonly eachPage: RecordPageIteratationMethod; readonly all: RecordCollectionRequestMethod; static paramValidators: { fields: (value: string[]) => { pass: true; } | { pass: false; error: string; }; filterByFormula: (value: string) => { pass: true; } | { pass: false; error: string; }; maxRecords: (value: number) => { pass: true; } | { pass: false; error: string; }; pageSize: (value: number) => { pass: true; } | { pass: false; error: string; }; offset: (value: number) => { pass: true; } | { pass: false; error: string; }; sort: (value: { field: string; direction?: "desc" | "asc"; }[]) => { pass: true; } | { pass: false; error: string; }; view: (value: string) => { pass: true; } | { pass: false; error: string; }; cellFormat: (value: "string" | "json") => { pass: true; } | { pass: false; error: string; }; timeZone: (value: string) => { pass: true; } | { pass: false; error: string; }; userLocale: (value: string) => { pass: true; } | { pass: false; error: string; }; method: (value: "string" | "json") => { pass: true; } | { pass: false; error: string; }; returnFieldsByFieldId: (value: boolean) => { pass: true; } | { pass: false; error: string; }; recordMetadata: (value: string[]) => { pass: true; } | { pass: false; error: string; }; }; constructor(table: Table, params: QueryParams); /** * Validates the parameters for passing to the Query constructor. * * @params {object} params parameters to validate * * @return an object with two keys: * validParams: the object that should be passed to the constructor. * ignoredKeys: a list of keys that will be ignored. * errors: a list of error messages. */ static validateParams = QueryParams>(params: Params): { validParams: QueryParams; ignoredKeys: string[]; errors: string[]; }; } export = Query;