import { type DTRExp } from 'dtrexp'; import type { ConditionFunction, ConditionJSON, UnknownObject } from '../types/index.js'; /** * Parses a `during` dtrexp expression — or returns the cached instance. * `DTRExp` instances are immutable ("parse once, evaluate many"); the cache is * FIFO-bounded by {@link MAX_DTREXP_CACHE}. Exported only as an internal test * hook (not part of the public API surface). * * @throws {AccessControlError} - If the expression is too long or malformed * (carries dtrexp's message and character position; original error as `cause`). */ export declare function getDTRExp(expression: string, errorCodePrefix?: string, safeErrors?: boolean): DTRExp; /** * Compiles a condition (string sugar and/or partial JSON) into the canonical * JSON form. Idempotent: canonical input passes through validated. Custom-fn * references (`{ fn, args }`) are returned unchanged (evaluated in a later * async phase). * * @param input - The author-supplied condition. * @param pathPrefix - The notation path sentinel (default `'$'`). * @param errorCodePrefix - The `engine.errorCodePrefix` stamped on every code. * @param safeErrors - The `engine.safeErrors` setting: when on (default), * messages leave out the expression and its values. * @returns The canonical, validated condition. * @throws {AccessControlError} - On malformed syntax, unknown operators or * statically-invalid ranges. * * @example * compileCondition('$.order.value > 100000'); * // → ['$.order.value', '>', 100000] * * @example * compileCondition({ and: ['$.a == 1', '$.b != 2'] }); * // → { and: [['$.a', '==', 1], ['$.b', '!=', 2]] } */ export declare function compileCondition(input: ConditionJSON, pathPrefix?: string, errorCodePrefix?: string, safeErrors?: boolean, _depth?: number): ConditionJSON; /** * Returns the condition with every `during` (schedule) leaf assumed satisfied * (replaced by a tautology). Used to derive the `out_of_schedule` deny reason: * if a failed condition passes in this transformed form, time was the *only* * blocker — "granted, but not now". A schedule-free condition is returned * semantically unchanged (so re-evaluating it simply fails again). Note the * polarity: a `during` under `not` becomes `not(true)` — a failing "only * OUTSIDE the schedule" rule deliberately does not read as out-of-schedule. */ export declare function assumeSchedules(node: ConditionJSON): ConditionJSON; /** * Evaluates a **canonical** condition (the {@link compileCondition} output) * against the merged check-time context, returning whether it holds. * The reserved `now` key is auto-injected and expanded into `$.now.*` fields * (overridable via `context.now` for deterministic tests; timezone via * `context.tz`). Synchronous: `{ fn }` conditions throw; use `evaluateConditionAsync`. * * @param condition - A canonical condition (compile string sugar first). * @param context - The merged data bag; `$.`-paths resolve against it. * @param pathPrefix - The notation path sentinel (default `'$'`). * @param allowRegex - Whether the `matches` operator is permitted (default * `true` for direct use; the engine passes `policy.allowRegex`, default `false`). * @returns `true` if the condition holds for the context. * @throws {AccessControlError} - On an uncompiled/invalid node or a custom fn. * * @example * evaluateCondition(['$.order.value', '>', 100], { order: { value: 150 } }); // true */ export declare function evaluateCondition(condition: ConditionJSON, context?: UnknownObject, pathPrefix?: string, allowRegex?: boolean, errorCodePrefix?: string): boolean; /** * Async sibling of {@link evaluateCondition}. Evaluates a **canonical** * condition, awaiting any custom `{ fn, args }` references resolved against the * registry (`ac.defineCondition`). Declarative leaves/combinators behave exactly * as the sync path; `and`/`or` short-circuit. * * @param condition - A canonical condition (compile string sugar first). * @param context - The merged data bag; `$.`-paths resolve against it. * @param pathPrefix - The notation path sentinel (default `'$'`). * @param registry - Custom condition functions by name. * @param allowRegex - Whether the `matches` operator is permitted (default * `true` for direct use; the engine passes `policy.allowRegex`, default `false`). * @returns A promise of whether the condition holds. */ export declare function evaluateConditionAsync(condition: ConditionJSON, context?: UnknownObject, pathPrefix?: string, registry?: Record, allowRegex?: boolean, errorCodePrefix?: string): Promise; //# sourceMappingURL=condition.d.ts.map