UNPKG

@tachybase/plugin-workflow-approval

Version:

Approval base in Workflow

89 lines (88 loc) 3.72 kB
var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var plugin_exports = {}; __export(plugin_exports, { PluginWorkflowApproval: () => PluginWorkflowApproval, default: () => plugin_default }); module.exports = __toCommonJS(plugin_exports); var import_node_path = __toESM(require("node:path")); var import_module_workflow = require("@tachybase/module-workflow"); var import_server = require("@tego/server"); var import_constants = require("../common/constants"); var import_actions = require("./actions"); var import_Approval = __toESM(require("./instructions/Approval")); var import_ApprovalCarbonCopy = __toESM(require("./instructions/ApprovalCarbonCopy")); var import_Approval2 = __toESM(require("./triggers/Approval")); class PluginWorkflowApproval extends import_server.Plugin { afterAdd() { } beforeLoad() { this.app.on("afterLoadPlugin", (plugin) => { if (!(plugin instanceof import_module_workflow.PluginWorkflow)) { return; } this.workflow = plugin; plugin.triggers.register("approval", new import_Approval2.default(plugin)); plugin.instructions.register("approval", new import_Approval.default(plugin)); plugin.instructions.register(import_constants.COLLECTION_NAME_APPROVAL_CARBON_COPY, new import_ApprovalCarbonCopy.default(plugin)); }); } async load() { const { db } = this; db.addMigrations({ namespace: "approval", directory: import_node_path.default.resolve(__dirname, "migrations"), context: { plugin: this } }); await db.import({ directory: import_node_path.default.resolve(__dirname, "collections") }); (0, import_actions.init)(this); this.app.acl.allow("workflows", ["listApprovalFlows"], "loggedIn"); this.app.acl.allow("approvals", "*", "loggedIn"); this.app.acl.allow("approvalExecutions", ["get"], "loggedIn"); this.app.acl.allow("approvalRecords", ["get", "list", "listCentralized", "submit"], "loggedIn"); this.app.acl.allow(import_constants.COLLECTION_NAME_APPROVAL_CARBON_COPY, ["get", "list", "listCentralized", "submit"], "loggedIn"); } async install(options) { } async afterEnable() { } async afterDisable() { } async remove() { } } var plugin_default = PluginWorkflowApproval; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { PluginWorkflowApproval });