@nocobase/plugin-workflow 0.16.0-alpha.4 → 0.16.0-alpha.6
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/dist/client/index.js +70 -70
- package/dist/externalVersion.js +8 -8
- package/dist/locale/zh-CN.d.ts +1 -1
- package/dist/locale/zh-CN.js +1 -1
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/server/Plugin.js +14 -6
- package/dist/server/Processor.js +3 -1
- package/dist/server/instructions/condition.js +3 -1
- package/dist/server/triggers/schedule.js +31 -35
- package/package.json +2 -2
package/dist/client/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(k,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("react/jsx-runtime"),require("@ant-design/icons"),require("@nocobase/client"),require("react-i18next"),require("antd"),require("react"),require("lodash"),require("@formily/core"),require("@formily/react"),require("@nocobase/utils/client"),require("react-router-dom"),require("dayjs"),require("@formily/antd-v5"),require("@nocobase/evaluators/client")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@ant-design/icons","@nocobase/client","react-i18next","antd","react","lodash","@formily/core","@formily/react","@nocobase/utils/client","react-router-dom","dayjs","@formily/antd-v5","@nocobase/evaluators/client"],r):(k=typeof globalThis!="undefined"?globalThis:k||self,r(k["@nocobase/plugin-workflow"]={},k.jsxRuntime,k["@ant-design/icons"],k["@nocobase/client"],k["react-i18next"],k.antd,k.react,k.lodash,k["@formily/core"],k["@formily/react"],k["@nocobase/utils"],k["react-router-dom"],k.dayjs,k["@formily/antd-v5"],k["@nocobase/evaluators"]))})(this,function(k,r,O,l,R,b,y,be,oe,T,K,ue,zo,ve,je){"use strict";var Os=Object.defineProperty,Ts=Object.defineProperties;var $s=Object.getOwnPropertyDescriptors;var xo=Object.getOwnPropertySymbols;var en=Object.prototype.hasOwnProperty,on=Object.prototype.propertyIsEnumerable;var Lo=(k,r,O)=>r in k?Os(k,r,{enumerable:!0,configurable:!0,writable:!0,value:O}):k[r]=O,g=(k,r)=>{for(var O in r||(r={}))en.call(r,O)&&Lo(k,O,r[O]);if(xo)for(var O of xo(r))on.call(r,O)&&Lo(k,O,r[O]);return k},C=(k,r)=>Ts(k,$s(r));var tn=k=>typeof k=="symbol"?k:k+"",z=(k,r)=>{var O={};for(var l in k)en.call(k,l)&&r.indexOf(l)<0&&(O[l]=k[l]);if(k!=null&&xo)for(var l of xo(k))r.indexOf(l)<0&&on.call(k,l)&&(O[l]=k[l]);return O};var bo=(k,r,O)=>(Lo(k,typeof r!="symbol"?r+"":r,O),O);var H=(k,r,O)=>new Promise((l,R)=>{var b=oe=>{try{be(O.next(oe))}catch(T){R(T)}},y=oe=>{try{be(O.throw(oe))}catch(T){R(T)}},be=oe=>oe.done?l(oe.value):Promise.resolve(oe.value).then(b,y);be((O=O.apply(k,r)).next())});const u="workflow";function D(e,o={}){return l.i18n.t(e,C(g({},o),{ns:u}))}function vo(){return R.useTranslation(u)}const pe={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},Qe=[{value:pe.QUEUEING,label:`{{t("Queueing", { ns: "${u}" })}}`,color:"blue",icon:r.jsx(O.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${u}" })}}`},{value:pe.STARTED,label:`{{t("On going", { ns: "${u}" })}}`,color:"gold",icon:r.jsx(O.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${u}" })}}`},{value:pe.RESOLVED,label:`{{t("Resolved", { ns: "${u}" })}}`,color:"green",icon:r.jsx(O.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${u}" })}}`},{value:pe.FAILED,label:`{{t("Failed", { ns: "${u}" })}}`,color:"red",icon:r.jsx(O.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${u}" })}}`},{value:pe.ERROR,label:`{{t("Error", { ns: "${u}" })}}`,color:"red",icon:r.jsx(O.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${u}" })}}`},{value:pe.ABORTED,label:`{{t("Aborted", { ns: "${u}" })}}`,color:"red",icon:r.jsx(O.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${u}" })}}`},{value:pe.CANCELED,label:`{{t("Canceled", { ns: "${u}" })}}`,color:"volcano",icon:r.jsx(O.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${u}" })}}`},{value:pe.REJECTED,label:`{{t("Rejected", { ns: "${u}" })}}`,color:"volcano",icon:r.jsx(O.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${u}" })}}`},{value:pe.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${u}" })}}`,color:"volcano",icon:r.jsx(O.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${u}" })}}`}],Xe=Qe.reduce((e,o)=>Object.assign(e,{[o.value]:o}),{}),Z={PENDING:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},Re=[{value:Z.PENDING,label:`{{t("Pending", { ns: "${u}" })}}`,color:"gold",icon:r.jsx(O.ClockCircleOutlined,{})},{value:Z.RESOLVED,label:`{{t("Resolved", { ns: "${u}" })}}`,color:"green",icon:r.jsx(O.CheckOutlined,{})},{value:Z.FAILED,label:`{{t("Failed", { ns: "${u}" })}}`,color:"red",icon:r.jsx(O.ExclamationOutlined,{})},{value:Z.ERROR,label:`{{t("Error", { ns: "${u}" })}}`,color:"red",icon:r.jsx(O.CloseOutlined,{})},{value:Z.ABORTED,label:`{{t("Aborted", { ns: "${u}" })}}`,color:"red",icon:r.jsx(O.MinusOutlined,{rotate:90})},{value:Z.CANCELED,label:`{{t("Canceled", { ns: "${u}" })}}`,color:"volcano",icon:r.jsx(O.MinusOutlined,{rotate:45})},{value:Z.REJECTED,label:`{{t("Rejected", { ns: "${u}" })}}`,color:"volcano",icon:r.jsx(O.MinusOutlined,{})},{value:Z.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${u}" })}}`,color:"volcano",icon:r.jsx(O.RedoOutlined,{})}],Le=Re.reduce((e,o)=>Object.assign(e,{[o.value]:o}),{}),ze=y.createContext({});function U(){return y.useContext(ze)}const nn=l.createStyles(({css:e,token:o})=>({container:e`
|
|
2
2
|
margin-bottom: 1.5em;
|
|
3
3
|
padding: 1em;
|
|
4
|
-
background-color: ${
|
|
4
|
+
background-color: ${o.colorFillAlter};
|
|
5
5
|
|
|
6
6
|
> *:last-child {
|
|
7
7
|
margin-bottom: 0;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
align-items: baseline;
|
|
13
13
|
|
|
14
14
|
dt {
|
|
15
|
-
color: ${
|
|
15
|
+
color: ${o.colorText};
|
|
16
16
|
&:after {
|
|
17
17
|
content: ':';
|
|
18
18
|
margin-right: 0.5em;
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
p {
|
|
24
|
-
color: ${
|
|
24
|
+
color: ${o.colorTextDescription};
|
|
25
25
|
}
|
|
26
|
-
`}));function
|
|
26
|
+
`}));function Wo(e){const{label:o,title:n,description:t}=e,{styles:s}=nn();return r.jsxs("div",{className:l.cx(s.container,e.className),children:[r.jsxs("dl",{children:[r.jsx("dt",{children:o}),r.jsx("dd",{children:r.jsx(b.Tag,{style:{background:"none"},children:n})})]}),t?r.jsx("p",{children:t}):null]})}function rn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Uo={exports:{}};/*!
|
|
27
27
|
Copyright (c) 2018 Jed Watson.
|
|
28
28
|
Licensed under the MIT License (MIT), see
|
|
29
29
|
http://jedwatson.github.io/classnames
|
|
30
|
-
*/(function(e){(function(){var
|
|
30
|
+
*/(function(e){(function(){var o={}.hasOwnProperty;function n(){for(var t=[],s=0;s<arguments.length;s++){var i=arguments[s];if(i){var a=typeof i;if(a==="string"||a==="number")t.push(i);else if(Array.isArray(i)){if(i.length){var c=n.apply(null,i);c&&t.push(c)}}else if(a==="object"){if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]")){t.push(i.toString());continue}for(var d in i)o.call(i,d)&&i[d]&&t.push(d)}}}return t.join(" ")}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(Uo);var sn=Uo.exports;const ln=rn(sn),an=l.createStyles(({css:e,token:o})=>({statusButtonClass:e`
|
|
31
31
|
border: none;
|
|
32
32
|
.ant-tag {
|
|
33
33
|
width: 100%;
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
}
|
|
40
40
|
`,noStatusButtonClass:e`
|
|
41
41
|
border-width: 2px;
|
|
42
|
-
`}));function
|
|
42
|
+
`}));function We(e){var t;const{styles:o}=an();let n=null;if(typeof e.status!="undefined"&&((t=e.statusMap)!=null&&t[e.status])){const{icon:s,color:i}=e.statusMap[e.status];n=r.jsx(b.Tag,{color:i,children:s})}return r.jsx(b.Button,C(g({},e),{shape:"circle",size:"small",className:ln(n?o.statusButtonClass:o.noStatusButtonClass,e.className),children:n}))}const Co=(e,o)=>({getAriaLabel:y.useCallback(t=>["add-button",e==null?void 0:e.type,e==null?void 0:e.title,o!=null?String(o):"",t].filter(Boolean).join("-"),[o,e==null?void 0:e.title,e==null?void 0:e.type])}),te=l.createStyles(({css:e,token:o})=>({workflowPageClass:e`
|
|
43
43
|
flex-grow: 1;
|
|
44
44
|
overflow: hidden;
|
|
45
45
|
display: flex;
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
justify-content: space-between;
|
|
52
52
|
position: relative;
|
|
53
53
|
padding: 0.5rem 1rem;
|
|
54
|
-
background: ${
|
|
55
|
-
border-bottom: 1px solid ${
|
|
54
|
+
background: ${o.colorBgContainer};
|
|
55
|
+
border-bottom: 1px solid ${o.colorBorderSecondary};
|
|
56
56
|
|
|
57
57
|
header {
|
|
58
58
|
display: flex;
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
height: 10em;
|
|
88
88
|
padding: 1em 0;
|
|
89
89
|
border-radius: 0.5em;
|
|
90
|
-
background: ${
|
|
90
|
+
background: ${o.colorBgContainer};
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
.workflow-canvas {
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
bottom: 0;
|
|
159
159
|
left: calc(50% - 0.5px);
|
|
160
160
|
width: 1px;
|
|
161
|
-
background-color: ${
|
|
161
|
+
background-color: ${o.colorBgLayout};
|
|
162
162
|
}
|
|
163
163
|
`,branchClass:e`
|
|
164
164
|
display: flex;
|
|
@@ -177,7 +177,7 @@
|
|
|
177
177
|
top: 0;
|
|
178
178
|
bottom: 0;
|
|
179
179
|
width: 1px;
|
|
180
|
-
background-color: ${
|
|
180
|
+
background-color: ${o.colorBorder};
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
:before,
|
|
@@ -185,7 +185,7 @@
|
|
|
185
185
|
content: '';
|
|
186
186
|
position: absolute;
|
|
187
187
|
height: 1px;
|
|
188
|
-
background-color: ${
|
|
188
|
+
background-color: ${o.colorBorder};
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
:before {
|
|
@@ -229,7 +229,7 @@
|
|
|
229
229
|
width: 0;
|
|
230
230
|
height: 4em;
|
|
231
231
|
padding: 1em 0;
|
|
232
|
-
border-left: 1px dashed ${
|
|
232
|
+
border-left: 1px dashed ${o.colorBgLayout};
|
|
233
233
|
|
|
234
234
|
.anticon {
|
|
235
235
|
font-size: 1.5em;
|
|
@@ -251,15 +251,15 @@
|
|
|
251
251
|
`,nodeCardClass:e`
|
|
252
252
|
position: relative;
|
|
253
253
|
width: 20em;
|
|
254
|
-
background: ${
|
|
254
|
+
background: ${o.colorBgContainer};
|
|
255
255
|
padding: 1em;
|
|
256
|
-
box-shadow: ${
|
|
257
|
-
border-radius: ${
|
|
256
|
+
box-shadow: ${o.boxShadowTertiary};
|
|
257
|
+
border-radius: ${o.borderRadiusLG}px;
|
|
258
258
|
cursor: pointer;
|
|
259
259
|
transition: box-shadow 0.3s ease;
|
|
260
260
|
|
|
261
261
|
&:hover {
|
|
262
|
-
box-shadow: ${
|
|
262
|
+
box-shadow: ${o.boxShadow};
|
|
263
263
|
|
|
264
264
|
.workflow-node-remove-button {
|
|
265
265
|
display: block;
|
|
@@ -267,7 +267,7 @@
|
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
&.configuring {
|
|
270
|
-
box-shadow: ${
|
|
270
|
+
box-shadow: ${o.boxShadow};
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
.workflow-node-remove-button {
|
|
@@ -275,14 +275,14 @@
|
|
|
275
275
|
position: absolute;
|
|
276
276
|
right: 0.5em;
|
|
277
277
|
top: 0.5em;
|
|
278
|
-
color: ${
|
|
278
|
+
color: ${o.colorText};
|
|
279
279
|
|
|
280
280
|
&[disabled] {
|
|
281
281
|
display: none;
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
&:hover {
|
|
285
|
-
color: ${
|
|
285
|
+
color: ${o.colorErrorHover};
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
|
|
@@ -293,15 +293,15 @@
|
|
|
293
293
|
transition:
|
|
294
294
|
background-color 0.3s ease,
|
|
295
295
|
border-color 0.3s ease;
|
|
296
|
-
border-color: ${
|
|
297
|
-
background-color: ${
|
|
296
|
+
border-color: ${o.colorBorderBg};
|
|
297
|
+
background-color: ${o.colorBgContainerDisabled};
|
|
298
298
|
|
|
299
299
|
&:not(:disabled):hover {
|
|
300
|
-
border-color: ${
|
|
300
|
+
border-color: ${o.colorPrimaryBorderHover};
|
|
301
301
|
}
|
|
302
302
|
|
|
303
303
|
&:disabled:hover {
|
|
304
|
-
border-color: ${
|
|
304
|
+
border-color: ${o.colorBorderBg};
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
}
|
|
@@ -324,14 +324,14 @@
|
|
|
324
324
|
right: 1em;
|
|
325
325
|
justify-content: center;
|
|
326
326
|
align-items: center;
|
|
327
|
-
color: ${
|
|
327
|
+
color: ${o.colorTextLightSolid};
|
|
328
328
|
`,nodeHeaderClass:e`
|
|
329
329
|
position: relative;
|
|
330
330
|
`,nodeMetaClass:e`
|
|
331
331
|
margin-bottom: 0.5em;
|
|
332
332
|
|
|
333
333
|
.workflow-node-id {
|
|
334
|
-
color: ${
|
|
334
|
+
color: ${o.colorTextDescription};
|
|
335
335
|
|
|
336
336
|
&:before {
|
|
337
337
|
content: '#';
|
|
@@ -342,7 +342,7 @@
|
|
|
342
342
|
align-items: center;
|
|
343
343
|
font-weight: normal;
|
|
344
344
|
.workflow-node-id {
|
|
345
|
-
color: ${
|
|
345
|
+
color: ${o.colorTextDescription};
|
|
346
346
|
}
|
|
347
347
|
`,nodeSubtreeClass:e`
|
|
348
348
|
display: flex;
|
|
@@ -351,7 +351,7 @@
|
|
|
351
351
|
margin: auto;
|
|
352
352
|
`,nodeJobResultClass:e`
|
|
353
353
|
padding: 1em;
|
|
354
|
-
background-color: ${
|
|
354
|
+
background-color: ${o.colorBgContainer};
|
|
355
355
|
`,addButtonClass:e`
|
|
356
356
|
flex-shrink: 0;
|
|
357
357
|
padding: 2em 0;
|
|
@@ -369,8 +369,8 @@
|
|
|
369
369
|
position: absolute;
|
|
370
370
|
top: calc(1.5em - 1px);
|
|
371
371
|
line-height: 1em;
|
|
372
|
-
color: ${
|
|
373
|
-
background-color: ${
|
|
372
|
+
color: ${o.colorTextSecondary};
|
|
373
|
+
background-color: ${o.colorBgLayout};
|
|
374
374
|
padding: 1px;
|
|
375
375
|
}
|
|
376
376
|
`,loopLineClass:e`
|
|
@@ -390,22 +390,22 @@
|
|
|
390
390
|
width: 4em;
|
|
391
391
|
height: 4em;
|
|
392
392
|
border-radius: 50%;
|
|
393
|
-
background-color: ${
|
|
394
|
-
color: ${
|
|
395
|
-
`}));function
|
|
393
|
+
background-color: ${o.colorText};
|
|
394
|
+
color: ${o.colorBgContainer};
|
|
395
|
+
`}));function cn(){return!0}const wo=T.observer(e=>{const c=e,{filter:o=cn}=c,n=z(c,["filter"]),t=l.useCompile(),{getCollectionFields:s}=l.useCollectionManager(),{values:i}=T.useForm(),a=s(i==null?void 0:i.collection);return r.jsx(b.Select,C(g({popupMatchSelectWidth:!1},n),{options:a.filter(o).map(d=>{var p;return{label:t((p=d.uiSchema)==null?void 0:p.title),value:d.name}})}))},{displayName:"FieldsSelect"});function ko(e,o){o(e),e.properties&&Object.keys(e.properties).forEach(n=>{ko(e.properties[n],o)})}function Ce(e,o,n=!1){const t=[];return e?o(e)&&(!n||!e.properties)?(t.push(e),t):(e.properties&&Object.keys(e.properties).forEach(s=>{t.push(...Ce(e.properties[s],o))}),t):t}function dn(s){var i=s,{insert:e,collection:o,dataSource:n}=i,t=z(i,["insert","collection","dataSource"]);const{getTemplateSchemaByMode:a}=l.useSchemaTemplateManager(),{getCollection:c}=l.useCollectionManager(),d=l.useRecordCollectionDataSourceItems("FormItem"),p=c(o);function f(v){return H(this,arguments,function*({item:x}){const h=x.template?yield a(x):null,m={type:"void",name:p.name,title:p.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:o,dataSource:n},"x-component":"CardItem","x-component-props":{title:t.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-component-props":{useProps:"{{useDetailsBlockProps}}"},"x-read-pretty":!0,properties:{grid:h||{type:"void","x-component":"Grid","x-initializer":"ReadPrettyFormItemInitializers",properties:{}}}}}};ko(m,S=>{S["x-uid"]&&delete S["x-uid"]}),e(m)})}return r.jsx(l.SchemaInitializer.Item,C(g({},t),{onClick:f,items:d}))}function Te(e){return r.jsx(l.CollectionProvider,{collection:e.collection,children:r.jsx(dn,g({},e))})}const ae={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"CollectionSelect","x-component-props":{className:"auto-width"}},qo={type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:l.css`
|
|
396
396
|
flex-direction: column;
|
|
397
|
-
`},"x-component":"CollectionFieldset",description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${
|
|
397
|
+
`},"x-component":"CollectionFieldset",description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${u}" })}}`},$e={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-component-props":{useProps(){const{values:e}=T.useForm();return{options:l.useCollectionFilterOptions(e==null?void 0:e.collection),className:l.css`
|
|
398
398
|
position: relative;
|
|
399
399
|
width: 100%;
|
|
400
|
-
`}},dynamicComponent:"FilterDynamicComponent"}},ds={type:"array",title:'{{t("Sort")}}',"x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:"{{useSortableFields()}}",required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:'{{t("ASC")}}',value:"asc"},{label:'{{t("DESC")}}',value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{t("Add sort field")}}',"x-component":"ArrayItems.Addition"}}},ps={type:"void",title:'{{t("Pagination")}}',"x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{page:{type:"void","x-component":"Grid.Col",properties:{page:{type:"number",title:'{{t("Page number")}}',"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:["number","null"]},default:1}}},pageSize:{type:"void","x-component":"Grid.Col",properties:{pageSize:{type:"number",title:'{{t("Page size")}}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:1,max:100},default:20}}}}}}},Be={type:"array",title:`{{t("Preload associations", { ns: "${d}" })}}`,description:`{{t("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution.", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=F.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},Ve={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},ms=[{label:`{{t("After record added", { ns: "${d}" })}}`,value:Ve.CREATED},{label:`{{t("After record updated", { ns: "${d}" })}}`,value:Ve.UPDATED},{label:`{{t("After record added or updated", { ns: "${d}" })}}`,value:Ve.SAVED},{label:`{{t("After record deleted", { ns: "${d}" })}}`,value:Ve.DELETED}],jo={title:`{{t("Collection event", { ns: "${d}" })}}`,type:"collection",description:`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${d}" })}}`,fieldset:{collection:C(v({},de),{"x-reactions":[...de["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${d}" })}}`,className:"auto-width"},enum:ms,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${d}" })}}`,description:`{{t("Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(e){return!e.hidden&&(e.uiSchema?!e.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(e.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Ve.UPDATED})}}`}}}]},condition:C(v({},je),{title:`{{t("Only triggers when match conditions", { ns: "${d}" })}}`,"x-component-props":{useProps:je["x-component-props"].useProps},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:C(v({},Be),{"x-reactions":[...Be["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Ve.DELETED})}}`}}}]})},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{FieldsSelect:qt},useVariables(e,t){var l;const o=i.useCompile(),{getCollectionFields:r}=i.useCollectionManager(),s=[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:N("Trigger data")}}];return be(C(v({appends:["data",...((l=e.appends)==null?void 0:l.map(c=>`data.${c}`))||[]]},t),{fields:s,compile:o,getCollectionFields:r}))},useInitializers(e){return e.collection?{type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${d}" })}}`,component:_e,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{}};function fs(e,t){for(var o=-1,r=e==null?0:e.length,s=Array(r);++o<r;)s[o]=t(e[o],o,e);return s}var Bo=fs;function hs(){this.__data__=[],this.size=0}var ys=hs;function gs(e,t){return e===t||e!==e&&t!==t}var Vo=gs,vs=Vo;function bs(e,t){for(var o=e.length;o--;)if(vs(e[o][0],t))return o;return-1}var vt=bs,xs=vt,Cs=Array.prototype,ws=Cs.splice;function $s(e){var t=this.__data__,o=xs(t,e);if(o<0)return!1;var r=t.length-1;return o==r?t.pop():ws.call(t,o,1),--this.size,!0}var Ss=$s,ks=vt;function As(e){var t=this.__data__,o=ks(t,e);return o<0?void 0:t[o][1]}var Ts=As,Os=vt;function Fs(e){return Os(this.__data__,e)>-1}var Is=Fs,Ds=vt;function Ns(e,t){var o=this.__data__,r=Ds(o,e);return r<0?(++this.size,o.push([e,t])):o[r][1]=t,this}var Ps=Ns,Es=ys,Ms=Ss,_s=Ts,js=Is,Bs=Ps;function Le(e){var t=-1,o=e==null?0:e.length;for(this.clear();++t<o;){var r=e[t];this.set(r[0],r[1])}}Le.prototype.clear=Es,Le.prototype.delete=Ms,Le.prototype.get=_s,Le.prototype.has=js,Le.prototype.set=Bs;var bt=Le,Vs=bt;function Ls(){this.__data__=new Vs,this.size=0}var zs=Ls;function Ws(e){var t=this.__data__,o=t.delete(e);return this.size=t.size,o}var Us=Ws;function Gs(e){return this.__data__.get(e)}var Hs=Gs;function Ks(e){return this.__data__.has(e)}var qs=Ks,Js=typeof gt=="object"&>&>.Object===Object&>,Lo=Js,Ys=Lo,Zs=typeof self=="object"&&self&&self.Object===Object&&self,Qs=Ys||Zs||Function("return this")(),ve=Qs,Xs=ve,Rs=Xs.Symbol,ot=Rs,zo=ot,Wo=Object.prototype,ea=Wo.hasOwnProperty,ta=Wo.toString,rt=zo?zo.toStringTag:void 0;function oa(e){var t=ea.call(e,rt),o=e[rt];try{e[rt]=void 0;var r=!0}catch(a){}var s=ta.call(e);return r&&(t?e[rt]=o:delete e[rt]),s}var ra=oa,na=Object.prototype,sa=na.toString;function aa(e){return sa.call(e)}var ia=aa,Uo=ot,la=ra,ca=ia,ua="[object Null]",da="[object Undefined]",Go=Uo?Uo.toStringTag:void 0;function pa(e){return e==null?e===void 0?da:ua:Go&&Go in Object(e)?la(e):ca(e)}var ze=pa;function ma(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var nt=ma,fa=ze,ha=nt,ya="[object AsyncFunction]",ga="[object Function]",va="[object GeneratorFunction]",ba="[object Proxy]";function xa(e){if(!ha(e))return!1;var t=fa(e);return t==ga||t==va||t==ya||t==ba}var Ho=xa,Ca=ve,wa=Ca["__core-js_shared__"],$a=wa,Yt=$a,Ko=function(){var e=/[^.]+$/.exec(Yt&&Yt.keys&&Yt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Sa(e){return!!Ko&&Ko in e}var ka=Sa,Aa=Function.prototype,Ta=Aa.toString;function Oa(e){if(e!=null){try{return Ta.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var qo=Oa,Fa=Ho,Ia=ka,Da=nt,Na=qo,Pa=/[\\^$.*+?()[\]{}|]/g,Ea=/^\[object .+?Constructor\]$/,Ma=Function.prototype,_a=Object.prototype,ja=Ma.toString,Ba=_a.hasOwnProperty,Va=RegExp("^"+ja.call(Ba).replace(Pa,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function La(e){if(!Da(e)||Ia(e))return!1;var t=Fa(e)?Va:Ea;return t.test(Na(e))}var za=La;function Wa(e,t){return e==null?void 0:e[t]}var Ua=Wa,Ga=za,Ha=Ua;function Ka(e,t){var o=Ha(e,t);return Ga(o)?o:void 0}var Fe=Ka,qa=Fe,Ja=ve,Ya=qa(Ja,"Map"),Zt=Ya,Za=Fe,Qa=Za(Object,"create"),xt=Qa,Jo=xt;function Xa(){this.__data__=Jo?Jo(null):{},this.size=0}var Ra=Xa;function ei(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var ti=ei,oi=xt,ri="__lodash_hash_undefined__",ni=Object.prototype,si=ni.hasOwnProperty;function ai(e){var t=this.__data__;if(oi){var o=t[e];return o===ri?void 0:o}return si.call(t,e)?t[e]:void 0}var ii=ai,li=xt,ci=Object.prototype,ui=ci.hasOwnProperty;function di(e){var t=this.__data__;return li?t[e]!==void 0:ui.call(t,e)}var pi=di,mi=xt,fi="__lodash_hash_undefined__";function hi(e,t){var o=this.__data__;return this.size+=this.has(e)?0:1,o[e]=mi&&t===void 0?fi:t,this}var yi=hi,gi=Ra,vi=ti,bi=ii,xi=pi,Ci=yi;function We(e){var t=-1,o=e==null?0:e.length;for(this.clear();++t<o;){var r=e[t];this.set(r[0],r[1])}}We.prototype.clear=gi,We.prototype.delete=vi,We.prototype.get=bi,We.prototype.has=xi,We.prototype.set=Ci;var wi=We,Yo=wi,$i=bt,Si=Zt;function ki(){this.size=0,this.__data__={hash:new Yo,map:new(Si||$i),string:new Yo}}var Ai=ki;function Ti(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var Oi=Ti,Fi=Oi;function Ii(e,t){var o=e.__data__;return Fi(t)?o[typeof t=="string"?"string":"hash"]:o.map}var Ct=Ii,Di=Ct;function Ni(e){var t=Di(this,e).delete(e);return this.size-=t?1:0,t}var Pi=Ni,Ei=Ct;function Mi(e){return Ei(this,e).get(e)}var _i=Mi,ji=Ct;function Bi(e){return ji(this,e).has(e)}var Vi=Bi,Li=Ct;function zi(e,t){var o=Li(this,e),r=o.size;return o.set(e,t),this.size+=o.size==r?0:1,this}var Wi=zi,Ui=Ai,Gi=Pi,Hi=_i,Ki=Vi,qi=Wi;function Ue(e){var t=-1,o=e==null?0:e.length;for(this.clear();++t<o;){var r=e[t];this.set(r[0],r[1])}}Ue.prototype.clear=Ui,Ue.prototype.delete=Gi,Ue.prototype.get=Hi,Ue.prototype.has=Ki,Ue.prototype.set=qi;var Zo=Ue,Ji=bt,Yi=Zt,Zi=Zo,Qi=200;function Xi(e,t){var o=this.__data__;if(o instanceof Ji){var r=o.__data__;if(!Yi||r.length<Qi-1)return r.push([e,t]),this.size=++o.size,this;o=this.__data__=new Zi(r)}return o.set(e,t),this.size=o.size,this}var Ri=Xi,el=bt,tl=zs,ol=Us,rl=Hs,nl=qs,sl=Ri;function Ge(e){var t=this.__data__=new el(e);this.size=t.size}Ge.prototype.clear=tl,Ge.prototype.delete=ol,Ge.prototype.get=rl,Ge.prototype.has=nl,Ge.prototype.set=sl;var al=Ge;function il(e,t){for(var o=-1,r=e==null?0:e.length;++o<r&&t(e[o],o,e)!==!1;);return e}var ll=il,cl=Fe,ul=function(){try{var e=cl(Object,"defineProperty");return e({},"",{}),e}catch(t){}}(),Qo=ul,Xo=Qo;function dl(e,t,o){t=="__proto__"&&Xo?Xo(e,t,{configurable:!0,enumerable:!0,value:o,writable:!0}):e[t]=o}var Ro=dl,pl=Ro,ml=Vo,fl=Object.prototype,hl=fl.hasOwnProperty;function yl(e,t,o){var r=e[t];(!(hl.call(e,t)&&ml(r,o))||o===void 0&&!(t in e))&&pl(e,t,o)}var er=yl,gl=er,vl=Ro;function bl(e,t,o,r){var s=!o;o||(o={});for(var a=-1,l=t.length;++a<l;){var c=t[a],u=r?r(o[c],e[c],c,o,e):void 0;u===void 0&&(u=e[c]),s?vl(o,c,u):gl(o,c,u)}return o}var st=bl;function xl(e,t){for(var o=-1,r=Array(e);++o<e;)r[o]=t(o);return r}var Cl=xl;function wl(e){return e!=null&&typeof e=="object"}var Ie=wl,$l=ze,Sl=Ie,kl="[object Arguments]";function Al(e){return Sl(e)&&$l(e)==kl}var Tl=Al,tr=Tl,Ol=Ie,or=Object.prototype,Fl=or.hasOwnProperty,Il=or.propertyIsEnumerable,Dl=tr(function(){return arguments}())?tr:function(e){return Ol(e)&&Fl.call(e,"callee")&&!Il.call(e,"callee")},rr=Dl,Nl=Array.isArray,De=Nl,wt={exports:{}};function Pl(){return!1}var El=Pl;wt.exports,function(e,t){var o=ve,r=El,s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,l=a&&a.exports===s,c=l?o.Buffer:void 0,u=c?c.isBuffer:void 0,p=u||r;e.exports=p}(wt,wt.exports);var nr=wt.exports,Ml=9007199254740991,_l=/^(?:0|[1-9]\d*)$/;function jl(e,t){var o=typeof e;return t=t==null?Ml:t,!!t&&(o=="number"||o!="symbol"&&_l.test(e))&&e>-1&&e%1==0&&e<t}var Bl=jl,Vl=9007199254740991;function Ll(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Vl}var sr=Ll,zl=ze,Wl=sr,Ul=Ie,Gl="[object Arguments]",Hl="[object Array]",Kl="[object Boolean]",ql="[object Date]",Jl="[object Error]",Yl="[object Function]",Zl="[object Map]",Ql="[object Number]",Xl="[object Object]",Rl="[object RegExp]",ec="[object Set]",tc="[object String]",oc="[object WeakMap]",rc="[object ArrayBuffer]",nc="[object DataView]",sc="[object Float32Array]",ac="[object Float64Array]",ic="[object Int8Array]",lc="[object Int16Array]",cc="[object Int32Array]",uc="[object Uint8Array]",dc="[object Uint8ClampedArray]",pc="[object Uint16Array]",mc="[object Uint32Array]",q={};q[sc]=q[ac]=q[ic]=q[lc]=q[cc]=q[uc]=q[dc]=q[pc]=q[mc]=!0,q[Gl]=q[Hl]=q[rc]=q[Kl]=q[nc]=q[ql]=q[Jl]=q[Yl]=q[Zl]=q[Ql]=q[Xl]=q[Rl]=q[ec]=q[tc]=q[oc]=!1;function fc(e){return Ul(e)&&Wl(e.length)&&!!q[zl(e)]}var hc=fc;function yc(e){return function(t){return e(t)}}var Qt=yc,$t={exports:{}};$t.exports,function(e,t){var o=Lo,r=t&&!t.nodeType&&t,s=r&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===r,l=a&&o.process,c=function(){try{var u=s&&s.require&&s.require("util").types;return u||l&&l.binding&&l.binding("util")}catch(p){}}();e.exports=c}($t,$t.exports);var Xt=$t.exports,gc=hc,vc=Qt,ar=Xt,ir=ar&&ar.isTypedArray,bc=ir?vc(ir):gc,xc=bc,Cc=Cl,wc=rr,$c=De,Sc=nr,kc=Bl,Ac=xc,Tc=Object.prototype,Oc=Tc.hasOwnProperty;function Fc(e,t){var o=$c(e),r=!o&&wc(e),s=!o&&!r&&Sc(e),a=!o&&!r&&!s&&Ac(e),l=o||r||s||a,c=l?Cc(e.length,String):[],u=c.length;for(var p in e)(t||Oc.call(e,p))&&!(l&&(p=="length"||s&&(p=="offset"||p=="parent")||a&&(p=="buffer"||p=="byteLength"||p=="byteOffset")||kc(p,u)))&&c.push(p);return c}var lr=Fc,Ic=Object.prototype;function Dc(e){var t=e&&e.constructor,o=typeof t=="function"&&t.prototype||Ic;return e===o}var Rt=Dc;function Nc(e,t){return function(o){return e(t(o))}}var cr=Nc,Pc=cr,Ec=Pc(Object.keys,Object),Mc=Ec,_c=Rt,jc=Mc,Bc=Object.prototype,Vc=Bc.hasOwnProperty;function Lc(e){if(!_c(e))return jc(e);var t=[];for(var o in Object(e))Vc.call(e,o)&&o!="constructor"&&t.push(o);return t}var zc=Lc,Wc=Ho,Uc=sr;function Gc(e){return e!=null&&Uc(e.length)&&!Wc(e)}var ur=Gc,Hc=lr,Kc=zc,qc=ur;function Jc(e){return qc(e)?Hc(e):Kc(e)}var eo=Jc,Yc=st,Zc=eo;function Qc(e,t){return e&&Yc(t,Zc(t),e)}var Xc=Qc;function Rc(e){var t=[];if(e!=null)for(var o in Object(e))t.push(o);return t}var eu=Rc,tu=nt,ou=Rt,ru=eu,nu=Object.prototype,su=nu.hasOwnProperty;function au(e){if(!tu(e))return ru(e);var t=ou(e),o=[];for(var r in e)r=="constructor"&&(t||!su.call(e,r))||o.push(r);return o}var iu=au,lu=lr,cu=iu,uu=ur;function du(e){return uu(e)?lu(e,!0):cu(e)}var to=du,pu=st,mu=to;function fu(e,t){return e&&pu(t,mu(t),e)}var hu=fu,St={exports:{}};St.exports,function(e,t){var o=ve,r=t&&!t.nodeType&&t,s=r&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===r,l=a?o.Buffer:void 0,c=l?l.allocUnsafe:void 0;function u(p,f){if(f)return p.slice();var g=p.length,x=c?c(g):new p.constructor(g);return p.copy(x),x}e.exports=u}(St,St.exports);var yu=St.exports;function gu(e,t){var o=-1,r=e.length;for(t||(t=Array(r));++o<r;)t[o]=e[o];return t}var vu=gu;function bu(e,t){for(var o=-1,r=e==null?0:e.length,s=0,a=[];++o<r;){var l=e[o];t(l,o,e)&&(a[s++]=l)}return a}var xu=bu;function Cu(){return[]}var dr=Cu,wu=xu,$u=dr,Su=Object.prototype,ku=Su.propertyIsEnumerable,pr=Object.getOwnPropertySymbols,Au=pr?function(e){return e==null?[]:(e=Object(e),wu(pr(e),function(t){return ku.call(e,t)}))}:$u,oo=Au,Tu=st,Ou=oo;function Fu(e,t){return Tu(e,Ou(e),t)}var Iu=Fu;function Du(e,t){for(var o=-1,r=t.length,s=e.length;++o<r;)e[s+o]=t[o];return e}var ro=Du,Nu=cr,Pu=Nu(Object.getPrototypeOf,Object),no=Pu,Eu=ro,Mu=no,_u=oo,ju=dr,Bu=Object.getOwnPropertySymbols,Vu=Bu?function(e){for(var t=[];e;)Eu(t,_u(e)),e=Mu(e);return t}:ju,mr=Vu,Lu=st,zu=mr;function Wu(e,t){return Lu(e,zu(e),t)}var Uu=Wu,Gu=ro,Hu=De;function Ku(e,t,o){var r=t(e);return Hu(e)?r:Gu(r,o(e))}var fr=Ku,qu=fr,Ju=oo,Yu=eo;function Zu(e){return qu(e,Yu,Ju)}var Qu=Zu,Xu=fr,Ru=mr,ed=to;function td(e){return Xu(e,ed,Ru)}var hr=td,od=Fe,rd=ve,nd=od(rd,"DataView"),sd=nd,ad=Fe,id=ve,ld=ad(id,"Promise"),cd=ld,ud=Fe,dd=ve,pd=ud(dd,"Set"),md=pd,fd=Fe,hd=ve,yd=fd(hd,"WeakMap"),gd=yd,so=sd,ao=Zt,io=cd,lo=md,co=gd,yr=ze,He=qo,gr="[object Map]",vd="[object Object]",vr="[object Promise]",br="[object Set]",xr="[object WeakMap]",Cr="[object DataView]",bd=He(so),xd=He(ao),Cd=He(io),wd=He(lo),$d=He(co),Ne=yr;(so&&Ne(new so(new ArrayBuffer(1)))!=Cr||ao&&Ne(new ao)!=gr||io&&Ne(io.resolve())!=vr||lo&&Ne(new lo)!=br||co&&Ne(new co)!=xr)&&(Ne=function(e){var t=yr(e),o=t==vd?e.constructor:void 0,r=o?He(o):"";if(r)switch(r){case bd:return Cr;case xd:return gr;case Cd:return vr;case wd:return br;case $d:return xr}return t});var uo=Ne,Sd=Object.prototype,kd=Sd.hasOwnProperty;function Ad(e){var t=e.length,o=new e.constructor(t);return t&&typeof e[0]=="string"&&kd.call(e,"index")&&(o.index=e.index,o.input=e.input),o}var Td=Ad,Od=ve,Fd=Od.Uint8Array,Id=Fd,wr=Id;function Dd(e){var t=new e.constructor(e.byteLength);return new wr(t).set(new wr(e)),t}var po=Dd,Nd=po;function Pd(e,t){var o=t?Nd(e.buffer):e.buffer;return new e.constructor(o,e.byteOffset,e.byteLength)}var Ed=Pd,Md=/\w*$/;function _d(e){var t=new e.constructor(e.source,Md.exec(e));return t.lastIndex=e.lastIndex,t}var jd=_d,$r=ot,Sr=$r?$r.prototype:void 0,kr=Sr?Sr.valueOf:void 0;function Bd(e){return kr?Object(kr.call(e)):{}}var Vd=Bd,Ld=po;function zd(e,t){var o=t?Ld(e.buffer):e.buffer;return new e.constructor(o,e.byteOffset,e.length)}var Wd=zd,Ud=po,Gd=Ed,Hd=jd,Kd=Vd,qd=Wd,Jd="[object Boolean]",Yd="[object Date]",Zd="[object Map]",Qd="[object Number]",Xd="[object RegExp]",Rd="[object Set]",ep="[object String]",tp="[object Symbol]",op="[object ArrayBuffer]",rp="[object DataView]",np="[object Float32Array]",sp="[object Float64Array]",ap="[object Int8Array]",ip="[object Int16Array]",lp="[object Int32Array]",cp="[object Uint8Array]",up="[object Uint8ClampedArray]",dp="[object Uint16Array]",pp="[object Uint32Array]";function mp(e,t,o){var r=e.constructor;switch(t){case op:return Ud(e);case Jd:case Yd:return new r(+e);case rp:return Gd(e,o);case np:case sp:case ap:case ip:case lp:case cp:case up:case dp:case pp:return qd(e,o);case Zd:return new r;case Qd:case ep:return new r(e);case Xd:return Hd(e);case Rd:return new r;case tp:return Kd(e)}}var fp=mp,hp=nt,Ar=Object.create,yp=function(){function e(){}return function(t){if(!hp(t))return{};if(Ar)return Ar(t);e.prototype=t;var o=new e;return e.prototype=void 0,o}}(),gp=yp,vp=gp,bp=no,xp=Rt;function Cp(e){return typeof e.constructor=="function"&&!xp(e)?vp(bp(e)):{}}var wp=Cp,$p=uo,Sp=Ie,kp="[object Map]";function Ap(e){return Sp(e)&&$p(e)==kp}var Tp=Ap,Op=Tp,Fp=Qt,Tr=Xt,Or=Tr&&Tr.isMap,Ip=Or?Fp(Or):Op,Dp=Ip,Np=uo,Pp=Ie,Ep="[object Set]";function Mp(e){return Pp(e)&&Np(e)==Ep}var _p=Mp,jp=_p,Bp=Qt,Fr=Xt,Ir=Fr&&Fr.isSet,Vp=Ir?Bp(Ir):jp,Lp=Vp,zp=al,Wp=ll,Up=er,Gp=Xc,Hp=hu,Kp=yu,qp=vu,Jp=Iu,Yp=Uu,Zp=Qu,Qp=hr,Xp=uo,Rp=Td,em=fp,tm=wp,om=De,rm=nr,nm=Dp,sm=nt,am=Lp,im=eo,lm=to,cm=1,um=2,dm=4,Dr="[object Arguments]",pm="[object Array]",mm="[object Boolean]",fm="[object Date]",hm="[object Error]",Nr="[object Function]",ym="[object GeneratorFunction]",gm="[object Map]",vm="[object Number]",Pr="[object Object]",bm="[object RegExp]",xm="[object Set]",Cm="[object String]",wm="[object Symbol]",$m="[object WeakMap]",Sm="[object ArrayBuffer]",km="[object DataView]",Am="[object Float32Array]",Tm="[object Float64Array]",Om="[object Int8Array]",Fm="[object Int16Array]",Im="[object Int32Array]",Dm="[object Uint8Array]",Nm="[object Uint8ClampedArray]",Pm="[object Uint16Array]",Em="[object Uint32Array]",H={};H[Dr]=H[pm]=H[Sm]=H[km]=H[mm]=H[fm]=H[Am]=H[Tm]=H[Om]=H[Fm]=H[Im]=H[gm]=H[vm]=H[Pr]=H[bm]=H[xm]=H[Cm]=H[wm]=H[Dm]=H[Nm]=H[Pm]=H[Em]=!0,H[hm]=H[Nr]=H[$m]=!1;function kt(e,t,o,r,s,a){var l,c=t&cm,u=t&um,p=t&dm;if(o&&(l=s?o(e,r,s,a):o(e)),l!==void 0)return l;if(!sm(e))return e;var f=om(e);if(f){if(l=Rp(e),!c)return qp(e,l)}else{var g=Xp(e),x=g==Nr||g==ym;if(rm(e))return Kp(e,c);if(g==Pr||g==Dr||x&&!s){if(l=u||x?{}:tm(e),!c)return u?Yp(e,Hp(l,e)):Jp(e,Gp(l,e))}else{if(!H[g])return s?e:{};l=em(e,g,c)}}a||(a=new zp);var h=a.get(e);if(h)return h;a.set(e,l),am(e)?e.forEach(function(w){l.add(kt(w,t,o,w,e,a))}):nm(e)&&e.forEach(function(w,T){l.set(T,kt(w,t,o,T,e,a))});var m=p?u?Qp:Zp:u?lm:im,k=f?void 0:m(e);return Wp(k||e,function(w,T){k&&(T=w,w=e[T]),Up(l,T,kt(w,t,o,T,e,a))}),l}var Mm=kt,_m=ze,jm=Ie,Bm="[object Symbol]";function Vm(e){return typeof e=="symbol"||jm(e)&&_m(e)==Bm}var mo=Vm,Lm=De,zm=mo,Wm=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Um=/^\w*$/;function Gm(e,t){if(Lm(e))return!1;var o=typeof e;return o=="number"||o=="symbol"||o=="boolean"||e==null||zm(e)?!0:Um.test(e)||!Wm.test(e)||t!=null&&e in Object(t)}var Hm=Gm,Er=Zo,Km="Expected a function";function fo(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Km);var o=function(){var r=arguments,s=t?t.apply(this,r):r[0],a=o.cache;if(a.has(s))return a.get(s);var l=e.apply(this,r);return o.cache=a.set(s,l)||a,l};return o.cache=new(fo.Cache||Er),o}fo.Cache=Er;var qm=fo,Jm=qm,Ym=500;function Zm(e){var t=Jm(e,function(r){return o.size===Ym&&o.clear(),r}),o=t.cache;return t}var Qm=Zm,Xm=Qm,Rm=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ef=/\\(\\)?/g,tf=Xm(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Rm,function(o,r,s,a){t.push(s?a.replace(ef,"$1"):r||o)}),t}),of=tf,Mr=ot,rf=Bo,nf=De,sf=mo,af=1/0,_r=Mr?Mr.prototype:void 0,jr=_r?_r.toString:void 0;function Br(e){if(typeof e=="string")return e;if(nf(e))return rf(e,Br)+"";if(sf(e))return jr?jr.call(e):"";var t=e+"";return t=="0"&&1/e==-af?"-0":t}var lf=Br,cf=lf;function uf(e){return e==null?"":cf(e)}var df=uf,pf=De,mf=Hm,ff=of,hf=df;function yf(e,t){return pf(e)?e:mf(e,t)?[e]:ff(hf(e))}var ho=yf;function gf(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var vf=gf,bf=mo,xf=1/0;function Cf(e){if(typeof e=="string"||bf(e))return e;var t=e+"";return t=="0"&&1/e==-xf?"-0":t}var Vr=Cf,wf=ho,$f=Vr;function Sf(e,t){t=wf(t,e);for(var o=0,r=t.length;e!=null&&o<r;)e=e[$f(t[o++])];return o&&o==r?e:void 0}var kf=Sf;function Af(e,t,o){var r=-1,s=e.length;t<0&&(t=-t>s?0:s+t),o=o>s?s:o,o<0&&(o+=s),s=t>o?0:o-t>>>0,t>>>=0;for(var a=Array(s);++r<s;)a[r]=e[r+t];return a}var Tf=Af,Of=kf,Ff=Tf;function If(e,t){return t.length<2?e:Of(e,Ff(t,0,-1))}var Df=If,Nf=ho,Pf=vf,Ef=Df,Mf=Vr;function _f(e,t){return t=Nf(t,e),e=Ef(e,t),e==null||delete e[Mf(Pf(t))]}var jf=_f,Bf=ze,Vf=no,Lf=Ie,zf="[object Object]",Wf=Function.prototype,Uf=Object.prototype,Lr=Wf.toString,Gf=Uf.hasOwnProperty,Hf=Lr.call(Object);function Kf(e){if(!Lf(e)||Bf(e)!=zf)return!1;var t=Vf(e);if(t===null)return!0;var o=Gf.call(t,"constructor")&&t.constructor;return typeof o=="function"&&o instanceof o&&Lr.call(o)==Hf}var qf=Kf,Jf=qf;function Yf(e){return Jf(e)?void 0:e}var Zf=Yf,zr=ot,Qf=rr,Xf=De,Wr=zr?zr.isConcatSpreadable:void 0;function Rf(e){return Xf(e)||Qf(e)||!!(Wr&&e&&e[Wr])}var eh=Rf,th=ro,oh=eh;function Ur(e,t,o,r,s){var a=-1,l=e.length;for(o||(o=oh),s||(s=[]);++a<l;){var c=e[a];t>0&&o(c)?t>1?Ur(c,t-1,o,r,s):th(s,c):r||(s[s.length]=c)}return s}var rh=Ur,nh=rh;function sh(e){var t=e==null?0:e.length;return t?nh(e,1):[]}var ah=sh;function ih(e,t,o){switch(o.length){case 0:return e.call(t);case 1:return e.call(t,o[0]);case 2:return e.call(t,o[0],o[1]);case 3:return e.call(t,o[0],o[1],o[2])}return e.apply(t,o)}var lh=ih,ch=lh,Gr=Math.max;function uh(e,t,o){return t=Gr(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,a=Gr(r.length-t,0),l=Array(a);++s<a;)l[s]=r[t+s];s=-1;for(var c=Array(t+1);++s<t;)c[s]=r[s];return c[t]=o(l),ch(e,this,c)}}var dh=uh;function ph(e){return function(){return e}}var mh=ph;function fh(e){return e}var hh=fh,yh=mh,Hr=Qo,gh=hh,vh=Hr?function(e,t){return Hr(e,"toString",{configurable:!0,enumerable:!1,value:yh(t),writable:!0})}:gh,bh=vh,xh=800,Ch=16,wh=Date.now;function $h(e){var t=0,o=0;return function(){var r=wh(),s=Ch-(r-o);if(o=r,s>0){if(++t>=xh)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var Sh=$h,kh=bh,Ah=Sh,Th=Ah(kh),Oh=Th,Fh=ah,Ih=dh,Dh=Oh;function Nh(e){return Dh(Ih(e,void 0,Fh),e+"")}var Ph=Nh,Eh=Bo,Mh=Mm,_h=jf,jh=ho,Bh=st,Vh=Zf,Lh=Ph,zh=hr,Wh=1,Uh=2,Gh=4,Hh=Lh(function(e,t){var o={};if(e==null)return o;var r=!1;t=Eh(t,function(a){return a=jh(a,e),r||(r=a.length>1),a}),Bh(e,zh(e),o),r&&(o=Mh(o,Wh|Uh|Gh,Vh));for(var s=t.length;s--;)_h(o,t[s]);return o}),Kh=Hh;const qh=Eo(Kh),Kr={title:`{{t("Form event", { ns: "${d}" })}}`,type:"form",description:`{{t("Event triggers when submitted a workflow bound form action.", { ns: "${d}" })}}`,fieldset:{collection:C(v({},de),{title:`{{t("Form data model", { ns: "${d}" })}}`,description:`{{t("Use a collection to match form data.", { ns: "${d}" })}}`,"x-reactions":[...de["x-reactions"],{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),appends:C(v({},Be),{title:`{{t("Associations to use", { ns: "${d}" })}}`})},scope:{useCollectionDataSource:i.useCollectionDataSource},components:{},useVariables(e,t){var l;const o=i.useCompile(),{getCollectionFields:r}=i.useCollectionManager(),s=[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:N("Trigger data")}},{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:N("User submitted form")}}];return be(C(v({appends:["data","user",...((l=e.appends)==null?void 0:l.map(c=>`data.${c}`))||[]]},t),{fields:s,compile:o,getCollectionFields:r}))},useInitializers(e){return e.collection?{type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${d}" })}}`,component:_e,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{},useActionTriggerable:!0};function Jh({filterByTk:e,form:t,getField:o,actionFields:r}){if(e&&r){const s=Object.keys(t.values).filter(a=>{const l=o(a);return!r.includes(a)&&["hasOne","hasMany","belongsTo","belongsToMany"].includes(l==null?void 0:l.type)});return qh(v({},t.values),s)}return t.values}function Yh(){var _;const e=i.useAPIClient(),t=F.useForm(),{field:o,resource:r,__parent:s}=i.useBlockRequestContext(),{setVisible:a,fieldSchema:l}=i.useActionContext(),c=he.useNavigate(),u=F.useFieldSchema(),p=F.useField(),{fields:f,getField:g,getTreeParentField:x}=i.useCollection(),h=i.useCompile(),m=i.useFilterByTk(),k=i.useRecord(),w=i.useCurrentUserContext(),{modal:T}=b.App.useApp(),{getActiveFieldsName:$}=i.useFormActiveFields()||{},D=(_=w==null?void 0:w.data)==null?void 0:_.data,M=p.componentProps.filterKeys||[];return{onClick(){return J(this,null,function*(){var L,ie,Y,Q,R,ne;const{assignedValues:P={},onSuccess:A,overwriteValues:I,skipValidator:U,triggerWorkflows:V}=(L=u==null?void 0:u["x-action-settings"])!=null?L:{},Z=(ie=l==null?void 0:l["x-component-props"])==null?void 0:ie.addChild,E=X.parse(P)({currentTime:new Date,currentRecord:k,currentUser:D,$user:D,$nRecord:k,$nForm:t.values,$nDate:{now:new Date}});U||(yield t.submit());const j=Jh({filterByTk:m,form:t,getField:g,actionFields:($==null?void 0:$("form"))||[]});if(Z){const ue=x();j[(Y=ue==null?void 0:ue.name)!=null?Y:"parent"]=k,j[(Q=ue==null?void 0:ue.foreignKey)!=null?Q:"parentId"]=k.id}p.data=o.data||{},p.data.loading=!0;try{const ue=yield e.resource("workflows").trigger({values:v(v(v({},j),I),E),filterKeys:M,triggerWorkflows:V!=null&&V.length?V.map(me=>[me.workflowKey,me.context].filter(Boolean).join("!")).join(","):void 0});if(p.data.loading=!1,p.data.data=ue,(ne=(R=s==null?void 0:s.service)==null?void 0:R.refresh)==null||ne.call(R),a==null||a(!1),!(A!=null&&A.successMessage))return;A!=null&&A.manualClose?T.success({title:h(A==null?void 0:A.successMessage),onOk:()=>J(this,null,function*(){yield t.reset(),A!=null&&A.redirecting&&(A!=null&&A.redirectTo)&&(X.isURL(A.redirectTo)?window.location.href=A.redirectTo:c(A.redirectTo))})}):b.message.success(h(A==null?void 0:A.successMessage))}catch(ue){p.data.loading=!1}})}}}const Pe={STATIC:0,COLLECTION_FIELD:1};function Zh(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function qr({value:e,onChange:t}){const{t:o}=oe.useTranslation(),[r,s]=y.useState(e.offset?e.offset/Math.abs(e.offset):0);return n.jsxs("fieldset",{className:i.css`
|
|
400
|
+
`}},dynamicComponent:"FilterDynamicComponent"}},un={type:"array",title:'{{t("Sort")}}',"x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:"{{useSortableFields()}}",required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:'{{t("ASC")}}',value:"asc"},{label:'{{t("DESC")}}',value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{t("Add sort field")}}',"x-component":"ArrayItems.Addition"}}},pn={type:"void",title:'{{t("Pagination")}}',"x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{page:{type:"void","x-component":"Grid.Col",properties:{page:{type:"number",title:'{{t("Page number")}}',"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:["number","null"]},default:1}}},pageSize:{type:"void","x-component":"Grid.Col",properties:{pageSize:{type:"number",title:'{{t("Page size")}}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:1,max:100},default:20}}}}}}},De={type:"array",title:`{{t("Preload associations", { ns: "${u}" })}}`,description:`{{t("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution.", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=T.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},Ie={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},mn=[{label:`{{t("After record added", { ns: "${u}" })}}`,value:Ie.CREATED},{label:`{{t("After record updated", { ns: "${u}" })}}`,value:Ie.UPDATED},{label:`{{t("After record added or updated", { ns: "${u}" })}}`,value:Ie.SAVED},{label:`{{t("After record deleted", { ns: "${u}" })}}`,value:Ie.DELETED}],Go={title:`{{t("Collection event", { ns: "${u}" })}}`,type:"collection",description:`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${u}" })}}`,fieldset:{collection:C(g({},ae),{"x-reactions":[...ae["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${u}" })}}`,className:"auto-width"},enum:mn,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${u}" })}}`,description:`{{t("Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(e){return!e.hidden&&(e.uiSchema?!e.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(e.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Ie.UPDATED})}}`}}}]},condition:C(g({},$e),{title:`{{t("Only triggers when match conditions", { ns: "${u}" })}}`,"x-component-props":{useProps:$e["x-component-props"].useProps},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:C(g({},De),{"x-reactions":[...De["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Ie.DELETED})}}`}}}]})},scope:{useCollectionDataSource:l.useCollectionDataSource},components:{FieldsSelect:wo},useVariables(e,o){var a;const n=l.useCompile(),{getCollectionFields:t}=l.useCollectionManager(),s=[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:D("Trigger data")}}];return fe(C(g({appends:["data",...((a=e.appends)==null?void 0:a.map(c=>`data.${c}`))||[]]},o),{fields:s,compile:n,getCollectionFields:t}))},useInitializers(e){return e.collection?{type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${u}" })}}`,component:Te,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{}},Jo={title:`{{t("Form event", { ns: "${u}" })}}`,type:"form",description:`{{t("Event triggers when submitted a workflow bound form action.", { ns: "${u}" })}}`,fieldset:{collection:C(g({},ae),{title:`{{t("Form data model", { ns: "${u}" })}}`,description:`{{t("Use a collection to match form data.", { ns: "${u}" })}}`,"x-reactions":[...ae["x-reactions"],{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),appends:C(g({},De),{title:`{{t("Associations to use", { ns: "${u}" })}}`})},scope:{useCollectionDataSource:l.useCollectionDataSource},components:{},useVariables(e,o){var a;const n=l.useCompile(),{getCollectionFields:t}=l.useCollectionManager(),s=[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:D("Trigger data")}},{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:D("User submitted form")}}];return fe(C(g({appends:["data","user",...((a=e.appends)==null?void 0:a.map(c=>`data.${c}`))||[]]},o),{fields:s,compile:n,getCollectionFields:t}))},useInitializers(e){return e.collection?{type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${u}" })}}`,component:Te,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{},useActionTriggerable:!0};function fn(){const e=l.useAPIClient(),o=T.useForm(),{field:n,__parent:t}=l.useBlockRequestContext(),{setVisible:s}=l.useActionContext(),i=ue.useNavigate(),a=T.useFieldSchema(),c=T.useField(),d=l.useCompile(),{modal:p}=b.App.useApp(),f=l.useCollectValuesToSubmit(),x=c.componentProps.filterKeys||[];return{onClick(){return H(this,null,function*(){var A,w,$;const{onSuccess:h,skipValidator:m,triggerWorkflows:S}=(A=a==null?void 0:a["x-action-settings"])!=null?A:{};m||(yield o.submit());const F=yield f();c.data=n.data||{},c.data.loading=!0;try{const P=yield e.resource("workflows").trigger({values:F,filterKeys:x,triggerWorkflows:S!=null&&S.length?S.map(B=>[B.workflowKey,B.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.loading=!1,c.data.data=P,($=(w=t==null?void 0:t.service)==null?void 0:w.refresh)==null||$.call(w),s==null||s(!1),!(h!=null&&h.successMessage))return;h!=null&&h.manualClose?p.success({title:d(h==null?void 0:h.successMessage),onOk:()=>H(this,null,function*(){yield o.reset(),h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(K.isURL(h.redirectTo)?window.location.href=h.redirectTo:i(h.redirectTo))})}):b.message.success(d(h==null?void 0:h.successMessage))}catch(P){c.data.loading=!1}})}}}const Fe={STATIC:0,COLLECTION_FIELD:1};function hn(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function Ho({value:e,onChange:o}){const{t:n}=R.useTranslation(),[t,s]=y.useState(e.offset?e.offset/Math.abs(e.offset):0);return r.jsxs("fieldset",{className:l.css`
|
|
401
401
|
display: flex;
|
|
402
402
|
gap: 0.5em;
|
|
403
|
-
`,children:[
|
|
403
|
+
`,children:[r.jsx(wo,{value:e.field,onChange:i=>o(C(g({},e),{field:i})),filter:hn,placeholder:n("Select field")}),e.field?r.jsx(b.Select,{value:t,onChange:i=>{s(i),o(C(g({},e),{offset:Math.abs(e.offset)*i}))},options:[{value:0,label:D("Exactly at")},{value:-1,label:n("Before")},{value:1,label:n("After")}]}):null,t?r.jsxs(r.Fragment,{children:[r.jsx(b.InputNumber,{value:Math.abs(e.offset),onChange:i=>o(C(g({},e),{offset:(i!=null?i:0)*t}))}),r.jsx(b.Select,{value:e.unit||864e5,onChange:i=>o(C(g({},e),{unit:i})),options:[{value:864e5,label:D("Days")},{value:36e5,label:D("Hours")},{value:6e4,label:D("Minutes")},{value:1e3,label:D("Seconds")}]})]}):null]})}function yn({value:e,onChange:o}){const{t:n}=vo(),t=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return r.jsxs("fieldset",{className:l.css`
|
|
404
404
|
display: flex;
|
|
405
405
|
gap: 0.5em;
|
|
406
|
-
`,children:[n.jsxs(b.Select,{value:r,onChange:s=>{t(s?s==="field"?{}:new Date:null)},children:[n.jsx(b.Select.Option,{value:null,children:o("No end")}),n.jsx(b.Select.Option,{value:"field",children:o("By field")}),n.jsx(b.Select.Option,{value:"date",children:o("By custom date")})]}),r==="field"?n.jsx(qr,{value:e,onChange:t}):null,r==="date"?n.jsx(b.DatePicker,{showTime:!0,value:No(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var ce=function(){return ce=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var s in t=arguments[o])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},ce.apply(this,arguments)};function Jr(e,t){var o={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(o[r[s]]=e[r[s]])}return o}function At(e,t,o){if(o||arguments.length===2)for(var r,s=0,a=t.length;s<a;s++)!r&&s in t||(r||(r=Array.prototype.slice.call(t,0,s)),r[s]=t[s]);return e.concat(r||Array.prototype.slice.call(t))}var Xh=[{name:"@yearly",value:"0 0 1 1 *"},{name:"@annually",value:"0 0 1 1 *"},{name:"@monthly",value:"0 0 1 * *"},{name:"@weekly",value:"0 0 * * 0"},{name:"@daily",value:"0 0 * * *"},{name:"@midnight",value:"0 0 * * *"},{name:"@hourly",value:"0 * * * *"}],Ee=[{type:"minutes",min:0,max:59,total:60},{type:"hours",min:0,max:23,total:24},{type:"month-days",min:1,max:31,total:31},{type:"months",min:1,max:12,total:12,alt:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]},{type:"week-days",min:0,max:6,total:7,alt:["SUN","MON","TUE","WED","THU","FRI","SAT"]}],B={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function Yr(e,t){for(var o=[],r=e;r<=t;r++)o.push(r);return o}function Tt(e){return e.sort(function(t,o){return t-o}),e}function Zr(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function fe(e){return Object.entries(e).filter(function(t){var o=t[0],r=t[1];return o&&r}).map(function(t){return t[0]}).join(" ")}function Qr(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||B.errorInvalidCron})}function Ot(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function Xr(e,t,o,r,s,a,l,c,u,p,f,g,x,h){o&&o(void 0),t(!1);var m=!1;if(!e){if(r==="always"||a&&r==="for-default-value")return;m=!0}if(!m){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void h("reboot");var k=Xh.find(function($){return $.name===e});k&&(e=k.value)}try{var w=function($){if(typeof $!="string")throw new Error("Invalid cron string");var D=$.replace(/\s+/g," ").trim().split(" ");if(D.length===5)return D.map(function(M,_){return function(z,P){if(z==="*"||z==="*/1")return[];var A=Tt(Zr(on(function(U,V,Z){if(Z){U=U.toUpperCase();for(var E=0;E<Z.length;E++)U=U.replace(Z[E],"".concat(E+V))}return U}(z,P.min,P.alt).split(",").map(function(U){var V,Z=U.split("/");if(Z.length>2)throw new Error('Invalid value "'.concat(z,' for "').concat(P.type,'"'));var E=Z[0],j=Z[1];V=E==="*"?Yr(P.min,P.max):function(Y,Q,R){var ne=Y.split("-");if(ne.length===1){var ue=Ot(ne[0]);if(isNaN(ue))throw new Error('Invalid value "'.concat(Q,'" for ').concat(R.type));return[ue]}if(ne.length===2){var me=Ot(ne[0]),Ze=Ot(ne[1]);if(isNaN(me)||isNaN(Ze))throw new Error('Invalid value "'.concat(Q,'" for ').concat(R.type));if(Ze<me)throw new Error('Max range is less than min range in "'.concat(Y,'" for ').concat(R.type));return Yr(me,Ze)}throw new Error('Invalid value "'.concat(Y,'" for ').concat(R.type))}(E,z,P);var L=function(Y,Q){if(Y!==void 0){var R=Ot(Y);if(isNaN(R)||R<1)throw new Error('Invalid interval step value "'.concat(Y,'" for ').concat(Q.type));return R}}(j,P),ie=function(Y,Q){if(Q){var R=Y[0];Y=Y.filter(function(ne){return ne%Q==R%Q||ne===R})}return Y}(V,L);return ie}).flat(),P))),I=rn(A,P);if(I!==void 0)throw new Error('Value "'.concat(I,'" out of range for ').concat(P.type));return A.length===P.total?[]:A}(M,Ee[_])});throw new Error("Invalid cron string format")}(e),T=function($){return $[3].length>0?"year":$[2].length>0?"month":$[4].length>0?"week":$[1].length>0?"day":$[0].length>0?"hour":"minute"}(w);h(T),u(w[0]),p(w[1]),f(w[2]),g(w[3]),x(w[4])}catch($){m=!0}}m&&(s.current=e,t(!0),Qr(o,l))}function Rr(e,t,o,r,s,a,l){if(e==="reboot")return"@reboot";var c=function(u,p){return u.map(function(f,g){var x=Ee[g];return en(tn(f,x),x,p)})}([e!=="minute"&&a?a:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!r?[]:r],l);return c.join(" ")}function en(e,t,o,r,s){var a="";if(function(c,u){return c.length===u.max-u.min+1}(e,t)||e.length===0)a="*";else{var l=function(c){if(c.length>2){var u=c[1]-c[0];if(u>1)return u}}(e);a=l&&function(c,u){for(var p=1;p<c.length;p++){var f=c[p-1];if(c[p]-f!==u)return!1}return!0}(e,l)?function(c,u,p){var f=nn(c),g=sn(c),x=c.length===(g-f)/p+1;return!!(f===u.min&&g+p>u.max&&x)}(e,t,l)?"*/".concat(l):"".concat(Ke(nn(e),t,o,r,s),"-").concat(Ke(sn(e),t,o,r,s),"/").concat(l):function(c){var u=[],p=null;return c.forEach(function(f,g,x){f!==x[g+1]-1?p!==null?(u.push([p,f]),p=null):u.push(f):p===null&&(p=f)}),u}(e).map(function(c){return Array.isArray(c)?"".concat(Ke(c[0],t,o,r,s),"-").concat(Ke(c[1],t,o,r,s)):Ke(c,t,o,r,s)}).join(",")}return a}function Ke(e,t,o,r,s){var a=e.toString(),l=t.type,c=t.alt,u=t.min,p=r&&(r===!0||r.includes(l)),f=s==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?a=c[e-u]:e<10&&(p||f)&&(a=a.padStart(2,"0")),l==="hours"&&s==="12-hour-clock"){var g=e>=12?"PM":"AM",x=e%12||12;x<10&&p&&(x=x.toString().padStart(2,"0")),a="".concat(x).concat(g)}return a}function tn(e,t){var o=Tt(Zr(on(e,t)));if(o.length===0)return o;var r=rn(o,t);if(r!==void 0)throw new Error('Value "'.concat(r,'" out of range for ').concat(t.type));return o}function on(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function rn(e,t){var o=e[0],r=e[e.length-1];return o<t.min?o:r>t.max?r:void 0}function nn(e){return e[0]}function sn(e){return e[e.length-1]}function at(e){var t=e.value,o=e.grid,r=o===void 0||o,s=e.optionsList,a=e.setValue,l=e.locale,c=e.className,u=e.humanizeLabels,p=e.disabled,f=e.readOnly,g=e.leadingZero,x=e.clockFormat,h=e.period,m=e.unit,k=e.periodicityOnDoubleClick,w=e.mode,T=Jr(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),$=y.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(E){return E.toString()})},[t]),D=y.useMemo(function(){return s?s.map(function(E,j){return{value:(m.min===0?j:j+1).toString(),label:E}}):At([],Array(m.total),!0).map(function(E,j){var L=m.min===0?j:j+1;return{value:L.toString(),label:Ke(L,m,u,g,x)}})},[s,g,u,x]),M=JSON.stringify(l),_=y.useCallback(function(E){var j=E.value;if(!t||t[0]!==Number(j))return n.jsx(n.Fragment,{});var L=en(tn(t,m),m,u,g,x),ie=L.match(/^\*\/([0-9]+),?/)||[];return n.jsx("div",{children:ie[1]?"".concat(l.everyText||B.everyText," ").concat(ie[1]):L})},[t,M,u,g,x]),z=y.useCallback(function(E){var j=Array.isArray(E)?Tt(E):[E],L=j;t&&(L=w==="single"?[]:At([],t,!0),j.forEach(function(ie){var Y=Number(ie);L=t.some(function(Q){return Q===Y})?L.filter(function(Q){return Q!==Y}):Tt(At(At([],L,!0),[Y],!1))})),L.length===m.total?a([]):a(L)},[a,t]),P=y.useCallback(function(E){if(E!==0&&E!==1){for(var j=m.total+m.min,L=[],ie=m.min;ie<j;ie++)ie%E==0&&L.push(ie);var Y=t&&L&&t.length===L.length&&t.every(function(R,ne){return R===L[ne]}),Q=L.length===D.length;a(Q||Y?[]:L)}else a([])},[t,D,a]),A=y.useRef([]),I=y.useCallback(function(E){if(!f){var j=A.current;j.push({time:new Date().getTime(),value:Number(E)});var L=window.setTimeout(function(){k&&j.length>1&&j[j.length-1].time-j[j.length-2].time<300?j[j.length-1].value===j[j.length-2].value?P(Number(E)):z([j[j.length-2].value,j[j.length-1].value]):z(Number(E)),A.current=[]},300);return function(){window.clearTimeout(L)}}},[A,z,P,f,k]),U=y.useCallback(function(){f||a([])},[a,f]),V=y.useMemo(function(){var E;return fe(((E={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,E))},[c]),Z=y.useMemo(function(){var E;return fe(((E={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(m.type)]=!0,E["react-js-cron-custom-select-dropdown"]=!0,E["react-js-cron-custom-select-dropdown-".concat(m.type)]=!0,E["react-js-cron-custom-select-dropdown-minutes-large"]=m.type==="minutes"&&h!=="hour"&&h!=="day",E["react-js-cron-custom-select-dropdown-minutes-medium"]=m.type==="minutes"&&(h==="day"||h==="hour"),E["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=m.type==="hours"&&x==="12-hour-clock",E["react-js-cron-custom-select-dropdown-grid"]=!!r,E["".concat(c,"-select-dropdown")]=!!c,E["".concat(c,"-select-dropdown-").concat(m.type)]=!!c,E))},[c,r,x,h]);return n.jsx(b.Select,ce({mode:w!=="single"||k?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:$,onClear:U,tagRender:_,className:V,popupClassName:Z,options:D,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:I,onDeselect:I,disabled:p,dropdownAlign:m.type!=="minutes"&&m.type!=="hours"||h==="day"||h==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(m.type)},T))}function Rh(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,p=e.period,f=e.periodicityOnDoubleClick,g=e.mode,x=y.useMemo(function(){var h;return fe(((h={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-hours")]=!!s,h))},[s]);return n.jsxs("div",ce({className:x},{children:[r.prefixHours!==""&&n.jsx("span",{children:r.prefixHours||B.prefixHours}),n.jsx(at,{placeholder:r.emptyHours||B.emptyHours,value:t,unit:Ee[1],setValue:o,locale:r,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:p,periodicityOnDoubleClick:f,mode:g})]}))}function ey(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,p=e.period,f=e.periodicityOnDoubleClick,g=e.mode,x=y.useMemo(function(){var h;return fe(((h={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-minutes")]=!!s,h))},[s]);return n.jsxs("div",ce({className:x},{children:[p==="hour"?r.prefixMinutesForHourPeriod!==""&&n.jsx("span",{children:r.prefixMinutesForHourPeriod||B.prefixMinutesForHourPeriod}):r.prefixMinutes!==""&&n.jsx("span",{children:r.prefixMinutes||B.prefixMinutes}),n.jsx(at,{placeholder:p==="hour"?r.emptyMinutesForHourPeriod||B.emptyMinutesForHourPeriod:r.emptyMinutes||B.emptyMinutes,value:t,unit:Ee[0],setValue:o,locale:r,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:p,periodicityOnDoubleClick:f,mode:g}),p==="hour"&&r.suffixMinutesForHourPeriod!==""&&n.jsx("span",{children:r.suffixMinutesForHourPeriod||B.suffixMinutesForHourPeriod})]}))}function ty(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.weekDays,l=e.disabled,c=e.readOnly,u=e.leadingZero,p=e.period,f=e.periodicityOnDoubleClick,g=e.mode,x=!a||a.length===0,h=y.useMemo(function(){var w;return fe(((w={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!x})["".concat(s,"-field")]=!!s,w["".concat(s,"-month-days")]=!!s,w))},[s,x]),m=JSON.stringify(r),k=y.useMemo(function(){return x?r.emptyMonthDays||B.emptyMonthDays:r.emptyMonthDaysShort||B.emptyMonthDaysShort},[x,m]);return!c||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?n.jsxs("div",ce({className:h},{children:[r.prefixMonthDays!==""&&n.jsx("span",{children:r.prefixMonthDays||B.prefixMonthDays}),n.jsx(at,{placeholder:k,value:t,setValue:o,unit:Ee[2],locale:r,className:s,disabled:l,readOnly:c,leadingZero:u,period:p,periodicityOnDoubleClick:f,mode:g})]})):null}function oy(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.humanizeLabels,l=e.disabled,c=e.readOnly,u=e.period,p=e.periodicityOnDoubleClick,f=e.mode,g=r.months||B.months,x=y.useMemo(function(){var h;return fe(((h={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-months")]=!!s,h))},[s]);return n.jsxs("div",ce({className:x},{children:[r.prefixMonths!==""&&n.jsx("span",{children:r.prefixMonths||B.prefixMonths}),n.jsx(at,{placeholder:r.emptyMonths||B.emptyMonths,optionsList:g,grid:!1,value:t,unit:ce(ce({},Ee[3]),{alt:r.altMonths||B.altMonths}),setValue:o,locale:r,className:s,humanizeLabels:a,disabled:l,readOnly:c,period:u,periodicityOnDoubleClick:p,mode:f})]}))}function ry(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.shortcuts,u=e.allowedPeriods,p=[];u.includes("year")&&p.push({value:"year",label:r.yearOption||B.yearOption}),u.includes("month")&&p.push({value:"month",label:r.monthOption||B.monthOption}),u.includes("week")&&p.push({value:"week",label:r.weekOption||B.weekOption}),u.includes("day")&&p.push({value:"day",label:r.dayOption||B.dayOption}),u.includes("hour")&&p.push({value:"hour",label:r.hourOption||B.hourOption}),u.includes("minute")&&p.push({value:"minute",label:r.minuteOption||B.minuteOption}),u.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&p.push({value:"reboot",label:r.rebootOption||B.rebootOption});var f=y.useCallback(function(m){l||o(m)},[o,l]),g=y.useMemo(function(){var m;return fe(((m={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,m["".concat(s,"-period")]=!!s,m))},[s]),x=y.useMemo(function(){var m;return fe(((m={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":r.prefixPeriod===""})["".concat(s,"-select")]=!!s,m))},[s,r.prefixPeriod]),h=y.useMemo(function(){var m;return fe(((m={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,m["".concat(s,"-select-dropdown-period")]=!!s,m))},[s]);return n.jsxs("div",ce({className:g},{children:[r.prefixPeriod!==""&&n.jsx("span",{children:r.prefixPeriod||B.prefixPeriod}),n.jsx(b.Select,{defaultValue:t,value:t,onChange:f,options:p,className:x,popupClassName:h,disabled:a,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(r))]}))}function ny(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.humanizeLabels,l=e.monthDays,c=e.disabled,u=e.readOnly,p=e.period,f=e.periodicityOnDoubleClick,g=e.mode,x=r.weekDays||B.weekDays,h=p==="week"||!l||l.length===0,m=y.useMemo(function(){var D;return fe(((D={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!h})["".concat(s,"-field")]=!!s,D["".concat(s,"-week-days")]=!!s,D))},[s,h]),k=JSON.stringify(r),w=y.useMemo(function(){return h?r.emptyWeekDays||B.emptyWeekDays:r.emptyWeekDaysShort||B.emptyWeekDaysShort},[h,k]),T=p==="week"||!u||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),$=!u||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return T?n.jsxs("div",ce({className:m},{children:[r.prefixWeekDays!==""&&(p==="week"||!$)&&n.jsx("span",{children:r.prefixWeekDays||B.prefixWeekDays}),r.prefixWeekDaysForMonthAndYearPeriod!==""&&p!=="week"&&$&&n.jsx("span",{children:r.prefixWeekDaysForMonthAndYearPeriod||B.prefixWeekDaysForMonthAndYearPeriod}),n.jsx(at,{placeholder:w,optionsList:x,grid:!1,value:t,unit:ce(ce({},Ee[4]),{alt:r.altWeekDays||B.altWeekDays}),setValue:o,locale:r,className:s,humanizeLabels:a,disabled:c,readOnly:u,period:p,periodicityOnDoubleClick:f,mode:g})]})):null}function sy(e){var t=e.clearButton,o=t===void 0||t,r=e.clearButtonProps,s=r===void 0?{}:r,a=e.clearButtonAction,l=a===void 0?"fill-with-every":a,c=e.locale,u=c===void 0?B:c,p=e.value,f=p===void 0?"":p,g=e.setValue,x=e.displayError,h=x===void 0||x,m=e.onError,k=e.className,w=e.defaultPeriod,T=w===void 0?"day":w,$=e.allowEmpty,D=$===void 0?"for-default-value":$,M=e.humanizeLabels,_=M===void 0||M,z=e.humanizeValue,P=z!==void 0&&z,A=e.disabled,I=A!==void 0&&A,U=e.readOnly,V=U!==void 0&&U,Z=e.leadingZero,E=Z!==void 0&&Z,j=e.shortcuts,L=j===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:j,ie=e.clockFormat,Y=e.periodicityOnDoubleClick,Q=Y===void 0||Y,R=e.mode,ne=R===void 0?"multiple":R,ue=e.allowedDropdowns,me=ue===void 0?["period","months","month-days","week-days","hours","minutes"]:ue,Ze=e.allowedPeriods,nv=Ze===void 0?["year","month","week","day","hour","minute","reboot"]:Ze,Qe=y.useRef(f),Oo=y.useRef(T),Wn=y.useState(),we=Wn[0],Pt=Wn[1],Un=y.useState(),dt=Un[0],Et=Un[1],Gn=y.useState(),Mt=Gn[0],_t=Gn[1],Hn=y.useState(),pt=Hn[0],jt=Hn[1],Kn=y.useState(),Bt=Kn[0],Vt=Kn[1],qn=y.useState(),Lt=qn[0],zt=qn[1],Jn=y.useState(!1),Fo=Jn[0],mt=Jn[1],Yn=y.useState(!1),Wt=Yn[0],Zn=Yn[1],sv=function(te){var xe=y.useRef(te);return y.useEffect(function(){xe.current=te},[te]),xe.current}(Wt),Qn=JSON.stringify(u);y.useEffect(function(){Xr(f,mt,m,D,Qe,!0,u,L,zt,Vt,Et,_t,jt,Pt)},[]),y.useEffect(function(){f!==Qe.current&&Xr(f,mt,m,D,Qe,!1,u,L,zt,Vt,Et,_t,jt,Pt)},[f,Qe,Qn,D,L]),y.useEffect(function(){if(!(we||Lt||Mt||dt||pt||Bt)||Wt||sv)Wt&&Zn(!1);else{var te=we||Oo.current,xe=Rr(te,Mt,dt,pt,Bt,Lt,P);g(xe,{selectedPeriod:te}),Qe.current=xe,m&&m(void 0),mt(!1)}},[we,dt,Mt,pt,Bt,Lt,P,Wt]);var Xn=y.useCallback(function(){Et(void 0),_t(void 0),jt(void 0),Vt(void 0),zt(void 0);var te="",xe=we!=="reboot"&&we?we:Oo.current;xe!==we&&Pt(xe),l==="fill-with-every"&&(te=Rr(xe,void 0,void 0,void 0,void 0,void 0)),g(te,{selectedPeriod:xe}),Qe.current=te,Zn(!0),D==="never"&&l==="empty"?(mt(!0),Qr(m,u)):(m&&m(void 0),mt(!1))},[we,g,m,l]),av=y.useMemo(function(){var te;return fe(((te={"react-js-cron":!0,"react-js-cron-error":Fo&&h,"react-js-cron-disabled":I,"react-js-cron-read-only":V})["".concat(k)]=!!k,te["".concat(k,"-error")]=Fo&&h&&!!k,te["".concat(k,"-disabled")]=I&&!!k,te["".concat(k,"-read-only")]=V&&!!k,te))},[k,Fo,h,I,V]),Io=s.className,Rn=Jr(s,["className"]),es=y.useMemo(function(){var te;return fe(((te={"react-js-cron-clear-button":!0})["".concat(k,"-clear-button")]=!!k,te["".concat(Io)]=!!Io,te))},[k,Io]),iv=JSON.stringify(Rn),ts=y.useMemo(function(){return o&&!V?n.jsx(b.Button,ce({className:es,danger:!0,type:"primary",disabled:I},Rn,{onClick:Xn},{children:u.clearButtonText||B.clearButtonText})):null},[o,V,Qn,es,I,iv,Xn]),le=we||Oo.current;return n.jsxs("div",ce({className:av},{children:[me.includes("period")&&n.jsx(ry,{value:le,setValue:Pt,locale:u,className:k,disabled:I,readOnly:V,shortcuts:L,allowedPeriods:nv}),le==="reboot"?ts:n.jsxs(n.Fragment,{children:[le==="year"&&me.includes("months")&&n.jsx(oy,{value:Mt,setValue:_t,locale:u,className:k,humanizeLabels:_,disabled:I,readOnly:V,period:le,periodicityOnDoubleClick:Q,mode:ne}),(le==="year"||le==="month")&&me.includes("month-days")&&n.jsx(ty,{value:dt,setValue:Et,locale:u,className:k,weekDays:pt,disabled:I,readOnly:V,leadingZero:E,period:le,periodicityOnDoubleClick:Q,mode:ne}),(le==="year"||le==="month"||le==="week")&&me.includes("week-days")&&n.jsx(ny,{value:pt,setValue:jt,locale:u,className:k,humanizeLabels:_,monthDays:dt,disabled:I,readOnly:V,period:le,periodicityOnDoubleClick:Q,mode:ne}),n.jsxs("div",{children:[le!=="minute"&&le!=="hour"&&me.includes("hours")&&n.jsx(Rh,{value:Bt,setValue:Vt,locale:u,className:k,disabled:I,readOnly:V,leadingZero:E,clockFormat:ie,period:le,periodicityOnDoubleClick:Q,mode:ne}),le!=="minute"&&me.includes("minutes")&&n.jsx(ey,{value:Lt,setValue:zt,locale:u,period:le,className:k,disabled:I,readOnly:V,leadingZero:E,clockFormat:ie,periodicityOnDoubleClick:Q,mode:ne}),ts]})]})]}))}const ay={"zh-CN":{everyText:"每",emptyMonths:"每月",emptyMonthDays:"每日(月)",emptyMonthDaysShort:"每日",emptyWeekDays:"每天(周)",emptyWeekDaysShort:"每天(周)",emptyHours:"每小时",emptyMinutes:"每分钟",emptyMinutesForHourPeriod:"每",yearOption:"年",monthOption:"月",weekOption:"周",dayOption:"天",hourOption:"小时",minuteOption:"分钟",rebootOption:"重启",prefixPeriod:"每",prefixMonths:"的",prefixMonthDays:"的",prefixWeekDays:"的",prefixWeekDaysForMonthAndYearPeriod:"并且",prefixHours:"的",prefixMinutes:":",prefixMinutesForHourPeriod:"的",suffixMinutesForHourPeriod:"分钟",errorInvalidCron:"不符合 cron 规则的表达式",clearButtonText:"清空",weekDays:["周日","周一","周二","周三","周四","周五","周六"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],altWeekDays:["周日","周一","周二","周三","周四","周五","周六"],altMonths:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},an=[{value:"none",text:"No repeat"},{value:6e4,text:"By minute",unitText:"Minutes"},{value:36e5,text:"By hour",unitText:"Hours"},{value:864e5,text:"By day",unitText:"Days"},{value:6048e5,text:"By week",unitText:"Weeks"},{value:"cron",text:"Advanced"}];function ln(e){return an.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function iy(e){let t;switch(typeof e){case"number":return t=ln(e),t?t.value:"none";case"string":return"cron"}return"none"}function ly({value:e,onChange:t}){const{t:o}=Ht(),r=ln(e);return n.jsx(b.InputNumber,{value:e/r.value,onChange:s=>t(s*r.value),min:1,addonBefore:o("Every"),addonAfter:o(r.unitText),className:"auto-width"})}function cy({value:e=null,onChange:t}){const{t:o}=Ht(),r=iy(e);function s(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const a=ay[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return n.jsxs("fieldset",{className:i.css`
|
|
406
|
+
`,children:[r.jsxs(b.Select,{value:t,onChange:s=>{o(s?s==="field"?{}:new Date:null)},children:[r.jsx(b.Select.Option,{value:null,children:n("No end")}),r.jsx(b.Select.Option,{value:"field",children:n("By field")}),r.jsx(b.Select.Option,{value:"date",children:n("By custom date")})]}),t==="field"?r.jsx(Ho,{value:e,onChange:o}):null,t==="date"?r.jsx(b.DatePicker,{showTime:!0,value:zo(e),onChange:s=>{o(s?s.toDate():null)}}):null]})}var ie=function(){return ie=Object.assign||function(e){for(var o,n=1,t=arguments.length;n<t;n++)for(var s in o=arguments[n])Object.prototype.hasOwnProperty.call(o,s)&&(e[s]=o[s]);return e},ie.apply(this,arguments)};function Yo(e,o){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&o.indexOf(t)<0&&(n[t]=e[t]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(t=Object.getOwnPropertySymbols(e);s<t.length;s++)o.indexOf(t[s])<0&&Object.prototype.propertyIsEnumerable.call(e,t[s])&&(n[t[s]]=e[t[s]])}return n}function eo(e,o,n){if(n||arguments.length===2)for(var t,s=0,i=o.length;s<i;s++)!t&&s in o||(t||(t=Array.prototype.slice.call(o,0,s)),t[s]=o[s]);return e.concat(t||Array.prototype.slice.call(o))}var gn=[{name:"@yearly",value:"0 0 1 1 *"},{name:"@annually",value:"0 0 1 1 *"},{name:"@monthly",value:"0 0 1 * *"},{name:"@weekly",value:"0 0 * * 0"},{name:"@daily",value:"0 0 * * *"},{name:"@midnight",value:"0 0 * * *"},{name:"@hourly",value:"0 * * * *"}],Ae=[{type:"minutes",min:0,max:59,total:60},{type:"hours",min:0,max:23,total:24},{type:"month-days",min:1,max:31,total:31},{type:"months",min:1,max:12,total:12,alt:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]},{type:"week-days",min:0,max:6,total:7,alt:["SUN","MON","TUE","WED","THU","FRI","SAT"]}],V={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function _o(e,o){for(var n=[],t=e;t<=o;t++)n.push(t);return n}function oo(e){return e.sort(function(o,n){return o-n}),e}function Ko(e){var o=[];return e.forEach(function(n){o.indexOf(n)<0&&o.push(n)}),o}function de(e){return Object.entries(e).filter(function(o){var n=o[0],t=o[1];return n&&t}).map(function(o){return o[0]}).join(" ")}function Zo(e,o){e&&e({type:"invalid_cron",description:o.errorInvalidCron||V.errorInvalidCron})}function to(e){var o=parseInt(e,10),n=Number(e);return o===n?n:NaN}function Qo(e,o,n,t,s,i,a,c,d,p,f,x,v,h){n&&n(void 0),o(!1);var m=!1;if(!e){if(t==="always"||i&&t==="for-default-value")return;m=!0}if(!m){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void h("reboot");var S=gn.find(function(w){return w.name===e});S&&(e=S.value)}try{var F=function(w){if(typeof w!="string")throw new Error("Invalid cron string");var $=w.replace(/\s+/g," ").trim().split(" ");if($.length===5)return $.map(function(P,B){return function(L,E){if(L==="*"||L==="*/1")return[];var N=oo(Ko(ot(function(G,J,Y){if(Y){G=G.toUpperCase();for(var M=0;M<Y.length;M++)G=G.replace(Y[M],"".concat(M+J))}return G}(L,E.min,E.alt).split(",").map(function(G){var J,Y=G.split("/");if(Y.length>2)throw new Error('Invalid value "'.concat(L,' for "').concat(E.type,'"'));var M=Y[0],j=Y[1];J=M==="*"?_o(E.min,E.max):function(_,Q,ne){var re=_.split("-");if(re.length===1){var Ye=to(re[0]);if(isNaN(Ye))throw new Error('Invalid value "'.concat(Q,'" for ').concat(ne.type));return[Ye]}if(re.length===2){var he=to(re[0]),Be=to(re[1]);if(isNaN(he)||isNaN(Be))throw new Error('Invalid value "'.concat(Q,'" for ').concat(ne.type));if(Be<he)throw new Error('Max range is less than min range in "'.concat(_,'" for ').concat(ne.type));return _o(he,Be)}throw new Error('Invalid value "'.concat(_,'" for ').concat(ne.type))}(M,L,E);var W=function(_,Q){if(_!==void 0){var ne=to(_);if(isNaN(ne)||ne<1)throw new Error('Invalid interval step value "'.concat(_,'" for ').concat(Q.type));return ne}}(j,E),le=function(_,Q){if(Q){var ne=_[0];_=_.filter(function(re){return re%Q==ne%Q||re===ne})}return _}(J,W);return le}).flat(),E))),I=tt(N,E);if(I!==void 0)throw new Error('Value "'.concat(I,'" out of range for ').concat(E.type));return N.length===E.total?[]:N}(P,Ae[B])});throw new Error("Invalid cron string format")}(e),A=function(w){return w[3].length>0?"year":w[2].length>0?"month":w[4].length>0?"week":w[1].length>0?"day":w[0].length>0?"hour":"minute"}(F);h(A),d(F[0]),p(F[1]),f(F[2]),x(F[3]),v(F[4])}catch(w){m=!0}}m&&(s.current=e,o(!0),Zo(n,a))}function Xo(e,o,n,t,s,i,a){if(e==="reboot")return"@reboot";var c=function(d,p){return d.map(function(f,x){var v=Ae[x];return Ro(et(f,v),v,p)})}([e!=="minute"&&i?i:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!n?[]:n,e==="year"&&o?o:[],e!=="year"&&e!=="month"&&e!=="week"||!t?[]:t],a);return c.join(" ")}function Ro(e,o,n,t,s){var i="";if(function(c,d){return c.length===d.max-d.min+1}(e,o)||e.length===0)i="*";else{var a=function(c){if(c.length>2){var d=c[1]-c[0];if(d>1)return d}}(e);i=a&&function(c,d){for(var p=1;p<c.length;p++){var f=c[p-1];if(c[p]-f!==d)return!1}return!0}(e,a)?function(c,d,p){var f=nt(c),x=rt(c),v=c.length===(x-f)/p+1;return!!(f===d.min&&x+p>d.max&&v)}(e,o,a)?"*/".concat(a):"".concat(Ne(nt(e),o,n,t,s),"-").concat(Ne(rt(e),o,n,t,s),"/").concat(a):function(c){var d=[],p=null;return c.forEach(function(f,x,v){f!==v[x+1]-1?p!==null?(d.push([p,f]),p=null):d.push(f):p===null&&(p=f)}),d}(e).map(function(c){return Array.isArray(c)?"".concat(Ne(c[0],o,n,t,s),"-").concat(Ne(c[1],o,n,t,s)):Ne(c,o,n,t,s)}).join(",")}return i}function Ne(e,o,n,t,s){var i=e.toString(),a=o.type,c=o.alt,d=o.min,p=t&&(t===!0||t.includes(a)),f=s==="24-hour-clock"&&(a==="hours"||a==="minutes");if(n&&a==="week-days"||n&&a==="months"?i=c[e-d]:e<10&&(p||f)&&(i=i.padStart(2,"0")),a==="hours"&&s==="12-hour-clock"){var x=e>=12?"PM":"AM",v=e%12||12;v<10&&p&&(v=v.toString().padStart(2,"0")),i="".concat(v).concat(x)}return i}function et(e,o){var n=oo(Ko(ot(e,o)));if(n.length===0)return n;var t=tt(n,o);if(t!==void 0)throw new Error('Value "'.concat(t,'" out of range for ').concat(o.type));return n}function ot(e,o){return o.type==="week-days"&&(e=e.map(function(n){return n===7?0:n})),e}function tt(e,o){var n=e[0],t=e[e.length-1];return n<o.min?n:t>o.max?t:void 0}function nt(e){return e[0]}function rt(e){return e[e.length-1]}function Ue(e){var o=e.value,n=e.grid,t=n===void 0||n,s=e.optionsList,i=e.setValue,a=e.locale,c=e.className,d=e.humanizeLabels,p=e.disabled,f=e.readOnly,x=e.leadingZero,v=e.clockFormat,h=e.period,m=e.unit,S=e.periodicityOnDoubleClick,F=e.mode,A=Yo(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),w=y.useMemo(function(){if(o&&Array.isArray(o))return o.map(function(M){return M.toString()})},[o]),$=y.useMemo(function(){return s?s.map(function(M,j){return{value:(m.min===0?j:j+1).toString(),label:M}}):eo([],Array(m.total),!0).map(function(M,j){var W=m.min===0?j:j+1;return{value:W.toString(),label:Ne(W,m,d,x,v)}})},[s,x,d,v]),P=JSON.stringify(a),B=y.useCallback(function(M){var j=M.value;if(!o||o[0]!==Number(j))return r.jsx(r.Fragment,{});var W=Ro(et(o,m),m,d,x,v),le=W.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:le[1]?"".concat(a.everyText||V.everyText," ").concat(le[1]):W})},[o,P,d,x,v]),L=y.useCallback(function(M){var j=Array.isArray(M)?oo(M):[M],W=j;o&&(W=F==="single"?[]:eo([],o,!0),j.forEach(function(le){var _=Number(le);W=o.some(function(Q){return Q===_})?W.filter(function(Q){return Q!==_}):oo(eo(eo([],W,!0),[_],!1))})),W.length===m.total?i([]):i(W)},[i,o]),E=y.useCallback(function(M){if(M!==0&&M!==1){for(var j=m.total+m.min,W=[],le=m.min;le<j;le++)le%M==0&&W.push(le);var _=o&&W&&o.length===W.length&&o.every(function(ne,re){return ne===W[re]}),Q=W.length===$.length;i(Q||_?[]:W)}else i([])},[o,$,i]),N=y.useRef([]),I=y.useCallback(function(M){if(!f){var j=N.current;j.push({time:new Date().getTime(),value:Number(M)});var W=window.setTimeout(function(){S&&j.length>1&&j[j.length-1].time-j[j.length-2].time<300?j[j.length-1].value===j[j.length-2].value?E(Number(M)):L([j[j.length-2].value,j[j.length-1].value]):L(Number(M)),N.current=[]},300);return function(){window.clearTimeout(W)}}},[N,L,E,f,S]),G=y.useCallback(function(){f||i([])},[i,f]),J=y.useMemo(function(){var M;return de(((M={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,M))},[c]),Y=y.useMemo(function(){var M;return de(((M={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(m.type)]=!0,M["react-js-cron-custom-select-dropdown"]=!0,M["react-js-cron-custom-select-dropdown-".concat(m.type)]=!0,M["react-js-cron-custom-select-dropdown-minutes-large"]=m.type==="minutes"&&h!=="hour"&&h!=="day",M["react-js-cron-custom-select-dropdown-minutes-medium"]=m.type==="minutes"&&(h==="day"||h==="hour"),M["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=m.type==="hours"&&v==="12-hour-clock",M["react-js-cron-custom-select-dropdown-grid"]=!!t,M["".concat(c,"-select-dropdown")]=!!c,M["".concat(c,"-select-dropdown-").concat(m.type)]=!!c,M))},[c,t,v,h]);return r.jsx(b.Select,ie({mode:F!=="single"||S?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:w,onClear:G,tagRender:B,className:J,popupClassName:Y,options:$,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:I,onDeselect:I,disabled:p,dropdownAlign:m.type!=="minutes"&&m.type!=="hours"||h==="day"||h==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(m.type)},A))}function xn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.disabled,a=e.readOnly,c=e.leadingZero,d=e.clockFormat,p=e.period,f=e.periodicityOnDoubleClick,x=e.mode,v=y.useMemo(function(){var h;return de(((h={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-hours")]=!!s,h))},[s]);return r.jsxs("div",ie({className:v},{children:[t.prefixHours!==""&&r.jsx("span",{children:t.prefixHours||V.prefixHours}),r.jsx(Ue,{placeholder:t.emptyHours||V.emptyHours,value:o,unit:Ae[1],setValue:n,locale:t,className:s,disabled:i,readOnly:a,leadingZero:c,clockFormat:d,period:p,periodicityOnDoubleClick:f,mode:x})]}))}function bn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.disabled,a=e.readOnly,c=e.leadingZero,d=e.clockFormat,p=e.period,f=e.periodicityOnDoubleClick,x=e.mode,v=y.useMemo(function(){var h;return de(((h={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-minutes")]=!!s,h))},[s]);return r.jsxs("div",ie({className:v},{children:[p==="hour"?t.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:t.prefixMinutesForHourPeriod||V.prefixMinutesForHourPeriod}):t.prefixMinutes!==""&&r.jsx("span",{children:t.prefixMinutes||V.prefixMinutes}),r.jsx(Ue,{placeholder:p==="hour"?t.emptyMinutesForHourPeriod||V.emptyMinutesForHourPeriod:t.emptyMinutes||V.emptyMinutes,value:o,unit:Ae[0],setValue:n,locale:t,className:s,disabled:i,readOnly:a,leadingZero:c,clockFormat:d,period:p,periodicityOnDoubleClick:f,mode:x}),p==="hour"&&t.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:t.suffixMinutesForHourPeriod||V.suffixMinutesForHourPeriod})]}))}function vn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.weekDays,a=e.disabled,c=e.readOnly,d=e.leadingZero,p=e.period,f=e.periodicityOnDoubleClick,x=e.mode,v=!i||i.length===0,h=y.useMemo(function(){var F;return de(((F={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!v})["".concat(s,"-field")]=!!s,F["".concat(s,"-month-days")]=!!s,F))},[s,v]),m=JSON.stringify(t),S=y.useMemo(function(){return v?t.emptyMonthDays||V.emptyMonthDays:t.emptyMonthDaysShort||V.emptyMonthDaysShort},[v,m]);return!c||o&&o.length>0||(!o||o.length===0)&&(!i||i.length===0)?r.jsxs("div",ie({className:h},{children:[t.prefixMonthDays!==""&&r.jsx("span",{children:t.prefixMonthDays||V.prefixMonthDays}),r.jsx(Ue,{placeholder:S,value:o,setValue:n,unit:Ae[2],locale:t,className:s,disabled:a,readOnly:c,leadingZero:d,period:p,periodicityOnDoubleClick:f,mode:x})]})):null}function Cn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.humanizeLabels,a=e.disabled,c=e.readOnly,d=e.period,p=e.periodicityOnDoubleClick,f=e.mode,x=t.months||V.months,v=y.useMemo(function(){var h;return de(((h={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-months")]=!!s,h))},[s]);return r.jsxs("div",ie({className:v},{children:[t.prefixMonths!==""&&r.jsx("span",{children:t.prefixMonths||V.prefixMonths}),r.jsx(Ue,{placeholder:t.emptyMonths||V.emptyMonths,optionsList:x,grid:!1,value:o,unit:ie(ie({},Ae[3]),{alt:t.altMonths||V.altMonths}),setValue:n,locale:t,className:s,humanizeLabels:i,disabled:a,readOnly:c,period:d,periodicityOnDoubleClick:p,mode:f})]}))}function wn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.disabled,a=e.readOnly,c=e.shortcuts,d=e.allowedPeriods,p=[];d.includes("year")&&p.push({value:"year",label:t.yearOption||V.yearOption}),d.includes("month")&&p.push({value:"month",label:t.monthOption||V.monthOption}),d.includes("week")&&p.push({value:"week",label:t.weekOption||V.weekOption}),d.includes("day")&&p.push({value:"day",label:t.dayOption||V.dayOption}),d.includes("hour")&&p.push({value:"hour",label:t.hourOption||V.hourOption}),d.includes("minute")&&p.push({value:"minute",label:t.minuteOption||V.minuteOption}),d.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&p.push({value:"reboot",label:t.rebootOption||V.rebootOption});var f=y.useCallback(function(m){a||n(m)},[n,a]),x=y.useMemo(function(){var m;return de(((m={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,m["".concat(s,"-period")]=!!s,m))},[s]),v=y.useMemo(function(){var m;return de(((m={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":t.prefixPeriod===""})["".concat(s,"-select")]=!!s,m))},[s,t.prefixPeriod]),h=y.useMemo(function(){var m;return de(((m={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,m["".concat(s,"-select-dropdown-period")]=!!s,m))},[s]);return r.jsxs("div",ie({className:x},{children:[t.prefixPeriod!==""&&r.jsx("span",{children:t.prefixPeriod||V.prefixPeriod}),r.jsx(b.Select,{defaultValue:o,value:o,onChange:f,options:p,className:v,popupClassName:h,disabled:i,showArrow:!a,open:!a&&void 0,"data-testid":"select-period"},JSON.stringify(t))]}))}function kn(e){var o=e.value,n=e.setValue,t=e.locale,s=e.className,i=e.humanizeLabels,a=e.monthDays,c=e.disabled,d=e.readOnly,p=e.period,f=e.periodicityOnDoubleClick,x=e.mode,v=t.weekDays||V.weekDays,h=p==="week"||!a||a.length===0,m=y.useMemo(function(){var $;return de((($={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!h})["".concat(s,"-field")]=!!s,$["".concat(s,"-week-days")]=!!s,$))},[s,h]),S=JSON.stringify(t),F=y.useMemo(function(){return h?t.emptyWeekDays||V.emptyWeekDays:t.emptyWeekDaysShort||V.emptyWeekDaysShort},[h,S]),A=p==="week"||!d||o&&o.length>0||(!o||o.length===0)&&(!a||a.length===0),w=!d||a&&a.length>0||(!a||a.length===0)&&(!o||o.length===0);return A?r.jsxs("div",ie({className:m},{children:[t.prefixWeekDays!==""&&(p==="week"||!w)&&r.jsx("span",{children:t.prefixWeekDays||V.prefixWeekDays}),t.prefixWeekDaysForMonthAndYearPeriod!==""&&p!=="week"&&w&&r.jsx("span",{children:t.prefixWeekDaysForMonthAndYearPeriod||V.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(Ue,{placeholder:F,optionsList:v,grid:!1,value:o,unit:ie(ie({},Ae[4]),{alt:t.altWeekDays||V.altWeekDays}),setValue:n,locale:t,className:s,humanizeLabels:i,disabled:c,readOnly:d,period:p,periodicityOnDoubleClick:f,mode:x})]})):null}function Sn(e){var o=e.clearButton,n=o===void 0||o,t=e.clearButtonProps,s=t===void 0?{}:t,i=e.clearButtonAction,a=i===void 0?"fill-with-every":i,c=e.locale,d=c===void 0?V:c,p=e.value,f=p===void 0?"":p,x=e.setValue,v=e.displayError,h=v===void 0||v,m=e.onError,S=e.className,F=e.defaultPeriod,A=F===void 0?"day":F,w=e.allowEmpty,$=w===void 0?"for-default-value":w,P=e.humanizeLabels,B=P===void 0||P,L=e.humanizeValue,E=L!==void 0&&L,N=e.disabled,I=N!==void 0&&N,G=e.readOnly,J=G!==void 0&&G,Y=e.leadingZero,M=Y!==void 0&&Y,j=e.shortcuts,W=j===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:j,le=e.clockFormat,_=e.periodicityOnDoubleClick,Q=_===void 0||_,ne=e.mode,re=ne===void 0?"multiple":ne,Ye=e.allowedDropdowns,he=Ye===void 0?["period","months","month-days","week-days","hours","minutes"]:Ye,Be=e.allowedPeriods,ks=Be===void 0?["year","month","week","day","hour","minute","reboot"]:Be,Ve=y.useRef(f),Bo=y.useRef(A),zt=y.useState(),xe=zt[0],lo=zt[1],Wt=y.useState(),_e=Wt[0],ao=Wt[1],Ut=y.useState(),co=Ut[0],uo=Ut[1],qt=y.useState(),Ke=qt[0],po=qt[1],Gt=y.useState(),mo=Gt[0],fo=Gt[1],Jt=y.useState(),ho=Jt[0],yo=Jt[1],Ht=y.useState(!1),Vo=Ht[0],Ze=Ht[1],Yt=y.useState(!1),go=Yt[0],_t=Yt[1],Ss=function(X){var ye=y.useRef(X);return y.useEffect(function(){ye.current=X},[X]),ye.current}(go),Kt=JSON.stringify(d);y.useEffect(function(){Qo(f,Ze,m,$,Ve,!0,d,W,yo,fo,ao,uo,po,lo)},[]),y.useEffect(function(){f!==Ve.current&&Qo(f,Ze,m,$,Ve,!1,d,W,yo,fo,ao,uo,po,lo)},[f,Ve,Kt,$,W]),y.useEffect(function(){if(!(xe||ho||co||_e||Ke||mo)||go||Ss)go&&_t(!1);else{var X=xe||Bo.current,ye=Xo(X,co,_e,Ke,mo,ho,E);x(ye,{selectedPeriod:X}),Ve.current=ye,m&&m(void 0),Ze(!1)}},[xe,_e,co,Ke,mo,ho,E,go]);var Zt=y.useCallback(function(){ao(void 0),uo(void 0),po(void 0),fo(void 0),yo(void 0);var X="",ye=xe!=="reboot"&&xe?xe:Bo.current;ye!==xe&&lo(ye),a==="fill-with-every"&&(X=Xo(ye,void 0,void 0,void 0,void 0,void 0)),x(X,{selectedPeriod:ye}),Ve.current=X,_t(!0),$==="never"&&a==="empty"?(Ze(!0),Zo(m,d)):(m&&m(void 0),Ze(!1))},[xe,x,m,a]),Fs=y.useMemo(function(){var X;return de(((X={"react-js-cron":!0,"react-js-cron-error":Vo&&h,"react-js-cron-disabled":I,"react-js-cron-read-only":J})["".concat(S)]=!!S,X["".concat(S,"-error")]=Vo&&h&&!!S,X["".concat(S,"-disabled")]=I&&!!S,X["".concat(S,"-read-only")]=J&&!!S,X))},[S,Vo,h,I,J]),jo=s.className,Qt=Yo(s,["className"]),Xt=y.useMemo(function(){var X;return de(((X={"react-js-cron-clear-button":!0})["".concat(S,"-clear-button")]=!!S,X["".concat(jo)]=!!jo,X))},[S,jo]),As=JSON.stringify(Qt),Rt=y.useMemo(function(){return n&&!J?r.jsx(b.Button,ie({className:Xt,danger:!0,type:"primary",disabled:I},Qt,{onClick:Zt},{children:d.clearButtonText||V.clearButtonText})):null},[n,J,Kt,Xt,I,As,Zt]),se=xe||Bo.current;return r.jsxs("div",ie({className:Fs},{children:[he.includes("period")&&r.jsx(wn,{value:se,setValue:lo,locale:d,className:S,disabled:I,readOnly:J,shortcuts:W,allowedPeriods:ks}),se==="reboot"?Rt:r.jsxs(r.Fragment,{children:[se==="year"&&he.includes("months")&&r.jsx(Cn,{value:co,setValue:uo,locale:d,className:S,humanizeLabels:B,disabled:I,readOnly:J,period:se,periodicityOnDoubleClick:Q,mode:re}),(se==="year"||se==="month")&&he.includes("month-days")&&r.jsx(vn,{value:_e,setValue:ao,locale:d,className:S,weekDays:Ke,disabled:I,readOnly:J,leadingZero:M,period:se,periodicityOnDoubleClick:Q,mode:re}),(se==="year"||se==="month"||se==="week")&&he.includes("week-days")&&r.jsx(kn,{value:Ke,setValue:po,locale:d,className:S,humanizeLabels:B,monthDays:_e,disabled:I,readOnly:J,period:se,periodicityOnDoubleClick:Q,mode:re}),r.jsxs("div",{children:[se!=="minute"&&se!=="hour"&&he.includes("hours")&&r.jsx(xn,{value:mo,setValue:fo,locale:d,className:S,disabled:I,readOnly:J,leadingZero:M,clockFormat:le,period:se,periodicityOnDoubleClick:Q,mode:re}),se!=="minute"&&he.includes("minutes")&&r.jsx(bn,{value:ho,setValue:yo,locale:d,period:se,className:S,disabled:I,readOnly:J,leadingZero:M,clockFormat:le,periodicityOnDoubleClick:Q,mode:re}),Rt]})]})]}))}const Fn={"zh-CN":{everyText:"每",emptyMonths:"每月",emptyMonthDays:"每日(月)",emptyMonthDaysShort:"每日",emptyWeekDays:"每天(周)",emptyWeekDaysShort:"每天(周)",emptyHours:"每小时",emptyMinutes:"每分钟",emptyMinutesForHourPeriod:"每",yearOption:"年",monthOption:"月",weekOption:"周",dayOption:"天",hourOption:"小时",minuteOption:"分钟",rebootOption:"重启",prefixPeriod:"每",prefixMonths:"的",prefixMonthDays:"的",prefixWeekDays:"的",prefixWeekDaysForMonthAndYearPeriod:"并且",prefixHours:"的",prefixMinutes:":",prefixMinutesForHourPeriod:"的",suffixMinutesForHourPeriod:"分钟",errorInvalidCron:"不符合 cron 规则的表达式",clearButtonText:"清空",weekDays:["周日","周一","周二","周三","周四","周五","周六"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],altWeekDays:["周日","周一","周二","周三","周四","周五","周六"],altMonths:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},st=[{value:"none",text:"No repeat"},{value:6e4,text:"By minute",unitText:"Minutes"},{value:36e5,text:"By hour",unitText:"Hours"},{value:864e5,text:"By day",unitText:"Days"},{value:6048e5,text:"By week",unitText:"Weeks"},{value:"cron",text:"Advanced"}];function it(e){return st.filter(n=>typeof n.value=="number").reverse().find(n=>!(e%n.value))}function An(e){let o;switch(typeof e){case"number":return o=it(e),o?o.value:"none";case"string":return"cron"}return"none"}function On({value:e,onChange:o}){const{t:n}=vo(),t=it(e);return r.jsx(b.InputNumber,{value:e/t.value,onChange:s=>o(s*t.value),min:1,addonBefore:n("Every"),addonAfter:n(t.unitText),className:"auto-width"})}function Tn({value:e=null,onChange:o}){const{t:n}=vo(),t=An(e);function s(a){if(a==="none"){o(null);return}if(a==="cron"){o("0 * * * * *");return}o(a)}const i=Fn[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:l.css`
|
|
407
407
|
display: flex;
|
|
408
|
-
flex-direction: ${
|
|
408
|
+
flex-direction: ${t==="cron"?"column":"row"};
|
|
409
409
|
align-items: flex-start;
|
|
410
410
|
gap: 0.5em;
|
|
411
411
|
|
|
@@ -432,7 +432,7 @@
|
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
434
|
}
|
|
435
|
-
`,children:[
|
|
435
|
+
`,children:[r.jsx(b.Select,{value:t,onChange:s,className:"auto-width",children:st.map(a=>r.jsx(b.Select.Option,{value:a.value,children:n(a.text)},a.value))}),typeof t=="number"?r.jsx(On,{value:e,onChange:o}):null,t==="cron"?r.jsx(Sn,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:a=>o(`0 ${a}`),clearButton:!1,locale:i}):null]})}const $n={[Fe.STATIC]:{startsOn:{type:"datetime",title:`{{t("Starts on", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"datetime",title:`{{t("Ends on", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0}},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${u}" })}}`,min:0}}},[Fe.COLLECTION_FIELD]:{collection:C(g({},ae),{"x-reactions":[...ae["x-reactions"],{target:"startsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}}]}),startsOn:{type:"object",title:`{{t("Starts on", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"OnField","x-reactions":[{target:"repeat",fulfill:{state:{visible:"{{!!$self.value}}"}}}],required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"object",title:`{{t("Ends on", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"EndsByField"},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${u}" })}}`,min:0}},appends:C(g({},De),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${Fe.COLLECTION_FIELD} && $deps[1]}}`}}}]})}},Dn=[{value:Fe.STATIC,label:`{{t("Based on certain date", { ns: "${u}" })}}`},{value:Fe.COLLECTION_FIELD,label:`{{t("Based on date field of collection", { ns: "${u}" })}}`}],In=()=>{const{values:e={},clearFormGraph:o}=T.useForm(),[n,t]=y.useState(e.mode);return T.useFormEffects(()=>{oe.onFieldValueChange("mode",s=>{t(s.value),o("collection"),o("startsOn"),o("repeat"),o("endsOn"),o("limit")})}),r.jsxs(r.Fragment,{children:[r.jsx(l.SchemaComponent,{schema:{type:"number",title:`{{t("Trigger mode", { ns: "${u}" })}}`,name:"mode","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:Dn},required:!0,default:Fe.STATIC}}),r.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`mode-${n}`]:{type:"void","x-component":"fieldset","x-component-props":{className:l.css`
|
|
436
436
|
.ant-input-number {
|
|
437
437
|
width: auto;
|
|
438
438
|
min-width: 6em;
|
|
@@ -441,37 +441,37 @@
|
|
|
441
441
|
.ant-picker {
|
|
442
442
|
width: auto;
|
|
443
443
|
}
|
|
444
|
-
`},properties
|
|
444
|
+
`},properties:$n[n]}}},components:{OnField:Ho,RepeatField:Tn,EndsByField:yn}})]})},lt={title:`{{t("Schedule event", { ns: "${u}" })}}`,type:"schedule",description:`{{t("Event will be scheduled and triggered base on time conditions.", { ns: "${u}" })}}`,fieldset:{config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}},scope:{useCollectionDataSource:l.useCollectionDataSource},components:{ScheduleConfig:In},useVariables(e,o){var i;const n=l.useCompile(),{getCollectionFields:t}=l.useCollectionManager(),s=[];if((!(o!=null&&o.types)||o.types.includes("date"))&&s.push({key:"date",value:"date",label:D("Trigger time")}),e.mode===Fe.COLLECTION_FIELD){const[a]=fe(C(g({appends:["data",...((i=e.appends)==null?void 0:i.map(c=>`data.${c}`))||[]]},o),{fields:[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:D("Trigger data")}}],compile:n,getCollectionFields:t}));a&&s.push(a)}return s},useInitializers(e){return e.collection?{type:"item",title:`{{t("Trigger data", { ns: "${u}" })}}`,component:Te,collection:e.collection,dataSource:"{{$context.data}}"}:null},initializers:{}};function Nn(){var i;const e=T.useForm(),o=l.useAPIClient(),{workflow:n}=(i=U())!=null?i:{},t=l.useActionContext(),{refresh:s}=l.useResourceActionContext();return{run(){return H(this,null,function*(){var c,d;if(n.executed){b.message.error(D("Trigger in executed workflow cannot be modified"));return}yield e.submit(),yield(d=(c=o.resource("workflows")).update)==null?void 0:d.call(c,{filterByTk:n.id,values:{config:e.values}}),t.setFormValueChanged(!1),t.setVisible(!1),s()})}}}const me=new K.Registry;me.register(Jo.type,Jo),me.register(Go.type,Go),me.register(lt.type,lt);function En(){const e=l.useCompile(),{workflow:o,execution:n}=U(),{styles:t}=te();if(!n)return null;const s=me.get(o.type);return r.jsx(l.SchemaComponent,{schema:{type:"void",name:"execution","x-component":"Action","x-component-props":{title:r.jsx(O.InfoOutlined,{}),shape:"circle",size:"small",className:t.nodeJobButtonClass,type:"primary"},properties:{[n.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:n},"x-component":"Action.Modal",title:r.jsxs("div",{className:l.cx(t.nodeTitleClass),children:[r.jsx(b.Tag,{children:e(s.title)}),r.jsx("strong",{children:o.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",n.id]})]}),properties:{createdAt:{type:"string",title:`{{t("Triggered at", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},context:{type:"object",title:`{{t("Trigger variables", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:l.css`
|
|
445
445
|
padding: 1em;
|
|
446
446
|
background-color: #eee;
|
|
447
|
-
`},"x-read-pretty":!0}}}}}})}function
|
|
447
|
+
`},"x-read-pretty":!0}}}}}})}function Mn(){return{form:T.useForm()}}const Pn=()=>{const e=l.useAPIClient(),{workflow:o,refresh:n}=U(),[t,s]=y.useState(""),[i,a]=y.useState(!1),[c,d]=y.useState(!1),{styles:p}=te(),f=l.useCompile(),{title:x,type:v,executed:h}=o,m=me.get(v),S=f(m.title),{fieldset:F,scope:A,components:w}=m,$=h?'{{t("View")}}':'{{t("Configure")}}',P=D("Trigger");y.useEffect(()=>{var I;o&&s((I=o.title)!=null?I:S)},[o]);const B=y.useMemo(()=>{const I=be.cloneDeep(o==null?void 0:o.config);return oe.createForm({initialValues:I,disabled:o==null?void 0:o.executed})},[o]),L=y.useCallback(I=>{a(I),I||B.reset()},[B]),E=y.useCallback(function(I){return H(this,null,function*(){var J,Y;const G=I||S;s(G),G!==x&&(yield(Y=(J=e.resource("workflows")).update)==null?void 0:Y.call(J,{filterByTk:o.id,values:{title:G}}),n())})},[o]),N=y.useCallback(function(I){var J;if(I.target===I.currentTarget){a(!0);return}const G=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let Y=I.target;Y&&Y!==I.currentTarget;Y=Y.parentNode)if(Array.from((J=Y.classList)!=null?J:[]).some(M=>G.has(M))){a(!0),I.stopPropagation();return}},[]);return r.jsxs("div",{role:"button","aria-label":`${P}-${t}`,className:l.cx(p.nodeCardClass),onClick:N,children:[r.jsx("div",{className:l.cx(p.nodeMetaClass,"workflow-node-meta"),children:r.jsx(b.Tag,{color:"gold",children:P})}),r.jsx("div",{children:r.jsx(b.Input.TextArea,{role:"button","aria-label":"textarea",value:t,onChange:I=>s(I.target.value),onBlur:I=>E(I.target.value),autoSize:!0})}),r.jsx(En,{}),r.jsx(l.ActionContextProvider,{value:{visible:i,setVisible:L,formValueChanged:c,setFormValueChanged:d},children:r.jsx(l.FormProvider,{form:B,children:r.jsx(l.SchemaComponent,{scope:C(g({},A),{useFormProviderProps:Mn}),components:w,schema:{name:`workflow-trigger-${o.id}`,type:"void",properties:{config:{type:"void","x-content":$,"x-component":b.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},drawer:{type:"void",title:P,"x-component":"Action.Drawer","x-decorator":"FormV2","x-decorator-props":{useProps:"{{ useFormProviderProps }}"},properties:C(g({},m.description?{description:{type:"void","x-component":Wo,"x-component-props":{label:D("Trigger type"),title:m.title,description:m.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:l.css`
|
|
448
448
|
.ant-select.auto-width {
|
|
449
449
|
width: auto;
|
|
450
450
|
min-width: 6em;
|
|
451
451
|
}
|
|
452
|
-
`},properties:
|
|
452
|
+
`},properties:F},actions:g({},h?{}:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:Nn}}}})})}}}})})})]})};function So(){const{workflow:e}=U();return me.get(e.type)}function Fo(){return Array.from(me.getEntities()).map(t=>{var[e,s]=t,i=s,{title:o}=i,n=z(i,["title"]);return{value:e,label:o,color:"gold",options:n}})}const we={label:"label",value:"value",children:"children"},no={label:`{{t("Node result", { ns: "${u}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const o=ke(),n=Je(o),t=[];return n.forEach(s=>{var c;const i=q.get(s.type),a=(c=i.useVariables)==null?void 0:c.call(i,s,e);a&&t.push(a)}),t}},ro={label:`{{t("Trigger variables", { ns: "${u}" })}}`,value:"$context",useOptions(e){var t,s;const{workflow:o}=U(),n=me.get(o.type);return(s=(t=n==null?void 0:n.useVariables)==null?void 0:t.call(n,o.config,e))!=null?s:null}},Ao={label:`{{t("Scope variables", { ns: "${u}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:o=we,current:n}=e,t=ke(),s=n!=null?n:t,i=Ot(s),a=[];return i.forEach(c=>{var f,x;const d=q.get(c.type),p=(f=d.useScopeVariables)==null?void 0:f.call(d,c,e);p&&a.push({key:c.key,[o.value]:c.key,[o.label]:(x=c.title)!=null?x:`#${c.id}`,[o.children]:p})}),a}},at={label:`{{t("System variables", { ns: "${u}" })}}`,value:"$system",useOptions({types:e,fieldNames:o=we}){return[...!e||e.includes("date")?[{key:"now",[o.label]:D("System time"),[o.value]:"now"}]:[]]}},Ee={boolean:new Set(["checkbox"]),number:new Set(["integer","number","percent"]),string:new Set(["input","password","email","phone","select","radioGroup","text","markdown","richText","expression","time"]),date:new Set(["date","createdAt","updatedAt"])};function ct(e,o){var t,s,i,a,c,d;const n=typeof o;return n==="string"?(t=Ee[o])==null?void 0:t.has(e.interface):n==="object"&&o.type==="reference"?Oo(e)?((s=o.options)==null?void 0:s.entity)&&(e.collectionName===((i=o.options)==null?void 0:i.collection)||((a=o.options)==null?void 0:a.collection)==="*"):e.isForeignKey?e.collectionName===((c=o.options)==null?void 0:c.collection)&&e.name==="id"||e.target===((d=o.options)==null?void 0:d.collection):!1:n==="function"?o(e):!1}function Oo(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function To(e,o){if(o==null)return null;const n=`${e.name}.`;return o.filter(t=>t.startsWith(n)).map(t=>t.replace(n,""))}function $o({fields:e,types:o,appends:n,depth:t=1,compile:s,getCollectionFields:i}){return e.filter(a=>{const c=o!=null&&o.length?o.some(d=>ct(a,d)):!0;if(Oo(a)){if(n===null)return t?c||$o({fields:Do(a.target,{compile:s,getCollectionFields:i}),types:o,depth:t-1,appends:n,compile:s,getCollectionFields:i}):!1;const d=To(a,n),p=n.includes(a.name);return c?p:((d==null?void 0:d.length)||p)&&$o({fields:Do(a.target,{compile:s,getCollectionFields:i}),types:o,appends:d,compile:s,getCollectionFields:i}).length}else return c})}function so(e,o){var i,a;const n=l.useCompile(),t=(a=(i=e.useOptions)==null?void 0:i.call(e,o))==null?void 0:a.filter(Boolean),{fieldNames:s}=o;return{[s.label]:n(e.label),[s.value]:e.value,key:e[s.value],[s.children]:t,disabled:!t||!t.length}}function ce(e={}){var s;const o=Object.assign({},we,(s=e.fieldNames)!=null?s:{}),n=Object.assign(e,{fieldNames:o});return[so(Ao,n),so(no,n),so(ro,n),so(at,n)]}function Do(e,{compile:o,getCollectionFields:n}){var a,c,d,p,f,x,v;const t=n(e),s=[],i=[];t.forEach(h=>{h.isForeignKey?s.push(h):i.push(h)});for(let h=i.length-1;h>=0;h--){const m=i[h];if(m.type==="belongsTo"){const S=s.find(F=>F.name===m.foreignKey);S?i.splice(h,0,C(g(g({},m),S),{uiSchema:C(g({},m.uiSchema),{title:(a=m.uiSchema)!=null&&a.title?`${o((c=m.uiSchema)==null?void 0:c.title)} ID`:S.name})})):i.splice(h,0,C(g({},m),{name:m.foreignKey,type:"bigInt",isForeignKey:!0,interface:m.interface,uiSchema:C(g({},m.uiSchema),{title:(d=m.uiSchema)!=null&&d.title?`${o((p=m.uiSchema)==null?void 0:p.title)} ID`:m.name})}))}else if(m.type==="context"&&m.collectionName==="users"){const S=(f=i.find(F=>F.type==="belongsTo"&&F.target==="users"&&F.foreignKey===m.name))!=null?f:{};i.splice(h,0,C(g({},m),{type:m.dataType,interface:S.interface,uiSchema:C(g({},S.uiSchema),{title:(x=S.uiSchema)!=null&&x.title?`${o((v=S.uiSchema)==null?void 0:v.title)} ID`:m.name})}))}}return i.filter(h=>h.interface&&!h.hidden)}function Bn(e){const o=To(e.field,e.appends),n=fe(g({collection:e.field.target,types:e.types,appends:o,depth:e.depth-1},this));e.loadChildren=null,n.length?e.children=n:(e.isLeaf=!0,!e.types||e.types.some(s=>ct(e.field,s))||(e.disabled=!0))}function fe(e){const{fields:o,collection:n,types:t,appends:s=[],depth:i=1,compile:a,getCollectionFields:c,fieldNames:d=we}=e,p=Do(n,{compile:a,getCollectionFields:c}),f=o!=null?o:p,x=Bn.bind({compile:a,getCollectionFields:c,fieldNames:d});return $o({fields:f,types:t,depth:i,appends:s,compile:a,getCollectionFields:c}).map(h=>{var A;const m=a(((A=h.uiSchema)==null?void 0:A.title)||h.name),S=To(h,s),F=!Oo(h)||S&&!S.length&&!s.includes(h.name)||!1;return{[d.label]:m,key:h.name,[d.value]:h.name,isLeaf:F,loadChildren:F?null:x,field:h,depth:i,appends:s,types:t}})}function qe(n){var t=n,{variableOptions:e}=t,o=z(t,["variableOptions"]);const s=ce(e);return r.jsx(l.Variable.Input,g({scope:s},o))}function dt(n){var t=n,{variableOptions:e}=t,o=z(t,["variableOptions"]);const s=ce(e);return r.jsx(l.Variable.TextArea,g({scope:s},o))}function ut(n){var t=n,{variableOptions:e}=t,o=z(t,["variableOptions"]);const s=ce(e);return r.jsx(l.Variable.RawTextArea,g({scope:s},o))}function pt(n){var t=n,{variableOptions:e}=t,o=z(t,["variableOptions"]);const s=ce(e);return r.jsx(l.Variable.JSON,g({scope:s},o))}function Ge({value:e,onChange:o,renderSchemaComponent:n}){const t=ce();return r.jsx(l.Variable.Input,{value:e,onChange:o,scope:t,children:n()})}const Me=()=>null;function Vn(s){var i=s,{node:e,resultTitle:o,insert:n}=i,t=z(i,["node","resultTitle","insert"]);return r.jsx(l.SchemaInitializer.Item,C(g({},t),{onClick:()=>{var a;n({type:"void",name:e.id,title:e.title,"x-component":"CardItem","x-component-props":{title:(a=e.title)!=null?a:`#${e.id}`},"x-designer":"SimpleDesigner",properties:{result:{type:"void",title:o,"x-component":"ValueBlock.Result","x-component-props":{dataSource:`{{$jobsMapByNodeKey.${e.key}}}`}}}})}}))}function jn({dataSource:e}){var s;const o=T.useFieldSchema(),{execution:n}=U();if(!n)return o.title;const t=K.parse(e)({$jobsMapByNodeKey:((s=n.jobs)!=null?s:[]).reduce((i,a)=>Object.assign(i,{[a.nodeId]:a.result}),{})});return r.jsx("pre",{className:l.css`
|
|
453
453
|
margin: 0;
|
|
454
|
-
`,children:JSON.stringify(
|
|
454
|
+
`,children:JSON.stringify(t,null,2)})}Me.Initializer=Vn,Me.Result=jn;function Ln(e){return["hasMany","belongsToMany"].includes(e.type)}function zn(){const e=l.useCompile();return[no,ro].map(o=>{var t;const n=(t=o.useOptions({types:[Ln],appends:null,depth:4}))==null?void 0:t.filter(Boolean);return{label:e(o.label),value:o.value,key:o.value,children:e(n),disabled:n&&!n.length}})}function Wn(t){var s=t,{value:e,onChange:o}=s,n=z(s,["value","onChange"]);const{setValuesIn:i}=T.useForm(),{getCollection:a}=l.useCollectionManager(),c=zn(),[d,p]=y.useState(c),{associatedKey:f="",name:x}=e!=null?e:{};let v=[];const h=f.match(/^{{(.*)}}$/);h&&(v=[...h[1].trim().split(".").slice(0,-1),x]);const m=F=>H(this,null,function*(){var w;const A=F[F.length-1];!((w=A.children)!=null&&w.length)&&!A.isLeaf&&A.loadChildren&&(yield A.loadChildren(A),p($=>[...$]))});y.useEffect(()=>{(()=>H(this,null,function*(){var w;if(!v||d.length<=1)return;let A=null;for(let $=0;$<v.length;$++){const P=v[$];try{$===0?A=d.find(B=>B.value===P):(A.loadChildren&&!((w=A.children)!=null&&w.length)&&(yield A.loadChildren(A)),A=A.children.find(B=>B.value===P))}catch(B){console.error(B)}}p([...d])}))()},[e,d.length]);const S=y.useCallback((F,A)=>{if(!(F!=null&&F.length)){i("collection",null),o({});return}const{field:w}=A.pop();if(!w||!["hasMany","belongsToMany"].includes(w.type))return;const{collectionName:$,target:P,name:B}=w,E=a($).fields.find(N=>N.primaryKey);i("collection",P),o({name:B,associatedKey:`{{${F.slice(0,-1).join(".")}.${E.name}}}`,associatedCollection:$})},[o]);return r.jsx(b.Cascader,C(g({},n),{value:v,options:d,onChange:S,loadData:m}))}const Un={title:`{{t("Aggregate", { ns: "${u}" })}}`,type:"aggregate",group:"collection",description:`{{t("Counting, summing, finding maximum, minimum, and average values for multiple records of a collection or associated data of a record.", { ns: "${u}" })}}`,fieldset:{aggregator:{type:"string",title:`{{t("Aggregator function", { ns: "${u}" })}}`,"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: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Data of collection", { ns: "${u}" })}}`,value:!1},{label:`{{t("Data of associated collection", { ns: "${u}" })}}`,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:C(g({},ae),{title:`{{t("Data of collection", { ns: "${u}" })}}`,"x-component-props":C(g({},ae["x-component-props"]),{className:null}),"x-reactions":[...ae["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: "${u}" })}}`,"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: "${u}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{filter(e){return!e.hidden&&e.interface&&!["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}},required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}}}}},params:{type:"object",properties:{distinct:{type:"boolean",title:`{{t("Distinct", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox","x-reactions":[{dependencies:["collection","aggregator"],fulfill:{state:{visible:'{{!!$deps[0] && ["count"].includes($deps[1])}}'}}}]},filter:C(g({},$e),{"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]})}}},view:{},scope:{useCollectionDataSource:l.useCollectionDataSource},components:{SchemaComponentContext:l.SchemaComponentContext,FilterDynamicComponent:Ge,FieldsSelect:wo,ValueBlock:Me,AssociatedConfig:Wn},useVariables({key:e,title:o},{types:n,fieldNames:t=we}){return n&&!n.some(s=>s in Ee||Object.values(Ee).some(i=>i.has(s)))?null:{[t.value]:e,[t.label]:o}},useInitializers(e){var o;return e.config.collection?{type:"item",title:(o=e.title)!=null?o:`#${e.id}`,component:Me.Initializer,node:e,resultTitle:D("Query result")}:null}};function io(e){const s=e,{options:o=[]}=s,n=z(s,["options"]),t=l.useCompile();return r.jsx(b.Radio.Group,C(g({},n),{children:o.map(i=>r.jsxs(b.Radio,{value:i.value,children:[r.jsx("span",{className:l.css`
|
|
455
455
|
& + .anticon {
|
|
456
456
|
margin-left: 0.25em;
|
|
457
457
|
}
|
|
458
|
-
`,children:
|
|
458
|
+
`,children:t(i.label)}),i.tooltip&&r.jsx(b.Tooltip,{title:t(i.tooltip),children:r.jsx(O.QuestionCircleOutlined,{style:{color:"#666"}})})]},i.value))}))}const mt=e=>{const o=je.evaluators.get(e);return o&&o.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:l.css`
|
|
459
459
|
&:after {
|
|
460
460
|
content: ':';
|
|
461
461
|
}
|
|
462
462
|
& + a {
|
|
463
463
|
margin-left: 0.25em;
|
|
464
464
|
}
|
|
465
|
-
`,children:
|
|
465
|
+
`,children:l.i18n.t("Syntax references")}),r.jsx("a",{href:o.link,target:"_blank",rel:"noreferrer",children:o.label})]}):null};function qn(e){var n;return["belongsTo","hasOne"].includes(e.type)?((n=this.getCollection(e.collectionName))==null?void 0:n.template)==="expression"?!0:this.getCollectionFields(e.target).some(t=>t.interface==="expression"):!1}const Gn=({value:e,onChange:o})=>{const{t:n}=R.useTranslation(),{getCollectionFields:t,getCollection:s}=l.useCollectionManager(),i=ce({types:[qn.bind({getCollectionFields:t,getCollection:s})]});return r.jsxs(ve.FormLayout,{layout:"vertical",children:[r.jsx(ve.FormItem,{colon:!0,label:n("Expression type",{ns:u}),children:r.jsxs(b.Radio.Group,{value:e===!1?!1:e||"",onChange:a=>{o(a.target.value)},children:[r.jsx(b.Radio,{value:!1,children:n("Static",{ns:u})}),r.jsx(b.Radio,{value:e||"",children:n("Dynamic",{ns:u})})]})}),e!==!1?r.jsx(ve.FormItem,{label:n("Select dynamic expression",{ns:u}),extra:n("Select the dynamic expression queried from the upstream node. You need to query it from an expression collection.",{ns:u}),children:r.jsx(l.Variable.Input,{value:e||"",onChange:a=>o(a),scope:i})}):null]})},Jn={title:`{{t("Calculation", { ns: "${u}" })}}`,type:"calculation",group:"control",description:`{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression. The expression can be static or dynamic one from an expression collections.", { ns: "${u}" })}}`,fieldset:{dynamic:{type:"string","x-component":"DynamicConfig",default:!1},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:je.getOptions()},required:!0,default:"math.js","x-reactions":{dependencies:["dynamic"],fulfill:{state:{visible:"{{$deps[0] === false}}"}}}},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(e,o,{form:n}){const{values:t}=n,{evaluate:s}=je.evaluators.get(t.engine),i=e.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return s(i),""}catch(a){return D("Expression syntax error")}},"x-reactions":[{dependencies:["dynamic"],fulfill:{state:{visible:"{{$deps[0] === false}}"}}},{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0},scope:{type:"string",title:`{{t("Variable datasource", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,variableOptions:{types:[{type:"reference",options:{collection:"*",entity:!0}}]}},"x-reactions":{dependencies:["dynamic"],fulfill:{state:{visible:"{{$deps[0]}}"}}}}},view:{},scope:{renderEngineReference:mt},components:{WorkflowVariableInput:qe,WorkflowVariableTextArea:dt,RadioWithTooltip:io,DynamicConfig:Gn,ValueBlock:Me},useVariables({key:e,title:o},{types:n,fieldNames:t=l.defaultFieldNames}){return n&&!n.some(s=>s in Ee||Object.values(Ee).some(i=>i.has(s)))?null:{[t.value]:e,[t.label]:o}},useInitializers(e){var o;return{type:"item",title:(o=e.title)!=null?o:`#${e.id}`,component:Me.Initializer,node:e,resultTitle:D("Calculation result")}}},ee=new K.Registry;ee.register("equal",{name:"=",type:"boolean",group:"boolean"}),ee.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),ee.register("gt",{name:">",type:"boolean",group:"boolean"}),ee.register("gte",{name:"≥",type:"boolean",group:"boolean"}),ee.register("lt",{name:"<",type:"boolean",group:"boolean"}),ee.register("lte",{name:"≤",type:"boolean",group:"boolean"}),ee.register("add",{name:"+",type:"number",group:"number"}),ee.register("minus",{name:"-",type:"number",group:"number"}),ee.register("multiple",{name:"*",type:"number",group:"number"}),ee.register("divide",{name:"/",type:"number",group:"number"}),ee.register("mod",{name:"%",type:"number",group:"number"}),ee.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),ee.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),ee.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),ee.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),ee.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),ee.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),ee.register("concat",{name:`{{t("concat", { ns: "${u}" })}}`,type:"string",group:"string"});const Hn=[{value:"boolean",title:'{{t("Comparision")}}'},{value:"number",title:`{{t("Arithmetic calculation", { ns: "${u}" })}}`},{value:"string",title:`{{t("String operation", { ns: "${u}" })}}`},{value:"date",title:`{{t("Date", { ns: "${u}" })}}`}];function ft(e){return Array.from(ee.getEntities()).filter(([o,n])=>n.group===e)}function Yn({calculator:e,operands:o=[],onChange:n}){const t=l.useCompile(),s=ce();return r.jsxs("fieldset",{className:l.css`
|
|
466
466
|
display: flex;
|
|
467
467
|
gap: 0.5em;
|
|
468
468
|
align-items: center;
|
|
469
469
|
flex-wrap: wrap;
|
|
470
|
-
`,children:[
|
|
470
|
+
`,children:[r.jsx(l.Variable.Input,{value:o[0],onChange:i=>n({calculator:e,operands:[i,o[1]]}),scope:s,useTypedConstant:!0}),r.jsx(b.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:i=>n({operands:o,calculator:i}),placeholder:D("Calculator"),popupMatchSelectWidth:!1,children:Hn.filter(i=>!!ft(i.value).length).map(i=>r.jsx(b.Select.OptGroup,{label:t(i.title),children:ft(i.value).map(([a,{name:c}])=>r.jsx(b.Select.Option,{value:a,children:t(c)},a))},i.value))}),r.jsx(l.Variable.Input,{value:o[1],onChange:i=>n({calculator:e,operands:[o[0],i]}),scope:s,useTypedConstant:!0})]})}function _n({value:e,onChange:o,onRemove:n}){if(!e)return null;const{calculator:t,operands:s=[]}=e;return r.jsxs("div",{className:l.css`
|
|
471
471
|
display: flex;
|
|
472
472
|
position: relative;
|
|
473
473
|
margin: 0.5em 0;
|
|
474
|
-
`,children:[e.group?
|
|
474
|
+
`,children:[e.group?r.jsx(ht,{value:e.group,onChange:i=>o(C(g({},e),{group:i}))}):r.jsx(Yn,{operands:s,calculator:t,onChange:o}),r.jsx(b.Button,{"aria-label":"icon-close",onClick:n,type:"link",icon:r.jsx(O.CloseCircleOutlined,{})})]})}function ht({value:e,onChange:o}){const{t:n}=R.useTranslation(),{type:t="and",calculations:s=[]}=e;function i(){o(C(g({},e),{calculations:[...s,{not:!1,calculator:"equal"}]}))}function a(){o(C(g({},e),{calculations:[...s,{not:!1,group:{type:"and",calculations:[]}}]}))}function c(p){s.splice(p,1),o(C(g({},e),{calculations:[...s]}))}function d(p,f){s.splice(p,1,f),o(C(g({},e),{calculations:[...s]}))}return r.jsxs("div",{className:l.cx("node-type-condition-group",l.css`
|
|
475
475
|
position: relative;
|
|
476
476
|
width: 100%;
|
|
477
477
|
.node-type-condition-group {
|
|
@@ -482,7 +482,7 @@
|
|
|
482
482
|
position: absolute;
|
|
483
483
|
right: 0;
|
|
484
484
|
}
|
|
485
|
-
`),children:[
|
|
485
|
+
`),children:[r.jsx("div",{className:l.css`
|
|
486
486
|
display: flex;
|
|
487
487
|
align-items: center;
|
|
488
488
|
gap: 0.5em;
|
|
@@ -490,14 +490,14 @@
|
|
|
490
490
|
width: auto;
|
|
491
491
|
min-width: 6em;
|
|
492
492
|
}
|
|
493
|
-
`,children:
|
|
493
|
+
`,children:r.jsxs(R.Trans,{children:["Meet ",r.jsxs(b.Select,{role:"button","data-testid":"filter-select-all-or-any",value:t,onChange:p=>o(C(g({},e),{type:p})),children:[r.jsx(b.Select.Option,{value:"and",children:"All"}),r.jsx(b.Select.Option,{value:"or",children:"Any"})]})," conditions in the group"]})}),r.jsx("div",{className:"calculation-items",children:s.map((p,f)=>r.jsx(_n,{value:p,onChange:d.bind(this,f),onRemove:()=>c(f)},`${p.calculator}_${f}`))}),r.jsxs("div",{className:l.css`
|
|
494
494
|
button {
|
|
495
495
|
padding: 0;
|
|
496
496
|
&:not(:last-child) {
|
|
497
497
|
margin-right: 1em;
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
|
-
`,children:[
|
|
500
|
+
`,children:[r.jsx(b.Button,{type:"link",onClick:i,children:n("Add condition")}),r.jsx(b.Button,{type:"link",onClick:a,children:n("Add condition group")})]})]})}function Kn({value:e,onChange:o}){const n=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(ht,{value:n.group,onChange:t=>o(C(g({},n),{group:t}))})}const Zn={title:`{{t("Condition", { ns: "${u}" })}}`,type:"condition",group:"control",description:`{{t('Based on boolean result of the calculation to determine whether to "continue" or "exit" the process, or continue on different branches of "yes" and "no".', { ns: "${u}" })}}`,fieldset:{rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{disabled:!0},enum:[{value:!0,label:`{{t('Continue when "Yes"', { ns: "${u}" })}}`},{value:!1,label:`{{t('Branch into "Yes" and "No"', { ns: "${u}" })}}`}]},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[["basic",{label:`{{t("Basic", { ns: "${u}" })}}`}],...Array.from(je.evaluators.getEntities())].reduce((e,[o,n])=>e.concat(g({value:o},n)),[])},required:!0,default:"basic"},calculation:{type:"string",title:`{{t("Condition", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"CalculationConfig","x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] === "basic"}}'}}},required:!0},expression:{type:"string",title:`{{t("Condition expression", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"CalculationExpression","x-validator"(e,o,{form:n}){const{values:t}=n,{evaluate:s}=je.evaluators.get(t.engine),i=e.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return s(i),""}catch(a){return D("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0}},view:{},options:[{label:`{{t('Continue when "Yes"', { ns: "${u}" })}}`,key:"rejectOnFalse",value:{rejectOnFalse:!0}},{label:`{{t('Branch into "Yes" and "No"', { ns: "${u}" })}}`,key:"branch",value:{rejectOnFalse:!1}}],component:function({data:o}){const{t:n}=R.useTranslation(),{nodes:t}=U(),{styles:s}=te(),{id:i,config:{rejectOnFalse:a}}=o,c=t.find(p=>p.upstreamId===i&&p.branchIndex===1),d=t.find(p=>p.upstreamId===i&&p.branchIndex===0);return r.jsx(He,{data:o,children:a?null:r.jsxs("div",{className:s.nodeSubtreeClass,children:[r.jsxs("div",{className:s.branchBlockClass,children:[r.jsx(Oe,{from:o,entry:d,branchIndex:0}),r.jsx(Oe,{from:o,entry:c,branchIndex:1})]}),r.jsxs("div",{className:s.conditionClass,children:[r.jsx("span",{style:{right:"4em"},children:n("No")}),r.jsx("span",{style:{left:"4em"},children:n("Yes")})]})]})})},scope:{renderEngineReference:mt,useWorkflowVariableOptions:ce},components:{CalculationConfig:Kn,CalculationExpression(e){const o=ce();return r.jsx(l.Variable.TextArea,g({scope:o},e))},RadioWithTooltip:io}};function Qn(e){const{getCollectionFields:o}=l.useCollectionManager(),{path:n}=T.useField(),t=n.segments[n.segments.length-1],{values:s}=T.useForm(),i=o(s==null?void 0:s.collection),{type:a}=i.find(p=>p.name===t),c=Array.isArray(e.value)?e.value.join(","):e.value;function d(p){const f=p.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(a)?f:f.split(/[,\s]+/))}return r.jsx(b.Input,C(g({},e),{value:c,onChange:d}))}const yt=T.observer(({value:e,disabled:o,onChange:n,filter:t})=>{const{token:s}=l.useToken(),{t:i}=R.useTranslation(),a=l.useCompile(),c=T.useForm(),{getCollection:d,getCollectionFields:p}=l.useCollectionManager(),f=ce(),{values:x}=c,v=x==null?void 0:x.collection,h=p(v).filter(w=>w.uiSchema),m=t?h.filter(t.bind(x)):h,S=y.useMemo(()=>m.filter(w=>!e||!(w.name in e)),[m,e]),F=o||c.disabled,A=y.useMemo(()=>({onClick:({key:w})=>{n(C(g({},e),{[w]:null}))},style:{maxHeight:300,overflowY:"auto"},items:S.map(w=>{var $,P;return{key:w.name,label:a((P=($=w.uiSchema)==null?void 0:$.title)!=null?P:w.name)}})}),[n,S,e]);return r.jsx("fieldset",{className:l.css`
|
|
501
501
|
margin-top: 0.5em;
|
|
502
502
|
|
|
503
503
|
> .ant-formily-item {
|
|
@@ -507,14 +507,14 @@
|
|
|
507
507
|
line-height: 32px;
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
|
-
`,children:m.length?
|
|
510
|
+
`,children:m.length?r.jsxs(l.CollectionProvider,{collection:d(v),children:[m.filter(w=>e&&w.name in e).map(w=>{var P,B;const $=["belongsTo","hasOne","hasMany","belongsToMany"].includes(w.type)?Qn:l.CollectionField;return r.jsxs(b.Form.Item,{label:a((B=(P=w.uiSchema)==null?void 0:P.title)!=null?B:w.name),labelAlign:"left",className:l.css`
|
|
511
511
|
.ant-form-item-control-input-content {
|
|
512
512
|
display: flex;
|
|
513
513
|
}
|
|
514
|
-
`,children:[
|
|
514
|
+
`,children:[r.jsx(l.Variable.Input,{scope:f,value:e[w.name],changeOnSelect:!0,onChange:L=>{n(C(g({},e),{[w.name]:L}))},children:r.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[w.name]:{"x-component":$,"x-validator"(){return""}}}}})}),F?null:r.jsx(b.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx(O.CloseCircleOutlined,{}),onClick:()=>{var N;const I=e,{[N=w.name]:L}=I,E=z(I,[tn(N)]);n(E)}})]},w.name)}),S.length?r.jsx(b.Dropdown,{menu:A,children:r.jsx(b.Button,{icon:r.jsx(O.PlusOutlined,{}),children:i("Add field")})}):null]}):r.jsx("p",{style:{color:s.colorText},children:D("Please select collection first")})})},{displayName:"CollectionFieldSet"}),Xn={title:`{{t("Create record", { ns: "${u}" })}}`,type:"create",group:"collection",description:`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${u}" })}}`,fieldset:{collection:ae,params:{type:"object",properties:{values:qo,appends:De}}},view:{},scope:{useCollectionDataSource:l.useCollectionDataSource},components:{CollectionFieldset:yt},useVariables({key:e,title:o,config:n},t){var c,d;const s=l.useCompile(),{getCollectionFields:i}=l.useCollectionManager(),[a]=fe(C(g({appends:[e,...((d=(c=n.params)==null?void 0:c.appends)==null?void 0:d.map(p=>`${e}.${p}`))||[]]},t),{fields:[{collectionName:n.collection,name:e,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:s,getCollectionFields:i}));return a},useInitializers(e){var o;return e.config.collection?{type:"item",title:(o=e.title)!=null?o:`#${e.id}`,component:Te,collection:e.config.collection,dataSource:`{{$jobsMapByNodeKey.${e.key}}}`}:null},initializers:{}},gt=[{value:1e3,label:"Seconds"},{value:6e4,label:"Minutes"},{value:36e5,label:"Hours"},{value:864e5,label:"Days"},{value:6048e5,label:"Weeks"}];function Rn(e){return gt.slice().reverse().find(o=>!(e%o.value))}function er({value:e=6e4,onChange:o}){const n=Rn(e),t=Math.round(e/n.value);return r.jsxs("fieldset",{className:l.css`
|
|
515
515
|
display: flex;
|
|
516
516
|
gap: 0.5em;
|
|
517
|
-
`,children:[
|
|
517
|
+
`,children:[r.jsx(b.InputNumber,{min:1,value:t,onChange:s=>o(Math.round(s*n.value)),className:"auto-width"}),r.jsx(b.Select,{role:"button","data-testid":"select-time-unit",popupMatchSelectWidth:!1,value:n.value,onChange:s=>o(Math.round(t*s)),className:"auto-width",children:gt.map(s=>r.jsx(b.Select.Option,{value:s.value,children:D(s.label)},s.value))})]})}const or={title:`{{t("Delay", { ns: "${u}" })}}`,type:"delay",group:"control",description:`{{t("Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.", { ns: "${u}" })}}`,fieldset:{duration:{type:"number",title:`{{t("Duration", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Duration",default:6e4,required:!0},endStatus:{type:"number",title:`{{t("End Status", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeed and continue", { ns: "${u}" })}}`,value:Z.RESOLVED},{label:`{{t("Fail and exit", { ns: "${u}" })}}`,value:Z.FAILED}],required:!0,default:Z.RESOLVED}},view:{},scope:{},components:{Duration:er}};function Io(e){const o=new Map;e.forEach(n=>o.set(n.id,n));for(const n of o.values())n.upstreamId&&(n.upstream=o.get(n.upstreamId)),n.downstreamId&&(n.downstream=o.get(n.downstreamId))}function No(e){const o=e.$and||e.$or;return o?o.some(n=>{if(n.$and||n.$or)return No(n);const[t]=Object.keys(n);if(!t||!n[t])return!1;const[s]=Object.keys(n[t]);return!(!s||typeof n[t][s]=="undefined")}):!1}const tr={title:'{{t("Delete record")}}',type:"destroy",group:"collection",description:`{{t("Delete records of a collection. Could use variables in workflow context as filter. All records match the filter will be deleted.", { ns: "${u}" })}}`,fieldset:{collection:ae,params:{type:"object",properties:{filter:C(g({},$e),{"x-validator"(e){return No(e)?"":`{{t("Please add at least one condition", { ns: "${u}" })}}`}})}}},view:{},scope:{useCollectionDataSource:l.useCollectionDataSource},components:{FilterDynamicComponent:Ge}};function nr(e,o){let n=e,t=null;for(let s=0;s<o.length;s++){const i=o[s],a=n.find(c=>c.value===i);if(!a)return null;t=a,!a.isLeaf&&a.loadChildren&&a.loadChildren(a),a.children&&(n=a.children)}return t}const rr={title:`{{t("Loop", { ns: "${u}" })}}`,type:"loop",group:"control",description:`{{t("By using a loop node, you can perform the same operation on multiple sets of data. The source of these sets can be either multiple records from a query node or multiple associated records of a single record. Loop node can also be used for iterating a certain number of times or for looping through each character in a string. However, excessive looping may cause performance issues, so use with caution.", { ns: "${u}" })}}`,fieldset:{target:{type:"string",title:`{{t("Loop target", { ns: "${u}" })}}`,description:`{{t("A single number will be treated as a loop count, a single string will be treated as an array of characters, and other non-array values will be converted to arrays. The loop node ends when the loop count is reached, or when the array loop is completed. You can also add condition nodes to the loop to terminate it.", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,useTypedConstant:["string","number","null"],className:l.css`
|
|
518
518
|
width: 100%;
|
|
519
519
|
|
|
520
520
|
.variable {
|
|
@@ -524,19 +524,19 @@
|
|
|
524
524
|
.ant-input.null-value {
|
|
525
525
|
width: 100%;
|
|
526
526
|
}
|
|
527
|
-
`},required:!0}},view:{},component:function({data:
|
|
527
|
+
`},required:!0}},view:{},component:function({data:o}){var i;const{nodes:n}=U(),{styles:t}=te(),s=n.find(a=>a.upstreamId===o.id&&a.branchIndex!=null);return r.jsx(He,{data:o,children:r.jsx("div",{className:t.nodeSubtreeClass,children:r.jsxs("div",{className:l.cx(t.branchBlockClass,l.css`
|
|
528
528
|
padding-left: 20em;
|
|
529
|
-
`),children:[n.jsx(Me,{from:t,entry:s,branchIndex:(a=s==null?void 0:s.branchIndex)!=null?a:0}),n.jsxs("div",{className:r.branchClass,children:[n.jsx("div",{className:"workflow-branch-lines"}),n.jsx("div",{className:i.cx(r.addButtonClass,r.loopLineClass),children:n.jsx(O.ArrowUpOutlined,{})})]})]})})})},scope:{},components:{WorkflowVariableInput:it},useScopeVariables(e,t){const o=i.useCompile(),{target:r}=e.config;if(!r)return null;const{fieldNames:s=Ae}=t;let a={key:"item",[s.value]:"item",[s.label]:N("Loop target")};if(typeof r=="string"&&r.startsWith("{{")&&r.endsWith("}}")){const l=r.slice(2,-2).split(".").map(p=>p.trim()),c=[vo,Ft,It].map(p=>{const f=p.useOptions(C(v({},t),{current:e})).filter(Boolean);return{[s.label]:o(p.label),[s.value]:p.value,key:p.value,[s.children]:f,disabled:f&&!f.length}}),u=By(c,l);a=Object.assign({},u,a)}return[a,{key:"index",[s.value]:"index",[s.label]:N("Loop index")},{key:"length",[s.value]:"length",[s.label]:N("Loop length")}]}};function Ly(e){const{execution:t,nodes:o}=G(),r=y.useMemo(()=>o.reduce((l,c)=>Object.assign(l,{[c.id]:c.key}),{}),[o]),s=y.useMemo(()=>{var l;return{$context:t==null?void 0:t.context,$jobsMapByNodeKey:((l=t==null?void 0:t.jobs)!=null?l:[]).reduce((c,u)=>Object.assign(c,{[r[u.nodeId]]:u.result}),{})}},[t]);return y.useMemo(()=>X.parse(e)(s),[t])}function xn(e){const t=F.useField(),o=y.useRef(null),{appends:r,updateAssociationValues:s}=i.useAssociationNames(),a=Ly(e.dataSource),l=y.useMemo(()=>se.createForm({values:a,readPretty:!0}),[a]),c={appends:r},u={loading:!1,data:{data:a}},f=i.useAPIClient().resource(e.collection),g=y.useContext(i.BlockRequestContext);return n.jsx(i.CollectionProvider,{collection:e.collection,children:n.jsx(i.RecordProvider,{record:a,parent:!1,children:n.jsx(i.BlockRequestContext.Provider,{value:{block:"form",field:t,service:u,resource:f,__parent:g},children:n.jsx(i.FormBlockContext.Provider,{value:{params:c,form:l,field:t,service:u,updateAssociationValues:s,formBlockRef:o},children:e.children})})})})}function Cn(e){var $,D,M;const t=i.useRecord(),o=F.useFieldSchema(),r=F.useField(),s=y.useRef(null),{appends:a,updateAssociationValues:l}=i.useAssociationNames(),[c]=Object.keys(($=o.toJSON().properties)!=null?$:{}),u=(D=t==null?void 0:t.result)==null?void 0:D[c],{findComponent:p}=i.useDesignable(),f=p((M=r.component)==null?void 0:M[0])||y.Fragment,g=y.useMemo(()=>se.createForm({initialValues:u}),[u]),x=y.useMemo(()=>v({appends:a},e.params),[a,e.params]),h=y.useMemo(()=>({loading:!1,data:{data:u}}),[u]),k=i.useAPIClient().resource(e.collection),w=y.useContext(i.BlockRequestContext),T=y.useMemo(()=>({params:x,form:g,field:r,service:h,updateAssociationValues:l,formBlockRef:s}),[r,g,x,h,l]);return!t.status||u?n.jsx(i.CollectionProvider,{collection:e.collection,children:n.jsx(i.RecordProvider,{record:u,parent:!1,children:n.jsx(i.FormActiveFieldsProvider,{name:"form",children:n.jsx(i.BlockRequestContext.Provider,{value:{block:"form",props:e,field:r,service:h,resource:k,__parent:w},children:n.jsx(i.FormBlockContext.Provider,{value:T,children:n.jsxs(f,C(v({},r.componentProps),{children:[n.jsx(i.FormV2.Templates,{style:{marginBottom:18},form:g}),n.jsx("div",{ref:s,children:n.jsx(F.RecursionField,{schema:o,onlyRenderProperties:!0})})]}))})})})})}):null}function zy(r){var s=r,{insert:e,schema:t}=s,o=W(s,["insert","schema"]);const{getTemplateSchemaByMode:a}=i.useSchemaTemplateManager(),l=i.useRecordCollectionDataSourceItems("FormItem");function c(p){return J(this,arguments,function*({item:u}){const f=u.template?yield a(u):null,g=i.createFormBlockSchema(C(v({actionInitializers:"AddActionButton",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${d}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:ee.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},t),{template:f}));delete g["x-acl-action-props"],delete g["x-acl-action"];const[x]=Object.keys(g.properties);g.properties[x].properties.actions["x-decorator"]="ActionBarProvider",g.properties[x].properties.actions["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},Jt(g,h=>{h["x-uid"]&&delete h["x-uid"]}),e(g)})}return n.jsx(i.SchemaInitializer.Item,C(v({},o),{onClick:c,items:l}))}function wn(e){var t;return n.jsx(i.CollectionProvider,{collection:(t=e.schema)==null?void 0:t.collection,children:n.jsx(zy,v({},e))})}function Wy(){const{name:e,title:t}=i.useCollection();return n.jsxs(i.GeneralSchemaDesigner,{title:t||e,children:[n.jsx(i.SchemaSettings.BlockTitleItem,{}),n.jsx(i.SchemaSettings.LinkageRules,{collectionName:e}),n.jsx(i.SchemaSettings.DataTemplates,{collectionName:e}),n.jsx(i.SchemaSettings.Divider,{}),n.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Uy={title:`{{t("Create record form", { ns: "${d}" })}}`,config:{useInitializer({collections:e}){return{key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${d}" })}}`,children:[{key:"createRecordForm-child",type:"itemGroup",style:{maxHeight:"48vh",overflowY:"auto"},loadChildren:({searchValue:t})=>e.filter(o=>!o.hidden&&o.title.toLowerCase().includes(t.toLowerCase())).map(o=>({key:`createRecordForm-child-${o.name}`,type:"item",title:o.title,schema:{collection:o.name,title:`{{t("Create record", { ns: "${d}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},component:wn}))}]}},initializers:{},components:{CreateFormDesigner:Wy},parseFormOptions(e){const t={};return ke(e,r=>r["x-decorator"]==="FormBlockProvider"&&r["x-decorator-props"].formType==="create").forEach(r=>{var l;const[s]=Object.keys(r.properties),a=r.properties[s];t[s]={type:"create",title:((l=r["x-component-props"])==null?void 0:l.title)||s,actions:ke(a.properties.actions,c=>c["x-component"]==="Action").map(c=>{var u,p;return{status:c["x-decorator-props"].value,values:(p=(u=c["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:p.values,key:c.name}}),collection:r["x-decorator-props"].collection}}),t}},block:{scope:{},components:{}}};function $n(e){var p,f,g,x;const[t,o]=y.useState((f=(p=e.collection)==null?void 0:p.fields)!=null?f:[]),r=i.useRecord(),s=F.useField(),a=F.useFieldSchema(),[l]=Object.keys((g=a.toJSON().properties)!=null?g:{}),c=(x=r==null?void 0:r.result)==null?void 0:x[l],u=y.useMemo(()=>se.createForm({initialValues:c}),[c]);return!r.status||c?n.jsx(i.CollectionProvider,{collection:C(v({},e.collection),{fields:t}),children:n.jsx(i.RecordProvider,{record:c,parent:!1,children:n.jsx(i.FormBlockContext.Provider,{value:{form:u,field:s,setCollectionFields:o},children:e.children})})}):null}function Gy(o){var r=o,{insert:e}=r,t=W(r,["insert"]);return n.jsx(i.SchemaInitializer.Item,C(v({},t),{onClick:()=>{e({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:X.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[X.uid()]:{type:"void","x-component":"FormV2","x-component-props":{useProps:"{{ useFormBlockProps }}"},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"AddCustomFormField"},actions:{type:"void","x-decorator":"ActionBarProvider","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:"1.5em",flexWrap:"wrap"}},"x-initializer":"AddActionButton",properties:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${d}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:ee.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const Sn={basic:'{{t("Basic")}}',choices:'{{t("Choices")}}',media:'{{t("Media")}}',datetime:'{{t("Date & Time")}}',relation:'{{t("Relation")}}',advanced:'{{t("Advanced type")}}',systemInfo:'{{t("System info")}}',others:'{{t("Others")}}'};function Hy(e){const t={};return Object.keys(e).forEach(o=>{const r=e[o],{group:s="others"}=r;t[s]=t[s]||{},$e.set(t,[s,o],r)}),Object.keys(Sn).filter(o=>["basic","choices","datetime","media"].includes(o)).map(o=>({title:Sn[o],children:Object.keys(t[o]||{}).map(r=>{const s=t[o][r];return v({value:r,title:s.title,name:r},t[o][r])}).sort((r,s)=>r.order-s.order)}))}function Ky(){const{interfaces:e}=i.useCollectionManager();return Hy(e).map(o=>({key:o.title,type:"itemGroup",title:o.title,children:o.children.map(r=>({key:r.name,type:"item",title:r.title,component:Jy,fieldInterface:r.name}))}))}const kn=y.createContext({});function qy(e){const{insertPosition:t="beforeEnd",component:o}=e,r=Ky(),s=y.useContext(i.CollectionContext),[a,l]=y.useState(null),[c,u]=y.useState(),{setCollectionFields:p}=y.useContext(i.FormBlockContext);return n.jsxs(kn.Provider,{value:{onAddField(f){const k=$e.cloneDeep(f),{properties:w}=k,T=w,{unique:g,type:x}=T,h=W(T,["unique","type"]),m=W(k,["properties"]);delete h.name["x-disabled"],l(C(v({},m),{properties:h}))},setCallback:u},children:[n.jsx(i.SchemaInitializer.Button,{wrap:i.gridRowColWrap,insertPosition:t,items:r,component:o,title:"{{t('Configure fields')}}"}),n.jsx(i.ActionContextProvider,{value:{visible:!!a},children:a?n.jsx(i.SchemaComponent,{schema:{type:"void",name:"drawer",title:'{{t("Configure field")}}',"x-decorator":"Form","x-component":"Action.Drawer",properties:C(v({},a.properties),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction(){const f=F.useForm();return{run(){return J(this,null,function*(){u(null),l(null),f.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:f,query:g}=F.useForm();return{run(){return J(this,null,function*(){var T,$,D,M;const{default:h}=a,m=X.uid();if(h.name=(T=f.name)!=null?T:m,h.uiSchema.title=(D=($=f.uiSchema)==null?void 0:$.title)!=null?D:m,h.interface=a.name,(M=s.fields)==null?void 0:M.find(_=>_.name===h.name)){g("name").take().setFeedback({type:"error",messages:[N("Field name existed in form")]});return}const w=X.merge(h,f);p([...s.fields,w]),c({name:h.name,type:h.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:w},"x-collection-field":`${s.name}.${h.name}`,"x-designer":"FormItem.Designer"}),u(null),l(null)})}}}}}}}})},components:{ArrayTable:Se.ArrayTable}}):null})]})}function Jy(e){const{item:t,insert:o}=e,{onAddField:r,setCallback:s}=y.useContext(kn),{getInterface:a}=i.useCollectionManager(),l=a(t.fieldInterface);return n.jsx(i.SchemaInitializer.Item,{onClick:()=>{s(()=>o),r(l)}},t.fieldInterface)}const An={title:`{{t("Custom form", { ns: "${d}" })}}`,config:{useInitializer(){return{key:"customForm",type:"item",title:`{{t("Custom form", { ns: "${d}" })}}`,component:Gy}},initializers:{AddCustomFormField:qy},components:{CustomFormBlockProvider:$n},parseFormOptions(e){const t={};return ke(e,r=>r["x-decorator"]==="CustomFormBlockProvider").forEach(r=>{var c;const[s]=Object.keys(r.properties),a=r.properties[s],l=ke(a.properties.grid,u=>u["x-component"]==="CollectionField",!0);r["x-decorator-props"].collection.fields=l.map(u=>{var p,f;return(f=(p=u["x-component-props"])==null?void 0:p.field)!=null?f:u["x-interface-options"]}),t[s]={type:"custom",title:((c=r["x-component-props"])==null?void 0:c.title)||s,actions:ke(a.properties.actions,u=>u["x-component"]==="Action").map(u=>{var p,f;return{status:u["x-decorator-props"].value,values:(f=(p=u["x-action-settings"])==null?void 0:p.assignedValues)==null?void 0:f.values,key:u.name}}),collection:r["x-decorator-props"].collection}}),t}},block:{scope:{},components:{CustomFormBlockProvider:$n}}};function Yy(){const{name:e,title:t}=i.useCollection(),o=F.useFieldSchema(),{t:r}=oe.useTranslation(),{dn:s}=i.useDesignable();return n.jsxs(i.GeneralSchemaDesigner,{title:t||e,children:[n.jsx(i.SchemaSettings.BlockTitleItem,{}),n.jsx(i.SchemaSettings.ActionModalItem,{title:r("Filter settings",{ns:d}),schema:{name:"filter",type:"object",title:'{{t("Filter")}}',"x-component":"Filter","x-component-props":{useProps(){var l;return{options:i.useCollectionFilterOptions((l=o==null?void 0:o["x-decorator-props"])==null?void 0:l.collection)}},dynamicComponent:"FilterDynamicComponent"}},initialValues:o==null?void 0:o["x-decorator-props"],onSubmit:({filter:a})=>{o["x-decorator-props"].filter=a,s.emit("patch",{schema:{"x-decorator-props":o["x-decorator-props"]}}),s.refresh()}}),n.jsx(i.SchemaSettings.LinkageRules,{collectionName:e}),n.jsx(i.SchemaSettings.Divider,{}),n.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Zy={title:`{{t("Update record form", { ns: "${d}" })}}`,config:{useInitializer({collections:e}){return{key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${d}" })}}`,children:[{key:"updateRecordForm-child",type:"itemGroup",style:{maxHeight:"48vh",overflowY:"auto"},loadChildren:({searchValue:t})=>e.filter(o=>!o.hidden&&o.title.toLowerCase().includes(t.toLowerCase())).map(o=>({key:`updateRecordForm-child-${o.name}`,type:"item",title:o.title,schema:{collection:o.name,title:`{{t("Update record", { ns: "${d}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},component:wn}))}]}},initializers:{},components:{FilterDynamicComponent:lt,UpdateFormDesigner:Yy},parseFormOptions(e){const t={};return ke(e,r=>r["x-decorator"]==="FormBlockProvider"&&r["x-decorator-props"].formType==="update").forEach(r=>{var l;const[s]=Object.keys(r.properties),a=r.properties[s];t[s]=C(v({},r["x-decorator-props"]),{type:"update",title:((l=r["x-component-props"])==null?void 0:l.title)||s,actions:ke(a.properties.actions,c=>c["x-component"]==="Action").map(c=>{var u,p;return{status:c["x-decorator-props"].value,values:(p=(u=c["x-action-settings"])==null?void 0:u.assignedValues)==null?void 0:p.values,key:c.name}})})}),t}},block:{scope:{},components:{}}},Ce=new X.Registry;Ce.register("customForm",An),Ce.register("createForm",Uy),Ce.register("updateForm",Zy);function Qy(){const{workflow:e}=G(),t=yo();return t.useInitializers?t.useInitializers(e.config):null}const Xy={customForm:An.title,record:`{{t("Data record", { ns: "${d}" })}}`};function Ry(){var r,s;const e=F.useFieldSchema(),t=(s=Xy[(r=e["x-designer-props"])==null?void 0:r.type])!=null?s:'{{t("Block")}}',o=i.useCompile();return n.jsxs(i.GeneralSchemaDesigner,{title:o(t),children:[n.jsx(i.SchemaSettings.BlockTitleItem,{}),n.jsx(i.SchemaSettings.Divider,{}),n.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}function eg(e){const{collections:t}=i.useCollectionManager(),o=Te(),r=ct(o),s=[Qy()].filter(Boolean),a=r.map(u=>{var f;const p=K.get(u.type);return(f=p==null?void 0:p.useInitializers)==null?void 0:f.call(p,u)}).filter(Boolean),l=[...s,...a.length?[{key:"nodes",type:"subMenu",title:`{{t("Node result", { ns: "${d}" })}}`,children:a}]:[]].filter(Boolean),c=[...l.length?[{type:"itemGroup",title:'{{t("Data blocks")}}',children:l}]:[],{type:"itemGroup",title:'{{t("Form")}}',children:Array.from(Ce.getValues()).map(u=>{const{useInitializer:p}=u.config;return p({collections:t})})},{type:"itemGroup",title:'{{t("Other blocks")}}',children:[{type:"item",title:'{{t("Markdown")}}',component:"MarkdownBlockInitializer"}]}];return n.jsx(i.SchemaInitializer.Button,C(v({},e),{wrap:i.gridRowColWrap,items:c,title:"{{t('Add block')}}"}))}function tg(){var w,T,$;const e=y.useContext(i.SchemaComponentContext),{t}=oe.useTranslation(),o=F.useFieldSchema(),r=pe(),[s,a]=y.useState(!1),[l,c]=y.useState(($=(T=(w=o==null?void 0:o["x-action-settings"])==null?void 0:w.assignedValues)==null?void 0:T.schema)!=null?$:{type:"void","x-component":"Grid","x-initializer":"CustomFormItemInitializers",properties:{}}),[u,p]=y.useState(null),{components:f}=i.useSchemaOptionsContext();y.useEffect(()=>{p(new F.Schema({properties:{grid:l}}))},[l]);const g=y.useMemo(()=>{var M,_;const D=(_=(M=o==null?void 0:o["x-action-settings"])==null?void 0:M.assignedValues)==null?void 0:_.values;return se.createForm({initialValues:X.lodash.cloneDeep(D),values:X.lodash.cloneDeep(D)})},[]),x=i.useFormActiveFields(),h=t("Assign field values");function m(){a(!1)}function k(){o["x-action-settings"]||(o["x-action-settings"]={}),o["x-action-settings"].assignedValues||(o["x-action-settings"].assignedValues={}),o["x-action-settings"].assignedValues.schema=l,o["x-action-settings"].assignedValues.values=g.values,a(!1),setTimeout(()=>{var D;(D=e.refresh)==null||D.call(e)},300)}return n.jsxs(n.Fragment,{children:[n.jsx(i.SchemaSettings.Item,{title:h,onClick:()=>a(!0),children:h}),n.jsx(b.Modal,{width:"50%",title:h,open:s,onCancel:m,footer:n.jsxs(b.Space,{children:[n.jsx(b.Button,{onClick:m,children:t("Cancel")}),n.jsx(b.Button,{type:"primary",onClick:k,children:t("Submit")})]}),children:n.jsx(i.DefaultValueProvider,{isAllowToSetDefaultValue:()=>!1,children:n.jsx(i.VariableScopeProvider,{scope:r,children:n.jsx(i.FormActiveFieldsProvider,{name:"form",getActiveFieldsName:x==null?void 0:x.getActiveFieldsName,children:n.jsx(F.FormProvider,{form:g,children:n.jsxs(Se.FormLayout,{layout:"vertical",children:[n.jsx(b.Alert,{message:N("Values preset in this form will override user submitted ones when continue or reject.")}),n.jsx("br",{}),s&&u&&n.jsx(i.SchemaComponentContext.Provider,{value:C(v({},e),{refresh(){c(X.lodash.get(u.toJSON(),"properties.grid"))}}),children:n.jsx(i.SchemaComponent,{schema:u,components:f})})]})})})})})})]})}function og(e){return n.jsxs(i.GeneralSchemaDesigner,C(v({},e),{disableInitializer:!0,children:[n.jsx(i.Action.Designer.ButtonEditor,{}),n.jsx(tg,{}),n.jsx(i.SchemaSettings.Divider,{}),n.jsx(i.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function rg(s){var a=s,{action:e,actionProps:t,insert:o}=a,r=W(a,["action","actionProps","insert"]);return n.jsx(i.SchemaInitializer.Item,C(v({},r),{onClick:()=>{o({type:"void",title:r.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:e},"x-component":"Action","x-component-props":C(v({},t),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function Tn(r){var s=r,{action:e,actionProps:t}=s,o=W(s,["action","actionProps"]);return n.jsx(i.InitializerWithSwitch,C(v({},o),{schema:{type:"void",title:o.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:e},"x-component":"Action","x-component-props":C(v({},t),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${e}`},type:"x-action"}))}function ng(e){return n.jsx(i.SchemaInitializer.Button,C(v({},e),{items:[{key:ee.RESOLVED,type:"item",title:`{{t("Continue the process", { ns: "${d}" })}}`,component:rg,action:ee.RESOLVED,actionProps:{type:"primary"}},{key:ee.REJECTED,type:"item",title:`{{t("Terminate the process", { ns: "${d}" })}}`,component:Tn,action:ee.REJECTED,actionProps:{danger:!0}},{key:ee.PENDING,type:"item",title:`{{t("Save temporarily", { ns: "${d}" })}}`,component:Tn,action:ee.PENDING}],title:"{{t('Configure actions')}}"}))}function sg(){return{run(){}}}function ag({value:e,onChange:t}){const o=y.useContext(i.SchemaComponentContext),r=yo(),s=Te(),a=ct(s),l=F.useForm(),{workflow:c}=G(),u={},p={};a.forEach(x=>{const h=K.get(x.type);Object.assign(u,h.initializers),Object.assign(p,h.components)});const f=y.useMemo(()=>new F.Schema({properties:{drawer:{type:"void",title:`{{t("User interface", { ns: "${d}" })}}`,"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{className:i.css`
|
|
529
|
+
`),children:[r.jsx(Oe,{from:o,entry:s,branchIndex:(i=s==null?void 0:s.branchIndex)!=null?i:0}),r.jsxs("div",{className:t.branchClass,children:[r.jsx("div",{className:"workflow-branch-lines"}),r.jsx("div",{className:l.cx(t.addButtonClass,t.loopLineClass),children:r.jsx(O.ArrowUpOutlined,{})})]})]})})})},scope:{},components:{WorkflowVariableInput:qe},useScopeVariables(e,o){const n=l.useCompile(),{target:t}=e.config;if(!t)return null;const{fieldNames:s=we}=o;let i={key:"item",[s.value]:"item",[s.label]:D("Loop target")};if(typeof t=="string"&&t.startsWith("{{")&&t.endsWith("}}")){const a=t.slice(2,-2).split(".").map(p=>p.trim()),c=[Ao,no,ro].map(p=>{const f=p.useOptions(C(g({},o),{current:e})).filter(Boolean);return{[s.label]:n(p.label),[s.value]:p.value,key:p.value,[s.children]:f,disabled:f&&!f.length}}),d=nr(c,a);i=Object.assign({},d,i)}return[i,{key:"index",[s.value]:"index",[s.label]:D("Loop index")},{key:"length",[s.value]:"length",[s.label]:D("Loop length")}]}};function sr(e){const{execution:o,nodes:n}=U(),t=y.useMemo(()=>n.reduce((a,c)=>Object.assign(a,{[c.id]:c.key}),{}),[n]),s=y.useMemo(()=>{var a;return{$context:o==null?void 0:o.context,$jobsMapByNodeKey:((a=o==null?void 0:o.jobs)!=null?a:[]).reduce((c,d)=>Object.assign(c,{[t[d.nodeId]]:d.result}),{})}},[o]);return y.useMemo(()=>K.parse(e)(s),[o])}function xt(e){const o=T.useField(),n=y.useRef(null),{appends:t,updateAssociationValues:s}=l.useAssociationNames(),i=sr(e.dataSource),a=y.useMemo(()=>oe.createForm({values:i,readPretty:!0}),[i]),c={appends:t},d={loading:!1,data:{data:i}},f=l.useAPIClient().resource(e.collection),x=y.useContext(l.BlockRequestContext);return r.jsx(l.CollectionProvider,{collection:e.collection,children:r.jsx(l.RecordProvider,{record:i,parent:!1,children:r.jsx(l.BlockRequestContext.Provider,{value:{block:"form",field:o,service:d,resource:f,__parent:x},children:r.jsx(l.FormBlockContext.Provider,{value:{params:c,form:a,field:o,service:d,updateAssociationValues:s,formBlockRef:n},children:e.children})})})})}function bt(e){var w,$,P;const o=l.useRecord(),n=T.useFieldSchema(),t=T.useField(),s=y.useRef(null),{appends:i,updateAssociationValues:a}=l.useAssociationNames(),[c]=Object.keys((w=n.toJSON().properties)!=null?w:{}),d=($=o==null?void 0:o.result)==null?void 0:$[c],{findComponent:p}=l.useDesignable(),f=p((P=t.component)==null?void 0:P[0])||y.Fragment,x=y.useMemo(()=>oe.createForm({initialValues:d}),[d]),v=y.useMemo(()=>g({appends:i},e.params),[i,e.params]),h=y.useMemo(()=>({loading:!1,data:{data:d}}),[d]),S=l.useAPIClient().resource(e.collection),F=y.useContext(l.BlockRequestContext),A=y.useMemo(()=>({params:v,form:x,field:t,service:h,updateAssociationValues:a,formBlockRef:s}),[t,x,v,h,a]);return!o.status||d?r.jsx(l.CollectionProvider,{collection:e.collection,children:r.jsx(l.RecordProvider,{record:d,parent:!1,children:r.jsx(l.FormActiveFieldsProvider,{name:"form",children:r.jsx(l.BlockRequestContext.Provider,{value:{block:"form",props:e,field:t,service:h,resource:S,__parent:F},children:r.jsx(l.FormBlockContext.Provider,{value:A,children:r.jsxs(f,C(g({},t.componentProps),{children:[r.jsx(l.FormV2.Templates,{style:{marginBottom:18},form:x}),r.jsx("div",{ref:s,children:r.jsx(T.RecursionField,{schema:n,onlyRenderProperties:!0})})]}))})})})})}):null}function ir(t){var s=t,{insert:e,schema:o}=s,n=z(s,["insert","schema"]);const{getTemplateSchemaByMode:i}=l.useSchemaTemplateManager(),a=l.useRecordCollectionDataSourceItems("FormItem");function c(p){return H(this,arguments,function*({item:d}){const f=d.template?yield i(d):null,x=l.createFormBlockSchema(C(g({actionInitializers:"AddActionButton",actions:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${u}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:Z.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner","x-designer-props":{}}}},o),{template:f}));delete x["x-acl-action-props"],delete x["x-acl-action"];const[v]=Object.keys(x.properties);x.properties[v].properties.actions["x-decorator"]="ActionBarProvider",x.properties[v].properties.actions["x-component-props"].style={marginTop:"1.5em",flexWrap:"wrap"},ko(x,h=>{h["x-uid"]&&delete h["x-uid"]}),e(x)})}return r.jsx(l.SchemaInitializer.Item,C(g({},n),{onClick:c,items:a}))}function vt(e){var o;return r.jsx(l.CollectionProvider,{collection:(o=e.schema)==null?void 0:o.collection,children:r.jsx(ir,g({},e))})}function lr(){const{name:e,title:o}=l.useCollection();return r.jsxs(l.GeneralSchemaDesigner,{title:o||e,children:[r.jsx(l.SchemaSettings.BlockTitleItem,{}),r.jsx(l.SchemaSettings.LinkageRules,{collectionName:e}),r.jsx(l.SchemaSettings.DataTemplates,{collectionName:e}),r.jsx(l.SchemaSettings.Divider,{}),r.jsx(l.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const ar={title:`{{t("Create record form", { ns: "${u}" })}}`,config:{useInitializer({collections:e}){return{key:"createRecordForm",type:"subMenu",title:`{{t("Create record form", { ns: "${u}" })}}`,children:[{key:"createRecordForm-child",type:"itemGroup",style:{maxHeight:"48vh",overflowY:"auto"},loadChildren:({searchValue:o})=>e.filter(n=>!n.hidden&&n.title.toLowerCase().includes(o.toLowerCase())).map(n=>({key:`createRecordForm-child-${n.name}`,type:"item",title:n.title,schema:{collection:n.name,title:`{{t("Create record", { ns: "${u}" })}}`,formType:"create","x-designer":"CreateFormDesigner"},component:vt}))}]}},initializers:{},components:{CreateFormDesigner:lr},parseFormOptions(e){const o={};return Ce(e,t=>t["x-decorator"]==="FormBlockProvider"&&t["x-decorator-props"].formType==="create").forEach(t=>{var a;const[s]=Object.keys(t.properties),i=t.properties[s];o[s]={type:"create",title:((a=t["x-component-props"])==null?void 0:a.title)||s,actions:Ce(i.properties.actions,c=>c["x-component"]==="Action").map(c=>{var d,p;return{status:c["x-decorator-props"].value,values:(p=(d=c["x-action-settings"])==null?void 0:d.assignedValues)==null?void 0:p.values,key:c.name}}),collection:t["x-decorator-props"].collection}}),o}},block:{scope:{},components:{}}};function Ct(e){var p,f,x,v;const[o,n]=y.useState((f=(p=e.collection)==null?void 0:p.fields)!=null?f:[]),t=l.useRecord(),s=T.useField(),i=T.useFieldSchema(),[a]=Object.keys((x=i.toJSON().properties)!=null?x:{}),c=(v=t==null?void 0:t.result)==null?void 0:v[a],d=y.useMemo(()=>oe.createForm({initialValues:c}),[c]);return!t.status||c?r.jsx(l.CollectionProvider,{collection:C(g({},e.collection),{fields:o}),children:r.jsx(l.RecordProvider,{record:c,parent:!1,children:r.jsx(l.FormBlockContext.Provider,{value:{form:d,field:s,setCollectionFields:n},children:e.children})})}):null}function cr(n){var t=n,{insert:e}=t,o=z(t,["insert"]);return r.jsx(l.SchemaInitializer.Item,C(g({},o),{onClick:()=>{e({type:"void","x-decorator":"CustomFormBlockProvider","x-decorator-props":{collection:{name:K.uid(),fields:[]}},"x-component":"CardItem","x-component-props":{title:'{{t("Form")}}'},"x-designer":"SimpleDesigner","x-designer-props":{type:"customForm"},properties:{[K.uid()]:{type:"void","x-component":"FormV2","x-component-props":{useProps:"{{ useFormBlockProps }}"},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"AddCustomFormField"},actions:{type:"void","x-decorator":"ActionBarProvider","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:"1.5em",flexWrap:"wrap"}},"x-initializer":"AddActionButton",properties:{resolve:{type:"void",title:`{{t("Continue the process", { ns: "${u}" })}}`,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:Z.RESOLVED},"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSubmit }}"},"x-designer":"ManualActionDesigner"}}}}}}})}}))}const wt={basic:'{{t("Basic")}}',choices:'{{t("Choices")}}',media:'{{t("Media")}}',datetime:'{{t("Date & Time")}}',relation:'{{t("Relation")}}',advanced:'{{t("Advanced type")}}',systemInfo:'{{t("System info")}}',others:'{{t("Others")}}'};function dr(e){const o={};return Object.keys(e).forEach(n=>{const t=e[n],{group:s="others"}=t;o[s]=o[s]||{},be.set(o,[s,n],t)}),Object.keys(wt).filter(n=>["basic","choices","datetime","media"].includes(n)).map(n=>({title:wt[n],children:Object.keys(o[n]||{}).map(t=>{const s=o[n][t];return g({value:t,title:s.title,name:t},o[n][t])}).sort((t,s)=>t.order-s.order)}))}function ur(){const{interfaces:e}=l.useCollectionManager();return dr(e).map(n=>({key:n.title,type:"itemGroup",title:n.title,children:n.children.map(t=>({key:t.name,type:"item",title:t.title,component:mr,fieldInterface:t.name}))}))}const kt=y.createContext({});function pr(e){const{insertPosition:o="beforeEnd",component:n}=e,t=ur(),s=y.useContext(l.CollectionContext),[i,a]=y.useState(null),[c,d]=y.useState(),{setCollectionFields:p}=y.useContext(l.FormBlockContext);return r.jsxs(kt.Provider,{value:{onAddField(f){const S=be.cloneDeep(f),{properties:F}=S,A=F,{unique:x,type:v}=A,h=z(A,["unique","type"]),m=z(S,["properties"]);delete h.name["x-disabled"],a(C(g({},m),{properties:h}))},setCallback:d},children:[r.jsx(l.SchemaInitializer.Button,{wrap:l.gridRowColWrap,insertPosition:o,items:t,component:n,title:"{{t('Configure fields')}}"}),r.jsx(l.ActionContextProvider,{value:{visible:!!i},children:i?r.jsx(l.SchemaComponent,{schema:{type:"void",name:"drawer",title:'{{t("Configure field")}}',"x-decorator":"Form","x-component":"Action.Drawer",properties:C(g({},i.properties),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction(){const f=T.useForm();return{run(){return H(this,null,function*(){d(null),a(null),f.reset()})}}}}},submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{values:f,query:x}=T.useForm();return{run(){return H(this,null,function*(){var A,w,$,P;const{default:h}=i,m=K.uid();if(h.name=(A=f.name)!=null?A:m,h.uiSchema.title=($=(w=f.uiSchema)==null?void 0:w.title)!=null?$:m,h.interface=i.name,(P=s.fields)==null?void 0:P.find(B=>B.name===h.name)){x("name").take().setFeedback({type:"error",messages:[D("Field name existed in form")]});return}const F=K.merge(h,f);p([...s.fields,F]),c({name:h.name,type:h.uiSchema.type,"x-decorator":"FormItem","x-component":"CollectionField","x-component-props":{field:F},"x-collection-field":`${s.name}.${h.name}`,"x-designer":"FormItem.Designer"}),d(null),a(null)})}}}}}}}})},components:{ArrayTable:ve.ArrayTable}}):null})]})}function mr(e){const{item:o,insert:n}=e,{onAddField:t,setCallback:s}=y.useContext(kt),{getInterface:i}=l.useCollectionManager(),a=i(o.fieldInterface);return r.jsx(l.SchemaInitializer.Item,{onClick:()=>{s(()=>n),t(a)}},o.fieldInterface)}const St={title:`{{t("Custom form", { ns: "${u}" })}}`,config:{useInitializer(){return{key:"customForm",type:"item",title:`{{t("Custom form", { ns: "${u}" })}}`,component:cr}},initializers:{AddCustomFormField:pr},components:{CustomFormBlockProvider:Ct},parseFormOptions(e){const o={};return Ce(e,t=>t["x-decorator"]==="CustomFormBlockProvider").forEach(t=>{var c;const[s]=Object.keys(t.properties),i=t.properties[s],a=Ce(i.properties.grid,d=>d["x-component"]==="CollectionField",!0);t["x-decorator-props"].collection.fields=a.map(d=>{var p,f;return(f=(p=d["x-component-props"])==null?void 0:p.field)!=null?f:d["x-interface-options"]}),o[s]={type:"custom",title:((c=t["x-component-props"])==null?void 0:c.title)||s,actions:Ce(i.properties.actions,d=>d["x-component"]==="Action").map(d=>{var p,f;return{status:d["x-decorator-props"].value,values:(f=(p=d["x-action-settings"])==null?void 0:p.assignedValues)==null?void 0:f.values,key:d.name}}),collection:t["x-decorator-props"].collection}}),o}},block:{scope:{},components:{CustomFormBlockProvider:Ct}}};function fr(){const{name:e,title:o}=l.useCollection(),n=T.useFieldSchema(),{t}=R.useTranslation(),{dn:s}=l.useDesignable();return r.jsxs(l.GeneralSchemaDesigner,{title:o||e,children:[r.jsx(l.SchemaSettings.BlockTitleItem,{}),r.jsx(l.SchemaSettings.ActionModalItem,{title:t("Filter settings",{ns:u}),schema:{name:"filter",type:"object",title:'{{t("Filter")}}',"x-component":"Filter","x-component-props":{useProps(){var a;return{options:l.useCollectionFilterOptions((a=n==null?void 0:n["x-decorator-props"])==null?void 0:a.collection)}},dynamicComponent:"FilterDynamicComponent"}},initialValues:n==null?void 0:n["x-decorator-props"],onSubmit:({filter:i})=>{n["x-decorator-props"].filter=i,s.emit("patch",{schema:{"x-decorator-props":n["x-decorator-props"]}}),s.refresh()}}),r.jsx(l.SchemaSettings.LinkageRules,{collectionName:e}),r.jsx(l.SchemaSettings.Divider,{}),r.jsx(l.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const hr={title:`{{t("Update record form", { ns: "${u}" })}}`,config:{useInitializer({collections:e}){return{key:"updateRecordForm",type:"subMenu",title:`{{t("Update record form", { ns: "${u}" })}}`,children:[{key:"updateRecordForm-child",type:"itemGroup",style:{maxHeight:"48vh",overflowY:"auto"},loadChildren:({searchValue:o})=>e.filter(n=>!n.hidden&&n.title.toLowerCase().includes(o.toLowerCase())).map(n=>({key:`updateRecordForm-child-${n.name}`,type:"item",title:n.title,schema:{collection:n.name,title:`{{t("Update record", { ns: "${u}" })}}`,formType:"update","x-designer":"UpdateFormDesigner"},component:vt}))}]}},initializers:{},components:{FilterDynamicComponent:Ge,UpdateFormDesigner:fr},parseFormOptions(e){const o={};return Ce(e,t=>t["x-decorator"]==="FormBlockProvider"&&t["x-decorator-props"].formType==="update").forEach(t=>{var a;const[s]=Object.keys(t.properties),i=t.properties[s];o[s]=C(g({},t["x-decorator-props"]),{type:"update",title:((a=t["x-component-props"])==null?void 0:a.title)||s,actions:Ce(i.properties.actions,c=>c["x-component"]==="Action").map(c=>{var d,p;return{status:c["x-decorator-props"].value,values:(p=(d=c["x-action-settings"])==null?void 0:d.assignedValues)==null?void 0:p.values,key:c.name}})})}),o}},block:{scope:{},components:{}}},ge=new K.Registry;ge.register("customForm",St),ge.register("createForm",ar),ge.register("updateForm",hr);function yr(){const{workflow:e}=U(),o=So();return o.useInitializers?o.useInitializers(e.config):null}const gr={customForm:St.title,record:`{{t("Data record", { ns: "${u}" })}}`};function xr(){var t,s;const e=T.useFieldSchema(),o=(s=gr[(t=e["x-designer-props"])==null?void 0:t.type])!=null?s:'{{t("Block")}}',n=l.useCompile();return r.jsxs(l.GeneralSchemaDesigner,{title:n(o),children:[r.jsx(l.SchemaSettings.BlockTitleItem,{}),r.jsx(l.SchemaSettings.Divider,{}),r.jsx(l.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}function br(e){const{collections:o}=l.useCollectionManager(),n=ke(),t=Je(n),s=[yr()].filter(Boolean),i=t.map(d=>{var f;const p=q.get(d.type);return(f=p==null?void 0:p.useInitializers)==null?void 0:f.call(p,d)}).filter(Boolean),a=[...s,...i.length?[{key:"nodes",type:"subMenu",title:`{{t("Node result", { ns: "${u}" })}}`,children:i}]:[]].filter(Boolean),c=[...a.length?[{type:"itemGroup",title:'{{t("Data blocks")}}',children:a}]:[],{type:"itemGroup",title:'{{t("Form")}}',children:Array.from(ge.getValues()).map(d=>{const{useInitializer:p}=d.config;return p({collections:o})})},{type:"itemGroup",title:'{{t("Other blocks")}}',children:[{type:"item",title:'{{t("Markdown")}}',component:"MarkdownBlockInitializer"}]}];return r.jsx(l.SchemaInitializer.Button,C(g({},e),{wrap:l.gridRowColWrap,items:c,title:"{{t('Add block')}}"}))}function vr(){var F,A,w;const e=y.useContext(l.SchemaComponentContext),{t:o}=R.useTranslation(),n=T.useFieldSchema(),t=ce(),[s,i]=y.useState(!1),[a,c]=y.useState((w=(A=(F=n==null?void 0:n["x-action-settings"])==null?void 0:F.assignedValues)==null?void 0:A.schema)!=null?w:{type:"void","x-component":"Grid","x-initializer":"CustomFormItemInitializers",properties:{}}),[d,p]=y.useState(null),{components:f}=l.useSchemaOptionsContext();y.useEffect(()=>{p(new T.Schema({properties:{grid:a}}))},[a]);const x=y.useMemo(()=>{var P,B;const $=(B=(P=n==null?void 0:n["x-action-settings"])==null?void 0:P.assignedValues)==null?void 0:B.values;return oe.createForm({initialValues:K.lodash.cloneDeep($),values:K.lodash.cloneDeep($)})},[]),v=l.useFormActiveFields(),h=o("Assign field values");function m(){i(!1)}function S(){n["x-action-settings"]||(n["x-action-settings"]={}),n["x-action-settings"].assignedValues||(n["x-action-settings"].assignedValues={}),n["x-action-settings"].assignedValues.schema=a,n["x-action-settings"].assignedValues.values=x.values,i(!1),setTimeout(()=>{var $;($=e.refresh)==null||$.call(e)},300)}return r.jsxs(r.Fragment,{children:[r.jsx(l.SchemaSettings.Item,{title:h,onClick:()=>i(!0),children:h}),r.jsx(b.Modal,{width:"50%",title:h,open:s,onCancel:m,footer:r.jsxs(b.Space,{children:[r.jsx(b.Button,{onClick:m,children:o("Cancel")}),r.jsx(b.Button,{type:"primary",onClick:S,children:o("Submit")})]}),children:r.jsx(l.DefaultValueProvider,{isAllowToSetDefaultValue:()=>!1,children:r.jsx(l.VariableScopeProvider,{scope:t,children:r.jsx(l.FormActiveFieldsProvider,{name:"form",getActiveFieldsName:v==null?void 0:v.getActiveFieldsName,children:r.jsx(T.FormProvider,{form:x,children:r.jsxs(ve.FormLayout,{layout:"vertical",children:[r.jsx(b.Alert,{message:D("Values preset in this form will override user submitted ones when continue or reject.")}),r.jsx("br",{}),s&&d&&r.jsx(l.SchemaComponentContext.Provider,{value:C(g({},e),{refresh(){c(K.lodash.get(d.toJSON(),"properties.grid"))}}),children:r.jsx(l.SchemaComponent,{schema:d,components:f})})]})})})})})})]})}function Cr(e){return r.jsxs(l.GeneralSchemaDesigner,C(g({},e),{disableInitializer:!0,children:[r.jsx(l.Action.Designer.ButtonEditor,{}),r.jsx(vr,{}),r.jsx(l.SchemaSettings.Divider,{}),r.jsx(l.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"ActionBar"}})]}))}function wr(s){var i=s,{action:e,actionProps:o,insert:n}=i,t=z(i,["action","actionProps","insert"]);return r.jsx(l.SchemaInitializer.Item,C(g({},t),{onClick:()=>{n({type:"void",title:t.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:e},"x-component":"Action","x-component-props":C(g({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"ManualActionDesigner","x-action-settings":{}})}}))}function Ft(t){var s=t,{action:e,actionProps:o}=s,n=z(s,["action","actionProps"]);return r.jsx(l.InitializerWithSwitch,C(g({},n),{schema:{type:"void",title:n.title,"x-decorator":"ManualActionStatusProvider","x-decorator-props":{value:e},"x-component":"Action","x-component-props":C(g({},o),{useAction:"{{ useSubmit }}"}),"x-designer":"Action.Designer","x-action":`${e}`},type:"x-action"}))}function kr(e){return r.jsx(l.SchemaInitializer.Button,C(g({},e),{items:[{key:Z.RESOLVED,type:"item",title:`{{t("Continue the process", { ns: "${u}" })}}`,component:wr,action:Z.RESOLVED,actionProps:{type:"primary"}},{key:Z.REJECTED,type:"item",title:`{{t("Terminate the process", { ns: "${u}" })}}`,component:Ft,action:Z.REJECTED,actionProps:{danger:!0}},{key:Z.PENDING,type:"item",title:`{{t("Save temporarily", { ns: "${u}" })}}`,component:Ft,action:Z.PENDING}],title:"{{t('Configure actions')}}"}))}function Sr(){return{run(){}}}function Fr({value:e,onChange:o}){const n=y.useContext(l.SchemaComponentContext),t=So(),s=ke(),i=Je(s),a=T.useForm(),{workflow:c}=U(),d={},p={};i.forEach(v=>{const h=q.get(v.type);Object.assign(d,h.initializers),Object.assign(p,h.components)});const f=y.useMemo(()=>new T.Schema({properties:{drawer:{type:"void",title:`{{t("User interface", { ns: "${u}" })}}`,"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{className:l.css`
|
|
530
530
|
.ant-drawer-body {
|
|
531
531
|
background: var(--nb-box-bg);
|
|
532
532
|
}
|
|
533
|
-
`},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"TabPaneInitializers","x-initializer-props":{gridInitializer:"AddBlockButton"},properties:e!=null?e:{tab1:{type:"void",title:`{{t("Manual", { ns: "${
|
|
533
|
+
`},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"TabPaneInitializers","x-initializer-props":{gridInitializer:"AddBlockButton"},properties:e!=null?e:{tab1:{type:"void",title:`{{t("Manual", { ns: "${u}" })}}`,"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"AddBlockButton",properties:{}}}}}}}}}}),[]),x=y.useCallback(function(){const{tabs:h}=K.lodash.get(f.toJSON(),"properties.drawer.properties"),m=Array.from(ge.getValues()).reduce((S,F)=>Object.assign(S,F.config.parseFormOptions(h)),{});a.setValuesIn("forms",m),o(h.properties)},[a,o,f]);return r.jsx(l.SchemaComponentContext.Provider,{value:C(g({},n),{designable:!c.executed,refresh:x}),children:r.jsx(l.SchemaInitializerProvider,{initializers:g(g(g({AddBlockButton:br,AddActionButton:kr},t.initializers),d),Array.from(ge.getValues()).reduce((v,h)=>Object.assign(v,h.config.initializers),{})),children:r.jsx(l.SchemaComponent,{schema:f,components:C(g(g({},p),Array.from(ge.getValues()).reduce((v,h)=>Object.assign(v,h.config.components),{})),{FormBlockProvider:bt,DetailsBlockProvider:xt,ManualActionStatusProvider(v){return v.children},ActionBarProvider(v){return v.children},SimpleDesigner:xr,ManualActionDesigner:Cr}),scope:{useSubmit:Sr,useDetailsBlockProps:l.useFormBlockContext}})})})}function Ar(e){const{workflow:o}=U(),[n,t]=y.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(b.Button,{type:"primary",onClick:()=>t(!0),disabled:!1,children:o.executed?D("View user interface"):D("Configure user interface")}),r.jsx(l.ActionContextProvider,{value:{visible:n,setVisible:t,formValueChanged:!1},children:e.children})]})}function Or({value:e,onChange:o}){return r.jsxs("fieldset",{className:l.css`
|
|
534
534
|
.ant-radio-group {
|
|
535
535
|
.anticon {
|
|
536
536
|
margin-left: 0.5em;
|
|
537
537
|
}
|
|
538
538
|
}
|
|
539
|
-
`,children:[
|
|
539
|
+
`,children:[r.jsx(b.Form.Item,{children:r.jsxs(b.Radio.Group,{value:!!e,onChange:({target:{value:n}})=>{console.log(n),o(Number(n))},children:[r.jsx(b.Radio,{value:!0,children:r.jsxs(b.Tooltip,{title:D("Each user has own task"),placement:"bottom",children:[r.jsx("span",{children:D("Separately")}),r.jsx(O.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(b.Radio,{value:!1,children:r.jsxs(b.Tooltip,{title:D("Everyone shares one task"),placement:"bottom",children:[r.jsx("span",{children:D("Collaboratively")}),r.jsx(O.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})}),e?r.jsx("fieldset",{children:r.jsx(ve.FormLayout,{layout:"vertical",children:r.jsx(l.FormItem,{label:D("Negotiation"),children:r.jsxs(b.Radio.Group,{value:e,onChange:o,children:[r.jsx(b.Radio,{value:1,children:r.jsxs(b.Tooltip,{title:D("Everyone should pass"),placement:"bottom",children:[r.jsx("span",{children:D("All pass")}),r.jsx(O.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(b.Radio,{value:-1,children:r.jsxs(b.Tooltip,{title:D("Anyone pass"),placement:"bottom",children:[r.jsx("span",{children:D("Any pass")}),r.jsx(O.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})})})}):null]})}function Tr(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function $r({multiple:e=!1,value:o=[],onChange:n}){const t=ce({types:[Tr]});return r.jsx(l.Variable.Input,{scope:t,value:o[0],onChange:s=>{n([s])},children:r.jsx(l.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:o[0],onChange:s=>{n(s!=null?[s]:[])}})})}const At=l.BlockInitializers.items.find(e=>e.key==="media");At.children.find(e=>e.key==="workflowTodos")||At.children.push({key:"workflowTodos",type:"item",title:`{{t("Workflow todos", { ns: "${u}" })}}`,component:"WorkflowTodoBlockInitializer",icon:"CheckSquareOutlined"});const Dr={title:`{{t("Manual", { ns: "${u}" })}}`,type:"manual",group:"manual",description:`{{t("Could be used for manually submitting data, and determine whether to continue or exit. Workflow will generate a todo item for assigned user when it reaches a manual node, and continue processing after user submits the form.", { ns: "${u}" })}}`,fieldset:{assignees:{type:"array",title:`{{t("Assignees", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"AssigneesSelect","x-component-props":{},required:!0,default:[]},mode:{type:"number",title:`{{t("Mode", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"ModeConfig",default:1,"x-reactions":{dependencies:["assignees"],fulfill:{state:{visible:"{{$deps[0].length > 1}}"}}}},schema:{type:"void",title:`{{t("User interface", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"SchemaConfigButton",properties:{schema:{type:"object","x-component":"SchemaConfig",default:null}}},forms:{type:"object",default:{}}},view:{},scope:{},components:{SchemaConfigButton:Ar,SchemaConfig:Fr,ModeConfig:Or,AssigneesSelect:$r},useVariables({key:e,title:o,config:n},{types:t,fieldNames:s=we}){var p;const i=l.useCompile(),{getCollectionFields:a}=l.useCollectionManager(),c=Object.keys((p=n.forms)!=null?p:{});if(!c.length)return null;const d=c.map(f=>{var m;const x=n.forms[f],v=fe({fields:(m=x.collection)==null?void 0:m.fields,collection:x.collection,types:t,compile:i,getCollectionFields:a}),h=i(x.title)||f;return v.length?{key:f,value:f,label:h,title:h,children:v}:null}).filter(Boolean);return d.length?{[s.value]:e,[s.label]:o,[s.children]:d}:null},useInitializers(e){var s;const{getCollection:o}=l.useCollectionManager(),n=Object.keys((s=e.config.forms)!=null?s:{});if(!n.length||e.config.mode)return null;const t=n.map(i=>{var d;const a=e.config.forms[i],{fields:c=[]}=o(a.collection);return c.length?{type:"item",title:(d=a.title)!=null?d:i,component:Te,collection:a.collection,dataSource:`{{$jobsMapByNodeKey.${e.key}.${i}}}`}:null}).filter(Boolean);return t.length?{key:"forms",type:"subMenu",title:e.title,children:t}:null},initializers:{}},Ir={title:`{{t("Parallel branch", { ns: "${u}" })}}`,type:"parallel",group:"control",description:`{{t("Run multiple branch processes in parallel.", { ns: "${u}" })}}`,fieldset:{mode:{type:"string",title:`{{t("Mode", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{value:"all",label:`{{t('All succeeded', { ns: "${u}" })}}`,tooltip:`{{t('Continue after all branches succeeded', { ns: "${u}" })}}`},{value:"any",label:`{{t('Any succeeded', { ns: "${u}" })}}`,tooltip:`{{t('Continue after any branch succeeded', { ns: "${u}" })}}`},{value:"race",label:`{{t('Any succeeded or failed', { ns: "${u}" })}}`,tooltip:`{{t('Continue after any branch succeeded, or exit after any branch failed.', { ns: "${u}" })}}`}]},default:"all"}},view:{},component:function({data:o}){const{styles:n}=te(),{id:t,config:{mode:s}}=o,{workflow:i,nodes:a}=U(),c=a.reduce((h,m)=>m.upstreamId===t&&m.branchIndex!=null?h.concat(m):h,[]).sort((h,m)=>h.branchIndex-m.branchIndex),[d,p]=y.useState(Math.max(2,c.length)),{getAriaLabel:f}=Co(o),x=Array(Math.max(0,d-c.length)).fill(null),v=c[c.length-1];return r.jsx(He,{data:o,children:r.jsxs("div",{className:n.nodeSubtreeClass,children:[r.jsxs("div",{className:n.branchBlockClass,children:[c.map(h=>r.jsx(Oe,{from:o,entry:h,branchIndex:h.branchIndex},h.id)),x.map((h,m)=>r.jsx(Oe,{from:o,branchIndex:(v?v.branchIndex:0)+m+1,controller:c.length+m>1?r.jsx("div",{className:l.css`
|
|
540
540
|
padding-top: 2em;
|
|
541
541
|
|
|
542
542
|
> button {
|
|
@@ -544,9 +544,9 @@
|
|
|
544
544
|
transform: rotate(45deg);
|
|
545
545
|
}
|
|
546
546
|
}
|
|
547
|
-
`,children:
|
|
548
|
-
visibility: ${
|
|
549
|
-
`,children:
|
|
547
|
+
`,children:r.jsx(b.Button,{shape:"circle",icon:r.jsx(O.PlusOutlined,{}),onClick:()=>p(d-1),disabled:i.executed})}):null},`temp_${c.length+m}`))]}),r.jsx(b.Tooltip,{title:D("Add branch"),className:l.css`
|
|
548
|
+
visibility: ${i.executed?"hidden":"visible"};
|
|
549
|
+
`,children:r.jsx(b.Button,{"aria-label":f("add-branch"),icon:r.jsx(O.PlusOutlined,{}),className:l.css`
|
|
550
550
|
position: relative;
|
|
551
551
|
top: 1em;
|
|
552
552
|
transform-origin: center;
|
|
@@ -556,10 +556,10 @@
|
|
|
556
556
|
transform-origin: center;
|
|
557
557
|
transform: rotate(-45deg);
|
|
558
558
|
}
|
|
559
|
-
`,onClick:()=>p(
|
|
559
|
+
`,onClick:()=>p(d+1),disabled:i.executed})})]})})},components:{RadioWithTooltip:io}},Nr={title:`{{t("Query record", { ns: "${u}" })}}`,type:"query",group:"collection",description:`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${u}" })}}`,fieldset:{collection:ae,multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${u}" })}}`,description:`{{t("If checked, when there are multiple records in the query result, an array will be returned as the result, which can be operated on one by one using a loop node. Otherwise, only one record will be returned.", { ns: "${u}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:$e,sort:un,pagination:pn,appends:De},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{$deps[0] != null}}"}}}]},failOnEmpty:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Exit when query result is null", { ns: "${u}" })}}`}},view:{},scope:{useCollectionDataSource:l.useCollectionDataSource,useSortableFields(){const e=l.useCompile(),{getCollectionFields:o,getInterface:n}=l.useCollectionManager(),{values:t}=T.useForm();return o(t.collection).filter(i=>{if(!i.interface)return!1;const a=n(i.interface);return!!(a!=null&&a.sortable)}).map(i=>{var a,c;return{value:i.name,label:(a=i==null?void 0:i.uiSchema)!=null&&a.title?e((c=i==null?void 0:i.uiSchema)==null?void 0:c.title):i.name}})}},components:{ArrayItems:ve.ArrayItems,FilterDynamicComponent:Ge,SchemaComponentContext:l.SchemaComponentContext,WorkflowVariableInput:qe},useVariables({key:e,title:o,config:n},t){var c,d;const s=l.useCompile(),{getCollectionFields:i}=l.useCollectionManager(),[a]=fe(C(g({appends:[e,...((d=(c=n.params)==null?void 0:c.appends)==null?void 0:d.map(p=>`${e}.${p}`))||[]]},t),{fields:[{collectionName:n.collection,name:e,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:s,getCollectionFields:i}));return a},useInitializers(e){var o;return!e.config.collection||e.config.multiple?null:{type:"item",title:(o=e.title)!=null?o:`#${e.id}`,component:Te,collection:e.config.collection,dataSource:`{{$jobsMapByNodeKey.${e.key}}}`}},initializers:{}},Er={title:`{{t("HTTP request", { ns: "${u}" })}}`,type:"request",group:"extended",description:`{{t("Send HTTP request to a URL. You can use the variables in the upstream nodes as request headers, parameters and request body.", { ns: "${u}" })}}`,fieldset:{method:{type:"string",required:!0,title:`{{t("HTTP method", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1,className:"auto-width"},enum:[{label:"GET",value:"GET"},{label:"POST",value:"POST"},{label:"PUT",value:"PUT"},{label:"PATCH",value:"PATCH"},{label:"DELETE",value:"DELETE"}],default:"POST"},url:{type:"string",required:!0,title:`{{t("URL", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"Input","x-component-props":{placeholder:"https://www.nocobase.com"}},headers:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Headers", { ns: "${u}" })}}`,description:`{{t('"Content-Type" only support "application/json", and no need to specify', { ns: "${u}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add request header", { ns: "${u}" })}}`,"x-component":"ArrayItems.Addition"}}},params:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Parameters", { ns: "${u}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add parameter", { ns: "${u}" })}}`,"x-component":"ArrayItems.Addition"}}},data:{type:"string",title:`{{t("Body", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"WorkflowVariableJSON","x-component-props":{changeOnSelect:!0,autoSize:{minRows:10},placeholder:`{{t("Input request data", { ns: "${u}" })}}`},description:`{{t("Only support standard JSON data", { ns: "${u}" })}}`},timeout:{type:"number",title:`{{t("Timeout config", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"InputNumber","x-component-props":{addonAfter:`{{t("ms", { ns: "${u}" })}}`,min:1,step:1e3,defaultValue:5e3}},ignoreFail:{type:"boolean",title:`{{t("Ignore failed request and continue workflow", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox"}},view:{},scope:{},components:{ArrayItems:ve.ArrayItems,WorkflowVariableInput:qe,WorkflowVariableJSON:pt},useVariables({key:e,title:o},{types:n,fieldNames:t=l.defaultFieldNames}){return{[t.value]:e,[t.label]:o}}},Mr={title:`{{t("SQL action", { ns: "${u}" })}}`,type:"sql",group:"collection",description:`{{t("Execute a SQL statement in database.", { ns: "${u}" })}}`,fieldset:{sql:{type:"string",required:!0,title:"SQL",description:`{{t("Usage of SQL query result is not supported yet.", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableRawTextArea","x-component-props":{rows:20,className:l.css`
|
|
560
560
|
font-size: 80%;
|
|
561
561
|
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
|
562
|
-
`}}},scope:{},components:{WorkflowVariableRawTextArea:
|
|
562
|
+
`}}},scope:{},components:{WorkflowVariableRawTextArea:ut},useVariables({key:e,title:o},{types:n,fieldNames:t=l.defaultFieldNames}){return{[t.value]:e,[t.label]:o}}};function Pr(n){var t=n,{onChange:e}=t,o=z(t,["onChange"]);const{getCollectionFields:s}=l.useCollectionManager(),i=T.useForm(),{collection:a}=i.values,c=s(a),d=T.useField();function p({target:f}){const x=d.query(".values").take();if(!x)return;const v=c.reduce((h,m)=>(m.name in x.value&&(f.value||!["hasOne","hasMany","belongsToMany"].includes(m.type))&&(h[m.name]=x.value[m.name]),h),{});i.setValuesIn("params.values",v),e(f.value)}return r.jsx(io,C(g({},o),{onChange:p}))}const Br={title:`{{t("Update record", { ns: "${u}" })}}`,type:"update",group:"collection",description:`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${u}" })}}`,fieldset:{collection:ae,params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${u}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.", { ns: "${u}" })}}`},{label:`{{t("Update one by one", { ns: "${u}" })}}`,value:!0,tooltip:`{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${u}" })}}`}]},default:!1},filter:C(g({},$e),{title:`{{t("Only update records matching conditions", { ns: "${u}" })}}`,"x-validator"(e){return No(e)?"":D("Please add at least one condition")}}),values:C(g({},qo),{"x-component-props":{filter(e){var o;return((o=this.params)==null?void 0:o.individualHooks)||!["hasOne","hasMany","belongsToMany"].includes(e.type)}}})}}},view:{},scope:{useCollectionDataSource:l.useCollectionDataSource},components:{FilterDynamicComponent:Ge,CollectionFieldset:yt,IndividualHooksRadioWithTooltip:Pr}},q=new K.Registry;q.register("calculation",Jn),q.register("condition",Zn),q.register("parallel",Ir),q.register("loop",rr),q.register("delay",or),q.register("manual",Dr),q.register("query",Nr),q.register("create",Xn),q.register("update",Br),q.register("destroy",tr),q.register("aggregate",Un),q.register("request",Er),q.register("sql",Mr);function Vr(){const e=T.useForm(),o=l.useAPIClient(),n=l.useActionContext(),{refresh:t}=l.useResourceActionContext(),s=ke(),{workflow:i}=U();return{run(){return H(this,null,function*(){var c,d;if(i.executed){b.message.error(D("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(d=(c=o.resource("flow_nodes")).update)==null?void 0:d.call(c,{filterByTk:s.id,values:{config:e.values}}),n.setFormValueChanged(!1),n.setVisible(!1),t()})}}}const Eo=y.createContext({});function ke(){return y.useContext(Eo)}function Je(e){const o=[];if(!e)return[];for(let n=e.upstream;n;n=n.upstream)o.push(n);return o}function Ot(e){const o=[];if(!e)return[];for(let n=e;n;n=n.upstream)n.upstream&&n.branchIndex!=null&&o.push(n.upstream);return o}function Tt({data:e}){const{styles:o}=te(),{getAriaLabel:n}=Co(e),{component:t=He}=q.get(e.type);return r.jsx(Eo.Provider,{value:e,children:r.jsxs("div",{className:l.cx(o.nodeBlockClass),children:[r.jsx(t,{data:e}),r.jsx(It,{"aria-label":n(),upstream:e})]})})}function $t(){var p;const{t:e}=R.useTranslation(),o=l.useAPIClient(),{workflow:n,nodes:t,refresh:s}=(p=U())!=null?p:{},i=ke(),{modal:a}=b.App.useApp();if(!n)return null;const c=o.resource("flow_nodes");function d(){return H(this,null,function*(){function f(){return H(this,null,function*(){var m;yield(m=c.destroy)==null?void 0:m.call(c,{filterByTk:i.id}),s()})}const x=t.filter(m=>m===i?!1:K.parse(m.config).parameters.filter(({key:A})=>A.startsWith(`$jobsMapByNodeKey.${i.key}.`)||A===`$jobsMapByNodeKey.${i.key}`).length);if(x.length){a.error({title:D("Can not delete"),content:D("The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",{nodes:x.map(m=>`#${m.id}`).join(", ")})});return}const h=!t.find(m=>m.upstream===i&&m.branchIndex!=null)?e("Are you sure you want to delete it?"):D("This node contains branches, deleting will also be preformed to them, are you sure?");a.confirm({title:e("Delete"),content:h,onOk:f})})}return n.executed?null:r.jsx(b.Button,{type:"text",shape:"circle",icon:r.jsx(O.DeleteOutlined,{}),onClick:d,className:"workflow-node-remove-button"})}function Dt(){var i;const{execution:e,setViewJob:o}=U(),{jobs:n}=(i=ke())!=null?i:{},{styles:t}=te();if(!e)return null;if(!n.length)return r.jsx(We,{className:t.nodeJobButtonClass,disabled:!0});function s({key:a}){const c=n.find(d=>d.id==a);o(c)}return n.length>1?r.jsx(b.Dropdown,{menu:{items:n.map(a=>({key:a.id,label:r.jsxs(r.Fragment,{children:[r.jsx(We,{statusMap:Le,status:a.status}),r.jsx("time",{children:K.str2moment(a.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),onClick:s,className:t.dropdownClass},children:r.jsx(We,{statusMap:Le,status:n[n.length-1].status,className:t.nodeJobButtonClass})}):r.jsx(We,{statusMap:Le,status:n[0].status,onClick:()=>o(n[0]),className:t.nodeJobButtonClass})}function jr(){return{form:T.useForm()}}function He(e){var B,L;const{data:o,children:n}=e,t=l.useCompile(),s=l.useAPIClient(),{workflow:i,refresh:a}=(B=U())!=null?B:{},{styles:c}=te(),d=q.get(o.type),p=i.executed?'{{t("View")}}':'{{t("Configure")}}',f=t(d.title),[x,v]=y.useState((L=o.title)!=null?L:f),[h,m]=y.useState(!1),[S,F]=y.useState(!1),A=y.useMemo(()=>{const E=be.cloneDeep(o.config);return oe.createForm({initialValues:E,disabled:i.executed})},[o,i]),w=y.useCallback(E=>{m(E),E||A.reset()},[A]),$=y.useCallback(function(E){return H(this,null,function*(){var I,G;const N=E||f;v(N),N!==o.title&&(yield(G=(I=s.resource("flow_nodes")).update)==null?void 0:G.call(I,{filterByTk:o.id,values:{title:N}}),a())})},[o]),P=y.useCallback(function(E){if(E.target===E.currentTarget){m(!0);return}const N=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let I=E.target;I&&I!==E.currentTarget&&I!==document.documentElement;I=I.parentNode)if(Array.from(I.classList).some(G=>N.has(G))){m(!0),E.stopPropagation();return}},[]);return r.jsxs("div",{className:l.cx(c.nodeClass,`workflow-node-type-${o.type}`),children:[r.jsxs("div",{role:"button","aria-label":`${f}-${x}`,className:l.cx(c.nodeCardClass,{configuring:h}),onClick:P,children:[r.jsxs("div",{className:l.cx(c.nodeMetaClass,"workflow-node-meta"),children:[r.jsx(b.Tag,{children:f}),r.jsx("span",{className:"workflow-node-id",children:o.id})]}),r.jsx(b.Input.TextArea,{role:"button","aria-label":"textarea",disabled:i.executed,value:x,onChange:E=>v(E.target.value),onBlur:E=>$(E.target.value),autoSize:!0}),r.jsx($t,{}),r.jsx(Dt,{}),r.jsx(l.ActionContextProvider,{value:{visible:h,setVisible:w,formValueChanged:S,setFormValueChanged:F},children:r.jsx(l.FormProvider,{form:A,children:r.jsx(l.SchemaComponent,{scope:C(g({},d.scope),{useFormProviderProps:jr}),components:d.components,schema:{type:"void",properties:C(g({},d.view?{view:d.view}:{}),{button:{type:"void","x-content":p,"x-component":b.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},[`${d.type}_${o.id}`]:{type:"void",title:r.jsxs("div",{className:l.css`
|
|
563
563
|
display: flex;
|
|
564
564
|
justify-content: space-between;
|
|
565
565
|
|
|
@@ -574,7 +574,7 @@
|
|
|
574
574
|
code {
|
|
575
575
|
font-weight: normal;
|
|
576
576
|
}
|
|
577
|
-
`,children:[
|
|
577
|
+
`,children:[r.jsx("strong",{children:o.title}),r.jsx(b.Tooltip,{title:D("Variable key of node"),children:r.jsx(b.Tag,{children:r.jsx("code",{children:o.key})})})]}),"x-decorator":"FormV2","x-decorator-props":{useProps:"{{ useFormProviderProps }}"},"x-component":"Action.Drawer",properties:C(g({},d.description?{description:{type:"void","x-component":Wo,"x-component-props":{label:D("Node type"),title:d.title,description:d.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:l.css`
|
|
578
578
|
.ant-input,
|
|
579
579
|
.ant-select,
|
|
580
580
|
.ant-cascader-picker,
|
|
@@ -586,17 +586,17 @@
|
|
|
586
586
|
min-width: 6em;
|
|
587
587
|
}
|
|
588
588
|
}
|
|
589
|
-
`},properties:
|
|
589
|
+
`},properties:d.fieldset},actions:i.executed?null:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:Vr}}}}})}})}})})})]}),n]})}function It(e){var h;const{upstream:o,branchIndex:n=null}=e,t=l.useCompile(),s=l.useAPIClient(),{workflow:i,refresh:a}=(h=U())!=null?h:{},c=Array.from(q.getValues()),{styles:d}=te(),p=y.useMemo(()=>[{key:"control",label:`{{t("Control", { ns: "${u}" })}}`},{key:"collection",label:`{{t("Collection operations", { ns: "${u}" })}}`},{key:"manual",label:`{{t("Manual", { ns: "${u}" })}}`},{key:"extended",label:`{{t("Extended types", { ns: "${u}" })}}`}].filter(m=>c.filter(S=>S.group===m.key).length).map(m=>{const S=c.filter(F=>F.group===m.key&&(F.isAvailable?F.isAvailable({workflow:i,upstream:o,branchIndex:n}):!0));return C(g({},m),{type:"group",children:S.map(F=>({role:"button","aria-label":F.type,key:F.type,label:F.title,type:F.options?"subMenu":null,children:F.options?F.options.map(A=>({role:"button","aria-label":A.key,key:A.key,label:A.label})):null}))})}),[n,c,o,i]),f=y.useMemo(()=>i?s.resource("workflows.nodes",i.id):null,[i==null?void 0:i.id]),x=y.useCallback(S=>H(this,[S],function*({keyPath:m}){var P,B,L;const F=m.pop(),A={},[w]=m,$=q.get(F);if(w){const{value:E}=(B=(P=$.options)==null?void 0:P.find(N=>N.key===w))!=null?B:{};Object.assign(A,typeof E=="function"?E():E)}f&&(yield f.create({values:{type:F,upstreamId:(L=o==null?void 0:o.id)!=null?L:null,branchIndex:n,title:t($.title),config:A}}),a())}),[n,f==null?void 0:f.create,o==null?void 0:o.id]),v=y.useMemo(()=>({onClick:x,items:t(p)}),[p,x]);return i?r.jsx("div",{className:d.addButtonClass,children:r.jsx(b.Dropdown,{trigger:["click"],menu:v,disabled:i.executed,overlayClassName:l.css`
|
|
590
590
|
.ant-dropdown-menu-root {
|
|
591
591
|
max-height: 30em;
|
|
592
592
|
overflow-y: auto;
|
|
593
593
|
}
|
|
594
|
-
`,children:
|
|
594
|
+
`,children:r.jsx(b.Button,{"aria-label":e["aria-label"]||"add-button",shape:"circle",icon:r.jsx(O.PlusOutlined,{})})})}):null}function Oe({from:e=null,entry:o=null,branchIndex:n=null,controller:t=null,className:s,end:i}){const{styles:a}=te(),{getAriaLabel:c}=Co(e,n),d=[];for(let p=o;p;p=p.downstream)d.push(p);return r.jsxs("div",{className:l.cx("workflow-branch",a.branchClass,s),children:[r.jsx("div",{className:"workflow-branch-lines"}),t,r.jsx(It,{"aria-label":c(),upstream:e,branchIndex:n}),r.jsx("div",{className:"workflow-node-list",children:d.map(p=>r.jsx(Tt,{data:p},p.id))}),i?r.jsx("div",{className:"end-sign",children:r.jsx(O.CloseOutlined,{})}):null]})}function Nt({entry:e}){const{styles:o}=te(),{workflow:n}=U(),[t,s]=y.useState(100);return r.jsxs("div",{className:"workflow-canvas-wrapper",children:[r.jsx("div",{className:"workflow-canvas",style:{zoom:t/100},children:r.jsx("div",{className:l.cx(o.branchBlockClass,l.css`
|
|
595
595
|
margin-top: 0 !important;
|
|
596
|
-
`),children:
|
|
596
|
+
`),children:r.jsxs("div",{className:o.branchClass,children:[n!=null&&n.executed?r.jsx(b.Alert,{type:"warning",message:D("Executed workflow cannot be modified"),showIcon:!0,className:l.css`
|
|
597
597
|
margin-bottom: 1em;
|
|
598
|
-
`}):null,
|
|
598
|
+
`}):null,r.jsx(Pn,{}),r.jsx("div",{className:l.cx(o.branchBlockClass,l.css`
|
|
599
599
|
margin-top: 0 !important;
|
|
600
|
-
`),children:n.jsx(Me,{entry:e})}),n.jsx("div",{className:t.terminalClass,children:N("End")})]})})}),n.jsx("div",{className:"workflow-canvas-zoomer",children:n.jsx(b.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:r,onChange:s})})]})}const Ye=e=>`/admin/workflow/workflows/${e}`,Ao=e=>`/admin/workflow/executions/${e}`;function xg(e,t=[]){const o=new Map;e.forEach(r=>{r.jobs=[],o.set(r.id,r)}),t.forEach(r=>{const s=o.get(r.nodeId);s.jobs.push(r),r.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(r=>{r.jobs=r.jobs.sort((s,a)=>s.id-a.id)})}function Cg(){const e=i.useCompile(),{viewJob:t,setViewJob:o}=G(),{styles:r}=ae(),{node:s={}}=t!=null?t:{},a=K.get(s.type);return n.jsx(i.ActionContextProvider,{value:{visible:!!t,setVisible:o},children:n.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`${t==null?void 0:t.id}-${t==null?void 0:t.updatedAt}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:t},"x-component":"Action.Modal",title:n.jsxs("div",{className:r.nodeTitleClass,children:[n.jsx(b.Tag,{children:e(a==null?void 0:a.title)}),n.jsx("strong",{children:s.title}),n.jsxs("span",{className:"workflow-node-id",children:["#",s.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:yt,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${d}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:r.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function wg(e){const{execution:t}=G(),o=i.useAPIClient(),r=he.useNavigate(),{styles:s}=ae(),[a,l]=y.useState([]),[c,u]=y.useState([]);y.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{l(f.data)}).catch(()=>{})},[t]),y.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{u(f.data.reverse())}).catch(()=>{})},[t]);const p=y.useCallback(({key:f})=>{f!=t.id&&r(Ao(f))},[t]);return t?n.jsx(b.Dropdown,{menu:{onClick:p,defaultSelectedKeys:[`${t.id}`],className:i.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...a].map(f=>({key:f.id,label:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"id",children:`#${f.id}`}),n.jsx("time",{children:X.str2moment(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:n.jsx("span",{children:n.jsx(tt,{statusMap:ht,status:f.status})})}))},children:n.jsxs(b.Space,{children:[n.jsx("strong",{children:`#${t.id}`}),n.jsx(O.DownOutlined,{})]})}):null}function $g(){var m;const e=i.useCompile(),{data:t,loading:o}=i.useResourceActionContext(),{setTitle:r}=i.useDocumentTitle(),[s,a]=y.useState(null),l=i.useApp();if(y.useEffect(()=>{var D;const{workflow:$}=(D=t==null?void 0:t.data)!=null?D:{};r==null||r(`${$!=null&&$.title?`${$.title} - `:""}${N("Execution history")}`)},[t==null?void 0:t.data]),!(t!=null&&t.data))return o?n.jsx(b.Spin,{}):n.jsx(b.Result,{status:"404",title:"Not found"});const k=(m=t==null?void 0:t.data)!=null?m:{},{jobs:c=[],workflow:w={}}=k,T=w,{nodes:u=[],revisions:p=[]}=T,f=W(T,["nodes","revisions"]),g=W(k,["jobs","workflow"]);$o(u),xg(u,c);const x=u.find($=>!$.upstream),h=ht[g.status];return n.jsxs(et.Provider,{value:{workflow:f.type?f:null,nodes:u,execution:g,viewJob:s,setViewJob:a},children:[n.jsxs("div",{className:"workflow-toolbar",children:[n.jsx("header",{children:n.jsx(b.Breadcrumb,{items:[{title:n.jsx(he.Link,{to:l.pluginSettingsManager.getRoutePath("workflow"),children:N("Workflow")})},{title:n.jsx(he.Link,{to:Ye(f.id),children:f.title})},{title:n.jsx(wg,{})}]})}),n.jsxs("aside",{children:[n.jsx(b.Tag,{color:h.color,children:e(h.label)}),n.jsx("time",{children:X.str2moment(g.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),n.jsx(En,{entry:x}),n.jsx(Cg,{})]})}const Mn=()=>{const e=he.useParams(),{styles:t}=ae();return n.jsx("div",{className:i.cx(t.workflowPageClass),children:n.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`execution_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:e,appends:["jobs","workflow","workflow.nodes"]}}},"x-component":"ExecutionCanvas"}}},components:{ExecutionCanvas:$g}})})},_n=()=>{const{t:e}=oe.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext();return n.jsx(he.Link,{to:Ao(t),onClick:()=>o(!1),children:e("View")})},Sg={name:"executions",fields:[{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${d}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${d}" })}}`,"x-component"({value:e}){const{setVisible:t}=i.useActionContext();return n.jsx(he.Link,{to:Ye(e),onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${d}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:ft}}]},jn={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${d}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:Sg,resourceName:"executions",request:{resource:"executions",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"],filter:{}}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=oe.useTranslation(),{refresh:t,defaultRequest:o}=i.useResourceActionContext(),{resource:r}=i.useResourceContext(),{setVisible:s}=i.useActionContext();return{run(){return J(this,null,function*(){var l;yield r.destroy({filter:(l=o.params)==null?void 0:l.filter}),b.message.success(e("Operation succeeded")),t(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${d}" })}}`,content:`{{t("Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?", { ns: "${d}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{createdAt:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{status:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void",title:`{{t("Details", { ns: "${d}" })}}`,"x-component":"ExecutionLink"}}}}}}}}}}};function kg(r){var s=r,{request:e,filter:t={}}=s,o=W(s,["request","filter"]);var c;const{workflow:a}=G(),l=C(v({},o),{request:C(v({},e),{params:C(v({},e==null?void 0:e.params),{filter:C(v({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return n.jsx(i.ResourceActionProvider,v({},l))}function Ag(){var z;const e=he.useNavigate(),{t}=oe.useTranslation(),o=i.useApp(),{data:r,refresh:s,loading:a}=i.useResourceActionContext(),{resource:l}=i.useResourceContext(),{setTitle:c}=i.useDocumentTitle(),[u,p]=y.useState(!1),{styles:f}=ae(),{modal:g}=b.App.useApp();if(y.useEffect(()=>{var I;const{title:A}=(I=r==null?void 0:r.data)!=null?I:{};c==null||c(`${N("Workflow")}${A?`: ${A}`:""}`)},[r==null?void 0:r.data]),!(r!=null&&r.data))return a?n.jsx(b.Spin,{}):n.jsx(b.Result,{status:"404",title:"Not found"});const P=(z=r==null?void 0:r.data)!=null?z:{},{nodes:x=[],revisions:h=[]}=P,m=W(P,["nodes","revisions"]);$o(x);const k=x.find(A=>!A.upstream);function w({key:A}){A!=m.id&&e(Ye(A))}function T(A){return J(this,null,function*(){yield l.update({filterByTk:m.id,values:{enabled:A}}),s()})}function $(){return J(this,null,function*(){const{data:{data:A}}=yield l.revision({filterByTk:m.id,filter:{key:m.key}});b.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${A.id}`)})}function D(){return J(this,null,function*(){const A=m.current?N("Delete a main version will cause all other revisions to be deleted too."):"";g.confirm({title:t("Are you sure you want to delete it?"),content:A,onOk(){return J(this,null,function*(){var U;yield l.destroy({filterByTk:m.id}),b.message.success(t("Operation succeeded")),e(m.current?o.pluginSettingsManager.getRoutePath("workflow"):Ye((U=h.find(V=>V.current))==null?void 0:U.id))})}})})}function M(I){return J(this,arguments,function*({key:A}){switch(A){case"history":p(!0);return;case"revision":return $();case"delete":return D()}})}const _=m.executed&&!h.find(A=>!A.executed&&new Date(A.createdAt)>new Date(m.createdAt));return n.jsxs(et.Provider,{value:{workflow:m,nodes:x,refresh:s},children:[n.jsxs("div",{className:"workflow-toolbar",children:[n.jsx("header",{children:n.jsx(b.Breadcrumb,{items:[{title:n.jsx(he.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:N("Workflow")})},{title:n.jsx("strong",{children:m.title})}]})}),n.jsxs("aside",{children:[n.jsx("div",{className:"workflow-versions",children:n.jsx(b.Dropdown,{trigger:["click"],menu:{onClick:w,defaultSelectedKeys:[`${m.id}`],className:i.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:h.sort((A,I)=>I.id-A.id).map((A,I)=>({role:"button","aria-label":`version-${I}`,key:`${A.id}`,icon:A.current?n.jsx(O.RightOutlined,{}):null,className:i.cx({executed:A.executed,unexecuted:!A.executed,enabled:A.enabled}),label:n.jsxs(n.Fragment,{children:[n.jsx("strong",{children:`#${A.id}`}),n.jsx("time",{children:X.str2moment(A.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:n.jsxs(b.Button,{type:"text","aria-label":"version",children:[n.jsx("label",{children:N("Version")}),n.jsx("span",{children:m!=null&&m.id?`#${m.id}`:null}),n.jsx(O.DownOutlined,{})]})})}),n.jsx(b.Switch,{checked:m.enabled,onChange:T,checkedChildren:N("On"),unCheckedChildren:N("Off")}),n.jsx(b.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:N("Execution history"),disabled:!m.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:N("Copy to new version"),disabled:!_},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")}],onClick:M},children:n.jsx(b.Button,{"aria-label":"more",type:"text",icon:n.jsx(O.EllipsisOutlined,{})})}),n.jsx(i.ActionContextProvider,{value:{visible:u,setVisible:p},children:n.jsx(i.SchemaComponent,{schema:jn,components:{ExecutionResourceProvider:kg,ExecutionLink:_n}})})]})]}),n.jsx(En,{entry:k})]})}const Bn=()=>{const e=he.useParams(),{styles:t}=ae();return n.jsx("div",{className:i.cx(t.workflowPageClass),children:n.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:Ag}})})},Tg=r=>{var s=r,{request:e,filter:t={}}=s,o=W(s,["request","filter"]);var c;const a=i.useRecord(),l=C(v({},o),{request:C(v({},e),{params:C(v({},e==null?void 0:e.params),{filter:C(v({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return n.jsx(i.ResourceActionProvider,v({},l))},Og=()=>{const{t:e}=oe.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext(),{getAriaLabel:r}=i.useGetAriaLabelOfAction("Configure");return n.jsx(he.Link,{"aria-label":r(),to:Ye(t),onClick:()=>o(!1),children:e("Configure")})};function Fg(r){var s=r,{component:e="div",children:t}=s,o=W(s,["component","children"]);const[a,l]=y.useState(!1),c=F.useFieldSchema();return n.jsxs(i.ActionContextProvider,{value:{visible:a,setVisible:l,fieldSchema:c},children:[y.createElement(e,C(v({},o),{onClick(){l(!0)}}),t),n.jsx(i.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}const{defaultProps:Ig}=i.interfacesProperties,Dg={name:"expression",type:"string",group:"advanced",order:1,title:`{{t("Expression", { ns: "${d}" })}}`,description:`{{t("An expression for calculation in each rows", { ns: "${d}" })}}`,sortable:!0,default:{type:"text",uiSchema:{"x-component":"DynamicExpression"}},properties:v({},Ig)},Vn={name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Trigger type", { ns: "${d}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}"},required:!0}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${d}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${d}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${d}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${d}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},Oe={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"fieldset",properties:{deleteExecutionOnStatus:{type:"array",title:`{{ t("Auto delete history when execution is on end status", { ns: "${d}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},Ng={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Vn,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider","x-component-props":{collection:Vn},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined",useProps:"{{ cm.useFilterActionProps }}"},"x-align":"left"},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:Oe.title,type:Oe.type,description:Oe.description,options:Oe.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=i.useRecord();return y.createElement("a",v({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:jn}}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{ t("Edit") }}',properties:{title:Oe.title,enabled:Oe.enabled,description:Oe.description,options:Oe.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},revision:{type:"void",title:`{{t("Duplicate", { ns: "${d}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${d}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=oe.useTranslation(),{refresh:t}=i.useResourceActionContext(),{resource:o,targetKey:r}=i.useResourceContext(),{setVisible:s}=i.useActionContext(),{[r]:a}=i.useRecord(),{values:l}=F.useForm();return{run(){return J(this,null,function*(){yield o.revision({filterByTk:a,values:l}),b.message.success(e("Operation succeeded")),t(),s(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"}}}}}}}}}}}};function Ln(e){var a;const o=i.useCompile()(e.label),r=y.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:s}=(a=ht[e.value])!=null?a:{};return n.jsx(b.Tag,{color:s,onMouseDown:r,closable:e.closable,onClose:e.onClose,children:o})}function Pg(e){const t=i.useCompile();return n.jsxs(n.Fragment,{children:[n.jsx(Ln,v({},e)),e.description?n.jsx("span",{children:t(e.description)}):null]})}function Eg(t){var e=W(t,[]);const o=e.multiple?"multiple":null;return n.jsx(b.Select,C(v({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Ln,children:ft.filter(r=>!!r.value&&r.value!==ye.ABORTED).map(r=>n.jsx(b.Select.Option,C(v({},r),{children:n.jsx(Pg,v({},r))}),r.value))}))}const Mg=y.createContext({});function _g(){const e=y.useContext(i.SchemaComponentContext);return n.jsx(b.Card,{bordered:!1,children:n.jsx(i.SchemaComponentContext.Provider,{value:C(v({},e),{designable:!1}),children:n.jsx(i.SchemaComponent,{schema:Ng,components:{WorkflowLink:Og,ExecutionResourceProvider:Tg,ExecutionLink:_n,OpenDrawer:Fg,ExecutionStatusSelect:Eg},scope:{getTriggersOptions:go}})})})}const jg=e=>{const t=y.useContext(i.PluginManagerContext),o=y.useContext(i.CollectionManagerContext);return n.jsx(i.PluginManagerContext.Provider,{value:{components:v({},t==null?void 0:t.components)},children:n.jsx(i.CollectionManagerContext.Provider,{value:C(v({},o),{interfaces:C(v({},o.interfaces),{expression:Dg})}),children:n.jsx(Mg.Provider,{value:{triggers:ge,instructions:K},children:e.children})})})},Bg=F.observer(e=>{const{onChange:t}=e,o=F.useField(),r=F.useForm(),a=[...o.path.segments.slice(0,-1),"sourceCollection"].join("."),[l,c]=y.useState(r.getValuesIn(a)),u=i.useCompile(),{getCollectionFields:p}=i.useCollectionManager();F.useFormEffects(()=>{se.onFormInitialValuesChange(g=>{c(g.getValuesIn(a))}),se.onFieldInputValueChange(a,g=>{c(g.value),t(null)})});const f=be({collection:l,compile:u,getCollectionFields:p});return n.jsx(i.Variable.TextArea,C(v({},e),{scope:f}))},{displayName:"InternalExpression"});function Vg(e){const{t}=oe.useTranslation(),o=i.useRecord(),r=i.useCompile(),{getCollectionFields:s}=i.useCollectionManager(),a=y.useMemo(()=>be({collection:o.sourceCollection,compile:r,getCollectionFields:s}),[o.sourceCollection,o.sourceCollection]);return e.value?n.jsx(i.Variable.TextArea,C(v({},e),{scope:a})):n.jsx(b.Tag,{children:t("Unconfigured",{ns:d})})}const Lg=F.connect(Bg,F.mapReadPretty(Vg)),zg={title:`{{t("Task", { ns: "${d}" })}}`,name:"flow_nodes",fields:[{type:"bigInt",name:"id",interface:"m2o",uiSchema:{type:"number",title:"ID","x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes",params:{filter:{type:"manual"}}}}}},{type:"string",name:"title",interface:"input",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}}]},Wg={title:`{{t("Workflow", { ns: "${d}" })}}`,name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}}]},Ug={title:`{{t("Workflow todos", { ns: "${d}" })}}`,name:"users_jobs",fields:[{type:"belongsTo",name:"user",target:"users",foreignKey:"userId",interface:"m2o",uiSchema:{type:"number",title:'{{t("User")}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"}}}},{type:"belongsTo",name:"node",target:"flow_nodes",foreignKey:"nodeId",interface:"m2o",isAssociation:!0,uiSchema:{type:"number",title:`{{t("Task", { ns: "${d}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes"}}}},{type:"belongsTo",name:"workflow",target:"workflows",foreignKey:"workflowId",interface:"m2o",uiSchema:{type:"number",title:`{{t("Workflow", { ns: "${d}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"integer",name:"status",interface:"select",uiSchema:{type:"number",title:`{{t("Status", { ns: "${d}" })}}`,"x-component":"Select",enum:yt}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},Gg=F.observer(()=>{var t,o,r;const e=F.useField();return(r=(t=e==null?void 0:e.value)==null?void 0:t.title)!=null?r:`#${(o=e.value)==null?void 0:o.id}`},{displayName:"NodeColumn"}),Hg=F.observer(()=>{var t,o,r;const e=F.useField();return(r=(t=e==null?void 0:e.value)==null?void 0:t.title)!=null?r:`#${(o=e.value)==null?void 0:o.id}`},{displayName:"WorkflowColumn"}),Kg=F.observer(()=>{var t,o,r;const e=F.useField();return(r=(t=e==null?void 0:e.value)==null?void 0:t.nickname)!=null?r:(o=e.value)==null?void 0:o.id},{displayName:"UserColumn"}),To=()=>n.jsx(i.SchemaComponent,{components:{NodeColumn:Gg,WorkflowColumn:Hg,UserColumn:Kg},schema:{type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined",useProps:"{{ useFilterActionProps }}"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined",useProps:"{{ useRefreshActionProps }}"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-component-props":{rowKey:"id",useProps:"{{ useTableBlockProps }}"},properties:{node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Task", { ns: "${d}" })}}`,properties:{node:{"x-component":"NodeColumn","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Workflow", { ns: "${d}" })}}`,properties:{workflow:{"x-component":"WorkflowColumn","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Assignee", { ns: "${d}" })}}`,properties:{user:{"x-component":"UserColumn","x-read-pretty":!0}}},status:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{status:{"x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("Actions")}}',properties:{view:{type:"void","x-component":"Action.Link",title:'{{t("View")}}',properties:{drawer:{"x-component":"WorkflowTodo.Drawer"}}}}}}}}}});function qg(e){var p;const{data:t}=i.useCurrentUserContext(),{userJob:o}=G(),{status:r,result:s,userId:a}=o,l=F.useFieldSchema(),{name:c}=l.parent.toJSON();let{children:u}=e;return r?s[c]||(u=null):((p=t==null?void 0:t.data)==null?void 0:p.id)!==a&&(u=null),u}const Jg=y.createContext(null);function Yg({value:e,children:t}){const{userJob:o}=G(),r=F.useField(),s=F.useFieldSchema();return y.useEffect(()=>{o.status&&(r.disabled=!0,r.visible=o.status===e&&o.result._===s.name)},[o,e,r]),n.jsx(Jg.Provider,{value:e,children:t})}function Zg(){const e=i.useAPIClient(),{setVisible:t}=i.useActionContext(),{values:o,submit:r}=F.useForm(),s=F.useFieldSchema(),{service:a}=i.useTableBlockContext(),{userJob:l}=G(),{name:c}=s,{name:u}=s.parent.parent;return{run(){return J(this,null,function*(){l.status||(yield r(),yield e.resource("users_jobs").submit({filterByTk:l.id,values:{result:{[u]:o,_:c}}}),t(!1),a.refresh())})}}}function Qg(e){var p;const t=i.useAPIClient(),{id:o}=i.useRecord(),[r,s]=y.useState(null),[a,l]=y.useState(null);y.useEffect(()=>{var f,g;o&&((g=(f=t.resource("users_jobs")).get)==null||g.call(f,{filterByTk:o,appends:["node","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:x})=>{var $;const D=($=x==null?void 0:x.data)!=null?$:{},{node:h,workflow:M={}}=D,_=M,{nodes:m=[]}=_,k=W(_,["nodes"]),z=D,{execution:w}=z,T=W(z,["node","workflow","execution"]);$o(m),l(h),s({userJob:T,workflow:k,nodes:m,execution:w})}))},[o]);const u=ct(r==null?void 0:r.nodes.find(f=>f.id===a.id)).reduce((f,{type:g})=>Object.assign(f,K.get(g).components),{});return a&&r?n.jsx(et.Provider,{value:r,children:n.jsx(i.SchemaComponent,{components:v(v({FormBlockProvider:Cn,DetailsBlockProvider:xn,ActionBarProvider:qg,ManualActionStatusProvider:Yg},Array.from(Ce.getValues()).reduce((f,g)=>Object.assign(f,g.block.components),{})),u),scope:v({useSubmit:Zg,useFormBlockProps:Xg,useDetailsBlockProps:Rg},Array.from(Ce.getValues()).reduce((f,g)=>Object.assign(f,g.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(p=a.config)==null?void 0:p.schema}})}):n.jsx(b.Spin,{})}function Xg(){var a;const{userJob:e}=G(),t=i.useRecord(),{data:o}=i.useCurrentUserContext(),{form:r}=i.useFormBlockContext(),s=e.status?t?"readPretty":"disabled":((a=o==null?void 0:o.data)==null?void 0:a.id)!==e.userId?"disabled":"editable";return y.useEffect(()=>{r==null||r.setPattern(s)},[s,r]),{form:r}}function Rg(){const{form:e}=i.useFormBlockContext();return{form:e}}function ev(){const e=i.useCompile(),{status:t,updatedAt:o}=i.useRecord(),r=Re[t];return t?n.jsxs(b.Space,{children:[n.jsx("time",{className:i.css`
|
|
600
|
+
`),children:r.jsx(Oe,{entry:e})}),r.jsx("div",{className:o.terminalClass,children:D("End")})]})})}),r.jsx("div",{className:"workflow-canvas-zoomer",children:r.jsx(b.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:t,onChange:s})})]})}const Pe=e=>`/admin/workflow/workflows/${e}`,Mo=e=>`/admin/workflow/executions/${e}`;function Lr(e,o=[]){const n=new Map;e.forEach(t=>{t.jobs=[],n.set(t.id,t)}),o.forEach(t=>{const s=n.get(t.nodeId);s.jobs.push(t),t.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(t=>{t.jobs=t.jobs.sort((s,i)=>s.id-i.id)})}function zr(){const e=l.useCompile(),{viewJob:o,setViewJob:n}=U(),{styles:t}=te(),{node:s={}}=o!=null?o:{},i=q.get(s.type);return r.jsx(l.ActionContextProvider,{value:{visible:!!o,setVisible:n},children:r.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`${o==null?void 0:o.id}-${o==null?void 0:o.updatedAt}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:r.jsxs("div",{className:t.nodeTitleClass,children:[r.jsx(b.Tag,{children:e(i==null?void 0:i.title)}),r.jsx("strong",{children:s.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",s.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:Re,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:t.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function Wr(e){const{execution:o}=U(),n=l.useAPIClient(),t=ue.useNavigate(),{styles:s}=te(),[i,a]=y.useState([]),[c,d]=y.useState([]);y.useEffect(()=>{o&&n.resource("executions").list({filter:{key:o.key,id:{$lt:o.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{a(f.data)}).catch(()=>{})},[o]),y.useEffect(()=>{o&&n.resource("executions").list({filter:{key:o.key,id:{$gt:o.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{d(f.data.reverse())}).catch(()=>{})},[o]);const p=y.useCallback(({key:f})=>{f!=o.id&&t(Mo(f))},[o]);return o?r.jsx(b.Dropdown,{menu:{onClick:p,defaultSelectedKeys:[`${o.id}`],className:l.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,o,...i].map(f=>({key:f.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${f.id}`}),r.jsx("time",{children:K.str2moment(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(We,{statusMap:Xe,status:f.status})})}))},children:r.jsxs(b.Space,{children:[r.jsx("strong",{children:`#${o.id}`}),r.jsx(O.DownOutlined,{})]})}):null}function Ur(){var m;const e=l.useCompile(),{data:o,loading:n}=l.useResourceActionContext(),{setTitle:t}=l.useDocumentTitle(),[s,i]=y.useState(null),a=l.useApp();if(y.useEffect(()=>{var $;const{workflow:w}=($=o==null?void 0:o.data)!=null?$:{};t==null||t(`${w!=null&&w.title?`${w.title} - `:""}${D("Execution history")}`)},[o==null?void 0:o.data]),!(o!=null&&o.data))return n?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const S=(m=o==null?void 0:o.data)!=null?m:{},{jobs:c=[],workflow:F={}}=S,A=F,{nodes:d=[],revisions:p=[]}=A,f=z(A,["nodes","revisions"]),x=z(S,["jobs","workflow"]);Io(d),Lr(d,c);const v=d.find(w=>!w.upstream),h=Xe[x.status];return r.jsxs(ze.Provider,{value:{workflow:f.type?f:null,nodes:d,execution:x,viewJob:s,setViewJob:i},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(b.Breadcrumb,{items:[{title:r.jsx(ue.Link,{to:a.pluginSettingsManager.getRoutePath("workflow"),children:D("Workflow")})},{title:r.jsx(ue.Link,{to:Pe(f.id),children:f.title})},{title:r.jsx(Wr,{})}]})}),r.jsxs("aside",{children:[r.jsx(b.Tag,{color:h.color,children:e(h.label)}),r.jsx("time",{children:K.str2moment(x.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(Nt,{entry:v}),r.jsx(zr,{})]})}const Et=()=>{const e=ue.useParams(),{styles:o}=te();return r.jsx("div",{className:l.cx(o.workflowPageClass),children:r.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`execution_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:e,appends:["jobs","workflow","workflow.nodes"]}}},"x-component":"ExecutionCanvas"}}},components:{ExecutionCanvas:Ur}})})},Mt=()=>{const{t:e}=R.useTranslation(),{id:o}=l.useRecord(),{setVisible:n}=l.useActionContext();return r.jsx(ue.Link,{to:Mo(o),onClick:()=>n(!1),children:e("View")})},qr={name:"executions",fields:[{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${u}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${u}" })}}`,"x-component"({value:e}){const{setVisible:o}=l.useActionContext();return r.jsx(ue.Link,{to:Pe(e),onClick:()=>o(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${u}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:Qe}}]},Pt={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${u}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:qr,resourceName:"executions",request:{resource:"executions",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"],filter:{}}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=R.useTranslation(),{refresh:o,defaultRequest:n}=l.useResourceActionContext(),{resource:t}=l.useResourceContext(),{setVisible:s}=l.useActionContext();return{run(){return H(this,null,function*(){var a;yield t.destroy({filter:(a=n.params)==null?void 0:a.filter}),b.message.success(e("Operation succeeded")),o(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${u}" })}}`,content:`{{t("Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?", { ns: "${u}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{createdAt:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{status:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void",title:`{{t("Details", { ns: "${u}" })}}`,"x-component":"ExecutionLink"}}}}}}}}}}};function Gr(t){var s=t,{request:e,filter:o={}}=s,n=z(s,["request","filter"]);var c;const{workflow:i}=U(),a=C(g({},n),{request:C(g({},e),{params:C(g({},e==null?void 0:e.params),{filter:C(g({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:i.key})})})});return r.jsx(l.ResourceActionProvider,g({},a))}function Jr(){var L;const e=ue.useNavigate(),{t:o}=R.useTranslation(),n=l.useApp(),{data:t,refresh:s,loading:i}=l.useResourceActionContext(),{resource:a}=l.useResourceContext(),{setTitle:c}=l.useDocumentTitle(),[d,p]=y.useState(!1),{styles:f}=te(),{modal:x}=b.App.useApp();if(y.useEffect(()=>{var I;const{title:N}=(I=t==null?void 0:t.data)!=null?I:{};c==null||c(`${D("Workflow")}${N?`: ${N}`:""}`)},[t==null?void 0:t.data]),!(t!=null&&t.data))return i?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const E=(L=t==null?void 0:t.data)!=null?L:{},{nodes:v=[],revisions:h=[]}=E,m=z(E,["nodes","revisions"]);Io(v);const S=v.find(N=>!N.upstream);function F({key:N}){N!=m.id&&e(Pe(N))}function A(N){return H(this,null,function*(){yield a.update({filterByTk:m.id,values:{enabled:N}}),s()})}function w(){return H(this,null,function*(){const{data:{data:N}}=yield a.revision({filterByTk:m.id,filter:{key:m.key}});b.message.success(o("Operation succeeded")),e(`/admin/workflow/workflows/${N.id}`)})}function $(){return H(this,null,function*(){const N=m.current?D("Delete a main version will cause all other revisions to be deleted too."):"";x.confirm({title:o("Are you sure you want to delete it?"),content:N,onOk(){return H(this,null,function*(){var G;yield a.destroy({filterByTk:m.id}),b.message.success(o("Operation succeeded")),e(m.current?n.pluginSettingsManager.getRoutePath("workflow"):Pe((G=h.find(J=>J.current))==null?void 0:G.id))})}})})}function P(I){return H(this,arguments,function*({key:N}){switch(N){case"history":p(!0);return;case"revision":return w();case"delete":return $()}})}const B=m.executed&&!h.find(N=>!N.executed&&new Date(N.createdAt)>new Date(m.createdAt));return r.jsxs(ze.Provider,{value:{workflow:m,nodes:v,refresh:s},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(b.Breadcrumb,{items:[{title:r.jsx(ue.Link,{to:n.pluginSettingsManager.getRoutePath("workflow"),children:D("Workflow")})},{title:r.jsx("strong",{children:m.title})}]})}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(b.Dropdown,{trigger:["click"],menu:{onClick:F,defaultSelectedKeys:[`${m.id}`],className:l.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:h.sort((N,I)=>I.id-N.id).map((N,I)=>({role:"button","aria-label":`version-${I}`,key:`${N.id}`,icon:N.current?r.jsx(O.RightOutlined,{}):null,className:l.cx({executed:N.executed,unexecuted:!N.executed,enabled:N.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${N.id}`}),r.jsx("time",{children:K.str2moment(N.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(b.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:D("Version")}),r.jsx("span",{children:m!=null&&m.id?`#${m.id}`:null}),r.jsx(O.DownOutlined,{})]})})}),r.jsx(b.Switch,{checked:m.enabled,onChange:A,checkedChildren:D("On"),unCheckedChildren:D("Off")}),r.jsx(b.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:D("Execution history"),disabled:!m.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:D("Copy to new version"),disabled:!B},{role:"button","aria-label":"delete",key:"delete",label:o("Delete")}],onClick:P},children:r.jsx(b.Button,{"aria-label":"more",type:"text",icon:r.jsx(O.EllipsisOutlined,{})})}),r.jsx(l.ActionContextProvider,{value:{visible:d,setVisible:p},children:r.jsx(l.SchemaComponent,{schema:Pt,components:{ExecutionResourceProvider:Gr,ExecutionLink:Mt}})})]})]}),r.jsx(Nt,{entry:S})]})}const Bt=()=>{const e=ue.useParams(),{styles:o}=te();return r.jsx("div",{className:l.cx(o.workflowPageClass),children:r.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:Jr}})})},Hr=t=>{var s=t,{request:e,filter:o={}}=s,n=z(s,["request","filter"]);var c;const i=l.useRecord(),a=C(g({},n),{request:C(g({},e),{params:C(g({},e==null?void 0:e.params),{filter:C(g({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:i.key})})})});return r.jsx(l.ResourceActionProvider,g({},a))},Yr=()=>{const{t:e}=R.useTranslation(),{id:o}=l.useRecord(),{setVisible:n}=l.useActionContext(),{getAriaLabel:t}=l.useGetAriaLabelOfAction("Configure");return r.jsx(ue.Link,{"aria-label":t(),to:Pe(o),onClick:()=>n(!1),children:e("Configure")})};function _r(t){var s=t,{component:e="div",children:o}=s,n=z(s,["component","children"]);const[i,a]=y.useState(!1),c=T.useFieldSchema();return r.jsxs(l.ActionContextProvider,{value:{visible:i,setVisible:a,fieldSchema:c},children:[y.createElement(e,C(g({},n),{onClick(){a(!0)}}),o),r.jsx(l.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}const{defaultProps:Kr}=l.interfacesProperties,Zr={name:"expression",type:"string",group:"advanced",order:1,title:`{{t("Expression", { ns: "${u}" })}}`,description:`{{t("An expression for calculation in each rows", { ns: "${u}" })}}`,sortable:!0,default:{type:"text",uiSchema:{"x-component":"DynamicExpression"}},properties:g({},Kr)},Vt={name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Trigger type", { ns: "${u}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}"},required:!0}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${u}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${u}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${u}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${u}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},Se={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"fieldset",properties:{deleteExecutionOnStatus:{type:"array",title:`{{ t("Auto delete history when execution is on end status", { ns: "${u}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},Qr={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Vt,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider","x-component-props":{collection:Vt},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined",useProps:"{{ cm.useFilterActionProps }}"},"x-align":"left"},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:Se.title,type:Se.type,description:Se.description,options:Se.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(o){const n=l.useRecord();return y.createElement("a",g({"aria-label":`executed-${n.title}`},o))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:Pt}}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{ t("Edit") }}',properties:{title:Se.title,enabled:Se.enabled,description:Se.description,options:Se.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},revision:{type:"void",title:`{{t("Duplicate", { ns: "${u}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${u}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=R.useTranslation(),{refresh:o}=l.useResourceActionContext(),{resource:n,targetKey:t}=l.useResourceContext(),{setVisible:s}=l.useActionContext(),{[t]:i}=l.useRecord(),{values:a}=T.useForm();return{run(){return H(this,null,function*(){yield n.revision({filterByTk:i,values:a}),b.message.success(e("Operation succeeded")),o(),s(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"}}}}}}}}}}}};function jt(e){var i;const n=l.useCompile()(e.label),t=y.useCallback(a=>{a.preventDefault(),a.stopPropagation()},[]),{color:s}=(i=Xe[e.value])!=null?i:{};return r.jsx(b.Tag,{color:s,onMouseDown:t,closable:e.closable,onClose:e.onClose,children:n})}function Xr(e){const o=l.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(jt,g({},e)),e.description?r.jsx("span",{children:o(e.description)}):null]})}function Rr(o){var e=z(o,[]);const n=e.multiple?"multiple":null;return r.jsx(b.Select,C(g({role:"button","data-testid":`select-${n||"single"}`},e),{mode:n,optionLabelProp:"label",tagRender:jt,children:Qe.filter(t=>!!t.value&&t.value!==pe.ABORTED).map(t=>r.jsx(b.Select.Option,C(g({},t),{children:r.jsx(Xr,g({},t))}),t.value))}))}const es=y.createContext({});function os(){const e=y.useContext(l.SchemaComponentContext);return r.jsx(b.Card,{bordered:!1,children:r.jsx(l.SchemaComponentContext.Provider,{value:C(g({},e),{designable:!1}),children:r.jsx(l.SchemaComponent,{schema:Qr,components:{WorkflowLink:Yr,ExecutionResourceProvider:Hr,ExecutionLink:Mt,OpenDrawer:_r,ExecutionStatusSelect:Rr},scope:{getTriggersOptions:Fo}})})})}const ts=e=>{const o=y.useContext(l.PluginManagerContext),n=y.useContext(l.CollectionManagerContext);return r.jsx(l.PluginManagerContext.Provider,{value:{components:g({},o==null?void 0:o.components)},children:r.jsx(l.CollectionManagerContext.Provider,{value:C(g({},n),{interfaces:C(g({},n.interfaces),{expression:Zr})}),children:r.jsx(es.Provider,{value:{triggers:me,instructions:q},children:e.children})})})},ns=T.observer(e=>{const{onChange:o}=e,n=T.useField(),t=T.useForm(),i=[...n.path.segments.slice(0,-1),"sourceCollection"].join("."),[a,c]=y.useState(t.getValuesIn(i)),d=l.useCompile(),{getCollectionFields:p}=l.useCollectionManager();T.useFormEffects(()=>{oe.onFormInitialValuesChange(x=>{c(x.getValuesIn(i))}),oe.onFieldInputValueChange(i,x=>{c(x.value),o(null)})});const f=fe({collection:a,compile:d,getCollectionFields:p});return r.jsx(l.Variable.TextArea,C(g({},e),{scope:f}))},{displayName:"InternalExpression"});function rs(e){const{t:o}=R.useTranslation(),n=l.useRecord(),t=l.useCompile(),{getCollectionFields:s}=l.useCollectionManager(),i=y.useMemo(()=>fe({collection:n.sourceCollection,compile:t,getCollectionFields:s}),[n.sourceCollection,n.sourceCollection]);return e.value?r.jsx(l.Variable.TextArea,C(g({},e),{scope:i})):r.jsx(b.Tag,{children:o("Unconfigured",{ns:u})})}const ss=T.connect(ns,T.mapReadPretty(rs)),is={title:`{{t("Task", { ns: "${u}" })}}`,name:"flow_nodes",fields:[{type:"bigInt",name:"id",interface:"m2o",uiSchema:{type:"number",title:"ID","x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes",params:{filter:{type:"manual"}}}}}},{type:"string",name:"title",interface:"input",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}}]},ls={title:`{{t("Workflow", { ns: "${u}" })}}`,name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}}]},as={title:`{{t("Workflow todos", { ns: "${u}" })}}`,name:"users_jobs",fields:[{type:"belongsTo",name:"user",target:"users",foreignKey:"userId",interface:"m2o",uiSchema:{type:"number",title:'{{t("User")}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"}}}},{type:"belongsTo",name:"node",target:"flow_nodes",foreignKey:"nodeId",interface:"m2o",isAssociation:!0,uiSchema:{type:"number",title:`{{t("Task", { ns: "${u}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"flow_nodes"}}}},{type:"belongsTo",name:"workflow",target:"workflows",foreignKey:"workflowId",interface:"m2o",uiSchema:{type:"number",title:`{{t("Workflow", { ns: "${u}" })}}`,"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"integer",name:"status",interface:"select",uiSchema:{type:"number",title:`{{t("Status", { ns: "${u}" })}}`,"x-component":"Select",enum:Re}},{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0}}}]},cs=T.observer(()=>{var o,n,t;const e=T.useField();return(t=(o=e==null?void 0:e.value)==null?void 0:o.title)!=null?t:`#${(n=e.value)==null?void 0:n.id}`},{displayName:"NodeColumn"}),ds=T.observer(()=>{var o,n,t;const e=T.useField();return(t=(o=e==null?void 0:e.value)==null?void 0:o.title)!=null?t:`#${(n=e.value)==null?void 0:n.id}`},{displayName:"WorkflowColumn"}),us=T.observer(()=>{var o,n,t;const e=T.useField();return(t=(o=e==null?void 0:e.value)==null?void 0:o.nickname)!=null?t:(n=e.value)==null?void 0:n.id},{displayName:"UserColumn"}),Po=()=>r.jsx(l.SchemaComponent,{components:{NodeColumn:cs,WorkflowColumn:ds,UserColumn:us},schema:{type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined",useProps:"{{ useFilterActionProps }}"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined",useProps:"{{ useRefreshActionProps }}"},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-component-props":{rowKey:"id",useProps:"{{ useTableBlockProps }}"},properties:{node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Task", { ns: "${u}" })}}`,properties:{node:{"x-component":"NodeColumn","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Workflow", { ns: "${u}" })}}`,properties:{workflow:{"x-component":"WorkflowColumn","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:`{{t("Assignee", { ns: "${u}" })}}`,properties:{user:{"x-component":"UserColumn","x-read-pretty":!0}}},status:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{status:{"x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("Actions")}}',properties:{view:{type:"void","x-component":"Action.Link",title:'{{t("View")}}',properties:{drawer:{"x-component":"WorkflowTodo.Drawer"}}}}}}}}}});function ps(e){var p;const{data:o}=l.useCurrentUserContext(),{userJob:n}=U(),{status:t,result:s,userId:i}=n,a=T.useFieldSchema(),{name:c}=a.parent.toJSON();let{children:d}=e;return t?s[c]||(d=null):((p=o==null?void 0:o.data)==null?void 0:p.id)!==i&&(d=null),d}const ms=y.createContext(null);function fs({value:e,children:o}){const{userJob:n}=U(),t=T.useField(),s=T.useFieldSchema();return y.useEffect(()=>{n.status&&(t.disabled=!0,t.visible=n.status===e&&n.result._===s.name)},[n,e,t]),r.jsx(ms.Provider,{value:e,children:o})}function hs(){const e=l.useAPIClient(),{setVisible:o}=l.useActionContext(),{values:n,submit:t}=T.useForm(),s=T.useFieldSchema(),{service:i}=l.useTableBlockContext(),{userJob:a}=U(),{name:c}=s,{name:d}=s.parent.parent;return{run(){return H(this,null,function*(){a.status||(yield t(),yield e.resource("users_jobs").submit({filterByTk:a.id,values:{result:{[d]:n,_:c}}}),o(!1),i.refresh())})}}}function ys(e){var p;const o=l.useAPIClient(),{id:n}=l.useRecord(),[t,s]=y.useState(null),[i,a]=y.useState(null);y.useEffect(()=>{var f,x;n&&((x=(f=o.resource("users_jobs")).get)==null||x.call(f,{filterByTk:n,appends:["node","workflow","workflow.nodes","execution","execution.jobs"]}).then(({data:v})=>{var w;const $=(w=v==null?void 0:v.data)!=null?w:{},{node:h,workflow:P={}}=$,B=P,{nodes:m=[]}=B,S=z(B,["nodes"]),L=$,{execution:F}=L,A=z(L,["node","workflow","execution"]);Io(m),a(h),s({userJob:A,workflow:S,nodes:m,execution:F})}))},[n]);const d=Je(t==null?void 0:t.nodes.find(f=>f.id===i.id)).reduce((f,{type:x})=>Object.assign(f,q.get(x).components),{});return i&&t?r.jsx(ze.Provider,{value:t,children:r.jsx(l.SchemaComponent,{components:g(g({FormBlockProvider:bt,DetailsBlockProvider:xt,ActionBarProvider:ps,ManualActionStatusProvider:fs},Array.from(ge.getValues()).reduce((f,x)=>Object.assign(f,x.block.components),{})),d),scope:g({useSubmit:hs,useFormBlockProps:gs,useDetailsBlockProps:xs},Array.from(ge.getValues()).reduce((f,x)=>Object.assign(f,x.block.scope),{})),schema:{type:"void",name:"tabs","x-component":"Tabs",properties:(p=i.config)==null?void 0:p.schema}})}):r.jsx(b.Spin,{})}function gs(){var i;const{userJob:e}=U(),o=l.useRecord(),{data:n}=l.useCurrentUserContext(),{form:t}=l.useFormBlockContext(),s=e.status?o?"readPretty":"disabled":((i=n==null?void 0:n.data)==null?void 0:i.id)!==e.userId?"disabled":"editable";return y.useEffect(()=>{t==null||t.setPattern(s)},[s,t]),{form:t}}function xs(){const{form:e}=l.useFormBlockContext();return{form:e}}function bs(){const e=l.useCompile(),{status:o,updatedAt:n}=l.useRecord(),t=Le[o];return o?r.jsxs(b.Space,{children:[r.jsx("time",{className:l.css`
|
|
601
601
|
margin-right: 0.5em;
|
|
602
|
-
`,children:
|
|
602
|
+
`,children:zo(n).format("YYYY-MM-DD HH:mm:ss")}),r.jsx(b.Tag,{icon:t.icon,color:t.color,children:e(t.label)})]}):null}function vs(){var i;const e=y.useContext(l.SchemaComponentContext),{id:o,node:n,workflow:t,status:s}=l.useRecord();return r.jsx(l.SchemaComponentContext.Provider,{value:C(g({},e),{reset(){},designable:!1}),children:r.jsx(l.SchemaComponent,{components:{FooterStatus:bs,FlowContextProvider:ys},schema:{type:"void",name:`drawer-${o}-${s}`,"x-component":"Action.Drawer","x-component-props":{className:"nb-action-popup"},title:`${t.title} - ${(i=n.title)!=null?i:`#${n.id}`}`,properties:{tabs:{type:"void","x-component":"FlowContextProvider"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{content:{type:"void","x-component":"FooterStatus"}}}}}})})}function Cs({params:e={},children:o}){const i=l.useCollectionManager(),{collections:n}=i,t=z(i,["collections"]),s={collection:"users_jobs",resource:"users_jobs",action:"list",params:C(g({pageSize:20,sort:["-createdAt"]},e),{appends:["user","node","workflow"],except:["node.config","workflow.config","workflow.options"]}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(l.CollectionManagerProvider,C(g({},t),{collections:[...n,is,ls,as],children:r.jsx(l.TableBlockProvider,C(g({name:"workflow-todo"},s),{children:o}))}))}Po.Drawer=vs,Po.Decorator=Cs;const ws=n=>{var t=n,{insert:e}=t,o=z(t,["insert"]);return r.jsx(l.SchemaInitializer.Item,C(g({icon:r.jsx(O.TableOutlined,{})},o),{onClick:()=>{e({type:"void","x-decorator":"WorkflowTodo.Decorator","x-decorator-props":{},"x-component":"CardItem","x-designer":"TableBlockDesigner",properties:{todos:{type:"void","x-component":"WorkflowTodo"}}})}}))};class Lt extends l.Plugin{constructor(){super(...arguments);bo(this,"triggers",me);bo(this,"getTriggersOptions",Fo);bo(this,"instructions",q)}load(){return H(this,null,function*(){this.addRoutes(),this.addScopes(),this.addComponents(),this.app.addProvider(ts),this.app.pluginSettingsManager.add(u,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${u}" })}}`,Component:os,aclSnippet:"pm.workflow.workflows"})})}addScopes(){this.app.addScopes({useTriggerWorkflowsActionProps:fn})}addComponents(){this.app.addComponents({WorkflowPage:Bt,ExecutionPage:Et,WorkflowTodo:Po,WorkflowTodoBlockInitializer:ws,DynamicExpression:ss})}addRoutes(){this.app.router.add("admin.workflow.workflows.id",{path:Pe(":id"),element:r.jsx(Bt,{})}),this.app.router.add("admin.workflow.executions.id",{path:Mo(":id"),element:r.jsx(Et,{})})}}k.BaseTypeSets=Ee,k.Branch=Oe,k.EXECUTION_STATUS=pe,k.ExecutionStatusOptions=Qe,k.ExecutionStatusOptionsMap=Xe,k.FlowContext=ze,k.JOB_STATUS=Z,k.JobButton=Dt,k.JobStatusOptions=Re,k.JobStatusOptionsMap=Le,k.Node=Tt,k.NodeContext=Eo,k.NodeDefaultView=He,k.RemoveButton=$t,k.WorkflowPlugin=Lt,k.WorkflowVariableInput=qe,k.WorkflowVariableJSON=pt,k.WorkflowVariableRawTextArea=ut,k.WorkflowVariableTextArea=dt,k.default=Lt,k.defaultFieldNames=we,k.getCollectionFieldOptions=fe,k.getTriggersOptions=Fo,k.instructions=q,k.nodesOptions=no,k.scopeOptions=Ao,k.systemOptions=at,k.triggerOptions=ro,k.triggers=me,k.useAvailableUpstreams=Je,k.useFlowContext=U,k.useNodeContext=ke,k.useStyles=te,k.useTrigger=So,k.useUpstreamScopes=Ot,k.useWorkflowVariableOptions=ce,Object.defineProperties(k,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|