Logos DX
    Preparing search index...

    Interface EngineConfig<H, P, S>

    Full configuration options for FetchEngine.

    This is the primary configuration interface. It's defined here independently of the FetchEngine class to avoid circular dependencies.

    Extends native fetch RequestInit to allow instance-level defaults for options like credentials, mode, cache, redirect, etc.

    interface EngineConfig<
        H = InstanceHeaders,
        P = InstanceParams,
        S = InstanceState,
    > {
        attemptTimeout?: number;
        baseUrl: string;
        cache?: RequestCache;
        cachePolicy?: boolean | CacheConfig<S, H, P>;
        cookies?: boolean | CookieConfig;
        credentials?: RequestCredentials;
        dedupePolicy?: boolean | DeduplicationConfig<S, H, P>;
        defaultType?: EngineType;
        determineType?: DetermineTypeFn;
        generateRequestId?: () => string;
        headers?: DictAndT<H>;
        integrity?: string;
        keepalive?: boolean;
        methodHeaders?: Partial<Record<_InternalHttpMethods, DictAndT<H>>>;
        methodParams?: Partial<Record<_InternalHttpMethods, Partial<DictAndT<P>>>>;
        mode?: RequestMode;
        name?: string;
        onAfterReq?: (
            response: Response,
            opts: EngineRequestConfig<H, P>,
        ) => void | Promise<void>;
        onBeforeReq?: (opts: EngineRequestConfig<H, P>) => void | Promise<void>;
        onError?: (err: FetchError<any, any>) => void | Promise<void>;
        params?: DictAndT<P>;
        plugins?: FetchPlugin<H, P, S>[];
        priority?: RequestPriority;
        rateLimitPolicy?: boolean | RateLimitConfig<S, H, P>;
        redirect?: RequestRedirect;
        referrer?: string;
        referrerPolicy?: ReferrerPolicy;
        requestIdHeader?: string;
        retry?: boolean | RetryConfig;
        spy?: (
            action: {
                context: any;
                data?: unknown;
                event: string | RegExp;
                fn: "on" | "once" | "off" | "emit" | "cleanup";
                listener?: Function | null;
            },
        ) => void;
        totalTimeout?: number;
        validate?: ValidateConfig<H, P, S>;
        window?: null;
    }

    Type Parameters

    Hierarchy (View Summary)

    Index

    Properties

    attemptTimeout?: number
    baseUrl: string

    The base URL for all requests.

    cache?: RequestCache

    A string indicating how the request will interact with the browser's cache to set request's cache.

    cachePolicy?: boolean | CacheConfig<S, H, P>

    Cache policy configuration.

    cookies?: boolean | CookieConfig

    Cookie management configuration.

    true enables a basic in-memory cookie jar with RFC 6265 defaults. Pass a CookieConfig to configure persistence adapters, limits, or domain exclusions. For full control (init/flush/jar access), use plugins: [cookiePlugin(config)] instead.

    credentials?: RequestCredentials

    A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials.

    dedupePolicy?: boolean | DeduplicationConfig<S, H, P>

    Deduplication policy configuration.

    defaultType?: EngineType

    The default type of response expected from the server.

    determineType?: DetermineTypeFn
    generateRequestId?: () => string

    Custom function to generate request IDs for tracing. When omitted, uses generateId from @logosdx/utils.

    headers?: DictAndT<H>

    The headers to be set on all requests.

    integrity?: string

    A cryptographic hash of the resource to be fetched by request. Sets request's integrity.

    keepalive?: boolean

    A boolean to set request's keepalive.

    The headers to be set on requests of a specific method.

    URL parameters to be set on requests of a specific method.

    A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode.

    name?: string

    Optional name for this FetchEngine instance.

    onAfterReq?: (
        response: Response,
        opts: EngineRequestConfig<H, P>,
    ) => void | Promise<void>
    onBeforeReq?: (opts: EngineRequestConfig<H, P>) => void | Promise<void>
    onError?: (err: FetchError<any, any>) => void | Promise<void>
    params?: DictAndT<P>

    URL parameters to be set on all requests.

    plugins?: FetchPlugin<H, P, S>[]

    Plugins to install at construction time.

    Each plugin's install() is called with the engine instance. Cleanup functions are collected and called on destroy().

    priority?: RequestPriority
    rateLimitPolicy?: boolean | RateLimitConfig<S, H, P>

    Rate limit policy configuration.

    redirect?: RequestRedirect

    A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect.

    referrer?: string

    A string whose value is a same-origin URL, "about:client", or the empty string, to set request's referrer.

    referrerPolicy?: ReferrerPolicy

    A referrer policy to set request's referrerPolicy.

    requestIdHeader?: string

    Header name for sending the request ID with every request.

    When set, each outgoing request includes this header with the generated requestId value, enabling end-to-end distributed tracing.

    const api = new FetchEngine({
    baseUrl: 'https://api.example.com',
    requestIdHeader: 'X-Request-Id'
    });
    retry?: boolean | RetryConfig
    spy?: (
        action: {
            context: any;
            data?: unknown;
            event: string | RegExp;
            fn: "on" | "once" | "off" | "emit" | "cleanup";
            listener?: Function | null;
        },
    ) => void

    Spy function that receives all event emissions.

    totalTimeout?: number
    validate?: ValidateConfig<H, P, S>

    Validators for headers, params, and state.

    window?: null

    Can only be null. Used to disassociate request from any Window.