@nocobase/plugin-workflow-aggregate 2.2.0-alpha.2 → 2.2.0-alpha.4

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.
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ "use strict";(self.webpackChunk_nocobase_plugin_workflow_aggregate=self.webpackChunk_nocobase_plugin_workflow_aggregate||[]).push([["604"],{7:function(e,n,t){t.d(n,{AggregateFieldset:function(){return M}});var r=t(155),l=t.n(r),o=t(59),a=t(197),i=[{label:"COUNT",value:"count"},{label:"SUM",value:"sum"},{label:"AVG",value:"avg"},{label:"MIN",value:"min"},{label:"MAX",value:"max"}],u=["hasMany","belongsToMany"],c=["belongsTo","hasOne","hasMany","belongsToMany"],s=t(488);function f(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}function d(e){return u.includes(e.type)}function p(e){return!!(!e.hidden&&e.interface&&!c.includes(e.type))}var m=t(694);function y(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}function b(e,n,t,r,l,o,a){try{var i=e[o](a),u=i.value}catch(e){t(e);return}i.done?n(u):Promise.resolve(u).then(r,l)}function g(e){return function(){var n=this,t=arguments;return new Promise(function(r,l){var o=e.apply(n,t);function a(e){b(o,r,l,a,i,"next",e)}function i(e){b(o,r,l,a,i,"throw",e)}a(void 0)})}}function v(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},r=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.forEach(function(n){var r;r=t[n],n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r})}return e}function h(e,n){return n=null!=n?n:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):(function(e){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n.push.apply(n,t)}return n})(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}),e}function w(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t,r,l=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=l){var o=[],a=!0,i=!1;try{for(l=l.call(e);!(a=(t=l.next()).done)&&(o.push(t.value),!n||o.length!==n);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==l.return||l.return()}finally{if(i)throw r}}return o}}(e,n)||j(e,n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e){return function(e){if(Array.isArray(e))return y(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||j(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function j(e,n){if(e){if("string"==typeof e)return y(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return y(e,n)}}function S(e,n){var t,r,l,o={label:0,sent:function(){if(1&l[0])throw l[1];return l[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(a,"next",{value:u(0)}),i(a,"throw",{value:u(1)}),i(a,"return",{value:u(2)}),"function"==typeof Symbol&&i(a,Symbol.iterator,{value:function(){return this}}),a;function u(i){return function(u){var c=[i,u];if(t)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(t=1,r&&(l=2&c[0]?r.return:c[0]?r.throw||((l=r.return)&&l.call(r),0):r.next)&&!(l=l.call(r,c[1])).done)return l;switch(r=0,l&&(c=[2&c[0],l.value]),c[0]){case 0:case 1:l=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,r=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!(l=(l=o.trys).length>0&&l[l.length-1])&&(6===c[0]||2===c[0])){o=0;continue}if(3===c[0]&&(!l||c[1]>l[0]&&c[1]<l[3])){o.label=c[1];break}if(6===c[0]&&o.label<l[1]){o.label=l[1],l=c;break}if(l&&o.label<l[2]){o.label=l[2],o.ops.push(c);break}l[2]&&o.ops.pop(),o.trys.pop();continue}c=n.call(e,o)}catch(e){c=[6,e],r=0}finally{t=l=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function E(e){return"options"in e&&e.options?e.options:e}function F(e){return w((0,a.parseCollectionName)(null!=e?e:""),1)[0]||"main"}function A(e,n,t){var r,l,o,a,i,u=e.field?E(e.field):void 0,c=u?h(v({},u),{dataSourceKey:null!=(a=u.dataSourceKey)?a:t}):void 0,s=null!=(i=null==c?void 0:c.dataSourceKey)?i:t,f="function"==typeof e.loadChildren?function(t){return g(function(){var r;return S(this,function(l){switch(l.label){case 0:return[4,null==(r=e.loadChildren)?void 0:r.call(e,t)];case 1:return l.sent(),t.children=Array.isArray(t.children)?t.children.map(function(e){return A(e,n,s)}):void 0,[2]}})})()}:void 0;return{appends:e.appends,depth:e.depth,key:e.key,value:"string"==typeof(l=null!=(r=e.value)?r:e.key)?l:String(null!=l?l:""),label:(o=e.label,"string"==typeof o?n(o,{ns:["workflow","workflow-aggregate","client"]}):o),disabled:!!e.disabled,isLeaf:!!e.isLeaf,field:c,loadChildren:f,types:e.types,children:Array.isArray(e.children)?e.children.map(function(e){return A(e,n,s)}):void 0}}function C(e){var n=e.label,t=e.value,r=e.children;return{key:t,value:t,label:n,children:r,disabled:!r.length}}function k(e){return g(function(){var n;return S(this,function(t){switch(t.label){case 0:if(!(!(null==(n=e.children)?void 0:n.length)&&!e.isLeaf&&e.loadChildren))return[3,2];return[4,e.loadChildren(e)];case 1:t.sent(),t.label=2;case 2:return[2]}})})()}function I(e){e.setFieldValue(["config","params","field"],null),e.setFieldValue(["config","params","filter"],null)}function V(e,n){e.setFieldValue(["config","collection"],null),I(e),null==n||n({})}function x(e){var n,t,i,u,c,s,p,y,b,j,x,P,N,D,M,T,K,_,R,q=e.value,U=e.onChange,$=e.onDropdownVisibleChange,W=function(e,n){if(null==e)return{};var t,r,l,o={};if("u">typeof Reflect&&Reflect.ownKeys){for(l=0,t=Reflect.ownKeys(Object(e));l<t.length;l++)r=t[l],!(n.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}if(o=function(e,n){if(null==e)return{};var t,r,l={},o=Object.getOwnPropertyNames(e);for(r=0;r<o.length;r++)t=o[r],!(n.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(e,t)&&(l[t]=e[t]);return l}(e,n),Object.getOwnPropertySymbols)for(l=0,t=Object.getOwnPropertySymbols(e);l<t.length;l++)r=t[l],!(n.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}(e,["value","onChange","onDropdownVisibleChange"]),G=(0,m.useFlowEngine)(),B=o.Form.useFormInstance(),L=(b=(0,m.useFlowEngine)(),j=(0,a.useNodeContext)(),x=(0,a.useCurrentWorkflowContext)(),P=(0,a.useAvailableUpstreams)(j),N=b.context.app.pm.get("workflow")||b.context.app.pm.get("@nocobase/plugin-workflow"),D=function(e,n){return b.context.t(e,n)},M={types:[d],appends:null,depth:4},T=[],P.forEach(function(e){var n,t,r,l=null==N||null==(n=N.instructions)?void 0:n.get(e.type),o=null==l||null==(t=l.useVariables)?void 0:t.call(l,e,M);o&&T.push(A(o,D,F(null==(r=e.config)?void 0:r.collection)))}),R=Array.isArray(_=null==(K=(null==x?void 0:x.type)?null==N||null==(p=N.triggers)?void 0:p.get(x.type):void 0)||null==(y=K.useVariables)?void 0:y.call(K,null==x?void 0:x.config,M))?_.filter(Boolean).map(function(e){var n;return A(e,D,F(null==x||null==(n=x.config)?void 0:n.collection))}):[],[C({label:D("Node result",{ns:"workflow"}),value:"$jobsMapByNodeKey",children:T}),C({label:D("Trigger variables",{ns:"workflow"}),value:"$context",children:R})]),X=L.map(function(e){var n,t;return"".concat(e.value,":").concat(null!=(n=null==(t=e.children)?void 0:t.map(function(e){return e.value}).join(","))?n:"")}).join("|"),z=w((0,r.useState)(L),2),H=z[0],J=z[1],Q=(u=(i=null!=(n=q)?n:{}).associatedKey,c=i.name,(s=(void 0===u?"":u).match(/^{{(.*)}}$/))&&c?((function(e){if(Array.isArray(e))return f(e)})(t=s[1].trim().split(".").slice(0,-1))||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e){if(e){if("string"==typeof e)return f(e,void 0);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,void 0)}}(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([c]).filter(Boolean):[]),Y=Q.join("."),Z=w((0,r.useState)(Q),2),ee=Z[0],en=Z[1];return(0,r.useEffect)(function(){J(L)},[X]),(0,r.useEffect)(function(){en(Q)},[Y]),(0,r.useEffect)(function(){var e=!1;return g(function(){var n,t,r,l,o,a,i,u,c,s;return S(this,function(f){switch(f.label){case 0:if(!Q.length||!H.length)return[2];n=H,r=!0,l=!0,o=!1,a=void 0,f.label=1;case 1:f.trys.push([1,6,7,8]),i=function(){var e,l;return S(this,function(o){switch(o.label){case 0:if(e=c.value,!(t=n.find(function(n){return n.value===e})))return r=!1,[2,"break"];return[4,k(t)];case 1:return o.sent(),n=null!=(l=t.children)?l:[],[2]}})},u=Q[Symbol.iterator](),f.label=2;case 2:if(l=(c=u.next()).done)return[3,5];return[5,function(e){var n="function"==typeof Symbol&&Symbol.iterator,t=n&&e[n],r=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}(i())];case 3:if("break"===f.sent())return[3,5];f.label=4;case 4:return l=!0,[3,2];case 5:return[3,8];case 6:return s=f.sent(),o=!0,a=s,[3,8];case 7:try{l||null==u.return||u.return()}finally{if(o)throw a}return[7];case 8:if(e)return[2];if(r&&(null==t?void 0:t.field)&&!d(t.field))return V(B,U),[2];return J(O(H)),[2]}})})(),function(){e=!0}},[Y,H.length]),l().createElement(o.Cascader,h(v({},W),{value:ee,options:H,changeOnSelect:!0,loadData:function(e){return g(function(){var n;return S(this,function(t){switch(t.label){case 0:if(!(n=e[e.length-1]))return[2];return[4,k(n)];case 1:return t.sent(),J(O(H)),[2]}})})()},onDropdownVisibleChange:function(e){e||en(Q),null==$||$(e)},onChange:function(e,n){if(en(e),!(null==e?void 0:e.length))return void V(B,U);var t,r=n[n.length-1],l=null==r?void 0:r.field;if(l&&d(l)&&l.collectionName&&l.target&&l.name){var o,i,u,c,s,f,p,m,y,b=null!=(t=l.dataSourceKey)?t:"main",g=(0,a.joinCollectionName)(b,l.collectionName),v=null!=(m=null==(y=((f=s=null!=(i=null!=(u=null==(o=(0,a.getCollection)(G.context.dataSourceManager,g))||null==(c=o.getFields)?void 0:c.call(o))?u:null==o?void 0:o.fields)?i:[],null!=(p=Map)&&"u">typeof Symbol&&p[Symbol.hasInstance]?!!p[Symbol.hasInstance](f):f instanceof p)?Array.from(s.values()):s).map(E).find(function(e){return e.primaryKey}))?void 0:y.name)?m:"id";B.setFieldValue(["config","collection"],(0,a.joinCollectionName)(b,l.target)),I(B),null==U||U({name:l.name,associatedKey:"{{".concat(e.slice(0,-1).join("."),".").concat(v,"}}"),associatedCollection:g})}}}))}function P(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}function N(e){var n=e.collection,t=(0,s.kj)();return n?l().createElement(o.Form.Item,{name:["config","params","field"],label:t("Field to aggregate"),rules:[{required:!0}]},l().createElement(a.FieldsSelect,{collection:n,filter:p})):null}function D(){var e=(0,s.kj)(),n=o.Form.useWatch(["config","collection"]),t=o.Form.useWatch(["config","aggregator"]);return n?l().createElement(l().Fragment,null,"count"===t?l().createElement(o.Form.Item,{name:["config","params","distinct"],valuePropName:"checked"},l().createElement(o.Checkbox,null,e("Distinct"))):null,l().createElement(o.Form.Item,{name:["config","params","filter"],label:e("Filter")},l().createElement(a.FilterDynamicComponent,{collection:n}))):null}function M(){var e=(0,s.kj)(),n=o.Form.useFormInstance(),t=o.Form.useWatch(["config","associated"]),u=o.Form.useWatch(["config","collection"]),c=[{label:e("Data of collection"),value:!1},{label:e("Data of associated collection"),value:!0}];return(0,r.useEffect)(function(){void 0===n.getFieldValue(["config","aggregator"])&&n.setFieldValue(["config","aggregator"],"count"),void 0===n.getFieldValue(["config","associated"])&&n.setFieldValue(["config","associated"],!1),void 0===n.getFieldValue(["config","precision"])&&n.setFieldValue(["config","precision"],2)},[n]),l().createElement(l().Fragment,null,l().createElement(o.Form.Item,{name:["config","aggregator"],label:e("Aggregator function"),rules:[{required:!0}]},l().createElement(o.Radio.Group,{options:function(e){if(Array.isArray(e))return P(e)}(i)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(i)||function(e){if(e){if("string"==typeof e)return P(e,void 0);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 P(e,void 0)}}(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.")}()})),l().createElement(o.Form.Item,{name:["config","associated"],label:e("Target type"),rules:[{required:!0}]},l().createElement(o.Radio.Group,{options:c,onChange:function(){n.setFieldValue(["config","collection"],null),n.setFieldValue(["config","association"],null),n.setFieldValue(["config","params","field"],null),n.setFieldValue(["config","params","filter"],null)}})),l().createElement(o.Row,{gutter:24},l().createElement(o.Col,{span:12},t?l().createElement(o.Form.Item,{name:["config","association"],label:e("Data of associated collection"),rules:[{required:!0}]},l().createElement(x,null)):l().createElement(o.Form.Item,{name:["config","collection"],label:e("Data of collection"),rules:[{required:!0}]},l().createElement(a.CollectionCascader,{onChange:function(){n.setFieldValue(["config","params","field"],null),n.setFieldValue(["config","params","filter"],null)}}))),l().createElement(o.Col,{span:12},l().createElement(N,{collection:u}))),l().createElement(D,null),l().createElement(o.Form.Item,{name:["config","precision"],label:e("Result precision"),extra:e("Number of decimal places for query result.")},l().createElement(o.InputNumber,{min:0,max:14,step:1,precision:0,className:"auto-width"})))}}}]);
@@ -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("react"),require("antd"),require("@nocobase/plugin-workflow/client-v2"),require("@nocobase/client"),require("@ant-design/icons"),require("@nocobase/plugin-workflow/client"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-aggregate",["react-i18next","react","antd","@nocobase/plugin-workflow/client-v2","@nocobase/client","@ant-design/icons","@nocobase/plugin-workflow/client","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-aggregate"]=t(require("react-i18next"),require("react"),require("antd"),require("@nocobase/plugin-workflow/client-v2"),require("@nocobase/client"),require("@ant-design/icons"),require("@nocobase/plugin-workflow/client"),require("@nocobase/flow-engine")):e["@nocobase/plugin-workflow-aggregate"]=t(e["react-i18next"],e.react,e.antd,e["@nocobase/plugin-workflow/client-v2"],e["@nocobase/client"],e["@ant-design/icons"],e["@nocobase/plugin-workflow/client"],e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o,i,u,c){return function(){"use strict";var a,l,f,s={488:function(e,t,n){n.d(t,{CU:function(){return o},kj:function(){return i}});var r=n(694),o="workflow-aggregate";function i(){var e=(0,r.useFlowEngine)();return function(t,n){return e.context.t(t,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}({ns:[o,"client"],nsMode:"fallback"},n))}}},375:function(e){e.exports=i},342:function(e){e.exports=o},694:function(e){e.exports=c},990:function(e){e.exports=u},197:function(e){e.exports=r},59:function(e){e.exports=n},155:function(e){e.exports=t},953:function(t){t.exports=e}},p={};function b(e){var t=p[e];if(void 0!==t)return t.exports;var n=p[e]={exports:{}};return s[e](n,n.exports,b),n.exports}b.m=s,b.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return b.d(t,{a:t}),t},b.d=function(e,t){for(var n in t)b.o(t,n)&&!b.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},b.f={},b.e=function(e){return Promise.all(Object.keys(b.f).reduce(function(t,n){return b.f[n](e,t),t},[]))},b.u=function(e){return""+e+".524bdbdadcebec8a.js"},b.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),b.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},g={},b.l=function(e,t,n,r){if(g[e])return void g[e].push(t);if(void 0!==n)for(var o,i,u=document.getElementsByTagName("script"),c=0;c<u.length;c++){var a=u[c];if(a.getAttribute("src")==e||a.getAttribute("data-rspack")=="@nocobase/plugin-workflow-aggregate:"+n){o=a;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,b.nc&&o.setAttribute("nonce",b.nc),o.setAttribute("data-rspack","@nocobase/plugin-workflow-aggregate:"+n),o.src=e),g[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(f);var r=g[e];if(delete g[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)},b.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},b.g.importScripts&&(d=b.g.location+"");var g,d,y=b.g.document;if(!d&&y&&(y.currentScript&&"SCRIPT"===y.currentScript.tagName.toUpperCase()&&(d=y.currentScript.src),!d)){var v=y.getElementsByTagName("script");if(v.length)for(var h=v.length-1;h>-1&&(!d||!/^http(s?):/.test(d));)d=v[h--].src}if(!d)throw Error("Automatic publicPath is not supported in this browser");b.p=d.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a={889:0},b.f.j=function(e,t){var n=b.o(a,e)?a[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=a[e]=[t,r]});t.push(n[2]=r);var o=b.p+b.u(e),i=Error();b.l(o,function(t){if(b.o(a,e)&&(0!==(n=a[e])&&(a[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)}},l=function(e,t){var n,r,o=t[0],i=t[1],u=t[2],c=0;if(o.some(function(e){return 0!==a[e]})){for(n in i)b.o(i,n)&&(b.m[n]=i[n]);u&&u(b)}for(e&&e(t);c<o.length;c++)r=o[c],b.o(a,r)&&a[r]&&a[r][0](),a[r]=0},(f=self.webpackChunk_nocobase_plugin_workflow_aggregate=self.webpackChunk_nocobase_plugin_workflow_aggregate||[]).forEach(l.bind(null,0)),f.push=l.bind(null,f.push.bind(f));var w={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-workflow-aggregate/dist/client/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-workflow-aggregate/dist/client/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var u=window.location.pathname||"/",c=u.indexOf(i);e=c>=0?u.slice(0,c+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-workflow-aggregate/dist/client/"}b.p=e}(),!function(){b.r(w),b.d(w,{default:function(){return E}});var e=b(342),t=b(990),n=b(155),r=b.n(n),o=b(375),i=b(197),u=b(488);function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e){return(a=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 f(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(f=function(){return!!e})()}var s=function(e){return'{{t("'.concat(e,'", { ns: "').concat(u.CU,'" })}}')},p=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,i;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,i=arguments,t=a(t),c(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">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,f()?Reflect.construct(t,i||[],a(this).constructor):t.apply(this,i)),"title",s("Aggregate")),c(e,"type","aggregate"),c(e,"group","collection"),c(e,"description",s("Counting, summing, finding maximum, minimum, and average values for multiple records of a collection or associated data of a record.")),c(e,"icon",r().createElement(o.BarChartOutlined,null)),c(e,"FieldsetLoader",function(){return b.e("604").then(b.bind(b,7)).then(function(e){return{default:e.AggregateFieldset}})}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&l(n,e),t=[{key:"createDefaultConfig",value:function(){return{aggregator:"count",associated:!1,precision:2}}},{key:"useVariables",value:function(e){var t,n=e.key,r=e.title,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=o.types,a=o.fieldNames,l=void 0===a?i.defaultFieldNames:a;return u&&!u.some(function(e){return"string"==typeof e&&(e in i.BaseTypeSets||Object.values(i.BaseTypeSets).some(function(t){return t.has(e)}))})?null:(c(t={},l.value,n),c(t,l.label,r),t)}},{key:"getCreateModelMenuItem",value:function(e){var t,n,r=e.node;return(null==(n=r.config)?void 0:n.collection)?{key:"#".concat(r.id),label:null!=(t=r.title)?t:"#".concat(r.id),useModel:"NodeValueModel",createModelOptions:{use:"NodeValueModel",stepParams:{valueSettings:{init:{dataSource:"{{$jobsMapByNodeKey.".concat(r.key,"}}"),defaultValue:s("Query result")}},cardSettings:{titleDescription:{title:s("Aggregate")}}}}}:null}}],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}(i.Instruction),g=b(953);function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function y(e,t){return(y=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function v(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(v=function(){return!!e})()}var h=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=d(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">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,v()?Reflect.construct(e,t||[],d(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&y(r,e),n=[{key:"useInitializers",value:function(e){var n,r=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,(t=n,(0,g.useTranslation)("workflow-aggregate",t)).t)(e)}("Query result");return e.config.collection?{name:"#".concat(e.id),type:"item",title:null!=(n=e.title)?n:"#".concat(e.id),Component:t.ValueBlock.Initializer,node:e,resultTitle:r}:null}}],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)}}(r.prototype,n),r}(p);function m(e,t,n,r,o,i,u){try{var c=e[i](u),a=c.value}catch(e){n(e);return}c.done?t(a):Promise.resolve(a).then(r,o)}function O(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function u(e){m(i,r,o,u,c,"next",e)}function c(e){m(i,r,o,u,c,"throw",e)}u(void 0)})}}function _(e,t,n){return(_=P()?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 k(e){return(k=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 x(e){var t="function"==typeof Map?new Map:void 0;return(x=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 _(e,arguments,k(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),j(n,e)})(e)}function P(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(P=function(){return!!e})()}function S(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(u,"next",{value:a(0)}),c(u,"throw",{value:a(1)}),c(u,"return",{value:a(2)}),"function"==typeof Symbol&&c(u,Symbol.iterator,{value:function(){return this}}),u;function a(c){return function(a){var l=[c,a];if(n)throw TypeError("Generator is already executing.");for(;u&&(u=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var E=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=k(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">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,P()?Reflect.construct(e,t||[],k(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:"afterAdd",value:function(){return O(function(){return S(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return O(function(){return S(this,function(e){return[2]})})()}},{key:"load",value:function(){return O(function(){return S(this,function(e){return this.app.pm.get("workflow").registerInstruction("aggregate",h),[2]})}).call(this)}}],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}(x(e.Plugin))}(),w}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("react"),require("antd"),require("@nocobase/plugin-workflow/client-v2"),require("@nocobase/client"),require("@ant-design/icons"),require("@nocobase/plugin-workflow/client"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-aggregate",["react-i18next","react","antd","@nocobase/plugin-workflow/client-v2","@nocobase/client","@ant-design/icons","@nocobase/plugin-workflow/client","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-aggregate"]=t(require("react-i18next"),require("react"),require("antd"),require("@nocobase/plugin-workflow/client-v2"),require("@nocobase/client"),require("@ant-design/icons"),require("@nocobase/plugin-workflow/client"),require("@nocobase/flow-engine")):e["@nocobase/plugin-workflow-aggregate"]=t(e["react-i18next"],e.react,e.antd,e["@nocobase/plugin-workflow/client-v2"],e["@nocobase/client"],e["@ant-design/icons"],e["@nocobase/plugin-workflow/client"],e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o,i,u,c){return function(){"use strict";var a,l,f,s={488:function(e,t,n){n.d(t,{CU:function(){return o},kj:function(){return i}});var r=n(694),o="workflow-aggregate";function i(){var e=(0,r.useFlowEngine)();return function(t,n){return e.context.t(t,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}({ns:[o,"client"],nsMode:"fallback"},n))}}},375:function(e){e.exports=i},342:function(e){e.exports=o},694:function(e){e.exports=c},990:function(e){e.exports=u},197:function(e){e.exports=r},59:function(e){e.exports=n},155:function(e){e.exports=t},953:function(t){t.exports=e}},p={};function b(e){var t=p[e];if(void 0!==t)return t.exports;var n=p[e]={exports:{}};return s[e](n,n.exports,b),n.exports}b.m=s,b.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return b.d(t,{a:t}),t},b.d=function(e,t){for(var n in t)b.o(t,n)&&!b.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},b.f={},b.e=function(e){return Promise.all(Object.keys(b.f).reduce(function(t,n){return b.f[n](e,t),t},[]))},b.u=function(e){return""+e+".f301445fdbe772db.js"},b.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),b.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},g={},b.l=function(e,t,n,r){if(g[e])return void g[e].push(t);if(void 0!==n)for(var o,i,u=document.getElementsByTagName("script"),c=0;c<u.length;c++){var a=u[c];if(a.getAttribute("src")==e||a.getAttribute("data-rspack")=="@nocobase/plugin-workflow-aggregate:"+n){o=a;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,b.nc&&o.setAttribute("nonce",b.nc),o.setAttribute("data-rspack","@nocobase/plugin-workflow-aggregate:"+n),o.src=e),g[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(f);var r=g[e];if(delete g[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)},b.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},b.g.importScripts&&(d=b.g.location+"");var g,d,y=b.g.document;if(!d&&y&&(y.currentScript&&"SCRIPT"===y.currentScript.tagName.toUpperCase()&&(d=y.currentScript.src),!d)){var v=y.getElementsByTagName("script");if(v.length)for(var h=v.length-1;h>-1&&(!d||!/^http(s?):/.test(d));)d=v[h--].src}if(!d)throw Error("Automatic publicPath is not supported in this browser");b.p=d.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a={889:0},b.f.j=function(e,t){var n=b.o(a,e)?a[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=a[e]=[t,r]});t.push(n[2]=r);var o=b.p+b.u(e),i=Error();b.l(o,function(t){if(b.o(a,e)&&(0!==(n=a[e])&&(a[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)}},l=function(e,t){var n,r,o=t[0],i=t[1],u=t[2],c=0;if(o.some(function(e){return 0!==a[e]})){for(n in i)b.o(i,n)&&(b.m[n]=i[n]);u&&u(b)}for(e&&e(t);c<o.length;c++)r=o[c],b.o(a,r)&&a[r]&&a[r][0](),a[r]=0},(f=self.webpackChunk_nocobase_plugin_workflow_aggregate=self.webpackChunk_nocobase_plugin_workflow_aggregate||[]).forEach(l.bind(null,0)),f.push=l.bind(null,f.push.bind(f));var w={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-workflow-aggregate/dist/client/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-workflow-aggregate/dist/client/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var u=window.location.pathname||"/",c=u.indexOf(i);e=c>=0?u.slice(0,c+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-workflow-aggregate/dist/client/"}b.p=e}(),!function(){b.r(w),b.d(w,{default:function(){return E}});var e=b(342),t=b(990),n=b(155),r=b.n(n),o=b(375),i=b(197),u=b(488);function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e){return(a=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 f(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(f=function(){return!!e})()}var s=function(e){return'{{t("'.concat(e,'", { ns: "').concat(u.CU,'" })}}')},p=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,i;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,i=arguments,t=a(t),c(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">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,f()?Reflect.construct(t,i||[],a(this).constructor):t.apply(this,i)),"title",s("Aggregate")),c(e,"type","aggregate"),c(e,"group","collection"),c(e,"description",s("Counting, summing, finding maximum, minimum, and average values for multiple records of a collection or associated data of a record.")),c(e,"icon",r().createElement(o.BarChartOutlined,null)),c(e,"FieldsetLoader",function(){return b.e("604").then(b.bind(b,7)).then(function(e){return{default:e.AggregateFieldset}})}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&l(n,e),t=[{key:"createDefaultConfig",value:function(){return{aggregator:"count",associated:!1,precision:2}}},{key:"useVariables",value:function(e){var t,n=e.key,r=e.title,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=o.types,a=o.fieldNames,l=void 0===a?i.defaultFieldNames:a;return u&&!u.some(function(e){return"string"==typeof e&&(e in i.BaseTypeSets||Object.values(i.BaseTypeSets).some(function(t){return t.has(e)}))})?null:(c(t={},l.value,n),c(t,l.label,r),t)}},{key:"getCreateModelMenuItem",value:function(e){var t,n,r=e.node;return(null==(n=r.config)?void 0:n.collection)?{key:"#".concat(r.id),label:null!=(t=r.title)?t:"#".concat(r.id),useModel:"NodeValueModel",createModelOptions:{use:"NodeValueModel",stepParams:{valueSettings:{init:{dataSource:"{{$jobsMapByNodeKey.".concat(r.key,"}}"),defaultValue:s("Query result")}},cardSettings:{titleDescription:{title:s("Aggregate")}}}}}:null}}],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}(i.Instruction),g=b(953);function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function y(e,t){return(y=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function v(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(v=function(){return!!e})()}var h=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=d(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">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,v()?Reflect.construct(e,t||[],d(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&y(r,e),n=[{key:"useInitializers",value:function(e){var n,r=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,(t=n,(0,g.useTranslation)("workflow-aggregate",t)).t)(e)}("Query result");return e.config.collection?{name:"#".concat(e.id),type:"item",title:null!=(n=e.title)?n:"#".concat(e.id),Component:t.ValueBlock.Initializer,node:e,resultTitle:r}:null}}],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)}}(r.prototype,n),r}(p);function m(e,t,n,r,o,i,u){try{var c=e[i](u),a=c.value}catch(e){n(e);return}c.done?t(a):Promise.resolve(a).then(r,o)}function O(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function u(e){m(i,r,o,u,c,"next",e)}function c(e){m(i,r,o,u,c,"throw",e)}u(void 0)})}}function _(e,t,n){return(_=P()?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 k(e){return(k=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 x(e){var t="function"==typeof Map?new Map:void 0;return(x=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 _(e,arguments,k(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),j(n,e)})(e)}function P(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(P=function(){return!!e})()}function S(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(u,"next",{value:a(0)}),c(u,"throw",{value:a(1)}),c(u,"return",{value:a(2)}),"function"==typeof Symbol&&c(u,Symbol.iterator,{value:function(){return this}}),u;function a(c){return function(a){var l=[c,a];if(n)throw TypeError("Generator is already executing.");for(;u&&(u=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var E=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=k(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">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,P()?Reflect.construct(e,t||[],k(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:"afterAdd",value:function(){return O(function(){return S(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return O(function(){return S(this,function(e){return[2]})})()}},{key:"load",value:function(){return O(function(){return S(this,function(e){return this.app.pm.get("workflow").registerInstruction("aggregate",h),[2]})}).call(this)}}],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}(x(e.Plugin))}(),w}()});
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ "use strict";(self.webpackChunk_nocobase_plugin_workflow_aggregate_client_v2=self.webpackChunk_nocobase_plugin_workflow_aggregate_client_v2||[]).push([["604"],{7:function(e,n,t){t.d(n,{AggregateFieldset:function(){return M}});var r=t(155),l=t.n(r),o=t(59),a=t(197),i=[{label:"COUNT",value:"count"},{label:"SUM",value:"sum"},{label:"AVG",value:"avg"},{label:"MIN",value:"min"},{label:"MAX",value:"max"}],u=["hasMany","belongsToMany"],c=["belongsTo","hasOne","hasMany","belongsToMany"],s=t(488);function f(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}function d(e){return u.includes(e.type)}function p(e){return!!(!e.hidden&&e.interface&&!c.includes(e.type))}var m=t(694);function y(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}function b(e,n,t,r,l,o,a){try{var i=e[o](a),u=i.value}catch(e){t(e);return}i.done?n(u):Promise.resolve(u).then(r,l)}function g(e){return function(){var n=this,t=arguments;return new Promise(function(r,l){var o=e.apply(n,t);function a(e){b(o,r,l,a,i,"next",e)}function i(e){b(o,r,l,a,i,"throw",e)}a(void 0)})}}function v(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},r=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.forEach(function(n){var r;r=t[n],n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r})}return e}function h(e,n){return n=null!=n?n:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):(function(e){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n.push.apply(n,t)}return n})(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}),e}function w(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t,r,l=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=l){var o=[],a=!0,i=!1;try{for(l=l.call(e);!(a=(t=l.next()).done)&&(o.push(t.value),!n||o.length!==n);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==l.return||l.return()}finally{if(i)throw r}}return o}}(e,n)||j(e,n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e){return function(e){if(Array.isArray(e))return y(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||j(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function j(e,n){if(e){if("string"==typeof e)return y(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return y(e,n)}}function S(e,n){var t,r,l,o={label:0,sent:function(){if(1&l[0])throw l[1];return l[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(a,"next",{value:u(0)}),i(a,"throw",{value:u(1)}),i(a,"return",{value:u(2)}),"function"==typeof Symbol&&i(a,Symbol.iterator,{value:function(){return this}}),a;function u(i){return function(u){var c=[i,u];if(t)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(t=1,r&&(l=2&c[0]?r.return:c[0]?r.throw||((l=r.return)&&l.call(r),0):r.next)&&!(l=l.call(r,c[1])).done)return l;switch(r=0,l&&(c=[2&c[0],l.value]),c[0]){case 0:case 1:l=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,r=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!(l=(l=o.trys).length>0&&l[l.length-1])&&(6===c[0]||2===c[0])){o=0;continue}if(3===c[0]&&(!l||c[1]>l[0]&&c[1]<l[3])){o.label=c[1];break}if(6===c[0]&&o.label<l[1]){o.label=l[1],l=c;break}if(l&&o.label<l[2]){o.label=l[2],o.ops.push(c);break}l[2]&&o.ops.pop(),o.trys.pop();continue}c=n.call(e,o)}catch(e){c=[6,e],r=0}finally{t=l=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function E(e){return"options"in e&&e.options?e.options:e}function F(e){return w((0,a.parseCollectionName)(null!=e?e:""),1)[0]||"main"}function A(e,n,t){var r,l,o,a,i,u=e.field?E(e.field):void 0,c=u?h(v({},u),{dataSourceKey:null!=(a=u.dataSourceKey)?a:t}):void 0,s=null!=(i=null==c?void 0:c.dataSourceKey)?i:t,f="function"==typeof e.loadChildren?function(t){return g(function(){var r;return S(this,function(l){switch(l.label){case 0:return[4,null==(r=e.loadChildren)?void 0:r.call(e,t)];case 1:return l.sent(),t.children=Array.isArray(t.children)?t.children.map(function(e){return A(e,n,s)}):void 0,[2]}})})()}:void 0;return{appends:e.appends,depth:e.depth,key:e.key,value:"string"==typeof(l=null!=(r=e.value)?r:e.key)?l:String(null!=l?l:""),label:(o=e.label,"string"==typeof o?n(o,{ns:["workflow","workflow-aggregate","client"]}):o),disabled:!!e.disabled,isLeaf:!!e.isLeaf,field:c,loadChildren:f,types:e.types,children:Array.isArray(e.children)?e.children.map(function(e){return A(e,n,s)}):void 0}}function C(e){var n=e.label,t=e.value,r=e.children;return{key:t,value:t,label:n,children:r,disabled:!r.length}}function k(e){return g(function(){var n;return S(this,function(t){switch(t.label){case 0:if(!(!(null==(n=e.children)?void 0:n.length)&&!e.isLeaf&&e.loadChildren))return[3,2];return[4,e.loadChildren(e)];case 1:t.sent(),t.label=2;case 2:return[2]}})})()}function I(e){e.setFieldValue(["config","params","field"],null),e.setFieldValue(["config","params","filter"],null)}function V(e,n){e.setFieldValue(["config","collection"],null),I(e),null==n||n({})}function x(e){var n,t,i,u,c,s,p,y,b,j,x,P,N,D,M,T,_,K,R,q=e.value,U=e.onChange,$=e.onDropdownVisibleChange,W=function(e,n){if(null==e)return{};var t,r,l,o={};if("u">typeof Reflect&&Reflect.ownKeys){for(l=0,t=Reflect.ownKeys(Object(e));l<t.length;l++)r=t[l],!(n.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}if(o=function(e,n){if(null==e)return{};var t,r,l={},o=Object.getOwnPropertyNames(e);for(r=0;r<o.length;r++)t=o[r],!(n.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(e,t)&&(l[t]=e[t]);return l}(e,n),Object.getOwnPropertySymbols)for(l=0,t=Object.getOwnPropertySymbols(e);l<t.length;l++)r=t[l],!(n.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}(e,["value","onChange","onDropdownVisibleChange"]),G=(0,m.useFlowEngine)(),B=o.Form.useFormInstance(),L=(b=(0,m.useFlowEngine)(),j=(0,a.useNodeContext)(),x=(0,a.useCurrentWorkflowContext)(),P=(0,a.useAvailableUpstreams)(j),N=b.context.app.pm.get("workflow")||b.context.app.pm.get("@nocobase/plugin-workflow"),D=function(e,n){return b.context.t(e,n)},M={types:[d],appends:null,depth:4},T=[],P.forEach(function(e){var n,t,r,l=null==N||null==(n=N.instructions)?void 0:n.get(e.type),o=null==l||null==(t=l.useVariables)?void 0:t.call(l,e,M);o&&T.push(A(o,D,F(null==(r=e.config)?void 0:r.collection)))}),R=Array.isArray(K=null==(_=(null==x?void 0:x.type)?null==N||null==(p=N.triggers)?void 0:p.get(x.type):void 0)||null==(y=_.useVariables)?void 0:y.call(_,null==x?void 0:x.config,M))?K.filter(Boolean).map(function(e){var n;return A(e,D,F(null==x||null==(n=x.config)?void 0:n.collection))}):[],[C({label:D("Node result",{ns:"workflow"}),value:"$jobsMapByNodeKey",children:T}),C({label:D("Trigger variables",{ns:"workflow"}),value:"$context",children:R})]),X=L.map(function(e){var n,t;return"".concat(e.value,":").concat(null!=(n=null==(t=e.children)?void 0:t.map(function(e){return e.value}).join(","))?n:"")}).join("|"),z=w((0,r.useState)(L),2),H=z[0],J=z[1],Q=(u=(i=null!=(n=q)?n:{}).associatedKey,c=i.name,(s=(void 0===u?"":u).match(/^{{(.*)}}$/))&&c?((function(e){if(Array.isArray(e))return f(e)})(t=s[1].trim().split(".").slice(0,-1))||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e){if(e){if("string"==typeof e)return f(e,void 0);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,void 0)}}(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([c]).filter(Boolean):[]),Y=Q.join("."),Z=w((0,r.useState)(Q),2),ee=Z[0],en=Z[1];return(0,r.useEffect)(function(){J(L)},[X]),(0,r.useEffect)(function(){en(Q)},[Y]),(0,r.useEffect)(function(){var e=!1;return g(function(){var n,t,r,l,o,a,i,u,c,s;return S(this,function(f){switch(f.label){case 0:if(!Q.length||!H.length)return[2];n=H,r=!0,l=!0,o=!1,a=void 0,f.label=1;case 1:f.trys.push([1,6,7,8]),i=function(){var e,l;return S(this,function(o){switch(o.label){case 0:if(e=c.value,!(t=n.find(function(n){return n.value===e})))return r=!1,[2,"break"];return[4,k(t)];case 1:return o.sent(),n=null!=(l=t.children)?l:[],[2]}})},u=Q[Symbol.iterator](),f.label=2;case 2:if(l=(c=u.next()).done)return[3,5];return[5,function(e){var n="function"==typeof Symbol&&Symbol.iterator,t=n&&e[n],r=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}(i())];case 3:if("break"===f.sent())return[3,5];f.label=4;case 4:return l=!0,[3,2];case 5:return[3,8];case 6:return s=f.sent(),o=!0,a=s,[3,8];case 7:try{l||null==u.return||u.return()}finally{if(o)throw a}return[7];case 8:if(e)return[2];if(r&&(null==t?void 0:t.field)&&!d(t.field))return V(B,U),[2];return J(O(H)),[2]}})})(),function(){e=!0}},[Y,H.length]),l().createElement(o.Cascader,h(v({},W),{value:ee,options:H,changeOnSelect:!0,loadData:function(e){return g(function(){var n;return S(this,function(t){switch(t.label){case 0:if(!(n=e[e.length-1]))return[2];return[4,k(n)];case 1:return t.sent(),J(O(H)),[2]}})})()},onDropdownVisibleChange:function(e){e||en(Q),null==$||$(e)},onChange:function(e,n){if(en(e),!(null==e?void 0:e.length))return void V(B,U);var t,r=n[n.length-1],l=null==r?void 0:r.field;if(l&&d(l)&&l.collectionName&&l.target&&l.name){var o,i,u,c,s,f,p,m,y,b=null!=(t=l.dataSourceKey)?t:"main",g=(0,a.joinCollectionName)(b,l.collectionName),v=null!=(m=null==(y=((f=s=null!=(i=null!=(u=null==(o=(0,a.getCollection)(G.context.dataSourceManager,g))||null==(c=o.getFields)?void 0:c.call(o))?u:null==o?void 0:o.fields)?i:[],null!=(p=Map)&&"u">typeof Symbol&&p[Symbol.hasInstance]?!!p[Symbol.hasInstance](f):f instanceof p)?Array.from(s.values()):s).map(E).find(function(e){return e.primaryKey}))?void 0:y.name)?m:"id";B.setFieldValue(["config","collection"],(0,a.joinCollectionName)(b,l.target)),I(B),null==U||U({name:l.name,associatedKey:"{{".concat(e.slice(0,-1).join("."),".").concat(v,"}}"),associatedCollection:g})}}}))}function P(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}function N(e){var n=e.collection,t=(0,s.kj)();return n?l().createElement(o.Form.Item,{name:["config","params","field"],label:t("Field to aggregate"),rules:[{required:!0}]},l().createElement(a.FieldsSelect,{collection:n,filter:p})):null}function D(){var e=(0,s.kj)(),n=o.Form.useWatch(["config","collection"]),t=o.Form.useWatch(["config","aggregator"]);return n?l().createElement(l().Fragment,null,"count"===t?l().createElement(o.Form.Item,{name:["config","params","distinct"],valuePropName:"checked"},l().createElement(o.Checkbox,null,e("Distinct"))):null,l().createElement(o.Form.Item,{name:["config","params","filter"],label:e("Filter")},l().createElement(a.FilterDynamicComponent,{collection:n}))):null}function M(){var e=(0,s.kj)(),n=o.Form.useFormInstance(),t=o.Form.useWatch(["config","associated"]),u=o.Form.useWatch(["config","collection"]),c=[{label:e("Data of collection"),value:!1},{label:e("Data of associated collection"),value:!0}];return(0,r.useEffect)(function(){void 0===n.getFieldValue(["config","aggregator"])&&n.setFieldValue(["config","aggregator"],"count"),void 0===n.getFieldValue(["config","associated"])&&n.setFieldValue(["config","associated"],!1),void 0===n.getFieldValue(["config","precision"])&&n.setFieldValue(["config","precision"],2)},[n]),l().createElement(l().Fragment,null,l().createElement(o.Form.Item,{name:["config","aggregator"],label:e("Aggregator function"),rules:[{required:!0}]},l().createElement(o.Radio.Group,{options:function(e){if(Array.isArray(e))return P(e)}(i)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(i)||function(e){if(e){if("string"==typeof e)return P(e,void 0);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 P(e,void 0)}}(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.")}()})),l().createElement(o.Form.Item,{name:["config","associated"],label:e("Target type"),rules:[{required:!0}]},l().createElement(o.Radio.Group,{options:c,onChange:function(){n.setFieldValue(["config","collection"],null),n.setFieldValue(["config","association"],null),n.setFieldValue(["config","params","field"],null),n.setFieldValue(["config","params","filter"],null)}})),l().createElement(o.Row,{gutter:24},l().createElement(o.Col,{span:12},t?l().createElement(o.Form.Item,{name:["config","association"],label:e("Data of associated collection"),rules:[{required:!0}]},l().createElement(x,null)):l().createElement(o.Form.Item,{name:["config","collection"],label:e("Data of collection"),rules:[{required:!0}]},l().createElement(a.CollectionCascader,{onChange:function(){n.setFieldValue(["config","params","field"],null),n.setFieldValue(["config","params","filter"],null)}}))),l().createElement(o.Col,{span:12},l().createElement(N,{collection:u}))),l().createElement(D,null),l().createElement(o.Form.Item,{name:["config","precision"],label:e("Result precision"),extra:e("Number of decimal places for query result.")},l().createElement(o.InputNumber,{min:0,max:14,step:1,precision:0,className:"auto-width"})))}}}]);
@@ -8,7 +8,7 @@
8
8
  */
9
9
  import React from 'react';
10
10
  import type { CascaderProps } from 'antd';
11
- import { type CollectionTriggerField } from '@nocobase/plugin-workflow/client-v2';
11
+ import { type CollectionTriggerField, type UseVariableOptions } from '@nocobase/plugin-workflow/client-v2';
12
12
  import type { AggregateAssociationConfig } from '../types';
13
13
  type FieldWithDataSource = CollectionTriggerField & {
14
14
  collectionName?: string;
@@ -16,16 +16,19 @@ type FieldWithDataSource = CollectionTriggerField & {
16
16
  options?: FieldWithDataSource;
17
17
  };
18
18
  type AssociatedCascaderOption = {
19
+ appends?: string[] | null;
20
+ depth?: number;
19
21
  key?: string;
20
22
  value: string;
21
23
  label?: React.ReactNode;
22
24
  disabled?: boolean;
23
25
  isLeaf?: boolean;
24
26
  field?: FieldWithDataSource;
25
- loadChildren?: (option: AssociatedCascaderOption) => Promise<void> | void;
27
+ loadChildren?: ((option: AssociatedCascaderOption) => Promise<void> | void) | null;
28
+ types?: UseVariableOptions['types'];
26
29
  children?: AssociatedCascaderOption[];
27
30
  };
28
- export declare function AssociatedConfig({ value, onChange, ...props }: Omit<CascaderProps<AssociatedCascaderOption, 'value', false>, 'loadData' | 'multiple' | 'onChange' | 'options' | 'value'> & {
31
+ export declare function AssociatedConfig({ value, onChange, onDropdownVisibleChange, ...props }: Omit<CascaderProps<AssociatedCascaderOption, 'value', false>, 'loadData' | 'multiple' | 'onChange' | 'options' | 'value'> & {
29
32
  value?: AggregateAssociationConfig | null;
30
33
  onChange?: (value: AggregateAssociationConfig) => void;
31
34
  }): React.JSX.Element;
@@ -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("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/plugin-workflow/client-v2"),require("@ant-design/icons"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-aggregate/client-v2",["@nocobase/client-v2","react","antd","@nocobase/plugin-workflow/client-v2","@ant-design/icons","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-aggregate/client-v2"]=t(require("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/plugin-workflow/client-v2"),require("@ant-design/icons"),require("@nocobase/flow-engine")):e["@nocobase/plugin-workflow-aggregate/client-v2"]=t(e["@nocobase/client-v2"],e.react,e.antd,e["@nocobase/plugin-workflow/client-v2"],e["@ant-design/icons"],e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o,i){return function(){"use strict";var u,a,c,l={488:function(e,t,n){n.d(t,{CU:function(){return o},kj:function(){return i}});var r=n(694),o="workflow-aggregate";function i(){var e=(0,r.useFlowEngine)();return function(t,n){return e.context.t(t,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}({ns:[o,"client"],nsMode:"fallback"},n))}}},375:function(e){e.exports=o},485:function(t){t.exports=e},694:function(e){e.exports=i},197:function(e){e.exports=r},59:function(e){e.exports=n},155:function(e){e.exports=t}},f={};function s(e){var t=f[e];if(void 0!==t)return t.exports;var n=f[e]={exports:{}};return l[e](n,n.exports,s),n.exports}s.m=l,s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,{a:t}),t},s.d=function(e,t){for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.f={},s.e=function(e){return Promise.all(Object.keys(s.f).reduce(function(t,n){return s.f[n](e,t),t},[]))},s.u=function(e){return""+e+".52f40a83508f65b8.js"},s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},p={},s.l=function(e,t,n,r){if(p[e])return void p[e].push(t);if(void 0!==n)for(var o,i,u=document.getElementsByTagName("script"),a=0;a<u.length;a++){var c=u[a];if(c.getAttribute("src")==e||c.getAttribute("data-rspack")=="@nocobase/plugin-workflow-aggregate/client-v2:"+n){o=c;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,s.nc&&o.setAttribute("nonce",s.nc),o.setAttribute("data-rspack","@nocobase/plugin-workflow-aggregate/client-v2:"+n),o.src=e),p[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(f);var r=p[e];if(delete p[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)},s.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.g.importScripts&&(g=s.g.location+"");var p,g,b=s.g.document;if(!g&&b&&(b.currentScript&&"SCRIPT"===b.currentScript.tagName.toUpperCase()&&(g=b.currentScript.src),!g)){var d=b.getElementsByTagName("script");if(d.length)for(var v=d.length-1;v>-1&&(!g||!/^http(s?):/.test(g));)g=d[v--].src}if(!g)throw Error("Automatic publicPath is not supported in this browser");s.p=g.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),u={889:0},s.f.j=function(e,t){var n=s.o(u,e)?u[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=u[e]=[t,r]});t.push(n[2]=r);var o=s.p+s.u(e),i=Error();s.l(o,function(t){if(s.o(u,e)&&(0!==(n=u[e])&&(u[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)}},a=function(e,t){var n,r,o=t[0],i=t[1],a=t[2],c=0;if(o.some(function(e){return 0!==u[e]})){for(n in i)s.o(i,n)&&(s.m[n]=i[n]);a&&a(s)}for(e&&e(t);c<o.length;c++)r=o[c],s.o(u,r)&&u[r]&&u[r][0](),u[r]=0},(c=self.webpackChunk_nocobase_plugin_workflow_aggregate_client_v2=self.webpackChunk_nocobase_plugin_workflow_aggregate_client_v2||[]).forEach(a.bind(null,0)),c.push=a.bind(null,c.push.bind(c));var y={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-workflow-aggregate/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-workflow-aggregate/dist/client-v2/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var u=window.location.pathname||"/",a=u.indexOf(i);e=a>=0?u.slice(0,a+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-workflow-aggregate/dist/client-v2/"}s.p=e}(),!function(){s.r(y),s.d(y,{default:function(){return m},AggregateInstruction:function(){return p}});var e=s(485),t=s(155),n=s.n(t),r=s(375),o=s(197),i=s(488);function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(l=function(){return!!e})()}var f=function(e){return'{{t("'.concat(e,'", { ns: "').concat(i.CU,'" })}}')},p=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function i(){var e,t,o;if(!(this instanceof i))throw TypeError("Cannot call a class as a function");return t=i,o=arguments,t=a(t),u(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">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,l()?Reflect.construct(t,o||[],a(this).constructor):t.apply(this,o)),"title",f("Aggregate")),u(e,"type","aggregate"),u(e,"group","collection"),u(e,"description",f("Counting, summing, finding maximum, minimum, and average values for multiple records of a collection or associated data of a record.")),u(e,"icon",n().createElement(r.BarChartOutlined,null)),u(e,"FieldsetLoader",function(){return s.e("604").then(s.bind(s,7)).then(function(e){return{default:e.AggregateFieldset}})}),e}return i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&c(i,e),t=[{key:"createDefaultConfig",value:function(){return{aggregator:"count",associated:!1,precision:2}}},{key:"useVariables",value:function(e){var t,n=e.key,r=e.title,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=i.types,c=i.fieldNames,l=void 0===c?o.defaultFieldNames:c;return a&&!a.some(function(e){return"string"==typeof e&&(e in o.BaseTypeSets||Object.values(o.BaseTypeSets).some(function(t){return t.has(e)}))})?null:(u(t={},l.value,n),u(t,l.label,r),t)}},{key:"getCreateModelMenuItem",value:function(e){var t,n,r=e.node;return(null==(n=r.config)?void 0:n.collection)?{key:"#".concat(r.id),label:null!=(t=r.title)?t:"#".concat(r.id),useModel:"NodeValueModel",createModelOptions:{use:"NodeValueModel",stepParams:{valueSettings:{init:{dataSource:"{{$jobsMapByNodeKey.".concat(r.key,"}}"),defaultValue:f("Query result")}},cardSettings:{titleDescription:{title:f("Aggregate")}}}}}:null}}],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)}}(i.prototype,t),i}(o.Instruction);function g(e,t,n,r,o,i,u){try{var a=e[i](u),c=a.value}catch(e){n(e);return}a.done?t(c):Promise.resolve(c).then(r,o)}function b(e,t,n){return(b=w()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&v(o,n.prototype),o}).apply(null,arguments)}function d(e){return(d=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 h(e){var t="function"==typeof Map?new Map:void 0;return(h=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 b(e,arguments,d(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),v(n,e)})(e)}function w(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(w=function(){return!!e})()}var m=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=d(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">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,w()?Reflect.construct(e,t||[],d(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&v(n,e),t=[{key:"load",value:function(){var e;return(e=function(){var e,t;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(u,"next",{value:c(0)}),a(u,"throw",{value:c(1)}),a(u,"return",{value:c(2)}),"function"==typeof Symbol&&a(u,Symbol.iterator,{value:function(){return this}}),u;function c(a){return function(c){var l=[a,c];if(n)throw TypeError("Generator is already executing.");for(;u&&(u=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(n){return null==(t=this.app.pm.get("workflow")||this.app.pm.get("@nocobase/plugin-workflow"))||null==(e=t.registerInstruction)||e.call(t,"aggregate",p),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function u(e){g(i,r,o,u,a,"next",e)}function a(e){g(i,r,o,u,a,"throw",e)}u(void 0)})}).call(this)}}],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}(h(e.Plugin))}(),y}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/plugin-workflow/client-v2"),require("@ant-design/icons"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-aggregate/client-v2",["@nocobase/client-v2","react","antd","@nocobase/plugin-workflow/client-v2","@ant-design/icons","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-aggregate/client-v2"]=t(require("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/plugin-workflow/client-v2"),require("@ant-design/icons"),require("@nocobase/flow-engine")):e["@nocobase/plugin-workflow-aggregate/client-v2"]=t(e["@nocobase/client-v2"],e.react,e.antd,e["@nocobase/plugin-workflow/client-v2"],e["@ant-design/icons"],e["@nocobase/flow-engine"])}(self,function(e,t,n,r,o,i){return function(){"use strict";var u,a,c,l={488:function(e,t,n){n.d(t,{CU:function(){return o},kj:function(){return i}});var r=n(694),o="workflow-aggregate";function i(){var e=(0,r.useFlowEngine)();return function(t,n){return e.context.t(t,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}({ns:[o,"client"],nsMode:"fallback"},n))}}},375:function(e){e.exports=o},485:function(t){t.exports=e},694:function(e){e.exports=i},197:function(e){e.exports=r},59:function(e){e.exports=n},155:function(e){e.exports=t}},f={};function s(e){var t=f[e];if(void 0!==t)return t.exports;var n=f[e]={exports:{}};return l[e](n,n.exports,s),n.exports}s.m=l,s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,{a:t}),t},s.d=function(e,t){for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.f={},s.e=function(e){return Promise.all(Object.keys(s.f).reduce(function(t,n){return s.f[n](e,t),t},[]))},s.u=function(e){return""+e+".46180b7b4af35a39.js"},s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},p={},s.l=function(e,t,n,r){if(p[e])return void p[e].push(t);if(void 0!==n)for(var o,i,u=document.getElementsByTagName("script"),a=0;a<u.length;a++){var c=u[a];if(c.getAttribute("src")==e||c.getAttribute("data-rspack")=="@nocobase/plugin-workflow-aggregate/client-v2:"+n){o=c;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,s.nc&&o.setAttribute("nonce",s.nc),o.setAttribute("data-rspack","@nocobase/plugin-workflow-aggregate/client-v2:"+n),o.src=e),p[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(f);var r=p[e];if(delete p[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)},s.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.g.importScripts&&(g=s.g.location+"");var p,g,b=s.g.document;if(!g&&b&&(b.currentScript&&"SCRIPT"===b.currentScript.tagName.toUpperCase()&&(g=b.currentScript.src),!g)){var d=b.getElementsByTagName("script");if(d.length)for(var v=d.length-1;v>-1&&(!g||!/^http(s?):/.test(g));)g=d[v--].src}if(!g)throw Error("Automatic publicPath is not supported in this browser");s.p=g.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),u={889:0},s.f.j=function(e,t){var n=s.o(u,e)?u[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=u[e]=[t,r]});t.push(n[2]=r);var o=s.p+s.u(e),i=Error();s.l(o,function(t){if(s.o(u,e)&&(0!==(n=u[e])&&(u[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)}},a=function(e,t){var n,r,o=t[0],i=t[1],a=t[2],c=0;if(o.some(function(e){return 0!==u[e]})){for(n in i)s.o(i,n)&&(s.m[n]=i[n]);a&&a(s)}for(e&&e(t);c<o.length;c++)r=o[c],s.o(u,r)&&u[r]&&u[r][0](),u[r]=0},(c=self.webpackChunk_nocobase_plugin_workflow_aggregate_client_v2=self.webpackChunk_nocobase_plugin_workflow_aggregate_client_v2||[]).forEach(a.bind(null,0)),c.push=a.bind(null,c.push.bind(c));var y={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-workflow-aggregate/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-workflow-aggregate/dist/client-v2/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var u=window.location.pathname||"/",a=u.indexOf(i);e=a>=0?u.slice(0,a+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-workflow-aggregate/dist/client-v2/"}s.p=e}(),!function(){s.r(y),s.d(y,{default:function(){return m},AggregateInstruction:function(){return p}});var e=s(485),t=s(155),n=s.n(t),r=s(375),o=s(197),i=s(488);function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(l=function(){return!!e})()}var f=function(e){return'{{t("'.concat(e,'", { ns: "').concat(i.CU,'" })}}')},p=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function i(){var e,t,o;if(!(this instanceof i))throw TypeError("Cannot call a class as a function");return t=i,o=arguments,t=a(t),u(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">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,l()?Reflect.construct(t,o||[],a(this).constructor):t.apply(this,o)),"title",f("Aggregate")),u(e,"type","aggregate"),u(e,"group","collection"),u(e,"description",f("Counting, summing, finding maximum, minimum, and average values for multiple records of a collection or associated data of a record.")),u(e,"icon",n().createElement(r.BarChartOutlined,null)),u(e,"FieldsetLoader",function(){return s.e("604").then(s.bind(s,7)).then(function(e){return{default:e.AggregateFieldset}})}),e}return i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&c(i,e),t=[{key:"createDefaultConfig",value:function(){return{aggregator:"count",associated:!1,precision:2}}},{key:"useVariables",value:function(e){var t,n=e.key,r=e.title,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=i.types,c=i.fieldNames,l=void 0===c?o.defaultFieldNames:c;return a&&!a.some(function(e){return"string"==typeof e&&(e in o.BaseTypeSets||Object.values(o.BaseTypeSets).some(function(t){return t.has(e)}))})?null:(u(t={},l.value,n),u(t,l.label,r),t)}},{key:"getCreateModelMenuItem",value:function(e){var t,n,r=e.node;return(null==(n=r.config)?void 0:n.collection)?{key:"#".concat(r.id),label:null!=(t=r.title)?t:"#".concat(r.id),useModel:"NodeValueModel",createModelOptions:{use:"NodeValueModel",stepParams:{valueSettings:{init:{dataSource:"{{$jobsMapByNodeKey.".concat(r.key,"}}"),defaultValue:f("Query result")}},cardSettings:{titleDescription:{title:f("Aggregate")}}}}}:null}}],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)}}(i.prototype,t),i}(o.Instruction);function g(e,t,n,r,o,i,u){try{var a=e[i](u),c=a.value}catch(e){n(e);return}a.done?t(c):Promise.resolve(c).then(r,o)}function b(e,t,n){return(b=w()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&v(o,n.prototype),o}).apply(null,arguments)}function d(e){return(d=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 h(e){var t="function"==typeof Map?new Map:void 0;return(h=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 b(e,arguments,d(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),v(n,e)})(e)}function w(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(w=function(){return!!e})()}var m=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=d(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">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,w()?Reflect.construct(e,t||[],d(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&v(n,e),t=[{key:"load",value:function(){var e;return(e=function(){var e,t;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(u,"next",{value:c(0)}),a(u,"throw",{value:c(1)}),a(u,"return",{value:c(2)}),"function"==typeof Symbol&&a(u,Symbol.iterator,{value:function(){return this}}),u;function c(a){return function(c){var l=[a,c];if(n)throw TypeError("Generator is already executing.");for(;u&&(u=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(n){return null==(t=this.app.pm.get("workflow")||this.app.pm.get("@nocobase/plugin-workflow"))||null==(e=t.registerInstruction)||e.call(t,"aggregate",p),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function u(e){g(i,r,o,u,a,"next",e)}function a(e){g(i,r,o,u,a,"throw",e)}u(void 0)})}).call(this)}}],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}(h(e.Plugin))}(),y}()});
@@ -8,19 +8,19 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.2.0-alpha.2",
12
- "@nocobase/plugin-workflow": "2.2.0-alpha.2",
11
+ "@nocobase/client": "2.2.0-alpha.4",
12
+ "@nocobase/plugin-workflow": "2.2.0-alpha.4",
13
13
  "react": "18.2.0",
14
14
  "@ant-design/icons": "5.6.1",
15
- "@nocobase/flow-engine": "2.2.0-alpha.2",
16
- "@nocobase/client-v2": "2.2.0-alpha.2",
15
+ "@nocobase/flow-engine": "2.2.0-alpha.4",
16
+ "@nocobase/client-v2": "2.2.0-alpha.4",
17
17
  "react-i18next": "11.18.6",
18
18
  "mathjs": "15.1.0",
19
- "@nocobase/data-source-manager": "2.2.0-alpha.2",
20
- "@nocobase/database": "2.2.0-alpha.2",
21
- "@nocobase/server": "2.2.0-alpha.2",
22
- "@nocobase/plugin-workflow-test": "2.2.0-alpha.2",
23
- "@nocobase/test": "2.2.0-alpha.2",
24
- "@nocobase/utils": "2.2.0-alpha.2",
19
+ "@nocobase/data-source-manager": "2.2.0-alpha.4",
20
+ "@nocobase/database": "2.2.0-alpha.4",
21
+ "@nocobase/server": "2.2.0-alpha.4",
22
+ "@nocobase/plugin-workflow-test": "2.2.0-alpha.4",
23
+ "@nocobase/test": "2.2.0-alpha.4",
24
+ "@nocobase/utils": "2.2.0-alpha.4",
25
25
  "antd": "5.24.2"
26
26
  };
@@ -1 +1 @@
1
- {"name":"joi","description":"Object schema validation","version":"17.13.3","repository":"git://github.com/hapijs/joi","main":"lib/index.js","types":"lib/index.d.ts","browser":"dist/joi-browser.min.js","files":["lib/**/*","dist/*"],"keywords":["schema","validation"],"dependencies":{"@hapi/hoek":"^9.3.0","@hapi/topo":"^5.1.0","@sideway/address":"^4.1.5","@sideway/formula":"^3.0.1","@sideway/pinpoint":"^2.0.0"},"devDependencies":{"@hapi/bourne":"2.x.x","@hapi/code":"8.x.x","@hapi/joi-legacy-test":"npm:@hapi/joi@15.x.x","@hapi/lab":"^25.1.3","@types/node":"^14.18.63","typescript":"4.3.x"},"scripts":{"prepublishOnly":"cd browser && npm install && npm run build","test":"lab -t 100 -a @hapi/code -L -Y","test-cov-html":"lab -r html -o coverage.html -a @hapi/code"},"license":"BSD-3-Clause","_lastModified":"2026-06-26T03:51:40.492Z"}
1
+ {"name":"joi","description":"Object schema validation","version":"17.13.3","repository":"git://github.com/hapijs/joi","main":"lib/index.js","types":"lib/index.d.ts","browser":"dist/joi-browser.min.js","files":["lib/**/*","dist/*"],"keywords":["schema","validation"],"dependencies":{"@hapi/hoek":"^9.3.0","@hapi/topo":"^5.1.0","@sideway/address":"^4.1.5","@sideway/formula":"^3.0.1","@sideway/pinpoint":"^2.0.0"},"devDependencies":{"@hapi/bourne":"2.x.x","@hapi/code":"8.x.x","@hapi/joi-legacy-test":"npm:@hapi/joi@15.x.x","@hapi/lab":"^25.1.3","@types/node":"^14.18.63","typescript":"4.3.x"},"scripts":{"prepublishOnly":"cd browser && npm install && npm run build","test":"lab -t 100 -a @hapi/code -L -Y","test-cov-html":"lab -r html -o coverage.html -a @hapi/code"},"license":"BSD-3-Clause","_lastModified":"2026-07-01T07:57:54.418Z"}
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "Used to aggregate data against the database in workflow, such as: statistics, sum, average, etc.",
7
7
  "description.zh-CN": "可用于在工作流中对数据库进行聚合查询,如:统计数量、求和、平均值等。",
8
8
  "description.ru-RU": "Используется для агрегирования данных из базы данных в рабочем процессе, например: статистика, сумма, среднее и т.д.",
9
- "version": "2.2.0-alpha.2",
9
+ "version": "2.2.0-alpha.4",
10
10
  "license": "Apache-2.0",
11
11
  "main": "./dist/server/index.js",
12
12
  "homepage": "https://docs.nocobase.com/handbook/workflow-aggregate",
@@ -27,7 +27,7 @@
27
27
  "@nocobase/test": "2.x",
28
28
  "mathjs": "^15.1.0"
29
29
  },
30
- "gitHead": "9dd5224bb8f6c1ac12d766b9f175bdc29bddd845",
30
+ "gitHead": "81bf8733db4bccf08a6bc5e6d97f274bce349161",
31
31
  "keywords": [
32
32
  "Workflow"
33
33
  ]
@@ -1,10 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- "use strict";(self.webpackChunk_nocobase_plugin_workflow_aggregate=self.webpackChunk_nocobase_plugin_workflow_aggregate||[]).push([["604"],{7:function(e,t,n){n.d(t,{AggregateFieldset:function(){return N}});var r=n(155),l=n.n(r),o=n(59),a=n(197),i=[{label:"COUNT",value:"count"},{label:"SUM",value:"sum"},{label:"AVG",value:"avg"},{label:"MIN",value:"min"},{label:"MAX",value:"max"}],u=["hasMany","belongsToMany"],c=["belongsTo","hasOne","hasMany","belongsToMany"],s=n(488);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 d(e){return u.includes(e.type)}function m(e){return!!(!e.hidden&&e.interface&&!c.includes(e.type))}var p=n(694);function y(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 b(e,t,n,r,l,o,a){try{var i=e[o](a),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,l)}function g(e){return function(){var t=this,n=arguments;return new Promise(function(r,l){var o=e.apply(t,n);function a(e){b(o,r,l,a,i,"next",e)}function i(e){b(o,r,l,a,i,"throw",e)}a(void 0)})}}function v(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 h(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function w(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,l=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=l){var o=[],a=!0,i=!1;try{for(l=l.call(e);!(a=(n=l.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==l.return||l.return()}finally{if(i)throw r}}return o}}(e,t)||j(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e){return function(e){if(Array.isArray(e))return y(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||j(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function j(e,t){if(e){if("string"==typeof e)return y(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 y(e,t)}}function S(e,t){var n,r,l,o={label:0,sent:function(){if(1&l[0])throw l[1];return l[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(a,"next",{value:u(0)}),i(a,"throw",{value:u(1)}),i(a,"return",{value:u(2)}),"function"==typeof Symbol&&i(a,Symbol.iterator,{value:function(){return this}}),a;function u(i){return function(u){var c=[i,u];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(l=2&c[0]?r.return:c[0]?r.throw||((l=r.return)&&l.call(r),0):r.next)&&!(l=l.call(r,c[1])).done)return l;switch(r=0,l&&(c=[2&c[0],l.value]),c[0]){case 0:case 1:l=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,r=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!(l=(l=o.trys).length>0&&l[l.length-1])&&(6===c[0]||2===c[0])){o=0;continue}if(3===c[0]&&(!l||c[1]>l[0]&&c[1]<l[3])){o.label=c[1];break}if(6===c[0]&&o.label<l[1]){o.label=l[1],l=c;break}if(l&&o.label<l[2]){o.label=l[2],o.ops.push(c);break}l[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],r=0}finally{n=l=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function E(e){return"options"in e&&e.options?e.options:e}function F(e){return w((0,a.parseCollectionName)(null!=e?e:""),1)[0]||"main"}function A(e,t,n){var r,l,o,a,i,u=e.field?E(e.field):void 0,c=u?h(v({},u),{dataSourceKey:null!=(a=u.dataSourceKey)?a:n}):void 0,s=null!=(i=null==c?void 0:c.dataSourceKey)?i:n,f="function"==typeof e.loadChildren?function(n){return g(function(){var r;return S(this,function(l){switch(l.label){case 0:return[4,null==(r=e.loadChildren)?void 0:r.call(e,n)];case 1:return l.sent(),n.children=Array.isArray(n.children)?n.children.map(function(e){return A(e,t,s)}):void 0,[2]}})})()}:void 0;return{key:e.key,value:"string"==typeof(l=null!=(r=e.value)?r:e.key)?l:String(null!=l?l:""),label:(o=e.label,"string"==typeof o?t(o,{ns:["workflow","workflow-aggregate","client"]}):o),disabled:!!e.disabled,isLeaf:!!e.isLeaf,field:c,loadChildren:f,children:Array.isArray(e.children)?e.children.map(function(e){return A(e,t,s)}):void 0}}function C(e){var t=e.label,n=e.value,r=e.children;return{key:n,value:n,label:t,children:r,disabled:!r.length}}function k(e){return g(function(){var t;return S(this,function(n){switch(n.label){case 0:if(!(!(null==(t=e.children)?void 0:t.length)&&!e.isLeaf&&e.loadChildren))return[3,2];return[4,e.loadChildren(e)];case 1:n.sent(),n.label=2;case 2:return[2]}})})()}function I(e){var t,n,i,u,c,s,m,y,b,j,I,x,P,V,N,M,T,D,K,_=e.value,R=e.onChange,q=function(e,t){if(null==e)return{};var n,r,l,o={};if("u">typeof Reflect&&Reflect.ownKeys){for(l=0,n=Reflect.ownKeys(Object(e));l<n.length;l++)r=n[l],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}if(o=function(e,t){if(null==e)return{};var n,r,l={},o=Object.getOwnPropertyNames(e);for(r=0;r<o.length;r++)n=o[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n]);return l}(e,t),Object.getOwnPropertySymbols)for(l=0,n=Object.getOwnPropertySymbols(e);l<n.length;l++)r=n[l],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}(e,["value","onChange"]),U=(0,p.useFlowEngine)(),$=o.Form.useFormInstance(),W=(b=(0,p.useFlowEngine)(),j=(0,a.useNodeContext)(),I=(0,a.useCurrentWorkflowContext)(),x=(0,a.useAvailableUpstreams)(j),P=b.context.app.pm.get("workflow")||b.context.app.pm.get("@nocobase/plugin-workflow"),V=function(e,t){return b.context.t(e,t)},N={types:[d],appends:null,depth:4},M=[],x.forEach(function(e){var t,n,r,l=null==P||null==(t=P.instructions)?void 0:t.get(e.type),o=null==l||null==(n=l.useVariables)?void 0:n.call(l,e,N);o&&M.push(A(o,V,F(null==(r=e.config)?void 0:r.collection)))}),K=Array.isArray(D=null==(T=(null==I?void 0:I.type)?null==P||null==(m=P.triggers)?void 0:m.get(I.type):void 0)||null==(y=T.useVariables)?void 0:y.call(T,null==I?void 0:I.config,N))?D.filter(Boolean).map(function(e){var t;return A(e,V,F(null==I||null==(t=I.config)?void 0:t.collection))}):[],[C({label:V("Node result",{ns:"workflow"}),value:"$jobsMapByNodeKey",children:M}),C({label:V("Trigger variables",{ns:"workflow"}),value:"$context",children:K})]),G=W.map(function(e){var t,n;return"".concat(e.value,":").concat(null!=(t=null==(n=e.children)?void 0:n.map(function(e){return e.value}).join(","))?t:"")}).join("|"),B=w((0,r.useState)(W),2),L=B[0],X=B[1],z=(u=(i=null!=(t=_)?t:{}).associatedKey,c=i.name,(s=(void 0===u?"":u).match(/^{{(.*)}}$/))&&c?((function(e){if(Array.isArray(e))return f(e)})(n=s[1].trim().split(".").slice(0,-1))||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||function(e){if(e){if("string"==typeof e)return f(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return f(e,void 0)}}(n)||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([c]).filter(Boolean):[]),H=z.join(".");return(0,r.useEffect)(function(){X(W)},[G]),(0,r.useEffect)(function(){var e=!1;return g(function(){var t,n,r,l,o,a,i,u,c;return S(this,function(s){switch(s.label){case 0:if(!z.length||!L.length)return[2];t=L,r=!0,l=!1,o=void 0,s.label=1;case 1:s.trys.push([1,6,7,8]),a=function(){var e,r;return S(this,function(l){switch(l.label){case 0:if(e=u.value,!(n=t.find(function(t){return t.value===e})))return[2,"break"];return[4,k(n)];case 1:return l.sent(),t=null!=(r=n.children)?r:[],[2]}})},i=z[Symbol.iterator](),s.label=2;case 2:if(r=(u=i.next()).done)return[3,5];return[5,function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(a())];case 3:if("break"===s.sent())return[3,5];s.label=4;case 4:return r=!0,[3,2];case 5:return[3,8];case 6:return c=s.sent(),l=!0,o=c,[3,8];case 7:try{r||null==i.return||i.return()}finally{if(l)throw o}return[7];case 8:return e||X(O(L)),[2]}})})(),function(){e=!0}},[H,L.length]),l().createElement(o.Cascader,h(v({},q),{value:z,options:L,changeOnSelect:!0,loadData:function(e){return g(function(){var t;return S(this,function(n){switch(n.label){case 0:if(!(t=e[e.length-1]))return[2];return[4,k(t)];case 1:return n.sent(),X(O(L)),[2]}})})()},onChange:function(e,t){if(!(null==e?void 0:e.length)){$.setFieldValue(["config","collection"],null),null==R||R({});return}var n,r=t[t.length-1],l=null==r?void 0:r.field;if(l&&d(l)&&l.collectionName&&l.target&&l.name){var o,i,u,c,s,f,m,p,y,b=null!=(n=l.dataSourceKey)?n:"main",g=(0,a.joinCollectionName)(b,l.collectionName),v=null!=(p=null==(y=((f=s=null!=(i=null!=(u=null==(o=(0,a.getCollection)(U.context.dataSourceManager,g))||null==(c=o.getFields)?void 0:c.call(o))?u:null==o?void 0:o.fields)?i:[],null!=(m=Map)&&"u">typeof Symbol&&m[Symbol.hasInstance]?!!m[Symbol.hasInstance](f):f instanceof m)?Array.from(s.values()):s).map(E).find(function(e){return e.primaryKey}))?void 0:y.name)?p:"id";$.setFieldValue(["config","collection"],(0,a.joinCollectionName)(b,l.target)),null==R||R({name:l.name,associatedKey:"{{".concat(e.slice(0,-1).join("."),".").concat(v,"}}"),associatedCollection:g})}}}))}function x(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 P(e){var t=e.collection,n=(0,s.kj)();return t?l().createElement(o.Form.Item,{name:["config","params","field"],label:n("Field to aggregate"),rules:[{required:!0}]},l().createElement(a.FieldsSelect,{collection:t,filter:m})):null}function V(){var e=(0,s.kj)(),t=o.Form.useWatch(["config","collection"]),n=o.Form.useWatch(["config","aggregator"]);return t?l().createElement(l().Fragment,null,"count"===n?l().createElement(o.Form.Item,{name:["config","params","distinct"],valuePropName:"checked"},l().createElement(o.Checkbox,null,e("Distinct"))):null,l().createElement(o.Form.Item,{name:["config","params","filter"],label:e("Filter")},l().createElement(a.FilterDynamicComponent,{collection:t}))):null}function N(){var e=(0,s.kj)(),t=o.Form.useFormInstance(),n=o.Form.useWatch(["config","associated"]),u=o.Form.useWatch(["config","collection"]),c=[{label:e("Data of collection"),value:!1},{label:e("Data of associated collection"),value:!0}];return(0,r.useEffect)(function(){void 0===t.getFieldValue(["config","aggregator"])&&t.setFieldValue(["config","aggregator"],"count"),void 0===t.getFieldValue(["config","associated"])&&t.setFieldValue(["config","associated"],!1),void 0===t.getFieldValue(["config","precision"])&&t.setFieldValue(["config","precision"],2)},[t]),l().createElement(l().Fragment,null,l().createElement(o.Form.Item,{name:["config","aggregator"],label:e("Aggregator function"),rules:[{required:!0}]},l().createElement(o.Radio.Group,{options:function(e){if(Array.isArray(e))return x(e)}(i)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(i)||function(e){if(e){if("string"==typeof e)return x(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return x(e,void 0)}}(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.")}()})),l().createElement(o.Form.Item,{name:["config","associated"],label:e("Target type"),rules:[{required:!0}]},l().createElement(o.Radio.Group,{options:c,onChange:function(){t.setFieldValue(["config","collection"],null),t.setFieldValue(["config","association"],null),t.setFieldValue(["config","params","field"],null),t.setFieldValue(["config","params","filter"],null)}})),l().createElement(o.Row,{gutter:24},l().createElement(o.Col,{span:12},n?l().createElement(o.Form.Item,{name:["config","association"],label:e("Data of associated collection"),rules:[{required:!0}]},l().createElement(I,null)):l().createElement(o.Form.Item,{name:["config","collection"],label:e("Data of collection"),rules:[{required:!0}]},l().createElement(a.CollectionCascader,{onChange:function(){t.setFieldValue(["config","params","field"],null),t.setFieldValue(["config","params","filter"],null)}}))),l().createElement(o.Col,{span:12},l().createElement(P,{collection:u}))),l().createElement(V,null),l().createElement(o.Form.Item,{name:["config","precision"],label:e("Result precision"),extra:e("Number of decimal places for query result.")},l().createElement(o.InputNumber,{min:0,max:14,step:1,precision:0,className:"auto-width"})))}}}]);
@@ -1,10 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- "use strict";(self.webpackChunk_nocobase_plugin_workflow_aggregate_client_v2=self.webpackChunk_nocobase_plugin_workflow_aggregate_client_v2||[]).push([["604"],{7:function(e,t,n){n.d(t,{AggregateFieldset:function(){return N}});var r=n(155),l=n.n(r),o=n(59),a=n(197),i=[{label:"COUNT",value:"count"},{label:"SUM",value:"sum"},{label:"AVG",value:"avg"},{label:"MIN",value:"min"},{label:"MAX",value:"max"}],u=["hasMany","belongsToMany"],c=["belongsTo","hasOne","hasMany","belongsToMany"],s=n(488);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 d(e){return u.includes(e.type)}function m(e){return!!(!e.hidden&&e.interface&&!c.includes(e.type))}var p=n(694);function y(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 b(e,t,n,r,l,o,a){try{var i=e[o](a),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,l)}function g(e){return function(){var t=this,n=arguments;return new Promise(function(r,l){var o=e.apply(t,n);function a(e){b(o,r,l,a,i,"next",e)}function i(e){b(o,r,l,a,i,"throw",e)}a(void 0)})}}function v(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 h(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function w(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,l=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=l){var o=[],a=!0,i=!1;try{for(l=l.call(e);!(a=(n=l.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==l.return||l.return()}finally{if(i)throw r}}return o}}(e,t)||j(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e){return function(e){if(Array.isArray(e))return y(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||j(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function j(e,t){if(e){if("string"==typeof e)return y(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 y(e,t)}}function S(e,t){var n,r,l,o={label:0,sent:function(){if(1&l[0])throw l[1];return l[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(a,"next",{value:u(0)}),i(a,"throw",{value:u(1)}),i(a,"return",{value:u(2)}),"function"==typeof Symbol&&i(a,Symbol.iterator,{value:function(){return this}}),a;function u(i){return function(u){var c=[i,u];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(l=2&c[0]?r.return:c[0]?r.throw||((l=r.return)&&l.call(r),0):r.next)&&!(l=l.call(r,c[1])).done)return l;switch(r=0,l&&(c=[2&c[0],l.value]),c[0]){case 0:case 1:l=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,r=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!(l=(l=o.trys).length>0&&l[l.length-1])&&(6===c[0]||2===c[0])){o=0;continue}if(3===c[0]&&(!l||c[1]>l[0]&&c[1]<l[3])){o.label=c[1];break}if(6===c[0]&&o.label<l[1]){o.label=l[1],l=c;break}if(l&&o.label<l[2]){o.label=l[2],o.ops.push(c);break}l[2]&&o.ops.pop(),o.trys.pop();continue}c=t.call(e,o)}catch(e){c=[6,e],r=0}finally{n=l=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function E(e){return"options"in e&&e.options?e.options:e}function F(e){return w((0,a.parseCollectionName)(null!=e?e:""),1)[0]||"main"}function A(e,t,n){var r,l,o,a,i,u=e.field?E(e.field):void 0,c=u?h(v({},u),{dataSourceKey:null!=(a=u.dataSourceKey)?a:n}):void 0,s=null!=(i=null==c?void 0:c.dataSourceKey)?i:n,f="function"==typeof e.loadChildren?function(n){return g(function(){var r;return S(this,function(l){switch(l.label){case 0:return[4,null==(r=e.loadChildren)?void 0:r.call(e,n)];case 1:return l.sent(),n.children=Array.isArray(n.children)?n.children.map(function(e){return A(e,t,s)}):void 0,[2]}})})()}:void 0;return{key:e.key,value:"string"==typeof(l=null!=(r=e.value)?r:e.key)?l:String(null!=l?l:""),label:(o=e.label,"string"==typeof o?t(o,{ns:["workflow","workflow-aggregate","client"]}):o),disabled:!!e.disabled,isLeaf:!!e.isLeaf,field:c,loadChildren:f,children:Array.isArray(e.children)?e.children.map(function(e){return A(e,t,s)}):void 0}}function C(e){var t=e.label,n=e.value,r=e.children;return{key:n,value:n,label:t,children:r,disabled:!r.length}}function k(e){return g(function(){var t;return S(this,function(n){switch(n.label){case 0:if(!(!(null==(t=e.children)?void 0:t.length)&&!e.isLeaf&&e.loadChildren))return[3,2];return[4,e.loadChildren(e)];case 1:n.sent(),n.label=2;case 2:return[2]}})})()}function I(e){var t,n,i,u,c,s,m,y,b,j,I,x,P,V,N,M,T,_,D,K=e.value,R=e.onChange,q=function(e,t){if(null==e)return{};var n,r,l,o={};if("u">typeof Reflect&&Reflect.ownKeys){for(l=0,n=Reflect.ownKeys(Object(e));l<n.length;l++)r=n[l],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}if(o=function(e,t){if(null==e)return{};var n,r,l={},o=Object.getOwnPropertyNames(e);for(r=0;r<o.length;r++)n=o[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n]);return l}(e,t),Object.getOwnPropertySymbols)for(l=0,n=Object.getOwnPropertySymbols(e);l<n.length;l++)r=n[l],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}(e,["value","onChange"]),U=(0,p.useFlowEngine)(),$=o.Form.useFormInstance(),W=(b=(0,p.useFlowEngine)(),j=(0,a.useNodeContext)(),I=(0,a.useCurrentWorkflowContext)(),x=(0,a.useAvailableUpstreams)(j),P=b.context.app.pm.get("workflow")||b.context.app.pm.get("@nocobase/plugin-workflow"),V=function(e,t){return b.context.t(e,t)},N={types:[d],appends:null,depth:4},M=[],x.forEach(function(e){var t,n,r,l=null==P||null==(t=P.instructions)?void 0:t.get(e.type),o=null==l||null==(n=l.useVariables)?void 0:n.call(l,e,N);o&&M.push(A(o,V,F(null==(r=e.config)?void 0:r.collection)))}),D=Array.isArray(_=null==(T=(null==I?void 0:I.type)?null==P||null==(m=P.triggers)?void 0:m.get(I.type):void 0)||null==(y=T.useVariables)?void 0:y.call(T,null==I?void 0:I.config,N))?_.filter(Boolean).map(function(e){var t;return A(e,V,F(null==I||null==(t=I.config)?void 0:t.collection))}):[],[C({label:V("Node result",{ns:"workflow"}),value:"$jobsMapByNodeKey",children:M}),C({label:V("Trigger variables",{ns:"workflow"}),value:"$context",children:D})]),G=W.map(function(e){var t,n;return"".concat(e.value,":").concat(null!=(t=null==(n=e.children)?void 0:n.map(function(e){return e.value}).join(","))?t:"")}).join("|"),B=w((0,r.useState)(W),2),L=B[0],X=B[1],z=(u=(i=null!=(t=K)?t:{}).associatedKey,c=i.name,(s=(void 0===u?"":u).match(/^{{(.*)}}$/))&&c?((function(e){if(Array.isArray(e))return f(e)})(n=s[1].trim().split(".").slice(0,-1))||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||function(e){if(e){if("string"==typeof e)return f(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return f(e,void 0)}}(n)||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([c]).filter(Boolean):[]),H=z.join(".");return(0,r.useEffect)(function(){X(W)},[G]),(0,r.useEffect)(function(){var e=!1;return g(function(){var t,n,r,l,o,a,i,u,c;return S(this,function(s){switch(s.label){case 0:if(!z.length||!L.length)return[2];t=L,r=!0,l=!1,o=void 0,s.label=1;case 1:s.trys.push([1,6,7,8]),a=function(){var e,r;return S(this,function(l){switch(l.label){case 0:if(e=u.value,!(n=t.find(function(t){return t.value===e})))return[2,"break"];return[4,k(n)];case 1:return l.sent(),t=null!=(r=n.children)?r:[],[2]}})},i=z[Symbol.iterator](),s.label=2;case 2:if(r=(u=i.next()).done)return[3,5];return[5,function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(a())];case 3:if("break"===s.sent())return[3,5];s.label=4;case 4:return r=!0,[3,2];case 5:return[3,8];case 6:return c=s.sent(),l=!0,o=c,[3,8];case 7:try{r||null==i.return||i.return()}finally{if(l)throw o}return[7];case 8:return e||X(O(L)),[2]}})})(),function(){e=!0}},[H,L.length]),l().createElement(o.Cascader,h(v({},q),{value:z,options:L,changeOnSelect:!0,loadData:function(e){return g(function(){var t;return S(this,function(n){switch(n.label){case 0:if(!(t=e[e.length-1]))return[2];return[4,k(t)];case 1:return n.sent(),X(O(L)),[2]}})})()},onChange:function(e,t){if(!(null==e?void 0:e.length)){$.setFieldValue(["config","collection"],null),null==R||R({});return}var n,r=t[t.length-1],l=null==r?void 0:r.field;if(l&&d(l)&&l.collectionName&&l.target&&l.name){var o,i,u,c,s,f,m,p,y,b=null!=(n=l.dataSourceKey)?n:"main",g=(0,a.joinCollectionName)(b,l.collectionName),v=null!=(p=null==(y=((f=s=null!=(i=null!=(u=null==(o=(0,a.getCollection)(U.context.dataSourceManager,g))||null==(c=o.getFields)?void 0:c.call(o))?u:null==o?void 0:o.fields)?i:[],null!=(m=Map)&&"u">typeof Symbol&&m[Symbol.hasInstance]?!!m[Symbol.hasInstance](f):f instanceof m)?Array.from(s.values()):s).map(E).find(function(e){return e.primaryKey}))?void 0:y.name)?p:"id";$.setFieldValue(["config","collection"],(0,a.joinCollectionName)(b,l.target)),null==R||R({name:l.name,associatedKey:"{{".concat(e.slice(0,-1).join("."),".").concat(v,"}}"),associatedCollection:g})}}}))}function x(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 P(e){var t=e.collection,n=(0,s.kj)();return t?l().createElement(o.Form.Item,{name:["config","params","field"],label:n("Field to aggregate"),rules:[{required:!0}]},l().createElement(a.FieldsSelect,{collection:t,filter:m})):null}function V(){var e=(0,s.kj)(),t=o.Form.useWatch(["config","collection"]),n=o.Form.useWatch(["config","aggregator"]);return t?l().createElement(l().Fragment,null,"count"===n?l().createElement(o.Form.Item,{name:["config","params","distinct"],valuePropName:"checked"},l().createElement(o.Checkbox,null,e("Distinct"))):null,l().createElement(o.Form.Item,{name:["config","params","filter"],label:e("Filter")},l().createElement(a.FilterDynamicComponent,{collection:t}))):null}function N(){var e=(0,s.kj)(),t=o.Form.useFormInstance(),n=o.Form.useWatch(["config","associated"]),u=o.Form.useWatch(["config","collection"]),c=[{label:e("Data of collection"),value:!1},{label:e("Data of associated collection"),value:!0}];return(0,r.useEffect)(function(){void 0===t.getFieldValue(["config","aggregator"])&&t.setFieldValue(["config","aggregator"],"count"),void 0===t.getFieldValue(["config","associated"])&&t.setFieldValue(["config","associated"],!1),void 0===t.getFieldValue(["config","precision"])&&t.setFieldValue(["config","precision"],2)},[t]),l().createElement(l().Fragment,null,l().createElement(o.Form.Item,{name:["config","aggregator"],label:e("Aggregator function"),rules:[{required:!0}]},l().createElement(o.Radio.Group,{options:function(e){if(Array.isArray(e))return x(e)}(i)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(i)||function(e){if(e){if("string"==typeof e)return x(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return x(e,void 0)}}(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.")}()})),l().createElement(o.Form.Item,{name:["config","associated"],label:e("Target type"),rules:[{required:!0}]},l().createElement(o.Radio.Group,{options:c,onChange:function(){t.setFieldValue(["config","collection"],null),t.setFieldValue(["config","association"],null),t.setFieldValue(["config","params","field"],null),t.setFieldValue(["config","params","filter"],null)}})),l().createElement(o.Row,{gutter:24},l().createElement(o.Col,{span:12},n?l().createElement(o.Form.Item,{name:["config","association"],label:e("Data of associated collection"),rules:[{required:!0}]},l().createElement(I,null)):l().createElement(o.Form.Item,{name:["config","collection"],label:e("Data of collection"),rules:[{required:!0}]},l().createElement(a.CollectionCascader,{onChange:function(){t.setFieldValue(["config","params","field"],null),t.setFieldValue(["config","params","filter"],null)}}))),l().createElement(o.Col,{span:12},l().createElement(P,{collection:u}))),l().createElement(V,null),l().createElement(o.Form.Item,{name:["config","precision"],label:e("Result precision"),extra:e("Number of decimal places for query result.")},l().createElement(o.InputNumber,{min:0,max:14,step:1,precision:0,className:"auto-width"})))}}}]);