UNPKG

@tachybase/plugin-workflow-approval

Version:

Approval base in Workflow

61 lines (60 loc) 2.18 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; 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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var approvalCarbonCopy_exports = {}; __export(approvalCarbonCopy_exports, { approvalCarbonCopy: () => approvalCarbonCopy }); module.exports = __toCommonJS(approvalCarbonCopy_exports); var import_module_workflow = require("@tachybase/module-workflow"); var import_server = require("@tego/server"); var import_status = require("../constants/status"); var import_utils = require("../utils"); const approvalCarbonCopy = { async listCentralized(context, next) { const centralizedApprovalFlow = await context.db.getRepository(import_module_workflow.COLLECTION_WORKFLOWS_NAME).find({ filter: { type: "approval", "config.centralized": true }, fields: ["id"] }); context.action.mergeParams({ filter: { workflowId: centralizedApprovalFlow.map((item) => item.id), approval: { status: { [import_server.Op.ne]: import_status.APPROVAL_STATUS.DRAFT } } } }); await import_server.actions.list(context, next); if (context.body.rows) { context.body.rows = (0, import_utils.findUniqueObjects)( context.body.rows, ["userId", "approvalId"], "createdAt", (a, b) => new Date(a).getTime() - new Date(b).getTime() ); } } }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { approvalCarbonCopy });