UNPKG

dcl-catalyst-commons

Version:

Common tools and types to share between catalyst servers and clients

59 lines (58 loc) 2.97 kB
/// <reference types="node" /> import { CompleteRequestOptions, RequestOptions } from './FetcherConfiguration'; /** @deprecated use well-known-components fetcher instead */ export declare class Fetcher { customDefaults: Omit<RequestOptions, 'body'>; constructor(customDefaults?: Omit<RequestOptions, 'body'>); overrideDefaults(overrideDefaults: Omit<RequestOptions, 'body'>): void; fetch(url: string, options?: Partial<CompleteRequestOptions>): Promise<Response>; /** * @deprecated please use Fetcher.fetch instead */ fetchJson(url: string, options?: RequestOptions): Promise<unknown>; /** * @deprecated please use Fetcher.fetch instead */ fetchBuffer(url: string, options?: RequestOptions): Promise<Buffer>; /** * Fetches the url and pipes the response obtained from the upstream to the `writeTo` Stream and * returns the headers from the upstream request. * IMPORTANT: THIS METHOD DOES NOT AWAIT THE PIPE TO FINISH. THE PROMISE FULFILLS RIGHT AFTER WE RECEIVE THE HEADERS. * @param url to request * @param writeTo the stream to pipe the response to * @param options config for the request * @deprecated please use Fetcher.fetch instead */ fetchPipe(url: string, writeTo: any, options?: RequestOptions): Promise<Headers>; /** * @deprecated please use Fetcher.fetch instead */ postForm(url: string, options?: RequestOptions): Promise<unknown>; queryGraph<T = any>(url: string, query: string, variables: Record<string, any>, options?: RequestOptions): Promise<T>; clone(): Fetcher; } /** @deprecated use well-known-components fetcher instead */ export declare function fetchJson(url: string, options?: RequestOptions): Promise<unknown>; /** @deprecated use well-known-components fetcher instead */ export declare function fetchArrayBuffer(url: string, options?: RequestOptions): Promise<Uint8Array>; /** * @deprecated use fetchArrayBuffer instead */ export declare function fetchBuffer(url: string, options?: RequestOptions): Promise<Buffer>; /** * Fetches the url and pipes the response obtained from the upstream to the `writeTo` Stream and * returns the headers from the upstream request. * IMPORTANT: THIS METHOD DOES NOT AWAIT THE PIPE TO FINISH. THE PROMISE FULFILLS RIGHT AFTER WE RECEIVE THE HEADERS. * @param url to request * @param writeTo the stream to pipe the response to * @param options config for the request * @deprecated */ export declare function fetchPipe(url: string, writeTo: any, options?: RequestOptions): Promise<Headers>; export declare function postForm(url: string, options?: RequestOptions): Promise<unknown>; export declare type GraphQLResponse = { errors: any[]; data: any; }; /** @deprecated use well-known-components thegraph-component instead */ export declare function queryGraph<T = any>(url: string, query: string, variables: Record<string, any>, options?: RequestOptions): Promise<T>;