DefinitelyTyped/types/airtable/index.d.ts
Brandon Valosek e168859f8e [airtable] new package - airtable npm module (Airtable JS API) (#34119)
* [airtable] initialized airtable module and basic types

* [airtable] added FieldSet interface for constraining shape of Rows

* [airtable] using export =, other types in namespace, all in global
2019-03-25 09:52:00 -07:00

63 lines
1.5 KiB
TypeScript

// Type definitions for airtable 0.5
// Project: https://github.com/airtable/airtable.js
// Definitions by: Brandon Valosek <https://github.com/bvalosek>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
export = Airtable;
declare global {
class Airtable {
base(appId: string): Airtable.Base;
}
namespace Airtable {
interface FieldSet {
[ key: string ]: undefined | string | ReadonlyArray<Attachment>;
}
interface Base {
(tableName: string): Table<{}>;
}
interface Table<TFields extends FieldSet> {
select(opt?: SelectOptions): Query<TFields>;
}
interface SelectOptions {
view?: string;
}
interface Query<TFields extends object> {
all(): Promise<Response<TFields>>;
firstPage(): Promise<Response<TFields>>;
}
type Response<TFields> = ReadonlyArray<Row<TFields>>;
interface Row<TFields> {
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;
}
}
}