UNPKG

@tableau/taco-toolkit

Version:
40 lines (39 loc) 1.44 kB
/// <reference types="node" /> import https from 'node:https'; import { RequestInit, Response } from 'node-fetch'; import { HTTPMethod } from '../../shared/types/http'; import { NetworkProtocol } from './network-adapter-utils/types'; /** * The options to init NetworkAdapter */ export interface NetworkAdapterOptions { protocols: NetworkProtocol[]; allowLocalhost: boolean; httpProxy?: string; caCertPath?: string; } /** * The type for fetchOptions to perform the NetworkAdapter.fetch call. * It is a subset type of FetchOptionsParam for NetworkAdapter.fetch. * * The type is normally used for the result of converted request inputs from * different shapes, e.g. LoadDataOptions, FetchRequestOptions. */ export interface NetworkAdapterFetchOptions { method: Extract<HTTPMethod, 'GET' | 'POST'>; headers?: Record<string, string>; body?: string; } /** * The type for options parameter of NetworkAdapter.fetch */ type FetchOptionsParam = Pick<RequestInit, 'body' | 'headers' | 'method'>; export declare class NetworkAdapter { private readonly httpsAgent; private readonly ruleEngine; constructor(options: NetworkAdapterOptions); fetch(url: string, options: FetchOptionsParam): Promise<Response>; } type HttpsAgentConfig = Pick<NetworkAdapterOptions, 'httpProxy' | 'caCertPath'>; export declare function createHttpsAgent(options: HttpsAgentConfig): https.Agent | undefined; export {};