UNPKG

jinaga

Version:

Data management for web and mobile applications.

76 lines 4.44 kB
import { Device, User } from '../model/user'; import { FactConstructor, FactRepository, LabelOf, Model, Traversal } from '../specification/model'; import { Match, Specification } from '../specification/specification'; import { FactRecord, FactReference, Storage } from '../storage'; declare class FactGraph { private factRecords; constructor(factRecords: FactRecord[]); getField(reference: FactReference, name: string): any; executeSpecification(givenName: string, matches: Match[], label: string, fact: FactRecord): FactReference[]; private executeMatches; private executeMatch; private executePathCondition; private executePredecessorStep; private filterByCondition; private findFact; } interface AuthorizationRule { describe(type: string): string; isAuthorized(userFact: FactReference | null, fact: FactRecord, graph: FactGraph, store: Storage): Promise<boolean>; getAuthorizedPopulation(candidateKeys: string[], fact: FactRecord, graph: FactGraph, store: Storage): Promise<AuthorizationPopulation>; } export declare class AuthorizationRuleAny implements AuthorizationRule { describe(type: string): string; isAuthorized(userFact: FactReference | null, fact: FactRecord, graph: FactGraph, store: Storage): Promise<boolean>; getAuthorizedPopulation(candidateKeys: string[], fact: FactRecord, graph: FactGraph, store: Storage): Promise<AuthorizationPopulation>; } export declare class AuthorizationRuleNone implements AuthorizationRule { describe(type: string): string; isAuthorized(userFact: FactReference | null, fact: FactRecord, graph: FactGraph, store: Storage): Promise<boolean>; getAuthorizedPopulation(candidateKeys: string[], fact: FactRecord, graph: FactGraph, store: Storage): Promise<AuthorizationPopulation>; } export declare class AuthorizationRuleSpecification implements AuthorizationRule { private specification; constructor(specification: Specification); describe(type: string): string; isAuthorized(userFact: FactReference | null, fact: FactRecord, graph: FactGraph, store: Storage): Promise<boolean>; getAuthorizedPopulation(candidateKeys: string[], fact: FactRecord, graph: FactGraph, store: Storage): Promise<AuthorizationPopulation>; } declare type UserSpecificationDefinition<T> = ((fact: LabelOf<T>, facts: FactRepository) => (Traversal<LabelOf<User>>)) | ((fact: LabelOf<T>, facts: FactRepository) => (Traversal<LabelOf<Device>>)); declare type UserPredecessorSelector<T> = ((fact: LabelOf<T>) => (LabelOf<User>)) | ((fact: LabelOf<T>) => (LabelOf<Device>)); declare type AuthorizationPopulationEveryone = { quantifier: "everyone"; }; declare type AuthorizationPopulationSome = { quantifier: "some"; authorizedKeys: string[]; }; declare type AuthorizationPopulationNone = { quantifier: "none"; }; export declare type AuthorizationPopulation = AuthorizationPopulationEveryone | AuthorizationPopulationSome | AuthorizationPopulationNone; export declare class AuthorizationRules { private model; static empty: AuthorizationRules; private rulesByType; constructor(model: Model | undefined); with(rules: (r: AuthorizationRules) => AuthorizationRules): AuthorizationRules; no(type: string): AuthorizationRules; no<T>(factConstructor: FactConstructor<T>): AuthorizationRules; any(type: string): AuthorizationRules; any<T>(factConstructor: FactConstructor<T>): AuthorizationRules; type<T>(factConstructor: FactConstructor<T>, definition: UserSpecificationDefinition<T>): AuthorizationRules; type<T>(factConstructor: FactConstructor<T>, predecessorSelector: UserPredecessorSelector<T>): AuthorizationRules; private typeFromDefinition; private typeFromPredecessorSelector; merge(authorizationRules2: AuthorizationRules): AuthorizationRules; static combine(rules: AuthorizationRules, type: string, rule: AuthorizationRule): AuthorizationRules; private withRule; hasRule(type: string): boolean; getAuthorizedPopulation(candidateKeys: string[], fact: FactRecord, factRecords: FactRecord[], store: Storage): Promise<AuthorizationPopulation>; saveToDescription(): string; static loadFromDescription(description: string): AuthorizationRules; } export declare function describeAuthorizationRules(model: Model, authorization: (a: AuthorizationRules) => AuthorizationRules): string; export {}; //# sourceMappingURL=authorizationRules.d.ts.map