UNPKG

@nocobase/flow-engine

Version:

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

80 lines (78 loc) 4.51 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 helpers_exports = {}; __export(helpers_exports, { createJSRunnerWithVersion: () => createJSRunnerWithVersion, getRunJSDocFor: () => getRunJSDocFor, registerDefaultMappings: () => registerDefaultMappings }); module.exports = __toCommonJS(helpers_exports); var import_JSRunner = require("../JSRunner"); var import_FlowRunJSContext = require("./contexts/FlowRunJSContext"); var import_registry = require("./registry"); var import_JSBlockRunJSContext = require("./contexts/JSBlockRunJSContext"); var import_JSFieldRunJSContext = require("./contexts/JSFieldRunJSContext"); var import_JSItemRunJSContext = require("./contexts/JSItemRunJSContext"); var import_FormJSFieldItemRunJSContext = require("./contexts/FormJSFieldItemRunJSContext"); var import_JSRecordActionRunJSContext = require("./contexts/JSRecordActionRunJSContext"); var import_JSCollectionActionRunJSContext = require("./contexts/JSCollectionActionRunJSContext"); function getRunJSDocFor(ctx, { version = "v1" } = {}) { var _a; const modelClass = (0, import_registry.getModelClassName)(ctx); const ctor = import_registry.RunJSContextRegistry.resolve(version, modelClass) || import_registry.RunJSContextRegistry.resolve("latest", modelClass) || import_FlowRunJSContext.FlowRunJSContext; return ((_a = ctor.getDoc) == null ? void 0 : _a.call(ctor)) || {}; } __name(getRunJSDocFor, "getRunJSDocFor"); function createJSRunnerWithVersion(options) { var _a; const version = (options == null ? void 0 : options.version) || "v1"; const modelClass = (0, import_registry.getModelClassName)(this); const Ctor = import_registry.RunJSContextRegistry.resolve(version, modelClass) || import_registry.RunJSContextRegistry.resolve("latest", modelClass) || import_FlowRunJSContext.FlowRunJSContext; const runCtx = new Ctor(this.createProxy ? this.createProxy() : this); const def = ((_a = Ctor.injectDefaultGlobals) == null ? void 0 : _a.call(Ctor)) || {}; const globals = { ctx: runCtx, ...def, ...(options == null ? void 0 : options.globals) || {} }; const { timeoutMs } = options || {}; return new import_JSRunner.JSRunner({ globals, timeoutMs }); } __name(createJSRunnerWithVersion, "createJSRunnerWithVersion"); function registerDefaultMappings() { const v = "v1"; import_registry.RunJSContextRegistry.register(v, "JSBlockModel", import_JSBlockRunJSContext.JSBlockRunJSContext); import_registry.RunJSContextRegistry.register(v, "JSFieldModel", import_JSFieldRunJSContext.JSFieldRunJSContext); import_registry.RunJSContextRegistry.register(v, "JSItemModel", import_JSItemRunJSContext.JSItemRunJSContext); import_registry.RunJSContextRegistry.register(v, "FormJSFieldItemModel", import_FormJSFieldItemRunJSContext.FormJSFieldItemRunJSContext); import_registry.RunJSContextRegistry.register(v, "JSRecordActionModel", import_JSRecordActionRunJSContext.JSRecordActionRunJSContext); import_registry.RunJSContextRegistry.register(v, "JSCollectionActionModel", import_JSCollectionActionRunJSContext.JSCollectionActionRunJSContext); import_registry.RunJSContextRegistry.register(v, "*", import_FlowRunJSContext.FlowRunJSContext); } __name(registerDefaultMappings, "registerDefaultMappings"); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { createJSRunnerWithVersion, getRunJSDocFor, registerDefaultMappings });