import type { Vault } from "./vault.js"; /** Top-level shape of a parsed `.base` file. Mirrors the Obsidian schema. */ export interface ParsedBase { /** Global filter applying to all views (string or recursive object). */ filters?: BaseFilter; /** Derived properties (formula expressions as strings). NOT evaluated by us. */ formulas?: Record; /** Display configuration per property. */ properties?: Record; /** Aggregations. NOT evaluated by us. */ summaries?: Record; /** Views: how data is rendered. We surface as metadata. */ views?: Array<{ type: string; name?: string; filters?: BaseFilter; [k: string]: unknown; }>; } /** * Filter DSL — either a string predicate ("status != \"done\"") or a recursive * combinator object. Mirrors the Obsidian YAML grammar. */ export type BaseFilter = string | { and: BaseFilter[]; } | { or: BaseFilter[]; } | { not: BaseFilter; }; /** What `obsidian_list_bases` returns per file. */ export interface BaseSummary { path: string; name: string; size_bytes: number; mtime: string; view_count: number; view_names: string[]; } /** What `obsidian_read_base` returns. Strict subset of `ParsedBase` plus * the source path so callers can re-fetch. */ export interface BaseDocument { path: string; name: string; filters?: BaseFilter; formulas?: Record; properties?: Record; summaries?: Record; views: Array<{ type: string; name: string | null; filters?: BaseFilter; [k: string]: unknown; }>; } /** What `obsidian_query_base` returns per matching note. */ export interface BaseQueryHit { path: string; title: string; /** Frontmatter keys+values used in matching, for transparency. */ matched_on: Record; } export interface BaseQueryResult { base_path: string; view: string | null; /** * v3.6.2 HN-1 — count of ALL matching notes in the vault, NOT just the * returned slice. Pre-3.6.2 this was `matches.length` after the limit * cap, which underreported when more matches existed than `limit`. * Callers can now reliably tell when a result was truncated by * comparing `total_matched > matches.length` (or check `truncated`). */ total_matched: number; /** v3.6.2 HN-1 — true iff `total_matched > matches.length` (i.e. the * `limit` capped the response). */ truncated: boolean; /** Sub-set of matches (truncated to limit). */ matches: BaseQueryHit[]; /** * Predicates the parser couldn't evaluate (formula calls, linksTo, etc). * v3.6.2 HN-2 — under strict mode (the new default) these now exclude * the row instead of admitting it. Listed verbatim so callers can see * what was REJECTED — empty array = all predicates fully evaluated. */ unevaluated_predicates: string[]; } /** Parse a .base file body into typed structure. Throws on malformed YAML. */ export declare function parseBase(body: string): Promise; export declare function listBases(vault: Vault, args: { folder?: string; limit?: number; }): Promise; /** * Read and parse a `.base` file. * * v3.7.12 H2 — path normalization parity with `readCanvas` / `readPdf`: * - `path` is required (rejects empty string) * - extension auto-appended (`Books` → `Books.base`) * - non-`.base` paths rejected (caller can't accidentally read a `.md` * file through this surface and trigger parser errors) * - resolves through `vault.resolveInside` (path-traversal guard) * - `stat()` checked early — fail fast on missing/excluded files * - returned `path` is the canonical vault-relative form, so callers * can re-issue requests by the same key regardless of how they * spelled the input */ export declare function readBase(vault: Vault, args: { path: string; }): Promise; export interface QueryBaseArgs { /** Path to the .base file (vault-relative). */ path: string; /** Optional view-name filter. When set, the view's filters are concat'd * with the global filter via AND (matching Obsidian semantics). */ view?: string; /** Cap on matches returned (default 50). */ limit?: number; /** Extra folder scope on top of the .base's filters. */ folder?: string; } /** * Run a base's filter against the vault's markdown notes. Returns a list * of matching notes plus any predicates we couldn't evaluate. * * Implementation: walks the vault, parses each note's frontmatter, evals * the filter tree against (file.path, frontmatter, tags). Tags come from * frontmatter `tags:` AND inline `#tags` in the body. * * NOT a full Obsidian DSL implementation — see module header for the * subset we support. */ export declare function queryBase(vault: Vault, args: QueryBaseArgs): Promise; /** * v3.6.2 HN-2 — stderr warning is rate-limited to ONE message per * predicate string per process, so a single typo doesn't drown out logs * on a vault with 10k notes. The dedup Set is module-level (the daemon is * single-process). * * v3.9.0-rc.15 — the original "one log line each" reasoning only held for a * FIXED set of predicates; a stream of DISTINCT malformed predicates * (attacker- or agent-controlled `.base` input) would grow the Set without * bound over a long-lived `serve`. `MAX_WARNED_PREDICATES` caps it (past the * cap a distinct predicate may re-warn — an acceptable trade vs. a leak). */ export declare const MAX_WARNED_PREDICATES = 1000; /** * Add `value` to a dedup `set` only while it's under `max` entries — a bounded * "warn once" tracker. Past the cap, returns false (caller may still act, but * the value isn't tracked, so it could re-fire later — an acceptable trade vs. * unbounded memory). Pure + exported for unit testing. * * @returns true if the value was newly added; false if already present OR the * set is at `max` capacity. */ export declare function boundedSetAdd(set: Set, value: string, max: number): boolean; //# sourceMappingURL=bases.d.ts.map