Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/request / dist / TwoRequest.d.ts
Size: Mime:
/**
 * @todo - should add .env logging
 */
import './deps/polyfill';
import { HTTPCache } from 'apollo-datasource-rest';
import { OneRequestApolloDataSource } from './adapters/apollo';
import { RequestBody, Params, Method, Credentials, CommonChildren, OneRequestStore, OneRequestObj, HeadersObj, TransformParams, TransformResponse, OneRequestAdapter, OneRequestAsSerializedDebug, OneRequestContextBase, ResponseExtended } from './typings';
/**
 * @todo add a way to set the adapter so we can specify for cases like viewbag?
 */
declare class OneRequest<Context extends OneRequestContextBase = OneRequestContextBase> {
    static init(args?: OneRequestObj): OneRequest<OneRequestContextBase>;
    store: OneRequestStore;
    private _parent?;
    private _children?;
    constructor();
    setUrl(url: string): this;
    setMethod(method: Method): this;
    setDefaultParams(params?: any): this;
    setParamsTransform(): this;
    setMock(mock?: any): this;
    setFixture(mock?: any): this;
    setData(data?: any): this;
    toMock(data?: any): Promise<import("./typings").ResponseDataOut>;
    setDebug(shouldDebug?: boolean): this;
    from(obj?: OneRequestObj): this;
    named(named: string): this;
    debug(shouldDebug: boolean): this;
    toJSON(): OneRequestAsSerializedDebug;
    parent(parent: OneRequest): this;
    children(): CommonChildren;
    child(childName: string): OneRequest<OneRequestContextBase>;
    /**
     * @todo validate url...
     */
    url(absoluteUrl: string): this;
    baseUrl(baseUrl: string): this;
    basePath(basePath: string): this;
    path(path?: string): this;
    params(params: Params): this;
    body(body: RequestBody): this;
    tapRequestParams(tapParams: TransformParams): this;
    tapResponseData(tapResponse: TransformResponse): this;
    post(): this;
    get(): this;
    patch(): this;
    delete(): this;
    method(method: Method): this;
    httpCache: HTTPCache;
    context: Context;
    /**
     * @todo `ttl`?
     */
    cache(value: string | false): this;
    /**
     * @todo should weakmap this...
     */
    toApollo(): OneRequestApolloDataSource;
    /**
     * @see https://github.com/apollographql/apollo-server/blob/2ece27d82e10c22e85ee8a679341f334a8be01e0/packages/apollo-server-core/src/requestPipeline.ts#L96
     * @see https://github.com/apollographql/apollo-server/blob/master/packages/apollo-server-core/src/runHttpQuery.ts#L343
     */
    initialize(args: {
        context: Context;
        cache: HTTPCache;
    }): this;
    /**
     * @protected
     * @todo make it settable...
     * @note - this has assign constants, which may be an issue
     *         if we are using .toRequest directly
     *         separately/instead of .doRequest
     *         - since this returns the `global.Request` for `fetch`
     */
    toRequest(): ResponseExtended<any> | OneRequestApolloDataSource;
    credentials(value?: 'include' | 'same-origin'): this;
    /**
     * same as () / .call() / .end() / .fetch() / send() / doRequest()
     */
    doRequest<ResponseType extends ResponseExtended | {
        [key: string]: any;
    } = ResponseExtended>(): Promise<ResponseType extends ResponseExtended ? ResponseExtended : ResponseExtended<ResponseType>>;
    /**
     * @alias to
     * @todo pass in adapter here like `toFetch`, `toAxios`, `toApollo`
     */
    as(adapter?: OneRequestAdapter): import("./typings").AdapterType;
    correlationId(correlationIdArg?: string): this;
    /**
     * @protected
     * @todo need typings for context which is in gql...
     */
    forwardRequest(context: Context): this;
    cookie(cookieToSet: string | string[]): this;
    header(key: string, value: string): this;
    headers(headers?: Headers | HeadersObj): this;
    deleteHeader(key: string): this;
    auth(credentials: Credentials): void;
    jwt(token: string): this;
    /**
     * @todo split to dep?
     */
    clone(): OneRequest<OneRequestContextBase>;
    /**
     * @todo should be @name .clear?
     */
    reset(): this;
    entries(): import("exotic/dist/types/obj/cast/fromCollectionToObj").CollectionAsObj<any>;
    /** @deprecated use this.store.set instead */
    private _set;
    /** @deprecated use this.store.get instead */
    private _get;
    /** @deprecated use this.store.has instead */
    private _has;
    /** @deprecated use this.store.delete instead */
    private _delete;
}
export { OneRequest };
export { OneRequest as Request };