@nocobase/plugin-workflow-dynamic-calculation 1.7.0-beta.8 → 1.8.0-beta.1

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.
@@ -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("react-i18next"),require("@nocobase/evaluators/client"),require("@formily/core"),require("@nocobase/client"),require("antd"),require("@ant-design/icons"),require("@formily/react"),require("@nocobase/plugin-workflow/client"),require("react")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-dynamic-calculation",["react-i18next","@nocobase/evaluators/client","@formily/core","@nocobase/client","antd","@ant-design/icons","@formily/react","@nocobase/plugin-workflow/client","react"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-dynamic-calculation"]=t(require("react-i18next"),require("@nocobase/evaluators/client"),require("@formily/core"),require("@nocobase/client"),require("antd"),require("@ant-design/icons"),require("@formily/react"),require("@nocobase/plugin-workflow/client"),require("react")):e["@nocobase/plugin-workflow-dynamic-calculation"]=t(e["react-i18next"],e["@nocobase/evaluators/client"],e["@formily/core"],e["@nocobase/client"],e.antd,e["@ant-design/icons"],e["@formily/react"],e["@nocobase/plugin-workflow/client"],e.react)}(self,function(e,t,n,r,o,i,c,u,a){return function(){"use strict";var l={482:function(e){e.exports=i},563:function(e){e.exports=n},505:function(e){e.exports=c},772:function(e){e.exports=r},47:function(e){e.exports=t},433:function(e){e.exports=u},721:function(e){e.exports=o},156:function(e){e.exports=a},238:function(t){t.exports=e}},s={};function f(e){var t=s[e];if(void 0!==t)return t.exports;var n=s[e]={exports:{}};return l[e](n,n.exports,f),n.exports}f.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(t,{a:t}),t},f.d=function(e,t){for(var n in t)f.o(t,n)&&!f.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},f.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var p={};f.r(p),f.d(p,{default:function(){return eo}});var y=f("772"),b=f("156"),d=f.n(b),m=f("482"),v=f("433"),g=f("238"),h="workflow-dynamic-calculation";function O(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)}}function w(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}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 P(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(P=function(){return!!e})()}function S(e){var t;if(!["belongsTo","hasOne"].includes(e.type))return!1;if((null===(t=this.getCollection(e.collectionName))||void 0===t?void 0:t.template)==="expression")return!0;return this.getCollectionFields(e.target).some(function(e){return"expression"===e.interface})}function C(e){var t=e.value,n=e.onChange,r=(0,y.useCollectionManager_deprecated)(),o=r.getCollectionFields,i=r.getCollection,c=(0,v.useWorkflowVariableOptions)({types:[S.bind({getCollectionFields:o,getCollection:i})]});return d().createElement(y.Variable.Input,{value:t,onChange:n,scope:c})}var _=function(e){var t,n,r;function o(){var e,t,n,r;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),t=this,n=o,r=arguments,n=x(n),w(e=function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(t,P()?Reflect.construct(n,r||[],x(t).constructor):n.apply(t,r)),"title",'{{t("Dynamic expression calculation", { ns: "'.concat(h,'" })}}')),w(e,"type","dynamic-calculation"),w(e,"group","calculation"),w(e,"description",'{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression. The expression is dynamic one from an expression collections.", { ns: "'.concat(h,'" })}}')),w(e,"icon",d().createElement(m.FunctionOutlined,null)),w(e,"fieldset",{expression:{type:"string",title:'{{t("Calculation expression", { ns: "'.concat(h,'" })}}'),"x-decorator":"FormItem","x-component":"DynamicExpression",required:!0},scope:{type:"string",title:'{{t("Variable datasource", { ns: "'.concat(h,'" })}}'),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,variableOptions:{types:[{type:"reference",options:{collection:"*",entity:!0}}]}},"x-reactions":{dependencies:["expression"],fulfill:{state:{visible:"{{$deps[0]}}"}}}}}),w(e,"components",{DynamicExpression:C,WorkflowVariableInput:v.WorkflowVariableInput,ValueBlock:v.ValueBlock}),e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&j(e,t)}(o,e),t=o,n=[{key:"useVariables",value:function(e,t){var n,r=e.key,o=e.title,i=t.types,c=t.fieldNames,u=void 0===c?v.defaultFieldNames:c;return i&&!i.some(function(e){return e in v.BaseTypeSets||Object.values(v.BaseTypeSets).some(function(t){return t.has(e)})})?null:(w(n={},u.value,r),w(n,u.label,o),n)}},{key:"useInitializers",value:function(e){var t;return{name:"#".concat(e.id),type:"item",title:null!==(t=e.title)&&void 0!==t?t:"#".concat(e.id),Component:v.ValueBlock.Initializer,node:e,resultTitle:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,function(e){return(0,g.useTranslation)(h,e)}(t).t)(e)}("Calculation result")}}}],O(t.prototype,n),o}(v.Instruction),E=f("563"),k=f("505"),T=f("721");function F(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function I(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,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}function q(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function V(e,t){if(e){if("string"==typeof e)return F(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return F(e,t)}}var R=(0,k.observer)(function(e){var t,n,r,o=e.onChange,i=(0,k.useField)(),c=(0,k.useForm)();var u=((function(e){if(Array.isArray(e))return F(e)})(t=i.path.segments.slice(0,-1))||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||V(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat(["sourceCollection"]).join(".");var a=(n=(0,b.useState)(c.getValuesIn(u)),r=2,function(e){if(Array.isArray(e))return e}(n)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],c=!0,u=!1;try{for(o=o.call(e);!(c=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);c=!0);}catch(e){u=!0,r=e}finally{try{!c&&null!=o.return&&o.return()}finally{if(u)throw r}}return i}}(n,2)||V(n,r)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),l=a[0],s=a[1],f=(0,y.useCompile)(),p=(0,y.useCollectionManager_deprecated)().getCollectionFields;(0,k.useFormEffects)(function(){(0,E.onFormInitialValuesChange)(function(e){s(e.getValuesIn(u))}),(0,E.onFieldInputValueChange)(u,function(e){s(e.value),o(null)})});var m=(0,v.getCollectionFieldOptions)({collection:l,compile:f,getCollectionFields:p});return d().createElement(y.Variable.TextArea,q(I({},e),{scope:m}))},{displayName:"InternalExpression"}),B=(0,k.connect)(R,(0,k.mapReadPretty)(function(e){var t=(0,g.useTranslation)().t,n=(0,y.useRecord)(),r=(0,y.useCompile)(),o=(0,y.useCollectionManager_deprecated)().getCollectionFields,i=(0,b.useMemo)(function(){return(0,v.getCollectionFieldOptions)({collection:n.sourceCollection,compile:r,getCollectionFields:o})},[n.sourceCollection,n.sourceCollection]);return e.value?d().createElement(y.Variable.TextArea,q(I({},e),{scope:i})):d().createElement(T.Tag,null,t("Unconfigured",{ns:h}))}));function A(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function M(e){return(M=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function D(e,t){return(D=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function N(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(N=function(){return!!e})()}var W=y.interfacesProperties.defaultProps,G=function(e){function t(){var e,n,r,o;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),n=this,r=t,o=arguments,r=M(r),A(e=function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(n,N()?Reflect.construct(r,o||[],M(n).constructor):r.apply(n,o)),"name","expression"),A(e,"type","string"),A(e,"group","advanced"),A(e,"order",1),A(e,"title",'{{t("Expression", { ns: "'.concat(h,'" })}}')),A(e,"description",'{{t("Used to store expressions for use in workflows so that different expressions can be called for different data.", { ns: "'.concat(h,'" })}}')),A(e,"sortable",!0),A(e,"default",{type:"text",uiSchema:{"x-component":"DynamicExpression"}}),A(e,"properties",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){A(e,t,n[t])})}return e}({},W)),A(e,"hidden",!0),e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&D(e,t)}(t,e),t}(y.CollectionFieldInterface),U=f("47");function z(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $(e){return($=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function L(e,t){return(L=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function H(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(H=function(){return!!e})()}var J=function(e){function t(){var e,n,r,o;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),n=this,r=t,o=arguments,r=$(r),z(e=function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(n,H()?Reflect.construct(r,o||[],$(n).constructor):r.apply(n,o)),"name","expression"),z(e,"title",'{{t("Expression collection")}}'),z(e,"order",4),z(e,"color","orange"),z(e,"default",{createdBy:!0,updatedBy:!0,createdAt:!0,updatedAt:!0,fields:[{name:"engine",type:"string",interface:"radioGroup",uiSchema:{type:"string",title:'{{t("Calculation engine")}}',"x-component":"Radio.Group",enum:(0,U.getOptions)(),default:"formula.js"}},{name:"sourceCollection",type:"string",interface:"select",uiSchema:{type:"string",title:'{{t("Collection")}}',"x-component":"CollectionSelect","x-component-props":{}}},{name:"expression",type:"text",interface:"expression",uiSchema:{type:"string",title:'{{t("Expression")}}',"x-component":"DynamicExpression"}}]}),z(e,"availableFieldInterfaces",{include:[]}),z(e,"configurableProperties",(0,y.getConfigurableProperties)("title","name","inherits","category","description","presetFields")),e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&L(e,t)}(t,e),t}(y.CollectionTemplate);function K(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 Q(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function c(e){K(i,r,o,c,u,"next",e)}function u(e){K(i,r,o,c,u,"throw",e)}c(void 0)})}}function X(e,t,n){return(X=en()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&ee(o,n.prototype),o}).apply(null,arguments)}function Y(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)}}function Z(e){return(Z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ee(e,t){return(ee=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function et(e){var t="function"==typeof Map?new Map:void 0;return(et=function(e){var n;if(null===e||(n=e,-1===Function.toString.call(n).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,r)}function r(){return X(e,arguments,Z(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),ee(r,e)})(e)}function en(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(en=function(){return!!e})()}function er(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){return function(i){if(n)throw TypeError("Generator is already executing.");for(;c;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,r=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){c=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){c.label=i[1];break}if(6===i[0]&&c.label<o[1]){c.label=o[1],o=i;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(i);break}o[2]&&c.ops.pop(),c.trys.pop();continue}i=t.call(e,c)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var eo=function(e){var t,n,r;function o(){var e,t,n;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),e=this,t=o,n=arguments,t=Z(t),function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,en()?Reflect.construct(t,n||[],Z(e).constructor):t.apply(e,n))}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ee(e,t)}(o,e),t=o,n=[{key:"afterAdd",value:function(){return Q(function(){return er(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return Q(function(){return er(this,function(e){return[2]})})()}},{key:"load",value:function(){var e=this;return Q(function(){var t,n;return er(this,function(r){return e.app.dataSourceManager.addFieldInterfaces([G]),e.app.addComponents({DynamicExpression:B}),e.dataSourceManager.addCollectionTemplates([J]),t=e.app.pm.get("workflow"),n=new _,t.instructions.register(n.type,n),[2]})})()}}],Y(t.prototype,n),o}(et(y.Plugin));return p}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@formily/core"),require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("react"),require("@formily/react"),require("@nocobase/evaluators/client"),require("@ant-design/icons"),require("antd"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-dynamic-calculation",["@formily/core","@nocobase/client","@nocobase/plugin-workflow/client","react","@formily/react","@nocobase/evaluators/client","@ant-design/icons","antd","react-i18next"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-dynamic-calculation"]=t(require("@formily/core"),require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("react"),require("@formily/react"),require("@nocobase/evaluators/client"),require("@ant-design/icons"),require("antd"),require("react-i18next")):e["@nocobase/plugin-workflow-dynamic-calculation"]=t(e["@formily/core"],e["@nocobase/client"],e["@nocobase/plugin-workflow/client"],e.react,e["@formily/react"],e["@nocobase/evaluators/client"],e["@ant-design/icons"],e.antd,e["react-i18next"])}(self,function(e,t,n,r,o,i,c,a,u){return function(){"use strict";var l={482:function(e){e.exports=c},563:function(t){t.exports=e},505:function(e){e.exports=o},772:function(e){e.exports=t},47:function(e){e.exports=i},433:function(e){e.exports=n},721:function(e){e.exports=a},156:function(e){e.exports=r},238:function(e){e.exports=u}},s={};function f(e){var t=s[e];if(void 0!==t)return t.exports;var n=s[e]={exports:{}};return l[e](n,n.exports,f),n.exports}f.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(t,{a:t}),t},f.d=function(e,t){for(var n in t)f.o(t,n)&&!f.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},f.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var p={};return!function(){f.r(p),f.d(p,{default:function(){return $}});var e=f(772),t=f(156),n=f.n(t),r=f(482),o=f(433),i=f(238),c="workflow-dynamic-calculation";function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(s=function(){return!!e})()}function y(e){var t;return!!["belongsTo","hasOne"].includes(e.type)&&((null==(t=this.getCollection(e.collectionName))?void 0:t.template)==="expression"||this.getCollectionFields(e.target).some(function(e){return"expression"===e.interface}))}function b(t){var r=t.value,i=t.onChange,c=(0,e.useCollectionManager_deprecated)(),a=c.getCollectionFields,u=c.getCollection,l=(0,o.useWorkflowVariableOptions)({types:[y.bind({getCollectionFields:a,getCollection:u})]});return n().createElement(e.Variable.Input,{value:r,onChange:i,scope:l})}var d=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function f(){var e,t,i;if(!(this instanceof f))throw TypeError("Cannot call a class as a function");return t=f,i=arguments,t=u(t),a(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,s()?Reflect.construct(t,i||[],u(this).constructor):t.apply(this,i)),"title",'{{t("Dynamic expression calculation", { ns: "'.concat(c,'" })}}')),a(e,"type","dynamic-calculation"),a(e,"group","calculation"),a(e,"description",'{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression. The expression is dynamic one from an expression collections.", { ns: "'.concat(c,'" })}}')),a(e,"icon",n().createElement(r.FunctionOutlined,null)),a(e,"fieldset",{expression:{type:"string",title:'{{t("Calculation expression", { ns: "'.concat(c,'" })}}'),"x-decorator":"FormItem","x-component":"DynamicExpression",required:!0},scope:{type:"string",title:'{{t("Variable datasource", { ns: "'.concat(c,'" })}}'),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,variableOptions:{types:[{type:"reference",options:{collection:"*",entity:!0}}]}},"x-reactions":{dependencies:["expression"],fulfill:{state:{visible:"{{$deps[0]}}"}}}}}),a(e,"components",{DynamicExpression:b,WorkflowVariableInput:o.WorkflowVariableInput,ValueBlock:o.ValueBlock}),e}return f.prototype=Object.create(e&&e.prototype,{constructor:{value:f,writable:!0,configurable:!0}}),e&&l(f,e),t=[{key:"useVariables",value:function(e,t){var n,r=e.key,i=e.title,c=t.types,u=t.fieldNames,l=void 0===u?o.defaultFieldNames:u;return c&&!c.some(function(e){return e in o.BaseTypeSets||Object.values(o.BaseTypeSets).some(function(t){return t.has(e)})})?null:(a(n={},l.value,r),a(n,l.label,i),n)}},{key:"useInitializers",value:function(e){var t;return{name:"#".concat(e.id),type:"item",title:null!=(t=e.title)?t:"#".concat(e.id),Component:o.ValueBlock.Initializer,node:e,resultTitle:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,(t=n,(0,i.useTranslation)(c,t)).t)(e)}("Calculation result")}}}],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)}}(f.prototype,t),f}(o.Instruction),m=f(563),v=f(505),h=f(721);function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function O(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}function w(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function x(e,t){if(e){if("string"==typeof e)return g(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return g(e,t)}}var j=(0,v.observer)(function(r){var i,c,a=r.onChange,u=(0,v.useField)(),l=(0,v.useForm)(),s=((function(e){if(Array.isArray(e))return g(e)})(i=u.path.segments.slice(0,-1))||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(i)||x(i)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat(["sourceCollection"]).join("."),f=(c=(0,t.useState)(l.getValuesIn(s)),function(e){if(Array.isArray(e))return e}(c)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],c=!0,a=!1;try{for(o=o.call(e);!(c=(n=o.next()).done)&&(i.push(n.value),i.length!==t);c=!0);}catch(e){a=!0,r=e}finally{try{c||null==o.return||o.return()}finally{if(a)throw r}}return i}}(c,2)||x(c,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),p=f[0],y=f[1],b=(0,e.useCompile)(),d=(0,e.useCollectionManager_deprecated)().getCollectionFields;(0,v.useFormEffects)(function(){(0,m.onFormInitialValuesChange)(function(e){y(e.getValuesIn(s))}),(0,m.onFieldInputValueChange)(s,function(e){y(e.value),a(null)})});var h=(0,o.getCollectionFieldOptions)({collection:p,compile:b,getCollectionFields:d});return n().createElement(e.Variable.TextArea,w(O({},r),{scope:h}))},{displayName:"InternalExpression"}),P=(0,v.connect)(j,(0,v.mapReadPretty)(function(r){var a=(0,i.useTranslation)().t,u=(0,e.useRecord)(),l=(0,e.useCompile)(),s=(0,e.useCollectionManager_deprecated)().getCollectionFields,f=(0,t.useMemo)(function(){return(0,o.getCollectionFieldOptions)({collection:u.sourceCollection,compile:l,getCollectionFields:s})},[u.sourceCollection,u.sourceCollection]);return r.value?n().createElement(e.Variable.TextArea,w(O({},r),{scope:f})):n().createElement(h.Tag,null,a("Unconfigured",{ns:c}))}));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 C(e){return(C=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _(e,t){return(_=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function E(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(E=function(){return!!e})()}var k=e.interfacesProperties.defaultProps,T=function(e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function t(){var e,n,r;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");return n=t,r=arguments,n=C(n),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,E()?Reflect.construct(n,r||[],C(this).constructor):n.apply(this,r)),"name","expression"),S(e,"type","string"),S(e,"group","advanced"),S(e,"order",1),S(e,"title",'{{t("Expression", { ns: "'.concat(c,'" })}}')),S(e,"description",'{{t("Used to store expressions for use in workflows so that different expressions can be called for different data.", { ns: "'.concat(c,'" })}}')),S(e,"sortable",!0),S(e,"default",{type:"text",uiSchema:{"x-component":"DynamicExpression"}}),S(e,"properties",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){S(e,t,n[t])})}return e}({},k)),S(e,"hidden",!0),e}return t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_(t,e),t}(e.CollectionFieldInterface),F=f(47);function I(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function q(e){return(q=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function V(e,t){return(V=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function R(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(R=function(){return!!e})()}var B=function(t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function n(){var t,r,o;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return r=n,o=arguments,r=q(r),I(t=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,R()?Reflect.construct(r,o||[],q(this).constructor):r.apply(this,o)),"name","expression"),I(t,"title",'{{t("Expression collection")}}'),I(t,"order",4),I(t,"color","orange"),I(t,"default",{createdBy:!0,updatedBy:!0,createdAt:!0,updatedAt:!0,fields:[{name:"engine",type:"string",interface:"radioGroup",uiSchema:{type:"string",title:'{{t("Calculation engine")}}',"x-component":"Radio.Group",enum:(0,F.getOptions)(),default:"formula.js"}},{name:"sourceCollection",type:"string",interface:"select",uiSchema:{type:"string",title:'{{t("Collection")}}',"x-component":"CollectionSelect","x-component-props":{}}},{name:"expression",type:"text",interface:"expression",uiSchema:{type:"string",title:'{{t("Expression")}}',"x-component":"DynamicExpression"}}]}),I(t,"availableFieldInterfaces",{include:[]}),I(t,"configurableProperties",(0,e.getConfigurableProperties)("title","name","inherits","category","description","presetFields")),t}return n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),t&&V(n,t),n}(e.CollectionTemplate);function A(e,t,n,r,o,i,c){try{var a=e[i](c),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function M(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function c(e){A(i,r,o,c,a,"next",e)}function a(e){A(i,r,o,c,a,"throw",e)}c(void 0)})}}function D(e,t,n){return(D=U()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&W(o,n.prototype),o}).apply(null,arguments)}function N(e){return(N=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function W(e,t){return(W=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function G(e){var t="function"==typeof Map?new Map:void 0;return(G=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 D(e,arguments,N(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),W(n,e)})(e)}function U(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(U=function(){return!!e})()}function z(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:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){var u=[i,a];if(n)throw TypeError("Generator is already executing.");for(;c;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return c.label++,{value:u[1],done:!1};case 5:c.label++,r=u[1],u=[0];continue;case 7:u=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){c=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){c.label=u[1];break}if(6===u[0]&&c.label<o[1]){c.label=o[1],o=u;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(u);break}o[2]&&c.ops.pop(),c.trys.pop();continue}u=t.call(e,c)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}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=N(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,U()?Reflect.construct(e,t||[],N(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&W(n,e),t=[{key:"afterAdd",value:function(){return M(function(){return z(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return M(function(){return z(this,function(e){return[2]})})()}},{key:"load",value:function(){var e=this;return M(function(){var t,n;return z(this,function(r){return e.app.dataSourceManager.addFieldInterfaces([T]),e.app.addComponents({DynamicExpression:P}),e.dataSourceManager.addCollectionTemplates([B]),t=e.app.pm.get("workflow"),n=new d,t.instructions.register(n.type,n),[2]})})()}}],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}(G(e.Plugin))}(),p}()});
@@ -10,14 +10,14 @@
10
10
  module.exports = {
11
11
  "react": "18.2.0",
12
12
  "@ant-design/icons": "5.6.1",
13
- "@nocobase/client": "1.7.0-beta.8",
14
- "@nocobase/plugin-workflow": "1.7.0-beta.8",
13
+ "@nocobase/client": "1.8.0-beta.1",
14
+ "@nocobase/plugin-workflow": "1.8.0-beta.1",
15
15
  "@formily/core": "2.3.0",
16
16
  "@formily/react": "2.3.0",
17
- "antd": "5.12.8",
17
+ "antd": "5.24.2",
18
18
  "react-i18next": "11.18.6",
19
- "@nocobase/evaluators": "1.7.0-beta.8",
20
- "@nocobase/utils": "1.7.0-beta.8",
21
- "@nocobase/server": "1.7.0-beta.8",
22
- "@nocobase/database": "1.7.0-beta.8"
19
+ "@nocobase/evaluators": "1.8.0-beta.1",
20
+ "@nocobase/utils": "1.8.0-beta.1",
21
+ "@nocobase/server": "1.8.0-beta.1",
22
+ "@nocobase/database": "1.8.0-beta.1"
23
23
  };
@@ -1,11 +1,12 @@
1
1
  {
2
- "Dynamic Calculation": "Dynamic Calculation",
2
+ "Expression": "Expression",
3
+ "Dynamic expression calculation": "Dynamic expression calculation",
3
4
  "Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression. The expression is dynamic one from an expression collections.": "Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression. The expression is dynamic one from an expression collections.",
4
5
  "Select dynamic expression": "Select dynamic expression",
5
6
  "Select the dynamic expression queried from the upstream node. You need to query it from an expression collection.": "Select the dynamic expression queried from the upstream node. You need to query it from an expression collection.",
6
7
  "Variable datasource": "Variable datasource",
7
8
  "Dynamic expression": "Dynamic expression",
8
- "An expression for calculation in each rows": "An expression for calculation in each rows",
9
+ "Used to store expressions for use in workflows so that different expressions can be called for different data.": "Used to store expressions for use in workflows so that different expressions can be called for different data.",
9
10
  "Unconfigured": "Unconfigured",
10
11
  "Calculation result": "Calculation result"
11
- }
12
+ }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "工作流:动态表达式计算节点",
5
5
  "description": "Useful plugin for doing dynamic calculation based on expression collection records in workflow.",
6
6
  "description.zh-CN": "用于在工作流中进行基于数据行的动态表达式计算。",
7
- "version": "1.7.0-beta.8",
7
+ "version": "1.8.0-beta.1",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/workflow-dynamic-calculation",
@@ -30,7 +30,7 @@
30
30
  "@nocobase/test": "1.x",
31
31
  "@nocobase/utils": "1.x"
32
32
  },
33
- "gitHead": "9ad35ee90db98d95dfa660645d155f4f4e81b47c",
33
+ "gitHead": "103935669123174f2942247202e3d9ff15f0d4ed",
34
34
  "keywords": [
35
35
  "Workflow",
36
36
  "Collections"