@equinor/fusion-query
Version:
Reactive data fetching and caching library with observable streams and comprehensive event system
150 lines (149 loc) • 6.09 kB
TypeScript
import { type ActionInstanceMap } from '@equinor/fusion-observable';
import type { ActionTypes } from '@equinor/fusion-observable';
import type { QueryClientResult, RetryOptions } from './types';
declare const createActions: <TType, TArgs>() => {
/**
* Action to initiate a request.
*
* @param args - The arguments for the request.
* @param options - Optional parameters including a reference and retry options.
* @returns An action with the request details and metadata.
*/
request: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[args: TArgs, options?: {
ref?: string;
retry?: Partial<RetryOptions>;
} | undefined], {
args: TArgs;
options: {
ref?: string;
retry?: Partial<RetryOptions>;
} | undefined;
}, "client/request", never, {
transaction: string;
created: number;
}>;
/**
* Async action to execute a request.
*
* @param transaction - The unique identifier for the transaction.
* @returns An async action with the transaction details and metadata.
*/
execute: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[transaction: string], string, "client/execute::request", never, {
transaction: string;
created: number;
}> & {
success: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[result: QueryClientResult<TType, TArgs>], QueryClientResult<TType, TArgs>, "client/execute::success", never, {
transaction: string;
created: number;
}>;
failure: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[error: Error, transaction: string], {
error: Error;
}, "client/execute::failure", never, {
transaction: string;
created: number;
}>;
};
/**
* Action to cancel a request.
*
* @param transaction - The unique identifier for the transaction to cancel.
* @param reason - Optional reason for cancellation.
* @returns An action with the cancellation details and metadata.
*/
cancel: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[transaction: string, reason?: string | undefined], {
transaction: string;
reason: string | undefined;
}, "client/cancel", never, {
transaction: string;
created: number;
}>;
/**
* Action to report an error.
*
* @param transaction - The unique identifier for the transaction that errored.
* @param error - The error that occurred.
* @returns An action with the error details and metadata.
*/
error: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[transaction: string, error: unknown], {
transaction: string;
error: unknown;
}, "client/error", never, {
transaction: string;
created: number;
}>;
};
export declare const actions: {
/**
* Action to initiate a request.
*
* @param args - The arguments for the request.
* @param options - Optional parameters including a reference and retry options.
* @returns An action with the request details and metadata.
*/
request: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[args: unknown, options?: {
ref?: string;
retry?: Partial<RetryOptions>;
} | undefined], {
args: unknown;
options: {
ref?: string;
retry?: Partial<RetryOptions>;
} | undefined;
}, "client/request", never, {
transaction: string;
created: number;
}>;
/**
* Async action to execute a request.
*
* @param transaction - The unique identifier for the transaction.
* @returns An async action with the transaction details and metadata.
*/
execute: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[transaction: string], string, "client/execute::request", never, {
transaction: string;
created: number;
}> & {
success: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[result: QueryClientResult<unknown, unknown>], QueryClientResult<unknown, unknown>, "client/execute::success", never, {
transaction: string;
created: number;
}>;
failure: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[error: Error, transaction: string], {
error: Error;
}, "client/execute::failure", never, {
transaction: string;
created: number;
}>;
};
/**
* Action to cancel a request.
*
* @param transaction - The unique identifier for the transaction to cancel.
* @param reason - Optional reason for cancellation.
* @returns An action with the cancellation details and metadata.
*/
cancel: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[transaction: string, reason?: string | undefined], {
transaction: string;
reason: string | undefined;
}, "client/cancel", never, {
transaction: string;
created: number;
}>;
/**
* Action to report an error.
*
* @param transaction - The unique identifier for the transaction that errored.
* @param error - The error that occurred.
* @returns An action with the error details and metadata.
*/
error: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[transaction: string, error: unknown], {
transaction: string;
error: unknown;
}, "client/error", never, {
transaction: string;
created: number;
}>;
};
export type ActionBuilder<TType = any, TArgs = any> = ReturnType<typeof createActions<TType, TArgs>>;
export type ActionMap<TType = any, TArgs = any> = ActionInstanceMap<ActionBuilder<TType, TArgs>>;
export type Actions<TType = any, TArgs = any> = ActionTypes<ActionMap<TType, TArgs>>;
export default actions;