import { RequestOptions } from '../../../../shared/app-transport/request'; import { TacoFileParserName } from '../../../../shared/enums/taco-file-parser'; import { DataRow } from '../../../../shared/types/data-row'; import { BasicHandlerInput, FileBasedHandlerInput } from '../../../../shared/types/handler-input'; import { HTTPMethod } from '../../../../shared/types/http'; import { Permission } from '../../../../shared/types/permission'; import { NetworkAdapter, NetworkAdapterFetchOptions } from '../../../modules/network-adapter'; import { TempDataManager } from '../../../modules/temp-data-manager'; import SandboxVM from '../../sandbox-vm'; import { SandboxPlugin } from '../sandbox-plugin'; /** * Request options for fetchJson and fetchArrayBuffer */ export interface FetchRequestOptions extends RequestOptions { /** HTTP method, GET or POST. Default value is GET. */ method?: Extract; /** * Request body. * * When an object is provided for body, it will be serialized into JSON string by default. * When application/x-www-form-urlencoded header is provided, the object will be serialized as query params. */ body?: string | object; } export interface LoadDataOptions extends RequestOptions { headers?: Record; method?: Extract; body?: string | object; } export interface LoadCsvDataOptions extends LoadDataOptions { /** * If this attribute is set to true, it will remove subsequent column headers from next chunk before writing to disk */ trimColumnHeader?: boolean; } /** * The type for the request options of {@link FetchUtils.fetchJson}. */ export type FetchJsonOptions = FetchRequestOptions; /** * The type for the request options of {@link FetchUtils.fetchArrayBuffer}. */ export type FetchArrayBufferOptions = FetchRequestOptions; export type fetchJsonType = ReturnType['createFetchJson']>; export type fetchArrayBufferType = ReturnType['createFetchArrayBuffer']>; export type loadCsvDataType = ReturnType['createLoadCsvData']>; export type loadExcelDataType = ReturnType['createLoadExcelData']>; export type loadParquetDataType = ReturnType['createLoadParquetData']>; export type ingestDataRowsType = ReturnType['createIngestDataRows']>; type FetchUtilsPluginConfig = { extractorId: string; permission: Permission; } | { extractorId: string; permission: Permission; handlerInput: BasicHandlerInput | FileBasedHandlerInput; } | { extractorId: string; permission: Permission; tableName: string; }; interface FetchUtilsPluginState { parser?: TacoFileParserName; } export declare class FetchUtilsPlugin extends SandboxPlugin { private config; private networkAdapter; private tempDataManager; readonly state: FetchUtilsPluginState; private extractorId; private permission; constructor(config: FetchUtilsPluginConfig, networkAdapter: NetworkAdapter, tempDataManager: TempDataManager); getState(): Readonly; registerClass(sandbox: SandboxVM): void; private createFetchJson; private createFetchArrayBuffer; private createLoadData; private createLoadExcelData; private createLoadCsvData; private createLoadParquetData; private createIngestDataRows; private setParser; } export declare function fetchJson(networkAdapter: NetworkAdapter, url: string, options?: FetchJsonOptions): Promise; export declare function fetchArrayBuffer(networkAdapter: NetworkAdapter, url: string, options?: FetchArrayBufferOptions): Promise; export declare function loadCsvData(extractorId: string, fileName: string, tempDataManager: TempDataManager, networkAdapter: NetworkAdapter, url: string, options?: LoadCsvDataOptions): Promise; export declare function loadData(extractorId: string, fileName: string, tempDataManager: TempDataManager, networkAdapter: NetworkAdapter, url: string, options?: LoadDataOptions): Promise; export declare function loadParquetData(extractorId: string, fileName: string, tempDataManager: TempDataManager, networkAdapter: NetworkAdapter, tableFileCounter: Record, url: string, options?: LoadDataOptions): Promise; /** * Using HandlerInput for now because we are getting HandlerInput via sandbox during runtime, and the type is HandlerInput. * When we export the API from SDK we should use FileBasedHandlerInput instead. */ export declare function ingestDataRows(extractorId: string, fileName: string, tempDataManager: TempDataManager, rows: DataRow[]): Promise; export declare function getFetchParams(urlString: string, options: LoadDataOptions | FetchRequestOptions | undefined): { urlWithQuery: string; options: NetworkAdapterFetchOptions; }; export {};