@nocobase/plugin-workflow 1.2.14-alpha → 1.3.0-alpha.20240710141659
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 +59 -59
- package/dist/client/variable.d.ts +15 -2
- package/dist/externalVersion.js +11 -11
- package/dist/locale/ko_KR.json +1 -0
- package/dist/locale/zh-CN.json +1 -0
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/server/Plugin.d.ts +1 -0
- package/dist/server/Plugin.js +45 -10
- package/dist/server/Processor.js +12 -1
- package/dist/server/functions/index.d.ts +23 -0
- package/dist/server/functions/index.js +84 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +2 -0
- package/package.json +3 -3
package/dist/client/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
(function(v,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("react/jsx-runtime"),require("@nocobase/client"),require("@nocobase/utils/client"),require("react-router-dom"),require("react"),require("antd"),require("react-i18next"),require("@ant-design/icons"),require("@formily/core"),require("@formily/reactive"),require("@formily/react"),require("lodash"),require("@formily/shared"),require("dayjs"),require("@nocobase/evaluators/client"),require("@formily/antd-v5")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","@nocobase/utils/client","react-router-dom","react","antd","react-i18next","@ant-design/icons","@formily/core","@formily/reactive","@formily/react","lodash","@formily/shared","dayjs","@nocobase/evaluators/client","@formily/antd-v5"],n):(v=typeof globalThis!="undefined"?globalThis:v||self,n(v["@nocobase/plugin-workflow"]={},v.jsxRuntime,v["@nocobase/client"],v["@nocobase/utils"],v["react-router-dom"],v.react,v.antd,v["react-i18next"],v["@ant-design/icons"],v["@formily/core"],v["@formily/reactive"],v["@formily/react"],v.lodash,v["@formily/shared"],v.dayjs,v["@nocobase/evaluators"],v["@formily/antd-v5"]))})(this,function(v,n,l,J,
|
|
10
|
+
(function(v,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("react/jsx-runtime"),require("@nocobase/client"),require("@nocobase/utils/client"),require("react-router-dom"),require("react"),require("antd"),require("react-i18next"),require("@ant-design/icons"),require("@formily/core"),require("@formily/reactive"),require("@formily/react"),require("lodash"),require("@formily/shared"),require("dayjs"),require("@nocobase/evaluators/client"),require("@formily/antd-v5")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","@nocobase/utils/client","react-router-dom","react","antd","react-i18next","@ant-design/icons","@formily/core","@formily/reactive","@formily/react","lodash","@formily/shared","dayjs","@nocobase/evaluators/client","@formily/antd-v5"],n):(v=typeof globalThis!="undefined"?globalThis:v||self,n(v["@nocobase/plugin-workflow"]={},v.jsxRuntime,v["@nocobase/client"],v["@nocobase/utils"],v["react-router-dom"],v.react,v.antd,v["react-i18next"],v["@ant-design/icons"],v["@formily/core"],v["@formily/reactive"],v["@formily/react"],v.lodash,v["@formily/shared"],v.dayjs,v["@nocobase/evaluators"],v["@formily/antd-v5"]))})(this,function(v,n,l,J,oe,b,y,G,I,le,mt,L,ke,ft,Ko,$e,Vt){"use strict";var Dr=Object.defineProperty,Er=Object.defineProperties;var $r=Object.getOwnPropertyDescriptors;var pt=Object.getOwnPropertySymbols;var Yo=Object.prototype.hasOwnProperty,qo=Object.prototype.propertyIsEnumerable;var Bt=(v,n,l)=>n in v?Dr(v,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):v[n]=l,C=(v,n)=>{for(var l in n||(n={}))Yo.call(n,l)&&Bt(v,l,n[l]);if(pt)for(var l of pt(n))qo.call(n,l)&&Bt(v,l,n[l]);return v},A=(v,n)=>Er(v,$r(n));var Go=v=>typeof v=="symbol"?v:v+"",Q=(v,n)=>{var l={};for(var J in v)Yo.call(v,J)&&n.indexOf(J)<0&&(l[J]=v[J]);if(v!=null&&pt)for(var J of pt(v))n.indexOf(J)<0&&qo.call(v,J)&&(l[J]=v[J]);return l};var w=(v,n,l)=>(Bt(v,typeof n!="symbol"?n+"":n,l),l);var U=(v,n,l)=>new Promise((J,oe)=>{var b=I=>{try{G(l.next(I))}catch(le){oe(le)}},y=I=>{try{G(l.throw(I))}catch(le){oe(le)}},G=I=>I.done?J(I.value):Promise.resolve(I.value).then(b,y);G((l=l.apply(v,n)).next())});const _o=b.createContext(null),ht={didCatch:!1,error:null};class Zo extends b.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=ht}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var o,r,s=arguments.length,i=new Array(s),a=0;a<s;a++)i[a]=arguments[a];(o=(r=this.props).onReset)===null||o===void 0||o.call(r,{args:i,reason:"imperative-api"}),this.setState(ht)}}componentDidCatch(t,o){var r,s;(r=(s=this.props).onError)===null||r===void 0||r.call(s,t,o)}componentDidUpdate(t,o){const{didCatch:r}=this.state,{resetKeys:s}=this.props;if(r&&o.error!==null&&Qo(t.resetKeys,s)){var i,a;(i=(a=this.props).onReset)===null||i===void 0||i.call(a,{next:s,prev:t.resetKeys,reason:"keys"}),this.setState(ht)}}render(){const{children:t,fallbackRender:o,FallbackComponent:r,fallback:s}=this.props,{didCatch:i,error:a}=this.state;let c=t;if(i){const u={error:a,resetErrorBoundary:this.resetErrorBoundary};if(b.isValidElement(s))c=s;else if(typeof o=="function")c=o(u);else if(r)c=b.createElement(r,u);else throw a}return b.createElement(_o.Provider,{value:{didCatch:i,error:a,resetErrorBoundary:this.resetErrorBoundary}},c)}}function Qo(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((o,r)=>!Object.is(o,t[r]))}const Ie=b.createContext({});function Y(){return b.useContext(Ie)}const p="workflow";function O(e,t={}){return l.i18n.t(e,A(C({},t),{ns:p}))}function yt(){return G.useTranslation(p)}const ne=l.createStyles(({css:e,token:t})=>({workflowPageClass:e`
|
|
11
11
|
flex-grow: 1;
|
|
12
12
|
overflow: hidden;
|
|
13
13
|
display: flex;
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
justify-content: space-between;
|
|
20
20
|
position: relative;
|
|
21
21
|
padding: 0.5rem 1rem;
|
|
22
|
-
background: ${
|
|
23
|
-
border-bottom: 1px solid ${
|
|
22
|
+
background: ${t.colorBgContainer};
|
|
23
|
+
border-bottom: 1px solid ${t.colorBorderSecondary};
|
|
24
24
|
|
|
25
25
|
header {
|
|
26
26
|
display: flex;
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
height: 10em;
|
|
56
56
|
padding: 1em 0;
|
|
57
57
|
border-radius: 0.5em;
|
|
58
|
-
background: ${
|
|
58
|
+
background: ${t.colorBgContainer};
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
.workflow-canvas {
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
bottom: 0;
|
|
130
130
|
left: calc(50% - 0.5px);
|
|
131
131
|
width: 1px;
|
|
132
|
-
background-color: ${
|
|
132
|
+
background-color: ${t.colorBgLayout};
|
|
133
133
|
}
|
|
134
134
|
`,branchClass:e`
|
|
135
135
|
display: flex;
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
top: 0;
|
|
149
149
|
bottom: 0;
|
|
150
150
|
width: 1px;
|
|
151
|
-
background-color: ${
|
|
151
|
+
background-color: ${t.colorBorder};
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
:before,
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
content: '';
|
|
157
157
|
position: absolute;
|
|
158
158
|
height: 1px;
|
|
159
|
-
background-color: ${
|
|
159
|
+
background-color: ${t.colorBorder};
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
:before {
|
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
justify-content: center;
|
|
200
200
|
width: 0;
|
|
201
201
|
height: 6em;
|
|
202
|
-
border-left: 1px dashed ${
|
|
202
|
+
border-left: 1px dashed ${t.colorBgLayout};
|
|
203
203
|
|
|
204
204
|
.anticon {
|
|
205
205
|
font-size: 1.5em;
|
|
@@ -221,15 +221,15 @@
|
|
|
221
221
|
`,nodeCardClass:e`
|
|
222
222
|
position: relative;
|
|
223
223
|
width: 20em;
|
|
224
|
-
background: ${
|
|
224
|
+
background: ${t.colorBgContainer};
|
|
225
225
|
padding: 1em;
|
|
226
|
-
box-shadow: ${
|
|
227
|
-
border-radius: ${
|
|
226
|
+
box-shadow: ${t.boxShadowTertiary};
|
|
227
|
+
border-radius: ${t.borderRadiusLG}px;
|
|
228
228
|
cursor: pointer;
|
|
229
229
|
transition: box-shadow 0.3s ease;
|
|
230
230
|
|
|
231
231
|
&:hover {
|
|
232
|
-
box-shadow: ${
|
|
232
|
+
box-shadow: ${t.boxShadow};
|
|
233
233
|
|
|
234
234
|
.workflow-node-remove-button {
|
|
235
235
|
display: block;
|
|
@@ -237,7 +237,7 @@
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
&.configuring {
|
|
240
|
-
box-shadow: ${
|
|
240
|
+
box-shadow: ${t.boxShadow};
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
.workflow-node-remove-button {
|
|
@@ -245,14 +245,14 @@
|
|
|
245
245
|
position: absolute;
|
|
246
246
|
right: 0.5em;
|
|
247
247
|
top: 0.5em;
|
|
248
|
-
color: ${
|
|
248
|
+
color: ${t.colorText};
|
|
249
249
|
|
|
250
250
|
&[disabled] {
|
|
251
251
|
display: none;
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
&:hover {
|
|
255
|
-
color: ${
|
|
255
|
+
color: ${t.colorErrorHover};
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
|
|
@@ -263,15 +263,15 @@
|
|
|
263
263
|
transition:
|
|
264
264
|
background-color 0.3s ease,
|
|
265
265
|
border-color 0.3s ease;
|
|
266
|
-
border-color: ${
|
|
267
|
-
background-color: ${
|
|
266
|
+
border-color: ${t.colorBorderBg};
|
|
267
|
+
background-color: ${t.colorBgContainerDisabled};
|
|
268
268
|
|
|
269
269
|
&:not(:disabled):hover {
|
|
270
|
-
border-color: ${
|
|
270
|
+
border-color: ${t.colorPrimaryBorderHover};
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
&:disabled:hover {
|
|
274
|
-
border-color: ${
|
|
274
|
+
border-color: ${t.colorBorderBg};
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
277
|
}
|
|
@@ -294,14 +294,14 @@
|
|
|
294
294
|
right: 1em;
|
|
295
295
|
justify-content: center;
|
|
296
296
|
align-items: center;
|
|
297
|
-
color: ${
|
|
297
|
+
color: ${t.colorTextLightSolid};
|
|
298
298
|
`,nodeHeaderClass:e`
|
|
299
299
|
position: relative;
|
|
300
300
|
`,nodeMetaClass:e`
|
|
301
301
|
margin-bottom: 0.5em;
|
|
302
302
|
|
|
303
303
|
.workflow-node-id {
|
|
304
|
-
color: ${
|
|
304
|
+
color: ${t.colorTextDescription};
|
|
305
305
|
|
|
306
306
|
&:before {
|
|
307
307
|
content: '#';
|
|
@@ -312,7 +312,7 @@
|
|
|
312
312
|
align-items: center;
|
|
313
313
|
font-weight: normal;
|
|
314
314
|
.workflow-node-id {
|
|
315
|
-
color: ${
|
|
315
|
+
color: ${t.colorTextDescription};
|
|
316
316
|
}
|
|
317
317
|
`,nodeSubtreeClass:e`
|
|
318
318
|
display: flex;
|
|
@@ -321,7 +321,7 @@
|
|
|
321
321
|
margin: auto;
|
|
322
322
|
`,nodeJobResultClass:e`
|
|
323
323
|
padding: 1em;
|
|
324
|
-
background-color: ${
|
|
324
|
+
background-color: ${t.colorBgContainer};
|
|
325
325
|
`,addButtonClass:e`
|
|
326
326
|
flex-shrink: 0;
|
|
327
327
|
padding: 2em 0;
|
|
@@ -339,8 +339,8 @@
|
|
|
339
339
|
position: absolute;
|
|
340
340
|
top: calc(1.5em - 1px);
|
|
341
341
|
line-height: 1em;
|
|
342
|
-
color: ${
|
|
343
|
-
background-color: ${
|
|
342
|
+
color: ${t.colorTextSecondary};
|
|
343
|
+
background-color: ${t.colorBgLayout};
|
|
344
344
|
padding: 1px;
|
|
345
345
|
}
|
|
346
346
|
`,loopLineClass:e`
|
|
@@ -360,17 +360,17 @@
|
|
|
360
360
|
width: 4em;
|
|
361
361
|
height: 4em;
|
|
362
362
|
border-radius: 50%;
|
|
363
|
-
background-color: ${
|
|
364
|
-
color: ${
|
|
365
|
-
`}));function
|
|
363
|
+
background-color: ${t.colorText};
|
|
364
|
+
color: ${t.colorBgContainer};
|
|
365
|
+
`}));function jt(e){var k;const{upstream:t,branchIndex:o=null}=e,r=l.usePlugin(de),s=l.useCompile(),i=l.useAPIClient(),{workflow:a,refresh:c}=(k=Y())!=null?k:{},u=Array.from(r.instructions.getValues()),{styles:d}=ne(),[f,h]=b.useState(!1),x=b.useMemo(()=>[{key:"control",label:`{{t("Control", { ns: "${p}" })}}`},{key:"collection",label:`{{t("Collection operations", { ns: "${p}" })}}`},{key:"manual",label:`{{t("Manual", { ns: "${p}" })}}`},{key:"extended",label:`{{t("Extended types", { ns: "${p}" })}}`}].map(T=>{const B=u.filter(S=>S.group===T.key&&(S.isAvailable?S.isAvailable({engine:r,workflow:a,upstream:t,branchIndex:o}):!0));return A(C({},T),{type:"group",children:B.map(S=>({role:"button","aria-label":S.type,key:S.type,label:S.title,type:S.options?"subMenu":null,children:S.options?S.options.map(D=>({role:"button","aria-label":D.key,key:D.key,label:D.label})):null}))})}).filter(T=>T.children.length),[o,r,u,t,a]),g=b.useCallback(B=>U(this,[B],function*({keyPath:T}){var M,N,F;const S=T.pop(),[D]=T,W=r.instructions.get(S),E=W.createDefaultConfig();if(D){const{value:$}=(N=(M=W.options)==null?void 0:M.find(H=>H.key===D))!=null?N:{};Object.assign(E,typeof $=="function"?$():$)}if(a){h(!0);try{yield i.resource("workflows.nodes",a.id).create({values:{type:S,upstreamId:(F=t==null?void 0:t.id)!=null?F:null,branchIndex:o,title:s(W.title),config:E}}),c()}catch($){console.error($)}finally{h(!1)}}}),[i,o,r.instructions,c,t==null?void 0:t.id,a]),m=b.useMemo(()=>({onClick:g,items:s(x)}),[x,g]);return a?n.jsx("div",{className:d.addButtonClass,children:n.jsx(y.Dropdown,{trigger:["click"],menu:m,disabled:a.executed,overlayClassName:l.css`
|
|
366
366
|
.ant-dropdown-menu-root {
|
|
367
367
|
max-height: 30em;
|
|
368
368
|
overflow-y: auto;
|
|
369
369
|
}
|
|
370
|
-
`,children:n.jsx(y.Button,{"aria-label":e["aria-label"]||"add-button",shape:"circle",icon:n.jsx(I.PlusOutlined,{}),loading:f})})}):null}const
|
|
370
|
+
`,children:n.jsx(y.Button,{"aria-label":e["aria-label"]||"add-button",shape:"circle",icon:n.jsx(I.PlusOutlined,{}),loading:f})})}):null}const gt=(e,t)=>({getAriaLabel:b.useCallback(r=>["add-button",e==null?void 0:e.type,e==null?void 0:e.title,t!=null?String(t):"",r].filter(Boolean).join("-"),[t,e==null?void 0:e.title,e==null?void 0:e.type])}),Xo=l.createStyles(({css:e,token:t})=>({container:e`
|
|
371
371
|
margin-bottom: 1.5em;
|
|
372
372
|
padding: 1em;
|
|
373
|
-
background-color: ${
|
|
373
|
+
background-color: ${t.colorFillAlter};
|
|
374
374
|
|
|
375
375
|
> *:last-child {
|
|
376
376
|
margin-bottom: 0;
|
|
@@ -381,7 +381,7 @@
|
|
|
381
381
|
align-items: baseline;
|
|
382
382
|
|
|
383
383
|
dt {
|
|
384
|
-
color: ${
|
|
384
|
+
color: ${t.colorText};
|
|
385
385
|
&:after {
|
|
386
386
|
content: ':';
|
|
387
387
|
margin-right: 0.5em;
|
|
@@ -390,13 +390,13 @@
|
|
|
390
390
|
}
|
|
391
391
|
|
|
392
392
|
p {
|
|
393
|
-
color: ${
|
|
393
|
+
color: ${t.colorTextDescription};
|
|
394
394
|
}
|
|
395
|
-
`}));function
|
|
395
|
+
`}));function Wt(e){const{label:t,title:o,description:r}=e,{styles:s}=Xo();return n.jsxs("div",{className:l.cx(s.container,e.className),children:[n.jsxs("dl",{children:[n.jsx("dt",{children:t}),n.jsx("dd",{children:n.jsx(y.Tag,{style:{background:"none"},children:o})})]}),r?n.jsx("p",{children:r}):null]})}function Ro(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Lt={exports:{}};/*!
|
|
396
396
|
Copyright (c) 2018 Jed Watson.
|
|
397
397
|
Licensed under the MIT License (MIT), see
|
|
398
398
|
http://jedwatson.github.io/classnames
|
|
399
|
-
*/(function(e){(function(){var
|
|
399
|
+
*/(function(e){(function(){var t={}.hasOwnProperty;function o(){for(var i="",a=0;a<arguments.length;a++){var c=arguments[a];c&&(i=s(i,r(c)))}return i}function r(i){if(typeof i=="string"||typeof i=="number")return i;if(typeof i!="object")return"";if(Array.isArray(i))return o.apply(null,i);if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]"))return i.toString();var a="";for(var c in i)t.call(i,c)&&i[c]&&(a=s(a,c));return a}function s(i,a){return a?i?i+" "+a:i+a:i}e.exports?(o.default=o,e.exports=o):window.classNames=o})()})(Lt);var en=Lt.exports;const tn=Ro(en),on=l.createStyles(({css:e,token:t})=>({statusButtonClass:e`
|
|
400
400
|
border: none;
|
|
401
401
|
.ant-tag {
|
|
402
402
|
width: 100%;
|
|
@@ -408,7 +408,7 @@
|
|
|
408
408
|
}
|
|
409
409
|
`,noStatusButtonClass:e`
|
|
410
410
|
border-width: 2px;
|
|
411
|
-
`}));function Pe(e){const
|
|
411
|
+
`}));function Pe(e){const a=e,{status:t,statusMap:o}=a,r=Q(a,["status","statusMap"]),{styles:s}=on();let i=null;if(typeof t!="undefined"&&(o!=null&&o[t])){const{icon:c,color:u}=o[t];i=n.jsx(y.Tag,{color:u,children:c})}return n.jsx(y.Button,A(C({},r),{shape:"circle",size:"small",className:tn(i?s.statusButtonClass:s.noStatusButtonClass,e.className),children:i}))}const pe={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},He=[{value:pe.QUEUEING,label:`{{t("Queueing", { ns: "${p}" })}}`,color:"blue",icon:n.jsx(I.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${p}" })}}`},{value:pe.STARTED,label:`{{t("On going", { ns: "${p}" })}}`,color:"gold",icon:n.jsx(I.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${p}" })}}`},{value:pe.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:n.jsx(I.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${p}" })}}`},{value:pe.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:n.jsx(I.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${p}" })}}`},{value:pe.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:n.jsx(I.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${p}" })}}`},{value:pe.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:n.jsx(I.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${p}" })}}`},{value:pe.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(I.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${p}" })}}`},{value:pe.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(I.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${p}" })}}`},{value:pe.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(I.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${p}" })}}`}],Ye=He.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),ae={PENDING:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},bt=[{value:ae.PENDING,label:`{{t("Pending", { ns: "${p}" })}}`,color:"gold",icon:n.jsx(I.ClockCircleOutlined,{})},{value:ae.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:n.jsx(I.CheckOutlined,{})},{value:ae.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:n.jsx(I.ExclamationOutlined,{})},{value:ae.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:n.jsx(I.CloseOutlined,{})},{value:ae.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:n.jsx(I.MinusOutlined,{rotate:90})},{value:ae.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(I.MinusOutlined,{rotate:45})},{value:ae.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(I.MinusOutlined,{})},{value:ae.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(I.RedoOutlined,{})}],qe=bt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});class ge{constructor(){w(this,"title");w(this,"type");w(this,"group");w(this,"description");w(this,"options");w(this,"fieldset");w(this,"view");w(this,"scope");w(this,"components");w(this,"end")}createDefaultConfig(){return{}}}function nn(){const e=L.useForm(),t=l.useAPIClient(),o=l.useActionContext(),{refresh:r}=l.useResourceActionContext(),s=ve(),{workflow:i}=Y();return{run(){return U(this,null,function*(){var c,u;if(i.executed){y.message.error(O("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(u=(c=t.resource("flow_nodes")).update)==null?void 0:u.call(c,{filterByTk:s.id,values:{config:e.values}}),e.setInitialValues(mt.toJS(e.values)),o.setFormValueChanged(!1),o.setVisible(!1),r()})}}}const vt=b.createContext({});function ve(){return b.useContext(vt)}function Me(e=[]){const t=ve();return e.some(o=>ke.get(t.config,o)!=null)}function zt(e,t){const o=[];if(!e)return[];for(let r=e.upstream;r;r=r.upstream)(typeof t!="function"||t(r))&&o.push(r);return o}function Jt(e){const t=[];if(!e)return[];for(let o=e;o;o=o.upstream)o.upstream&&o.branchIndex!=null&&t.push(o.upstream);return t}function Ut({data:e}){var a;const{styles:t}=ne(),{getAriaLabel:o}=gt(e),r=l.usePlugin(de),{Component:s=Ct,end:i}=(a=r.instructions.get(e.type))!=null?a:{};return n.jsx(vt.Provider,{value:e,children:n.jsxs("div",{className:l.cx(t.nodeBlockClass),children:[n.jsx(s,{data:e}),!i||typeof i=="function"&&!i(e)?n.jsx(jt,{"aria-label":o(),upstream:e}):n.jsx("div",{className:"end-sign",children:n.jsx(I.CloseOutlined,{})})]})})}function xt(){var d;const{t:e}=G.useTranslation(),t=l.useAPIClient(),{workflow:o,nodes:r,refresh:s}=(d=Y())!=null?d:{},i=ve(),{modal:a}=y.App.useApp();if(!o)return null;const c=t.resource("flow_nodes");function u(){return U(this,null,function*(){function f(){return U(this,null,function*(){var m;yield(m=c.destroy)==null?void 0:m.call(c,{filterByTk:i.id}),s()})}const h=r.filter(m=>m===i?!1:J.parse(m.config).parameters.filter(({key:B})=>B.startsWith(`$jobsMapByNodeKey.${i.key}.`)||B===`$jobsMapByNodeKey.${i.key}`).length);if(h.length){a.error({title:O("Can not delete"),content:O("The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",{nodes:h.map(m=>`#${m.id}`).join(", ")})});return}const g=!r.find(m=>m.upstream===i&&m.branchIndex!=null)?e("Are you sure you want to delete it?"):O("This node contains branches, deleting will also be preformed to them, are you sure?");a.confirm({title:e("Delete"),content:g,onOk:f})})}return o.executed?null:n.jsx(y.Button,{type:"text",shape:"circle",icon:n.jsx(I.DeleteOutlined,{}),onClick:u,className:"workflow-node-remove-button"})}function wt(){var i;const{execution:e,setViewJob:t}=Y(),{jobs:o}=(i=ve())!=null?i:{},{styles:r}=ne();if(!e)return null;if(!o.length)return n.jsx(Pe,{className:r.nodeJobButtonClass,disabled:!0});function s({key:a}){const c=o.find(u=>u.id==a);t(c)}return o.length>1?n.jsx(y.Dropdown,{menu:{items:o.map(a=>({key:a.id,label:n.jsxs(n.Fragment,{children:[n.jsx(Pe,{statusMap:qe,status:a.status}),n.jsx("time",{children:J.str2moment(a.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),onClick:s,className:r.dropdownClass},children:n.jsx(Pe,{statusMap:qe,status:o[o.length-1].status,className:r.nodeJobButtonClass})}):n.jsx(Pe,{statusMap:qe,status:o[0].status,onClick:()=>t(o[0]),className:r.nodeJobButtonClass})}function rn(){return{form:L.useForm()}}function Ct(e){var M;const{data:t,children:o}=e,r=l.useCompile(),s=l.useAPIClient(),{workflow:i,refresh:a}=(M=Y())!=null?M:{},{styles:c}=ne(),d=l.usePlugin(de).instructions.get(t.type),f=i.executed?'{{t("View")}}':'{{t("Configure")}}',[h,x]=b.useState(t.title),[g,m]=b.useState(!1),[k,T]=b.useState(!1),B=b.useMemo(()=>{const N=ke.cloneDeep(t.config);return le.createForm({initialValues:N,disabled:i.executed})},[t,i]),S=b.useCallback(N=>{m(N),N||B.reset()},[B]),D=b.useCallback(function(N){return U(this,null,function*(){var $,H;const F=N||r(d==null?void 0:d.title);x(F),F!==t.title&&(yield(H=($=s.resource("flow_nodes")).update)==null?void 0:H.call($,{filterByTk:t.id,values:{title:F}}),a())})},[t,d]),W=b.useCallback(function(N){if(N.target===N.currentTarget){m(!0);return}const F=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let $=N.target;$&&$!==N.currentTarget&&$!==document.documentElement;$=$.parentNode)if(Array.from($.classList).some(H=>F.has(H))){m(!0),N.stopPropagation();return}},[]);if(!d)return n.jsx("div",{className:l.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:n.jsx(y.Tooltip,{title:O("Node with unknown type will cause error. Please delete it or check plugin which provide this type."),children:n.jsxs("div",{role:"button","aria-label":`_untyped-${h}`,className:l.cx(c.nodeCardClass,"invalid"),onClick:W,children:[n.jsxs("div",{className:l.cx(c.nodeMetaClass,"workflow-node-meta"),children:[n.jsx(y.Tag,{color:"error",children:O("Unknown node")}),n.jsx("span",{className:"workflow-node-id",children:t.id})]}),n.jsx(y.Input.TextArea,{value:h,disabled:!0,autoSize:!0}),n.jsx(xt,{}),n.jsx(wt,{})]})})});const E=r(d.title);return n.jsxs("div",{className:l.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:[n.jsxs("div",{role:"button","aria-label":`${E}-${h}`,className:l.cx(c.nodeCardClass,{configuring:g}),onClick:W,children:[n.jsxs("div",{className:l.cx(c.nodeMetaClass,"workflow-node-meta"),children:[n.jsx(y.Tag,{children:E}),n.jsx("span",{className:"workflow-node-id",children:t.id})]}),n.jsx(y.Input.TextArea,{disabled:i.executed,value:h,onChange:N=>x(N.target.value),onBlur:N=>D(N.target.value),autoSize:!0}),n.jsx(xt,{}),n.jsx(wt,{}),n.jsx(l.ActionContextProvider,{value:{visible:g,setVisible:S,formValueChanged:k,setFormValueChanged:T},children:n.jsx(l.FormProvider,{form:B,children:n.jsx(l.SchemaComponent,{distributed:!1,scope:A(C({},d.scope),{useFormProviderProps:rn,useUpdateAction:nn}),components:d.components,schema:{type:"void",properties:A(C({},d.view?{view:d.view}:{}),{button:{type:"void","x-content":f,"x-component":y.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},[t.id]:{type:"void",title:n.jsxs("div",{className:l.css`
|
|
412
412
|
display: flex;
|
|
413
413
|
justify-content: space-between;
|
|
414
414
|
|
|
@@ -423,7 +423,7 @@
|
|
|
423
423
|
code {
|
|
424
424
|
font-weight: normal;
|
|
425
425
|
}
|
|
426
|
-
`,children:[n.jsx("strong",{children:
|
|
426
|
+
`,children:[n.jsx("strong",{children:t.title}),n.jsx(y.Tooltip,{title:O("Variable key of node"),children:n.jsx(y.Tag,{children:n.jsx("code",{children:t.key})})})]}),"x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps","x-component":"Action.Drawer",properties:A(C({},d.description?{description:{type:"void","x-component":Wt,"x-component-props":{label:O("Node type"),title:d.title,description:d.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:l.css`
|
|
427
427
|
.ant-input,
|
|
428
428
|
.ant-select,
|
|
429
429
|
.ant-cascader-picker,
|
|
@@ -435,34 +435,34 @@
|
|
|
435
435
|
min-width: 6em;
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
|
-
`},properties:d.fieldset},actions:
|
|
438
|
+
`},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:"{{ useUpdateAction }}"}}}}})}})}})})})]}),o]})}function Ge({from:e=null,entry:t=null,branchIndex:o=null,controller:r=null,className:s,end:i}){const{styles:a}=ne(),{getAriaLabel:c}=gt(e,o),u=[];for(let d=t;d;d=d.downstream)u.push(d);return n.jsxs("div",{className:l.cx("workflow-branch",a.branchClass,s),children:[n.jsx("div",{className:"workflow-branch-lines"}),r,n.jsx(jt,{"aria-label":c(),upstream:e,branchIndex:o}),n.jsx("div",{className:"workflow-node-list",children:u.map(d=>n.jsx(Ut,{data:d},d.id))}),i?n.jsx("div",{className:"end-sign",children:n.jsx(I.CloseOutlined,{})}):null]})}function sn(){var i;const e=L.useForm(),t=l.useAPIClient(),{workflow:o}=(i=Y())!=null?i:{},r=l.useActionContext(),{refresh:s}=l.useResourceActionContext();return{run(){return U(this,null,function*(){if(o.executed){y.message.error(O("Trigger in executed workflow cannot be modified"));return}yield e.submit(),yield t.resource("workflows").update({filterByTk:o.id,values:{config:e.values}}),r.setFormValueChanged(!1),r.setVisible(!1),s()})}}}class kt{constructor(){w(this,"sync");w(this,"title");w(this,"description");w(this,"fieldset");w(this,"view");w(this,"scope");w(this,"components");w(this,"initializers");w(this,"isActionTriggerable")}}function ln(){const e=l.useCompile(),{workflow:t,execution:o}=Y(),{styles:r}=ne(),s=St();return o?n.jsx(l.SchemaComponent,{schema:{type:"void",name:"execution","x-component":"Action","x-component-props":{title:n.jsx(I.InfoOutlined,{}),shape:"circle",size:"small",className:r.nodeJobButtonClass,type:"primary"},properties:{[o.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:n.jsxs("div",{className:l.cx(r.nodeTitleClass),children:[n.jsx(y.Tag,{children:e(s.title)}),n.jsx("strong",{children:t.title}),n.jsxs("span",{className:"workflow-node-id",children:["#",o.id]})]}),properties:{createdAt:{type:"string",title:`{{t("Triggered at", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},context:{type:"object",title:`{{t("Trigger variables", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:l.css`
|
|
439
439
|
padding: 1em;
|
|
440
440
|
background-color: #eee;
|
|
441
|
-
`},"x-read-pretty":!0}}}}}}):null}function an(){return{form:L.useForm()}}const cn=()=>{const e=l.useAPIClient(),{workflow:
|
|
441
|
+
`},"x-read-pretty":!0}}}}}}):null}function an(){return{form:L.useForm()}}const cn=()=>{const e=l.useAPIClient(),{workflow:t,refresh:o}=Y(),[r,s]=b.useState(""),[i,a]=b.useState(!1),[c,u]=b.useState(!1),{styles:d}=ne(),f=l.useCompile(),h=St();b.useEffect(()=>{var E,M;t&&s((M=(E=t.triggerTitle)!=null?E:t.title)!=null?M:f(h==null?void 0:h.title))},[t,h]);const x=b.useMemo(()=>{const E=ke.cloneDeep(t.config);return le.createForm({initialValues:E,disabled:t.executed})},[t]),g=b.useCallback(E=>{a(E),E||x.reset()},[x]),m=b.useCallback(function(E){return U(this,null,function*(){const M=E||f(h==null?void 0:h.title);s(M),M!==t.triggerTitle&&(yield e.resource("workflows").update({filterByTk:t.id,values:{triggerTitle:M}}),o())})},[t,h]),k=b.useCallback(function(E){var N;if(E.target===E.currentTarget){a(!0);return}const M=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let F=E.target;F&&F!==E.currentTarget;F=F.parentNode)if(Array.from((N=F.classList)!=null?N:[]).some($=>M.has($))){a(!0),E.stopPropagation();return}},[]),T=t.executed?'{{t("View")}}':'{{t("Configure")}}',B=O("Trigger");if(!h)return n.jsx(y.Tooltip,{title:O("Workflow with unknown type will cause error. Please delete it or check plugin which provide this type."),children:n.jsxs("div",{role:"button","aria-label":`${B}-${r}`,className:l.cx(d.nodeCardClass,"invalid"),onClick:k,children:[n.jsx("div",{className:l.cx(d.nodeMetaClass,"workflow-node-meta"),children:n.jsx(y.Tag,{color:"error",children:O("Unknown trigger")})}),n.jsx("div",{className:"workflow-node-title",children:n.jsx(y.Input.TextArea,{value:r,disabled:!0,autoSize:!0})})]})});const{fieldset:S,scope:D,components:W}=h;return n.jsxs("div",{role:"button","aria-label":`${B}-${r}`,className:l.cx(d.nodeCardClass),onClick:k,children:[n.jsx("div",{className:l.cx(d.nodeMetaClass,"workflow-node-meta"),children:n.jsxs(y.Tag,{color:"gold",children:[n.jsx(I.ThunderboltOutlined,{}),n.jsx("span",{className:"type",children:f(h.title)})]})}),n.jsx("div",{className:"workflow-node-title",children:n.jsx(y.Input.TextArea,{value:r,onChange:E=>s(E.target.value),onBlur:E=>m(E.target.value),autoSize:!0,disabled:t.executed})}),n.jsx(ln,{}),n.jsx(l.ActionContextProvider,{value:{visible:i,setVisible:g,formValueChanged:c,setFormValueChanged:u},children:n.jsx(l.FormProvider,{form:x,children:n.jsx(l.SchemaComponent,{scope:A(C({},D),{useFormProviderProps:an}),components:W,schema:{name:`workflow-trigger-${t.id}`,type:"void",properties:{config:{type:"void","x-content":T,"x-component":y.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},drawer:{type:"void",title:B,"x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps",properties:A(C({},h.description?{description:{type:"void","x-component":Wt,"x-component-props":{label:O("Trigger type"),title:h.title,description:h.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:l.css`
|
|
442
442
|
.ant-select.auto-width {
|
|
443
443
|
width: auto;
|
|
444
444
|
min-width: 6em;
|
|
445
445
|
}
|
|
446
|
-
`},properties:S},actions:C({},
|
|
446
|
+
`},properties:S},actions:C({},t.executed?{}:{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:sn}}}})})}}}})})})]})};function St(){const e=l.usePlugin(de),{workflow:t}=Y();return e.triggers.get(t.type)}function Ht({entry:e}){const{styles:t}=ne(),{workflow:o}=Y(),[r,s]=b.useState(100);return n.jsxs("div",{className:"workflow-canvas-wrapper",children:[n.jsx(Zo,{FallbackComponent:l.ErrorFallback,onError:console.error,children:n.jsx("div",{className:"workflow-canvas",style:{zoom:r/100},children:n.jsx("div",{className:l.cx(t.branchBlockClass,l.css`
|
|
447
447
|
margin-top: 0 !important;
|
|
448
|
-
`),children:n.jsxs("div",{className:
|
|
448
|
+
`),children:n.jsxs("div",{className:t.branchClass,children:[o!=null&&o.executed?n.jsx(y.Alert,{type:"warning",message:O("Executed workflow cannot be modified. Could be copied to a new version to modify."),showIcon:!0,className:l.css`
|
|
449
449
|
margin-bottom: 1em;
|
|
450
|
-
`}):null,n.jsx(cn,{}),n.jsx("div",{className:l.cx(
|
|
450
|
+
`}):null,n.jsx(cn,{}),n.jsx("div",{className:l.cx(t.branchBlockClass,l.css`
|
|
451
451
|
margin-top: 0 !important;
|
|
452
|
-
`),children:n.jsx(Ke,{entry:e})}),n.jsx("div",{className:o.terminalClass,children:T("End")})]})})})}),n.jsx("div",{className:"workflow-canvas-zoomer",children:n.jsx(y.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:r,onChange:s})})]})}function Fo(e){const o=new Map;e.forEach(t=>o.set(t.id,t));for(const t of o.values())t.upstreamId&&(t.upstream=o.get(t.upstreamId)),t.downstreamId&&(t.downstream=o.get(t.downstreamId))}function Oo(e,o){o(e),e.properties&&Object.keys(e.properties).forEach(t=>{Oo(e.properties[t],o)})}function xe(e){return`/admin/workflow/workflows/${e}`}function Ye(e){return`/admin/workflow/executions/${e}`}function dn(e,o=[]){const t=new Map;e.forEach(r=>{r.jobs=[],t.set(r.id,r)}),o.forEach(r=>{const s=t.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 un(){const{instructions:e}=l.usePlugin(de),o=l.useCompile(),{viewJob:t,setViewJob:r}=G(),{styles:s}=ne(),{node:a={}}=t!=null?t:{},i=e.get(a.type);return n.jsx(l.ActionContextProvider,{value:{visible:!!t,setVisible:r},children:n.jsx(l.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:s.nodeTitleClass,children:[n.jsx(y.Tag,{children:o(i==null?void 0:i.title)}),n.jsx("strong",{children:a.title}),n.jsxs("span",{className:"workflow-node-id",children:["#",a.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:vo,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:s.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function pn(e){const{execution:o}=G(),t=l.useAPIClient(),r=te.useNavigate(),{styles:s}=ne(),[a,i]=b.useState([]),[c,u]=b.useState([]);b.useEffect(()=>{o&&t.resource("executions").list({filter:{key:o.key,id:{$lt:o.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{i(f.data)}).catch(()=>{})},[o]),b.useEffect(()=>{o&&t.resource("executions").list({filter:{key:o.key,id:{$gt:o.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{u(f.data.reverse())}).catch(()=>{})},[o]);const d=b.useCallback(({key:f})=>{f!=o.id&&r(Ye(f))},[o]);return o?n.jsx(y.Dropdown,{menu:{onClick:d,defaultSelectedKeys:[`${o.id}`],className:l.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,o,...a].map(f=>({key:f.id,label:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"id",children:`#${f.id}`}),n.jsx("time",{children:J.str2moment(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:n.jsx("span",{children:n.jsx(Pe,{statusMap:Ge,status:f.status})})}))},children:n.jsxs(y.Space,{children:[n.jsx("strong",{children:`#${o.id}`}),n.jsx(I.DownOutlined,{})]})}):null}function mn(){var S;const{t:e}=Q.useTranslation(),o=l.useCompile(),{data:t,loading:r,refresh:s}=l.useResourceActionContext(),{setTitle:a}=l.useDocumentTitle(),[i,c]=b.useState(null),u=l.useApp(),d=l.useAPIClient();b.useEffect(()=>{var N;const{workflow:M}=(N=t==null?void 0:t.data)!=null?N:{};a==null||a(`${M!=null&&M.title?`${M.title} - `:""}${T("Execution history")}`)},[t==null?void 0:t.data]);const f=b.useCallback(()=>{y.Modal.confirm({title:T("Cancel the execution"),icon:n.jsx(I.ExclamationCircleFilled,{}),content:T("Are you sure you want to cancel the execution?"),onOk:()=>{d.resource("executions").cancel({filterByTk:t==null?void 0:t.data.id}).then(()=>{y.message.success(e("Operation succeeded")),s()}).catch(M=>{console.error(M.data.error)})}})},[t==null?void 0:t.data]);if(!(t!=null&&t.data))return r?n.jsx(y.Spin,{}):n.jsx(y.Result,{status:"404",title:"Not found"});const E=(S=t==null?void 0:t.data)!=null?S:{},{jobs:h=[],workflow:W={}}=E,$=W,{nodes:x=[],revisions:g=[]}=$,m=Z($,["nodes","revisions"]),k=Z(E,["jobs","workflow"]);Fo(x),dn(x,h);const O=x.find(M=>!M.upstream),B=Ge[k.status];return n.jsxs(Ie.Provider,{value:{workflow:m.type?m:null,nodes:x,execution:k,viewJob:i,setViewJob:c},children:[n.jsxs("div",{className:"workflow-toolbar",children:[n.jsx("header",{children:n.jsx(y.Breadcrumb,{items:[{title:n.jsx(te.Link,{to:u.pluginSettingsManager.getRoutePath("workflow"),children:T("Workflow")})},{title:n.jsx(y.Tooltip,{title:`Key: ${m.key}`,children:n.jsx(te.Link,{to:xe(m.id),children:m.title})})},{title:n.jsx(pn,{})}]})}),n.jsxs("aside",{children:[n.jsx(y.Tag,{color:B.color,children:o(B.label)}),k.status?null:n.jsx(y.Tooltip,{title:T("Cancel the execution"),children:n.jsx(y.Button,{type:"link",danger:!0,onClick:f,shape:"circle",size:"small",icon:n.jsx(I.StopOutlined,{})})}),n.jsx("time",{children:J.str2moment(k.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),n.jsx(Go,{entry:O}),n.jsx(un,{})]})}const qo=()=>{const e=te.useParams(),{styles:o}=ne();return n.jsx("div",{className:l.cx(o.workflowPageClass),children:n.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:mn}})})},Ko=()=>{const{t:e}=Q.useTranslation(),{id:o}=l.useRecord(),{setVisible:t}=l.useActionContext();return n.jsx(te.Link,{to:Ye(o),onClick:()=>t(!1),children:e("View")})},fn={name:"execution-executions",fields:[{interface:"id",type:"bigInt",name:"id",uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${p}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${p}" })}}`,"x-component"({value:e}){const{setVisible:o}=l.useActionContext();return n.jsx(te.Link,{to:xe(e),onClick:()=>o(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${p}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:He}}]},Yo={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${p}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:fn,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:{refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=Q.useTranslation(),{refresh:o,defaultRequest:t}=l.useResourceActionContext(),{resource:r}=l.useResourceContext(),{setVisible:s}=l.useActionContext();return{run(){return U(this,null,function*(){var i;yield r.destroy({filter:(i=t.params)==null?void 0:i.filter}),y.message.success(e("Operation succeeded")),o(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${p}" })}}`,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: "${p}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},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",title:`{{t("Status", { ns: "${p}" })}}`,properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","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","x-component":"ExecutionLink"}}}}}}}}}}};function _o(e){var a;const t=l.useCompile()(e.label),r=b.useCallback(i=>{i.preventDefault(),i.stopPropagation()},[]),{color:s}=(a=Ge[e.value])!=null?a:{};return n.jsx(y.Tag,{color:s,onMouseDown:r,closable:e.closable,onClose:e.onClose,children:t})}function hn(e){const o=l.useCompile();return n.jsxs(n.Fragment,{children:[n.jsx(_o,C({},e)),e.description?n.jsx("span",{children:o(e.description)}):null]})}function yn(o){var e=Z(o,[]);const t=e.multiple?"multiple":null;return n.jsx(y.Select,A(C({role:"button","data-testid":`select-${t||"single"}`},e),{mode:t,optionLabelProp:"label",tagRender:_o,children:He.filter(r=>!!r.value&&r.value!==pe.ABORTED).map(r=>n.jsx(y.Select.Option,A(C({},r),{children:n.jsx(hn,C({},r))}),r.value))}))}function Zo(e){const{t:o}=Q.useTranslation(),{refresh:t}=l.useResourceActionContext(),{resource:r}=l.useResourceContext(),s=l.useRecord(),a=b.useCallback(()=>{y.Modal.confirm({title:T("Cancel the execution"),icon:n.jsx(I.ExclamationCircleFilled,{}),content:T("Are you sure you want to cancel the execution?"),onOk:()=>{r.cancel({filterByTk:s.id}).then(()=>{y.message.success(o("Operation succeeded")),t()}).catch(i=>{console.error(i.data.error)})}})},[s]);return n.jsxs("div",{className:l.css`
|
|
452
|
+
`),children:n.jsx(Ge,{entry:e})}),n.jsx("div",{className:t.terminalClass,children:O("End")})]})})})}),n.jsx("div",{className:"workflow-canvas-zoomer",children:n.jsx(y.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:r,onChange:s})})]})}function At(e){const t=new Map;e.forEach(o=>t.set(o.id,o));for(const o of t.values())o.upstreamId&&(o.upstream=t.get(o.upstreamId)),o.downstreamId&&(o.downstream=t.get(o.downstreamId))}function Ft(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{Ft(e.properties[o],t)})}function xe(e){return`/admin/workflow/workflows/${e}`}function Ke(e){return`/admin/workflow/executions/${e}`}function dn(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,i)=>s.id-i.id)})}function un(){const{instructions:e}=l.usePlugin(de),t=l.useCompile(),{viewJob:o,setViewJob:r}=Y(),{styles:s}=ne(),{node:i={}}=o!=null?o:{},a=e.get(i.type);return n.jsx(l.ActionContextProvider,{value:{visible:!!o,setVisible:r},children:n.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:n.jsxs("div",{className:s.nodeTitleClass,children:[n.jsx(y.Tag,{children:t(a==null?void 0:a.title)}),n.jsx("strong",{children:i.title}),n.jsxs("span",{className:"workflow-node-id",children:["#",i.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:bt,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:s.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function pn(e){const{execution:t}=Y(),o=l.useAPIClient(),r=oe.useNavigate(),{styles:s}=ne(),[i,a]=b.useState([]),[c,u]=b.useState([]);b.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})=>{a(f.data)}).catch(()=>{})},[t]),b.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 d=b.useCallback(({key:f})=>{f!=t.id&&r(Ke(f))},[t]);return t?n.jsx(y.Dropdown,{menu:{onClick:d,defaultSelectedKeys:[`${t.id}`],className:l.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...i].map(f=>({key:f.id,label:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"id",children:`#${f.id}`}),n.jsx("time",{children:J.str2moment(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:n.jsx("span",{children:n.jsx(Pe,{statusMap:Ye,status:f.status})})}))},children:n.jsxs(y.Space,{children:[n.jsx("strong",{children:`#${t.id}`}),n.jsx(I.DownOutlined,{})]})}):null}function mn(){var S;const{t:e}=G.useTranslation(),t=l.useCompile(),{data:o,loading:r,refresh:s}=l.useResourceActionContext(),{setTitle:i}=l.useDocumentTitle(),[a,c]=b.useState(null),u=l.useApp(),d=l.useAPIClient();b.useEffect(()=>{var N;const{workflow:M}=(N=o==null?void 0:o.data)!=null?N:{};i==null||i(`${M!=null&&M.title?`${M.title} - `:""}${O("Execution history")}`)},[o==null?void 0:o.data]);const f=b.useCallback(()=>{y.Modal.confirm({title:O("Cancel the execution"),icon:n.jsx(I.ExclamationCircleFilled,{}),content:O("Are you sure you want to cancel the execution?"),onOk:()=>{d.resource("executions").cancel({filterByTk:o==null?void 0:o.data.id}).then(()=>{y.message.success(e("Operation succeeded")),s()}).catch(M=>{console.error(M.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return r?n.jsx(y.Spin,{}):n.jsx(y.Result,{status:"404",title:"Not found"});const D=(S=o==null?void 0:o.data)!=null?S:{},{jobs:h=[],workflow:W={}}=D,E=W,{nodes:x=[],revisions:g=[]}=E,m=Q(E,["nodes","revisions"]),k=Q(D,["jobs","workflow"]);At(x),dn(x,h);const T=x.find(M=>!M.upstream),B=Ye[k.status];return n.jsxs(Ie.Provider,{value:{workflow:m.type?m:null,nodes:x,execution:k,viewJob:a,setViewJob:c},children:[n.jsxs("div",{className:"workflow-toolbar",children:[n.jsx("header",{children:n.jsx(y.Breadcrumb,{items:[{title:n.jsx(oe.Link,{to:u.pluginSettingsManager.getRoutePath("workflow"),children:O("Workflow")})},{title:n.jsx(y.Tooltip,{title:`Key: ${m.key}`,children:n.jsx(oe.Link,{to:xe(m.id),children:m.title})})},{title:n.jsx(pn,{})}]})}),n.jsxs("aside",{children:[n.jsx(y.Tag,{color:B.color,children:t(B.label)}),k.status?null:n.jsx(y.Tooltip,{title:O("Cancel the execution"),children:n.jsx(y.Button,{type:"link",danger:!0,onClick:f,shape:"circle",size:"small",icon:n.jsx(I.StopOutlined,{})})}),n.jsx("time",{children:J.str2moment(k.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),n.jsx(Ht,{entry:T}),n.jsx(un,{})]})}const Yt=()=>{const e=oe.useParams(),{styles:t}=ne();return n.jsx("div",{className:l.cx(t.workflowPageClass),children:n.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:mn}})})},qt=()=>{const{t:e}=G.useTranslation(),{id:t}=l.useRecord(),{setVisible:o}=l.useActionContext();return n.jsx(oe.Link,{to:Ke(t),onClick:()=>o(!1),children:e("View")})},fn={name:"execution-executions",fields:[{interface:"id",type:"bigInt",name:"id",uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${p}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${p}" })}}`,"x-component"({value:e}){const{setVisible:t}=l.useActionContext();return n.jsx(oe.Link,{to:xe(e),onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${p}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:He}}]},Gt={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${p}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:fn,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:{refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=G.useTranslation(),{refresh:t,defaultRequest:o}=l.useResourceActionContext(),{resource:r}=l.useResourceContext(),{setVisible:s}=l.useActionContext();return{run(){return U(this,null,function*(){var a;yield r.destroy({filter:(a=o.params)==null?void 0:a.filter}),y.message.success(e("Operation succeeded")),t(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${p}" })}}`,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: "${p}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},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",title:`{{t("Status", { ns: "${p}" })}}`,properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","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","x-component":"ExecutionLink"}}}}}}}}}}};function Kt(e){var i;const o=l.useCompile()(e.label),r=b.useCallback(a=>{a.preventDefault(),a.stopPropagation()},[]),{color:s}=(i=Ye[e.value])!=null?i:{};return n.jsx(y.Tag,{color:s,onMouseDown:r,closable:e.closable,onClose:e.onClose,children:o})}function hn(e){const t=l.useCompile();return n.jsxs(n.Fragment,{children:[n.jsx(Kt,C({},e)),e.description?n.jsx("span",{children:t(e.description)}):null]})}function yn(t){var e=Q(t,[]);const o=e.multiple?"multiple":null;return n.jsx(y.Select,A(C({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Kt,children:He.filter(r=>!!r.value&&r.value!==pe.ABORTED).map(r=>n.jsx(y.Select.Option,A(C({},r),{children:n.jsx(hn,C({},r))}),r.value))}))}function _t(e){const{t}=G.useTranslation(),{refresh:o}=l.useResourceActionContext(),{resource:r}=l.useResourceContext(),s=l.useRecord(),i=b.useCallback(()=>{y.Modal.confirm({title:O("Cancel the execution"),icon:n.jsx(I.ExclamationCircleFilled,{}),content:O("Are you sure you want to cancel the execution?"),onOk:()=>{r.cancel({filterByTk:s.id}).then(()=>{y.message.success(t("Operation succeeded")),o()}).catch(a=>{console.error(a.data.error)})}})},[s]);return n.jsxs("div",{className:l.css`
|
|
453
453
|
display: flex;
|
|
454
|
-
`,children:[e.children,s.status?null:n.jsx(y.Tooltip,{title:T("Cancel the execution"),children:n.jsx(y.Button,{type:"link",danger:!0,onClick:a,shape:"circle",size:"small",icon:n.jsx(I.StopOutlined,{})})})]})}function Qo(){const e=l.useResourceActionContext();return{onClick(){return U(this,null,function*(){var t;(t=e==null?void 0:e.refresh)==null||t.call(e)})}}}function gn(r){var s=r,{request:e,filter:o={}}=s,t=Z(s,["request","filter"]);var c;const{workflow:a}=G(),i=A(C({},t),{request:A(C({},e),{params:A(C({},e==null?void 0:e.params),{filter:A(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return n.jsx(l.ResourceActionProvider,C({},i))}function bn(){var M;const e=te.useNavigate(),{t:o}=Q.useTranslation(),t=l.useApp(),{data:r,refresh:s,loading:a}=l.useResourceActionContext(),{resource:i}=l.useResourceContext(),{setTitle:c}=l.useDocumentTitle(),[u,d]=b.useState(!1),{styles:f}=ne(),{modal:h}=y.App.useApp();if(b.useEffect(()=>{var D;const{title:F}=(D=r==null?void 0:r.data)!=null?D:{};c==null||c(`${T("Workflow")}${F?`: ${F}`:""}`)},[r==null?void 0:r.data]),!(r!=null&&r.data))return a?n.jsx(y.Spin,{}):n.jsx(y.Result,{status:"404",title:"Not found",extra:n.jsx(y.Button,{onClick:()=>e(-1),children:T("Go back")})});const N=(M=r==null?void 0:r.data)!=null?M:{},{nodes:x=[],revisions:g=[]}=N,m=Z(N,["nodes","revisions"]);Fo(x);const k=x.find(F=>!F.upstream);function O({key:F}){F!=m.id&&e(xe(F))}function B(F){return U(this,null,function*(){yield i.update({filterByTk:m.id,values:{enabled:F}}),s()})}function S(){return U(this,null,function*(){const{data:{data:F}}=yield i.revision({filterByTk:m.id,filter:{key:m.key}});y.message.success(o("Operation succeeded")),e(`/admin/workflow/workflows/${F.id}`)})}function E(){return U(this,null,function*(){const F=m.current?T("Delete a main version will cause all other revisions to be deleted too."):"";h.confirm({title:o("Are you sure you want to delete it?"),content:F,onOk(){return U(this,null,function*(){var H;yield i.destroy({filterByTk:m.id}),y.message.success(o("Operation succeeded")),e(m.current?t.pluginSettingsManager.getRoutePath("workflow"):xe((H=g.find(K=>K.current))==null?void 0:H.id))})}})})}function W(D){return U(this,arguments,function*({key:F}){switch(F){case"history":d(!0);return;case"revision":return S();case"delete":return E()}})}const $=m.executed&&!g.find(F=>!F.executed&&new Date(F.createdAt)>new Date(m.createdAt));return n.jsxs(Ie.Provider,{value:{workflow:m,nodes:x,refresh:s},children:[n.jsxs("div",{className:"workflow-toolbar",children:[n.jsx("header",{children:n.jsx(y.Breadcrumb,{items:[{title:n.jsx(te.Link,{to:t.pluginSettingsManager.getRoutePath("workflow"),children:T("Workflow")})},{title:n.jsx(y.Tooltip,{title:`Key: ${m.key}`,children:n.jsx("strong",{children:m.title})})}]})}),n.jsxs("aside",{children:[m.sync?n.jsx(y.Tag,{color:"orange",children:T("Synchronously")}):n.jsx(y.Tag,{color:"cyan",children:T("Asynchronously")}),n.jsx(y.Dropdown,{className:"workflow-versions",trigger:["click"],menu:{onClick:O,defaultSelectedKeys:[`${m.id}`],className:l.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:g.sort((F,D)=>D.id-F.id).map((F,D)=>({role:"button","aria-label":`version-${D}`,key:`${F.id}`,icon:F.current?n.jsx(I.RightOutlined,{}):null,className:l.cx({executed:F.executed,unexecuted:!F.executed,enabled:F.enabled}),label:n.jsxs(n.Fragment,{children:[n.jsx("strong",{children:`#${F.id}`}),n.jsx("time",{children:J.str2moment(F.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:n.jsxs(y.Button,{type:"text","aria-label":"version",children:[n.jsx("label",{children:T("Version")}),n.jsx("span",{children:m!=null&&m.id?`#${m.id}`:null}),n.jsx(I.DownOutlined,{})]})}),n.jsx(y.Switch,{checked:m.enabled,onChange:B,checkedChildren:T("On"),unCheckedChildren:T("Off")}),n.jsx(y.Dropdown,{menu:{items:[{key:"key",label:`Key: ${m.key}`,disabled:!0},{type:"divider"},{role:"button","aria-label":"history",key:"history",label:T("Execution history"),disabled:!m.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:T("Copy to new version"),disabled:!$},{type:"divider"},{role:"button","aria-label":"delete",danger:!0,key:"delete",label:o("Delete")}],onClick:W},children:n.jsx(y.Button,{"aria-label":"more",type:"text",icon:n.jsx(I.EllipsisOutlined,{})})}),n.jsx(l.ActionContextProvider,{value:{visible:u,setVisible:d},children:n.jsx(l.SchemaComponent,{schema:Yo,components:{ExecutionResourceProvider:gn,ExecutionLink:Ko,ExecutionStatusColumn:Zo},scope:{useRefreshActionProps:Qo}})})]})]}),n.jsx(Go,{entry:k})]})}const Xo=()=>{const e=te.useParams(),{styles:o}=ne();return n.jsx("div",{className:l.cx(o.workflowPageClass),children:n.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:bn}})})},vn=r=>{var s=r,{request:e,filter:o={}}=s,t=Z(s,["request","filter"]);var c;const a=l.useRecord(),i=A(C({},t),{request:A(C({},e),{params:A(C({},e==null?void 0:e.params),{filter:A(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return n.jsx(l.ResourceActionProvider,C({},i))},xn=()=>{const{t:e}=Q.useTranslation(),{id:o}=l.useRecord(),{setVisible:t}=l.useActionContext(),{getAriaLabel:r}=l.useGetAriaLabelOfAction("Configure");return n.jsx(te.Link,{"aria-label":r(),to:xe(o),onClick:()=>t(!1),children:e("Configure")})};function wn(r){var s=r,{component:e="div",children:o}=s,t=Z(s,["component","children"]);const[a,i]=b.useState(!1),c=L.useFieldSchema();return n.jsxs(l.ActionContextProvider,{value:{visible:a,setVisible:i,fieldSchema:c},children:[b.createElement(e,A(C({},t),{onClick(){i(!0)}}),o),n.jsx(l.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}function Cn({data:e}){const{label:o,color:t,options:r}=e,s=l.useCompile();return n.jsxs(y.Space,{direction:"vertical",children:[n.jsx(y.Tag,{color:t,children:s(o)}),n.jsx(y.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:s(r.description)})]})}const Ro={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: "${p}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}",optionRender:Cn,popupMatchSelectWidth:!0,listHeight:300},required:!0}},{type:"boolean",name:"sync",interface:"select",uiSchema:{title:`{{t("Mode", { ns: "${p}" })}}`,type:"boolean","x-decorator":"FormItem","x-component":"Select",enum:[{label:`{{ t("Asynchronously", { ns: "${p}" }) }}`,value:!1,color:"cyan"},{label:`{{ t("Synchronously", { ns: "${p}" }) }}`,value:!0,color:"orange"}],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: "${p}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${p}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${p}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${p}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},fe={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${p}" }) }}`,description:`{{ t("Execute workflow asynchronously or synchronously based on trigger type, and could not be changed after created.", { ns: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Asynchronously", { ns: "${p}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${p}" }) }}`},{label:`{{ t("Synchronously", { ns: "${p}" }) }}`,value:!0,tooltip:`{{ t("For user actions that require immediate feedback. Can not use asynchronous nodes in such mode, and it is not recommended to perform time-consuming operations under synchronous mode.", { ns: "${p}" }) }}`}]}},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: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},kn={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Ro,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:Ro},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-use-component-props":"cm.useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},sync:{type:"void",title:`{{t("Sync", { ns: "${p}" })}}`,"x-decorator":"Tooltip","x-decorator-props":{title:`{{ t("Sync enabled status of all workflows from database", { ns: "${p}" }) }}`},"x-component":"Action","x-component-props":{icon:"SyncOutlined",useAction(){const{t:e}=Q.useTranslation(),{resource:o}=l.useResourceContext(),t=l.useResourceActionContext();return{run(){return U(this,null,function*(){yield o.sync(),yield t==null?void 0:t.refresh(),y.message.success(e("Operation succeeded"))})}}}},"x-reactions":["{{useWorkflowSyncAction}}"]},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",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",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:fe.title,type:fe.type,sync:fe.sync,description:fe.description,options:fe.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}}},sync:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{sync:{type:"boolean","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 t=l.useRecord();return b.createElement("a",C({"aria-label":`executed-${t.title}`},o))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:Yo}}}},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:fe.title,enabled:fe.enabled,sync:fe.sync,description:fe.description,options:fe.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: "${p}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${p}" })}}`,"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}=Q.useTranslation(),{refresh:o}=l.useResourceActionContext(),{resource:t,targetKey:r}=l.useResourceContext(),{setVisible:s}=l.useActionContext(),{[r]:a}=l.useRecord(),{values:i}=L.useForm();return{run(){return U(this,null,function*(){yield t.revision({filterByTk:a,values:i}),y.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 Sn(e){const o=L.useField(),t=l.useRecord(),r=l.usePlugin(de);return L.useFormEffects(s=>{le.onFieldChange("type",a=>{let i=t.id||!a.value;if(a.value){const c=r.triggers.get(a.value);c.sync!=null?(i=!0,o.setValue(c.sync)):o.setInitialValue(!1)}o.setPattern(i?"disabled":"editable")})}),b.useEffect(()=>{if(t.id){o.setPattern("disabled");const s=r.triggers.get(t.type);s.sync!=null?o.setValue(s.sync):o.setInitialValue(!1)}},[t.id,o,r.triggers]),n.jsx(Te,C({},e))}function An(e){const o=l.useApp();e.visible=!!(l.usePlugin("multi-app-share-collection")||o.name!=="main")}function Fn(){const e=b.useContext(l.SchemaComponentContext),{getTriggersOptions:o}=l.usePlugin(de);return n.jsx(y.Card,{bordered:!1,children:n.jsx(l.SchemaComponentContext.Provider,{value:A(C({},e),{designable:!1}),children:n.jsx(l.SchemaComponent,{schema:kn,components:{WorkflowLink:xn,ExecutionResourceProvider:vn,ExecutionLink:Ko,OpenDrawer:wn,ExecutionStatusSelect:yn,SyncOptionSelect:Sn,ExecutionStatusColumn:Zo,Tooltip:y.Tooltip},scope:{getTriggersOptions:o,useWorkflowSyncAction:An,useRefreshActionProps:Qo}})})})}function On(r){var s=r,{collection:e,dataPath:o}=s,t=Z(s,["collection","dataPath"]);const{insert:a}=l.useSchemaInitializer(),{getTemplateSchemaByMode:i}=l.useSchemaTemplateManager(),{getCollection:c}=l.useCollectionManager_deprecated(),u=l.useRecordCollectionDataSourceItems("FormItem");let d;if(typeof e=="string"){const[h,x]=l.parseCollectionName(e);d=c(x,h)}else d=e;function f(x){return U(this,arguments,function*({item:h}){const g=h.template?yield i(h):null,m={type:"void",name:ho.uid(),title:d.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:e,dataPath:o},"x-component":"CardItem","x-component-props":{title:t.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-use-component-props":"useDetailsBlockProps","x-read-pretty":!0,properties:{grid:g||{type:"void","x-component":"Grid","x-initializer":"details:configureFields",properties:{}}}}}};Oo(m,k=>{k["x-uid"]&&delete k["x-uid"]}),a(m)})}return n.jsx(l.SchemaInitializerItem,A(C({},t),{onClick:f,items:u}))}function Be(e){var a;const o=l.useSchemaInitializerItem(),t=(a=e==null?void 0:e.collection)!=null?a:o.collection;let r,s;if(typeof t=="string"){const i=l.parseCollectionName(t);r=i[0],s=i[1]}else s=t;return n.jsx(l.CollectionProvider_deprecated,{dataSource:r,collection:s,children:n.jsx(On,C(C({},o),e))})}function Tn(){return!0}const To=L.observer(e=>{const d=e,{filter:o=Tn}=d,t=Z(d,["filter"]),r=l.useCompile(),{getCollectionFields:s}=l.useCollectionManager_deprecated(),{values:a}=L.useForm(),[i,c]=l.parseCollectionName(a==null?void 0:a.collection),u=s(c,i);return n.jsx(y.Select,A(C({popupMatchSelectWidth:!1},t),{options:u.filter(o).map(f=>{var h;return{label:r((h=f.uiSchema)==null?void 0:h.title),value:f.name}})}))},{displayName:"FieldsSelect"}),ae={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"},et={type:"object",title:'{{t("Fields values")}}',description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:l.css`
|
|
454
|
+
`,children:[e.children,s.status?null:n.jsx(y.Tooltip,{title:O("Cancel the execution"),children:n.jsx(y.Button,{type:"link",danger:!0,onClick:i,shape:"circle",size:"small",icon:n.jsx(I.StopOutlined,{})})})]})}function Zt(){const e=l.useResourceActionContext();return{onClick(){return U(this,null,function*(){var o;(o=e==null?void 0:e.refresh)==null||o.call(e)})}}}function gn(r){var s=r,{request:e,filter:t={}}=s,o=Q(s,["request","filter"]);var c;const{workflow:i}=Y(),a=A(C({},o),{request:A(C({},e),{params:A(C({},e==null?void 0:e.params),{filter:A(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:i.key})})})});return n.jsx(l.ResourceActionProvider,C({},a))}function bn(){var M;const e=oe.useNavigate(),{t}=G.useTranslation(),o=l.useApp(),{data:r,refresh:s,loading:i}=l.useResourceActionContext(),{resource:a}=l.useResourceContext(),{setTitle:c}=l.useDocumentTitle(),[u,d]=b.useState(!1),{styles:f}=ne(),{modal:h}=y.App.useApp();if(b.useEffect(()=>{var $;const{title:F}=($=r==null?void 0:r.data)!=null?$:{};c==null||c(`${O("Workflow")}${F?`: ${F}`:""}`)},[r==null?void 0:r.data]),!(r!=null&&r.data))return i?n.jsx(y.Spin,{}):n.jsx(y.Result,{status:"404",title:"Not found",extra:n.jsx(y.Button,{onClick:()=>e(-1),children:O("Go back")})});const N=(M=r==null?void 0:r.data)!=null?M:{},{nodes:x=[],revisions:g=[]}=N,m=Q(N,["nodes","revisions"]);At(x);const k=x.find(F=>!F.upstream);function T({key:F}){F!=m.id&&e(xe(F))}function B(F){return U(this,null,function*(){yield a.update({filterByTk:m.id,values:{enabled:F}}),s()})}function S(){return U(this,null,function*(){const{data:{data:F}}=yield a.revision({filterByTk:m.id,filter:{key:m.key}});y.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${F.id}`)})}function D(){return U(this,null,function*(){const F=m.current?O("Delete a main version will cause all other revisions to be deleted too."):"";h.confirm({title:t("Are you sure you want to delete it?"),content:F,onOk(){return U(this,null,function*(){var H;yield a.destroy({filterByTk:m.id}),y.message.success(t("Operation succeeded")),e(m.current?o.pluginSettingsManager.getRoutePath("workflow"):xe((H=g.find(K=>K.current))==null?void 0:H.id))})}})})}function W($){return U(this,arguments,function*({key:F}){switch(F){case"history":d(!0);return;case"revision":return S();case"delete":return D()}})}const E=m.executed&&!g.find(F=>!F.executed&&new Date(F.createdAt)>new Date(m.createdAt));return n.jsxs(Ie.Provider,{value:{workflow:m,nodes:x,refresh:s},children:[n.jsxs("div",{className:"workflow-toolbar",children:[n.jsx("header",{children:n.jsx(y.Breadcrumb,{items:[{title:n.jsx(oe.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:O("Workflow")})},{title:n.jsx(y.Tooltip,{title:`Key: ${m.key}`,children:n.jsx("strong",{children:m.title})})}]})}),n.jsxs("aside",{children:[m.sync?n.jsx(y.Tag,{color:"orange",children:O("Synchronously")}):n.jsx(y.Tag,{color:"cyan",children:O("Asynchronously")}),n.jsx(y.Dropdown,{className:"workflow-versions",trigger:["click"],menu:{onClick:T,defaultSelectedKeys:[`${m.id}`],className:l.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:g.sort((F,$)=>$.id-F.id).map((F,$)=>({role:"button","aria-label":`version-${$}`,key:`${F.id}`,icon:F.current?n.jsx(I.RightOutlined,{}):null,className:l.cx({executed:F.executed,unexecuted:!F.executed,enabled:F.enabled}),label:n.jsxs(n.Fragment,{children:[n.jsx("strong",{children:`#${F.id}`}),n.jsx("time",{children:J.str2moment(F.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:n.jsxs(y.Button,{type:"text","aria-label":"version",children:[n.jsx("label",{children:O("Version")}),n.jsx("span",{children:m!=null&&m.id?`#${m.id}`:null}),n.jsx(I.DownOutlined,{})]})}),n.jsx(y.Switch,{checked:m.enabled,onChange:B,checkedChildren:O("On"),unCheckedChildren:O("Off")}),n.jsx(y.Dropdown,{menu:{items:[{key:"key",label:`Key: ${m.key}`,disabled:!0},{type:"divider"},{role:"button","aria-label":"history",key:"history",label:O("Execution history"),disabled:!m.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:O("Copy to new version"),disabled:!E},{type:"divider"},{role:"button","aria-label":"delete",danger:!0,key:"delete",label:t("Delete")}],onClick:W},children:n.jsx(y.Button,{"aria-label":"more",type:"text",icon:n.jsx(I.EllipsisOutlined,{})})}),n.jsx(l.ActionContextProvider,{value:{visible:u,setVisible:d},children:n.jsx(l.SchemaComponent,{schema:Gt,components:{ExecutionResourceProvider:gn,ExecutionLink:qt,ExecutionStatusColumn:_t},scope:{useRefreshActionProps:Zt}})})]})]}),n.jsx(Ht,{entry:k})]})}const Qt=()=>{const e=oe.useParams(),{styles:t}=ne();return n.jsx("div",{className:l.cx(t.workflowPageClass),children:n.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:bn}})})},vn=r=>{var s=r,{request:e,filter:t={}}=s,o=Q(s,["request","filter"]);var c;const i=l.useRecord(),a=A(C({},o),{request:A(C({},e),{params:A(C({},e==null?void 0:e.params),{filter:A(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:i.key})})})});return n.jsx(l.ResourceActionProvider,C({},a))},xn=()=>{const{t:e}=G.useTranslation(),{id:t}=l.useRecord(),{setVisible:o}=l.useActionContext(),{getAriaLabel:r}=l.useGetAriaLabelOfAction("Configure");return n.jsx(oe.Link,{"aria-label":r(),to:xe(t),onClick:()=>o(!1),children:e("Configure")})};function wn(r){var s=r,{component:e="div",children:t}=s,o=Q(s,["component","children"]);const[i,a]=b.useState(!1),c=L.useFieldSchema();return n.jsxs(l.ActionContextProvider,{value:{visible:i,setVisible:a,fieldSchema:c},children:[b.createElement(e,A(C({},o),{onClick(){a(!0)}}),t),n.jsx(l.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}function Cn({data:e}){const{label:t,color:o,options:r}=e,s=l.useCompile();return n.jsxs(y.Space,{direction:"vertical",children:[n.jsx(y.Tag,{color:o,children:s(t)}),n.jsx(y.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:s(r.description)})]})}const Xt={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: "${p}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}",optionRender:Cn,popupMatchSelectWidth:!0,listHeight:300},required:!0}},{type:"boolean",name:"sync",interface:"select",uiSchema:{title:`{{t("Mode", { ns: "${p}" })}}`,type:"boolean","x-decorator":"FormItem","x-component":"Select",enum:[{label:`{{ t("Asynchronously", { ns: "${p}" }) }}`,value:!1,color:"cyan"},{label:`{{ t("Synchronously", { ns: "${p}" }) }}`,value:!0,color:"orange"}],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: "${p}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${p}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${p}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${p}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},fe={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${p}" }) }}`,description:`{{ t("Execute workflow asynchronously or synchronously based on trigger type, and could not be changed after created.", { ns: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Asynchronously", { ns: "${p}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${p}" }) }}`},{label:`{{ t("Synchronously", { ns: "${p}" }) }}`,value:!0,tooltip:`{{ t("For user actions that require immediate feedback. Can not use asynchronous nodes in such mode, and it is not recommended to perform time-consuming operations under synchronous mode.", { ns: "${p}" }) }}`}]}},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: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},kn={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Xt,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:Xt},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-use-component-props":"cm.useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},sync:{type:"void",title:`{{t("Sync", { ns: "${p}" })}}`,"x-decorator":"Tooltip","x-decorator-props":{title:`{{ t("Sync enabled status of all workflows from database", { ns: "${p}" }) }}`},"x-component":"Action","x-component-props":{icon:"SyncOutlined",useAction(){const{t:e}=G.useTranslation(),{resource:t}=l.useResourceContext(),o=l.useResourceActionContext();return{run(){return U(this,null,function*(){yield t.sync(),yield o==null?void 0:o.refresh(),y.message.success(e("Operation succeeded"))})}}}},"x-reactions":["{{useWorkflowSyncAction}}"]},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",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",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:fe.title,type:fe.type,sync:fe.sync,description:fe.description,options:fe.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}}},sync:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{sync:{type:"boolean","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=l.useRecord();return b.createElement("a",C({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:Gt}}}},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:fe.title,enabled:fe.enabled,sync:fe.sync,description:fe.description,options:fe.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: "${p}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${p}" })}}`,"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}=G.useTranslation(),{refresh:t}=l.useResourceActionContext(),{resource:o,targetKey:r}=l.useResourceContext(),{setVisible:s}=l.useActionContext(),{[r]:i}=l.useRecord(),{values:a}=L.useForm();return{run(){return U(this,null,function*(){yield o.revision({filterByTk:i,values:a}),y.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 Sn(e){const t=L.useField(),o=l.useRecord(),r=l.usePlugin(de);return L.useFormEffects(s=>{le.onFieldChange("type",i=>{let a=o.id||!i.value;if(i.value){const c=r.triggers.get(i.value);c.sync!=null?(a=!0,t.setValue(c.sync)):t.setInitialValue(!1)}t.setPattern(a?"disabled":"editable")})}),b.useEffect(()=>{if(o.id){t.setPattern("disabled");const s=r.triggers.get(o.type);s.sync!=null?t.setValue(s.sync):t.setInitialValue(!1)}},[o.id,t,r.triggers]),n.jsx(Oe,C({},e))}function An(e){const t=l.useApp();e.visible=!!(l.usePlugin("multi-app-share-collection")||t.name!=="main")}function Fn(){const e=b.useContext(l.SchemaComponentContext),{getTriggersOptions:t}=l.usePlugin(de);return n.jsx(y.Card,{bordered:!1,children:n.jsx(l.SchemaComponentContext.Provider,{value:A(C({},e),{designable:!1}),children:n.jsx(l.SchemaComponent,{schema:kn,components:{WorkflowLink:xn,ExecutionResourceProvider:vn,ExecutionLink:qt,OpenDrawer:wn,ExecutionStatusSelect:yn,SyncOptionSelect:Sn,ExecutionStatusColumn:_t,Tooltip:y.Tooltip},scope:{getTriggersOptions:t,useWorkflowSyncAction:An,useRefreshActionProps:Zt}})})})}function Tn(r){var s=r,{collection:e,dataPath:t}=s,o=Q(s,["collection","dataPath"]);const{insert:i}=l.useSchemaInitializer(),{getTemplateSchemaByMode:a}=l.useSchemaTemplateManager(),{getCollection:c}=l.useCollectionManager_deprecated(),u=l.useRecordCollectionDataSourceItems("FormItem");let d;if(typeof e=="string"){const[h,x]=l.parseCollectionName(e);d=c(x,h)}else d=e;function f(x){return U(this,arguments,function*({item:h}){const g=h.template?yield a(h):null,m={type:"void",name:ft.uid(),title:d.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:e,dataPath:t},"x-component":"CardItem","x-component-props":{title:o.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-use-component-props":"useDetailsBlockProps","x-read-pretty":!0,properties:{grid:g||{type:"void","x-component":"Grid","x-initializer":"details:configureFields",properties:{}}}}}};Ft(m,k=>{k["x-uid"]&&delete k["x-uid"]}),i(m)})}return n.jsx(l.SchemaInitializerItem,A(C({},o),{onClick:f,items:u}))}function Be(e){var i;const t=l.useSchemaInitializerItem(),o=(i=e==null?void 0:e.collection)!=null?i:t.collection;let r,s;if(typeof o=="string"){const a=l.parseCollectionName(o);r=a[0],s=a[1]}else s=o;return n.jsx(l.CollectionProvider_deprecated,{dataSource:r,collection:s,children:n.jsx(Tn,C(C({},t),e))})}function On(){return!0}const Tt=L.observer(e=>{const d=e,{filter:t=On}=d,o=Q(d,["filter"]),r=l.useCompile(),{getCollectionFields:s}=l.useCollectionManager_deprecated(),{values:i}=L.useForm(),[a,c]=l.parseCollectionName(i==null?void 0:i.collection),u=s(c,a);return n.jsx(y.Select,A(C({popupMatchSelectWidth:!1},o),{options:u.filter(t).map(f=>{var h;return{label:r((h=f.uiSchema)==null?void 0:h.title),value:f.name}})}))},{displayName:"FieldsSelect"}),ie={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"},Rt={type:"object",title:'{{t("Fields values")}}',description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:l.css`
|
|
455
455
|
flex-direction: column;
|
|
456
|
-
`},"x-component":"CollectionFieldset"},_e={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:e}=L.useForm(),[o
|
|
456
|
+
`},"x-component":"CollectionFieldset"},_e={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:e}=L.useForm(),[t,o]=l.parseCollectionName(e==null?void 0:e.collection);return{options:l.useCollectionFilterOptions(o,t),className:l.css`
|
|
457
457
|
position: relative;
|
|
458
458
|
width: 100%;
|
|
459
|
-
`}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},Nn={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"}}},En={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}}}}}}},Ve={type:"array",title:`{{t("Preload associations", { ns: "${p}" })}}`,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: "${p}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=L.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},Se={label:"label",value:"value",children:"children"},ot={label:`{{t("Node result", { ns: "${p}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:o}=l.usePlugin(de),t=ve(),r=Jo(t),s=[];return r.forEach(a=>{var u;const i=o.get(a.type),c=(u=i.useVariables)==null?void 0:u.call(i,a,e);c&&s.push(c)}),s}},tt={label:`{{t("Trigger variables", { ns: "${p}" })}}`,value:"$context",useOptions(e){var s,a;const{triggers:o}=l.usePlugin(de),{workflow:t}=G(),r=o.get(t.type);return(a=(s=r==null?void 0:r.useVariables)==null?void 0:s.call(r,t.config,e))!=null?a:null}},nt={label:`{{t("Scope variables", { ns: "${p}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:o=Se,current:t}=e,{instructions:r}=l.usePlugin(de),s=ve(),a=t!=null?t:s,i=Uo(a),c=[];return i.forEach(u=>{var h,x;const d=r.get(u.type),f=(h=d.useScopeVariables)==null?void 0:h.call(d,u,e);f&&c.push({key:u.key,[o.value]:u.key,[o.label]:(x=u.title)!=null?x:`#${u.id}`,[o.children]:f})}),c}},rt={label:`{{t("System variables", { ns: "${p}" })}}`,value:"$system",useOptions({types:e,fieldNames:o=Se}){return[...!e||e.includes("date")?[{key:"now",[o.label]:T("System time"),[o.value]:"now"}]:[]]}},Ze={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 st(e,o){var t,r,s,a,i,c;return typeof o=="string"?(t=Ze[o])==null?void 0:t.has(e.interface):typeof o=="object"&&o.type==="reference"?No(e)?((r=o.options)==null?void 0:r.entity)&&(e.collectionName===((s=o.options)==null?void 0:s.collection)||((a=o.options)==null?void 0:a.collection)==="*"):e.isForeignKey?e.collectionName===((i=o.options)==null?void 0:i.collection)&&e.name==="id"||e.target===((c=o.options)==null?void 0:c.collection):!1:typeof o=="function"?o(e):!1}function No(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function Eo(e,o){if(o==null)return null;const t=`${e.name}.`;return o.filter(r=>r.startsWith(t)).map(r=>r.replace(t,""))}function $o({fields:e,types:o,appends:t,depth:r=1,compile:s,getCollectionFields:a}){return e.filter(i=>{const c=o!=null&&o.length?o.some(u=>st(i,u)):!0;if(No(i)){if(t===null)return r?c||$o({fields:Do(i.target,{compile:s,getCollectionFields:a}),types:o,depth:r-1,appends:t,compile:s,getCollectionFields:a}):!1;const u=Eo(i,t),d=t.includes(i.name);return c?d:((u==null?void 0:u.length)||d)&&$o({fields:Do(i.target,{compile:s,getCollectionFields:a}),types:o,appends:u,compile:s,getCollectionFields:a}).length}else return c})}function Qe(e,o){var a,i;const t=l.useCompile(),r=(i=(a=e.useOptions)==null?void 0:a.call(e,o))==null?void 0:i.filter(Boolean),{fieldNames:s}=o;return{[s.label]:t(e.label),[s.value]:e.value,key:e[s.value],[s.children]:r,disabled:!r||!r.length}}function me(e={}){var s;const o=Object.assign({},Se,(s=e.fieldNames)!=null?s:{}),t=Object.assign(e,{fieldNames:o});return[Qe(nt,t),Qe(ot,t),Qe(tt,t),Qe(rt,t)]}function Do(e,{compile:o,getCollectionFields:t}){var d,f,h,x;const[r,s]=l.parseCollectionName(e),a=t(s,r),i=[],c=[];a.forEach(g=>{if(g.isForeignKey)i.push(g);else{const m=a.find(k=>k.name===g.foreignKey);m&&i.push(m),c.push(g)}});const u=ke.uniqBy(i,"name");for(let g=c.length-1;g>=0;g--){const m=c[g];if(m.type==="belongsTo"){const k=u.find(O=>O.name===m.foreignKey);k?c.splice(g,0,A(C(C({},m),k),{uiSchema:A(C({},m.uiSchema),{title:(d=k.uiSchema)!=null&&d.title?o((f=k.uiSchema)==null?void 0:f.title):k.name})})):c.splice(g,0,A(C({},m),{name:m.foreignKey,type:"bigInt",isForeignKey:!0,interface:m.interface,uiSchema:A(C({},m.uiSchema),{title:(h=m.uiSchema)!=null&&h.title?`${o((x=m.uiSchema)==null?void 0:x.title)} ID`:m.name})}))}else m.type==="context"&&m.collectionName==="users"&&c.splice(g,1)}return ke.uniqBy(c,"name").filter(g=>g.interface&&!g.hidden)}function $n(e){const o=Eo(e.field,e.appends),t=Ae(C({collection:`${e.field.dataSourceKey&&e.field.dataSourceKey!=="main"?`${e.field.dataSourceKey}:`:""}${e.field.target}`,types:e.types,appends:o,depth:e.depth-1},this));e.loadChildren=null,t.length?e.children=t:(e.isLeaf=!0,!e.types||e.types.some(s=>st(e.field,s))||(e.disabled=!0))}function Ae(e){const{fields:o,collection:t,types:r,appends:s=[],depth:a=1,compile:i,getCollectionFields:c,fieldNames:u=Se}=e,d=o!=null?o:Do(t,{compile:i,getCollectionFields:c}),f=$n.bind({compile:i,getCollectionFields:c,fieldNames:u});return $o({fields:d,types:r,depth:a,appends:s,compile:i,getCollectionFields:c}).map(x=>{var O;const g=i(((O=x.uiSchema)==null?void 0:O.title)||x.name),m=Eo(x,s),k=!No(x)||m&&!m.length&&!s.includes(x.name)||!1;return{[u.label]:g,key:x.name,[u.value]:x.name,isLeaf:k,loadChildren:k?null:f,field:x,depth:a,appends:s,types:r}})}function je(e){const o=l.useApp(),{collectionManager:t}=o.dataSourceManager.getDataSource(e);return b.useCallback(r=>t.getCollectionFields(r),[t])}function lt(t){var r=t,{variableOptions:e}=r,o=Z(r,["variableOptions"]);const s=me(e);return n.jsx(l.Variable.Input,C({scope:s},o))}function Io(t){var r=t,{variableOptions:e}=r,o=Z(r,["variableOptions"]);const s=me(e);return n.jsx(l.Variable.TextArea,C({scope:s},o))}function Dn(t){var r=t,{variableOptions:e}=r,o=Z(r,["variableOptions"]);const s=me(e);return n.jsx(l.Variable.RawTextArea,C({scope:s},o))}function In(t){var r=t,{variableOptions:e}=r,o=Z(r,["variableOptions"]);const s=me(e);return n.jsx(l.Variable.JSON,C({scope:s},o))}function Pn(){const e=l.useAPIClient(),o=L.useForm(),{field:t,__parent:r}=l.useBlockRequestContext(),{setVisible:s}=l.useActionContext(),a=te.useNavigate(),i=L.useFieldSchema(),c=L.useField(),u=l.useCompile(),{modal:d}=y.App.useApp(),f=l.useCollectValuesToSubmit(),h=c.componentProps.filterKeys||[];return{onClick(){return U(this,null,function*(){var B,S,E;const{onSuccess:g,skipValidator:m,triggerWorkflows:k}=(B=i==null?void 0:i["x-action-settings"])!=null?B:{};m||(yield o.submit());const O=yield f();c.data=t.data||{},c.data.loading=!0;try{const W=yield e.resource("workflows").trigger({values:O,filterKeys:h,triggerWorkflows:k!=null&&k.length?k.map($=>[$.workflowKey,$.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.loading=!1,c.data.data=W,(E=(S=r==null?void 0:r.service)==null?void 0:S.refresh)==null||E.call(S),s==null||s(!1),!(g!=null&&g.successMessage))return;g!=null&&g.manualClose?d.success({title:u(g==null?void 0:g.successMessage),onOk:()=>U(this,null,function*(){yield o.reset(),g!=null&&g.redirecting&&(g!=null&&g.redirectTo)&&(J.isURL(g.redirectTo)?window.location.href=g.redirectTo:a(g.redirectTo))})}):y.message.success(u(g==null?void 0:g.successMessage))}catch(W){c.data.loading=!1}})}}}function Mn(){var g;const e=l.useCompile(),o=l.useAPIClient(),t=l.useRecord(),r=L.useField(),s=L.useFieldSchema(),{field:a,__parent:i}=l.useBlockRequestContext(),{setVisible:c,setSubmitted:u}=l.useActionContext(),{modal:d}=y.App.useApp(),f=te.useNavigate(),{onSuccess:h,triggerWorkflows:x}=(g=s==null?void 0:s["x-action-settings"])!=null?g:{};return{onClick(k,O){return U(this,null,function*(){r.data=a.data||{},r.data.loading=!0;try{if(yield o.resource("workflows").trigger({values:t,triggerWorkflows:x!=null&&x.length?x.map(B=>[B.workflowKey,B.context].filter(Boolean).join("!")).join(","):void 0}),O&&O(),c==null||c(!1),u==null||u(!0),!(h!=null&&h.successMessage))return;if(h!=null&&h.manualClose){let B;d.success({title:e(h==null?void 0:h.successMessage),onOk(){return U(this,null,function*(){h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(J.isURL(h.redirectTo)?window.location.href=h.redirectTo:f(h.redirectTo))})}})}else y.message.success(e(h==null?void 0:h.successMessage))}catch(B){console.error(B)}finally{r.data.loading=!1}})}}}function Bn(){const{workflow:e}=G();return!!(e!=null&&e.executed)}function it(){const{workflow:e}=G();return!!(e!=null&&e.allExecuted)}const Fe={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},Vn=[{label:`{{t("After record added", { ns: "${p}" })}}`,value:Fe.CREATED},{label:`{{t("After record updated", { ns: "${p}" })}}`,value:Fe.UPDATED},{label:`{{t("After record added or updated", { ns: "${p}" })}}`,value:Fe.SAVED},{label:`{{t("After record deleted", { ns: "${p}" })}}`,value:Fe.DELETED}];function jn(e,o){var u;const[t,r]=l.parseCollectionName(e.collection),s=l.useCompile(),a=je(t),i=[{collectionName:r,name:"data",type:"hasOne",target:r,uiSchema:{title:T("Trigger data")}}];return Ae(A(C({appends:["data",...((u=e.appends)==null?void 0:u.map(d=>`data.${d}`))||[]]},o),{fields:i,compile:s,getCollectionFields:a}))}class Wn extends So{constructor(){super(...arguments);w(this,"title",`{{t("Collection event", { ns: "${p}" })}}`);w(this,"description",`{{t('Triggered when data changes in the collection, such as after adding, updating, or deleting a record. Unlike "Post-action event", Collection event listens for data changes rather than HTTP requests. Unless you understand the exact meaning, it is recommended to use "Post-action event".', { ns: "${p}" })}}`);w(this,"fieldset",{collection:A(C({},ae),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(t){return t.options.key==="main"||t.options.isDBInstance}},"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: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${p}" })}}`,className:"auto-width"},enum:Vn,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${p}" })}}`,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: "${p}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(t){return!t.hidden&&(t.uiSchema?!t.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(t.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Fe.UPDATED})}}`}}}]},condition:A(C({},_e),{title:`{{t("Only triggers when match conditions", { ns: "${p}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:A(C({},Ve),{"x-reactions":[...Ve["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Fe.DELETED})}}`}}}]})});w(this,"scope",{useCollectionDataSource:l.useCollectionDataSource,useWorkflowAnyExecuted:it});w(this,"components",{FieldsSelect:To});w(this,"useVariables",jn)}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Be,collection:t.collection,dataPath:"$context.data"}:null}}const we={STATIC:0,DATE_FIELD:1};function Ln(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function at({value:e,onChange:o}){const t=e!=null?e:{},{t:r}=Q.useTranslation(),[s,a]=b.useState(t.offset?t.offset/Math.abs(t.offset):0);return n.jsxs("fieldset",{className:l.css`
|
|
459
|
+
`}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},Nn={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"}}},Dn={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}}}}}}},Ve={type:"array",title:`{{t("Preload associations", { ns: "${p}" })}}`,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: "${p}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=L.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},Se={label:"label",value:"value",children:"children"},En=e=>[{key:"yesterday",value:"yesterday",label:e("Yesterday")},{key:"today",value:"today",label:e("Today")},{key:"tomorrow",value:"tomorrow",label:e("Tomorrow")},{key:"lastWeek",value:"lastWeek",label:e("Last week")},{key:"thisWeek",value:"thisWeek",label:e("This week")},{key:"nextWeek",value:"nextWeek",label:e("Next week")},{key:"lastMonth",value:"lastMonth",label:e("Last month")},{key:"thisMonth",value:"thisMonth",label:e("This month")},{key:"nextMonth",value:"nextMonth",label:e("Next month")},{key:"lastQuarter",value:"lastQuarter",label:e("Last quarter")},{key:"thisQuarter",value:"thisQuarter",label:e("This quarter")},{key:"nextQuarter",value:"nextQuarter",label:e("Next quarter")},{key:"lastYear",value:"lastYear",label:e("Last year")},{key:"thisYear",value:"thisYear",label:e("This year")},{key:"nextYear",value:"nextYear",label:e("Next year")},{key:"last7Days",value:"last7Days",label:e("Last 7 days")},{key:"next7Days",value:"next7Days",label:e("Next 7 days")},{key:"last30Days",value:"last30Days",label:e("Last 30 days")},{key:"next30Days",value:"next30Days",label:e("Next 30 days")},{key:"last90Days",value:"last90Days",label:e("Last 90 days")},{key:"next90Days",value:"next90Days",label:e("Next 90 days")}],eo={label:`{{t("Node result", { ns: "${p}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=l.usePlugin(de),o=ve(),r=zt(o),s=[];return r.forEach(i=>{var u;const a=t.get(i.type),c=(u=a.useVariables)==null?void 0:u.call(a,i,e);c&&s.push(c)}),s}},to={label:`{{t("Trigger variables", { ns: "${p}" })}}`,value:"$context",useOptions(e){var s,i;const{triggers:t}=l.usePlugin(de),{workflow:o}=Y(),r=t.get(o.type);return(i=(s=r==null?void 0:r.useVariables)==null?void 0:s.call(r,o.config,e))!=null?i:null}},oo={label:`{{t("Scope variables", { ns: "${p}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=Se,current:o}=e,{instructions:r}=l.usePlugin(de),s=ve(),i=o!=null?o:s,a=Jt(i),c=[];return a.forEach(u=>{var h,x;const d=r.get(u.type),f=(h=d.useScopeVariables)==null?void 0:h.call(d,u,e);f&&c.push({key:u.key,[t.value]:u.key,[t.label]:(x=u.title)!=null?x:`#${u.id}`,[t.children]:f})}),c}},no={label:`{{t("System variables", { ns: "${p}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=Se}){const{t:o}=G.useTranslation();return[...!e||e.includes("date")?[{key:"now",[t.label]:O("System time"),[t.value]:"now"},{key:"dateRange",[t.label]:O("Date range"),[t.value]:"dateRange",children:En(o)}]:[]]}},Ze={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 ro(e,t){var o,r,s,i,a,c;return typeof t=="string"?(o=Ze[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?Ot(e)?((r=t.options)==null?void 0:r.entity)&&(e.collectionName===((s=t.options)==null?void 0:s.collection)||((i=t.options)==null?void 0:i.collection)==="*"):e.isForeignKey?e.collectionName===((a=t.options)==null?void 0:a.collection)&&e.name==="id"||e.target===((c=t.options)==null?void 0:c.collection):!1:typeof t=="function"?t(e):!1}function Ot(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function Nt(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(r=>r.startsWith(o)).map(r=>r.replace(o,""))}function Dt({fields:e,types:t,appends:o,depth:r=1,compile:s,getCollectionFields:i}){return e.filter(a=>{const c=t!=null&&t.length?t.some(u=>ro(a,u)):!0;if(Ot(a)){if(o===null)return r?c||Dt({fields:Et(a.target,{compile:s,getCollectionFields:i}),types:t,depth:r-1,appends:o,compile:s,getCollectionFields:i}):!1;const u=Nt(a,o),d=o.includes(a.name);return c?d:((u==null?void 0:u.length)||d)&&Dt({fields:Et(a.target,{compile:s,getCollectionFields:i}),types:t,appends:u,compile:s,getCollectionFields:i}).length}else return c})}function Qe(e,t){var i,a;const o=l.useCompile(),r=(a=(i=e.useOptions)==null?void 0:i.call(e,t))==null?void 0:a.filter(Boolean),{fieldNames:s}=t;return{[s.label]:o(e.label),[s.value]:e.value,key:e[s.value],[s.children]:r,disabled:!r||!r.length}}function me(e={}){var s;const t=Object.assign({},Se,(s=e.fieldNames)!=null?s:{}),o=Object.assign(e,{fieldNames:t});return[Qe(oo,o),Qe(eo,o),Qe(to,o),Qe(no,o)]}function Et(e,{compile:t,getCollectionFields:o}){var d,f,h,x;const[r,s]=l.parseCollectionName(e),i=o(s,r),a=[],c=[];i.forEach(g=>{if(g.isForeignKey)a.push(g);else{const m=i.find(k=>k.name===g.foreignKey);m&&a.push(m),c.push(g)}});const u=ke.uniqBy(a,"name");for(let g=c.length-1;g>=0;g--){const m=c[g];if(m.type==="belongsTo"){const k=u.find(T=>T.name===m.foreignKey);k?c.splice(g,0,A(C(C({},m),k),{uiSchema:A(C({},m.uiSchema),{title:(d=k.uiSchema)!=null&&d.title?t((f=k.uiSchema)==null?void 0:f.title):k.name})})):c.splice(g,0,A(C({},m),{name:m.foreignKey,type:"bigInt",isForeignKey:!0,interface:m.interface,uiSchema:A(C({},m.uiSchema),{title:(h=m.uiSchema)!=null&&h.title?`${t((x=m.uiSchema)==null?void 0:x.title)} ID`:m.name})}))}else m.type==="context"&&m.collectionName==="users"&&c.splice(g,1)}return ke.uniqBy(c,"name").filter(g=>g.interface&&!g.hidden)}function $n(e){const t=Nt(e.field,e.appends),o=Ae(C({collection:`${e.field.dataSourceKey&&e.field.dataSourceKey!=="main"?`${e.field.dataSourceKey}:`:""}${e.field.target}`,types:e.types,appends:t,depth:e.depth-1},this));e.loadChildren=null,o.length?e.children=o:(e.isLeaf=!0,!e.types||e.types.some(s=>ro(e.field,s))||(e.disabled=!0))}function Ae(e){const{fields:t,collection:o,types:r,appends:s=[],depth:i=1,compile:a,getCollectionFields:c,fieldNames:u=Se}=e,d=t!=null?t:Et(o,{compile:a,getCollectionFields:c}),f=$n.bind({compile:a,getCollectionFields:c,fieldNames:u});return Dt({fields:d,types:r,depth:i,appends:s,compile:a,getCollectionFields:c}).map(x=>{var T;const g=a(((T=x.uiSchema)==null?void 0:T.title)||x.name),m=Nt(x,s),k=!Ot(x)||m&&!m.length&&!s.includes(x.name)||!1;return{[u.label]:g,key:x.name,[u.value]:x.name,isLeaf:k,loadChildren:k?null:f,field:x,depth:i,appends:s,types:r}})}function je(e){const t=l.useApp(),{collectionManager:o}=t.dataSourceManager.getDataSource(e);return b.useCallback(r=>o.getCollectionFields(r),[o])}function so(o){var r=o,{variableOptions:e}=r,t=Q(r,["variableOptions"]);const s=me(e);return n.jsx(l.Variable.Input,C({scope:s},t))}function $t(o){var r=o,{variableOptions:e}=r,t=Q(r,["variableOptions"]);const s=me(e);return n.jsx(l.Variable.TextArea,C({scope:s},t))}function In(o){var r=o,{variableOptions:e}=r,t=Q(r,["variableOptions"]);const s=me(e);return n.jsx(l.Variable.RawTextArea,C({scope:s},t))}function Pn(o){var r=o,{variableOptions:e}=r,t=Q(r,["variableOptions"]);const s=me(e);return n.jsx(l.Variable.JSON,C({scope:s},t))}function Mn(){const e=l.useAPIClient(),t=L.useForm(),{field:o,__parent:r}=l.useBlockRequestContext(),{setVisible:s}=l.useActionContext(),i=oe.useNavigate(),a=L.useFieldSchema(),c=L.useField(),u=l.useCompile(),{modal:d}=y.App.useApp(),f=l.useCollectValuesToSubmit(),h=c.componentProps.filterKeys||[];return{onClick(){return U(this,null,function*(){var B,S,D;const{onSuccess:g,skipValidator:m,triggerWorkflows:k}=(B=a==null?void 0:a["x-action-settings"])!=null?B:{};m||(yield t.submit());const T=yield f();c.data=o.data||{},c.data.loading=!0;try{const W=yield e.resource("workflows").trigger({values:T,filterKeys:h,triggerWorkflows:k!=null&&k.length?k.map(E=>[E.workflowKey,E.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.loading=!1,c.data.data=W,(D=(S=r==null?void 0:r.service)==null?void 0:S.refresh)==null||D.call(S),s==null||s(!1),!(g!=null&&g.successMessage))return;g!=null&&g.manualClose?d.success({title:u(g==null?void 0:g.successMessage),onOk:()=>U(this,null,function*(){yield t.reset(),g!=null&&g.redirecting&&(g!=null&&g.redirectTo)&&(J.isURL(g.redirectTo)?window.location.href=g.redirectTo:i(g.redirectTo))})}):y.message.success(u(g==null?void 0:g.successMessage))}catch(W){c.data.loading=!1}})}}}function Bn(){var g;const e=l.useCompile(),t=l.useAPIClient(),o=l.useRecord(),r=L.useField(),s=L.useFieldSchema(),{field:i,__parent:a}=l.useBlockRequestContext(),{setVisible:c,setSubmitted:u}=l.useActionContext(),{modal:d}=y.App.useApp(),f=oe.useNavigate(),{onSuccess:h,triggerWorkflows:x}=(g=s==null?void 0:s["x-action-settings"])!=null?g:{};return{onClick(k,T){return U(this,null,function*(){r.data=i.data||{},r.data.loading=!0;try{if(yield t.resource("workflows").trigger({values:o,triggerWorkflows:x!=null&&x.length?x.map(B=>[B.workflowKey,B.context].filter(Boolean).join("!")).join(","):void 0}),T&&T(),c==null||c(!1),u==null||u(!0),!(h!=null&&h.successMessage))return;if(h!=null&&h.manualClose){let B;d.success({title:e(h==null?void 0:h.successMessage),onOk(){return U(this,null,function*(){h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(J.isURL(h.redirectTo)?window.location.href=h.redirectTo:f(h.redirectTo))})}})}else y.message.success(e(h==null?void 0:h.successMessage))}catch(B){console.error(B)}finally{r.data.loading=!1}})}}}function Vn(){const{workflow:e}=Y();return!!(e!=null&&e.executed)}function lo(){const{workflow:e}=Y();return!!(e!=null&&e.allExecuted)}const Fe={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},jn=[{label:`{{t("After record added", { ns: "${p}" })}}`,value:Fe.CREATED},{label:`{{t("After record updated", { ns: "${p}" })}}`,value:Fe.UPDATED},{label:`{{t("After record added or updated", { ns: "${p}" })}}`,value:Fe.SAVED},{label:`{{t("After record deleted", { ns: "${p}" })}}`,value:Fe.DELETED}];function Wn(e,t){var u;const[o,r]=l.parseCollectionName(e.collection),s=l.useCompile(),i=je(o),a=[{collectionName:r,name:"data",type:"hasOne",target:r,uiSchema:{title:O("Trigger data")}}];return Ae(A(C({appends:["data",...((u=e.appends)==null?void 0:u.map(d=>`data.${d}`))||[]]},t),{fields:a,compile:s,getCollectionFields:i}))}class Ln extends kt{constructor(){super(...arguments);w(this,"title",`{{t("Collection event", { ns: "${p}" })}}`);w(this,"description",`{{t('Triggered when data changes in the collection, such as after adding, updating, or deleting a record. Unlike "Post-action event", Collection event listens for data changes rather than HTTP requests. Unless you understand the exact meaning, it is recommended to use "Post-action event".', { ns: "${p}" })}}`);w(this,"fieldset",{collection:A(C({},ie),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(o){return o.options.key==="main"||o.options.isDBInstance}},"x-reactions":[...ie["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: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${p}" })}}`,className:"auto-width"},enum:jn,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${p}" })}}`,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: "${p}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(o){return!o.hidden&&(o.uiSchema?!o.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(o.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Fe.UPDATED})}}`}}}]},condition:A(C({},_e),{title:`{{t("Only triggers when match conditions", { ns: "${p}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:A(C({},Ve),{"x-reactions":[...Ve["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Fe.DELETED})}}`}}}]})});w(this,"scope",{useCollectionDataSource:l.useCollectionDataSource,useWorkflowAnyExecuted:lo});w(this,"components",{FieldsSelect:Tt});w(this,"useVariables",Wn)}useInitializers(o){return o.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Be,collection:o.collection,dataPath:"$context.data"}:null}}const we={STATIC:0,DATE_FIELD:1};function zn(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function ao({value:e,onChange:t}){const o=e!=null?e:{},{t:r}=G.useTranslation(),[s,i]=b.useState(o.offset?o.offset/Math.abs(o.offset):0);return n.jsxs("fieldset",{className:l.css`
|
|
460
460
|
display: flex;
|
|
461
461
|
gap: 0.5em;
|
|
462
|
-
`,children:[n.jsx(
|
|
462
|
+
`,children:[n.jsx(Tt,{value:o.field,onChange:a=>t(A(C({},o),{field:a})),filter:zn,placeholder:r("Select field"),className:"auto-width"}),o.field?n.jsx(y.Select,{value:s,onChange:a=>{i(a),t(A(C({},o),{offset:Math.abs(o.offset)*a}))},options:[{value:0,label:O("Exactly at")},{value:-1,label:r("Before")},{value:1,label:r("After")}],className:"auto-width"}):null,s?n.jsxs(n.Fragment,{children:[n.jsx(y.InputNumber,{value:Math.abs(o.offset),onChange:a=>t(A(C({},o),{offset:(a!=null?a:0)*s}))}),n.jsx(y.Select,{value:o.unit||864e5,onChange:a=>t(A(C({},o),{unit:a})),options:[{value:864e5,label:O("Days")},{value:36e5,label:O("Hours")},{value:6e4,label:O("Minutes")},{value:1e3,label:O("Seconds")}],className:"auto-width"})]}):null]})}function Jn({value:e,onChange:t}){const{t:o}=yt(),r=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return n.jsxs("fieldset",{className:l.css`
|
|
463
463
|
display: flex;
|
|
464
464
|
gap: 0.5em;
|
|
465
|
-
`,children:[n.jsxs(y.Select,{value:r,onChange:s=>{o(s?s==="field"?{}:new Date:null)},className:"auto-width",children:[n.jsx(y.Select.Option,{value:null,children:t("No end")}),n.jsx(y.Select.Option,{value:"field",children:t("By field")}),n.jsx(y.Select.Option,{value:"date",children:t("By custom date")})]}),r==="field"?n.jsx(at,{value:e,onChange:o}):null,r==="date"?n.jsx(y.DatePicker,{showTime:!0,value:Yt(e),onChange:s=>{o(s?s.toDate():null)}}):null]})}var re=function(){return re=Object.assign||function(e){for(var o,t=1,r=arguments.length;t<r;t++)for(var s in o=arguments[t])Object.prototype.hasOwnProperty.call(o,s)&&(e[s]=o[s]);return e},re.apply(this,arguments)};function ct(e,o){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&o.indexOf(r)<0&&(t[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)o.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(t[r[s]]=e[r[s]])}return t}function Xe(e,o,t){if(t||arguments.length===2)for(var r,s=0,a=o.length;s<a;s++)!r&&s in o||(r||(r=Array.prototype.slice.call(o,0,s)),r[s]=o[s]);return e.concat(r||Array.prototype.slice.call(o))}var Jn=[{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 * * * *"}],Ce=[{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 dt(e,o){for(var t=[],r=e;r<=o;r++)t.push(r);return t}function Re(e){return e.sort(function(o,t){return o-t}),e}function ut(e){var o=[];return e.forEach(function(t){o.indexOf(t)<0&&o.push(t)}),o}function ce(e){return Object.entries(e).filter(function(o){var t=o[0],r=o[1];return t&&r}).map(function(o){return o[0]}).join(" ")}function pt(e,o){e&&e({type:"invalid_cron",description:o.errorInvalidCron||V.errorInvalidCron})}function eo(e){var o=parseInt(e,10),t=Number(e);return o===t?t:NaN}function mt(e,o,t,r,s,a,i,c,u,d,f,h,x,g){t&&t(void 0),o(!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 g("reboot");var k=Jn.find(function(S){return S.name===e});k&&(e=k.value)}try{var O=function(S){if(typeof S!="string")throw new Error("Invalid cron string");var E=S.replace(/\s+/g," ").trim().split(" ");if(E.length===5)return E.map(function(W,$){return function(M,N){if(M==="*"||M==="*/1")return[];var F=Re(ut(gt(function(H,K,ue){if(ue){H=H.toUpperCase();for(var P=0;P<ue.length;P++)H=H.replace(ue[P],"".concat(P+K))}return H}(M,N.min,N.alt).split(",").map(function(H){var K,ue=H.split("/");if(ue.length>2)throw new Error('Invalid value "'.concat(M,' for "').concat(N.type,'"'));var P=ue[0],j=ue[1];K=P==="*"?dt(N.min,N.max):function(q,Y,R){var ee=q.split("-");if(ee.length===1){var Le=eo(ee[0]);if(isNaN(Le))throw new Error('Invalid value "'.concat(Y,'" for ').concat(R.type));return[Le]}if(ee.length===2){var he=eo(ee[0]),Ee=eo(ee[1]);if(isNaN(he)||isNaN(Ee))throw new Error('Invalid value "'.concat(Y,'" for ').concat(R.type));if(Ee<he)throw new Error('Max range is less than min range in "'.concat(q,'" for ').concat(R.type));return dt(he,Ee)}throw new Error('Invalid value "'.concat(q,'" for ').concat(R.type))}(P,M,N);var z=function(q,Y){if(q!==void 0){var R=eo(q);if(isNaN(R)||R<1)throw new Error('Invalid interval step value "'.concat(q,'" for ').concat(Y.type));return R}}(j,N),se=function(q,Y){if(Y){var R=q[0];q=q.filter(function(ee){return ee%Y==R%Y||ee===R})}return q}(K,z);return se}).flat(),N))),D=bt(F,N);if(D!==void 0)throw new Error('Value "'.concat(D,'" out of range for ').concat(N.type));return F.length===N.total?[]:F}(W,Ce[$])});throw new Error("Invalid cron string format")}(e),B=function(S){return S[3].length>0?"year":S[2].length>0?"month":S[4].length>0?"week":S[1].length>0?"day":S[0].length>0?"hour":"minute"}(O);g(B),u(O[0]),d(O[1]),f(O[2]),h(O[3]),x(O[4])}catch(S){m=!0}}m&&(s.current=e,o(!0),pt(t,i))}function ft(e,o,t,r,s,a,i){if(e==="reboot")return"@reboot";var c=function(u,d){return u.map(function(f,h){var x=Ce[h];return ht(yt(f,x),x,d)})}([e!=="minute"&&a?a:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!t?[]:t,e==="year"&&o?o:[],e!=="year"&&e!=="month"&&e!=="week"||!r?[]:r],i);return c.join(" ")}function ht(e,o,t,r,s){var a="";if(function(c,u){return c.length===u.max-u.min+1}(e,o)||e.length===0)a="*";else{var i=function(c){if(c.length>2){var u=c[1]-c[0];if(u>1)return u}}(e);a=i&&function(c,u){for(var d=1;d<c.length;d++){var f=c[d-1];if(c[d]-f!==u)return!1}return!0}(e,i)?function(c,u,d){var f=vt(c),h=xt(c),x=c.length===(h-f)/d+1;return!!(f===u.min&&h+d>u.max&&x)}(e,o,i)?"*/".concat(i):"".concat(Oe(vt(e),o,t,r,s),"-").concat(Oe(xt(e),o,t,r,s),"/").concat(i):function(c){var u=[],d=null;return c.forEach(function(f,h,x){f!==x[h+1]-1?d!==null?(u.push([d,f]),d=null):u.push(f):d===null&&(d=f)}),u}(e).map(function(c){return Array.isArray(c)?"".concat(Oe(c[0],o,t,r,s),"-").concat(Oe(c[1],o,t,r,s)):Oe(c,o,t,r,s)}).join(",")}return a}function Oe(e,o,t,r,s){var a=e.toString(),i=o.type,c=o.alt,u=o.min,d=r&&(r===!0||r.includes(i)),f=s==="24-hour-clock"&&(i==="hours"||i==="minutes");if(t&&i==="week-days"||t&&i==="months"?a=c[e-u]:e<10&&(d||f)&&(a=a.padStart(2,"0")),i==="hours"&&s==="12-hour-clock"){var h=e>=12?"PM":"AM",x=e%12||12;x<10&&d&&(x=x.toString().padStart(2,"0")),a="".concat(x).concat(h)}return a}function yt(e,o){var t=Re(ut(gt(e,o)));if(t.length===0)return t;var r=bt(t,o);if(r!==void 0)throw new Error('Value "'.concat(r,'" out of range for ').concat(o.type));return t}function gt(e,o){return o.type==="week-days"&&(e=e.map(function(t){return t===7?0:t})),e}function bt(e,o){var t=e[0],r=e[e.length-1];return t<o.min?t:r>o.max?r:void 0}function vt(e){return e[0]}function xt(e){return e[e.length-1]}function We(e){var o=e.value,t=e.grid,r=t===void 0||t,s=e.optionsList,a=e.setValue,i=e.locale,c=e.className,u=e.humanizeLabels,d=e.disabled,f=e.readOnly,h=e.leadingZero,x=e.clockFormat,g=e.period,m=e.unit,k=e.periodicityOnDoubleClick,O=e.mode,B=ct(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),S=b.useMemo(function(){if(o&&Array.isArray(o))return o.map(function(P){return P.toString()})},[o]),E=b.useMemo(function(){return s?s.map(function(P,j){return{value:(m.min===0?j:j+1).toString(),label:P}}):Xe([],Array(m.total),!0).map(function(P,j){var z=m.min===0?j:j+1;return{value:z.toString(),label:Oe(z,m,u,h,x)}})},[s,h,u,x]),W=JSON.stringify(i),$=b.useCallback(function(P){var j=P.value;if(!o||o[0]!==Number(j))return n.jsx(n.Fragment,{});var z=ht(yt(o,m),m,u,h,x),se=z.match(/^\*\/([0-9]+),?/)||[];return n.jsx("div",{children:se[1]?"".concat(i.everyText||V.everyText," ").concat(se[1]):z})},[o,W,u,h,x]),M=b.useCallback(function(P){var j=Array.isArray(P)?Re(P):[P],z=j;o&&(z=O==="single"?[]:Xe([],o,!0),j.forEach(function(se){var q=Number(se);z=o.some(function(Y){return Y===q})?z.filter(function(Y){return Y!==q}):Re(Xe(Xe([],z,!0),[q],!1))})),z.length===m.total?a([]):a(z)},[a,o]),N=b.useCallback(function(P){if(P!==0&&P!==1){for(var j=m.total+m.min,z=[],se=m.min;se<j;se++)se%P==0&&z.push(se);var q=o&&z&&o.length===z.length&&o.every(function(R,ee){return R===z[ee]}),Y=z.length===E.length;a(Y||q?[]:z)}else a([])},[o,E,a]),F=b.useRef([]),D=b.useCallback(function(P){if(!f){var j=F.current;j.push({time:new Date().getTime(),value:Number(P)});var z=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?N(Number(P)):M([j[j.length-2].value,j[j.length-1].value]):M(Number(P)),F.current=[]},300);return function(){window.clearTimeout(z)}}},[F,M,N,f,k]),H=b.useCallback(function(){f||a([])},[a,f]),K=b.useMemo(function(){var P;return ce(((P={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,P))},[c]),ue=b.useMemo(function(){var P;return ce(((P={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(m.type)]=!0,P["react-js-cron-custom-select-dropdown"]=!0,P["react-js-cron-custom-select-dropdown-".concat(m.type)]=!0,P["react-js-cron-custom-select-dropdown-minutes-large"]=m.type==="minutes"&&g!=="hour"&&g!=="day",P["react-js-cron-custom-select-dropdown-minutes-medium"]=m.type==="minutes"&&(g==="day"||g==="hour"),P["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=m.type==="hours"&&x==="12-hour-clock",P["react-js-cron-custom-select-dropdown-grid"]=!!r,P["".concat(c,"-select-dropdown")]=!!c,P["".concat(c,"-select-dropdown-").concat(m.type)]=!!c,P))},[c,r,x,g]);return n.jsx(y.Select,re({mode:O!=="single"||k?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:S,onClear:H,tagRender:$,className:K,popupClassName:ue,options:E,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:D,onDeselect:D,disabled:d,dropdownAlign:m.type!=="minutes"&&m.type!=="hours"||g==="day"||g==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(m.type)},B))}function Un(e){var o=e.value,t=e.setValue,r=e.locale,s=e.className,a=e.disabled,i=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=b.useMemo(function(){var g;return ce(((g={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,g["".concat(s,"-hours")]=!!s,g))},[s]);return n.jsxs("div",re({className:x},{children:[r.prefixHours!==""&&n.jsx("span",{children:r.prefixHours||V.prefixHours}),n.jsx(We,{placeholder:r.emptyHours||V.emptyHours,value:o,unit:Ce[1],setValue:t,locale:r,className:s,disabled:a,readOnly:i,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:h})]}))}function Hn(e){var o=e.value,t=e.setValue,r=e.locale,s=e.className,a=e.disabled,i=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=b.useMemo(function(){var g;return ce(((g={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,g["".concat(s,"-minutes")]=!!s,g))},[s]);return n.jsxs("div",re({className:x},{children:[d==="hour"?r.prefixMinutesForHourPeriod!==""&&n.jsx("span",{children:r.prefixMinutesForHourPeriod||V.prefixMinutesForHourPeriod}):r.prefixMinutes!==""&&n.jsx("span",{children:r.prefixMinutes||V.prefixMinutes}),n.jsx(We,{placeholder:d==="hour"?r.emptyMinutesForHourPeriod||V.emptyMinutesForHourPeriod:r.emptyMinutes||V.emptyMinutes,value:o,unit:Ce[0],setValue:t,locale:r,className:s,disabled:a,readOnly:i,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:h}),d==="hour"&&r.suffixMinutesForHourPeriod!==""&&n.jsx("span",{children:r.suffixMinutesForHourPeriod||V.suffixMinutesForHourPeriod})]}))}function Gn(e){var o=e.value,t=e.setValue,r=e.locale,s=e.className,a=e.weekDays,i=e.disabled,c=e.readOnly,u=e.leadingZero,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=!a||a.length===0,g=b.useMemo(function(){var O;return ce(((O={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!x})["".concat(s,"-field")]=!!s,O["".concat(s,"-month-days")]=!!s,O))},[s,x]),m=JSON.stringify(r),k=b.useMemo(function(){return x?r.emptyMonthDays||V.emptyMonthDays:r.emptyMonthDaysShort||V.emptyMonthDaysShort},[x,m]);return!c||o&&o.length>0||(!o||o.length===0)&&(!a||a.length===0)?n.jsxs("div",re({className:g},{children:[r.prefixMonthDays!==""&&n.jsx("span",{children:r.prefixMonthDays||V.prefixMonthDays}),n.jsx(We,{placeholder:k,value:o,setValue:t,unit:Ce[2],locale:r,className:s,disabled:i,readOnly:c,leadingZero:u,period:d,periodicityOnDoubleClick:f,mode:h})]})):null}function qn(e){var o=e.value,t=e.setValue,r=e.locale,s=e.className,a=e.humanizeLabels,i=e.disabled,c=e.readOnly,u=e.period,d=e.periodicityOnDoubleClick,f=e.mode,h=r.months||V.months,x=b.useMemo(function(){var g;return ce(((g={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,g["".concat(s,"-months")]=!!s,g))},[s]);return n.jsxs("div",re({className:x},{children:[r.prefixMonths!==""&&n.jsx("span",{children:r.prefixMonths||V.prefixMonths}),n.jsx(We,{placeholder:r.emptyMonths||V.emptyMonths,optionsList:h,grid:!1,value:o,unit:re(re({},Ce[3]),{alt:r.altMonths||V.altMonths}),setValue:t,locale:r,className:s,humanizeLabels:a,disabled:i,readOnly:c,period:u,periodicityOnDoubleClick:d,mode:f})]}))}function Kn(e){var o=e.value,t=e.setValue,r=e.locale,s=e.className,a=e.disabled,i=e.readOnly,c=e.shortcuts,u=e.allowedPeriods,d=[];u.includes("year")&&d.push({value:"year",label:r.yearOption||V.yearOption}),u.includes("month")&&d.push({value:"month",label:r.monthOption||V.monthOption}),u.includes("week")&&d.push({value:"week",label:r.weekOption||V.weekOption}),u.includes("day")&&d.push({value:"day",label:r.dayOption||V.dayOption}),u.includes("hour")&&d.push({value:"hour",label:r.hourOption||V.hourOption}),u.includes("minute")&&d.push({value:"minute",label:r.minuteOption||V.minuteOption}),u.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&d.push({value:"reboot",label:r.rebootOption||V.rebootOption});var f=b.useCallback(function(m){i||t(m)},[t,i]),h=b.useMemo(function(){var m;return ce(((m={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,m["".concat(s,"-period")]=!!s,m))},[s]),x=b.useMemo(function(){var m;return ce(((m={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":r.prefixPeriod===""})["".concat(s,"-select")]=!!s,m))},[s,r.prefixPeriod]),g=b.useMemo(function(){var m;return ce(((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",re({className:h},{children:[r.prefixPeriod!==""&&n.jsx("span",{children:r.prefixPeriod||V.prefixPeriod}),n.jsx(y.Select,{defaultValue:o,value:o,onChange:f,options:d,className:x,popupClassName:g,disabled:a,showArrow:!i,open:!i&&void 0,"data-testid":"select-period"},JSON.stringify(r))]}))}function Yn(e){var o=e.value,t=e.setValue,r=e.locale,s=e.className,a=e.humanizeLabels,i=e.monthDays,c=e.disabled,u=e.readOnly,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=r.weekDays||V.weekDays,g=d==="week"||!i||i.length===0,m=b.useMemo(function(){var E;return ce(((E={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!g})["".concat(s,"-field")]=!!s,E["".concat(s,"-week-days")]=!!s,E))},[s,g]),k=JSON.stringify(r),O=b.useMemo(function(){return g?r.emptyWeekDays||V.emptyWeekDays:r.emptyWeekDaysShort||V.emptyWeekDaysShort},[g,k]),B=d==="week"||!u||o&&o.length>0||(!o||o.length===0)&&(!i||i.length===0),S=!u||i&&i.length>0||(!i||i.length===0)&&(!o||o.length===0);return B?n.jsxs("div",re({className:m},{children:[r.prefixWeekDays!==""&&(d==="week"||!S)&&n.jsx("span",{children:r.prefixWeekDays||V.prefixWeekDays}),r.prefixWeekDaysForMonthAndYearPeriod!==""&&d!=="week"&&S&&n.jsx("span",{children:r.prefixWeekDaysForMonthAndYearPeriod||V.prefixWeekDaysForMonthAndYearPeriod}),n.jsx(We,{placeholder:O,optionsList:x,grid:!1,value:o,unit:re(re({},Ce[4]),{alt:r.altWeekDays||V.altWeekDays}),setValue:t,locale:r,className:s,humanizeLabels:a,disabled:c,readOnly:u,period:d,periodicityOnDoubleClick:f,mode:h})]})):null}function _n(e){var o=e.clearButton,t=o===void 0||o,r=e.clearButtonProps,s=r===void 0?{}:r,a=e.clearButtonAction,i=a===void 0?"fill-with-every":a,c=e.locale,u=c===void 0?V:c,d=e.value,f=d===void 0?"":d,h=e.setValue,x=e.displayError,g=x===void 0||x,m=e.onError,k=e.className,O=e.defaultPeriod,B=O===void 0?"day":O,S=e.allowEmpty,E=S===void 0?"for-default-value":S,W=e.humanizeLabels,$=W===void 0||W,M=e.humanizeValue,N=M!==void 0&&M,F=e.disabled,D=F!==void 0&&F,H=e.readOnly,K=H!==void 0&&H,ue=e.leadingZero,P=ue!==void 0&&ue,j=e.shortcuts,z=j===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:j,se=e.clockFormat,q=e.periodicityOnDoubleClick,Y=q===void 0||q,R=e.mode,ee=R===void 0?"multiple":R,Le=e.allowedDropdowns,he=Le===void 0?["period","months","month-days","week-days","hours","minutes"]:Le,Ee=e.allowedPeriods,Ar=Ee===void 0?["year","month","week","day","hour","minute","reboot"]:Ee,$e=b.useRef(f),Po=b.useRef(B),$t=b.useState(),be=$t[0],to=$t[1],Dt=b.useState(),ze=Dt[0],no=Dt[1],It=b.useState(),ro=It[0],so=It[1],Pt=b.useState(),Je=Pt[0],lo=Pt[1],Mt=b.useState(),io=Mt[0],ao=Mt[1],Bt=b.useState(),co=Bt[0],uo=Bt[1],Vt=b.useState(!1),Mo=Vt[0],Ue=Vt[1],jt=b.useState(!1),po=jt[0],Wt=jt[1],Fr=function(_){var ye=b.useRef(_);return b.useEffect(function(){ye.current=_},[_]),ye.current}(po),Lt=JSON.stringify(u);b.useEffect(function(){mt(f,Ue,m,E,$e,!0,u,z,uo,ao,no,so,lo,to)},[]),b.useEffect(function(){f!==$e.current&&mt(f,Ue,m,E,$e,!1,u,z,uo,ao,no,so,lo,to)},[f,$e,Lt,E,z]),b.useEffect(function(){if(!(be||co||ro||ze||Je||io)||po||Fr)po&&Wt(!1);else{var _=be||Po.current,ye=ft(_,ro,ze,Je,io,co,N);h(ye,{selectedPeriod:_}),$e.current=ye,m&&m(void 0),Ue(!1)}},[be,ze,ro,Je,io,co,N,po]);var zt=b.useCallback(function(){no(void 0),so(void 0),lo(void 0),ao(void 0),uo(void 0);var _="",ye=be!=="reboot"&&be?be:Po.current;ye!==be&&to(ye),i==="fill-with-every"&&(_=ft(ye,void 0,void 0,void 0,void 0,void 0)),h(_,{selectedPeriod:ye}),$e.current=_,Wt(!0),E==="never"&&i==="empty"?(Ue(!0),pt(m,u)):(m&&m(void 0),Ue(!1))},[be,h,m,i]),Or=b.useMemo(function(){var _;return ce(((_={"react-js-cron":!0,"react-js-cron-error":Mo&&g,"react-js-cron-disabled":D,"react-js-cron-read-only":K})["".concat(k)]=!!k,_["".concat(k,"-error")]=Mo&&g&&!!k,_["".concat(k,"-disabled")]=D&&!!k,_["".concat(k,"-read-only")]=K&&!!k,_))},[k,Mo,g,D,K]),Bo=s.className,Jt=ct(s,["className"]),Ut=b.useMemo(function(){var _;return ce(((_={"react-js-cron-clear-button":!0})["".concat(k,"-clear-button")]=!!k,_["".concat(Bo)]=!!Bo,_))},[k,Bo]),Tr=JSON.stringify(Jt),Ht=b.useMemo(function(){return t&&!K?n.jsx(y.Button,re({className:Ut,danger:!0,type:"primary",disabled:D},Jt,{onClick:zt},{children:u.clearButtonText||V.clearButtonText})):null},[t,K,Lt,Ut,D,Tr,zt]),oe=be||Po.current;return n.jsxs("div",re({className:Or},{children:[he.includes("period")&&n.jsx(Kn,{value:oe,setValue:to,locale:u,className:k,disabled:D,readOnly:K,shortcuts:z,allowedPeriods:Ar}),oe==="reboot"?Ht:n.jsxs(n.Fragment,{children:[oe==="year"&&he.includes("months")&&n.jsx(qn,{value:ro,setValue:so,locale:u,className:k,humanizeLabels:$,disabled:D,readOnly:K,period:oe,periodicityOnDoubleClick:Y,mode:ee}),(oe==="year"||oe==="month")&&he.includes("month-days")&&n.jsx(Gn,{value:ze,setValue:no,locale:u,className:k,weekDays:Je,disabled:D,readOnly:K,leadingZero:P,period:oe,periodicityOnDoubleClick:Y,mode:ee}),(oe==="year"||oe==="month"||oe==="week")&&he.includes("week-days")&&n.jsx(Yn,{value:Je,setValue:lo,locale:u,className:k,humanizeLabels:$,monthDays:ze,disabled:D,readOnly:K,period:oe,periodicityOnDoubleClick:Y,mode:ee}),n.jsxs("div",{children:[oe!=="minute"&&oe!=="hour"&&he.includes("hours")&&n.jsx(Un,{value:io,setValue:ao,locale:u,className:k,disabled:D,readOnly:K,leadingZero:P,clockFormat:se,period:oe,periodicityOnDoubleClick:Y,mode:ee}),oe!=="minute"&&he.includes("minutes")&&n.jsx(Hn,{value:co,setValue:uo,locale:u,period:oe,className:k,disabled:D,readOnly:K,leadingZero:P,clockFormat:se,periodicityOnDoubleClick:Y,mode:ee}),Ht]})]})]}))}const wt=[{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 Ct(e){return wt.filter(t=>typeof t.value=="number").reverse().find(t=>!(e%t.value))}function Zn(e){let o;switch(typeof e){case"number":return o=Ct(e),o?o.value:"none";case"string":return"cron"}return"none"}function Qn({value:e,onChange:o}){const{t}=go(),r=Ct(e);return n.jsx(y.InputNumber,{value:e/r.value,onChange:s=>o(s*r.value),min:1,addonBefore:t("Every"),addonAfter:t(r.unitText),className:"auto-width"})}function Xn({value:e=null,onChange:o}){const{t}=go(),r=Zn(e),s=b.useCallback(a=>{if(a==="none"){o(null);return}if(a==="cron"){o("0 * * * * *");return}o(a)},[o]);return n.jsxs("fieldset",{className:l.css`
|
|
465
|
+
`,children:[n.jsxs(y.Select,{value:r,onChange:s=>{t(s?s==="field"?{}:new Date:null)},className:"auto-width",children:[n.jsx(y.Select.Option,{value:null,children:o("No end")}),n.jsx(y.Select.Option,{value:"field",children:o("By field")}),n.jsx(y.Select.Option,{value:"date",children:o("By custom date")})]}),r==="field"?n.jsx(ao,{value:e,onChange:t}):null,r==="date"?n.jsx(y.DatePicker,{showTime:!0,value:Ko(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var re=function(){return re=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},re.apply(this,arguments)};function io(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 Xe(e,t,o){if(o||arguments.length===2)for(var r,s=0,i=t.length;s<i;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 Un=[{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 * * * *"}],Ce=[{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 co(e,t){for(var o=[],r=e;r<=t;r++)o.push(r);return o}function Re(e){return e.sort(function(t,o){return t-o}),e}function uo(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function ce(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 po(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||V.errorInvalidCron})}function et(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function mo(e,t,o,r,s,i,a,c,u,d,f,h,x,g){o&&o(void 0),t(!1);var m=!1;if(!e){if(r==="always"||i&&r==="for-default-value")return;m=!0}if(!m){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void g("reboot");var k=Un.find(function(S){return S.name===e});k&&(e=k.value)}try{var T=function(S){if(typeof S!="string")throw new Error("Invalid cron string");var D=S.replace(/\s+/g," ").trim().split(" ");if(D.length===5)return D.map(function(W,E){return function(M,N){if(M==="*"||M==="*/1")return[];var F=Re(uo(go(function(H,K,ue){if(ue){H=H.toUpperCase();for(var P=0;P<ue.length;P++)H=H.replace(ue[P],"".concat(P+K))}return H}(M,N.min,N.alt).split(",").map(function(H){var K,ue=H.split("/");if(ue.length>2)throw new Error('Invalid value "'.concat(M,' for "').concat(N.type,'"'));var P=ue[0],j=ue[1];K=P==="*"?co(N.min,N.max):function(q,_,R){var ee=q.split("-");if(ee.length===1){var Le=et(ee[0]);if(isNaN(Le))throw new Error('Invalid value "'.concat(_,'" for ').concat(R.type));return[Le]}if(ee.length===2){var he=et(ee[0]),De=et(ee[1]);if(isNaN(he)||isNaN(De))throw new Error('Invalid value "'.concat(_,'" for ').concat(R.type));if(De<he)throw new Error('Max range is less than min range in "'.concat(q,'" for ').concat(R.type));return co(he,De)}throw new Error('Invalid value "'.concat(q,'" for ').concat(R.type))}(P,M,N);var z=function(q,_){if(q!==void 0){var R=et(q);if(isNaN(R)||R<1)throw new Error('Invalid interval step value "'.concat(q,'" for ').concat(_.type));return R}}(j,N),se=function(q,_){if(_){var R=q[0];q=q.filter(function(ee){return ee%_==R%_||ee===R})}return q}(K,z);return se}).flat(),N))),$=bo(F,N);if($!==void 0)throw new Error('Value "'.concat($,'" out of range for ').concat(N.type));return F.length===N.total?[]:F}(W,Ce[E])});throw new Error("Invalid cron string format")}(e),B=function(S){return S[3].length>0?"year":S[2].length>0?"month":S[4].length>0?"week":S[1].length>0?"day":S[0].length>0?"hour":"minute"}(T);g(B),u(T[0]),d(T[1]),f(T[2]),h(T[3]),x(T[4])}catch(S){m=!0}}m&&(s.current=e,t(!0),po(o,a))}function fo(e,t,o,r,s,i,a){if(e==="reboot")return"@reboot";var c=function(u,d){return u.map(function(f,h){var x=Ce[h];return ho(yo(f,x),x,d)})}([e!=="minute"&&i?i:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!r?[]:r],a);return c.join(" ")}function ho(e,t,o,r,s){var i="";if(function(c,u){return c.length===u.max-u.min+1}(e,t)||e.length===0)i="*";else{var a=function(c){if(c.length>2){var u=c[1]-c[0];if(u>1)return u}}(e);i=a&&function(c,u){for(var d=1;d<c.length;d++){var f=c[d-1];if(c[d]-f!==u)return!1}return!0}(e,a)?function(c,u,d){var f=vo(c),h=xo(c),x=c.length===(h-f)/d+1;return!!(f===u.min&&h+d>u.max&&x)}(e,t,a)?"*/".concat(a):"".concat(Te(vo(e),t,o,r,s),"-").concat(Te(xo(e),t,o,r,s),"/").concat(a):function(c){var u=[],d=null;return c.forEach(function(f,h,x){f!==x[h+1]-1?d!==null?(u.push([d,f]),d=null):u.push(f):d===null&&(d=f)}),u}(e).map(function(c){return Array.isArray(c)?"".concat(Te(c[0],t,o,r,s),"-").concat(Te(c[1],t,o,r,s)):Te(c,t,o,r,s)}).join(",")}return i}function Te(e,t,o,r,s){var i=e.toString(),a=t.type,c=t.alt,u=t.min,d=r&&(r===!0||r.includes(a)),f=s==="24-hour-clock"&&(a==="hours"||a==="minutes");if(o&&a==="week-days"||o&&a==="months"?i=c[e-u]:e<10&&(d||f)&&(i=i.padStart(2,"0")),a==="hours"&&s==="12-hour-clock"){var h=e>=12?"PM":"AM",x=e%12||12;x<10&&d&&(x=x.toString().padStart(2,"0")),i="".concat(x).concat(h)}return i}function yo(e,t){var o=Re(uo(go(e,t)));if(o.length===0)return o;var r=bo(o,t);if(r!==void 0)throw new Error('Value "'.concat(r,'" out of range for ').concat(t.type));return o}function go(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function bo(e,t){var o=e[0],r=e[e.length-1];return o<t.min?o:r>t.max?r:void 0}function vo(e){return e[0]}function xo(e){return e[e.length-1]}function We(e){var t=e.value,o=e.grid,r=o===void 0||o,s=e.optionsList,i=e.setValue,a=e.locale,c=e.className,u=e.humanizeLabels,d=e.disabled,f=e.readOnly,h=e.leadingZero,x=e.clockFormat,g=e.period,m=e.unit,k=e.periodicityOnDoubleClick,T=e.mode,B=io(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),S=b.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(P){return P.toString()})},[t]),D=b.useMemo(function(){return s?s.map(function(P,j){return{value:(m.min===0?j:j+1).toString(),label:P}}):Xe([],Array(m.total),!0).map(function(P,j){var z=m.min===0?j:j+1;return{value:z.toString(),label:Te(z,m,u,h,x)}})},[s,h,u,x]),W=JSON.stringify(a),E=b.useCallback(function(P){var j=P.value;if(!t||t[0]!==Number(j))return n.jsx(n.Fragment,{});var z=ho(yo(t,m),m,u,h,x),se=z.match(/^\*\/([0-9]+),?/)||[];return n.jsx("div",{children:se[1]?"".concat(a.everyText||V.everyText," ").concat(se[1]):z})},[t,W,u,h,x]),M=b.useCallback(function(P){var j=Array.isArray(P)?Re(P):[P],z=j;t&&(z=T==="single"?[]:Xe([],t,!0),j.forEach(function(se){var q=Number(se);z=t.some(function(_){return _===q})?z.filter(function(_){return _!==q}):Re(Xe(Xe([],z,!0),[q],!1))})),z.length===m.total?i([]):i(z)},[i,t]),N=b.useCallback(function(P){if(P!==0&&P!==1){for(var j=m.total+m.min,z=[],se=m.min;se<j;se++)se%P==0&&z.push(se);var q=t&&z&&t.length===z.length&&t.every(function(R,ee){return R===z[ee]}),_=z.length===D.length;i(_||q?[]:z)}else i([])},[t,D,i]),F=b.useRef([]),$=b.useCallback(function(P){if(!f){var j=F.current;j.push({time:new Date().getTime(),value:Number(P)});var z=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?N(Number(P)):M([j[j.length-2].value,j[j.length-1].value]):M(Number(P)),F.current=[]},300);return function(){window.clearTimeout(z)}}},[F,M,N,f,k]),H=b.useCallback(function(){f||i([])},[i,f]),K=b.useMemo(function(){var P;return ce(((P={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,P))},[c]),ue=b.useMemo(function(){var P;return ce(((P={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(m.type)]=!0,P["react-js-cron-custom-select-dropdown"]=!0,P["react-js-cron-custom-select-dropdown-".concat(m.type)]=!0,P["react-js-cron-custom-select-dropdown-minutes-large"]=m.type==="minutes"&&g!=="hour"&&g!=="day",P["react-js-cron-custom-select-dropdown-minutes-medium"]=m.type==="minutes"&&(g==="day"||g==="hour"),P["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=m.type==="hours"&&x==="12-hour-clock",P["react-js-cron-custom-select-dropdown-grid"]=!!r,P["".concat(c,"-select-dropdown")]=!!c,P["".concat(c,"-select-dropdown-").concat(m.type)]=!!c,P))},[c,r,x,g]);return n.jsx(y.Select,re({mode:T!=="single"||k?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:S,onClear:H,tagRender:E,className:K,popupClassName:ue,options:D,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:$,onDeselect:$,disabled:d,dropdownAlign:m.type!=="minutes"&&m.type!=="hours"||g==="day"||g==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(m.type)},B))}function Hn(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,i=e.disabled,a=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=b.useMemo(function(){var g;return ce(((g={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,g["".concat(s,"-hours")]=!!s,g))},[s]);return n.jsxs("div",re({className:x},{children:[r.prefixHours!==""&&n.jsx("span",{children:r.prefixHours||V.prefixHours}),n.jsx(We,{placeholder:r.emptyHours||V.emptyHours,value:t,unit:Ce[1],setValue:o,locale:r,className:s,disabled:i,readOnly:a,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:h})]}))}function Yn(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,i=e.disabled,a=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=b.useMemo(function(){var g;return ce(((g={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,g["".concat(s,"-minutes")]=!!s,g))},[s]);return n.jsxs("div",re({className:x},{children:[d==="hour"?r.prefixMinutesForHourPeriod!==""&&n.jsx("span",{children:r.prefixMinutesForHourPeriod||V.prefixMinutesForHourPeriod}):r.prefixMinutes!==""&&n.jsx("span",{children:r.prefixMinutes||V.prefixMinutes}),n.jsx(We,{placeholder:d==="hour"?r.emptyMinutesForHourPeriod||V.emptyMinutesForHourPeriod:r.emptyMinutes||V.emptyMinutes,value:t,unit:Ce[0],setValue:o,locale:r,className:s,disabled:i,readOnly:a,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:h}),d==="hour"&&r.suffixMinutesForHourPeriod!==""&&n.jsx("span",{children:r.suffixMinutesForHourPeriod||V.suffixMinutesForHourPeriod})]}))}function qn(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,i=e.weekDays,a=e.disabled,c=e.readOnly,u=e.leadingZero,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=!i||i.length===0,g=b.useMemo(function(){var T;return ce(((T={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!x})["".concat(s,"-field")]=!!s,T["".concat(s,"-month-days")]=!!s,T))},[s,x]),m=JSON.stringify(r),k=b.useMemo(function(){return x?r.emptyMonthDays||V.emptyMonthDays:r.emptyMonthDaysShort||V.emptyMonthDaysShort},[x,m]);return!c||t&&t.length>0||(!t||t.length===0)&&(!i||i.length===0)?n.jsxs("div",re({className:g},{children:[r.prefixMonthDays!==""&&n.jsx("span",{children:r.prefixMonthDays||V.prefixMonthDays}),n.jsx(We,{placeholder:k,value:t,setValue:o,unit:Ce[2],locale:r,className:s,disabled:a,readOnly:c,leadingZero:u,period:d,periodicityOnDoubleClick:f,mode:h})]})):null}function Gn(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,i=e.humanizeLabels,a=e.disabled,c=e.readOnly,u=e.period,d=e.periodicityOnDoubleClick,f=e.mode,h=r.months||V.months,x=b.useMemo(function(){var g;return ce(((g={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,g["".concat(s,"-months")]=!!s,g))},[s]);return n.jsxs("div",re({className:x},{children:[r.prefixMonths!==""&&n.jsx("span",{children:r.prefixMonths||V.prefixMonths}),n.jsx(We,{placeholder:r.emptyMonths||V.emptyMonths,optionsList:h,grid:!1,value:t,unit:re(re({},Ce[3]),{alt:r.altMonths||V.altMonths}),setValue:o,locale:r,className:s,humanizeLabels:i,disabled:a,readOnly:c,period:u,periodicityOnDoubleClick:d,mode:f})]}))}function Kn(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,i=e.disabled,a=e.readOnly,c=e.shortcuts,u=e.allowedPeriods,d=[];u.includes("year")&&d.push({value:"year",label:r.yearOption||V.yearOption}),u.includes("month")&&d.push({value:"month",label:r.monthOption||V.monthOption}),u.includes("week")&&d.push({value:"week",label:r.weekOption||V.weekOption}),u.includes("day")&&d.push({value:"day",label:r.dayOption||V.dayOption}),u.includes("hour")&&d.push({value:"hour",label:r.hourOption||V.hourOption}),u.includes("minute")&&d.push({value:"minute",label:r.minuteOption||V.minuteOption}),u.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&d.push({value:"reboot",label:r.rebootOption||V.rebootOption});var f=b.useCallback(function(m){a||o(m)},[o,a]),h=b.useMemo(function(){var m;return ce(((m={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,m["".concat(s,"-period")]=!!s,m))},[s]),x=b.useMemo(function(){var m;return ce(((m={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":r.prefixPeriod===""})["".concat(s,"-select")]=!!s,m))},[s,r.prefixPeriod]),g=b.useMemo(function(){var m;return ce(((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",re({className:h},{children:[r.prefixPeriod!==""&&n.jsx("span",{children:r.prefixPeriod||V.prefixPeriod}),n.jsx(y.Select,{defaultValue:t,value:t,onChange:f,options:d,className:x,popupClassName:g,disabled:i,showArrow:!a,open:!a&&void 0,"data-testid":"select-period"},JSON.stringify(r))]}))}function _n(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,i=e.humanizeLabels,a=e.monthDays,c=e.disabled,u=e.readOnly,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=r.weekDays||V.weekDays,g=d==="week"||!a||a.length===0,m=b.useMemo(function(){var D;return ce(((D={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!g})["".concat(s,"-field")]=!!s,D["".concat(s,"-week-days")]=!!s,D))},[s,g]),k=JSON.stringify(r),T=b.useMemo(function(){return g?r.emptyWeekDays||V.emptyWeekDays:r.emptyWeekDaysShort||V.emptyWeekDaysShort},[g,k]),B=d==="week"||!u||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0),S=!u||a&&a.length>0||(!a||a.length===0)&&(!t||t.length===0);return B?n.jsxs("div",re({className:m},{children:[r.prefixWeekDays!==""&&(d==="week"||!S)&&n.jsx("span",{children:r.prefixWeekDays||V.prefixWeekDays}),r.prefixWeekDaysForMonthAndYearPeriod!==""&&d!=="week"&&S&&n.jsx("span",{children:r.prefixWeekDaysForMonthAndYearPeriod||V.prefixWeekDaysForMonthAndYearPeriod}),n.jsx(We,{placeholder:T,optionsList:x,grid:!1,value:t,unit:re(re({},Ce[4]),{alt:r.altWeekDays||V.altWeekDays}),setValue:o,locale:r,className:s,humanizeLabels:i,disabled:c,readOnly:u,period:d,periodicityOnDoubleClick:f,mode:h})]})):null}function Zn(e){var t=e.clearButton,o=t===void 0||t,r=e.clearButtonProps,s=r===void 0?{}:r,i=e.clearButtonAction,a=i===void 0?"fill-with-every":i,c=e.locale,u=c===void 0?V:c,d=e.value,f=d===void 0?"":d,h=e.setValue,x=e.displayError,g=x===void 0||x,m=e.onError,k=e.className,T=e.defaultPeriod,B=T===void 0?"day":T,S=e.allowEmpty,D=S===void 0?"for-default-value":S,W=e.humanizeLabels,E=W===void 0||W,M=e.humanizeValue,N=M!==void 0&&M,F=e.disabled,$=F!==void 0&&F,H=e.readOnly,K=H!==void 0&&H,ue=e.leadingZero,P=ue!==void 0&&ue,j=e.shortcuts,z=j===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:j,se=e.clockFormat,q=e.periodicityOnDoubleClick,_=q===void 0||q,R=e.mode,ee=R===void 0?"multiple":R,Le=e.allowedDropdowns,he=Le===void 0?["period","months","month-days","week-days","hours","minutes"]:Le,De=e.allowedPeriods,Fr=De===void 0?["year","month","week","day","hour","minute","reboot"]:De,Ee=b.useRef(f),It=b.useRef(B),Eo=b.useState(),be=Eo[0],ot=Eo[1],$o=b.useState(),ze=$o[0],nt=$o[1],Io=b.useState(),rt=Io[0],st=Io[1],Po=b.useState(),Je=Po[0],lt=Po[1],Mo=b.useState(),at=Mo[0],it=Mo[1],Bo=b.useState(),ct=Bo[0],dt=Bo[1],Vo=b.useState(!1),Pt=Vo[0],Ue=Vo[1],jo=b.useState(!1),ut=jo[0],Wo=jo[1],Tr=function(Z){var ye=b.useRef(Z);return b.useEffect(function(){ye.current=Z},[Z]),ye.current}(ut),Lo=JSON.stringify(u);b.useEffect(function(){mo(f,Ue,m,D,Ee,!0,u,z,dt,it,nt,st,lt,ot)},[]),b.useEffect(function(){f!==Ee.current&&mo(f,Ue,m,D,Ee,!1,u,z,dt,it,nt,st,lt,ot)},[f,Ee,Lo,D,z]),b.useEffect(function(){if(!(be||ct||rt||ze||Je||at)||ut||Tr)ut&&Wo(!1);else{var Z=be||It.current,ye=fo(Z,rt,ze,Je,at,ct,N);h(ye,{selectedPeriod:Z}),Ee.current=ye,m&&m(void 0),Ue(!1)}},[be,ze,rt,Je,at,ct,N,ut]);var zo=b.useCallback(function(){nt(void 0),st(void 0),lt(void 0),it(void 0),dt(void 0);var Z="",ye=be!=="reboot"&&be?be:It.current;ye!==be&&ot(ye),a==="fill-with-every"&&(Z=fo(ye,void 0,void 0,void 0,void 0,void 0)),h(Z,{selectedPeriod:ye}),Ee.current=Z,Wo(!0),D==="never"&&a==="empty"?(Ue(!0),po(m,u)):(m&&m(void 0),Ue(!1))},[be,h,m,a]),Or=b.useMemo(function(){var Z;return ce(((Z={"react-js-cron":!0,"react-js-cron-error":Pt&&g,"react-js-cron-disabled":$,"react-js-cron-read-only":K})["".concat(k)]=!!k,Z["".concat(k,"-error")]=Pt&&g&&!!k,Z["".concat(k,"-disabled")]=$&&!!k,Z["".concat(k,"-read-only")]=K&&!!k,Z))},[k,Pt,g,$,K]),Mt=s.className,Jo=io(s,["className"]),Uo=b.useMemo(function(){var Z;return ce(((Z={"react-js-cron-clear-button":!0})["".concat(k,"-clear-button")]=!!k,Z["".concat(Mt)]=!!Mt,Z))},[k,Mt]),Nr=JSON.stringify(Jo),Ho=b.useMemo(function(){return o&&!K?n.jsx(y.Button,re({className:Uo,danger:!0,type:"primary",disabled:$},Jo,{onClick:zo},{children:u.clearButtonText||V.clearButtonText})):null},[o,K,Lo,Uo,$,Nr,zo]),te=be||It.current;return n.jsxs("div",re({className:Or},{children:[he.includes("period")&&n.jsx(Kn,{value:te,setValue:ot,locale:u,className:k,disabled:$,readOnly:K,shortcuts:z,allowedPeriods:Fr}),te==="reboot"?Ho:n.jsxs(n.Fragment,{children:[te==="year"&&he.includes("months")&&n.jsx(Gn,{value:rt,setValue:st,locale:u,className:k,humanizeLabels:E,disabled:$,readOnly:K,period:te,periodicityOnDoubleClick:_,mode:ee}),(te==="year"||te==="month")&&he.includes("month-days")&&n.jsx(qn,{value:ze,setValue:nt,locale:u,className:k,weekDays:Je,disabled:$,readOnly:K,leadingZero:P,period:te,periodicityOnDoubleClick:_,mode:ee}),(te==="year"||te==="month"||te==="week")&&he.includes("week-days")&&n.jsx(_n,{value:Je,setValue:lt,locale:u,className:k,humanizeLabels:E,monthDays:ze,disabled:$,readOnly:K,period:te,periodicityOnDoubleClick:_,mode:ee}),n.jsxs("div",{children:[te!=="minute"&&te!=="hour"&&he.includes("hours")&&n.jsx(Hn,{value:at,setValue:it,locale:u,className:k,disabled:$,readOnly:K,leadingZero:P,clockFormat:se,period:te,periodicityOnDoubleClick:_,mode:ee}),te!=="minute"&&he.includes("minutes")&&n.jsx(Yn,{value:ct,setValue:dt,locale:u,period:te,className:k,disabled:$,readOnly:K,leadingZero:P,clockFormat:se,periodicityOnDoubleClick:_,mode:ee}),Ho]})]})]}))}const wo=[{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 Co(e){return wo.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function Qn(e){let t;switch(typeof e){case"number":return t=Co(e),t?t.value:"none";case"string":return"cron"}return"none"}function Xn({value:e,onChange:t}){const{t:o}=yt(),r=Co(e);return n.jsx(y.InputNumber,{value:e/r.value,onChange:s=>t(s*r.value),min:1,addonBefore:o("Every"),addonAfter:o(r.unitText),className:"auto-width"})}function Rn({value:e=null,onChange:t}){const{t:o}=yt(),r=Qn(e),s=b.useCallback(i=>{if(i==="none"){t(null);return}if(i==="cron"){t("0 * * * * *");return}t(i)},[t]);return n.jsxs("fieldset",{className:l.css`
|
|
466
466
|
display: flex;
|
|
467
467
|
flex-direction: ${r==="cron"?"column":"row"};
|
|
468
468
|
align-items: flex-start;
|
|
@@ -491,7 +491,7 @@
|
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
|
-
`,children:[n.jsx(y.Select,{value:r,onChange:s,className:"auto-width",children:
|
|
494
|
+
`,children:[n.jsx(y.Select,{value:r,onChange:s,className:"auto-width",children:wo.map(i=>n.jsx(y.Select.Option,{value:i.value,children:o(i.text)},i.value))}),typeof r=="number"?n.jsx(Xn,{value:e,onChange:t}):null,r==="cron"?n.jsx(Zn,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:i=>t(`0 ${i}`),clearButton:!1,locale:window.cronLocale}):null]})}const er={[we.STATIC]:{startsOn:{type:"datetime",title:`{{t("Starts on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${p}" })}}`,"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: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0}},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${p}" })}}`,min:0}}},[we.DATE_FIELD]:{collection:A(C({},ie),{"x-component-props":{dataSourceFilter(e){return e.options.key==="main"||e.options.isDBInstance}},"x-reactions":[...ie["x-reactions"],{target:"startsOn",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),startsOn:{type:"object",title:`{{t("Starts on", { ns: "${p}" })}}`,"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: "${p}" })}}`,"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: "${p}" })}}`,"x-decorator":"FormItem","x-component":"EndsByField"},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${p}" })}}`,min:0}},appends:A(C({},Ve),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${we.DATE_FIELD} && $deps[1]}}`}}}]})}},tr=[{value:we.STATIC,label:`{{t("Based on certain date", { ns: "${p}" })}}`},{value:we.DATE_FIELD,label:`{{t("Based on date field of collection", { ns: "${p}" })}}`}],or=()=>{const{values:e={},clearFormGraph:t}=L.useForm(),[o,r]=b.useState(e.mode);return L.useFormEffects(()=>{le.onFieldValueChange("mode",s=>{r(s.value),t("collection"),t("startsOn"),t("repeat"),t("endsOn"),t("limit")})}),n.jsxs(n.Fragment,{children:[n.jsx(l.SchemaComponent,{schema:{type:"number",title:`{{t("Trigger mode", { ns: "${p}" })}}`,name:"mode","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:tr},required:!0,default:we.STATIC}}),n.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`mode-${o}`]:{type:"void","x-component":"fieldset","x-component-props":{className:l.css`
|
|
495
495
|
.ant-input-number {
|
|
496
496
|
width: auto;
|
|
497
497
|
min-width: 6em;
|
|
@@ -500,29 +500,29 @@
|
|
|
500
500
|
.ant-picker {
|
|
501
501
|
width: auto;
|
|
502
502
|
}
|
|
503
|
-
`},properties:
|
|
503
|
+
`},properties:er[o]}}},components:{OnField:ao,RepeatField:Rn,EndsByField:Jn}})]})};function nr(e,t){var c;const[o,r]=l.parseCollectionName(e.collection),s=l.useCompile(),i=je(o),a=[];if((!(t!=null&&t.types)||t.types.includes("date"))&&a.push({key:"date",value:"date",label:O("Trigger time")}),e.mode===we.DATE_FIELD){const[u]=Ae(A(C({appends:["data",...((c=e.appends)==null?void 0:c.map(d=>`data.${d}`))||[]]},t),{fields:[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:O("Trigger data")}}],compile:s,getCollectionFields:i}));u&&a.push(u)}return a}class rr extends kt{constructor(){super(...arguments);w(this,"sync",!1);w(this,"title",`{{t("Schedule event", { ns: "${p}" })}}`);w(this,"description",`{{t("Triggered according to preset time conditions. Suitable for one-time or periodic tasks, such as sending notifications and cleaning data on a schedule.", { ns: "${p}" })}}`);w(this,"fieldset",{config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}});w(this,"scope",{useCollectionDataSource:l.useCollectionDataSource});w(this,"components",{ScheduleConfig:or});w(this,"useVariables",nr)}useInitializers(o){return o.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Be,collection:o.collection,dataPath:"$context.data"}:null}}function Oe(e){const i=e,{options:t=[],direction:o}=i,r=Q(i,["options","direction"]),s=l.useCompile();return n.jsx(y.Radio.Group,A(C({},r),{children:n.jsx(y.Space,{direction:o,children:t.map(a=>n.jsxs(y.Radio,{value:a.value,children:[n.jsx("span",{className:l.css`
|
|
504
504
|
& + .anticon {
|
|
505
505
|
margin-left: 0.25em;
|
|
506
506
|
}
|
|
507
|
-
`,children:s(
|
|
507
|
+
`,children:s(a.label)}),a.tooltip&&n.jsx(y.Tooltip,{title:s(a.tooltip),children:n.jsx(I.QuestionCircleOutlined,{style:{color:"#666"}})})]},a.value))})}))}function ko(){const e=L.useFieldSchema(),t=l.useCompile();return n.jsxs(l.GeneralSchemaDesigner,{title:t(e.title),children:[n.jsx(l.SchemaSettingsBlockTitleItem,{}),n.jsx(l.SchemaSettingsDivider,{}),n.jsx(l.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Ne=()=>null;function sr(){const i=l.useSchemaInitializerItem(),{node:t,resultTitle:o}=i,r=Q(i,["node","resultTitle"]),{insert:s}=l.useSchemaInitializer();return n.jsx(l.SchemaInitializerItem,A(C({},r),{onClick:()=>{var a;s({type:"void",name:t.id,title:t.title,"x-component":"CardItem","x-component-props":{title:(a=t.title)!=null?a:`#${t.id}`},"x-designer":"ValueBlock.Designer",properties:{result:{type:"void",title:o,"x-component":"ValueBlock.Result","x-component-props":{dataSource:`{{$jobsMapByNodeKey.${t.key}}}`}}}})}}))}function lr({dataSource:e}){var s;const t=L.useFieldSchema(),{execution:o}=Y();if(!o)return t.title;const r=J.parse(e)({$jobsMapByNodeKey:((s=o.jobs)!=null?s:[]).reduce((i,a)=>Object.assign(i,{[a.nodeKey]:a.result}),{})});return n.jsx("pre",{className:l.css`
|
|
508
508
|
margin: 0;
|
|
509
|
-
`,children:JSON.stringify(r,null,2)})}Ne.Initializer=
|
|
509
|
+
`,children:JSON.stringify(r,null,2)})}Ne.Initializer=sr,Ne.Result=lr,Ne.Designer=ko;const So=e=>{const t=$e.evaluators.get(e);return t&&t.link?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:l.css`
|
|
510
510
|
&:after {
|
|
511
511
|
content: ':';
|
|
512
512
|
}
|
|
513
513
|
& + a {
|
|
514
514
|
margin-left: 0.25em;
|
|
515
515
|
}
|
|
516
|
-
`,children:l.i18n.t("Syntax references")}),n.jsx("a",{href:
|
|
516
|
+
`,children:l.i18n.t("Syntax references")}),n.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class ar extends ge{constructor(){super(...arguments);w(this,"title",`{{t("Calculation", { ns: "${p}" })}}`);w(this,"type","calculation");w(this,"group","control");w(this,"description",`{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression.", { ns: "${p}" })}}`);w(this,"fieldset",{engine:{type:"string",title:`{{t("Calculation engine", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:$e.getOptions()},required:!0,default:"math.js"},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(o,r,{form:s}){const{values:i}=s,{evaluate:a}=$e.evaluators.get(i.engine),c=o.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return a(c),""}catch(u){return O("Expression syntax error")}},"x-reactions":[{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0}});w(this,"scope",{renderEngineReference:So});w(this,"components",{WorkflowVariableTextArea:$t,RadioWithTooltip:Oe,ValueBlock:Ne})}useVariables({key:o,title:r},{types:s,fieldNames:i=Se}){return s&&!s.some(a=>a in Ze||Object.values(Ze).some(c=>c.has(a)))?null:{value:o,label:r}}useInitializers(o){var r,s;return{name:(r=o.title)!=null?r:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Ne.Initializer,node:o,resultTitle:O("Calculation result")}}}const X=new J.Registry;X.register("equal",{name:"=",type:"boolean",group:"boolean"}),X.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),X.register("gt",{name:">",type:"boolean",group:"boolean"}),X.register("gte",{name:"≥",type:"boolean",group:"boolean"}),X.register("lt",{name:"<",type:"boolean",group:"boolean"}),X.register("lte",{name:"≤",type:"boolean",group:"boolean"}),X.register("add",{name:"+",type:"number",group:"number"}),X.register("minus",{name:"-",type:"number",group:"number"}),X.register("multiple",{name:"*",type:"number",group:"number"}),X.register("divide",{name:"/",type:"number",group:"number"}),X.register("mod",{name:"%",type:"number",group:"number"}),X.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),X.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),X.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),X.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),X.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),X.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),X.register("concat",{name:`{{t("concat", { ns: "${p}" })}}`,type:"string",group:"string"});const ir=[{value:"boolean",title:'{{t("Comparision")}}'},{value:"number",title:`{{t("Arithmetic calculation", { ns: "${p}" })}}`},{value:"string",title:`{{t("String operation", { ns: "${p}" })}}`},{value:"date",title:`{{t("Date", { ns: "${p}" })}}`}];function Ao(e){return Array.from(X.getEntities()).filter(([t,o])=>o.group===e)}function cr({calculator:e,operands:t=[],onChange:o}){const r=l.useCompile(),s=me(),i=me(),a=b.useCallback(d=>o({calculator:e,operands:[d,t[1]]}),[e,o,t]),c=b.useCallback(d=>o({calculator:e,operands:[t[0],d]}),[e,o,t]),u=b.useCallback(d=>o({operands:t,calculator:d}),[o,t]);return n.jsxs("fieldset",{className:l.css`
|
|
517
517
|
display: flex;
|
|
518
518
|
gap: 0.5em;
|
|
519
519
|
align-items: center;
|
|
520
520
|
flex-wrap: wrap;
|
|
521
|
-
`,children:[n.jsx(l.Variable.Input,{changeOnSelect:!0,value:
|
|
521
|
+
`,children:[n.jsx(l.Variable.Input,{changeOnSelect:!0,value:t[0],onChange:a,scope:s,useTypedConstant:!0}),n.jsx(y.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:u,placeholder:O("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:ir.filter(d=>!!Ao(d.value).length).map(d=>n.jsx(y.Select.OptGroup,{label:r(d.title),children:Ao(d.value).map(([f,{name:h}])=>n.jsx(y.Select.Option,{value:f,children:r(h)},f))},d.value))}),n.jsx(l.Variable.Input,{changeOnSelect:!0,value:t[1],onChange:c,scope:i,useTypedConstant:!0})]})}function dr({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:r,operands:s=[]}=e;return n.jsxs("div",{className:l.css`
|
|
522
522
|
display: flex;
|
|
523
523
|
position: relative;
|
|
524
524
|
margin: 0.5em 0;
|
|
525
|
-
`,children:[e.group?n.jsx(
|
|
525
|
+
`,children:[e.group?n.jsx(Fo,{value:e.group,onChange:i=>t(A(C({},e),{group:i}))}):n.jsx(cr,{operands:s,calculator:r,onChange:t}),n.jsx(y.Button,{"aria-label":"icon-close",onClick:o,type:"link",icon:n.jsx(I.CloseCircleOutlined,{})})]})}function Fo({value:e,onChange:t}){const{t:o}=G.useTranslation(),{type:r="and",calculations:s=[]}=e;function i(){t(A(C({},e),{calculations:[...s,{not:!1,calculator:"equal"}]}))}function a(){t(A(C({},e),{calculations:[...s,{not:!1,group:{type:"and",calculations:[]}}]}))}function c(d){s.splice(d,1),t(A(C({},e),{calculations:[...s]}))}function u(d,f){s.splice(d,1,f),t(A(C({},e),{calculations:[...s]}))}return n.jsxs("div",{className:l.cx("node-type-condition-group",l.css`
|
|
526
526
|
position: relative;
|
|
527
527
|
width: 100%;
|
|
528
528
|
.node-type-condition-group {
|
|
@@ -541,18 +541,18 @@
|
|
|
541
541
|
width: auto;
|
|
542
542
|
min-width: 6em;
|
|
543
543
|
}
|
|
544
|
-
`,children:n.jsxs(
|
|
544
|
+
`,children:n.jsxs(G.Trans,{children:["Meet ",n.jsxs(y.Select,{role:"button","data-testid":"filter-select-all-or-any",value:r,onChange:d=>t(A(C({},e),{type:d})),children:[n.jsx(y.Select.Option,{value:"and",children:"All"}),n.jsx(y.Select.Option,{value:"or",children:"Any"})]})," conditions in the group"]})}),n.jsx("div",{className:"calculation-items",children:s.map((d,f)=>n.jsx(dr,{value:d,onChange:u.bind(this,f),onRemove:()=>c(f)},`${d.calculator}_${f}`))}),n.jsxs("div",{className:l.css`
|
|
545
545
|
button {
|
|
546
546
|
padding: 0;
|
|
547
547
|
&:not(:last-child) {
|
|
548
548
|
margin-right: 1em;
|
|
549
549
|
}
|
|
550
550
|
}
|
|
551
|
-
`,children:[n.jsx(y.Button,{type:"link",onClick:
|
|
551
|
+
`,children:[n.jsx(y.Button,{type:"link",onClick:i,children:o("Add condition")}),n.jsx(y.Button,{type:"link",onClick:a,children:o("Add condition group")})]})]})}function ur({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return n.jsx(Fo,{value:o.group,onChange:r=>t(A(C({},o),{group:r}))})}class pr extends ge{constructor(){super(...arguments);w(this,"title",`{{t("Condition", { ns: "${p}" })}}`);w(this,"type","condition");w(this,"group","control");w(this,"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: "${p}" })}}`);w(this,"fieldset",{rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{disabled:!0},enum:[{value:!0,label:`{{t('Continue when "Yes"', { ns: "${p}" })}}`},{value:!1,label:`{{t('Branch into "Yes" and "No"', { ns: "${p}" })}}`}]},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[["basic",{label:`{{t("Basic", { ns: "${p}" })}}`}],...Array.from($e.evaluators.getEntities()).filter(([o])=>["math.js","formula.js"].includes(o))].reduce((o,[r,s])=>o.concat(C({value:r},s)),[])},required:!0,default:"basic"},calculation:{type:"string",title:`{{t("Condition", { ns: "${p}" })}}`,"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: "${p}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(o,r,{form:s}){const{values:i}=s,{evaluate:a}=$e.evaluators.get(i.engine),c=o.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return a(c),""}catch(u){return O("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0}});w(this,"options",[{label:`{{t('Continue when "Yes"', { ns: "${p}" })}}`,key:"rejectOnFalse",value:{rejectOnFalse:!0}},{label:`{{t('Branch into "Yes" and "No"', { ns: "${p}" })}}`,key:"branch",value:{rejectOnFalse:!1}}]);w(this,"scope",{renderEngineReference:So,useWorkflowVariableOptions:me});w(this,"components",{CalculationConfig:ur,WorkflowVariableTextArea:$t,RadioWithTooltip:Oe})}Component({data:o}){const{t:r}=G.useTranslation(),{nodes:s}=Y(),{styles:i}=ne(),{id:a,config:{rejectOnFalse:c}}=o,u=s.find(f=>f.upstreamId===a&&f.branchIndex===1),d=s.find(f=>f.upstreamId===a&&f.branchIndex===0);return n.jsx(Ct,{data:o,children:c?null:n.jsxs("div",{className:i.nodeSubtreeClass,children:[n.jsxs("div",{className:i.branchBlockClass,children:[n.jsx(Ge,{from:o,entry:d,branchIndex:0}),n.jsx(Ge,{from:o,entry:u,branchIndex:1})]}),n.jsxs("div",{className:i.conditionClass,children:[n.jsx("span",{style:{right:"4em"},children:r("No")}),n.jsx("span",{style:{left:"4em"},children:r("Yes")})]})]})})}}class mr extends ge{constructor(){super(...arguments);w(this,"title",`{{t("End process", { ns: "${p}" })}}`);w(this,"type","end");w(this,"group","control");w(this,"description",`{{t("End the process immediately, with set status.", { ns: "${p}" })}}`);w(this,"fieldset",{endStatus:{type:"number",title:`{{t("End status", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeeded", { ns: "${p}" })}}`,value:ae.RESOLVED},{label:`{{t("Failed", { ns: "${p}" })}}`,value:ae.FAILED}],required:!0,default:ae.RESOLVED}});w(this,"end",!0)}}function tt({value:e,onChange:t,renderSchemaComponent:o}){const r=me();return n.jsx(l.Variable.Input,{value:e,onChange:t,scope:r,children:o()})}function fr(e){const{execution:t,nodes:o}=Y(),r=b.useMemo(()=>o.reduce((a,c)=>Object.assign(a,{[c.id]:c.key}),{}),[o]),s=b.useMemo(()=>{var a;return{$context:t==null?void 0:t.context,$jobsMapByNodeKey:((a=t==null?void 0:t.jobs)!=null?a:[]).reduce((c,u)=>Object.assign(c,{[r[u.nodeId]]:u.result}),{})}},[t==null?void 0:t.context,t==null?void 0:t.jobs,r]);return b.useMemo(()=>ke.get(s,e),[s,e])}function hr({collection:e,dataPath:t,children:o}){const r=L.useField(),s=b.useRef(null),{getAssociationAppends:i}=l.useAssociationNames(),{appends:a,updateAssociationValues:c}=i(),u=fr(t);let d,f;if(typeof e=="string"){const B=l.parseCollectionName(e);d=B[0],f=B[1]}else f=e;const h=b.useMemo(()=>le.createForm({values:u,readPretty:!0}),[u]),x={appends:a},g={loading:!1,data:{data:u}},k=l.useAPIClient().resource(f),T=l.useBlockRequestContext();return n.jsx(l.CollectionProvider_deprecated,{dataSource:d,collection:f,children:n.jsx(l.RecordProvider,{record:u,parent:null,children:n.jsx(l.BlockRequestContext_deprecated.Provider,{value:{block:"form",field:r,service:g,resource:k,__parent:T},children:n.jsx(l.FormBlockContext.Provider,{value:{params:x,form:h,field:r,service:g,updateAssociationValues:c,formBlockRef:s},children:o})})})})}function yr(e){const i=e,{options:t=[],direction:o}=i,r=Q(i,["options","direction"]),s=l.useCompile();return n.jsx(y.Checkbox.Group,A(C({},r),{children:n.jsx(y.Space,{direction:o,children:t.map(a=>n.jsxs(y.Checkbox,{value:a.value,children:[n.jsx("span",{className:l.css`
|
|
552
552
|
& + .anticon {
|
|
553
553
|
margin-left: 0.25em;
|
|
554
554
|
}
|
|
555
|
-
`,children:s(
|
|
555
|
+
`,children:s(a.label)}),a.tooltip&&n.jsx(y.Tooltip,{title:s(a.tooltip),children:n.jsx(I.QuestionCircleOutlined,{style:{color:"#666"}})})]},a.value))})}))}function gr({key:e,title:t,config:o},r){var d,f;const[s,i]=l.parseCollectionName(o.collection),a=l.useCompile(),c=je(s),[u]=Ae(A(C({appends:[e,...((f=(d=o.params)==null?void 0:d.appends)==null?void 0:f.map(h=>`${e}.${h}`))||[]]},r),{fields:[{collectionName:i,name:e,type:"hasOne",target:i,uiSchema:{title:t}}],compile:a,getCollectionFields:c}));return u}class br extends ge{constructor(){super(...arguments);w(this,"title",`{{t("Query record", { ns: "${p}" })}}`);w(this,"type","query");w(this,"group","collection");w(this,"description",`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:A(C({},ie),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...ie["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),multiple:{type:"boolean",title:`{{t("Result type", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{label:`{{t("Single record", { ns: "${p}" })}}`,value:!1,tooltip:`{{t("The result will be an object of the first matching record only, or null if no matched record.", { ns: "${p}" })}}`},{label:`{{t("Multiple records", { ns: "${p}" })}}`,value:!0,tooltip:`{{t("The result will be an array containing matched records, or an empty one if no matching records. This can be used to be processed in a loop node.", { ns: "${p}" })}}`}]},required:!0,default:!1},params:{type:"object","x-component":"fieldset",properties:{filter:_e,sort:Nn,pagination:Dn,appends:Ve},"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: "${p}" })}}`}});w(this,"scope",{useNodeSavedConfig:Me,useCollectionDataSource:l.useCollectionDataSource,useSortableFields(){const o=l.useCompile(),{values:r}=L.useForm(),[s,i]=l.parseCollectionName(r.collection),a=l.useApp(),{collectionManager:c}=a.dataSourceManager.getDataSource(s);return c.getCollectionFields(i).filter(d=>{if(!d.interface)return!1;const f=a.dataSourceManager.collectionFieldInterfaceManager.getFieldInterface(d.interface);return!!(f!=null&&f.sortable)}).map(d=>{var f,h;return{value:d.name,label:(f=d==null?void 0:d.uiSchema)!=null&&f.title?o((h=d==null?void 0:d.uiSchema)==null?void 0:h.title):d.name}})}});w(this,"components",{ArrayItems:Vt.ArrayItems,FilterDynamicComponent:tt,SchemaComponentContext:l.SchemaComponentContext,WorkflowVariableInput:so,RadioWithTooltip:Oe});w(this,"useVariables",gr)}useInitializers(o){var r,s;return!o.config.collection||o.config.multiple?null:{name:(r=o.title)!=null?r:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Be,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}}}function vr(e){const{getCollectionFields:t}=l.useCollectionManager_deprecated(),{path:o}=L.useField(),r=o.segments[o.segments.length-1],{values:s}=L.useForm(),[i,a]=l.parseCollectionName(s==null?void 0:s.collection),c=t(a,i),{type:u}=c.find(h=>h.name===r),d=Array.isArray(e.value)?e.value.join(","):e.value,f=b.useCallback(h=>{const x=h.target.value.trim(),g=["belongsTo","hasOne"].includes(u)?x||null:x.split(",").map(m=>m.trim()).filter(m=>m!=="");e.onChange(g)},[e.onChange,u]);return n.jsx(y.Input,A(C({},e),{value:d,onChange:f}))}const To=L.observer(({value:e,disabled:t,onChange:o,filter:r})=>{const{token:s}=l.useToken(),{t:i}=G.useTranslation(),a=l.useCompile(),c=L.useForm(),{getCollectionFields:u}=l.useCollectionManager_deprecated(),d=me(),{values:f}=c,[h,x]=l.parseCollectionName(f==null?void 0:f.collection),g=u(x,h).filter(S=>S.uiSchema),m=r?g.filter(r.bind(f)):g,k=b.useMemo(()=>m.filter(S=>!e||!(S.name in e)),[m,e]),T=t||c.disabled,B=b.useMemo(()=>({onClick:({key:S})=>{o(A(C({},e),{[S]:null}))},style:{maxHeight:300,overflowY:"auto"},items:k.map(S=>{var D,W;return{key:S.name,label:a((W=(D=S.uiSchema)==null?void 0:D.title)!=null?W:S.name)}})}),[o,k,e]);return n.jsx("fieldset",{className:l.css`
|
|
556
556
|
margin-top: 0.5em;
|
|
557
557
|
|
|
558
558
|
> .ant-formily-item {
|
|
@@ -562,8 +562,8 @@
|
|
|
562
562
|
line-height: 32px;
|
|
563
563
|
}
|
|
564
564
|
}
|
|
565
|
-
`,children:m.length?n.jsxs(l.CollectionProvider_deprecated,{name:x,dataSource:h,children:[m.filter(S=>e&&S.name in e).map(S=>{var W
|
|
565
|
+
`,children:m.length?n.jsxs(l.CollectionProvider_deprecated,{name:x,dataSource:h,children:[m.filter(S=>e&&S.name in e).map(S=>{var W,E;const D=["belongsTo","hasOne","hasMany","belongsToMany"].includes(S.type)?vr:l.CollectionField;return n.jsxs(y.Form.Item,{label:a((E=(W=S.uiSchema)==null?void 0:W.title)!=null?E:S.name),labelAlign:"left",className:l.css`
|
|
566
566
|
.ant-form-item-control-input-content {
|
|
567
567
|
display: flex;
|
|
568
568
|
}
|
|
569
|
-
`,children:[n.jsx(l.Variable.Input,{scope:d,value:e[S.name],changeOnSelect:!0,onChange:M=>{t(A(C({},e),{[S.name]:M}))},children:n.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[S.name]:{"x-component":E,"x-validator"(){return""}}}}})}),O?null:n.jsx(y.Button,{"aria-label":"icon-close",type:"link",icon:n.jsx(I.CloseCircleOutlined,{}),onClick:()=>{var F;const D=e,{[F=S.name]:M}=D,N=Z(D,[Kt(F)]);t(N)}})]},S.name)}),k.length?n.jsx(y.Dropdown,{menu:B,children:n.jsx(y.Button,{icon:n.jsx(I.PlusOutlined,{}),children:a("Add field")})}):null]}):n.jsx("p",{style:{color:s.colorText},children:T("Please select collection first")})})},{displayName:"CollectionFieldSet"});function Tt(e,o){o(e),e!=null&&e.properties&&Object.values(e.properties).forEach(t=>{Tt(t,o)})}function Nt(){return{name:ho.uid(),type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields"}}function Et(e){const{workflow:o}=G(),{setFormValueChanged:t}=l.useActionContext();l.useAPIClient();const r=me(),s=L.useForm(),{values:a,setValuesIn:i}=s,c=fo.toJS(a.params),[u,d]=l.parseCollectionName(a.collection),f=l.useSchemaOptionsContext(),[h,x]=b.useState(e.value&&Object.keys(e.value).length?e.value:Nt()),g=b.useMemo(()=>le.createForm({initialValues:c.values,disabled:o.executed,effects(){le.onFormValuesChange(k=>{i("params.values",fo.toJS(k.values)),t(!0)})}}),[o.executed]);L.useFormEffects(()=>{le.onFieldValueChange("collection",k=>U(this,null,function*(){g.clearFormGraph("*");const O=Nt();i("params.values",{}),x(O)}))});const m=b.useCallback(k=>{const[O]=Object.values(k.toJSON().properties);e.onChange(O);const B=new Set;Tt(O,E=>{var W;if(E["x-component"]==="AssignedField"&&(W=E["x-collection-field"])!=null&&W.startsWith(`${d}.`)){const[,$]=E["x-collection-field"].split(".");B.add($)}});const S={};Array.from(B).forEach(E=>{E in g.values&&(S[E]=g.values[E])}),i("params.values",S)},[d,e.onChange]);return n.jsx(y.Card,{children:n.jsx(l.CollectionManagerProvider,{dataSource:u,children:n.jsx(l.CollectionProvider,{name:d,children:n.jsx(l.FormProvider,{form:g,children:n.jsx(jo.FormLayout,{layout:"vertical",children:n.jsx(l.VariableScopeProvider,{scope:r,children:n.jsx(l.SchemaComponentProvider,{form:g,designable:!s.disabled,children:n.jsx(l.SchemaComponentOptions,A(C({},f),{children:n.jsx(l.SchemaComponent,{schema:h,onChange:m})}))})})})})})})})}function vr({key:e,title:o,config:t},r){var d,f;const[s,a]=l.parseCollectionName(t.collection),i=l.useCompile(),c=je(s),[u]=Ae(A(C({appends:[e,...((f=(d=t.params)==null?void 0:d.appends)==null?void 0:f.map(h=>`${e}.${h}`))||[]]},r),{fields:[{collectionName:a,name:e,type:"hasOne",target:a,uiSchema:{title:o}}],compile:i,getCollectionFields:c}));return u}class xr extends ge{constructor(){super(...arguments);w(this,"title",`{{t("Create record", { ns: "${p}" })}}`);w(this,"type","create");w(this,"group","collection");w(this,"description",`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:A(C({},ae),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...ae["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),usingAssignFormSchema:{type:"boolean"},assignFormSchema:{type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-component":"AssignedFieldsFormSchemaConfig","x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && $deps[1]) ? "visible" : "hidden"}}'}}}]},params:{type:"object",properties:{values:A(C({},et),{"x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && !$deps[1]) ? "visible" : "hidden"}}'}}}]}),appends:Ve}}});w(this,"scope",{useCollectionDataSource:l.useCollectionDataSource,useNodeSavedConfig:Me});w(this,"components",{CollectionFieldset:Ot,AssignedFieldsFormSchemaConfig:Et});w(this,"useVariables",vr)}createDefaultConfig(){return{usingAssignFormSchema:!0,assignFormSchema:{}}}useInitializers(t){var r,s;return t.config.collection?{name:(r=t.title)!=null?r:`#${t.id}`,type:"item",title:(s=t.title)!=null?s:`#${t.id}`,Component:Be,collection:t.config.collection,dataPath:`$jobsMapByNodeKey.${t.key}`}:null}}class wr extends ge{constructor(){super(...arguments);w(this,"title",`{{t("Update record", { ns: "${p}" })}}`);w(this,"type","update");w(this,"group","collection");w(this,"description",`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:A(C({},ae),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...ae["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}},{target:"params.values",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${p}" })}}`,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: "${p}" })}}`},{label:`{{t("Update one by one", { ns: "${p}" })}}`,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: "${p}" })}}`}]},default:!1},filter:A(C({},_e),{title:`{{t("Only update records matching conditions", { ns: "${p}" })}}`,"x-validator"(t){return J.isValidFilter(t)?"":T("Please add at least one condition")}}),values:A(C({},et),{"x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && !$deps[1]) ? "visible" : "hidden"}}'}}}]})}},usingAssignFormSchema:{type:"boolean"},assignFormSchema:{type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-component":"AssignedFieldsFormSchemaConfig","x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && $deps[1]) ? "visible" : "hidden"}}'}}}]}});w(this,"scope",{useCollectionDataSource:l.useCollectionDataSource,useNodeSavedConfig:Me});w(this,"components",{FilterDynamicComponent:oo,CollectionFieldset:Ot,AssignedFieldsFormSchemaConfig:Et,RadioWithTooltip:Te})}createDefaultConfig(){return{usingAssignFormSchema:!0,assignFormSchema:{}}}}class Cr extends ge{constructor(){super(...arguments);w(this,"title",'{{t("Delete record")}}');w(this,"type","destroy");w(this,"group","collection");w(this,"description",`{{t("Delete records of a collection. Could use variables in workflow context as filter. All records match the filter will be deleted.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:A(C({},ae),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...ae["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:A(C({},_e),{"x-validator"(t){return J.isValidFilter(t)?"":T("Please add at least one condition")}})}}});w(this,"scope",{useNodeSavedConfig:Me,useCollectionDataSource:l.useCollectionDataSource});w(this,"components",{FilterDynamicComponent:oo})}}const kr=new l.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:l.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=l.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:l.SecondConFirm},{name:"assignFieldValues",Component:l.AssignedFieldValues},{name:"skipRequiredValidation",Component:l.SkipValidation},{name:"afterSuccessfulSubmission",Component:l.AfterSuccess,useVisible(){var o;const e=L.useFieldSchema();return ho.isValid((o=e==null?void 0:e["x-action-settings"])==null?void 0:o.onSuccess)}},{name:"bindWorkflow",Component:l.WorkflowConfig},{name:"delete",sort:100,Component:l.RemoveButton,useComponentProps(){const{removeButtonProps:e}=l.useSchemaToolbar();return e}}]});function Sr({children:e,workflow:o,execution:t,nodes:r}){const s=l.usePlugin(de),a=s.triggers.get(o.type).components,i=r.reduce((c,{type:u})=>Object.assign(c,s.instructions.get(u).components),{});return n.jsx(Ie.Provider,{value:{workflow:o,nodes:r,execution:t},children:n.jsx(l.SchemaComponentOptions,{components:C(C({},a),i),children:e})})}class de extends l.Plugin{constructor(){super(...arguments);w(this,"triggers",new J.Registry);w(this,"instructions",new J.Registry);w(this,"getTriggersOptions",()=>Array.from(this.triggers.getEntities()).map(a=>{var[t,i]=a,c=i,{title:r}=c,s=Z(c,["title"]);return{value:t,label:r,color:"gold",options:s}}))}isWorkflowSync(t){var r,s;return(s=(r=this.triggers.get(t.type))==null?void 0:r.sync)!=null?s:t.sync}registerTrigger(t,r){if(typeof r=="function")this.triggers.register(t,new r);else if(r)this.triggers.register(t,r);else throw new TypeError("invalid trigger type to register")}registerInstruction(t,r){if(typeof r=="function")this.instructions.register(t,new r);else if(r instanceof ge)this.instructions.register(t,r);else throw new TypeError("invalid instruction type to register")}load(){return U(this,null,function*(){this.app.router.add("admin.workflow.workflows.id",{path:xe(":id"),element:n.jsx(Xo,{})}),this.app.router.add("admin.workflow.executions.id",{path:Ye(":id"),element:n.jsx(qo,{})}),this.app.addComponents({WorkflowPage:Xo,ExecutionPage:qo}),this.app.pluginSettingsManager.add(p,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${p}" })}}`,Component:Fn,aclSnippet:"pm.workflow.workflows"}),this.app.schemaSettingsManager.add(kr),this.registerTrigger("collection",Wn),this.registerTrigger("schedule",nr),this.registerInstruction("calculation",lr),this.registerInstruction("condition",ur),this.registerInstruction("end",pr),this.registerInstruction("query",gr),this.registerInstruction("create",xr),this.registerInstruction("update",wr),this.registerInstruction("destroy",Cr)})}}v.BaseTypeSets=Ze,v.Branch=Ke,v.CheckboxGroupWithTooltip=hr,v.CollectionBlockInitializer=Be,v.DetailsBlockProvider=fr,v.EXECUTION_STATUS=pe,v.ExecutionContextProvider=Sr,v.ExecutionStatusOptions=He,v.ExecutionStatusOptionsMap=Ge,v.FieldsSelect=To,v.FilterDynamicComponent=oo,v.FlowContext=Ie,v.Instruction=ge,v.JOB_STATUS=ie,v.JobButton=Co,v.JobStatusOptions=vo,v.JobStatusOptionsMap=qe,v.Node=Ho,v.NodeContext=xo,v.NodeDefaultView=ko,v.RadioWithTooltip=Te,v.RemoveButton=wo,v.SimpleDesigner=kt,v.Trigger=So,v.ValueBlock=Ne,v.WorkflowVariableInput=lt,v.WorkflowVariableJSON=In,v.WorkflowVariableRawTextArea=Dn,v.WorkflowVariableTextArea=Io,v.default=de,v.defaultFieldNames=Se,v.getCollectionFieldOptions=Ae,v.getWorkflowDetailPath=xe,v.getWorkflowExecutionsPath=Ye,v.linkNodes=Fo,v.nodesOptions=ot,v.scopeOptions=nt,v.systemOptions=rt,v.traverseSchema=Oo,v.triggerOptions=tt,v.useAvailableUpstreams=Jo,v.useFlowContext=G,v.useGetAriaLabelOfAddButton=bo,v.useGetCollectionFields=je,v.useNodeContext=ve,v.useNodeSavedConfig=Me,v.useRecordTriggerWorkflowsActionProps=Mn,v.useStyles=ne,v.useTrigger=Ao,v.useTriggerWorkflowsActionProps=Pn,v.useUpstreamScopes=Uo,v.useWorkflowAnyExecuted=it,v.useWorkflowExecuted=Bn,v.useWorkflowVariableOptions=me,Object.defineProperties(v,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
569
|
+
`,children:[n.jsx(l.Variable.Input,{scope:d,value:e[S.name],changeOnSelect:!0,onChange:M=>{o(A(C({},e),{[S.name]:M}))},children:n.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[S.name]:{"x-component":D,"x-validator"(){return""}}}}})}),T?null:n.jsx(y.Button,{"aria-label":"icon-close",type:"link",icon:n.jsx(I.CloseCircleOutlined,{}),onClick:()=>{var F;const $=e,{[F=S.name]:M}=$,N=Q($,[Go(F)]);o(N)}})]},S.name)}),k.length?n.jsx(y.Dropdown,{menu:B,children:n.jsx(y.Button,{icon:n.jsx(I.PlusOutlined,{}),children:i("Add field")})}):null]}):n.jsx("p",{style:{color:s.colorText},children:O("Please select collection first")})})},{displayName:"CollectionFieldSet"});function Oo(e,t){t(e),e!=null&&e.properties&&Object.values(e.properties).forEach(o=>{Oo(o,t)})}function No(){return{name:ft.uid(),type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields"}}function Do(e){const{workflow:t}=Y(),{setFormValueChanged:o}=l.useActionContext();l.useAPIClient();const r=me(),s=L.useForm(),{values:i,setValuesIn:a}=s,c=mt.toJS(i.params),[u,d]=l.parseCollectionName(i.collection),f=l.useSchemaOptionsContext(),[h,x]=b.useState(e.value&&Object.keys(e.value).length?e.value:No()),g=b.useMemo(()=>le.createForm({initialValues:c.values,disabled:t.executed,effects(){le.onFormValuesChange(k=>{a("params.values",mt.toJS(k.values)),o(!0)})}}),[t.executed]);L.useFormEffects(()=>{le.onFieldValueChange("collection",k=>U(this,null,function*(){g.clearFormGraph("*");const T=No();a("params.values",{}),x(T)}))});const m=b.useCallback(k=>{const[T]=Object.values(k.toJSON().properties);e.onChange(T);const B=new Set;Oo(T,D=>{var W;if(D["x-component"]==="AssignedField"&&(W=D["x-collection-field"])!=null&&W.startsWith(`${d}.`)){const[,E]=D["x-collection-field"].split(".");B.add(E)}});const S={};Array.from(B).forEach(D=>{D in g.values&&(S[D]=g.values[D])}),a("params.values",S)},[d,e.onChange]);return n.jsx(y.Card,{children:n.jsx(l.CollectionManagerProvider,{dataSource:u,children:n.jsx(l.CollectionProvider,{name:d,children:n.jsx(l.FormProvider,{form:g,children:n.jsx(Vt.FormLayout,{layout:"vertical",children:n.jsx(l.VariableScopeProvider,{scope:r,children:n.jsx(l.SchemaComponentProvider,{form:g,designable:!s.disabled,children:n.jsx(l.SchemaComponentOptions,A(C({},f),{children:n.jsx(l.SchemaComponent,{schema:h,onChange:m})}))})})})})})})})}function xr({key:e,title:t,config:o},r){var d,f;const[s,i]=l.parseCollectionName(o.collection),a=l.useCompile(),c=je(s),[u]=Ae(A(C({appends:[e,...((f=(d=o.params)==null?void 0:d.appends)==null?void 0:f.map(h=>`${e}.${h}`))||[]]},r),{fields:[{collectionName:i,name:e,type:"hasOne",target:i,uiSchema:{title:t}}],compile:a,getCollectionFields:c}));return u}class wr extends ge{constructor(){super(...arguments);w(this,"title",`{{t("Create record", { ns: "${p}" })}}`);w(this,"type","create");w(this,"group","collection");w(this,"description",`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:A(C({},ie),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...ie["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),usingAssignFormSchema:{type:"boolean"},assignFormSchema:{type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-component":"AssignedFieldsFormSchemaConfig","x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && $deps[1]) ? "visible" : "hidden"}}'}}}]},params:{type:"object",properties:{values:A(C({},Rt),{"x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && !$deps[1]) ? "visible" : "hidden"}}'}}}]}),appends:Ve}}});w(this,"scope",{useCollectionDataSource:l.useCollectionDataSource,useNodeSavedConfig:Me});w(this,"components",{CollectionFieldset:To,AssignedFieldsFormSchemaConfig:Do});w(this,"useVariables",xr)}createDefaultConfig(){return{usingAssignFormSchema:!0,assignFormSchema:{}}}useInitializers(o){var r,s;return o.config.collection?{name:(r=o.title)!=null?r:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Be,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}:null}}class Cr extends ge{constructor(){super(...arguments);w(this,"title",`{{t("Update record", { ns: "${p}" })}}`);w(this,"type","update");w(this,"group","collection");w(this,"description",`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:A(C({},ie),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...ie["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}},{target:"params.values",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${p}" })}}`,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: "${p}" })}}`},{label:`{{t("Update one by one", { ns: "${p}" })}}`,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: "${p}" })}}`}]},default:!1},filter:A(C({},_e),{title:`{{t("Only update records matching conditions", { ns: "${p}" })}}`,"x-validator"(o){return J.isValidFilter(o)?"":O("Please add at least one condition")}}),values:A(C({},Rt),{"x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && !$deps[1]) ? "visible" : "hidden"}}'}}}]})}},usingAssignFormSchema:{type:"boolean"},assignFormSchema:{type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-component":"AssignedFieldsFormSchemaConfig","x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && $deps[1]) ? "visible" : "hidden"}}'}}}]}});w(this,"scope",{useCollectionDataSource:l.useCollectionDataSource,useNodeSavedConfig:Me});w(this,"components",{FilterDynamicComponent:tt,CollectionFieldset:To,AssignedFieldsFormSchemaConfig:Do,RadioWithTooltip:Oe})}createDefaultConfig(){return{usingAssignFormSchema:!0,assignFormSchema:{}}}}class kr extends ge{constructor(){super(...arguments);w(this,"title",'{{t("Delete record")}}');w(this,"type","destroy");w(this,"group","collection");w(this,"description",`{{t("Delete records of a collection. Could use variables in workflow context as filter. All records match the filter will be deleted.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:A(C({},ie),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...ie["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:A(C({},_e),{"x-validator"(o){return J.isValidFilter(o)?"":O("Please add at least one condition")}})}}});w(this,"scope",{useNodeSavedConfig:Me,useCollectionDataSource:l.useCollectionDataSource});w(this,"components",{FilterDynamicComponent:tt})}}const Sr=new l.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:l.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=l.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:l.SecondConFirm},{name:"assignFieldValues",Component:l.AssignedFieldValues},{name:"skipRequiredValidation",Component:l.SkipValidation},{name:"afterSuccessfulSubmission",Component:l.AfterSuccess,useVisible(){var t;const e=L.useFieldSchema();return ft.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.onSuccess)}},{name:"bindWorkflow",Component:l.WorkflowConfig},{name:"delete",sort:100,Component:l.RemoveButton,useComponentProps(){const{removeButtonProps:e}=l.useSchemaToolbar();return e}}]});function Ar({children:e,workflow:t,execution:o,nodes:r}){const s=l.usePlugin(de),i=s.triggers.get(t.type).components,a=r.reduce((c,{type:u})=>Object.assign(c,s.instructions.get(u).components),{});return n.jsx(Ie.Provider,{value:{workflow:t,nodes:r,execution:o},children:n.jsx(l.SchemaComponentOptions,{components:C(C({},i),a),children:e})})}class de extends l.Plugin{constructor(){super(...arguments);w(this,"triggers",new J.Registry);w(this,"instructions",new J.Registry);w(this,"getTriggersOptions",()=>Array.from(this.triggers.getEntities()).map(i=>{var[o,a]=i,c=a,{title:r}=c,s=Q(c,["title"]);return{value:o,label:r,color:"gold",options:s}}))}isWorkflowSync(o){var r,s;return(s=(r=this.triggers.get(o.type))==null?void 0:r.sync)!=null?s:o.sync}registerTrigger(o,r){if(typeof r=="function")this.triggers.register(o,new r);else if(r)this.triggers.register(o,r);else throw new TypeError("invalid trigger type to register")}registerInstruction(o,r){if(typeof r=="function")this.instructions.register(o,new r);else if(r instanceof ge)this.instructions.register(o,r);else throw new TypeError("invalid instruction type to register")}load(){return U(this,null,function*(){this.app.router.add("admin.workflow.workflows.id",{path:xe(":id"),element:n.jsx(Qt,{})}),this.app.router.add("admin.workflow.executions.id",{path:Ke(":id"),element:n.jsx(Yt,{})}),this.app.addComponents({WorkflowPage:Qt,ExecutionPage:Yt}),this.app.pluginSettingsManager.add(p,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${p}" })}}`,Component:Fn,aclSnippet:"pm.workflow.workflows"}),this.app.schemaSettingsManager.add(Sr),this.registerTrigger("collection",Ln),this.registerTrigger("schedule",rr),this.registerInstruction("calculation",ar),this.registerInstruction("condition",pr),this.registerInstruction("end",mr),this.registerInstruction("query",br),this.registerInstruction("create",wr),this.registerInstruction("update",Cr),this.registerInstruction("destroy",kr)})}}v.BaseTypeSets=Ze,v.Branch=Ge,v.CheckboxGroupWithTooltip=yr,v.CollectionBlockInitializer=Be,v.DetailsBlockProvider=hr,v.EXECUTION_STATUS=pe,v.ExecutionContextProvider=Ar,v.ExecutionStatusOptions=He,v.ExecutionStatusOptionsMap=Ye,v.FieldsSelect=Tt,v.FilterDynamicComponent=tt,v.FlowContext=Ie,v.Instruction=ge,v.JOB_STATUS=ae,v.JobButton=wt,v.JobStatusOptions=bt,v.JobStatusOptionsMap=qe,v.Node=Ut,v.NodeContext=vt,v.NodeDefaultView=Ct,v.RadioWithTooltip=Oe,v.RemoveButton=xt,v.SimpleDesigner=ko,v.Trigger=kt,v.ValueBlock=Ne,v.WorkflowVariableInput=so,v.WorkflowVariableJSON=Pn,v.WorkflowVariableRawTextArea=In,v.WorkflowVariableTextArea=$t,v.default=de,v.defaultFieldNames=Se,v.getCollectionFieldOptions=Ae,v.getWorkflowDetailPath=xe,v.getWorkflowExecutionsPath=Ke,v.linkNodes=At,v.nodesOptions=eo,v.scopeOptions=oo,v.systemOptions=no,v.traverseSchema=Ft,v.triggerOptions=to,v.useAvailableUpstreams=zt,v.useFlowContext=Y,v.useGetAriaLabelOfAddButton=gt,v.useGetCollectionFields=je,v.useNodeContext=ve,v.useNodeSavedConfig=Me,v.useRecordTriggerWorkflowsActionProps=Bn,v.useStyles=ne,v.useTrigger=St,v.useTriggerWorkflowsActionProps=Mn,v.useUpstreamScopes=Jt,v.useWorkflowAnyExecuted=lo,v.useWorkflowExecuted=Vn,v.useWorkflowVariableOptions=me,Object.defineProperties(v,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|