Skip to content

resolveAccessConstraint

resolveAccessConstraint<TSubjects>(props): AccessFilterFn | undefined

Defined in: packages/core/src/access/resolveAccessRule.ts:304

Resolves an access rule to a .filter() expression, if any.

The sibling of resolveAccessIndex, for query shapes with no withIndex slot to claim (search) or where the caller’s own index already claimed it (find’s displaced branch). Both share selectSingleCondition, so they cannot disagree about which rule applies.

Succeeds for BOTH halves of a condition. An indexed rule’s positional constraints compile to a filter expression just as well as they do to a range — the whole point of recording data rather than a callback — and a flat rule’s tree compiles here too. When a condition carries both, they are and-ed.

TSubjects extends Record<string, SubjectEntry> = Record<string, SubjectEntry>

Input props.

VexAccessConfig<TSubjects, readonly AccessResource[], string, string | undefined, Partial<Record<string, CustomActionsInput>>>

Resolved access config; absent or enabled: false ⇒ no filter.

string

Query-shaped action.

boolean

Set when the caller already pushed this rule’s index range down via .withIndex(name, range). The range is then omitted here, leaving only the filter half — applying it twice would be redundant work on every row. Leave unset (find’s displaced branch, search, get) to get the whole condition as one expression.

Record<string, unknown>

Active organization, forwarded to the rule’s callback.

string

Subject slug.

Record<string, unknown> | null

Caller, or null for anonymous (resolves through access.anonRole).

AccessFilterFn | undefined

A thunk taking the query’s own FilterBuilder, or undefined when nothing is left to exclude.