import type { DenyReason, IAccessInfo, IGrants, IGrantsItem, IGrantsList, IGrantsListItem, IQueryInfo, IResolveOptions, IResourceGrants } from '../types/index.js'; import { type INameOptions } from './validation.js'; export declare function eachRole(grants: IGrants, callback: (role: IGrantsItem, roleName: string) => void): void; export declare function eachRoleResource(grants: IGrants, callback: (role: string, resource: string, resourceInfo: IResourceGrants) => void): void; /** * Inspects whether the given grants object/array has a valid structure and * returns a normalized `IGrants` model for internal use. * @throws {AccessControlError} - If the grants have an invalid structure. */ export declare function getInspectedGrants(o: unknown, pathPrefix?: string, opts?: INameOptions): IGrants; /** * Gets all the unique resources granted access for at least one role. */ export declare function getResources(grants: IGrants): string[]; /** * Gets all unique action names that appear anywhere in the grants model (the * strict-mode known-actions set). */ export declare function getActions(grants: IGrants, roles?: string[]): string[]; /** * Serializes the internal grants object into the flat **grants list** form (the * DB-friendly shape) — the inverse of {@link inspectGrantsList}. Each grant * rule becomes a row (`{ role, resource, action, possession, attributes, * condition?, effect? }`) and each role's `$extend` becomes one inheritance row * (`{ role, $extend }`). Round-trips: feeding the result back to AccessControl * reproduces the same model. */ export declare function toGrantsList(grants: IGrants): IGrantsList; /** * Commits the given access info to the grants model by pushing an `IGrant` rule * onto `grants[role][resource][action]` (an array — Option B, multiple rules * per action). Omitted attributes default to `['*']`. * * @param grants * @param access * @param normalizeAll - Also validate/normalize `action`/`possession` (used for * flat list rows; the builder sets these itself). * @throws {AccessControlError} - If the access info fails validation. */ export declare function commitToGrants(grants: IGrants, access: IAccessInfo | IGrantsListItem, normalizeAll?: boolean, pathPrefix?: string, opts?: INameOptions): void; /** The result of a resolution: effective attributes, denial reason, possession. */ export interface ResolveResult { attributes: string[]; reason?: DenyReason; /** The possession that effectively granted access (the requested one on denial). */ possession: 'own' | 'any'; } /** * Resolves the effective attributes (+ denial reason) for the given query * — synchronous. * * Per queried role chain: union granted attributes, subtract denied attributes * (deny-overrides). Grants cascade across possession (`any` ⊇ `own`); denies do * not. Finally, union the per-chain results across all queried roles. * * A rule whose `condition` fails for the check context is dropped from the * applicability set. An `own`-possession rule additionally requires * verified ownership. A custom/async `{ fn }` condition throws * `asyncRequired` — use {@link resolveAccessAsync}. * * @param grants * @param query * @param options - Resolved engine options (path prefix, context, ownership, * strict, vocabulary, require() gates). Query metadata is injected after the * caller context, so it always wins. */ export declare function resolveAccess(grants: IGrants, query: IQueryInfo, options?: IResolveOptions): ResolveResult; /** * Async sibling of {@link resolveAccess}. Identical resolution, but * `await`s any custom `{ fn }` conditions (rules and require() gates) against the * registered condition functions (`options.conditions`). */ export declare function resolveAccessAsync(grants: IGrants, query: IQueryInfo, options?: IResolveOptions): Promise; //# sourceMappingURL=grants.d.ts.map