@nocobase/plugin-workflow-dynamic-calculation 0.19.0-alpha.1 → 0.19.0-alpha.10

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.
@@ -1 +1 @@
1
- (function(n,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("react-i18next"),require("@nocobase/plugin-workflow/client"),require("@formily/core"),require("@formily/react"),require("antd"),require("react")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","react-i18next","@nocobase/plugin-workflow/client","@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["react-i18next"],n["@nocobase/plugin-workflow"],n["@formily/core"],n["@formily/react"],n.antd,n.react))})(this,function(n,e,o,C,r,g,u,x,c){"use strict";var z=Object.defineProperty,L=Object.defineProperties;var _=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var v=(n,e,o)=>e in n?z(n,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[e]=o,m=(n,e)=>{for(var o in e||(e={}))U.call(e,o)&&v(n,o,e[o]);if(F)for(var o of F(e))G.call(e,o)&&v(n,o,e[o]);return n},y=(n,e)=>L(n,_(e));var f=(n,e,o)=>(v(n,typeof e!="symbol"?e+"":e,o),o);var w=(n,e,o)=>new Promise((C,r)=>{var g=c=>{try{x(o.next(c))}catch(a){r(a)}},u=c=>{try{x(o.throw(c))}catch(a){r(a)}},x=c=>c.done?C(c.value):Promise.resolve(c.value).then(g,u);x((o=o.apply(n,e)).next())});const a="workflow-dynamic-calculation";function k(s,i={}){const{t}=I(i);return t(s)}function I(s){return C.useTranslation(a,s)}const{defaultProps:T}=e.interfacesProperties,P={name:"expression",type:"string",group:"advanced",order:1,title:`{{t("Expression", { ns: "${a}" })}}`,description:`{{t("An expression for calculation in each rows", { ns: "${a}" })}}`,sortable:!0,default:{type:"text",uiSchema:{"x-component":"DynamicExpression"}},properties:m({},T)};function E(s){const i=e.useCollectionManager();return o.jsx(e.CollectionManagerContext.Provider,{value:y(m({},i),{interfaces:y(m({},i.interfaces),{expression:P})}),children:s.children})}function M(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(l=>l.interface==="expression"):!1}function q({value:s,onChange:i}){const{getCollectionFields:t,getCollection:l}=e.useCollectionManager(),d=r.useWorkflowVariableOptions({types:[M.bind({getCollectionFields:t,getCollection:l})]});return o.jsx(e.Variable.Input,{value:s,onChange:i,scope:d})}class j extends r.Instruction{constructor(){super(...arguments);f(this,"title",`{{t("Dynamic Calculation", { ns: "${a}" })}}`);f(this,"type","dynamic-calculation");f(this,"group","extended");f(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}" })}}`);f(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]}}"}}}}});f(this,"components",{DynamicExpression:q,WorkflowVariableInput:r.WorkflowVariableInput,ValueBlock:r.ValueBlock})}useVariables({key:t,title:l},{types:d,fieldNames:p=r.defaultFieldNames}){return d&&!d.some(h=>h in r.BaseTypeSets||Object.values(r.BaseTypeSets).some(b=>b.has(h)))?null:{[p.value]:t,[p.label]:l}}useInitializers(t){var l;return{name:`#${t.id}`,type:"item",title:(l=t.title)!=null?l:`#${t.id}`,Component:r.ValueBlock.Initializer,node:t,resultTitle:k("Calculation result")}}}const D=u.observer(s=>{const{onChange:i}=s,t=u.useField(),l=u.useForm(),p=[...t.path.segments.slice(0,-1),"sourceCollection"].join("."),[h,b]=c.useState(l.getValuesIn(p)),B=e.useCompile(),{getCollectionFields:W}=e.useCollectionManager();u.useFormEffects(()=>{g.onFormInitialValuesChange(V=>{b(V.getValuesIn(p))}),g.onFieldInputValueChange(p,V=>{b(V.value),i(null)})});const N=r.getCollectionFieldOptions({collection:h,compile:B,getCollectionFields:W});return o.jsx(e.Variable.TextArea,y(m({},s),{scope:N}))},{displayName:"InternalExpression"});function O(s){const{t:i}=C.useTranslation(),t=e.useRecord(),l=e.useCompile(),{getCollectionFields:d}=e.useCollectionManager(),p=c.useMemo(()=>r.getCollectionFieldOptions({collection:t.sourceCollection,compile:l,getCollectionFields:d}),[t.sourceCollection,t.sourceCollection]);return s.value?o.jsx(e.Variable.TextArea,y(m({},s),{scope:p})):o.jsx(x.Tag,{children:i("Unconfigured",{ns:a})})}const S=u.connect(D,u.mapReadPretty(O));class A extends e.Plugin{afterAdd(){return w(this,null,function*(){})}beforeLoad(){return w(this,null,function*(){})}load(){return w(this,null,function*(){this.app.addProvider(E),this.app.addComponents({DynamicExpression:S});const i=this.app.pm.get("workflow"),t=new j;i.instructions.register(t.type,t)})}}n.default=A,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(o,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("react-i18next"),require("@nocobase/plugin-workflow/client"),require("@formily/core"),require("@formily/react"),require("antd"),require("react")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","react-i18next","@nocobase/plugin-workflow/client","@formily/core","@formily/react","antd","react"],e):(o=typeof globalThis!="undefined"?globalThis:o||self,e(o["@nocobase/plugin-workflow-dynamic-calculation"]={},o["@nocobase/client"],o.jsxRuntime,o["react-i18next"],o["@nocobase/plugin-workflow"],o["@formily/core"],o["@formily/react"],o.antd,o.react))})(this,function(o,e,n,C,r,g,u,x,c){"use strict";var z=Object.defineProperty,L=Object.defineProperties;var U=Object.getOwnPropertyDescriptors;var k=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var v=(o,e,n)=>e in o?z(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n,m=(o,e)=>{for(var n in e||(e={}))_.call(e,n)&&v(o,n,e[n]);if(k)for(var n of k(e))G.call(e,n)&&v(o,n,e[n]);return o},y=(o,e)=>L(o,U(e));var f=(o,e,n)=>(v(o,typeof e!="symbol"?e+"":e,n),n);var w=(o,e,n)=>new Promise((C,r)=>{var g=c=>{try{x(n.next(c))}catch(a){r(a)}},u=c=>{try{x(n.throw(c))}catch(a){r(a)}},x=c=>c.done?C(c.value):Promise.resolve(c.value).then(g,u);x((n=n.apply(o,e)).next())});const a="workflow-dynamic-calculation";function F(s,i={}){const{t}=I(i);return t(s)}function I(s){return C.useTranslation(a,s)}const{defaultProps:T}=e.interfacesProperties,P={name:"expression",type:"string",group:"advanced",order:1,title:`{{t("Expression", { ns: "${a}" })}}`,description:`{{t("Used to store expressions for use in workflows so that different expressions can be called for different data.", { ns: "${a}" })}}`,sortable:!0,default:{type:"text",uiSchema:{"x-component":"DynamicExpression"}},properties:m({},T)};function E(s){const i=e.useCollectionManager();return n.jsx(e.CollectionManagerContext.Provider,{value:y(m({},i),{interfaces:y(m({},i.interfaces),{expression:P})}),children:s.children})}function M(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(l=>l.interface==="expression"):!1}function q({value:s,onChange:i}){const{getCollectionFields:t,getCollection:l}=e.useCollectionManager(),d=r.useWorkflowVariableOptions({types:[M.bind({getCollectionFields:t,getCollection:l})]});return n.jsx(e.Variable.Input,{value:s,onChange:i,scope:d})}class j extends r.Instruction{constructor(){super(...arguments);f(this,"title",`{{t("Dynamic Calculation", { ns: "${a}" })}}`);f(this,"type","dynamic-calculation");f(this,"group","extended");f(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}" })}}`);f(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]}}"}}}}});f(this,"components",{DynamicExpression:q,WorkflowVariableInput:r.WorkflowVariableInput,ValueBlock:r.ValueBlock})}useVariables({key:t,title:l},{types:d,fieldNames:p=r.defaultFieldNames}){return d&&!d.some(h=>h in r.BaseTypeSets||Object.values(r.BaseTypeSets).some(b=>b.has(h)))?null:{[p.value]:t,[p.label]:l}}useInitializers(t){var l;return{name:`#${t.id}`,type:"item",title:(l=t.title)!=null?l:`#${t.id}`,Component:r.ValueBlock.Initializer,node:t,resultTitle:F("Calculation result")}}}const D=u.observer(s=>{const{onChange:i}=s,t=u.useField(),l=u.useForm(),p=[...t.path.segments.slice(0,-1),"sourceCollection"].join("."),[h,b]=c.useState(l.getValuesIn(p)),B=e.useCompile(),{getCollectionFields:W}=e.useCollectionManager();u.useFormEffects(()=>{g.onFormInitialValuesChange(V=>{b(V.getValuesIn(p))}),g.onFieldInputValueChange(p,V=>{b(V.value),i(null)})});const N=r.getCollectionFieldOptions({collection:h,compile:B,getCollectionFields:W});return n.jsx(e.Variable.TextArea,y(m({},s),{scope:N}))},{displayName:"InternalExpression"});function O(s){const{t:i}=C.useTranslation(),t=e.useRecord(),l=e.useCompile(),{getCollectionFields:d}=e.useCollectionManager(),p=c.useMemo(()=>r.getCollectionFieldOptions({collection:t.sourceCollection,compile:l,getCollectionFields:d}),[t.sourceCollection,t.sourceCollection]);return s.value?n.jsx(e.Variable.TextArea,y(m({},s),{scope:p})):n.jsx(x.Tag,{children:i("Unconfigured",{ns:a})})}const S=u.connect(D,u.mapReadPretty(O));class A extends e.Plugin{afterAdd(){return w(this,null,function*(){})}beforeLoad(){return w(this,null,function*(){})}load(){return w(this,null,function*(){this.app.addProvider(E),this.app.addComponents({DynamicExpression:S});const i=this.app.pm.get("workflow"),t=new j;i.instructions.register(t.type,t)})}}o.default=A,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,13 +1,13 @@
1
1
  module.exports = {
2
2
  "react": "18.2.0",
3
- "@nocobase/client": "0.19.0-alpha.1",
4
- "@nocobase/plugin-workflow": "0.19.0-alpha.1",
3
+ "@nocobase/client": "0.19.0-alpha.10",
4
+ "@nocobase/plugin-workflow": "0.19.0-alpha.10",
5
5
  "@formily/core": "2.3.0",
6
6
  "@formily/react": "2.3.0",
7
7
  "antd": "5.12.8",
8
8
  "react-i18next": "11.18.6",
9
- "@nocobase/utils": "0.19.0-alpha.1",
10
- "@nocobase/evaluators": "0.19.0-alpha.1",
11
- "@nocobase/server": "0.19.0-alpha.1",
12
- "@nocobase/database": "0.19.0-alpha.1"
9
+ "@nocobase/utils": "0.19.0-alpha.10",
10
+ "@nocobase/evaluators": "0.19.0-alpha.10",
11
+ "@nocobase/server": "0.19.0-alpha.10",
12
+ "@nocobase/database": "0.19.0-alpha.10"
13
13
  };
