@nocobase/plugin-workflow-dynamic-calculation 1.0.0-alpha.6 → 1.0.0-alpha.8

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.
@@ -40,4 +40,5 @@ export declare class ExpressionFieldInterface extends CollectionFieldInterface {
40
40
  description: string;
41
41
  };
42
42
  };
43
+ hidden: boolean;
43
44
  }
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- (function(n,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("@nocobase/plugin-workflow/client"),require("react-i18next"),require("@formily/core"),require("@formily/react"),require("antd"),require("react")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","@nocobase/plugin-workflow/client","react-i18next","@formily/core","@formily/react","antd","react"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n["@nocobase/plugin-workflow-dynamic-calculation"]={},n["@nocobase/client"],n.jsxRuntime,n["@nocobase/plugin-workflow"],n["react-i18next"],n["@formily/core"],n["@formily/react"],n.antd,n.react))})(this,function(n,e,o,r,m,y,p,x,u){"use strict";var W=Object.defineProperty,N=Object.defineProperties;var z=Object.getOwnPropertyDescriptors;var V=Object.getOwnPropertySymbols;var L=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var F=(n,e,o)=>e in n?W(n,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[e]=o,b=(n,e)=>{for(var o in e||(e={}))L.call(e,o)&&F(n,o,e[o]);if(V)for(var o of V(e))U.call(e,o)&&F(n,o,e[o]);return n},I=(n,e)=>N(n,z(e));var i=(n,e,o)=>(F(n,typeof e!="symbol"?e+"":e,o),o);var h=(n,e,o)=>new Promise((r,m)=>{var y=u=>{try{x(o.next(u))}catch(a){m(a)}},p=u=>{try{x(o.throw(u))}catch(a){m(a)}},x=u=>u.done?r(u.value):Promise.resolve(u.value).then(y,p);x((o=o.apply(n,e)).next())});const a="workflow-dynamic-calculation";function k(s,l={}){const{t}=T(l);return t(s)}function T(s){return m.useTranslation(a,s)}function E(s){var t;return["belongsTo","hasOne"].includes(s.type)?((t=this.getCollection(s.collectionName))==null?void 0:t.template)==="expression"?!0:this.getCollectionFields(s.target).some(c=>c.interface==="expression"):!1}function v({value:s,onChange:l}){const{getCollectionFields:t,getCollection:c}=e.useCollectionManager_deprecated(),f=r.useWorkflowVariableOptions({types:[E.bind({getCollectionFields:t,getCollection:c})]});return o.jsx(e.Variable.Input,{value:s,onChange:l,scope:f})}class P extends r.Instruction{constructor(){super(...arguments);i(this,"title",`{{t("Dynamic Calculation", { ns: "${a}" })}}`);i(this,"type","dynamic-calculation");i(this,"group","extended");i(this,"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: "${a}" })}}`);i(this,"fieldset",{expression:{type:"string",title:`{{t("Calculation expression", { ns: "${a}" })}}`,"x-decorator":"FormItem","x-component":"DynamicExpression",required:!0},scope:{type:"string",title:`{{t("Variable datasource", { ns: "${a}" })}}`,"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]}}"}}}}});i(this,"components",{DynamicExpression:v,WorkflowVariableInput:r.WorkflowVariableInput,ValueBlock:r.ValueBlock})}useVariables({key:t,title:c},{types:f,fieldNames:d=r.defaultFieldNames}){return f&&!f.some(g=>g in r.BaseTypeSets||Object.values(r.BaseTypeSets).some(C=>C.has(g)))?null:{[d.value]:t,[d.label]:c}}useInitializers(t){var c;return{name:`#${t.id}`,type:"item",title:(c=t.title)!=null?c:`#${t.id}`,Component:r.ValueBlock.Initializer,node:t,resultTitle:k("Calculation result")}}}const q=p.observer(s=>{const{onChange:l}=s,t=p.useField(),c=p.useForm(),d=[...t.path.segments.slice(0,-1),"sourceCollection"].join("."),[g,C]=u.useState(c.getValuesIn(d)),A=e.useCompile(),{getCollectionFields:B}=e.useCollectionManager_deprecated();p.useFormEffects(()=>{y.onFormInitialValuesChange(w=>{C(w.getValuesIn(d))}),y.onFieldInputValueChange(d,w=>{C(w.value),l(null)})});const _=r.getCollectionFieldOptions({collection:g,compile:A,getCollectionFields:B});return o.jsx(e.Variable.TextArea,I(b({},s),{scope:_}))},{displayName:"InternalExpression"});function M(s){const{t:l}=m.useTranslation(),t=e.useRecord(),c=e.useCompile(),{getCollectionFields:f}=e.useCollectionManager_deprecated(),d=u.useMemo(()=>r.getCollectionFieldOptions({collection:t.sourceCollection,compile:c,getCollectionFields:f}),[t.sourceCollection,t.sourceCollection]);return s.value?o.jsx(e.Variable.TextArea,I(b({},s),{scope:d})):o.jsx(x.Tag,{children:l("Unconfigured",{ns:a})})}const S=p.connect(q,p.mapReadPretty(M)),{defaultProps:j}=e.interfacesProperties;class D extends e.CollectionFieldInterface{constructor(){super(...arguments);i(this,"name","expression");i(this,"type","string");i(this,"group","advanced");i(this,"order",1);i(this,"title",`{{t("Expression", { ns: "${a}" })}}`);i(this,"description",`{{t("Used to store expressions for use in workflows so that different expressions can be called for different data.", { ns: "${a}" })}}`);i(this,"sortable",!0);i(this,"default",{type:"text",uiSchema:{"x-component":"DynamicExpression"}});i(this,"properties",b({},j))}}class O extends e.Plugin{afterAdd(){return h(this,null,function*(){})}beforeLoad(){return h(this,null,function*(){})}load(){return h(this,null,function*(){this.app.dataSourceManager.addFieldInterfaces([D]),this.app.addComponents({DynamicExpression:S});const l=this.app.pm.get("workflow"),t=new P;l.instructions.register(t.type,t)})}}n.default=O,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
10
+ (function(n,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("@nocobase/plugin-workflow/client"),require("react-i18next"),require("@formily/core"),require("@formily/react"),require("antd"),require("react")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","@nocobase/plugin-workflow/client","react-i18next","@formily/core","@formily/react","antd","react"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n["@nocobase/plugin-workflow-dynamic-calculation"]={},n["@nocobase/client"],n.jsxRuntime,n["@nocobase/plugin-workflow"],n["react-i18next"],n["@formily/core"],n["@formily/react"],n.antd,n.react))})(this,function(n,e,o,r,m,y,p,x,u){"use strict";var W=Object.defineProperty,N=Object.defineProperties;var z=Object.getOwnPropertyDescriptors;var V=Object.getOwnPropertySymbols;var L=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var F=(n,e,o)=>e in n?W(n,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[e]=o,b=(n,e)=>{for(var o in e||(e={}))L.call(e,o)&&F(n,o,e[o]);if(V)for(var o of V(e))U.call(e,o)&&F(n,o,e[o]);return n},I=(n,e)=>N(n,z(e));var i=(n,e,o)=>(F(n,typeof e!="symbol"?e+"":e,o),o);var h=(n,e,o)=>new Promise((r,m)=>{var y=u=>{try{x(o.next(u))}catch(a){m(a)}},p=u=>{try{x(o.throw(u))}catch(a){m(a)}},x=u=>u.done?r(u.value):Promise.resolve(u.value).then(y,p);x((o=o.apply(n,e)).next())});const a="workflow-dynamic-calculation";function k(s,l={}){const{t}=T(l);return t(s)}function T(s){return m.useTranslation(a,s)}function E(s){var t;return["belongsTo","hasOne"].includes(s.type)?((t=this.getCollection(s.collectionName))==null?void 0:t.template)==="expression"?!0:this.getCollectionFields(s.target).some(c=>c.interface==="expression"):!1}function v({value:s,onChange:l}){const{getCollectionFields:t,getCollection:c}=e.useCollectionManager_deprecated(),f=r.useWorkflowVariableOptions({types:[E.bind({getCollectionFields:t,getCollection:c})]});return o.jsx(e.Variable.Input,{value:s,onChange:l,scope:f})}class P extends r.Instruction{constructor(){super(...arguments);i(this,"title",`{{t("Dynamic Calculation", { ns: "${a}" })}}`);i(this,"type","dynamic-calculation");i(this,"group","extended");i(this,"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: "${a}" })}}`);i(this,"fieldset",{expression:{type:"string",title:`{{t("Calculation expression", { ns: "${a}" })}}`,"x-decorator":"FormItem","x-component":"DynamicExpression",required:!0},scope:{type:"string",title:`{{t("Variable datasource", { ns: "${a}" })}}`,"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]}}"}}}}});i(this,"components",{DynamicExpression:v,WorkflowVariableInput:r.WorkflowVariableInput,ValueBlock:r.ValueBlock})}useVariables({key:t,title:c},{types:f,fieldNames:d=r.defaultFieldNames}){return f&&!f.some(g=>g in r.BaseTypeSets||Object.values(r.BaseTypeSets).some(C=>C.has(g)))?null:{[d.value]:t,[d.label]:c}}useInitializers(t){var c;return{name:`#${t.id}`,type:"item",title:(c=t.title)!=null?c:`#${t.id}`,Component:r.ValueBlock.Initializer,node:t,resultTitle:k("Calculation result")}}}const q=p.observer(s=>{const{onChange:l}=s,t=p.useField(),c=p.useForm(),d=[...t.path.segments.slice(0,-1),"sourceCollection"].join("."),[g,C]=u.useState(c.getValuesIn(d)),A=e.useCompile(),{getCollectionFields:B}=e.useCollectionManager_deprecated();p.useFormEffects(()=>{y.onFormInitialValuesChange(w=>{C(w.getValuesIn(d))}),y.onFieldInputValueChange(d,w=>{C(w.value),l(null)})});const _=r.getCollectionFieldOptions({collection:g,compile:A,getCollectionFields:B});return o.jsx(e.Variable.TextArea,I(b({},s),{scope:_}))},{displayName:"InternalExpression"});function M(s){const{t:l}=m.useTranslation(),t=e.useRecord(),c=e.useCompile(),{getCollectionFields:f}=e.useCollectionManager_deprecated(),d=u.useMemo(()=>r.getCollectionFieldOptions({collection:t.sourceCollection,compile:c,getCollectionFields:f}),[t.sourceCollection,t.sourceCollection]);return s.value?o.jsx(e.Variable.TextArea,I(b({},s),{scope:d})):o.jsx(x.Tag,{children:l("Unconfigured",{ns:a})})}const S=p.connect(q,p.mapReadPretty(M)),{defaultProps:j}=e.interfacesProperties;class D extends e.CollectionFieldInterface{constructor(){super(...arguments);i(this,"name","expression");i(this,"type","string");i(this,"group","advanced");i(this,"order",1);i(this,"title",`{{t("Expression", { ns: "${a}" })}}`);i(this,"description",`{{t("Used to store expressions for use in workflows so that different expressions can be called for different data.", { ns: "${a}" })}}`);i(this,"sortable",!0);i(this,"default",{type:"text",uiSchema:{"x-component":"DynamicExpression"}});i(this,"properties",b({},j));i(this,"hidden",!0)}}class O extends e.Plugin{afterAdd(){return h(this,null,function*(){})}beforeLoad(){return h(this,null,function*(){})}load(){return h(this,null,function*(){this.app.dataSourceManager.addFieldInterfaces([D]),this.app.addComponents({DynamicExpression:S});const l=this.app.pm.get("workflow"),t=new P;l.instructions.register(t.type,t)})}}n.default=O,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -9,14 +9,14 @@
9
9
 
