import type { SqlParam } from "./types.js"; /** * Pre-compiled exclude patterns, ready to be inlined into SQL WHERE clauses * and evaluated against single internal paths in JS. * * The hybrid pushdown strategy splits patterns into three buckets so the * fast, indexed paths handle as many cases as possible: * * 1. `lqueries`: label-level patterns (e.g. `node_modules`, `__pycache__`). * Match via `path ~ ANY($n::lquery[])`, GiST-indexed. * 2. `prefixes`: anchored subtree prefixes (e.g. `/build`, `/.git`). * Match via `path <@ ANY($n::ltree[])` plus exact equality, GiST-indexed. * 3. `regexes`: anything lquery cannot express (intra-label glob like * `*.log`, `Dockerfile.*`, mixed-segment globs). Match via * `path::text ~ ANY($n::text[])`. Sequential within the already * narrowed result set. * * The compiled form is per-instance because anchored patterns are resolved * relative to `rootDir` and the workspace prefix in encoded ltree. */ export interface CompiledExcludes { empty: boolean; lqueries: string[]; prefixes: string[]; regexes: string[]; /** Original raw patterns, kept for the JS-side predicate. */ rawPatterns: CompiledRawPattern[]; rootDirInternal: string; } interface CompiledRawPattern { /** Path-segment regex compiled for the JS predicate, applied to internal POSIX paths. */ test: (internalPath: string) => boolean; } export declare function emptyExcludes(): CompiledExcludes; /** * Compile a list of gitignore-like patterns into the hybrid form used by * `excludeWhereSql()` and `isExcluded()`. * * Supported syntax (subset of gitignore): * * - `name` — match a label called `name` anywhere in the tree. * - `name/` — same as `name` (dir-only semantics not enforced; see followups). * - `/name` — anchored at `rootDir`: match exact path and its subtree. * - `/a/b/c` — anchored multi-segment subtree. * - `*.ext` — leaf basename glob; matches files/dirs ending in `.ext` anywhere. * - `name.*` — leaf basename glob. * - `**`/`name` — equivalent to `name`. * - `dir/*.tmp` — anchored mixed-segment glob (full-path regex). * - empty / `#…` — ignored (gitignore comment). * * Negation (`!pat`) and dir-only enforcement (`name/` only matches dirs) * are not implemented in this pass. */ export declare function compileExcludes(patterns: string[] | undefined, rootDirInternal: string, workspaceId: string): CompiledExcludes; /** * Build a SQL fragment that, when ANDed into a `WHERE` clause, removes * excluded entries from the result. Returns the fragment plus the params * to append (assigned positions starting at `nextParamIdx`). * * The fragment is `TRUE` (no-op) when no patterns are configured. Otherwise * it has the shape `(NOT (lq OR pre OR re))` where each disjunct is omitted * if its bucket is empty. * * `pathExpr` must be the SQL expression naming the ltree path column * (e.g. `e.path` or just `path`). */ export declare function excludeWhereSql(c: CompiledExcludes, pathExpr: string, nextParamIdx: number): { sql: string; params: SqlParam[]; }; /** * JS-side predicate: returns true when `internalPath` (an internal absolute * POSIX path) matches any compiled exclude rule. Used by write-side guards * and symlink target resolution where we cannot defer to SQL. */ export declare function isExcluded(c: CompiledExcludes, internalPath: string): boolean; export {}; //# sourceMappingURL=exclude.d.ts.map