/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ import { type EditSession, type HistoryAction, type Origin } from "@elaraai/east-ui-components"; import type { QueryWords } from "./model/words.js"; import type { QueryRoot } from "./one-shot.js"; import { type QueryOpen } from "./open-query.js"; import { type QueriesHandle, type QueryBase, type QueryEntry, type SavedQueries } from "./session.js"; /** What the open query's session needs. */ export interface QuerySessionOptions { /** The saved queries record, bound with its patch. */ readonly handle: QueriesHandle; /** The record as it reads now; `undefined` while it has not been read. */ readonly record: SavedQueries | undefined; /** The root, or why it cannot be queried. */ readonly root: QueryRoot | string; /** The open query. */ readonly open: QueryOpen; /** Opens another query. */ readonly writeOpen: (next: QueryOpen) => void; /** The builder's storage key: the session's view. */ readonly storageKey: string; /** The words. */ readonly words: QueryWords; } /** The open query's session, and what the surfaces do through it. */ export interface QuerySessionState { /** The session: its history, its drafts, its request. */ readonly session: EditSession; /** Its session's source id. */ readonly sourceId: string; /** What it began from; `undefined` while the record has not been read, or the open saved query is not in it. */ readonly base: QueryBase | undefined; /** The query's entries as its drafts stand. */ readonly entries: readonly QueryEntry[] | undefined; /** Whether a gesture may be recorded now. */ readonly available: boolean; /** Moves with every change of the session. */ readonly version: number; /** The query's entries as the drafts stand this moment — after a gesture in the same event, too. */ readonly current: () => readonly QueryEntry[] | undefined; /** Records a gesture: the entries it leaves, as one transaction. */ readonly gesture: (next: readonly QueryEntry[], origin: Origin, label: string) => boolean; /** Runs a history item's action. */ readonly onAction: (action: HistoryAction) => void; /** Whether a query never saved has asked for its name, with Apply. */ readonly naming: boolean; /** Asks for, or stops asking for, a name. */ readonly setNaming: (naming: boolean) => void; } /** * The open query's editing session — see the module docs. * * @param options - The record, the root, the open query and the words * @returns The session, and what the surfaces do through it */ export declare function useQuerySession(options: QuerySessionOptions): QuerySessionState; //# sourceMappingURL=use-query-session.d.ts.map