UNPKG

@clickup/ent-framework

Version:

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

32 lines 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DenyIf = void 0; const EntAccessError_1 = require("../errors/EntAccessError"); const Rule_1 = require("./Rule"); /** * Returns DENY if the predicate succeeds, otherwise SKIP. * - Used mostly to early block some read/write access. * - EntAccessError exception will be treated as a DENY signal (so it will abort * processing immediately). * - This rule may still throw an exception if the exception is a wild one (not * derived from EntAccessError). */ class DenyIf extends Rule_1.Rule { async evaluate(vc, input) { try { return (await this.predicate.check(vc, input)) ? { decision: "DENY", rule: this, cause: null } : { decision: "SKIP", rule: this, cause: null }; } catch (error) { if (error instanceof EntAccessError_1.EntAccessError) { // We carry a cause for this DENY decision too if it was due to an // access-related error. return { decision: "DENY", rule: this, cause: error }; } throw error; } } } exports.DenyIf = DenyIf; //# sourceMappingURL=DenyIf.js.map