UNPKG

@clickup/ent-framework

Version:

A PostgreSQL graph-database-alike library with microsharding and row-level security

30 lines 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AllowIf = void 0; const EntAccessError_1 = require("../errors/EntAccessError"); const Rule_1 = require("./Rule"); /** * Returns ALLOW if the predicate succeeds, otherwise SKIP. * - Used mostly for read permission checks. * - This rule may still throw an exception if the exception is a wild one (not * derived from EntAccessError). */ class AllowIf extends Rule_1.Rule { async evaluate(vc, input) { try { return (await this.predicate.check(vc, input)) ? { decision: "ALLOW", rule: this, cause: null } : { decision: "SKIP", rule: this, cause: null }; } catch (error) { if (error instanceof EntAccessError_1.EntAccessError) { // We carry a cause for this SKIP decision too if it was due to an // access-related error. return { decision: "SKIP", rule: this, cause: error }; } throw error; } } } exports.AllowIf = AllowIf; //# sourceMappingURL=AllowIf.js.map