// Type definitions for airtable 0.5 // Project: https://github.com/airtable/airtable.js // Definitions by: Brandon Valosek // Max Chehab // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 export = Airtable; declare global { class Airtable { constructor(options?: Airtable.AirtableOptions); base(appId: string): Airtable.Base; } namespace Airtable { interface FieldSet { [key: string]: | undefined | string | number | boolean | Collaborator | ReadonlyArray | ReadonlyArray | ReadonlyArray; } interface AirtableOptions { apiKey?: string; endpointUrl?: string; apiVersion?: string; allowUnauthorizedSsl?: boolean; noRetryIfRateLimited?: boolean; requestTimeout?: number; } interface Base { (tableName: string): Table<{}>; } interface Table { select(opt?: SelectOptions): Query; find(id: string): Promise>; create(record: TFields, opts?: { typecast: boolean }): Promise>; create(records: TFields[], opts?: { typecast: boolean }): Promise>>; update(...args: any[]): Promise; replace(...args: any[]): Promise; destroy(...args: any[]): Promise; } interface SortParameter { field: string; direction?: 'asc' | 'desc'; } interface SelectOptions { fields?: string[]; filterByFormula?: string; maxRecords?: number; pageSize?: number; sort?: SortParameter[]; view?: string; cellFormat?: 'json' | 'string'; timeZone?: string; userLocale?: string; } interface Query { all(): Promise>; firstPage(): Promise>; eachPage(pageCallback: (records: Response, next: () => void) => void): Promise; } type Response = ReadonlyArray>; interface Row { id: string; fields: TFields; } interface Attachment { id: string; url: string; filename: string; size: number; type: string; thumbnails?: { small: Thumbnail; large: Thumbnail; full: Thumbnail; }; } interface Thumbnail { url: string; width: number; height: number; } interface Collaborator { id: string; email: string; name: string; } } }