mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* [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
63 lines
1.5 KiB
TypeScript
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;
|
|
}
|
|
}
|
|
}
|