@@ -0,0 +1,13 @@
1
+ {
2
+ "Dynamic Calculation": "동적 표현식 계산",
3
+ "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": "동적 표현식 선택",
6
+ "Select the dynamic expression queried from the upstream node. You need to query it from an expression collection.":
7
+ "상류 노드에서 조회한 동적 표현식을 선택하세요. 표현식 컬렉션에서 조회해야 합니다.",
8
+ "Variable datasource": "변수 데이터 소스",
9
+ "Dynamic expression": "동적 표현식",
10
+ "An expression for calculation in each rows": "각 행의 계산을 위한 식",
11
+ "Unconfigured": "구성되지 않음",
12
+ "Calculation result": "계산 결과"
13
+ }
@@ -1,11 +1,12 @@
1
1
  {
2
+ "Expression": "表达式",
2
3
  "Dynamic 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.": "基于计算引擎计算表达式并获取值作为结果。可以在表达式中使用上游节点的变量。表达式是从表达式表中动态获取的。",
4
5
  "Select dynamic expression": "选择动态表达式",
5
6
  "Select the dynamic expression queried from the upstream node. You need to query it from an expression collection.": "从上游节点中选择查询出来的动态表达式。你需要从动态表达式类型的数据表中查询。",
6
7
  "Variable datasource": "变量数据源",
7
8
  "Dynamic expression": "动态表达式",
8
- "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.": "用于存储表达式,在工作流中使用,以便针对不同的数据调用不同的表达式。",
9
10
  "Unconfigured": "未配置",
10
11
  "Calculation result": "运算结果"
11
12
  }
