| 27 | export type AirtableRunTask = InstanceType<typeof Airtable>["runTask"]; |
| 28 | |
| 29 | export class Airtable implements TriggerIntegration { |
| 30 | // @internal |
| 31 | private _options: AirtableIntegrationOptions; |
| 32 | // @internal |
| 33 | private _client?: AirtableSDK; |
| 34 | // @internal |
| 35 | private _io?: IO; |
| 36 | // @internal |
| 37 | private _connectionKey?: string; |
| 38 | |
| 39 | constructor(options: Prettify<AirtableIntegrationOptions>) { |
| 40 | if (Object.keys(options).includes("token") && !options.token) { |
| 41 | throw `Can't create Airtable integration (${options.id}) as token was passed in but undefined`; |
| 42 | } |
| 43 | |
| 44 | this._options = options; |
| 45 | } |
| 46 | |
| 47 | get authSource() { |
| 48 | return this._options.token ? ("LOCAL" as const) : ("HOSTED" as const); |
| 49 | } |
| 50 | |
| 51 | get id() { |
| 52 | return this._options.id; |
| 53 | } |
| 54 | |
| 55 | get metadata() { |
| 56 | return { id: "airtable", name: "Airtable" }; |
| 57 | } |
| 58 | |
| 59 | get source() { |
| 60 | return createWebhookSource(this); |
| 61 | } |
| 62 | |
| 63 | cloneForRun(io: IO, connectionKey: string, auth?: ConnectionAuth) { |
| 64 | const airtable = new Airtable(this._options); |
| 65 | airtable._io = io; |
| 66 | airtable._connectionKey = connectionKey; |
| 67 | airtable._client = this.createClient(auth); |
| 68 | return airtable; |
| 69 | } |
| 70 | |
| 71 | createClient(auth?: ConnectionAuth) { |
| 72 | if (auth) { |
| 73 | return new AirtableSDK({ |
| 74 | apiKey: auth.accessToken, |
| 75 | }); |
| 76 | } |
| 77 | |
| 78 | if (this._options.token) { |
| 79 | return new AirtableSDK({ |
| 80 | apiKey: this._options.token, |
| 81 | }); |
| 82 | } |
| 83 | |
| 84 | throw new Error("No auth"); |
| 85 | } |
| 86 |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…