/** * One disjunct of an `allow write: if ...` predicate after helper-function expansion * and DNF conversion. Always carries a numeric byte cap plus at least one MIME constraint. */ export interface PredicateBranch { readonly maxFileSizeBytes: number; readonly allowedMimeLiterals: readonly string[]; readonly allowedMimeRegexes: readonly string[]; } /** * Result of evaluating a CEL `allow write` predicate. When the predicate cannot be reduced * to at least one resource-constraining branch, {@link PredicateEvaluation.branches} is * empty and `unsupported` carries a human-readable reason. */ export interface PredicateEvaluation { readonly branches: readonly PredicateBranch[]; readonly unsupported?: string; } /** * Map of helper-function names → return-expression text. Entries are sourced from the * surrounding `storage.rules` scope (function definitions reachable from the `match` block). */ export interface HelperFunctionTable { readonly definitions: ReadonlyMap; } /** * Evaluates a CEL `allow write` predicate into the list of `(size, MIME)` branches the * `require-storagefile-policy-matches-rules` lint rule cross-checks against the TypeScript * upload-policy registry. * * Pipeline: parse with `@marcbachmann/cel-js`, inline zero-arg helper calls at the AST * level, expand to disjunctive normal form, then for each DNF clause harvest: * * - `request.resource.size < N` size caps, * - `request.resource.contentType == '...'` literal MIMEs, * - `request.resource.contentType.matches('...')` MIME regexes, * - `request.resource.contentType in [...]` MIME-list literals. * * A clause becomes a {@link PredicateBranch} only when it has ≥1 size cap AND ≥1 MIME * constraint. Auth-only clauses (e.g. `request.auth.token.a == 1`) are silently dropped — * they don't restrict uploads from the storage perspective. * * @param predicate - The raw predicate text (everything between `if` and `;` in the rules file). * @param helpers - Helper-function bodies in scope at the `match` block. * @returns Reduced branches, plus an `unsupported` reason when reduction yields zero branches or the predicate fails to parse. */ export declare function evaluatePredicate(predicate: string, helpers: HelperFunctionTable): PredicateEvaluation;