/** * @fileoverview Worker-thread entry that evaluates a caller's JSONLogic tree * against note contexts, for searches scoped by OBSIDIAN_READ_PATHS or * OBSIDIAN_DENY_PATHS. Runs the operator set the Local REST API plugin runs * (json-logic-js 2.0.5 plus its `glob` and `regexp`), with the plugin's hit * test and JSON-shaped results, so a scoped search answers as the plugin would * over the same notes. * * Off the main thread so a slow tree cannot hold the event loop: the evaluator * terminates this worker at its deadline, which also stops a native regex * mid-backtrack. Memory is bounded here by work budgets, since Bun ignores * `resourceLimits`: one per note for what its evaluation builds and drops, * and one across the search for what kept results hold past a * 1,024-character allowance each. * * Imports only packages and builtins, never sibling modules: under Node the * test suite loads this file from source, where `./x.js` specifiers do not * resolve to `.ts`. * * @module services/obsidian/jsonlogic-worker */ /** A note as the plugin's JSONLogic search evaluates it, less the link fields a scoped search leaves out. */ export interface NoteContext { path: string; [field: string]: unknown; } export interface EvaluationRequest { /** Work units left for kept results, across every batch of the search; see {@link chargeKept}. */ keptUnits: number; logic: unknown; notes: NoteContext[]; /** Work units each note's evaluation may build beyond the note's own size; see {@link charge}. */ noteUnits: number; } /** * How an evaluation ended. `json` is the hit's result serialized as the * plugin's response would carry it; `keptUnitsLeft` carries into the next * batch. */ export type EvaluationResponse = { ok: true; hits: Array<{ filename: string; json: string; }>; keptUnitsLeft: number; } | { ok: false; failure: 'invalid' | 'invalid_regexp' | BudgetFailure; detail: string; }; type BudgetFailure = 'over_note_budget' | 'over_kept_budget'; export {}; //# sourceMappingURL=jsonlogic-worker.d.ts.map