import { Rule, RuleOptions } from './Rule'; import { RawRuleFrom } from './RawRule'; import { Abilities, Normalize, SubjectType, AbilityParameters, AbilityTuple, ExtractSubjectType } from './types'; import { LinkedItem } from './structures/LinkedItem'; export interface RuleIndexOptions extends Partial> { detectSubjectType?(subject: Exclude[1], SubjectType>): ExtractSubjectType[1]>; anyAction?: string; anySubjectType?: string; } export declare const ɵabilities: unique symbol; export declare const ɵconditions: unique symbol; interface WithGenerics { [ɵabilities]: any; [ɵconditions]: any; } export type Public = { [K in keyof T]: T[K]; }; export interface Generics { abilities: T[typeof ɵabilities]; conditions: T[typeof ɵconditions]; } export type RuleOf = Rule['abilities'], Generics['conditions']>; export type RawRuleOf = RawRuleFrom['abilities'], Generics['conditions']>; export type RuleIndexOptionsOf = RuleIndexOptions['abilities'], Generics['conditions']>; interface AbilityEvent { target: T; /** @deprecated use "target" property instead */ ability: T; } export interface UpdateEvent extends AbilityEvent { rules: RawRuleOf[]; } /** * @deprecated `on`/`emit` properly infer type without this type * TODO(major): delete */ export type EventHandler = (event: Event) => void; export type Events = keyof EventsMap> = Map[K]> | null>; interface EventsMap { update(event: UpdateEvent): void; updated(event: UpdateEvent): void; } export type Unsubscribe = () => void; type AbilitySubjectTypeParameters = AbilityParameters, field?: string) => 0 : (action: T[0], subject: ExtractSubjectType) => 0 : never, (action: Extract) => 0>; export declare class RuleIndex { private _hasPerFieldRules; private _events?; private _indexedRules; private _rules; private readonly _ruleOptions; private _detectSubjectType; private readonly _anyAction; private readonly _anySubjectType; private readonly _hasCustomSubjectTypeDetection; readonly [ɵabilities]: A; readonly [ɵconditions]: Conditions; constructor(rules?: RawRuleFrom[], options?: RuleIndexOptions); get rules(): RawRuleFrom[]; detectSubjectType(object?: Normalize[1]): ExtractSubjectType[1]>; update(rules: RawRuleFrom[]): Public; private _indexAndAnalyzeRules; possibleRulesFor(...args: AbilitySubjectTypeParameters): Rule[]; rulesFor(...args: AbilitySubjectTypeParameters): Rule[]; actionsFor(subjectType: ExtractSubjectType[1]>): string[]; on>(event: T, handler: EventsMap>[T]): Unsubscribe; private _emit; } export {};