import { ToastConfig } from '../model';
import { EventuallyUpdated } from './CollectionOptimisticExecutor';
import { DeepPartial } from '../types/DeepPartial';
export interface OptimisticActionBasis {
    /**
     * Determines whether to display an undo toast before calling the server action.
     * @default false
     * @external
     */
    showUndoToast?: boolean;
    /**
     * Determines whether to display a toast after clicking on undo.
     * @default false
     * @external
     */
    showUndoSuccessToast?: boolean;
    /**
     * Callback function triggered when the user clicks on the undo button.
     * @external
     */
    onUndo?: () => void;
    /**
     * Function to generate error toast to show in case the server fails to perform the action.
     * @external
     */
    errorToast?: (err: unknown, params: {
        retry: () => void;
    }) => ToastConfig | string;
    /**
     * Callback function triggered when an error occurs.
     * @external
     */
    onError?: (err: unknown) => void;
    /**
     * Callback function to retry the action.
     * @deprecated Use the prop `errorToast={(err, {retry}) => { action:{onClick: () {retry();} }}}` instead.
     */
    onTryAgain?: () => void | Promise<void>;
    /**
     * Toast message or configuration to show on successful action.
     * @external
     */
    successToast?: ToastConfig | string;
    /**
     * Indicates when the server is eventually updated.
     * Possible values:
     *   - submit: Server updates immediately after the submission promise resolves.
     *   - number: Server updates after a specified timeout (in milliseconds).
     *   - Promise: Server updates after a forwarded promise resolves.
     * @default submit
     * @external
     */
    updateServerAfter?: EventuallyUpdated;
}
export interface CreateManyParams<T> extends OptimisticActionBasis {
    /**
     * Function to submit the creation operation.
     * @param items - The items to create.
     */
    submit: (items: T[]) => Promise<T[] | null | undefined | void>;
    /**
     * The key of the item after which to insert the created items.
     * If not provided, items are inserted at the beginning.
     * @external
     */
    afterItemKey?: string;
}
export interface UpdateManyParams<T, R> extends OptimisticActionBasis {
    /**
     * Function to submit the update operation.
     * @param items - The items to update.
     */
    submit: (items: T[]) => Promise<R>;
    /**
     * Indicates whether to keep the current position of items after the update.
     */
    keepPosition?: boolean;
    /**
     * Partial data to patch the items with.
     */
    patch?: DeepPartial<T>;
}
export interface UpdateAllParams<R> extends OptimisticActionBasis {
    /**
     * Function to submit the update operation.
     */
    submit: () => Promise<R>;
    /**
     * Indicates whether to keep the current position of items after the update.
     */
    keepPosition?: boolean;
}
export interface DeleteManyParams<T, R> extends OptimisticActionBasis {
    /**
     * Function to submit the deletion operation.
     * @param items - The items to delete.
     */
    submit: (items: T[]) => Promise<R>;
}
export interface DeleteAllParams<R> extends OptimisticActionBasis {
    /**
     * Function to submit the deletion operation.
     */
    submit: () => Promise<R>;
}
export interface OptimisticActions<T> {
    /**
     * Creates a single item in the collection.
     * @param item - The item to create.
     * @param params - Additional parameters for the operation.
     * @external
     */
    createOne(item: T, params: CreateManyParams<T>): void;
    /**
     * Creates multiple items in the collection.
     * @param items - The items to create.
     * @param params - Additional parameters for the operation.
     * @external
     */
    createMany(items: T[], params: CreateManyParams<T>): void;
    updateMany<R>(items: T[], params: UpdateManyParams<T, R>): void;
    updateOne<R>(item: T, params: UpdateManyParams<T, R>): void;
    updateAll<R>(patchOrFn: (item: T) => Partial<T>, params: UpdateAllParams<R>): void;
    deleteMany<R>(items: T[], params: DeleteManyParams<T, R>): void;
    deleteOne<R>(item: T, params: DeleteManyParams<T, R>): void;
    deleteAll<R>(params: UpdateAllParams<R>): void;
}
//# sourceMappingURL=OptimisticActions.d.ts.map