10
10
  module.exports = {
11
11
  "react": "18.2.0",
12
- "@nocobase/client": "1.0.0-alpha.6",
13
- "@nocobase/plugin-workflow": "1.0.0-alpha.6",
12
+ "@nocobase/client": "1.0.0-alpha.8",
13
+ "@nocobase/plugin-workflow": "1.0.0-alpha.8",
14
14
  "@formily/core": "2.3.0",
15
15
  "@formily/react": "2.3.0",
16
16
  "antd": "5.12.8",
17
17
  "react-i18next": "11.18.6",
18
- "@nocobase/utils": "1.0.0-alpha.6",
19
- "@nocobase/evaluators": "1.0.0-alpha.6",
20
- "@nocobase/server": "1.0.0-alpha.6",
21
- "@nocobase/database": "1.0.0-alpha.6"
18
+ "@nocobase/utils": "1.0.0-alpha.8",
19
+ "@nocobase/evaluators": "1.0.0-alpha.8",
20
+ "@nocobase/server": "1.0.0-alpha.8",
21
+ "@nocobase/database": "1.0.0-alpha.8"
22
22
  };
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.0.0-alpha.6",
7
+ "version": "1.0.0-alpha.8",
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": "cbba77fb83a4ee114002234a15d339054b092de8",
33
+ "gitHead": "3c4e978f6fc366c01621c9d625678e91f53f8662",
34
34
  "keywords": [
35
35
  "Workflow",
36
36
  "Collections"