import type { SagaIterator } from 'redux-saga'; import type { Action, ApiCtx, Next, PipeCtx, LoaderCtx } from './types'; /** * This middleware will catch any errors in the pipeline * and return the context object. */ export declare function errorHandler(ctx: Ctx, next: Next): Generator; /** * This middleware sets up the context object with some values that are * necessary for {@link createApi} to work properly. */ export declare function queryCtx(ctx: Ctx, next: Next): Generator; /** * This middleware converts the name provided to {@link createApi} into data for the fetch request. */ export declare function urlParser(ctx: Ctx, next: Next): Generator; /** * This middleware will take the result of `ctx.actions` and dispatch them * as a single batch. * * @remarks This is useful because sometimes there are a lot of actions that need dispatched * within the pipeline of the middleware and instead of dispatching them serially this * improves performance by only hitting the reducers once. */ export declare function dispatchActions(ctx: { actions: Action[]; }, next: Next): Generator; /** * This middleware creates a loader for a generator function which allows us to track * the status of a pipeline function. */ export declare function loadingMonitorSimple(ctx: Ctx, next: Next): Generator; /** * This middleware will track the status of a fetch request. */ export declare function loadingMonitor(errorFn?: (ctx: Ctx) => string): (ctx: Ctx, next: Next) => Generator; export interface UndoCtx

extends ApiCtx { undoable: boolean; } export declare const doIt: { (): { type: string; }; toString(): string; }; export declare const undo: { (): { type: string; }; toString(): string; }; /** * This middleware will allow pipeline functions to be undoable which means before they are activated * we have a timeout that allows the function to be cancelled. */ export declare function undoer(doItType?: string, undoType?: string, timeout?: number): (ctx: Ctx, next: Next) => SagaIterator; export interface OptimisticCtx extends ApiCtx { optimistic: { apply: A; revert: R; }; } /** * This middleware performs an optimistic update for a middleware pipeline. * It accepts an `apply` and `revert` action. * * @remarks This means that we will first `apply` and then if the request is successful we * keep the change or we `revert` if there's an error. */ export declare function optimistic = OptimisticCtx>(ctx: Ctx, next: Next): Generator; /** * This middleware will automatically cache any data found inside `ctx.json` * which is where we store JSON data from the `fetcher` middleware. */ export declare function simpleCache(ctx: Ctx, next: Next): SagaIterator; /** * This middleware allows the user to override the default key provided to every pipeline function * and instead use whatever they want. * * @example * ```ts * import { createPipe } from 'saga-query'; * * const thunk = createPipe(); * thunk.use(customKey); * * const doit = thunk.create('some-action', function*(ctx, next) { * ctx.key = 'something-i-want'; * }) * ``` */ export declare function customKey(ctx: Ctx, next: Next): Generator; /** * This middleware is a composition of many middleware used to faciliate the {@link createApi} */ export declare function requestMonitor(errorFn?: (ctx: Ctx) => string): (context: Ctx, next?: import("./types").Middleware> | undefined) => SagaIterator; export interface PerfCtx

extends PipeCtx

{ performance: number; } /** * This middleware will add `performance.now()` before and after your middleware pipeline. */ export declare function performanceMonitor(ctx: Ctx, next: Next): Generator; /** * This middleware will call the `saga` provided with the action sent to the middleware pipeline. */ export declare function wrap(saga: (...args: any[]) => any): (ctx: Ctx, next: Next) => Generator;