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

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.
package/client-v2.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './dist/client-v2';
2
+ export { default } from './dist/client-v2';
package/client-v2.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/client-v2/index.js');
@@ -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,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"})))}}}]);
@@ -6,242 +6,8 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- import React from 'react';
10
- import { SchemaInitializerItemType, useCollectionDataSource } from '@nocobase/client';
11
- import { FilterDynamicComponent, Instruction } from '@nocobase/plugin-workflow/client';
12
- import { SubModelItem } from '@nocobase/flow-engine';
13
- declare function AssociatedConfig({ value, onChange, ...props }: {
14
- [x: string]: any;
15
- value: any;
16
- onChange: any;
17
- }): JSX.Element;
18
- export default class extends Instruction {
19
- title: string;
20
- type: string;
21
- group: string;
22
- description: string;
23
- icon: React.JSX.Element;
24
- fieldset: {
25
- aggregator: {
26
- type: string;
27
- title: string;
28
- 'x-decorator': string;
29
- 'x-component': string;
30
- enum: {
31
- label: string;
32
- value: string;
33
- }[];
34
- required: boolean;
35
- default: string;
36
- };
37
- associated: {
38
- type: string;
39
- title: string;
40
- 'x-decorator': string;
41
- 'x-component': string;
42
- enum: {
43
- label: string;
44
- value: boolean;
45
- }[];
46
- required: boolean;
47
- default: boolean;
48
- 'x-reactions': {
49
- target: string;
50
- effects: string[];
51
- fulfill: {
52
- state: {
53
- value: any;
54
- };
55
- };
56
- }[];
57
- };
58
- collectionField: {
59
- type: string;
60
- 'x-decorator': string;
61
- 'x-decorator-props': {
62
- value: {
63
- designable: boolean;
64
- };
65
- };
66
- 'x-component': string;
67
- properties: {
68
- row: {
69
- type: string;
70
- 'x-component': string;
71
- properties: {
72
- target: {
73
- type: string;
74
- 'x-component': string;
75
- properties: {
76
- collection: {
77
- type: string;
78
- required: boolean;
79
- 'x-decorator': string;
80
- 'x-component': string;
81
- 'x-component-props': {
82
- dataSourceFilter(datasource: any): any;
83
- };
84
- title: string;
85
- 'x-reactions': ({
86
- dependencies: string[];
87
- fulfill: {
88
- state: {
89
- display: string;
90
- value?: undefined;
91
- };
92
- };
93
- target?: undefined;
94
- effects?: undefined;
95
- } | {
96
- target: string;
97
- effects: string[];
98
- fulfill: {
99
- state: {
100
- value: any;
101
- display?: undefined;
102
- };
103
- };
104
- dependencies?: undefined;
105
- })[];
106
- };
107
- association: {
108
- type: string;
109
- title: string;
110
- 'x-decorator': string;
111
- 'x-component': string;
112
- 'x-component-props': {
113
- changeOnSelect: boolean;
114
- };
115
- 'x-reactions': {
116
- dependencies: string[];
117
- fulfill: {
118
- state: {
119
- visible: string;
120
- };
121
- };
122
- }[];
123
- required: boolean;
124
- };
125
- };
126
- };
127
- field: {
128
- type: string;
129
- 'x-component': string;
130
- properties: {
131
- 'params.field': {
132
- type: string;
133
- title: string;
134
- 'x-decorator': string;
135
- 'x-component': string;
136
- 'x-component-props': {
137
- filter(field: any): boolean;
138
- };
139
- required: boolean;
140
- 'x-reactions': {
141
- dependencies: string[];
142
- fulfill: {
143
- state: {
144
- visible: string;
145
- };
146
- };
147
- }[];
148
- };
149
- };
150
- };
151
- };
152
- };
153
- };
154
- };
155
- params: {
156
- type: string;
157
- properties: {
158
- distinct: {
159
- type: string;
160
- 'x-decorator': string;
161
- 'x-component': string;
162
- 'x-content': string;
163
- 'x-reactions': {
164
- dependencies: string[];
165
- fulfill: {
166
- state: {
167
- visible: string;
168
- };
169
- };
170
- }[];
171
- };
172
- filter: {
173
- type: string;
174
- title: string;
175
- 'x-decorator': string;
176
- 'x-component': string;
177
- 'x-use-component-props': () => {
178
- options: any[];
179
- className: string;
180
- };
181
- 'x-component-props': {
182
- dynamicComponent: string;
183
- };
184
- 'x-reactions': {
185
- dependencies: string[];
186
- fulfill: {
187
- state: {
188
- visible: string;
189
- };
190
- };
191
- }[];
192
- };
193
- };
194
- };
195
- precision: {
196
- type: string;
197
- title: string;
198
- description: string;
199
- 'x-decorator': string;
200
- 'x-component': string;
201
- 'x-component-props': {
202
- min: number;
203
- max: number;
204
- step: number;
205
- precision: number;
206
- className: string;
207
- };
208
- default: number;
209
- };
210
- };
211
- scope: {
212
- useCollectionDataSource: typeof useCollectionDataSource;
213
- };
214
- components: {
215
- SchemaComponentContext: React.Context<import("@nocobase/client").ISchemaComponentContext>;
216
- FilterDynamicComponent: typeof FilterDynamicComponent;
217
- FieldsSelect: React.MemoExoticComponent<import("@formily/react").ReactFC<Omit<any, "ref">>>;
218
- ValueBlock: (() => JSX.Element) & {
219
- Initializer: () => JSX.Element;
220
- Result: (props: any) => JSX.Element;
221
- Designer: () => JSX.Element;
222
- };
223
- AssociatedConfig: typeof AssociatedConfig;
224
- };
225
- useVariables({ key, title }: {
226
- key: any;
227
- title: any;
228
- }, { types, fieldNames }: {
229
- types: any;
230
- fieldNames?: {
231
- readonly label: "label";
232
- readonly value: "value";
233
- readonly children: "children";
234
- };
235
- }): {
236
- value: any;
237
- label: any;
238
- };
9
+ import type { SchemaInitializerItemType } from '@nocobase/client';
10
+ import AggregateInstructionV2 from '../client-v2/AggregateInstruction';
11
+ export default class AggregateInstruction extends AggregateInstructionV2 {
239
12
  useInitializers(node: any): SchemaInitializerItemType | null;
240
- /**
241
- * 2.0
242
- */
243
- getCreateModelMenuItem({ node }: {
244
- node: any;
245
- }): SubModelItem;
246
13
  }
247
- export {};
@@ -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/client"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/plugin-workflow/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-aggregate",["react-i18next","react","antd","@nocobase/client","@formily/react","@ant-design/icons","@nocobase/plugin-workflow/client"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-aggregate"]=t(require("react-i18next"),require("react"),require("antd"),require("@nocobase/client"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/plugin-workflow/client")):e["@nocobase/plugin-workflow-aggregate"]=t(e["react-i18next"],e.react,e.antd,e["@nocobase/client"],e["@formily/react"],e["@ant-design/icons"],e["@nocobase/plugin-workflow/client"])}(self,function(e,t,n,r,o,i,a){return function(){"use strict";var c={375:function(e){e.exports=i},230:function(e){e.exports=o},342:function(e){e.exports=r},990:function(e){e.exports=a},59:function(e){e.exports=n},155:function(e){e.exports=t},953:function(t){t.exports=e}},l={};function u(e){var t=l[e];if(void 0!==t)return t.exports;var n=l[e]={exports:{}};return c[e](n,n.exports,u),n.exports}u.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(t,{a:t}),t},u.d=function(e,t){for(var n in t)u.o(t,n)&&!u.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},u.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),u.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},u.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.g.importScripts&&(s=u.g.location+"");var s,f=u.g.document;if(!s&&f&&(f.currentScript&&"SCRIPT"===f.currentScript.tagName.toUpperCase()&&(s=f.currentScript.src),!s)){var p=f.getElementsByTagName("script");if(p.length)for(var d=p.length-1;d>-1&&(!s||!/^http(s?):/.test(s));)s=p[d--].src}if(!s)throw Error("Automatic publicPath is not supported in this browser");u.p=s.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var y={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var n=window.__webpack_public_path__||"";n&&("/"!==n.charAt(n.length-1)&&(n+="/"),e=n+"static/plugins/@nocobase/plugin-workflow-aggregate/dist/client/")}if(!e){var r=window.__nocobase_modern_client_prefix__||"v",o="/"+(r=String(r).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var i=window.location.pathname||"/",a=i.indexOf(o);e=a>=0?i.slice(0,a+1):"/"}e&&(e=e.replace(RegExp("/"+r+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-workflow-aggregate/dist/client/"}u.p=e}(),!function(){u.r(y),u.d(y,{default:function(){return D}});var e=u(342),t=u(230),n=u(59),r=u(155),o=u.n(r),i=u(375),a=u(990),c=u(953),l="workflow-aggregate";function s(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 f(e,t,n,r,o,i,a){try{var c=e[i](a),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(r,o)}function p(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){f(i,r,o,a,c,"next",e)}function c(e){f(i,r,o,a,c,"throw",e)}a(void 0)})}}function d(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function b(e){return(b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t){return(m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function g(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,c=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){c=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(c)throw r}}return i}}(e,t)||h(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 v(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||h(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 h(e,t){if(e){if("string"==typeof e)return s(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 s(e,t)}}function O(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(O=function(){return!!e})()}function w(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:l(0)}),c(a,"throw",{value:l(1)}),c(a,"return",{value:l(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function l(c){return function(l){var u=[c,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function j(){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 j=function(){return n},n}function x(e){return["hasMany","belongsToMany"].includes(e.type)}function S(i){var c,l,u,s=i.value,f=i.onChange,y=function(e,t){if(null==e)return{};var n,r,o,i={};if("u">typeof Reflect&&Reflect.ownKeys){for(o=0,n=Reflect.ownKeys(Object(e));o<n.length;o++)r=n[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r]);return i}if(i=function(e,t){if(null==e)return{};var n,r,o={},i=Object.getOwnPropertyNames(e);for(r=0;r<i.length;r++)n=i[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n]);return o}(e,t),Object.getOwnPropertySymbols)for(o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)r=n[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r]);return i}(i,["value","onChange"]),b=(0,t.useForm)().setValuesIn,m=(0,e.useCollectionManager_deprecated)().getCollection,h=(c=(0,e.useCompile)(),[a.nodesOptions,a.triggerOptions].map(function(e){var t,n=null==(t=e.useOptions({types:[x],appends:null,depth:4}))?void 0:t.filter(Boolean);return{label:c(e.label),value:e.value,key:e.value,children:c(n),disabled:n&&!n.length}})),O=g((0,r.useState)(h),2),j=O[0],S=O[1],P=null!=s?s:{},C=P.associatedKey,k=P.name,_=[],F=(void 0===C?"":C).match(/^{{(.*)}}$/);F&&(_=v(F[1].trim().split(".").slice(0,-1)).concat([k])),(0,r.useEffect)(function(){p(function(){var e,t,n;return w(this,function(r){switch(r.label){case 0:if(e=function(e){var n,r;return w(this,function(o){switch(o.label){case 0:n=_[e],o.label=1;case 1:if(o.trys.push([1,6,,7]),0!==e)return[3,2];return t=j.find(function(e){return e.value===n}),[3,5];case 2:if(!(t.loadChildren&&!(null==(r=t.children)?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]}})},!_||j.length<=1)return[2];t=null,n=0,r.label=1;case 1:if(!(n<_.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 S(v(j)),[2]}})})()},[s,j.length]);var I=(0,r.useCallback)(function(t,n){if(!(null==t?void 0:t.length)){b("collection",null),f({});return}var r=n.pop().field;if(r&&["hasMany","belongsToMany"].includes(r.type)){var o=r.collectionName,i=r.target,a=r.name,c=r.dataSourceKey,l=m(o,c).fields.find(function(e){return e.primaryKey});b("collection",(0,e.joinCollectionName)(c,i)),f({name:a,associatedKey:"{{".concat(t.slice(0,-1).join("."),".").concat(l.name,"}}"),associatedCollection:(0,e.joinCollectionName)(c,o)})}},[f]);return o().createElement(n.Cascader,(l=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){d(e,t,n[t])})}return e}({},y),u=u={value:_,options:j,changeOnSelect:!0,onChange:I,loadData:function(e){return p(function(){var t,n;return w(this,function(r){switch(r.label){case 0:if(!(!(null==(t=(n=e[e.length-1]).children)?void 0:t.length)&&!n.isLeaf&&n.loadChildren))return[3,2];return[4,n.loadChildren(n)];case 1:r.sent(),S(function(e){return v(e)}),r.label=2;case 2:return[2]}})})()}},Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(u)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(u)).forEach(function(e){Object.defineProperty(l,e,Object.getOwnPropertyDescriptor(u,e))}),l))}var P=function(n){var r;if("function"!=typeof n&&null!==n)throw TypeError("Super expression must either be null or a function");function u(){var n,r,c;if(!(this instanceof u))throw TypeError("Cannot call a class as a function");return r=u,c=arguments,r=b(r),d(n=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,O()?Reflect.construct(r,c||[],b(this).constructor):r.apply(this,c)),"title",'{{t("Aggregate", { ns: "'.concat(l,'" })}}')),d(n,"type","aggregate"),d(n,"group","collection"),d(n,"description",'{{t("Counting, summing, finding maximum, minimum, and average values for multiple records of a collection or associated data of a record.", { ns: "'.concat(l,'" })}}')),d(n,"icon",o().createElement(i.BarChartOutlined,{style:{}})),d(n,"fieldset",{aggregator:{type:"string",title:'{{t("Aggregator function", { ns: "'.concat(l,'" })}}'),"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(l,'" })}}'),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:'{{t("Data of collection", { ns: "'.concat(l,'" })}}'),value:!1},{label:'{{t("Data of associated collection", { ns: "'.concat(l,'" })}}'),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(l,'" })}}'),"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(l,'" })}}'),"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(l,'" })}}'),"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","x-decorator":"FormItem","x-component":"Checkbox","x-content":'{{t("Distinct", { ns: "'.concat(l,'" })}}'),"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 n=(0,t.useForm)().values,r=g((0,e.parseCollectionName)(null==n?void 0:n.collection),2),o=r[0],i=r[1];return{options:(0,e.useCollectionFilterOptions)(i,o),className:(0,e.css)(j())}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}},precision:{type:"number",title:'{{t("Result precision", { ns: "'.concat(l,'" })}}'),description:'{{t("Number of decimal places for query result.", { ns: "'.concat(l,'" })}}'),"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:0,max:14,step:1,precision:0,className:"auto-width"},default:2}}),d(n,"scope",{useCollectionDataSource:e.useCollectionDataSource}),d(n,"components",{SchemaComponentContext:e.SchemaComponentContext,FilterDynamicComponent:a.FilterDynamicComponent,FieldsSelect:a.FieldsSelect,ValueBlock:a.ValueBlock,AssociatedConfig:S}),n}return u.prototype=Object.create(n&&n.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),n&&m(u,n),r=[{key:"useVariables",value:function(e,t){var n,r=e.key,o=e.title,i=t.types,c=t.fieldNames,l=void 0===c?a.defaultFieldNames:c;return i&&!i.some(function(e){return e in a.BaseTypeSets||Object.values(a.BaseTypeSets).some(function(t){return t.has(e)})})?null:(d(n={},l.value,r),d(n,l.label,o),n)}},{key:"useInitializers",value:function(e){var t,n=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,(t=n,(0,c.useTranslation)(l,t)).t)(e)}("Query result");return e.config.collection?{name:"#".concat(e.id),type:"item",title:null!=(t=e.title)?t:"#".concat(e.id),Component:a.ValueBlock.Initializer,node:e,resultTitle:n}:null}},{key:"getCreateModelMenuItem",value:function(t){var n,r=t.node;return{key:"#".concat(r.id),label:null!=(n=r.title)?n:"#".concat(r.id),useModel:"NodeValueModel",createModelOptions:{use:"NodeValueModel",stepParams:{valueSettings:{init:{dataSource:"{{$jobsMapByNodeKey.".concat(r.key,"}}"),defaultValue:function(t){var n,r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.i18n.t(t,(n=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}({},o),r=r={ns:l},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n))}("Query result")}},cardSettings:{titleDescription:{title:'{{t("Aggregate", { ns: "'.concat(l,'" })}}')}}}}}}}],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)}}(u.prototype,r),u}(a.Instruction);function C(e,t,n,r,o,i,a){try{var c=e[i](a),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(r,o)}function k(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){C(i,r,o,a,c,"next",e)}function c(e){C(i,r,o,a,c,"throw",e)}a(void 0)})}}function _(e,t,n){return(_=E()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&I(o,n.prototype),o}).apply(null,arguments)}function F(e){return(F=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function I(e,t){return(I=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function T(e){var t="function"==typeof Map?new Map:void 0;return(T=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,F(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),I(n,e)})(e)}function E(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(E=function(){return!!e})()}function M(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:l(0)}),c(a,"throw",{value:l(1)}),c(a,"return",{value:l(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function l(c){return function(l){var u=[c,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var D=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=F(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,E()?Reflect.construct(e,t||[],F(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&I(n,e),t=[{key:"afterAdd",value:function(){return k(function(){return M(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return k(function(){return M(this,function(e){return[2]})})()}},{key:"load",value:function(){return k(function(){return M(this,function(e){return this.app.pm.get("workflow").registerInstruction("aggregate",P),[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}(T(e.Plugin))}(),y}()});
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}()});
@@ -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,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"})))}}}]);
@@ -0,0 +1,39 @@
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
+ import React from 'react';
10
+ import type { SubModelItem } from '@nocobase/flow-engine';
11
+ import { Instruction, type UseVariableOptions, type VariableOption } from '@nocobase/plugin-workflow/client-v2';
12
+ type AggregateNodeLike = {
13
+ id?: string | number;
14
+ key: string;
15
+ title?: string;
16
+ config?: {
17
+ collection?: string;
18
+ };
19
+ };
20
+ export default class AggregateInstruction extends Instruction {
21
+ title: string;
22
+ type: string;
23
+ group: string;
24
+ description: string;
25
+ icon: React.JSX.Element;
26
+ FieldsetLoader: () => Promise<{
27
+ default: typeof import("./components/AggregateFieldset").AggregateFieldset;
28
+ }>;
29
+ createDefaultConfig(): {
30
+ aggregator: string;
31
+ associated: boolean;
32
+ precision: number;
33
+ };
34
+ useVariables({ key, title }: AggregateNodeLike, { types, fieldNames }?: UseVariableOptions): VariableOption | null;
35
+ getCreateModelMenuItem({ node }: {
36
+ node: AggregateNodeLike;
37
+ }): SubModelItem | null;
38
+ }
39
+ export {};
@@ -0,0 +1,11 @@
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
+ import React from 'react';
10
+ export declare function AggregateFieldset(): React.JSX.Element;
11
+ export default AggregateFieldset;
@@ -0,0 +1,32 @@
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
+ import React from 'react';
10
+ import type { CascaderProps } from 'antd';
11
+ import { type CollectionTriggerField } from '@nocobase/plugin-workflow/client-v2';
12
+ import type { AggregateAssociationConfig } from '../types';
13
+ type FieldWithDataSource = CollectionTriggerField & {
14
+ collectionName?: string;
15
+ dataSourceKey?: string;
16
+ options?: FieldWithDataSource;
17
+ };
18
+ type AssociatedCascaderOption = {
19
+ key?: string;
20
+ value: string;
21
+ label?: React.ReactNode;
22
+ disabled?: boolean;
23
+ isLeaf?: boolean;
24
+ field?: FieldWithDataSource;
25
+ loadChildren?: (option: AssociatedCascaderOption) => Promise<void> | void;
26
+ children?: AssociatedCascaderOption[];
27
+ };
28
+ export declare function AssociatedConfig({ value, onChange, ...props }: Omit<CascaderProps<AssociatedCascaderOption, 'value', false>, 'loadData' | 'multiple' | 'onChange' | 'options' | 'value'> & {
29
+ value?: AggregateAssociationConfig | null;
30
+ onChange?: (value: AggregateAssociationConfig) => void;
31
+ }): React.JSX.Element;
32
+ export default AssociatedConfig;
@@ -0,0 +1,30 @@
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
+ export declare const AGGREGATORS: readonly [{
10
+ readonly label: "COUNT";
11
+ readonly value: "count";
12
+ }, {
13
+ readonly label: "SUM";
14
+ readonly value: "sum";
15
+ }, {
16
+ readonly label: "AVG";
17
+ readonly value: "avg";
18
+ }, {
19
+ readonly label: "MIN";
20
+ readonly value: "min";
21
+ }, {
22
+ readonly label: "MAX";
23
+ readonly value: "max";
24
+ }];
25
+ export declare const ASSOCIATED_TARGETS: {
26
+ readonly COLLECTION: false;
27
+ readonly ASSOCIATION: true;
28
+ };
29
+ export declare const ASSOCIATION_FIELD_TYPES: readonly ["hasMany", "belongsToMany"];
30
+ export declare const RELATION_FIELD_TYPES: readonly ["belongsTo", "hasOne", "hasMany", "belongsToMany"];
@@ -0,0 +1,11 @@
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
+ export { default } from './plugin';
10
+ export * from './plugin';
11
+ export { default as AggregateInstruction } from './AggregateInstruction';
@@ -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
+ !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}()});
@@ -0,0 +1,11 @@
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
+ export declare const NAMESPACE = "workflow-aggregate";
10
+ export declare function useT(): (key: string, options?: Record<string, unknown>) => string;
11
+ export declare function tExpr(key: string): string;
@@ -0,0 +1,12 @@
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
+ import { Application, Plugin } from '@nocobase/client-v2';
10
+ export default class PluginWorkflowAggregateClientV2 extends Plugin<unknown, Application> {
11
+ load(): Promise<void>;
12
+ }
@@ -0,0 +1,25 @@
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
+ export type AggregateConfig = {
10
+ aggregator?: string;
11
+ associated?: boolean;
12
+ collection?: string | null;
13
+ association?: AggregateAssociationConfig | null;
14
+ params?: {
15
+ field?: string | null;
16
+ distinct?: boolean;
17
+ filter?: Record<string, unknown> | null;
18
+ };
19
+ precision?: number;
20
+ };
21
+ export type AggregateAssociationConfig = {
22
+ name?: string;
23
+ associatedKey?: string;
24
+ associatedCollection?: string;
25
+ };
@@ -0,0 +1,13 @@
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
+ import type { CollectionTriggerField } from '@nocobase/plugin-workflow/client-v2';
10
+ import type { AggregateAssociationConfig } from './types';
11
+ export declare function matchToManyField(field: CollectionTriggerField): boolean;
12
+ export declare function isAggregateValueField(field: CollectionTriggerField): boolean;
13
+ export declare function getAssociatedPath(value?: AggregateAssociationConfig | null): string[];
@@ -8,19 +8,19 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@formily/react": "2.3.7",
12
- "antd": "5.24.2",
11
+ "@nocobase/client": "2.2.0-alpha.2",
12
+ "@nocobase/plugin-workflow": "2.2.0-alpha.2",
13
13
  "react": "18.2.0",
