@nocobase/plugin-workflow-javascript 2.1.0-beta.13 → 2.1.0-beta.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env.example ADDED
@@ -0,0 +1,15 @@
1
+ # This is an example of environment variables for the plugin-workflow-javascript plugin.
2
+ # You can merge this file with your existing .env file and customize the values as needed.
3
+ #
4
+ # --- SECURITY WARNING ---
5
+ # * By default, no modules are allowed to be used in the JavaScript node. Your script will be executed in a sandboxed environment by `isolated-vm`.
6
+ #
7
+ # * By setting any module in WORKFLOW_SCRIPT_MODULES, the JavaScript node will use `node:vm` to execute the script,
8
+ # which will cause potential security risks. Please make sure the script content is managed by privileged users,
9
+ # and use it with caution. This will be at your own risk.
10
+ #
11
+ # See the documentation for more details: https://docs.nocobase.com/workflow/nodes/javascript#safe-mode-default
12
+ #
13
+ # Example: lodash,dayjs
14
+ # WORKFLOW_SCRIPT_MODULES=lodash,dayjs
15
+ WORKFLOW_SCRIPT_MODULES=
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("ahooks"),require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("@formily/antd-v5"),require("react"),require("@ant-design/icons"),require("lodash"),require("antd"),require("antd-style"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-javascript",["ahooks","@nocobase/client","@nocobase/plugin-workflow/client","@formily/antd-v5","react","@ant-design/icons","lodash","antd","antd-style","react-i18next"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-javascript"]=t(require("ahooks"),require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("@formily/antd-v5"),require("react"),require("@ant-design/icons"),require("lodash"),require("antd"),require("antd-style"),require("react-i18next")):e["@nocobase/plugin-workflow-javascript"]=t(e.ahooks,e["@nocobase/client"],e["@nocobase/plugin-workflow/client"],e["@formily/antd-v5"],e.react,e["@ant-design/icons"],e.lodash,e.antd,e["antd-style"],e["react-i18next"])}(self,function(e,t,n,r,o,i,c,u,a,l){return function(){var s,p,f,d,b,y,m={3581:function(e){e.exports=function(e,t){return"undefined"!=typeof __deoptimization_sideEffect__&&__deoptimization_sideEffect__(e,t),t}},482:function(e){"use strict";e.exports=i},4632:function(e){"use strict";e.exports=r},3772:function(e){"use strict";e.exports=t},8433:function(e){"use strict";e.exports=n},2749:function(t){"use strict";t.exports=e},2721:function(e){"use strict";e.exports=u},8202:function(e){"use strict";e.exports=a},467:function(e){"use strict";e.exports=c},8156:function(e){"use strict";e.exports=o},3238:function(e){"use strict";e.exports=l}},v={};function h(e){var t=v[e];if(void 0!==t)return t.exports;var n=v[e]={exports:{}};return m[e](n,n.exports,h),n.exports}h.m=m,h.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return h.d(t,{a:t}),t},h.d=function(e,t){for(var n in t)h.o(t,n)&&!h.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},h.f={},h.e=function(e){return Promise.all(Object.keys(h.f).reduce(function(t,n){return h.f[n](e,t),t},[]))},h.u=function(e){return""+({222:"d608e8e5c2f2b5cf",701:"907399554f340b0a"})[e]+".js"},h.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),h.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s={},p="@nocobase/plugin-workflow-javascript:",h.l=function(e,t,n,r){if(s[e])return void s[e].push(t);if(void 0!==n)for(var o,i,c=document.getElementsByTagName("script"),u=0;u<c.length;u++){var a=c[u];if(a.getAttribute("src")==e||a.getAttribute("data-webpack")==p+n){o=a;break}}o||(i=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,h.nc&&o.setAttribute("nonce",h.nc),o.setAttribute("data-webpack",p+n),o.src=e),s[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(f);var r=s[e];if(delete s[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},f=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),i&&document.head.appendChild(o)},h.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(f=window.__webpack_public_path__||"/").endsWith("/")||(f+="/"),h.p=f+"static/plugins/@nocobase/plugin-workflow-javascript/dist/client/",d={909:0},h.f.j=function(e,t){var n=h.o(d,e)?d[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=d[e]=[t,r]});t.push(n[2]=r);var o=h.p+h.u(e),i=Error();h.l(o,function(t){if(h.o(d,e)&&(0!==(n=d[e])&&(d[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},b=function(e,t){var n,r,o=t[0],i=t[1],c=t[2],u=0;if(o.some(function(e){return 0!==d[e]})){for(n in i)h.o(i,n)&&(h.m[n]=i[n]);c&&c(h)}for(e&&e(t);u<o.length;u++)r=o[u],h.o(d,r)&&d[r]&&d[r][0](),d[r]=0},(y=self.webpackChunk_nocobase_plugin_workflow_javascript=self.webpackChunk_nocobase_plugin_workflow_javascript||[]).forEach(b.bind(null,0)),y.push=b.bind(null,y.push.bind(y));var g={};return!function(){"use strict";h.r(g),h.d(g,{PluginWorkflowScriptClient:function(){return _},default:function(){return S}});var e=h(3772),t=h(4632),n=h(482),r=h(8433),o=h(2721),i=h(8156),c=h.n(i);h(3238);var u="workflow-javascript";function a(t){var n,r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.i18n.t(t,(n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},o),r=r={ns:u},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n))}var l=h(3581);function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function d(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(d=function(){return!!e})()}var b=(0,i.lazy)(function(){return l("imported_-9r67ij_component",Promise.all([h.e("701"),h.e("222")]).then(h.bind(h,1706)))});function y(){return c().createElement("div",null,c().createElement("span",null,a("Node.js features supported can be found in the documentaion: ")),c().createElement("a",{href:a("https://docs.nocobase.com/handbook/workflow-javascript"),target:"_blank",rel:"noreferrer"},a("JavaScript node")))}var m=function(e){var i;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function l(){var e,i,f;if(!(this instanceof l))throw TypeError("Cannot call a class as a function");return i=l,f=arguments,i=p(i),s(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,d()?Reflect.construct(i,f||[],p(this).constructor):i.apply(this,f)),"title","JavaScript"),s(e,"type","script"),s(e,"group","extended"),s(e,"description",'{{t("Execute a piece of JavaScript in an isolated Node.js environment.", { ns: "'.concat(u,'" })}}')),s(e,"icon",c().createElement(n.CodeOutlined,null)),s(e,"fieldset",{arguments:{type:"array",title:'{{t("Arguments", { ns: "'.concat(u,'" })}}'),description:'{{t("The arguments that will be used in script with same name.", { ns: "'.concat(u,'" })}}'),"x-decorator":"FormItem","x-component":"ArrayItems",default:[],items:{type:"object","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'},"x-validator":function(e,t,n){var r=RegExp("^[\\p{L}$_][\\p{L}\\p{N}$_]*$","u"),o=n.form.getValuesIn().arguments.filter(function(t){return t.name===e});return r.test(e)?!(o.length>1)||a("Argument name duplicated"):a("Argument name is invalid")}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,useTypedConstant:!0,placeholder:'{{t("Value")}}'}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}},properties:{add:{type:"void",title:'{{t("Add argument", { ns: "'.concat(u,'" })}}'),"x-component":"ArrayItems.Addition"}}},content:{type:"string",title:'{{t("Script content", { ns: "'.concat(u,'" })}}'),description:"{{useScriptDescription()}}","x-decorator":"FormItem","x-component":"CodeEditor",default:'return "Hello world!";'},timeout:{type:"number",title:'{{t("Timeout", { ns: "'.concat(u,'" })}}'),description:'{{t("The maximum execution time of the script. 0 means no timeout.", { ns: "'.concat(u,'" })}}'),"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:0,className:"auto-width",addonAfter:'{{t("Milliseconds", { ns: "'.concat(u,'" })}}')},default:0},continue:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":'{{t("Continue when exception thrown", { ns: "'.concat(u,'" })}}'),default:!1}}),s(e,"scope",{useScriptDescription:y}),s(e,"components",{ArrayItems:t.ArrayItems,CodeEditor:b,WorkflowVariableInput:r.WorkflowVariableInput,Space:o.Space}),s(e,"testable",!0),e}return l.prototype=Object.create(e&&e.prototype,{constructor:{value:l,writable:!0,configurable:!0}}),e&&f(l,e),i=[{key:"useVariables",value:function(e,t){var n=e.key,o=e.title,i=t.types;return(void 0===t.fieldNames&&r.defaultFieldNames,i&&!i.some(function(e){return e in r.BaseTypeSets||Object.values(r.BaseTypeSets).some(function(t){return t.has(e)})}))?null:{value:n,label:o}}},{key:"useInitializers",value:function(e){var t,n;return{name:null!=(t=e.title)?t:"#".concat(e.id),type:"item",title:null!=(n=e.title)?n:"#".concat(e.id),Component:r.ValueBlock.Initializer,node:e,resultTitle:a("Script result")}}},{key:"getCreateModelMenuItem",value:function(e){var t,n,r=e.node;return{key:null!=(t=r.title)?t:"#".concat(r.id),label:null!=(n=r.title)?n:"#".concat(r.id),useModel:"NodeValueModel",createModelOptions:{use:"NodeValueModel",stepParams:{valueSettings:{init:{dataSource:"{{$jobsMapByNodeKey.".concat(r.key,"}}"),defaultValue:a("Script result")}},cardSettings:{titleDescription:{title:'{{t("JavaScript", { ns: "'.concat(u,'" })}}')}}}}}}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(l.prototype,i),l}(r.Instruction);function v(e,t,n,r,o,i,c){try{var u=e[i](c),a=u.value}catch(e){n(e);return}u.done?t(a):Promise.resolve(a).then(r,o)}function w(e,t,n){return(w=k()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&j(o,n.prototype),o}).apply(null,arguments)}function x(e){return(x=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function j(e,t){return(j=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function O(e){var t="function"==typeof Map?new Map:void 0;return(O=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return w(e,arguments,x(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),j(n,e)})(e)}function k(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(k=function(){return!!e})()}var _=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=x(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,k()?Reflect.construct(e,t||[],x(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&j(n,e),t=[{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){var a=[i,u];if(n)throw TypeError("Generator is already executing.");for(;c;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,r=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=t.call(e,c)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}}(this,function(e){return t.app.pm.get("workflow").registerInstruction("script",m),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function c(e){v(i,r,o,c,u,"next",e)}function u(e){v(i,r,o,c,u,"throw",e)}c(void 0)})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(O(e.Plugin)),S=_}(),g}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("ahooks"),require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("@formily/antd-v5"),require("react"),require("@ant-design/icons"),require("lodash"),require("antd"),require("antd-style"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-javascript",["ahooks","@nocobase/client","@nocobase/plugin-workflow/client","@formily/antd-v5","react","@ant-design/icons","lodash","antd","antd-style","react-i18next"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-javascript"]=t(require("ahooks"),require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("@formily/antd-v5"),require("react"),require("@ant-design/icons"),require("lodash"),require("antd"),require("antd-style"),require("react-i18next")):e["@nocobase/plugin-workflow-javascript"]=t(e.ahooks,e["@nocobase/client"],e["@nocobase/plugin-workflow/client"],e["@formily/antd-v5"],e.react,e["@ant-design/icons"],e.lodash,e.antd,e["antd-style"],e["react-i18next"])}(self,function(e,t,n,r,o,i,c,u,a,l){return function(){var s,p,f,d,b,y,m={3581:function(e){e.exports=function(e,t){return"undefined"!=typeof __deoptimization_sideEffect__&&__deoptimization_sideEffect__(e,t),t}},482:function(e){"use strict";e.exports=i},4632:function(e){"use strict";e.exports=r},3772:function(e){"use strict";e.exports=t},8433:function(e){"use strict";e.exports=n},2749:function(t){"use strict";t.exports=e},2721:function(e){"use strict";e.exports=u},8202:function(e){"use strict";e.exports=a},467:function(e){"use strict";e.exports=c},8156:function(e){"use strict";e.exports=o},3238:function(e){"use strict";e.exports=l}},v={};function h(e){var t=v[e];if(void 0!==t)return t.exports;var n=v[e]={exports:{}};return m[e](n,n.exports,h),n.exports}h.m=m,h.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return h.d(t,{a:t}),t},h.d=function(e,t){for(var n in t)h.o(t,n)&&!h.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},h.f={},h.e=function(e){return Promise.all(Object.keys(h.f).reduce(function(t,n){return h.f[n](e,t),t},[]))},h.u=function(e){return""+e+"."+({222:"14d8875e2c6f2280",701:"b08b27a00a835b5b"})[e]+".js"},h.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),h.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s={},p="@nocobase/plugin-workflow-javascript:",h.l=function(e,t,n,r){if(s[e])return void s[e].push(t);if(void 0!==n)for(var o,i,c=document.getElementsByTagName("script"),u=0;u<c.length;u++){var a=c[u];if(a.getAttribute("src")==e||a.getAttribute("data-webpack")==p+n){o=a;break}}o||(i=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,h.nc&&o.setAttribute("nonce",h.nc),o.setAttribute("data-webpack",p+n),o.src=e),s[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(f);var r=s[e];if(delete s[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},f=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),i&&document.head.appendChild(o)},h.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(f=window.__webpack_public_path__||"/").endsWith("/")||(f+="/"),h.p=f+"static/plugins/@nocobase/plugin-workflow-javascript/dist/client/",d={909:0},h.f.j=function(e,t){var n=h.o(d,e)?d[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=d[e]=[t,r]});t.push(n[2]=r);var o=h.p+h.u(e),i=Error();h.l(o,function(t){if(h.o(d,e)&&(0!==(n=d[e])&&(d[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},b=function(e,t){var n,r,o=t[0],i=t[1],c=t[2],u=0;if(o.some(function(e){return 0!==d[e]})){for(n in i)h.o(i,n)&&(h.m[n]=i[n]);c&&c(h)}for(e&&e(t);u<o.length;u++)r=o[u],h.o(d,r)&&d[r]&&d[r][0](),d[r]=0},(y=self.webpackChunk_nocobase_plugin_workflow_javascript=self.webpackChunk_nocobase_plugin_workflow_javascript||[]).forEach(b.bind(null,0)),y.push=b.bind(null,y.push.bind(y));var g={};return!function(){"use strict";h.r(g),h.d(g,{PluginWorkflowScriptClient:function(){return _},default:function(){return S}});var e=h(3772),t=h(4632),n=h(482),r=h(8433),o=h(2721),i=h(8156),c=h.n(i);h(3238);var u="workflow-javascript";function a(t){var n,r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.i18n.t(t,(n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},o),r=r={ns:u},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n))}var l=h(3581);function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function d(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(d=function(){return!!e})()}var b=(0,i.lazy)(function(){return l("imported_-9r67ij_component",Promise.all([h.e("701"),h.e("222")]).then(h.bind(h,1706)))});function y(){return c().createElement("div",null,c().createElement("span",null,a("Node.js features supported can be found in the documentaion: ")),c().createElement("a",{href:a("https://docs.nocobase.com/handbook/workflow-javascript"),target:"_blank",rel:"noreferrer"},a("JavaScript node")))}var m=function(e){var i;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function l(){var e,i,f;if(!(this instanceof l))throw TypeError("Cannot call a class as a function");return i=l,f=arguments,i=p(i),s(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,d()?Reflect.construct(i,f||[],p(this).constructor):i.apply(this,f)),"title","JavaScript"),s(e,"type","script"),s(e,"group","extended"),s(e,"description",'{{t("Execute a piece of JavaScript in an isolated Node.js environment.", { ns: "'.concat(u,'" })}}')),s(e,"icon",c().createElement(n.CodeOutlined,null)),s(e,"fieldset",{arguments:{type:"array",title:'{{t("Arguments", { ns: "'.concat(u,'" })}}'),description:'{{t("The arguments that will be used in script with same name.", { ns: "'.concat(u,'" })}}'),"x-decorator":"FormItem","x-component":"ArrayItems",default:[],items:{type:"object","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'},"x-validator":function(e,t,n){var r=RegExp("^[\\p{L}$_][\\p{L}\\p{N}$_]*$","u"),o=n.form.getValuesIn().arguments.filter(function(t){return t.name===e});return r.test(e)?!(o.length>1)||a("Argument name duplicated"):a("Argument name is invalid")}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,useTypedConstant:!0,placeholder:'{{t("Value")}}'}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}},properties:{add:{type:"void",title:'{{t("Add argument", { ns: "'.concat(u,'" })}}'),"x-component":"ArrayItems.Addition"}}},content:{type:"string",title:'{{t("Script content", { ns: "'.concat(u,'" })}}'),description:"{{useScriptDescription()}}","x-decorator":"FormItem","x-component":"CodeEditor",default:'return "Hello world!";'},timeout:{type:"number",title:'{{t("Timeout", { ns: "'.concat(u,'" })}}'),description:'{{t("The maximum execution time of the script. 0 means no timeout.", { ns: "'.concat(u,'" })}}'),"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:0,className:"auto-width",addonAfter:'{{t("Milliseconds", { ns: "'.concat(u,'" })}}')},default:0},continue:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":'{{t("Continue when exception thrown", { ns: "'.concat(u,'" })}}'),default:!1}}),s(e,"scope",{useScriptDescription:y}),s(e,"components",{ArrayItems:t.ArrayItems,CodeEditor:b,WorkflowVariableInput:r.WorkflowVariableInput,Space:o.Space}),s(e,"testable",!0),e}return l.prototype=Object.create(e&&e.prototype,{constructor:{value:l,writable:!0,configurable:!0}}),e&&f(l,e),i=[{key:"useVariables",value:function(e,t){var n=e.key,o=e.title,i=t.types;return(void 0===t.fieldNames&&r.defaultFieldNames,i&&!i.some(function(e){return e in r.BaseTypeSets||Object.values(r.BaseTypeSets).some(function(t){return t.has(e)})}))?null:{value:n,label:o}}},{key:"useInitializers",value:function(e){var t,n;return{name:null!=(t=e.title)?t:"#".concat(e.id),type:"item",title:null!=(n=e.title)?n:"#".concat(e.id),Component:r.ValueBlock.Initializer,node:e,resultTitle:a("Script result")}}},{key:"getCreateModelMenuItem",value:function(e){var t,n,r=e.node;return{key:null!=(t=r.title)?t:"#".concat(r.id),label:null!=(n=r.title)?n:"#".concat(r.id),useModel:"NodeValueModel",createModelOptions:{use:"NodeValueModel",stepParams:{valueSettings:{init:{dataSource:"{{$jobsMapByNodeKey.".concat(r.key,"}}"),defaultValue:a("Script result")}},cardSettings:{titleDescription:{title:'{{t("JavaScript", { ns: "'.concat(u,'" })}}')}}}}}}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(l.prototype,i),l}(r.Instruction);function v(e,t,n,r,o,i,c){try{var u=e[i](c),a=u.value}catch(e){n(e);return}u.done?t(a):Promise.resolve(a).then(r,o)}function w(e,t,n){return(w=k()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&j(o,n.prototype),o}).apply(null,arguments)}function x(e){return(x=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function j(e,t){return(j=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function O(e){var t="function"==typeof Map?new Map:void 0;return(O=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return w(e,arguments,x(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),j(n,e)})(e)}function k(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(k=function(){return!!e})()}var _=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=x(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,k()?Reflect.construct(e,t||[],x(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&j(n,e),t=[{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){var a=[i,u];if(n)throw TypeError("Generator is already executing.");for(;c;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,r=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=t.call(e,c)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}}(this,function(e){return t.app.pm.get("workflow").registerInstruction("script",m),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function c(e){v(i,r,o,c,u,"next",e)}function u(e){v(i,r,o,c,u,"throw",e)}c(void 0)})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(O(e.Plugin)),S=_}(),g}()});
@@ -13,11 +13,11 @@ module.exports = {
13
13
  "antd-style": "3.7.1",
14
14
  "@formily/antd-v5": "1.2.3",
15
15
  "@ant-design/icons": "5.6.1",
16
- "@nocobase/client": "2.1.0-beta.13",
17
- "@nocobase/plugin-workflow": "2.1.0-beta.13",
16
+ "@nocobase/client": "2.1.0-beta.14",
17
+ "@nocobase/plugin-workflow": "2.1.0-beta.14",
18
18
  "antd": "5.24.2",
19
- "@nocobase/flow-engine": "2.1.0-beta.13",
19
+ "@nocobase/flow-engine": "2.1.0-beta.14",
20
20
  "react-i18next": "11.18.6",
21
21
  "winston": "3.13.0",
22
- "@nocobase/server": "2.1.0-beta.13"
22
+ "@nocobase/server": "2.1.0-beta.14"
23
23
  };
@@ -1 +1 @@
1
- {"name":"isolated-vm","version":"5.0.4","description":"Access to multiple isolates","main":"isolated-vm.js","types":"isolated-vm.d.ts","engines":{"node":">=18.0.0"},"scripts":{"install":"prebuild-install || (node-gyp rebuild --release -j max && node-gyp clean)","rebuild":"node-gyp rebuild --release -j max","lint":"find src -name '*.cc' | xargs -n1 clang-tidy","test":"node test.js"},"dependencies":{"prebuild-install":"^7.1.2"},"devDependencies":{"isolated-vm":".","prebuild":"^13.0.1"},"binary":{"module_path":"out"},"repository":{"type":"git","url":"git+https://github.com/laverdet/isolated-vm.git"},"author":"https://github.com/laverdet/","license":"ISC","gypfile":true,"bugs":{"url":"https://github.com/laverdet/isolated-vm/issues"},"homepage":"https://github.com/laverdet/isolated-vm#readme","_lastModified":"2026-04-08T16:24:25.185Z"}
1
+ {"name":"isolated-vm","version":"5.0.4","description":"Access to multiple isolates","main":"isolated-vm.js","types":"isolated-vm.d.ts","engines":{"node":">=18.0.0"},"scripts":{"install":"prebuild-install || (node-gyp rebuild --release -j max && node-gyp clean)","rebuild":"node-gyp rebuild --release -j max","lint":"find src -name '*.cc' | xargs -n1 clang-tidy","test":"node test.js"},"dependencies":{"prebuild-install":"^7.1.2"},"devDependencies":{"isolated-vm":".","prebuild":"^13.0.1"},"binary":{"module_path":"out"},"repository":{"type":"git","url":"git+https://github.com/laverdet/isolated-vm.git"},"author":"https://github.com/laverdet/","license":"ISC","gypfile":true,"bugs":{"url":"https://github.com/laverdet/isolated-vm/issues"},"homepage":"https://github.com/laverdet/isolated-vm#readme","_lastModified":"2026-04-20T09:22:20.565Z"}
@@ -1 +1 @@
1
- {"name":"winston-transport","description":"Base stream implementations for winston@3 and up.","version":"4.7.0","main":"index.js","browser":"dist/index.js","scripts":{"lint":"eslint test/*.js index.js --resolve-plugins-relative-to ./node_modules/@dabh/eslint-config-populist","pretest":"npm run lint && npm run build","test":"nyc mocha test/*.test.js","report":"nyc report --reporter=lcov","build":"rimraf dist && babel *.js -d ./dist","prepublishOnly":"npm run build"},"repository":{"type":"git","url":"git@github.com:winstonjs/winston-transport.git"},"keywords":["winston","transport","winston3"],"author":"Charlie Robbins <charlie.robbins@gmail.com>","license":"MIT","bugs":{"url":"https://github.com/winstonjs/winston-transport/issues"},"homepage":"https://github.com/winstonjs/winston-transport#readme","dependencies":{"logform":"^2.3.2","readable-stream":"^3.6.0","triple-beam":"^1.3.0"},"devDependencies":{"@types/node":"^20.8.6","abstract-winston-transport":">=0.5.1","assume":"^2.3.0","babel-cli":"^6.26.0","babel-preset-env":"^1.7.0","deep-equal":"^2.0.5","eslint":"^8.8.0","@dabh/eslint-config-populist":"^5.0.0","mocha":"^10.0.0","nyc":"^15.1.0","rimraf":"^5.0.5","winston-compat":"^0.1.5"},"engines":{"node":">= 12.0.0"},"_lastModified":"2026-04-08T16:24:25.651Z"}
1
+ {"name":"winston-transport","description":"Base stream implementations for winston@3 and up.","version":"4.7.0","main":"index.js","browser":"dist/index.js","scripts":{"lint":"eslint test/*.js index.js --resolve-plugins-relative-to ./node_modules/@dabh/eslint-config-populist","pretest":"npm run lint && npm run build","test":"nyc mocha test/*.test.js","report":"nyc report --reporter=lcov","build":"rimraf dist && babel *.js -d ./dist","prepublishOnly":"npm run build"},"repository":{"type":"git","url":"git@github.com:winstonjs/winston-transport.git"},"keywords":["winston","transport","winston3"],"author":"Charlie Robbins <charlie.robbins@gmail.com>","license":"MIT","bugs":{"url":"https://github.com/winstonjs/winston-transport/issues"},"homepage":"https://github.com/winstonjs/winston-transport#readme","dependencies":{"logform":"^2.3.2","readable-stream":"^3.6.0","triple-beam":"^1.3.0"},"devDependencies":{"@types/node":"^20.8.6","abstract-winston-transport":">=0.5.1","assume":"^2.3.0","babel-cli":"^6.26.0","babel-preset-env":"^1.7.0","deep-equal":"^2.0.5","eslint":"^8.8.0","@dabh/eslint-config-populist":"^5.0.0","mocha":"^10.0.0","nyc":"^15.1.0","rimraf":"^5.0.5","winston-compat":"^0.1.5"},"engines":{"node":">= 12.0.0"},"_lastModified":"2026-04-20T09:22:21.027Z"}
package/dist/server/Vm.js CHANGED
@@ -11,34 +11,184 @@ const { parentPort, workerData } = require("node:worker_threads");
11
11
  const { Script } = require("node:vm");
12
12
  const Path = require("node:path");
13
13
  let timer = null;
14
- function customRequire(m) {
15
- var _a;
16
- const configuredModules = (((_a = process.env.WORKFLOW_SCRIPT_MODULES) == null ? void 0 : _a.split(",")) ?? []).filter(Boolean);
17
- let mainName;
18
- if (Path.isAbsolute(m)) {
19
- mainName = m;
20
- } else if (m.startsWith(".")) {
21
- mainName = m;
22
- m = Path.resolve(process.cwd(), m);
23
- } else {
24
- mainName = m.split("/").slice(0, m.startsWith("@") ? 2 : 1).join("/");
25
- }
26
- if (configuredModules.includes(mainName)) {
27
- return require(m);
28
- }
29
- throw new Error(`module "${m}" not supported`);
30
- }
31
- function hardenFunction(fn) {
32
- Object.setPrototypeOf(fn, null);
33
- Object.defineProperty(fn, "constructor", {
14
+ function harden(v) {
15
+ Object.setPrototypeOf(v, null);
16
+ Object.defineProperty(v, "constructor", {
34
17
  value: null,
35
18
  writable: false,
36
19
  enumerable: false,
37
20
  configurable: false
38
21
  });
39
- return fn;
22
+ return v;
23
+ }
24
+ function createSandboxError(msg) {
25
+ return harden(new Error(msg));
26
+ }
27
+ function resolveProperty(obj, key) {
28
+ const desc = Object.getOwnPropertyDescriptor(obj, key);
29
+ if (!desc) return void 0;
30
+ if ("value" in desc) return desc.value;
31
+ if (desc.get) {
32
+ try {
33
+ return desc.get.call(obj);
34
+ } catch (_) {
35
+ return void 0;
36
+ }
37
+ }
38
+ return void 0;
39
+ }
40
+ function sanitizeError(e) {
41
+ let msg;
42
+ try {
43
+ msg = e != null && typeof e.message === "string" ? e.message : String(e);
44
+ } catch (_) {
45
+ msg = "unknown error";
46
+ }
47
+ return createSandboxError(msg);
48
+ }
49
+ function sanitizeReturnValue(result) {
50
+ if (result === null || result === void 0) return result;
51
+ if (typeof result !== "object" && typeof result !== "function") return result;
52
+ if (typeof result.then === "function") {
53
+ const cleanThenable = /* @__PURE__ */ Object.create(null);
54
+ const originalThen = result.then.bind(result);
55
+ Object.defineProperty(cleanThenable, "then", {
56
+ value: harden(function(onFulfilled, onRejected) {
57
+ const next = originalThen(
58
+ typeof onFulfilled === "function" ? (v) => onFulfilled(sanitizeForSandbox(v, null, /* @__PURE__ */ new WeakMap())) : onFulfilled,
59
+ typeof onRejected === "function" ? (e) => onRejected(sanitizeError(e)) : onRejected
60
+ );
61
+ return sanitizeReturnValue(next);
62
+ }),
63
+ writable: false,
64
+ enumerable: true,
65
+ configurable: false
66
+ });
67
+ return cleanThenable;
68
+ }
69
+ return sanitizeForSandbox(result, null, /* @__PURE__ */ new WeakMap());
70
+ }
71
+ function sanitizeForSandbox(val, parent, cache) {
72
+ if (!cache) cache = /* @__PURE__ */ new WeakMap();
73
+ if (val === null || val === void 0) return val;
74
+ if (typeof val !== "object" && typeof val !== "function") return val;
75
+ if (cache.has(val)) return cache.get(val);
76
+ if (typeof val === "function") {
77
+ const fn = parent != null ? val.bind(parent) : val;
78
+ const wrapper = function(...args) {
79
+ let ret;
80
+ try {
81
+ ret = fn(...args);
82
+ } catch (e) {
83
+ throw sanitizeError(e);
84
+ }
85
+ return sanitizeReturnValue(ret);
86
+ };
87
+ cache.set(val, wrapper);
88
+ harden(wrapper);
89
+ const SKIP_PROPS = /* @__PURE__ */ new Set(["length", "name", "prototype", "caller", "arguments", "constructor"]);
90
+ for (const key of Object.getOwnPropertyNames(val)) {
91
+ if (SKIP_PROPS.has(key)) continue;
92
+ try {
93
+ const resolved = resolveProperty(val, key);
94
+ if (resolved !== void 0) {
95
+ Object.defineProperty(wrapper, key, {
96
+ value: sanitizeForSandbox(resolved, val, cache),
97
+ writable: false,
98
+ enumerable: true,
99
+ configurable: false
100
+ });
101
+ }
102
+ } catch (_) {
103
+ }
104
+ }
105
+ return wrapper;
106
+ }
107
+ if (Array.isArray(val)) {
108
+ const len = val.length;
109
+ const cleanArr = /* @__PURE__ */ Object.create(null);
110
+ cache.set(val, cleanArr);
111
+ Object.defineProperty(cleanArr, "length", {
112
+ value: len,
113
+ writable: false,
114
+ enumerable: false,
115
+ configurable: false
116
+ });
117
+ for (let i = 0; i < len; i++) {
118
+ try {
119
+ cleanArr[i] = sanitizeForSandbox(val[i], null, cache);
120
+ } catch (_) {
121
+ }
122
+ }
123
+ Object.defineProperty(cleanArr, Symbol.iterator, {
124
+ value: harden(function() {
125
+ let idx = 0;
126
+ const iterator = /* @__PURE__ */ Object.create(null);
127
+ iterator.next = harden(function() {
128
+ const result = /* @__PURE__ */ Object.create(null);
129
+ if (idx < len) {
130
+ result.value = cleanArr[idx++];
131
+ result.done = false;
132
+ } else {
133
+ result.value = void 0;
134
+ result.done = true;
135
+ }
136
+ return result;
137
+ });
138
+ iterator[Symbol.iterator] = harden(function() {
139
+ return iterator;
140
+ });
141
+ return iterator;
142
+ }),
143
+ writable: false,
144
+ enumerable: false,
145
+ configurable: false
146
+ });
147
+ return cleanArr;
148
+ }
149
+ const clean = /* @__PURE__ */ Object.create(null);
150
+ cache.set(val, clean);
151
+ let proto = val;
152
+ while (proto !== null && proto !== Object.prototype) {
153
+ for (const key of Object.getOwnPropertyNames(proto)) {
154
+ if (key === "constructor" || key in clean) continue;
155
+ try {
156
+ const resolved = resolveProperty(proto, key);
157
+ if (resolved !== void 0) {
158
+ clean[key] = sanitizeForSandbox(resolved, val, cache);
159
+ }
160
+ } catch (_) {
161
+ }
162
+ }
163
+ proto = Object.getPrototypeOf(proto);
164
+ }
165
+ return clean;
40
166
  }
41
- hardenFunction(customRequire);
167
+ function customRequire(m) {
168
+ var _a;
169
+ try {
170
+ if (typeof m !== "string") {
171
+ throw new Error("module name must be a string");
172
+ }
173
+ const configuredModules = (((_a = process.env.WORKFLOW_SCRIPT_MODULES) == null ? void 0 : _a.split(",")) ?? []).filter(Boolean);
174
+ let mainName;
175
+ if (Path.isAbsolute(m)) {
176
+ mainName = m;
177
+ } else if (m.startsWith(".")) {
178
+ mainName = m;
179
+ m = Path.resolve(process.cwd(), m);
180
+ } else {
181
+ mainName = m.split("/").slice(0, m.startsWith("@") ? 2 : 1).join("/");
182
+ }
183
+ if (configuredModules.includes(mainName)) {
184
+ return sanitizeForSandbox(require(m));
185
+ }
186
+ throw new Error(`module "${m}" not supported`);
187
+ } catch (e) {
188
+ throw sanitizeError(e);
189
+ }
190
+ }
191
+ harden(customRequire);
42
192
  function createSafeConsole(originalConsole) {
43
193
  const safe = /* @__PURE__ */ Object.create(null);
44
194
  const allowedMethods = [
@@ -64,8 +214,7 @@ function createSafeConsole(originalConsole) {
64
214
  ];
65
215
  for (const key of allowedMethods) {
66
216
  if (typeof originalConsole[key] === "function") {
67
- const bound = originalConsole[key].bind(originalConsole);
68
- hardenFunction(bound);
217
+ const bound = harden(originalConsole[key].bind(originalConsole));
69
218
  Object.defineProperty(safe, key, {
70
219
  value: bound,
71
220
  writable: false,
@@ -74,13 +223,7 @@ function createSafeConsole(originalConsole) {
74
223
  });
75
224
  }
76
225
  }
77
- Object.defineProperty(safe, "constructor", {
78
- value: null,
79
- writable: false,
80
- enumerable: false,
81
- configurable: false
82
- });
83
- return Object.freeze(safe);
226
+ return Object.freeze(harden(safe));
84
227
  }
85
228
  async function main() {
86
229
  const { source, args = {}, options = {} } = workerData;
@@ -105,8 +248,17 @@ async function main() {
105
248
  const result = script.runInNewContext(context, { timeout: options.timeout });
106
249
  return result;
107
250
  }
251
+ function toJsonResult(value) {
252
+ if (value === null || value === void 0) return value;
253
+ if (typeof value !== "object" && typeof value !== "function") return value;
254
+ try {
255
+ return JSON.parse(JSON.stringify(value));
256
+ } catch (_) {
257
+ return value;
258
+ }
259
+ }
108
260
  main().then((result) => {
109
- parentPort.postMessage({ type: "result", result });
261
+ parentPort.postMessage({ type: "result", result: toJsonResult(result) });
110
262
  }).catch((error) => {
111
263
  throw error;
112
264
  }).finally(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-workflow-javascript",
3
- "version": "2.1.0-beta.13",
3
+ "version": "2.1.0-beta.14",
4
4
  "displayName": "Workflow: JavaScript",
5
5
  "displayName.zh-CN": "工作流:JavaScript 节点",
6
6
  "description": "Execute a piece of JavaScript in an isolated Node.js environment.",
@@ -37,5 +37,5 @@
37
37
  "Workflow"
38
38
  ],
39
39
  "license": "Apache-2.0",
40
- "gitHead": "691716e5f4e5f8bd3859d65bc8a29b4e3c32209b"
40
+ "gitHead": "cd55c9a14596d834c30c83a82c38f1f719f7aac4"
41
41
  }