UNPKG

@nocobase/flow-engine

Version:

A standalone flow engine for NocoBase, managing workflows, models, and actions.

94 lines (92 loc) 2.78 kB
/** * This file is part of the NocoBase (R) project. * Copyright (c) 2020-2024 NocoBase Co., Ltd. * Authors: NocoBase Team. * * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License. * For more information, please refer to: https://www.nocobase.com/agreement. */ var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); 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 filterItem_exports = {}; __export(filterItem_exports, { FilterGroup: () => FilterGroup, FilterItem: () => FilterItem }); module.exports = __toCommonJS(filterItem_exports); const _FilterItem = class _FilterItem { constructor(options) { this.options = options; if (options instanceof _FilterItem) { return options; } this.options = options; } toJSON() { if (this.options.operator) { return { [this.options.path]: { [this.options.operator]: this.options.value } }; } return { [this.options.path]: this.options.value }; } }; __name(_FilterItem, "FilterItem"); let FilterItem = _FilterItem; const _FilterGroup = class _FilterGroup { options; constructor(options) { if (options instanceof _FilterGroup) { return options; } if (options.logic !== "$and" && options.logic !== "$or") { throw new Error("Logic must be either $and or $or"); } if (!Array.isArray(options.items)) { throw new Error("Items must be an array"); } this.options = { logic: options.logic, items: options.items.map((item) => { if (item.logic) { return new _FilterGroup(item); } return new FilterItem(item); }) }; } toJSON() { return { [this.options.logic]: this.options.items.map((item) => { return item.toJSON(); }) }; } }; __name(_FilterGroup, "FilterGroup"); let FilterGroup = _FilterGroup; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { FilterGroup, FilterItem });