import { IDataStore } from '../services/datastore'; import { URI } from '../model/uri'; import { Query } from './saved'; /** Workspace-relative directory where saved queries live. */ export declare const QUERIES_DIR = ".foam/queries"; /** * Workspace-relative glob selecting every saved query file. Exported for * consumers (e.g. a VS Code `FileSystemWatcher`) that need the pattern * eagerly — everything else should go through {@link QueryStore}. */ export declare const QUERIES_GLOB = ".foam/queries/*.{yaml,yml}"; export interface LoadedQuery { query: Query; uri: URI; errors: string[]; } /** * Reads and writes saved queries against any {@link IDataStore}. * * The datastore must list YAML files under `.foam/queries/`. The general * Foam workspace datastore is typically scoped to notes (`**\/*.md`) and * won't see them — consumers should pass a queries-scoped datastore (e.g. * one built via {@link createQueryDataStore}) or one whose `list()` covers * the directory (e.g. `InMemoryDataStore`). * * Stateless: each call hits the datastore. Tree views and other consumers * that re-read frequently should layer their own cache on top. */ export declare class QueryStore { private readonly dataStore; private readonly workspaceRoot; constructor(dataStore: IDataStore, workspaceRoot: URI); /** The canonical file URI for a saved query with the given id. */ getFileUri(id: string): URI; /** Returns true if `uri` points at a YAML file under the queries directory. */ isQueryFile(uri: URI): boolean; /** Load every parseable query file; unparsable ones are silently skipped. */ loadAll(): Promise; /** * Returns `undefined` when the file is unreadable or fails to parse. * Soft parse warnings (e.g. unknown fields) come back in `errors` * alongside a successful load. */ load(uri: URI): Promise; /** Serialize and write a query to its canonical location. */ save(query: Query): Promise; /** Delete a saved query by id. No-op if the file doesn't exist. */ delete(id: string): Promise; /** Returns true if a query file with this id exists on disk. */ exists(id: string): Promise; private listQueryFiles; } /** * IO primitives that {@link createQueryDataStore} composes into an * {@link IDataStore}. `list` receives a workspace-relative glob and must * honor it — callers forward it to their native glob primitive * (`vscode.workspace.findFiles`, `fast-glob`, etc.). */ export interface QueryDataStoreOps { list: (pattern: string) => Promise; read: (uri: URI) => Promise; write: (uri: URI, content: string) => Promise; delete: (uri: URI) => Promise; exists: (uri: URI) => Promise; move?: (from: URI, to: URI) => Promise; } export declare function createQueryDataStore(ops: QueryDataStoreOps): IDataStore; //# sourceMappingURL=saved-store.d.ts.map