package/package.json CHANGED
@@ -4,9 +4,11 @@
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": "0.19.0-alpha.1",
7
+ "version": "0.19.0-alpha.10",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
+ "homepage": "https://docs.nocobase.com/plugins/workflow-dynamic-calculation",
11
+ "homepage.zh-CN": "https://docs-cn.nocobase.com/plugins/workflow-dynamic-calculation",
10
12
  "devDependencies": {
11
13
  "@ant-design/icons": "5.x",
12
14
  "@formily/antd-v5": "1.x",
@@ -28,5 +30,8 @@
28
30
  "@nocobase/test": "0.x",
29
31
  "@nocobase/utils": "0.x"
30
32
  },
31
- "gitHead": "64601944412fc4d2e2bd05f4b982118dd28247dc"
33
+ "gitHead": "d09d81eba67339da36bcec27939a85b35d180770",
34
+ "keywords": [
35
+ "Workflow"
36
+ ]
32
37
  }
@@ -10,7 +10,7 @@ export default {
10
10
  group: 'advanced',
11
11
  order: 1,
12
12
  title: `{{t("Expression", { ns: "${NAMESPACE}" })}}`,
13
- description: `{{t("An expression for calculation in each rows", { ns: "${NAMESPACE}" })}}`,
13
+ description: `{{t("Used to store expressions for use in workflows so that different expressions can be called for different data.", { ns: "${NAMESPACE}" })}}`,
14
14
  sortable: true,
15
15
  default: {
16
16
  type: 'text',
@@ -0,0 +1,13 @@
1
+ {
2
+ "Dynamic Calculation": "동적 표현식 계산",
3
+ "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": "동적 표현식 선택",
6
+ "Select the dynamic expression queried from the upstream node. You need to query it from an expression collection.":
7
+ "상류 노드에서 조회한 동적 표현식을 선택하세요. 표현식 컬렉션에서 조회해야 합니다.",
8
+ "Variable datasource": "변수 데이터 소스",
9
+ "Dynamic expression": "동적 표현식",
10
+ "An expression for calculation in each rows": "각 행의 계산을 위한 식",
11
+ "Unconfigured": "구성되지 않음",
12
+ "Calculation result": "계산 결과"
13
+ }
@@ -1,11 +1,12 @@
1
1
  {
2
+ "Expression": "表达式",
2
3
  "Dynamic 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.": "基于计算引擎计算表达式并获取值作为结果。可以在表达式中使用上游节点的变量。表达式是从表达式表中动态获取的。",
4
5
  "Select dynamic expression": "选择动态表达式",
5
6
  "Select the dynamic expression queried from the upstream node. You need to query it from an expression collection.": "从上游节点中选择查询出来的动态表达式。你需要从动态表达式类型的数据表中查询。",
6
7
  "Variable datasource": "变量数据源",
7
8
  "Dynamic expression": "动态表达式",
8
- "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.": "用于存储表达式,在工作流中使用,以便针对不同的数据调用不同的表达式。",
9
10
  "Unconfigured": "未配置",
10
11
  "Calculation result": "运算结果"
11
12
  }