14
14
  "@ant-design/icons": "5.6.1",
15
- "@nocobase/client": "2.2.0-alpha.1",
16
- "@nocobase/plugin-workflow": "2.2.0-alpha.1",
17
- "@nocobase/flow-engine": "2.2.0-alpha.1",
15
+ "@nocobase/flow-engine": "2.2.0-alpha.2",
16
+ "@nocobase/client-v2": "2.2.0-alpha.2",
18
17
  "react-i18next": "11.18.6",
19
18
  "mathjs": "15.1.0",
20
- "@nocobase/data-source-manager": "2.2.0-alpha.1",
21
- "@nocobase/database": "2.2.0-alpha.1",
22
- "@nocobase/server": "2.2.0-alpha.1",
23
- "@nocobase/plugin-workflow-test": "2.2.0-alpha.1",
24
- "@nocobase/test": "2.2.0-alpha.1",
25
- "@nocobase/utils": "2.2.0-alpha.1"
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",
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-10T18:13:23.692Z"}
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"}
@@ -86,10 +86,11 @@ class AggregateInstruction_default extends import_plugin_workflow.Instruction {
86
86
  if (!options.dataType && aggregator === "avg") {
87
87
  options.dataType = import_database.DataTypes.DOUBLE;
88
88
  }
89
+ const transaction = processor.getScopeTransaction(node, dataSourceName) ?? this.workflow.useDataSourceTransaction(dataSourceName, processor.transaction);
89
90
  const result = await repo.aggregate({
90
91
  ...options,
91
92
  method: aggregators[aggregator],
92
- transaction: this.workflow.useDataSourceTransaction(dataSourceName, processor.transaction)
93
+ transaction
93
94
  });
94
95
  return {
95
96
  result: (0, import_mathjs.round)(
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.1",
9
+ "version": "2.2.0-alpha.2",
10
10
  "license": "Apache-2.0",
11
11
  "main": "./dist/server/index.js",
12
12
  "homepage": "https://docs.nocobase.com/handbook/workflow-aggregate",
@@ -20,13 +20,14 @@
20
20
  },
21
21
  "peerDependencies": {
22
22
  "@nocobase/client": "2.x",
23
+ "@nocobase/client-v2": "2.x",
23
24
  "@nocobase/database": "2.x",
24
25
  "@nocobase/plugin-workflow": "2.x",
25
26
  "@nocobase/server": "2.x",
26
27
  "@nocobase/test": "2.x",
27
28
  "mathjs": "^15.1.0"
28
29
  },
29
- "gitHead": "303663aba6c6eefa27e6a6435b4c0352074ec40f",
30
+ "gitHead": "9dd5224bb8f6c1ac12d766b9f175bdc29bddd845",
30
31
  "keywords": [
31
32
  "Workflow"
32
33
  ]