@nocobase/plugin-workflow-aggregate 1.5.0-beta.1 → 1.6.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- (function(t,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("@formily/react"),require("antd"),require("react"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","@formily/react","antd","react","@nocobase/plugin-workflow/client","react-i18next"],e):(t=typeof globalThis!="undefined"?globalThis:t||self,e(t["@nocobase/plugin-workflow-aggregate"]={},t["@nocobase/client"],t.jsxRuntime,t["@formily/react"],t.antd,t.react,t["@nocobase/plugin-workflow"],t["react-i18next"]))})(this,function(t,e,n,r,w,h,s,b){"use strict";var J=Object.defineProperty,W=Object.defineProperties;var Y=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable;var D=(t,e,n)=>e in t?J(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,V=(t,e)=>{for(var n in e||(e={}))A.call(e,n)&&D(t,n,e[n]);if(T)for(var n of T(e))N.call(e,n)&&D(t,n,e[n]);return t},$=(t,e)=>W(t,Y(e));var B=(t,e)=>{var n={};for(var r in t)A.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&T)for(var r of T(t))e.indexOf(r)<0&&N.call(t,r)&&(n[r]=t[r]);return n};var g=(t,e,n)=>(D(t,typeof e!="symbol"?e+"":e,n),n);var C=(t,e,n)=>new Promise((r,w)=>{var h=i=>{try{b(n.next(i))}catch(v){w(v)}},s=i=>{try{b(n.throw(i))}catch(v){w(v)}},b=i=>i.done?r(i.value):Promise.resolve(i.value).then(h,s);b((n=n.apply(t,e)).next())});const i="workflow-aggregate";function v(l,c={}){const{t:o}=G(c);return o(l)}function G(l){return b.useTranslation(i,l)}function K(l){return["hasMany","belongsToMany"].includes(l.type)}function P(){const l=e.useCompile();return[s.nodesOptions,s.triggerOptions].map(c=>{var d;const o=(d=c.useOptions({types:[K],appends:null,depth:4}))==null?void 0:d.filter(Boolean);return{label:l(c.label),value:c.value,key:c.value,children:l(o),disabled:o&&!o.length}})}function R(d){var u=d,{value:l,onChange:c}=u,o=B(u,["value","onChange"]);const{setValuesIn:x}=r.useForm(),{getCollection:k}=e.useCollectionManager_deprecated(),M=P(),[F,q]=h.useState(M),{associatedKey:_="",name:z}=l!=null?l:{};let S=[];const O=_.match(/^{{(.*)}}$/);O&&(S=[...O[1].trim().split(".").slice(0,-1),z]);const U=m=>C(this,null,function*(){var p;const a=m[m.length-1];!((p=a.children)!=null&&p.length)&&!a.isLeaf&&a.loadChildren&&(yield a.loadChildren(a),q(f=>[...f]))});h.useEffect(()=>{C(this,null,function*(){var p;if(!S||F.length<=1)return;let a=null;for(let f=0;f<S.length;f++){const I=S[f];try{f===0?a=F.find(y=>y.value===I):(a.loadChildren&&!((p=a.children)!=null&&p.length)&&(yield a.loadChildren(a)),a=a.children.find(y=>y.value===I))}catch(y){console.error(y)}}q([...F])})},[l,F.length]);const Q=h.useCallback((m,a)=>{if(!(m!=null&&m.length)){x("collection",null),c({});return}const{field:p}=a.pop();if(!p||!["hasMany","belongsToMany"].includes(p.type))return;const{collectionName:f,target:I,name:y,dataSourceKey:j}=p,X=k(f,j).fields.find(H=>H.primaryKey);x("collection",e.joinCollectionName(j,I)),c({name:y,associatedKey:`{{${m.slice(0,-1).join(".")}.${X.name}}}`,associatedCollection:e.joinCollectionName(j,f)})},[c]);return n.jsx(w.Cascader,$(V({},o),{value:S,options:F,changeOnSelect:!0,onChange:Q,loadData:U}))}class E extends s.Instruction{constructor(){super(...arguments);g(this,"title",`{{t("Aggregate", { ns: "${i}" })}}`);g(this,"type","aggregate");g(this,"group","collection");g(this,"description",`{{t("Counting, summing, finding maximum, minimum, and average values for multiple records of a collection or associated data of a record.", { ns: "${i}" })}}`);g(this,"fieldset",{aggregator:{type:"string",title:`{{t("Aggregator function", { ns: "${i}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:"COUNT",value:"count"},{label:"SUM",value:"sum"},{label:"AVG",value:"avg"},{label:"MIN",value:"min"},{label:"MAX",value:"max"}],required:!0,default:"count"},associated:{type:"boolean",title:`{{t("Target type", { ns: "${i}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Data of collection", { ns: "${i}" })}}`,value:!1},{label:`{{t("Data of associated collection", { ns: "${i}" })}}`,value:!0}],required:!0,default:!1,"x-reactions":[{target:"collection",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"association",effects:["onFieldValueChange"],fulfill:{state:{value:null}}}]},collectionField:{type:"void","x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{target:{type:"void","x-component":"Grid.Col",properties:{collection:{type:"string",required:!0,"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader","x-component-props":{dataSourceFilter(o){return o.key==="main"||o.options.isDBInstance}},title:`{{t("Data of collection", { ns: "${i}" })}}`,"x-reactions":[{dependencies:["associated"],fulfill:{state:{display:'{{$deps[0] ? "hidden" : "visible"}}'}}},{target:"params.field",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:null}}}]},association:{type:"object",title:`{{t("Data of associated collection", { ns: "${i}" })}}`,"x-decorator":"FormItem","x-component":"AssociatedConfig","x-component-props":{changeOnSelect:!0},"x-reactions":[{dependencies:["associated"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}],required:!0}}},field:{type:"void","x-component":"Grid.Col",properties:{"params.field":{type:"string",title:`{{t("Field to aggregate", { ns: "${i}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{filter(o){return!o.hidden&&o.interface&&!["belongsTo","hasOne","hasMany","belongsToMany"].includes(o.type)}},required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}}}}},params:{type:"object",properties:{distinct:{type:"boolean",title:`{{t("Distinct", { ns: "${i}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox","x-reactions":[{dependencies:["collection","aggregator"],fulfill:{state:{visible:'{{!!$deps[0] && ["count"].includes($deps[1])}}'}}}]},filter:{type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:o}=r.useForm(),[d,u]=e.parseCollectionName(o==null?void 0:o.collection);return{options:e.useCollectionFilterOptions(u,d),className:e.css`
11
- position: relative;
12
- width: 100%;
13
- `}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}});g(this,"scope",{useCollectionDataSource:e.useCollectionDataSource});g(this,"components",{SchemaComponentContext:e.SchemaComponentContext,FilterDynamicComponent:s.FilterDynamicComponent,FieldsSelect:s.FieldsSelect,ValueBlock:s.ValueBlock,AssociatedConfig:R})}useVariables({key:o,title:d},{types:u,fieldNames:x=s.defaultFieldNames}){return u&&!u.some(k=>k in s.BaseTypeSets||Object.values(s.BaseTypeSets).some(M=>M.has(k)))?null:{[x.value]:o,[x.label]:d}}useInitializers(o){var u;const d=v("Query result");return o.config.collection?{name:`#${o.id}`,type:"item",title:(u=o.title)!=null?u:`#${o.id}`,Component:s.ValueBlock.Initializer,node:o,resultTitle:d}:null}}class L extends e.Plugin{afterAdd(){return C(this,null,function*(){})}beforeLoad(){return C(this,null,function*(){})}load(){return C(this,null,function*(){this.app.pm.get("workflow").registerInstruction("aggregate",E)})}}t.default=L,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("antd"),require("react-i18next"),require("@formily/react"),require("@nocobase/client"),require("react"),require("@nocobase/plugin-workflow/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-aggregate",["antd","react-i18next","@formily/react","@nocobase/client","react","@nocobase/plugin-workflow/client"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-aggregate"]=t(require("antd"),require("react-i18next"),require("@formily/react"),require("@nocobase/client"),require("react"),require("@nocobase/plugin-workflow/client")):e["@nocobase/plugin-workflow-aggregate"]=t(e.antd,e["react-i18next"],e["@formily/react"],e["@nocobase/client"],e.react,e["@nocobase/plugin-workflow/client"])}(self,function(e,t,n,r,o,i){return function(){"use strict";var a={505:function(e){e.exports=n},772:function(e){e.exports=r},433:function(e){e.exports=i},721:function(t){t.exports=e},156:function(e){e.exports=o},238:function(e){e.exports=t}},l={};function c(e){var t=l[e];if(void 0!==t)return t.exports;var n=l[e]={exports:{}};return a[e](n,n.exports,c),n.exports}c.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(t,{a:t}),t},c.d=function(e,t){for(var n in t)c.o(t,n)&&!c.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var u={};c.r(u),c.d(u,{default:function(){return z}});var s=c("772"),f=c("505"),p=c("721"),d=c("156"),y=c.n(d),b=c("433"),m=c("238"),v="workflow-aggregate";function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function h(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).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 a(e){h(i,r,o,a,l,"next",e)}function l(e){h(i,r,o,a,l,"throw",e)}a(void 0)})}}function w(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function x(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function j(e){return(j=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function S(e,t){return(S=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function C(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(l)throw r}}return i}}(e,t)||P(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 k(e){return function(e){if(Array.isArray(e))return g(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||P(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 P(e,t){if(e){if("string"==typeof e)return g(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return g(e,t)}}function F(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(F=function(){return!!e})()}function T(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}function _(){var e,t,n=(e=["\n position: relative;\n width: 100%;\n "],!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return _=function(){return n},n}function I(e){return["hasMany","belongsToMany"].includes(e.type)}function q(e){var t,n,r,o,i=e.value,a=e.onChange,l=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],!(t.indexOf(n)>=0)&&(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++){if(n=i[r],!(t.indexOf(n)>=0))Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}}return o}(e,["value","onChange"]),c=(0,f.useForm)().setValuesIn,u=(0,s.useCollectionManager_deprecated)().getCollection;var m=(t=(0,s.useCompile)(),[b.nodesOptions,b.triggerOptions].map(function(e){var n,r=null===(n=e.useOptions({types:[I],appends:null,depth:4}))||void 0===n?void 0:n.filter(Boolean);return{label:t(e.label),value:e.value,key:e.value,children:t(r),disabled:r&&!r.length}})),v=C((0,d.useState)(m),2),g=v[0],h=v[1],w=null!=i?i:{},j=w.associatedKey,S=w.name,P=[],F=(void 0===j?"":j).match(/^{{(.*)}}$/);F&&(P=k(F[1].trim().split(".").slice(0,-1)).concat([S]));var _=(n=O(function(e){var t,n;return T(this,function(r){switch(r.label){case 0:if(!(!(null===(t=(n=e[e.length-1]).children)||void 0===t?void 0:t.length)&&!n.isLeaf&&n.loadChildren))return[3,2];return[4,n.loadChildren(n)];case 1:r.sent(),h(function(e){return k(e)}),r.label=2;case 2:return[2]}})}),function(e){return n.apply(this,arguments)});(0,d.useEffect)(function(){var e;(e=O(function(){var e,t,n;return T(this,function(r){switch(r.label){case 0:if(e=function(e){var n,r;return T(this,function(o){switch(o.label){case 0:n=P[e],o.label=1;case 1:if(o.trys.push([1,6,,7]),0!==e)return[3,2];return t=g.find(function(e){return e.value===n}),[3,5];case 2:if(!(t.loadChildren&&!(null===(r=t.children)||void 0===r?void 0:r.length)))return[3,4];return[4,t.loadChildren(t)];case 3:o.sent(),o.label=4;case 4:t=t.children.find(function(e){return e.value===n}),o.label=5;case 5:return[3,7];case 6:return console.error(o.sent()),[3,7];case 7:return[2]}})},!P||g.length<=1)return[2];t=null,n=0,r.label=1;case 1:if(!(n<P.length))return[3,4];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.")}(e(n))];case 2:r.sent(),r.label=3;case 3:return n++,[3,1];case 4:return h(k(g)),[2]}})}),function(){return e.apply(this,arguments)})()},[i,g.length]);var q=(0,d.useCallback)(function(e,t){if(!(null==e?void 0:e.length)){c("collection",null),a({});return}var n=t.pop().field;if(!!n&&!!["hasMany","belongsToMany"].includes(n.type)){var r=n.collectionName,o=n.target,i=n.name,l=n.dataSourceKey,f=u(r,l).fields.find(function(e){return e.primaryKey});c("collection",(0,s.joinCollectionName)(l,o)),a({name:i,associatedKey:"{{".concat(e.slice(0,-1).join("."),".").concat(f.name,"}}"),associatedCollection:(0,s.joinCollectionName)(l,r)})}},[a]);return y().createElement(p.Cascader,(r=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){x(e,t,n[t])})}return e}({},l),o=(o={value:P,options:g,changeOnSelect:!0,onChange:q,loadData:_},o),Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),r))}var D=function(e){var t,n,r;function o(){var e,t,n,r;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),t=this,n=o,r=arguments,n=j(n),x(e=function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(t,F()?Reflect.construct(n,r||[],j(t).constructor):n.apply(t,r)),"title",'{{t("Aggregate", { ns: "'.concat(v,'" })}}')),x(e,"type","aggregate"),x(e,"group","collection"),x(e,"description",'{{t("Counting, summing, finding maximum, minimum, and average values for multiple records of a collection or associated data of a record.", { ns: "'.concat(v,'" })}}')),x(e,"fieldset",{aggregator:{type:"string",title:'{{t("Aggregator function", { ns: "'.concat(v,'" })}}'),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:"COUNT",value:"count"},{label:"SUM",value:"sum"},{label:"AVG",value:"avg"},{label:"MIN",value:"min"},{label:"MAX",value:"max"}],required:!0,default:"count"},associated:{type:"boolean",title:'{{t("Target type", { ns: "'.concat(v,'" })}}'),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:'{{t("Data of collection", { ns: "'.concat(v,'" })}}'),value:!1},{label:'{{t("Data of associated collection", { ns: "'.concat(v,'" })}}'),value:!0}],required:!0,default:!1,"x-reactions":[{target:"collection",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"association",effects:["onFieldValueChange"],fulfill:{state:{value:null}}}]},collectionField:{type:"void","x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{target:{type:"void","x-component":"Grid.Col",properties:{collection:{type:"string",required:!0,"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader","x-component-props":{dataSourceFilter:function(e){return"main"===e.key||e.options.isDBInstance}},title:'{{t("Data of collection", { ns: "'.concat(v,'" })}}'),"x-reactions":[{dependencies:["associated"],fulfill:{state:{display:'{{$deps[0] ? "hidden" : "visible"}}'}}},{target:"params.field",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:null}}}]},association:{type:"object",title:'{{t("Data of associated collection", { ns: "'.concat(v,'" })}}'),"x-decorator":"FormItem","x-component":"AssociatedConfig","x-component-props":{changeOnSelect:!0},"x-reactions":[{dependencies:["associated"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}],required:!0}}},field:{type:"void","x-component":"Grid.Col",properties:{"params.field":{type:"string",title:'{{t("Field to aggregate", { ns: "'.concat(v,'" })}}'),"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{filter:function(e){return!e.hidden&&e.interface&&!["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}},required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}}}}},params:{type:"object",properties:{distinct:{type:"boolean",title:'{{t("Distinct", { ns: "'.concat(v,'" })}}'),"x-decorator":"FormItem","x-component":"Checkbox","x-reactions":[{dependencies:["collection","aggregator"],fulfill:{state:{visible:'{{!!$deps[0] && ["count"].includes($deps[1])}}'}}}]},filter:{type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":function(){var e=(0,f.useForm)().values,t=C((0,s.parseCollectionName)(null==e?void 0:e.collection),2),n=t[0],r=t[1];return{options:(0,s.useCollectionFilterOptions)(r,n),className:(0,s.css)(_())}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}}),x(e,"scope",{useCollectionDataSource:s.useCollectionDataSource}),x(e,"components",{SchemaComponentContext:s.SchemaComponentContext,FilterDynamicComponent:b.FilterDynamicComponent,FieldsSelect:b.FieldsSelect,ValueBlock:b.ValueBlock,AssociatedConfig:q}),e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&S(e,t)}(o,e),t=o,n=[{key:"useVariables",value:function(e,t){var n,r=e.key,o=e.title,i=t.types,a=t.fieldNames,l=void 0===a?b.defaultFieldNames:a;return i&&!i.some(function(e){return e in b.BaseTypeSets||Object.values(b.BaseTypeSets).some(function(t){return t.has(e)})})?null:(x(n={},l.value,r),x(n,l.label,o),n)}},{key:"useInitializers",value:function(e){var t,n=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,function(e){return(0,m.useTranslation)(v,e)}(t).t)(e)}("Query result");return e.config.collection?{name:"#".concat(e.id),type:"item",title:null!==(t=e.title)&&void 0!==t?t:"#".concat(e.id),Component:b.ValueBlock.Initializer,node:e,resultTitle:n}:null}}],w(t.prototype,n),o}(b.Instruction);function E(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function A(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){E(i,r,o,a,l,"next",e)}function l(e){E(i,r,o,a,l,"throw",e)}a(void 0)})}}function M(e,t,n){return(M=N()?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 B(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function R(e){return(R=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 G(e){var t="function"==typeof Map?new Map:void 0;return(G=function(e){var n;if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return M(e,arguments,R(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),V(r,e)})(e)}function N(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(N=function(){return!!e})()}function $(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}var z=function(e){var t,n,r;function o(){var e,t,n;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),e=this,t=o,n=arguments,t=R(t),function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,N()?Reflect.construct(t,n||[],R(e).constructor):t.apply(e,n))}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&V(e,t)}(o,e),t=o,n=[{key:"afterAdd",value:function(){return A(function(){return $(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return A(function(){return $(this,function(e){return[2]})})()}},{key:"load",value:function(){var e=this;return A(function(){return $(this,function(t){return e.app.pm.get("workflow").registerInstruction("aggregate",D),[2]})})()}}],B(t.prototype,n),o}(G(s.Plugin));return u}()});
@@ -11,13 +11,13 @@ module.exports = {
11
11
  "@formily/react": "2.3.0",
12
12
  "antd": "5.12.8",
13
13
  "react": "18.2.0",
14
- "@nocobase/client": "1.5.0-beta.1",
15
- "@nocobase/plugin-workflow": "1.5.0-beta.1",
14
+ "@nocobase/client": "1.6.0-alpha.1",
15
+ "@nocobase/plugin-workflow": "1.6.0-alpha.1",
16
16
  "react-i18next": "11.18.6",
17
- "@nocobase/data-source-manager": "1.5.0-beta.1",
18
- "@nocobase/database": "1.5.0-beta.1",
19
- "@nocobase/server": "1.5.0-beta.1",
20
- "@nocobase/plugin-workflow-test": "1.5.0-beta.1",
21
- "@nocobase/test": "1.5.0-beta.1",
22
- "@nocobase/utils": "1.5.0-beta.1"
17
+ "@nocobase/data-source-manager": "1.6.0-alpha.1",
18
+ "@nocobase/database": "1.6.0-alpha.1",
19
+ "@nocobase/server": "1.6.0-alpha.1",
20
+ "@nocobase/plugin-workflow-test": "1.6.0-alpha.1",
21
+ "@nocobase/test": "1.6.0-alpha.1",
22
+ "@nocobase/utils": "1.6.0-alpha.1"
23
23
  };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "工作流:聚合查询节点",
5
5
  "description": "Used to aggregate data against the database in workflow, such as: statistics, sum, average, etc.",
6
6
  "description.zh-CN": "可用于在工作流中对数据库进行聚合查询,如:统计数量、求和、平均值等。",
7
- "version": "1.5.0-beta.1",
7
+ "version": "1.6.0-alpha.1",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/workflow-aggregate",
@@ -21,7 +21,7 @@
21
21
  "@nocobase/server": "1.x",
22
22
  "@nocobase/test": "1.x"
23
23
  },
24
- "gitHead": "10c6f1f3d90e91f3aabfa80449c7ef062e90f6af",
24
+ "gitHead": "a4c91015e34ec0c9a427451b5fbdfb5fedc4f3d7",
25
25
  "keywords": [
26
26
  "Workflow"
27
27
  ]