UNPKG

@qualifyze/airtable

Version:
59 lines (58 loc) 2.27 kB
import { FieldName, FieldsValidator, UnknownFields } from "./fields"; import { AirtableRecord } from "./record"; import { Formula } from "@qualifyze/airtable-formulator"; import { ActionPayload } from "./endpoint"; import { TableActionPoint } from "./table"; declare type CellFormat = "json" | "string"; declare type TimeZone = string; declare type UserLocale = string; declare type SortParam<Fields extends UnknownFields> = { field: keyof Fields; direction: "asc" | "desc"; }; export declare type SelectQueryPayload<Fields extends UnknownFields> = ActionPayload<Partial<Record<"offset" | keyof SelectQueryParams<Fields>, unknown>>, never>; export declare type SelectQueryParams<Fields extends UnknownFields> = { fields?: FieldName<Fields>[]; filterByFormula?: Formula; maxRecords?: number; pageSize?: number; sort?: SortParam<Fields>[]; view?: string; cellFormat?: CellFormat; timeZone?: TimeZone; userLocale?: UserLocale; }; export declare type SelectQueryDataSource<Fields extends UnknownFields> = FieldsValidator<Fields> & TableActionPoint; export declare class SelectQuery<Fields extends UnknownFields> implements AsyncIterable<AirtableRecord<Fields>> { readonly table: SelectQueryDataSource<Fields>; readonly params: SelectQueryParams<Fields>; constructor(table: SelectQueryDataSource<Fields>, param: SelectQueryParams<Fields>); private createQueryPayload; fetchRecords(payload: SelectQueryPayload<Fields>): Promise<{ records: AirtableRecord<Fields>[]; offset?: string; }>; /** * For cross-compatiblity with the offiical client. * * @deprecated */ firstPage(): Promise<AirtableRecord<Fields>[]>; pageIterable(): AsyncIterable<AirtableRecord<Fields>[]>; /** * For cross-compatibility with the official client. * * @deprecated * @param handler */ eachPage(handler: (records: AirtableRecord<Fields>[]) => void): Promise<void>; getPage(offset?: string): Promise<AirtableRecord<Fields>[]>; [Symbol.asyncIterator](): AsyncIterator<AirtableRecord<Fields>>; /** * For cross-compatibility with the official client. * * @deprecated */ all(): Promise<AirtableRecord<Fields>[]>; } export {};