| 37 | export type TypeformRunTask = InstanceType<typeof Typeform>["runTask"]; |
| 38 | |
| 39 | export class Typeform implements TriggerIntegration { |
| 40 | // @internal |
| 41 | private _options: TypeformIntegrationOptions; |
| 42 | // @internal |
| 43 | private _client?: TypeformSDK; |
| 44 | // @internal |
| 45 | private _io?: IO; |
| 46 | // @internal |
| 47 | private _connectionKey?: string; |
| 48 | |
| 49 | constructor(private options: TypeformIntegrationOptions) { |
| 50 | this._options = options; |
| 51 | } |
| 52 | |
| 53 | get authSource() { |
| 54 | return "LOCAL" as const; |
| 55 | } |
| 56 | |
| 57 | get id() { |
| 58 | return this.options.id; |
| 59 | } |
| 60 | |
| 61 | get metadata() { |
| 62 | return { id: "typeform", name: "Typeform" }; |
| 63 | } |
| 64 | |
| 65 | cloneForRun(io: IO, connectionKey: string, auth?: ConnectionAuth) { |
| 66 | const token = this._options.token ?? auth?.accessToken; |
| 67 | |
| 68 | if (!token) { |
| 69 | throw new Error( |
| 70 | `Can't initialize Typeform integration (${this._options.id}) as token was undefined` |
| 71 | ); |
| 72 | } |
| 73 | |
| 74 | const typeform = new Typeform(this._options); |
| 75 | typeform._io = io; |
| 76 | typeform._connectionKey = connectionKey; |
| 77 | typeform._client = createClient({ token }); |
| 78 | return typeform; |
| 79 | } |
| 80 | |
| 81 | runTask<T, TResult extends Json<T> | void>( |
| 82 | key: IntegrationTaskKey, |
| 83 | callback: (client: TypeformSDK, task: IOTask, io: IO) => Promise<TResult>, |
| 84 | options?: RunTaskOptions, |
| 85 | errorCallback?: RunTaskErrorCallback |
| 86 | ): Promise<TResult> { |
| 87 | if (!this._io) throw new Error("No IO"); |
| 88 | if (!this._connectionKey) throw new Error("No connection key"); |
| 89 | return this._io.runTask( |
| 90 | key, |
| 91 | (task, io) => { |
| 92 | if (!this._client) throw new Error("No client"); |
| 93 | return callback(this._client, task, io); |
| 94 | }, |
| 95 | { |
| 96 | icon: "typeform", |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…