import { ActionMove, ComputedQuery, FiltersMap } from '../model';
import { IObservableArray } from 'mobx';
import { CollectionState } from './CollectionState';
import { Order } from './QueryResultSimulation';
import { CollectionOptimisticActionsState } from './CollectionOptimisticActionsState';
import { CollectionOptimisticProcessor } from './CollectionOptimisticProcessor';
import { OptimisticPatch } from './CollectionOptimisticPatch';
import { CollectionOptimisticExecutor } from './CollectionOptimisticExecutor';
import { TypedEmitter } from '../util';
import { QueryResultSimulationDefault } from './QueryResultSimulationDefault';
import { CollectionOptimisticSequenceExecutor } from './CollectionOptimisticSequenceExecutor';
import { ModalLayoutProps } from '../services';
import { QueryState } from './QueryState';
import { CreateManyParams, DeleteManyParams, OptimisticActionBasis, OptimisticActions, UpdateAllParams, UpdateManyParams } from './OptimisticActions';
export interface MoveParams<T, R> extends OptimisticActionBasis {
    /**
     * Function to submit the move operation.
     * @param params - The parameters for the move action.
     */
    submit?: (params: ActionMove<T>) => Promise<R>;
    /**
     * Snapshot of the collection before the move operation.
     */
    collectionSnapshot: {
        [key: string]: string | number | undefined;
    };
}
export interface CollectionOptimisticActionsBaseParams<T, F extends FiltersMap> {
    /**
     * A function that simulates the filtering in the server.
     * The function should return another function that accepts an item, and return a boolean that indicates whether the item passes the query filters or not.
     * @param computedQuery - The computed query object.
     * @external
     */
    readonly predicate?: (computedQuery: ComputedQuery<F>) => (item: T) => boolean;
    /**
     * A function that simulates the ordering of the items in the server.<br>
     * The function should return a list of rules in the form of `{fieldName: string; order: 'asc' | 'desc';}` to order the items by
     * @param computedQuery - The computed query object.
     * @external
     */
    readonly orderBy?: (computedQuery: ComputedQuery<F>) => Order<T>[];
    /**
     * A function to retrieve the creation date of an item.
     * @param item - The item.
     * @external
     */
    readonly createdAt?: (item: T) => Date;
    /**
     * Time to wait before batching multiple `updateMany` calls into a single server call.
     * @default 0
     * @external
     */
    readonly batchWait?: number;
    /**
     * Indicates whether to refresh the current page without invalidating the cache.
     * @external
     */
    readonly noInvalidate?: boolean;
    /**
     * Adds a namespace to the cache key.
     * @external
     */
    readonly cacheNamespace?: string;
    readonly sequences?: Map<string, CollectionOptimisticSequenceExecutor>;
    readonly query?: QueryState<F>;
}
export interface CollectionOptimisticActionsParams<T, F extends FiltersMap> extends CollectionOptimisticActionsBaseParams<T, F> {
    /**
     * The main collection to reflect changes into.
     * @external
     */
    readonly collection: CollectionState<T, F>;
    /**
     * Additional collections to reflect changes into.
     * @default undefined
     * @external
     */
    readonly collections?: CollectionState<T, F>[];
    /**
     * Container holding patches cache and events emitter.
     * @external
     */
    readonly container: {
        patchesCache: Map<string, IObservableArray<OptimisticPatch<T>>>;
        events: TypedEmitter<{
            navigation: () => ModalLayoutProps | null | undefined;
        }>;
    };
}
export declare class CollectionOptimisticActions<T, F extends FiltersMap> implements OptimisticActions<T> {
    readonly collection: CollectionState<T, F>;
    readonly query: QueryState<F>;
    readonly collections: CollectionState<T, F>[];
    readonly predicate: (computedQuery: ComputedQuery<F>) => (item: T) => boolean;
    readonly orderBy: (computedQuery: ComputedQuery<F>) => Order<T>[];
    readonly createdAt?: (item: T) => Date;
    readonly events: TypedEmitter<{
        reprocess: () => void;
        updated: () => void;
        refresh: (params: {
            isStale: boolean;
        }) => void;
        unmount: () => void;
        beforeResultUpdated: () => void;
        dragAndDropSequenceError: (params: {
            patches: OptimisticPatch<T>[];
        }) => void;
        dragAndDropSequenceRetry: (params: {
            patches: OptimisticPatch<T>[];
        }) => void;
    }>;
    readonly noInvalidate: boolean | undefined;
    readonly state: CollectionOptimisticActionsState<T>;
    readonly processors: CollectionOptimisticProcessor<T, F>[];
    readonly executor: CollectionOptimisticExecutor<OptimisticPatch<T>>;
    readonly sequences: Map<string, CollectionOptimisticSequenceExecutor>;
    readonly resultSimulationDefault: QueryResultSimulationDefault<T, F>;
    readonly reorderModeCanceledMessage = "REORDER_MODE_CANCELED";
    _resumeNavigation: (() => void) | null;
    _orderByMode: 'orders' | 'moves';
    _commitMode: boolean;
    constructor(params: CollectionOptimisticActionsParams<T, F>);
    get _queryNames(): string[];
    get hasRunningSequence(): boolean;
    get pendingMovePatches(): OptimisticPatch<T>[];
    rollback(patch: OptimisticPatch<T> | OptimisticPatch<T>[]): void;
    private _clearPatch;
    _clearPatchOnNextResultOrUnmount: (patch: OptimisticPatch<T>) => void;
    pushPatchAndReprocess(patch: OptimisticPatch<T> | OptimisticPatch<T>[]): void;
    replacePatchAndReprocess(newPatch: OptimisticPatch<T>, oldPatch: OptimisticPatch<T>): void;
    createOne(item: T, params: CreateManyParams<T>): void;
    createMany(items: T[], params: CreateManyParams<T>): void;
    /**
     * Updates multiple items in the collection.
     * @param items - The items to update.
     * @param params - Additional parameters for the update operation.
     * @external
     */
    updateMany<R>(items: T[], params: UpdateManyParams<T, R>): void;
    enqueueMovePatch<R>(optimisticPatch: OptimisticPatch<T>, params: MoveParams<T, R>): void;
    move<R>(event: ActionMove<T>, params: MoveParams<T, R>): Promise<void>;
    /**
     * Updates a single item in the collection.
     * @param item - The item to update.
     * @param params - Additional parameters for the operation.
     * @external
     */
    updateOne<R>(item: T, params: UpdateManyParams<T, R>): void;
    /**
     * > `updateAll(fn)` API is not recommended as it's not possible to calculate "optimistic total", prefer updateAll(patchObject) API if possible.
     * Updates all items in the collection based on a function or a patch object.
     * @param patchOrFn - A function or a patch object to apply to each item.
     * @param params - Additional parameters for the operation.
     */
    updateAll<R>(patchOrFn: (item: T) => Partial<T>, params: UpdateAllParams<R>): void;
    /**
     * Updates all items in the collection based on a patch object.
     * @param patch - A patch object to apply to each item.
     * @param params - Additional parameters for the operation.
     * @external
     */
    updateAll<R>(patch: Partial<T>, params: UpdateAllParams<R>): void;
    /**
     * Deletes multiple items from the collection.
     * @param items - An array of items to delete.
     * @param params - Additional parameters for the delete operation.
     * @external
     */
    deleteMany<R>(items: T[], params: DeleteManyParams<T, R>): void;
    /**
     * Deletes a single item from the collection.
     * @param item - The item to delete.
     * @param params - Additional parameters for the operation.
     * @external
     */
    deleteOne<R>(item: T, params: DeleteManyParams<T, R>): void;
    /**
     * Deletes all items from the collection.
     * @param params - Additional parameters for the operation.
     * @external
     */
    deleteAll<R>(params: UpdateAllParams<R>): void;
    initCollection(collection: CollectionState<T, F>): () => void;
    init(): () => void;
    clear(): void;
}
//# sourceMappingURL=CollectionOptimisticActions.d.ts.map