UNPKG

sqrl-cli-functions

Version:

SQRL (A Safe, Stateful Rules Language for Event Streams) - functions intended for command line tools

41 lines (40 loc) 1.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.registerBlockFunctions = void 0; const sqrl_1 = require("sqrl"); const CliManipulator_1 = require("./CliManipulator"); function registerBlockFunctions(instance) { instance.registerStatement("SqrlBlockStatements", async function blockAction(state, cause) { if (!(state.manipulator instanceof CliManipulator_1.CliManipulator)) { throw new Error("Expected CliManipulator for SimpleBlockService"); } state.manipulator.setBlocked(cause); }, { args: [sqrl_1.AT.state, sqrl_1.AT.whenCause], allowNull: true, argstring: "", docstring: "Mark the current action as blocked", }); instance.registerStatement("SqrlBlockStatements", async function whitelistAction(state, cause) { if (!(state.manipulator instanceof CliManipulator_1.CliManipulator)) { throw new Error("Expected CliManipulator for SimpleBlockService"); } state.manipulator.setWhitelisted(cause); }, { args: [sqrl_1.AT.state, sqrl_1.AT.whenCause], allowNull: true, argstring: "", docstring: "Mark the current action as whitelisted", }); instance.registerSync(function wasBlocked(state) { if (!(state.manipulator instanceof CliManipulator_1.CliManipulator)) { throw new Error("Expected CliManipulator for SimpleBlockService"); } return state.manipulator.wasBlocked(); }, { args: [sqrl_1.AT.state, sqrl_1.AT.feature], argstring: "", docstring: "Check if the current action was marked as blocked", }); } exports.registerBlockFunctions = registerBlockFunctions;