import type { Args, ICommand, ICommandAgent, ICommandConfig, TPackedCommand } from "../../../query/types/index.js"; import { QueryCacheEntry } from "../cache/QueryCacheEntry.js"; /** * Abstraction for write operations (mutations). * * Manages cache entries, link-based optimistic/update patches on related resources, * and lifecycle hooks (`onCacheEntryAdded`, `onQueryStarted`). * * @template TArgs - The argument type accepted by the mutation. * @template TData - The data type returned by the mutation. * * @see {@link https://github.com/AcademyCity/rx-toolkit/blob/main/docs/query/api/command.md | Command API docs} */ export declare class Command implements ICommand { private readonly _cache; private readonly _queryFn; readonly _key: string | undefined; private readonly _linkManager; private readonly _retentionTime; private readonly _generateRequestId; private readonly _mapError; private readonly _onCacheEntryAdded; private readonly _onQueryStarted; private _keyCounter; constructor(config: ICommandConfig); /** * Imperatively execute the mutation. * * Applies optimistic patches, runs `queryFn`, then commits/rolls-back * patches and invalidates linked resources on success/failure. * * @param argsOrKeyed - Plain arguments or a {@link Keyed} wrapper. * @param key - Optional cache-entry key. Auto-generated when omitted. * @returns A promise that resolves with the mutation result. Every * rejection is normalized via `mapError` — including the * `CacheEntryRemovedError` produced when the entry is evicted mid-flight * (re-execute with the same key, `reset()` / `resetAll()`). */ execute(argsOrKeyed: Args, key?: string): Promise; /** * @deprecated Renamed to {@link execute} (identical contract). Will be * removed in a future release. */ trigger(argsOrKeyed: Args, key?: string): Promise; private _execute; /** * Synchronously retrieve a cache entry by key. * * @param key - The cache-entry key. * @returns The matching {@link QueryCacheEntry}, or `null` if none exists. */ getEntry(key: string): QueryCacheEntry | null; /** * Reactive variant of {@link getEntry}. * * Reads an internal signal so that callers in a reactive context * (e.g. `computed`, `effect`) re-evaluate when the cache changes. * * @param key - The cache-entry key. * @returns The matching {@link QueryCacheEntry}, or `null` if none exists. */ getEntry$(key: string): QueryCacheEntry | null; /** * Create a reactive agent that observes this command's state. * * @param key - Optional key to bind the agent to a specific cache entry. * @returns A new {@link ICommandAgent} instance. */ createAgent(key?: string): ICommandAgent; /** * Bundle this command with arguments (and an optional cache key) into an inert * {@link TPackedCommand} descriptor. Nothing is executed — the consumer hands * the descriptor back to the library, which can later run it * (e.g. `command.execute(args, key)`). * * @param args - Mutation arguments (or a {@link Keyed} wrapper). * @param key - Optional cache-entry key, forwarded to {@link execute}. * @returns A `{ kind: "command", command, args, key }` descriptor. */ pack(args: Args, key?: string): TPackedCommand; /** Clear all cache entries. Called by createApi.resetAll(). */ reset(): void; private _generateKey; private _toKeyed; private _fireOnCacheEntryAdded; private _fireOnQueryStarted; }