import type { AxiosError } from 'axios'; import type { QueryKey } from '@tanstack/query-core'; import type { QueryApiOptions } from '../query.api'; import { QueryApi } from '../query.api'; import type { ComposableStore } from './decorator'; /** * Container for creating runtime queries after store initialization. * The `@queryStore` decorator auto-discovers instances and binds the store reference. * * Use `add()` to create queries on demand (e.g., in response to user actions). * Queries are automatically set up with the store's QueryClientStore and * registered for disposal when the store is disposed. * * @example * ```typescript * @queryStore * class MyStore extends Store { * private queries = setupRuntimeQueries(); * * loadDetails(id: number) { * return this.queries.add
(() => ({ * queryKey: ['details', id], * queryFn: () => this.api?.getDetails(id), * }), ['details', id]); * } * } * ``` */ export declare class RuntimeQueries { /** @internal Bound by `@queryStore` decorator during initialize(). */ composableStore?: ComposableStore; /** * Creates and registers a runtime query. Deduplicates by key. * The query is immediately set up with the store's QueryClientStore. * * @param options - Query options, plain object or reactive function * @param key - Optional query key for dedup and retrieval via `get()` * @returns The created (or existing, if deduped) QueryApi instance */ add(options: QueryApiOptions | (() => QueryApiOptions), key?: QueryKey): QueryApi; /** * Retrieves a previously created runtime query by key. * * @param key - The query key used when calling `add()` */ get(key: QueryKey): QueryApi | undefined; } /** * Factory for creating a RuntimeQueries container. * Declare as a class field — the `@queryStore` decorator auto-discovers and binds it. * * @example * ```typescript * @queryStore * class MyStore extends Store { * private queries = setupRuntimeQueries(); * * loadDetails(id: number) { * return this.queries.add
(() => ({ * queryKey: ['details', id], * queryFn: () => fetchDetails(id), * }), ['details', id]); * } * } * ``` */ export declare function setupRuntimeQueries(): RuntimeQueries; //# sourceMappingURL=runtime-queries.d.ts.map