@clickup/ent-framework
Version:
A PostgreSQL graph-database-alike library with microsharding and row-level security
41 lines • 1.76 kB
TypeScript
import { IDsCache } from "../IDsCache";
import type { VC } from "../VC";
/**
* A predicate evaluates against some input (typically a row) and returns true
* or false (or throws which is considering the similar way as returning false).
*
* I.e. Predicate is a "yes/no" logic. If it resolves to "no", then the
* framework may disallow some Ent operation and include predicate object's
* properties (like name or any other info) to the exception.
*
* Also, some predicates try to use caches in vc to make the decision faster
* based on the previously computed results. E.g. CanReadOutgoingEdge predicate
* knows that it already returned true for some ID once, it returns true again
* immediately. This saves us lots of database operations.
*/
export interface Predicate<TInput> {
readonly name: string;
check(vc: VC, input: TInput): Promise<boolean>;
}
/**
* Sometimes, instead of passing a well-known predicate like OutgoingEdgePointsToVC
* or CanUpdateOutgoingEdge, we want to pass just a function which accepts a row
* and returns true or false. This class represents a Predicate which delegates
* its work to such a function. The name of the function becomes the name of the
* predicate.
*/
export declare class FuncToPredicate<TInput> implements Predicate<TInput> {
private func;
readonly name: string;
constructor(func: (vc: VC, input: TInput) => Promise<boolean> | boolean);
check(vc: VC, input: TInput): Promise<boolean>;
}
export declare class IDsCacheReadable extends IDsCache {
}
export declare class IDsCacheUpdatable extends IDsCache {
}
export declare class IDsCacheDeletable extends IDsCache {
}
export declare class IDsCacheCanReadIncomingEdge extends IDsCache {
}
//# sourceMappingURL=Predicate.d.ts.map