@nocobase/plugin-workflow 1.0.0-alpha.8 → 1.0.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.js +38 -35
- package/dist/client/nodes/condition.d.ts +3 -0
- package/dist/client/nodes/query.d.ts +12 -2
- package/dist/externalVersion.js +10 -10
- package/dist/locale/zh-CN.json +7 -2
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/server/Plugin.js +2 -3
- 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(
|
|
10
|
+
(function(b,r){typeof exports=="object"&&typeof module!="undefined"?r(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/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/react","lodash","@formily/shared","dayjs","@nocobase/evaluators/client","@formily/antd-v5"],r):(b=typeof globalThis!="undefined"?globalThis:b||self,r(b["@nocobase/plugin-workflow"]={},b.jsxRuntime,b["@nocobase/client"],b["@nocobase/utils"],b["react-router-dom"],b.react,b.antd,b["react-i18next"],b["@ant-design/icons"],b["@formily/core"],b["@formily/react"],b.lodash,b["@formily/shared"],b.dayjs,b["@nocobase/evaluators"],b["@formily/antd-v5"]))})(this,function(b,r,i,H,oe,g,y,Q,$,ye,j,ut,Dt,zo,De,Ho){"use strict";var wr=Object.defineProperty,Cr=Object.defineProperties;var kr=Object.getOwnPropertyDescriptors;var ct=Object.getOwnPropertySymbols;var jo=Object.prototype.hasOwnProperty,Wo=Object.prototype.propertyIsEnumerable;var Nt=(b,r,i)=>r in b?wr(b,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):b[r]=i,C=(b,r)=>{for(var i in r||(r={}))jo.call(r,i)&&Nt(b,i,r[i]);if(ct)for(var i of ct(r))Wo.call(r,i)&&Nt(b,i,r[i]);return b},T=(b,r)=>Cr(b,kr(r));var Lo=b=>typeof b=="symbol"?b:b+"",Z=(b,r)=>{var i={};for(var H in b)jo.call(b,H)&&r.indexOf(H)<0&&(i[H]=b[H]);if(b!=null&&ct)for(var H of ct(b))r.indexOf(H)<0&&Wo.call(b,H)&&(i[H]=b[H]);return i};var w=(b,r,i)=>(Nt(b,typeof r!="symbol"?r+"":r,i),i);var _=(b,r,i)=>new Promise((H,oe)=>{var g=$=>{try{Q(i.next($))}catch(ye){oe(ye)}},y=$=>{try{Q(i.throw($))}catch(ye){oe(ye)}},Q=$=>$.done?H($.value):Promise.resolve($.value).then(g,y);Q((i=i.apply(b,r)).next())});const Jo=g.createContext(null),dt={didCatch:!1,error:null};class Uo extends g.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=dt}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var o,n,s=arguments.length,a=new Array(s),l=0;l<s;l++)a[l]=arguments[l];(o=(n=this.props).onReset)===null||o===void 0||o.call(n,{args:a,reason:"imperative-api"}),this.setState(dt)}}componentDidCatch(t,o){var n,s;(n=(s=this.props).onError)===null||n===void 0||n.call(s,t,o)}componentDidUpdate(t,o){const{didCatch:n}=this.state,{resetKeys:s}=this.props;if(n&&o.error!==null&&_o(t.resetKeys,s)){var a,l;(a=(l=this.props).onReset)===null||a===void 0||a.call(l,{next:s,prev:t.resetKeys,reason:"keys"}),this.setState(dt)}}render(){const{children:t,fallbackRender:o,FallbackComponent:n,fallback:s}=this.props,{didCatch:a,error:l}=this.state;let c=t;if(a){const u={error:l,resetErrorBoundary:this.resetErrorBoundary};if(g.isValidElement(s))c=s;else if(typeof o=="function")c=o(u);else if(n)c=g.createElement(n,u);else throw l}return g.createElement(Jo.Provider,{value:{didCatch:a,error:l,resetErrorBoundary:this.resetErrorBoundary}},c)}}function _o(){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,n)=>!Object.is(o,t[n]))}const $e=g.createContext({});function Y(){return g.useContext($e)}const p="workflow";function N(e,t={}){return i.i18n.t(e,T(C({},t),{ns:p}))}function pt(){return Q.useTranslation(p)}const ne=i.createStyles(({css:e,token:t})=>({workflowPageClass:e`
|
|
11
11
|
flex-grow: 1;
|
|
12
12
|
overflow: hidden;
|
|
13
13
|
display: flex;
|
|
@@ -88,6 +88,9 @@
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
`,workflowVersionDropdownClass:e`
|
|
91
|
+
max-height: 80vh;
|
|
92
|
+
overflow-y: auto;
|
|
93
|
+
|
|
91
94
|
.ant-dropdown-menu-item {
|
|
92
95
|
.ant-dropdown-menu-title-content {
|
|
93
96
|
strong {
|
|
@@ -359,12 +362,12 @@
|
|
|
359
362
|
border-radius: 50%;
|
|
360
363
|
background-color: ${t.colorText};
|
|
361
364
|
color: ${t.colorBgContainer};
|
|
362
|
-
`}));function $t(e){var
|
|
365
|
+
`}));function $t(e){var v;const{upstream:t,branchIndex:o=null}=e,n=i.usePlugin(ce),s=i.useCompile(),a=i.useAPIClient(),{workflow:l,refresh:c}=(v=Y())!=null?v:{},u=Array.from(n.instructions.getValues()),{styles:d}=ne(),f=g.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(m=>{const k=u.filter(S=>S.group===m.key&&(S.isAvailable?S.isAvailable({engine:n,workflow:l,upstream:t,branchIndex:o}):!0));return T(C({},m),{type:"group",children:k.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(E=>({role:"button","aria-label":E.key,key:E.key,label:E.label})):null}))})}).filter(m=>m.children.length),[o,n,u,t,l]),h=g.useCallback(k=>_(this,[k],function*({keyPath:m}){var z,U,F;const S=m.pop(),E={},[A]=m,P=n.instructions.get(S);if(A){const{value:M}=(U=(z=P.options)==null?void 0:z.find(O=>O.key===A))!=null?U:{};Object.assign(E,typeof M=="function"?M():M)}l&&(yield a.resource("workflows.nodes",l.id).create({values:{type:S,upstreamId:(F=t==null?void 0:t.id)!=null?F:null,branchIndex:o,title:s(P.title),config:E}}),c())}),[a,o,n.instructions,c,t==null?void 0:t.id,l]),x=g.useMemo(()=>({onClick:h,items:s(f)}),[f,h]);return l?r.jsx("div",{className:d.addButtonClass,children:r.jsx(y.Dropdown,{trigger:["click"],menu:x,disabled:l.executed,overlayClassName:i.css`
|
|
363
366
|
.ant-dropdown-menu-root {
|
|
364
367
|
max-height: 30em;
|
|
365
368
|
overflow-y: auto;
|
|
366
369
|
}
|
|
367
|
-
`,children:r.jsx(y.Button,{"aria-label":e["aria-label"]||"add-button",shape:"circle",icon:r.jsx(
|
|
370
|
+
`,children:r.jsx(y.Button,{"aria-label":e["aria-label"]||"add-button",shape:"circle",icon:r.jsx($.PlusOutlined,{})})})}):null}const mt=(e,t)=>({getAriaLabel:g.useCallback(n=>["add-button",e==null?void 0:e.type,e==null?void 0:e.title,t!=null?String(t):"",n].filter(Boolean).join("-"),[t,e==null?void 0:e.title,e==null?void 0:e.type])}),Go=i.createStyles(({css:e,token:t})=>({container:e`
|
|
368
371
|
margin-bottom: 1.5em;
|
|
369
372
|
padding: 1em;
|
|
370
373
|
background-color: ${t.colorFillAlter};
|
|
@@ -389,11 +392,11 @@
|
|
|
389
392
|
p {
|
|
390
393
|
color: ${t.colorTextDescription};
|
|
391
394
|
}
|
|
392
|
-
`}));function
|
|
395
|
+
`}));function Mt(e){const{label:t,title:o,description:n}=e,{styles:s}=Go();return r.jsxs("div",{className:i.cx(s.container,e.className),children:[r.jsxs("dl",{children:[r.jsx("dt",{children:t}),r.jsx("dd",{children:r.jsx(y.Tag,{style:{background:"none"},children:o})})]}),n?r.jsx("p",{children:n}):null]})}function Yo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var It={exports:{}};/*!
|
|
393
396
|
Copyright (c) 2018 Jed Watson.
|
|
394
397
|
Licensed under the MIT License (MIT), see
|
|
395
398
|
http://jedwatson.github.io/classnames
|
|
396
|
-
*/(function(e){(function(){var t={}.hasOwnProperty;function o(){for(var
|
|
399
|
+
*/(function(e){(function(){var t={}.hasOwnProperty;function o(){for(var a="",l=0;l<arguments.length;l++){var c=arguments[l];c&&(a=s(a,n(c)))}return a}function n(a){if(typeof a=="string"||typeof a=="number")return a;if(typeof a!="object")return"";if(Array.isArray(a))return o.apply(null,a);if(a.toString!==Object.prototype.toString&&!a.toString.toString().includes("[native code]"))return a.toString();var l="";for(var c in a)t.call(a,c)&&a[c]&&(l=s(l,c));return l}function s(a,l){return l?a?a+" "+l:a+l:a}e.exports?(o.default=o,e.exports=o):window.classNames=o})()})(It);var qo=It.exports;const Ko=Yo(qo),Zo=i.createStyles(({css:e,token:t})=>({statusButtonClass:e`
|
|
397
400
|
border: none;
|
|
398
401
|
.ant-tag {
|
|
399
402
|
width: 100%;
|
|
@@ -405,7 +408,7 @@
|
|
|
405
408
|
}
|
|
406
409
|
`,noStatusButtonClass:e`
|
|
407
410
|
border-width: 2px;
|
|
408
|
-
`}));function
|
|
411
|
+
`}));function Me(e){var n;const{styles:t}=Zo();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:s,color:a}=e.statusMap[e.status];o=r.jsx(y.Tag,{color:a,children:s})}return r.jsx(y.Button,T(C({},e),{shape:"circle",size:"small",className:Ko(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const de={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},ze=[{value:de.QUEUEING,label:`{{t("Queueing", { ns: "${p}" })}}`,color:"blue",icon:r.jsx($.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${p}" })}}`},{value:de.STARTED,label:`{{t("On going", { ns: "${p}" })}}`,color:"gold",icon:r.jsx($.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${p}" })}}`},{value:de.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:r.jsx($.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${p}" })}}`},{value:de.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:r.jsx($.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${p}" })}}`},{value:de.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:r.jsx($.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${p}" })}}`},{value:de.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:r.jsx($.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${p}" })}}`},{value:de.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx($.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${p}" })}}`},{value:de.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx($.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${p}" })}}`},{value:de.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx($.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${p}" })}}`}],He=ze.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),ie={PENDING:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},ft=[{value:ie.PENDING,label:`{{t("Pending", { ns: "${p}" })}}`,color:"gold",icon:r.jsx($.ClockCircleOutlined,{})},{value:ie.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:r.jsx($.CheckOutlined,{})},{value:ie.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:r.jsx($.ExclamationOutlined,{})},{value:ie.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:r.jsx($.CloseOutlined,{})},{value:ie.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:r.jsx($.MinusOutlined,{rotate:90})},{value:ie.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx($.MinusOutlined,{rotate:45})},{value:ie.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx($.MinusOutlined,{})},{value:ie.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx($.RedoOutlined,{})}],Je=ft.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")}}function Qo(){const e=j.useForm(),t=i.useAPIClient(),o=i.useActionContext(),{refresh:n}=i.useResourceActionContext(),s=Ce(),{workflow:a}=Y();return{run(){return _(this,null,function*(){var c,u;if(a.executed){y.message.error(N("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}}),o.setFormValueChanged(!1),o.setVisible(!1),n()})}}}const ht=g.createContext({});function Ce(){return g.useContext(ht)}function Pt(e,t){const o=[];if(!e)return[];for(let n=e.upstream;n;n=n.upstream)(typeof t!="function"||t(n))&&o.push(n);return o}function Bt(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 Vt({data:e}){const{styles:t}=ne(),{getAriaLabel:o}=mt(e),n=i.usePlugin(ce),{Component:s=yt,end:a}=n.instructions.get(e.type);return r.jsx(ht.Provider,{value:e,children:r.jsxs("div",{className:i.cx(t.nodeBlockClass),children:[r.jsx(s,{data:e}),!a||typeof a=="function"&&!a(e)?r.jsx($t,{"aria-label":o(),upstream:e}):r.jsx("div",{className:"end-sign",children:r.jsx($.CloseOutlined,{})})]})})}function jt(){var d;const{t:e}=Q.useTranslation(),t=i.useAPIClient(),{workflow:o,nodes:n,refresh:s}=(d=Y())!=null?d:{},a=Ce(),{modal:l}=y.App.useApp();if(!o)return null;const c=t.resource("flow_nodes");function u(){return _(this,null,function*(){function f(){return _(this,null,function*(){var m;yield(m=c.destroy)==null?void 0:m.call(c,{filterByTk:a.id}),s()})}const h=n.filter(m=>m===a?!1:H.parse(m.config).parameters.filter(({key:E})=>E.startsWith(`$jobsMapByNodeKey.${a.key}.`)||E===`$jobsMapByNodeKey.${a.key}`).length);if(h.length){l.error({title:N("Can not delete"),content:N("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 v=!n.find(m=>m.upstream===a&&m.branchIndex!=null)?e("Are you sure you want to delete it?"):N("This node contains branches, deleting will also be preformed to them, are you sure?");l.confirm({title:e("Delete"),content:v,onOk:f})})}return o.executed?null:r.jsx(y.Button,{type:"text",shape:"circle",icon:r.jsx($.DeleteOutlined,{}),onClick:u,className:"workflow-node-remove-button"})}function Wt(){var a;const{execution:e,setViewJob:t}=Y(),{jobs:o}=(a=Ce())!=null?a:{},{styles:n}=ne();if(!e)return null;if(!o.length)return r.jsx(Me,{className:n.nodeJobButtonClass,disabled:!0});function s({key:l}){const c=o.find(u=>u.id==l);t(c)}return o.length>1?r.jsx(y.Dropdown,{menu:{items:o.map(l=>({key:l.id,label:r.jsxs(r.Fragment,{children:[r.jsx(Me,{statusMap:Je,status:l.status}),r.jsx("time",{children:H.str2moment(l.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),onClick:s,className:n.dropdownClass},children:r.jsx(Me,{statusMap:Je,status:o[o.length-1].status,className:n.nodeJobButtonClass})}):r.jsx(Me,{statusMap:Je,status:o[0].status,onClick:()=>t(o[0]),className:n.nodeJobButtonClass})}function Xo(){return{form:j.useForm()}}function yt(e){var F,M;const{data:t,children:o}=e,n=i.useCompile(),s=i.useAPIClient(),{workflow:a,refresh:l}=(F=Y())!=null?F:{},{styles:c}=ne(),d=i.usePlugin(ce).instructions.get(t.type),f=a.executed?'{{t("View")}}':'{{t("Configure")}}',h=n(d.title),[x,v]=g.useState((M=t.title)!=null?M:h),[m,k]=g.useState(!1),[S,E]=g.useState(!1),A=g.useMemo(()=>{const O=ut.cloneDeep(t.config);return ye.createForm({initialValues:O,disabled:a.executed})},[t,a]),P=g.useCallback(O=>{k(O),O||A.reset()},[A]),z=g.useCallback(function(O){return _(this,null,function*(){var L,J;const I=O||h;v(I),I!==t.title&&(yield(J=(L=s.resource("flow_nodes")).update)==null?void 0:J.call(L,{filterByTk:t.id,values:{title:I}}),l())})},[t]),U=g.useCallback(function(O){if(O.target===O.currentTarget){k(!0);return}const I=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let L=O.target;L&&L!==O.currentTarget&&L!==document.documentElement;L=L.parentNode)if(Array.from(L.classList).some(J=>I.has(J))){k(!0),O.stopPropagation();return}},[]);return r.jsxs("div",{className:i.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:[r.jsxs("div",{role:"button","aria-label":`${h}-${x}`,className:i.cx(c.nodeCardClass,{configuring:m}),onClick:U,children:[r.jsxs("div",{className:i.cx(c.nodeMetaClass,"workflow-node-meta"),children:[r.jsx(y.Tag,{children:h}),r.jsx("span",{className:"workflow-node-id",children:t.id})]}),r.jsx(y.Input.TextArea,{disabled:a.executed,value:x,onChange:O=>v(O.target.value),onBlur:O=>z(O.target.value),autoSize:!0}),r.jsx(jt,{}),r.jsx(Wt,{}),r.jsx(i.ActionContextProvider,{value:{visible:m,setVisible:P,formValueChanged:S,setFormValueChanged:E},children:r.jsx(i.FormProvider,{form:A,children:r.jsx(i.SchemaComponent,{distributed:!1,scope:T(C({},d.scope),{useFormProviderProps:Xo}),components:d.components,schema:{type:"void",properties:T(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:r.jsxs("div",{className:i.css`
|
|
409
412
|
display: flex;
|
|
410
413
|
justify-content: space-between;
|
|
411
414
|
|
|
@@ -420,7 +423,7 @@
|
|
|
420
423
|
code {
|
|
421
424
|
font-weight: normal;
|
|
422
425
|
}
|
|
423
|
-
`,children:[r.jsx("strong",{children:t.title}),r.jsx(y.Tooltip,{title:
|
|
426
|
+
`,children:[r.jsx("strong",{children:t.title}),r.jsx(y.Tooltip,{title:N("Variable key of node"),children:r.jsx(y.Tag,{children:r.jsx("code",{children:t.key})})})]}),"x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps","x-component":"Action.Drawer",properties:T(C({},d.description?{description:{type:"void","x-component":Mt,"x-component-props":{label:N("Node type"),title:d.title,description:d.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
|
|
424
427
|
.ant-input,
|
|
425
428
|
.ant-select,
|
|
426
429
|
.ant-cascader-picker,
|
|
@@ -432,34 +435,34 @@
|
|
|
432
435
|
min-width: 6em;
|
|
433
436
|
}
|
|
434
437
|
}
|
|
435
|
-
`},properties:d.fieldset},actions:a.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:
|
|
438
|
+
`},properties:d.fieldset},actions:a.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:Qo}}}}})}})}})})})]}),o]})}function Ue({from:e=null,entry:t=null,branchIndex:o=null,controller:n=null,className:s,end:a}){const{styles:l}=ne(),{getAriaLabel:c}=mt(e,o),u=[];for(let d=t;d;d=d.downstream)u.push(d);return r.jsxs("div",{className:i.cx("workflow-branch",l.branchClass,s),children:[r.jsx("div",{className:"workflow-branch-lines"}),n,r.jsx($t,{"aria-label":c(),upstream:e,branchIndex:o}),r.jsx("div",{className:"workflow-node-list",children:u.map(d=>r.jsx(Vt,{data:d},d.id))}),a?r.jsx("div",{className:"end-sign",children:r.jsx($.CloseOutlined,{})}):null]})}function Ro(){var a;const e=j.useForm(),t=i.useAPIClient(),{workflow:o}=(a=Y())!=null?a:{},n=i.useActionContext(),{refresh:s}=i.useResourceActionContext();return{run(){return _(this,null,function*(){if(o.executed){y.message.error(N("Trigger in executed workflow cannot be modified"));return}yield e.submit(),yield t.resource("workflows").update({filterByTk:o.id,values:{config:e.values}}),n.setFormValueChanged(!1),n.setVisible(!1),s()})}}}class gt{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 en(){const e=i.useCompile(),{workflow:t,execution:o}=Y(),{styles:n}=ne(),s=bt();return o?r.jsx(i.SchemaComponent,{schema:{type:"void",name:"execution","x-component":"Action","x-component-props":{title:r.jsx($.InfoOutlined,{}),shape:"circle",size:"small",className:n.nodeJobButtonClass,type:"primary"},properties:{[o.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:r.jsxs("div",{className:i.cx(n.nodeTitleClass),children:[r.jsx(y.Tag,{children:e(s.title)}),r.jsx("strong",{children:t.title}),r.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:i.css`
|
|
436
439
|
padding: 1em;
|
|
437
440
|
background-color: #eee;
|
|
438
|
-
`},"x-read-pretty":!0}}}}}}):null}function
|
|
441
|
+
`},"x-read-pretty":!0}}}}}}):null}function tn(){return{form:j.useForm()}}const on=()=>{const e=i.useAPIClient(),{workflow:t,refresh:o}=Y(),[n,s]=g.useState(""),[a,l]=g.useState(!1),[c,u]=g.useState(!1),{styles:d}=ne(),f=i.useCompile(),h=bt(),x=f(h.title),{fieldset:v,scope:m,components:k}=h,S=t.executed?'{{t("View")}}':'{{t("Configure")}}',E=N("Trigger");g.useEffect(()=>{var F,M;t&&s((M=(F=t.triggerTitle)!=null?F:t.title)!=null?M:x)},[t]);const A=g.useMemo(()=>{const F=ut.cloneDeep(t.config);return ye.createForm({initialValues:F,disabled:t.executed})},[t]),P=g.useCallback(F=>{l(F),F||A.reset()},[A]),z=g.useCallback(function(F){return _(this,null,function*(){const M=F||x;s(M),M!==t.triggerTitle&&(yield e.resource("workflows").update({filterByTk:t.id,values:{triggerTitle:M}}),o())})},[t]),U=g.useCallback(function(F){var O;if(F.target===F.currentTarget){l(!0);return}const M=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let I=F.target;I&&I!==F.currentTarget;I=I.parentNode)if(Array.from((O=I.classList)!=null?O:[]).some(L=>M.has(L))){l(!0),F.stopPropagation();return}},[]);return r.jsxs("div",{role:"button","aria-label":`${E}-${n}`,className:i.cx(d.nodeCardClass),onClick:U,children:[r.jsx("div",{className:i.cx(d.nodeMetaClass,"workflow-node-meta"),children:r.jsx(y.Tag,{color:"gold",children:E})}),r.jsx("div",{children:r.jsx(y.Input.TextArea,{value:n,onChange:F=>s(F.target.value),onBlur:F=>z(F.target.value),autoSize:!0,disabled:t.executed})}),r.jsx(en,{}),r.jsx(i.ActionContextProvider,{value:{visible:a,setVisible:P,formValueChanged:c,setFormValueChanged:u},children:r.jsx(i.FormProvider,{form:A,children:r.jsx(i.SchemaComponent,{scope:T(C({},m),{useFormProviderProps:tn}),components:k,schema:{name:`workflow-trigger-${t.id}`,type:"void",properties:{config:{type:"void","x-content":S,"x-component":y.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},drawer:{type:"void",title:E,"x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps",properties:T(C({},h.description?{description:{type:"void","x-component":Mt,"x-component-props":{label:N("Trigger type"),title:h.title,description:h.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
|
|
439
442
|
.ant-select.auto-width {
|
|
440
443
|
width: auto;
|
|
441
444
|
min-width: 6em;
|
|
442
445
|
}
|
|
443
|
-
`},properties:
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
`),children:r.jsx(Ue,{entry:e})}),r.jsx("div",{className:t.terminalClass,children:D("End")})]})})}),r.jsx("div",{className:"workflow-canvas-zoomer",children:r.jsx(y.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:n,onChange:s})})]})}function bt(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 xt(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{xt(e.properties[o],t)})}function xe(e){return`/admin/workflow/workflows/${e}`}function _e(e){return`/admin/workflow/executions/${e}`}function Ro(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const s=o.get(n.nodeId);s.jobs.push(n),n.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((s,a)=>s.id-a.id)})}function en(){const{instructions:e}=i.usePlugin(ce),t=i.useCompile(),{viewJob:o,setViewJob:n}=Y(),{styles:s}=ne(),{node:a={}}=o!=null?o:{},l=e.get(a.type);return r.jsx(i.ActionContextProvider,{value:{visible:!!o,setVisible:n},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`${o==null?void 0:o.id}-${o==null?void 0:o.updatedAt}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:r.jsxs("div",{className:s.nodeTitleClass,children:[r.jsx(y.Tag,{children:t(l==null?void 0:l.title)}),r.jsx("strong",{children:a.title}),r.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:mt,"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 tn(e){const{execution:t}=Y(),o=i.useAPIClient(),n=oe.useNavigate(),{styles:s}=ne(),[a,l]=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})=>{l(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&&n(_e(f))},[t]);return t?r.jsx(y.Dropdown,{menu:{onClick:d,defaultSelectedKeys:[`${t.id}`],className:i.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...a].map(f=>({key:f.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${f.id}`}),r.jsx("time",{children:H.str2moment(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(Ee,{statusMap:He,status:f.status})})}))},children:r.jsxs(y.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(E.DownOutlined,{})]})}):null}function on(){var A;const{t:e}=Q.useTranslation(),t=i.useCompile(),{data:o,loading:n,refresh:s}=i.useResourceActionContext(),{setTitle:a}=i.useDocumentTitle(),[l,c]=b.useState(null),u=i.useApp(),d=i.useAPIClient();b.useEffect(()=>{var M;const{workflow:F}=(M=o==null?void 0:o.data)!=null?M:{};a==null||a(`${F!=null&&F.title?`${F.title} - `:""}${D("Execution history")}`)},[o==null?void 0:o.data]);const f=b.useCallback(()=>{y.Modal.confirm({title:D("Cancel the execution"),icon:r.jsx(E.ExclamationCircleFilled,{}),content:D("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(F=>{console.error(F.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return n?r.jsx(y.Spin,{}):r.jsx(y.Result,{status:"404",title:"Not found"});const P=(A=o==null?void 0:o.data)!=null?A:{},{jobs:h=[],workflow:z={}}=P,U=z,{nodes:v=[],revisions:x=[]}=U,m=Z(U,["nodes","revisions"]),k=Z(P,["jobs","workflow"]);bt(v),Ro(v,h);const S=v.find(F=>!F.upstream),N=He[k.status];return r.jsxs($e.Provider,{value:{workflow:m.type?m:null,nodes:v,execution:k,viewJob:l,setViewJob:c},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(y.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:u.pluginSettingsManager.getRoutePath("workflow"),children:D("Workflow")})},{title:r.jsx(y.Tooltip,{title:`Key: ${m.key}`,children:r.jsx(oe.Link,{to:xe(m.id),children:m.title})})},{title:r.jsx(tn,{})}]})}),r.jsxs("aside",{children:[r.jsx(y.Tag,{color:N.color,children:t(N.label)}),k.status?null:r.jsx(y.Tooltip,{title:D("Cancel the execution"),children:r.jsx(y.Button,{type:"link",danger:!0,onClick:f,shape:"circle",size:"small",icon:r.jsx(E.StopOutlined,{})})}),r.jsx("time",{children:H.str2moment(k.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(Wt,{entry:S}),r.jsx(en,{})]})}const Lt=()=>{const e=oe.useParams(),{styles:t}=ne();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`execution_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:e,appends:["jobs","workflow","workflow.nodes"]}}},"x-component":"ExecutionCanvas"}}},components:{ExecutionCanvas:on}})})},zt=()=>{const{t:e}=Q.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext();return r.jsx(oe.Link,{to:_e(t),onClick:()=>o(!1),children:e("View")})},nn={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}=i.useActionContext();return r.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:ze}}]},Ht={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:nn,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:t,defaultRequest:o}=i.useResourceActionContext(),{resource:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext();return{run(){return _(this,null,function*(){var l;yield n.destroy({filter:(l=o.params)==null?void 0:l.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 Jt(e){var a;const o=i.useCompile()(e.label),n=b.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:s}=(a=He[e.value])!=null?a:{};return r.jsx(y.Tag,{color:s,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function rn(e){const t=i.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Jt,C({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function sn(t){var e=Z(t,[]);const o=e.multiple?"multiple":null;return r.jsx(y.Select,T(C({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Jt,children:ze.filter(n=>!!n.value&&n.value!==de.ABORTED).map(n=>r.jsx(y.Select.Option,T(C({},n),{children:r.jsx(rn,C({},n))}),n.value))}))}function Ut(e){const{t}=Q.useTranslation(),{refresh:o}=i.useResourceActionContext(),{resource:n}=i.useResourceContext(),s=i.useRecord(),a=b.useCallback(()=>{y.Modal.confirm({title:D("Cancel the execution"),icon:r.jsx(E.ExclamationCircleFilled,{}),content:D("Are you sure you want to cancel the execution?"),onOk:()=>{n.cancel({filterByTk:s.id}).then(()=>{y.message.success(t("Operation succeeded")),o()}).catch(l=>{console.error(l.data.error)})}})},[s]);return r.jsxs("div",{className:i.css`
|
|
446
|
+
`},properties:v},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:Ro}}}})})}}}})})})]})};function bt(){const e=i.usePlugin(ce),{workflow:t}=Y();return e.triggers.get(t.type)}function Lt({entry:e}){const{styles:t}=ne(),{workflow:o}=Y(),[n,s]=g.useState(100);return r.jsxs("div",{className:"workflow-canvas-wrapper",children:[r.jsx(Uo,{FallbackComponent:i.ErrorFallback,onError:console.error,children:r.jsx("div",{className:"workflow-canvas",style:{zoom:n/100},children:r.jsx("div",{className:i.cx(t.branchBlockClass,i.css`
|
|
447
|
+
margin-top: 0 !important;
|
|
448
|
+
`),children:r.jsxs("div",{className:t.branchClass,children:[o!=null&&o.executed?r.jsx(y.Alert,{type:"warning",message:N("Executed workflow cannot be modified. Could be copied to a new version to modify."),showIcon:!0,className:i.css`
|
|
449
|
+
margin-bottom: 1em;
|
|
450
|
+
`}):null,r.jsx(on,{}),r.jsx("div",{className:i.cx(t.branchBlockClass,i.css`
|
|
451
|
+
margin-top: 0 !important;
|
|
452
|
+
`),children:r.jsx(Ue,{entry:e})}),r.jsx("div",{className:t.terminalClass,children:N("End")})]})})})}),r.jsx("div",{className:"workflow-canvas-zoomer",children:r.jsx(y.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:n,onChange:s})})]})}function vt(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 xt(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{xt(e.properties[o],t)})}function ve(e){return`/admin/workflow/workflows/${e}`}function _e(e){return`/admin/workflow/executions/${e}`}function nn(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const s=o.get(n.nodeId);s.jobs.push(n),n.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((s,a)=>s.id-a.id)})}function rn(){const{instructions:e}=i.usePlugin(ce),t=i.useCompile(),{viewJob:o,setViewJob:n}=Y(),{styles:s}=ne(),{node:a={}}=o!=null?o:{},l=e.get(a.type);return r.jsx(i.ActionContextProvider,{value:{visible:!!o,setVisible:n},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`${o==null?void 0:o.id}-${o==null?void 0:o.updatedAt}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:r.jsxs("div",{className:s.nodeTitleClass,children:[r.jsx(y.Tag,{children:t(l==null?void 0:l.title)}),r.jsx("strong",{children:a.title}),r.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:ft,"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 sn(e){const{execution:t}=Y(),o=i.useAPIClient(),n=oe.useNavigate(),{styles:s}=ne(),[a,l]=g.useState([]),[c,u]=g.useState([]);g.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{l(f.data)}).catch(()=>{})},[t]),g.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=g.useCallback(({key:f})=>{f!=t.id&&n(_e(f))},[t]);return t?r.jsx(y.Dropdown,{menu:{onClick:d,defaultSelectedKeys:[`${t.id}`],className:i.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...a].map(f=>({key:f.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${f.id}`}),r.jsx("time",{children:H.str2moment(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(Me,{statusMap:He,status:f.status})})}))},children:r.jsxs(y.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx($.DownOutlined,{})]})}):null}function ln(){var A;const{t:e}=Q.useTranslation(),t=i.useCompile(),{data:o,loading:n,refresh:s}=i.useResourceActionContext(),{setTitle:a}=i.useDocumentTitle(),[l,c]=g.useState(null),u=i.useApp(),d=i.useAPIClient();g.useEffect(()=>{var M;const{workflow:F}=(M=o==null?void 0:o.data)!=null?M:{};a==null||a(`${F!=null&&F.title?`${F.title} - `:""}${N("Execution history")}`)},[o==null?void 0:o.data]);const f=g.useCallback(()=>{y.Modal.confirm({title:N("Cancel the execution"),icon:r.jsx($.ExclamationCircleFilled,{}),content:N("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(F=>{console.error(F.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return n?r.jsx(y.Spin,{}):r.jsx(y.Result,{status:"404",title:"Not found"});const P=(A=o==null?void 0:o.data)!=null?A:{},{jobs:h=[],workflow:z={}}=P,U=z,{nodes:x=[],revisions:v=[]}=U,m=Z(U,["nodes","revisions"]),k=Z(P,["jobs","workflow"]);vt(x),nn(x,h);const S=x.find(F=>!F.upstream),E=He[k.status];return r.jsxs($e.Provider,{value:{workflow:m.type?m:null,nodes:x,execution:k,viewJob:l,setViewJob:c},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(y.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:u.pluginSettingsManager.getRoutePath("workflow"),children:N("Workflow")})},{title:r.jsx(y.Tooltip,{title:`Key: ${m.key}`,children:r.jsx(oe.Link,{to:ve(m.id),children:m.title})})},{title:r.jsx(sn,{})}]})}),r.jsxs("aside",{children:[r.jsx(y.Tag,{color:E.color,children:t(E.label)}),k.status?null:r.jsx(y.Tooltip,{title:N("Cancel the execution"),children:r.jsx(y.Button,{type:"link",danger:!0,onClick:f,shape:"circle",size:"small",icon:r.jsx($.StopOutlined,{})})}),r.jsx("time",{children:H.str2moment(k.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(Lt,{entry:S}),r.jsx(rn,{})]})}const zt=()=>{const e=oe.useParams(),{styles:t}=ne();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`execution_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:e,appends:["jobs","workflow","workflow.nodes"]}}},"x-component":"ExecutionCanvas"}}},components:{ExecutionCanvas:ln}})})},Ht=()=>{const{t:e}=Q.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext();return r.jsx(oe.Link,{to:_e(t),onClick:()=>o(!1),children:e("View")})},an={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}=i.useActionContext();return r.jsx(oe.Link,{to:ve(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:ze}}]},Jt={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:an,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:t,defaultRequest:o}=i.useResourceActionContext(),{resource:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext();return{run(){return _(this,null,function*(){var l;yield n.destroy({filter:(l=o.params)==null?void 0:l.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 Ut(e){var a;const o=i.useCompile()(e.label),n=g.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:s}=(a=He[e.value])!=null?a:{};return r.jsx(y.Tag,{color:s,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function cn(e){const t=i.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Ut,C({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function un(t){var e=Z(t,[]);const o=e.multiple?"multiple":null;return r.jsx(y.Select,T(C({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Ut,children:ze.filter(n=>!!n.value&&n.value!==de.ABORTED).map(n=>r.jsx(y.Select.Option,T(C({},n),{children:r.jsx(cn,C({},n))}),n.value))}))}function _t(e){const{t}=Q.useTranslation(),{refresh:o}=i.useResourceActionContext(),{resource:n}=i.useResourceContext(),s=i.useRecord(),a=g.useCallback(()=>{y.Modal.confirm({title:N("Cancel the execution"),icon:r.jsx($.ExclamationCircleFilled,{}),content:N("Are you sure you want to cancel the execution?"),onOk:()=>{n.cancel({filterByTk:s.id}).then(()=>{y.message.success(t("Operation succeeded")),o()}).catch(l=>{console.error(l.data.error)})}})},[s]);return r.jsxs("div",{className:i.css`
|
|
450
453
|
display: flex;
|
|
451
|
-
`,children:[e.children,s.status?null:r.jsx(y.Tooltip,{title:D("Cancel the execution"),children:r.jsx(y.Button,{type:"link",danger:!0,onClick:a,shape:"circle",size:"small",icon:r.jsx(E.StopOutlined,{})})})]})}function _t(){const e=i.useResourceActionContext();return{onClick(){return _(this,null,function*(){var o;(o=e==null?void 0:e.refresh)==null||o.call(e)})}}}function ln(n){var s=n,{request:e,filter:t={}}=s,o=Z(s,["request","filter"]);var c;const{workflow:a}=Y(),l=T(C({},o),{request:T(C({},e),{params:T(C({},e==null?void 0:e.params),{filter:T(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,C({},l))}function an(){var F;const e=oe.useNavigate(),{t}=Q.useTranslation(),o=i.useApp(),{data:n,refresh:s,loading:a}=i.useResourceActionContext(),{resource:l}=i.useResourceContext(),{setTitle:c}=i.useDocumentTitle(),[u,d]=b.useState(!1),{styles:f}=ne(),{modal:h}=y.App.useApp();if(b.useEffect(()=>{var I;const{title:O}=(I=n==null?void 0:n.data)!=null?I:{};c==null||c(`${D("Workflow")}${O?`: ${O}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return a?r.jsx(y.Spin,{}):r.jsx(y.Result,{status:"404",title:"Not found",extra:r.jsx(y.Button,{onClick:()=>e(-1),children:D("Go back")})});const M=(F=n==null?void 0:n.data)!=null?F:{},{nodes:v=[],revisions:x=[]}=M,m=Z(M,["nodes","revisions"]);bt(v);const k=v.find(O=>!O.upstream);function S({key:O}){O!=m.id&&e(xe(O))}function N(O){return _(this,null,function*(){yield l.update({filterByTk:m.id,values:{enabled:O}}),s()})}function A(){return _(this,null,function*(){const{data:{data:O}}=yield l.revision({filterByTk:m.id,filter:{key:m.key}});y.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${O.id}`)})}function P(){return _(this,null,function*(){const O=m.current?D("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:O,onOk(){return _(this,null,function*(){var L;yield l.destroy({filterByTk:m.id}),y.message.success(t("Operation succeeded")),e(m.current?o.pluginSettingsManager.getRoutePath("workflow"):xe((L=x.find(J=>J.current))==null?void 0:L.id))})}})})}function z(I){return _(this,arguments,function*({key:O}){switch(O){case"history":d(!0);return;case"revision":return A();case"delete":return P()}})}const U=m.executed&&!x.find(O=>!O.executed&&new Date(O.createdAt)>new Date(m.createdAt));return r.jsxs($e.Provider,{value:{workflow:m,nodes:v,refresh:s},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(y.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:D("Workflow")})},{title:r.jsx(y.Tooltip,{title:`Key: ${m.key}`,children:r.jsx("strong",{children:m.title})})}]})}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(y.Dropdown,{trigger:["click"],menu:{onClick:S,defaultSelectedKeys:[`${m.id}`],className:i.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:x.sort((O,I)=>I.id-O.id).map((O,I)=>({role:"button","aria-label":`version-${I}`,key:`${O.id}`,icon:O.current?r.jsx(E.RightOutlined,{}):null,className:i.cx({executed:O.executed,unexecuted:!O.executed,enabled:O.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${O.id}`}),r.jsx("time",{children:H.str2moment(O.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(y.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:D("Version")}),r.jsx("span",{children:m!=null&&m.id?`#${m.id}`:null}),r.jsx(E.DownOutlined,{})]})})}),r.jsx(y.Switch,{checked:m.enabled,onChange:N,checkedChildren:D("On"),unCheckedChildren:D("Off")}),r.jsx(y.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:D("Execution history"),disabled:!m.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:D("Copy to new version"),disabled:!U},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")}],onClick:z},children:r.jsx(y.Button,{"aria-label":"more",type:"text",icon:r.jsx(E.EllipsisOutlined,{})})}),r.jsx(i.ActionContextProvider,{value:{visible:u,setVisible:d},children:r.jsx(i.SchemaComponent,{schema:Ht,components:{ExecutionResourceProvider:ln,ExecutionLink:zt,ExecutionStatusColumn:Ut},scope:{useRefreshActionProps:_t}})})]})]}),r.jsx(Wt,{entry:k})]})}const Gt=()=>{const e=oe.useParams(),{styles:t}=ne();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:an}})})},cn=n=>{var s=n,{request:e,filter:t={}}=s,o=Z(s,["request","filter"]);var c;const a=i.useRecord(),l=T(C({},o),{request:T(C({},e),{params:T(C({},e==null?void 0:e.params),{filter:T(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,C({},l))},un=()=>{const{t:e}=Q.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext(),{getAriaLabel:n}=i.useGetAriaLabelOfAction("Configure");return r.jsx(oe.Link,{"aria-label":n(),to:xe(t),onClick:()=>o(!1),children:e("Configure")})};function dn(n){var s=n,{component:e="div",children:t}=s,o=Z(s,["component","children"]);const[a,l]=b.useState(!1),c=j.useFieldSchema();return r.jsxs(i.ActionContextProvider,{value:{visible:a,setVisible:l,fieldSchema:c},children:[b.createElement(e,T(C({},o),{onClick(){l(!0)}}),t),r.jsx(i.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}function pn({data:e}){const{label:t,color:o,options:n}=e,s=i.useCompile();return r.jsxs(y.Space,{direction:"vertical",children:[r.jsx(y.Tag,{color:o,children:s(t)}),r.jsx(y.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:s(n.description)})]})}const Yt={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:pn,popupMatchSelectWidth:!0,listHeight:300},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"}]},pe={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}}}}},mn={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Yt,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:Yt},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:t}=i.useResourceContext(),o=i.useResourceActionContext();return{run(){return _(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:pe.title,type:pe.type,sync:pe.sync,description:pe.description,options:pe.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=i.useRecord();return b.createElement("a",C({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:Ht}}}},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:pe.title,enabled:pe.enabled,sync:pe.sync,description:pe.description,options:pe.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:t}=i.useResourceActionContext(),{resource:o,targetKey:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext(),{[n]:a}=i.useRecord(),{values:l}=j.useForm();return{run(){return _(this,null,function*(){yield o.revision({filterByTk:a,values:l}),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 fn(e){const t=j.useField(),o=i.useRecord(),n=i.usePlugin(ce);return j.useFormEffects(s=>{he.onFieldChange("type",a=>{let l=o.id||!a.value;if(a.value){const c=n.triggers.get(a.value);c.sync!=null?(l=!0,t.setValue(c.sync)):t.setInitialValue(!1)}t.setPattern(l?"disabled":"editable")})}),b.useEffect(()=>{if(o.id){t.setPattern("disabled");const s=n.triggers.get(o.type);s.sync!=null?t.setValue(s.sync):t.setInitialValue(!1)}},[o.id,t,n.triggers]),r.jsx(Be,C({},e))}function hn(e){const t=i.useApp();e.visible=!!(i.usePlugin("multi-app-share-collection")||t.name!=="main")}function yn(){const e=b.useContext(i.SchemaComponentContext),{getTriggersOptions:t}=i.usePlugin(ce);return r.jsx(y.Card,{bordered:!1,children:r.jsx(i.SchemaComponentContext.Provider,{value:T(C({},e),{designable:!1}),children:r.jsx(i.SchemaComponent,{schema:mn,components:{WorkflowLink:un,ExecutionResourceProvider:cn,ExecutionLink:zt,OpenDrawer:dn,ExecutionStatusSelect:sn,SyncOptionSelect:fn,ExecutionStatusColumn:Ut,Tooltip:y.Tooltip},scope:{getTriggersOptions:t,useWorkflowSyncAction:hn,useRefreshActionProps:_t}})})})}function gn(n){var s=n,{collection:e,dataPath:t}=s,o=Z(s,["collection","dataPath"]);const{insert:a}=i.useSchemaInitializer(),{getTemplateSchemaByMode:l}=i.useSchemaTemplateManager(),{getCollection:c}=i.useCollectionManager_deprecated(),u=i.useRecordCollectionDataSourceItems("FormItem");let d;if(typeof e=="string"){const[h,v]=i.parseCollectionName(e);d=c(v,h)}else d=e;function f(v){return _(this,arguments,function*({item:h}){const x=h.template?yield l(h):null,m={type:"void",name:Dt.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:x||{type:"void","x-component":"Grid","x-initializer":"details:configureFields",properties:{}}}}}};xt(m,k=>{k["x-uid"]&&delete k["x-uid"]}),a(m)})}return r.jsx(i.SchemaInitializerItem,T(C({},o),{onClick:f,items:u}))}function Me(e){var a;const t=i.useSchemaInitializerItem(),o=(a=e==null?void 0:e.collection)!=null?a:t.collection;let n,s;if(typeof o=="string"){const l=i.parseCollectionName(o);n=l[0],s=l[1]}else s=o;return r.jsx(i.CollectionProvider_deprecated,{dataSource:n,collection:s,children:r.jsx(gn,C(C({},t),e))})}function bn(){return!0}const vt=j.observer(e=>{const d=e,{filter:t=bn}=d,o=Z(d,["filter"]),n=i.useCompile(),{getCollectionFields:s}=i.useCollectionManager_deprecated(),{values:a}=j.useForm(),[l,c]=i.parseCollectionName(a==null?void 0:a.collection),u=s(c,l);return r.jsx(y.Select,T(C({popupMatchSelectWidth:!1},o),{options:u.filter(t).map(f=>{var h;return{label:n((h=f.uiSchema)==null?void 0:h.title),value:f.name}})}))},{displayName:"FieldsSelect"}),le={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"},qt={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:i.css`
|
|
454
|
+
`,children:[e.children,s.status?null:r.jsx(y.Tooltip,{title:N("Cancel the execution"),children:r.jsx(y.Button,{type:"link",danger:!0,onClick:a,shape:"circle",size:"small",icon:r.jsx($.StopOutlined,{})})})]})}function Gt(){const e=i.useResourceActionContext();return{onClick(){return _(this,null,function*(){var o;(o=e==null?void 0:e.refresh)==null||o.call(e)})}}}function dn(n){var s=n,{request:e,filter:t={}}=s,o=Z(s,["request","filter"]);var c;const{workflow:a}=Y(),l=T(C({},o),{request:T(C({},e),{params:T(C({},e==null?void 0:e.params),{filter:T(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,C({},l))}function pn(){var F;const e=oe.useNavigate(),{t}=Q.useTranslation(),o=i.useApp(),{data:n,refresh:s,loading:a}=i.useResourceActionContext(),{resource:l}=i.useResourceContext(),{setTitle:c}=i.useDocumentTitle(),[u,d]=g.useState(!1),{styles:f}=ne(),{modal:h}=y.App.useApp();if(g.useEffect(()=>{var I;const{title:O}=(I=n==null?void 0:n.data)!=null?I:{};c==null||c(`${N("Workflow")}${O?`: ${O}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return a?r.jsx(y.Spin,{}):r.jsx(y.Result,{status:"404",title:"Not found",extra:r.jsx(y.Button,{onClick:()=>e(-1),children:N("Go back")})});const M=(F=n==null?void 0:n.data)!=null?F:{},{nodes:x=[],revisions:v=[]}=M,m=Z(M,["nodes","revisions"]);vt(x);const k=x.find(O=>!O.upstream);function S({key:O}){O!=m.id&&e(ve(O))}function E(O){return _(this,null,function*(){yield l.update({filterByTk:m.id,values:{enabled:O}}),s()})}function A(){return _(this,null,function*(){const{data:{data:O}}=yield l.revision({filterByTk:m.id,filter:{key:m.key}});y.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${O.id}`)})}function P(){return _(this,null,function*(){const O=m.current?N("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:O,onOk(){return _(this,null,function*(){var L;yield l.destroy({filterByTk:m.id}),y.message.success(t("Operation succeeded")),e(m.current?o.pluginSettingsManager.getRoutePath("workflow"):ve((L=v.find(J=>J.current))==null?void 0:L.id))})}})})}function z(I){return _(this,arguments,function*({key:O}){switch(O){case"history":d(!0);return;case"revision":return A();case"delete":return P()}})}const U=m.executed&&!v.find(O=>!O.executed&&new Date(O.createdAt)>new Date(m.createdAt));return r.jsxs($e.Provider,{value:{workflow:m,nodes:x,refresh:s},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(y.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:N("Workflow")})},{title:r.jsx(y.Tooltip,{title:`Key: ${m.key}`,children:r.jsx("strong",{children:m.title})})}]})}),r.jsxs("aside",{children:[r.jsx(y.Dropdown,{className:"workflow-versions",trigger:["click"],menu:{onClick:S,defaultSelectedKeys:[`${m.id}`],className:i.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:v.sort((O,I)=>I.id-O.id).map((O,I)=>({role:"button","aria-label":`version-${I}`,key:`${O.id}`,icon:O.current?r.jsx($.RightOutlined,{}):null,className:i.cx({executed:O.executed,unexecuted:!O.executed,enabled:O.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${O.id}`}),r.jsx("time",{children:H.str2moment(O.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(y.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:N("Version")}),r.jsx("span",{children:m!=null&&m.id?`#${m.id}`:null}),r.jsx($.DownOutlined,{})]})}),r.jsx(y.Switch,{checked:m.enabled,onChange:E,checkedChildren:N("On"),unCheckedChildren:N("Off")}),r.jsx(y.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:N("Execution history"),disabled:!m.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:N("Copy to new version"),disabled:!U},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")}],onClick:z},children:r.jsx(y.Button,{"aria-label":"more",type:"text",icon:r.jsx($.EllipsisOutlined,{})})}),r.jsx(i.ActionContextProvider,{value:{visible:u,setVisible:d},children:r.jsx(i.SchemaComponent,{schema:Jt,components:{ExecutionResourceProvider:dn,ExecutionLink:Ht,ExecutionStatusColumn:_t},scope:{useRefreshActionProps:Gt}})})]})]}),r.jsx(Lt,{entry:k})]})}const Yt=()=>{const e=oe.useParams(),{styles:t}=ne();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:pn}})})},mn=n=>{var s=n,{request:e,filter:t={}}=s,o=Z(s,["request","filter"]);var c;const a=i.useRecord(),l=T(C({},o),{request:T(C({},e),{params:T(C({},e==null?void 0:e.params),{filter:T(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,C({},l))},fn=()=>{const{t:e}=Q.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext(),{getAriaLabel:n}=i.useGetAriaLabelOfAction("Configure");return r.jsx(oe.Link,{"aria-label":n(),to:ve(t),onClick:()=>o(!1),children:e("Configure")})};function hn(n){var s=n,{component:e="div",children:t}=s,o=Z(s,["component","children"]);const[a,l]=g.useState(!1),c=j.useFieldSchema();return r.jsxs(i.ActionContextProvider,{value:{visible:a,setVisible:l,fieldSchema:c},children:[g.createElement(e,T(C({},o),{onClick(){l(!0)}}),t),r.jsx(i.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}function yn({data:e}){const{label:t,color:o,options:n}=e,s=i.useCompile();return r.jsxs(y.Space,{direction:"vertical",children:[r.jsx(y.Tag,{color:o,children:s(t)}),r.jsx(y.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:s(n.description)})]})}const qt={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:yn,popupMatchSelectWidth:!0,listHeight:300},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"}]},pe={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}}}}},gn={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:qt,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:qt},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:t}=i.useResourceContext(),o=i.useResourceActionContext();return{run(){return _(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:pe.title,type:pe.type,sync:pe.sync,description:pe.description,options:pe.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=i.useRecord();return g.createElement("a",C({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:Jt}}}},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:pe.title,enabled:pe.enabled,sync:pe.sync,description:pe.description,options:pe.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:t}=i.useResourceActionContext(),{resource:o,targetKey:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext(),{[n]:a}=i.useRecord(),{values:l}=j.useForm();return{run(){return _(this,null,function*(){yield o.revision({filterByTk:a,values:l}),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 bn(e){const t=j.useField(),o=i.useRecord(),n=i.usePlugin(ce);return j.useFormEffects(s=>{ye.onFieldChange("type",a=>{let l=o.id||!a.value;if(a.value){const c=n.triggers.get(a.value);c.sync!=null?(l=!0,t.setValue(c.sync)):t.setInitialValue(!1)}t.setPattern(l?"disabled":"editable")})}),g.useEffect(()=>{if(o.id){t.setPattern("disabled");const s=n.triggers.get(o.type);s.sync!=null?t.setValue(s.sync):t.setInitialValue(!1)}},[o.id,t,n.triggers]),r.jsx(Te,C({},e))}function vn(e){const t=i.useApp();e.visible=!!(i.usePlugin("multi-app-share-collection")||t.name!=="main")}function xn(){const e=g.useContext(i.SchemaComponentContext),{getTriggersOptions:t}=i.usePlugin(ce);return r.jsx(y.Card,{bordered:!1,children:r.jsx(i.SchemaComponentContext.Provider,{value:T(C({},e),{designable:!1}),children:r.jsx(i.SchemaComponent,{schema:gn,components:{WorkflowLink:fn,ExecutionResourceProvider:mn,ExecutionLink:Ht,OpenDrawer:hn,ExecutionStatusSelect:un,SyncOptionSelect:bn,ExecutionStatusColumn:_t,Tooltip:y.Tooltip},scope:{getTriggersOptions:t,useWorkflowSyncAction:vn,useRefreshActionProps:Gt}})})})}function wn(n){var s=n,{collection:e,dataPath:t}=s,o=Z(s,["collection","dataPath"]);const{insert:a}=i.useSchemaInitializer(),{getTemplateSchemaByMode:l}=i.useSchemaTemplateManager(),{getCollection:c}=i.useCollectionManager_deprecated(),u=i.useRecordCollectionDataSourceItems("FormItem");let d;if(typeof e=="string"){const[h,x]=i.parseCollectionName(e);d=c(x,h)}else d=e;function f(x){return _(this,arguments,function*({item:h}){const v=h.template?yield l(h):null,m={type:"void",name:Dt.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:v||{type:"void","x-component":"Grid","x-initializer":"details:configureFields",properties:{}}}}}};xt(m,k=>{k["x-uid"]&&delete k["x-uid"]}),a(m)})}return r.jsx(i.SchemaInitializerItem,T(C({},o),{onClick:f,items:u}))}function Ie(e){var a;const t=i.useSchemaInitializerItem(),o=(a=e==null?void 0:e.collection)!=null?a:t.collection;let n,s;if(typeof o=="string"){const l=i.parseCollectionName(o);n=l[0],s=l[1]}else s=o;return r.jsx(i.CollectionProvider_deprecated,{dataSource:n,collection:s,children:r.jsx(wn,C(C({},t),e))})}function Cn(){return!0}const wt=j.observer(e=>{const d=e,{filter:t=Cn}=d,o=Z(d,["filter"]),n=i.useCompile(),{getCollectionFields:s}=i.useCollectionManager_deprecated(),{values:a}=j.useForm(),[l,c]=i.parseCollectionName(a==null?void 0:a.collection),u=s(c,l);return r.jsx(y.Select,T(C({popupMatchSelectWidth:!1},o),{options:u.filter(t).map(f=>{var h;return{label:n((h=f.uiSchema)==null?void 0:h.title),value:f.name}})}))},{displayName:"FieldsSelect"}),le={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"},Kt={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:i.css`
|
|
452
455
|
flex-direction: column;
|
|
453
456
|
`},"x-component":"CollectionFieldset"},Ge={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:e}=j.useForm(),[t,o]=i.parseCollectionName(e==null?void 0:e.collection);return{options:i.useCollectionFilterOptions(o,t),className:i.css`
|
|
454
457
|
position: relative;
|
|
455
458
|
width: 100%;
|
|
456
|
-
`}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},xn={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"}}},vn={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}}}}}}},Ie={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}=j.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},ke={label:"label",value:"value",children:"children"},Kt={label:`{{t("Node result", { ns: "${p}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=i.usePlugin(ce),o=Ce(),n=It(o),s=[];return n.forEach(a=>{var u;const l=t.get(a.type),c=(u=l.useVariables)==null?void 0:u.call(l,a,e);c&&s.push(c)}),s}},Zt={label:`{{t("Trigger variables", { ns: "${p}" })}}`,value:"$context",useOptions(e){var s,a;const{triggers:t}=i.usePlugin(ce),{workflow:o}=Y(),n=t.get(o.type);return(a=(s=n==null?void 0:n.useVariables)==null?void 0:s.call(n,o.config,e))!=null?a:null}},Qt={label:`{{t("Scope variables", { ns: "${p}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=ke,current:o}=e,{instructions:n}=i.usePlugin(ce),s=Ce(),a=o!=null?o:s,l=Pt(a),c=[];return l.forEach(u=>{var h,v;const d=n.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]:(v=u.title)!=null?v:`#${u.id}`,[t.children]:f})}),c}},Xt={label:`{{t("System variables", { ns: "${p}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=ke}){return[...!e||e.includes("date")?[{key:"now",[t.label]:D("System time"),[t.value]:"now"}]:[]]}},Ye={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 Rt(e,t){var o,n,s,a,l,c;return typeof t=="string"?(o=Ye[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?wt(e)?((n=t.options)==null?void 0:n.entity)&&(e.collectionName===((s=t.options)==null?void 0:s.collection)||((a=t.options)==null?void 0:a.collection)==="*"):e.isForeignKey?e.collectionName===((l=t.options)==null?void 0:l.collection)&&e.name==="id"||e.target===((c=t.options)==null?void 0:c.collection):!1:typeof t=="function"?t(e):!1}function wt(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function Ct(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function kt({fields:e,types:t,appends:o,depth:n=1,compile:s,getCollectionFields:a}){return e.filter(l=>{const c=t!=null&&t.length?t.some(u=>Rt(l,u)):!0;if(wt(l)){if(o===null)return n?c||kt({fields:St(l.target,{compile:s,getCollectionFields:a}),types:t,depth:n-1,appends:o,compile:s,getCollectionFields:a}):!1;const u=Ct(l,o),d=o.includes(l.name);return c?d:((u==null?void 0:u.length)||d)&&kt({fields:St(l.target,{compile:s,getCollectionFields:a}),types:t,appends:u,compile:s,getCollectionFields:a}).length}else return c})}function qe(e,t){var a,l;const o=i.useCompile(),n=(l=(a=e.useOptions)==null?void 0:a.call(e,t))==null?void 0:l.filter(Boolean),{fieldNames:s}=t;return{[s.label]:o(e.label),[s.value]:e.value,key:e[s.value],[s.children]:n,disabled:!n||!n.length}}function ge(e={}){var s;const t=Object.assign({},ke,(s=e.fieldNames)!=null?s:{}),o=Object.assign(e,{fieldNames:t});return[qe(Qt,o),qe(Kt,o),qe(Zt,o),qe(Xt,o)]}function St(e,{compile:t,getCollectionFields:o}){var u,d,f,h,v,x,m;const[n,s]=i.parseCollectionName(e),a=o(s,n),l=[],c=[];a.forEach(k=>{k.isForeignKey?l.push(k):c.push(k)});for(let k=c.length-1;k>=0;k--){const S=c[k];if(S.type==="belongsTo"){const N=l.find(A=>A.name===S.foreignKey);N?c.splice(k,0,T(C(C({},S),N),{uiSchema:T(C({},S.uiSchema),{title:(u=S.uiSchema)!=null&&u.title?`${t((d=S.uiSchema)==null?void 0:d.title)} ID`:N.name})})):c.splice(k,0,T(C({},S),{name:S.foreignKey,type:"bigInt",isForeignKey:!0,interface:S.interface,uiSchema:T(C({},S.uiSchema),{title:(f=S.uiSchema)!=null&&f.title?`${t((h=S.uiSchema)==null?void 0:h.title)} ID`:S.name})}))}else if(S.type==="context"&&S.collectionName==="users"){const N=(v=c.find(A=>A.type==="belongsTo"&&A.target==="users"&&A.foreignKey===S.name))!=null?v:{};c.splice(k,0,T(C({},S),{type:S.dataType,interface:N.interface,uiSchema:T(C({},N.uiSchema),{title:(x=N.uiSchema)!=null&&x.title?`${t((m=N.uiSchema)==null?void 0:m.title)} ID`:S.name})}))}}return c.filter(k=>k.interface&&!k.hidden)}function wn(e){const t=Ct(e.field,e.appends),o=Se(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=>Rt(e.field,s))||(e.disabled=!0))}function Se(e){const{fields:t,collection:o,types:n,appends:s=[],depth:a=1,compile:l,getCollectionFields:c,fieldNames:u=ke}=e,d=t!=null?t:St(o,{compile:l,getCollectionFields:c}),f=wn.bind({compile:l,getCollectionFields:c,fieldNames:u});return kt({fields:d,types:n,depth:a,appends:s,compile:l,getCollectionFields:c}).map(v=>{var S;const x=l(((S=v.uiSchema)==null?void 0:S.title)||v.name),m=Ct(v,s),k=!wt(v)||m&&!m.length&&!s.includes(v.name)||!1;return{[u.label]:x,key:v.name,[u.value]:v.name,isLeaf:k,loadChildren:k?null:f,field:v,depth:a,appends:s,types:n}})}function eo(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=ge(e);return r.jsx(i.Variable.Input,C({scope:s},t))}function At(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=ge(e);return r.jsx(i.Variable.TextArea,C({scope:s},t))}function Cn(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=ge(e);return r.jsx(i.Variable.RawTextArea,C({scope:s},t))}function kn(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=ge(e);return r.jsx(i.Variable.JSON,C({scope:s},t))}function Sn(){const e=i.useAPIClient(),t=j.useForm(),{field:o,__parent:n}=i.useBlockRequestContext(),{setVisible:s}=i.useActionContext(),a=oe.useNavigate(),l=j.useFieldSchema(),c=j.useField(),u=i.useCompile(),{modal:d}=y.App.useApp(),f=i.useCollectValuesToSubmit(),h=c.componentProps.filterKeys||[];return{onClick(){return _(this,null,function*(){var N,A,P;const{onSuccess:x,skipValidator:m,triggerWorkflows:k}=(N=l==null?void 0:l["x-action-settings"])!=null?N:{};m||(yield t.submit());const S=yield f();c.data=o.data||{},c.data.loading=!0;try{const z=yield e.resource("workflows").trigger({values:S,filterKeys:h,triggerWorkflows:k!=null&&k.length?k.map(U=>[U.workflowKey,U.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.loading=!1,c.data.data=z,(P=(A=n==null?void 0:n.service)==null?void 0:A.refresh)==null||P.call(A),s==null||s(!1),!(x!=null&&x.successMessage))return;x!=null&&x.manualClose?d.success({title:u(x==null?void 0:x.successMessage),onOk:()=>_(this,null,function*(){yield t.reset(),x!=null&&x.redirecting&&(x!=null&&x.redirectTo)&&(H.isURL(x.redirectTo)?window.location.href=x.redirectTo:a(x.redirectTo))})}):y.message.success(u(x==null?void 0:x.successMessage))}catch(z){c.data.loading=!1}})}}}function An(){var x;const e=i.useCompile(),t=i.useAPIClient(),o=i.useRecord(),n=j.useField(),s=j.useFieldSchema(),{field:a,__parent:l}=i.useBlockRequestContext(),{setVisible:c,setSubmitted:u}=i.useActionContext(),{modal:d}=y.App.useApp(),f=oe.useNavigate(),{onSuccess:h,triggerWorkflows:v}=(x=s==null?void 0:s["x-action-settings"])!=null?x:{};return{onClick(k,S){return _(this,null,function*(){n.data=a.data||{},n.data.loading=!0;try{if(yield t.resource("workflows").trigger({values:o,triggerWorkflows:v!=null&&v.length?v.map(N=>[N.workflowKey,N.context].filter(Boolean).join("!")).join(","):void 0}),S&&S(),c==null||c(!1),u==null||u(!0),!(h!=null&&h.successMessage))return;if(h!=null&&h.manualClose){let N;d.success({title:e(h==null?void 0:h.successMessage),onOk(){return _(this,null,function*(){h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(H.isURL(h.redirectTo)?window.location.href=h.redirectTo:f(h.redirectTo))})}})}else y.message.success(e(h==null?void 0:h.successMessage))}catch(N){console.error(N)}finally{n.data.loading=!1}})}}}function On(){const{workflow:e}=Y();return!!(e!=null&&e.executed)}function to(){const{workflow:e}=Y();return!!(e!=null&&e.allExecuted)}const Ae={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},Tn=[{label:`{{t("After record added", { ns: "${p}" })}}`,value:Ae.CREATED},{label:`{{t("After record updated", { ns: "${p}" })}}`,value:Ae.UPDATED},{label:`{{t("After record added or updated", { ns: "${p}" })}}`,value:Ae.SAVED},{label:`{{t("After record deleted", { ns: "${p}" })}}`,value:Ae.DELETED}];class Fn extends yt{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:T(C({},le),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(o){return o.options.key==="main"||o.options.isDBInstance}},"x-reactions":[...le["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:Tn,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] & ${Ae.UPDATED})}}`}}}]},condition:T(C({},Ge),{title:`{{t("Only triggers when match conditions", { ns: "${p}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:T(C({},Ie),{"x-reactions":[...Ie["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Ae.DELETED})}}`}}}]})});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource,useWorkflowAnyExecuted:to});w(this,"components",{FieldsSelect:vt})}useVariables(o,n){var u;const s=i.useCompile(),{getCollectionFields:a}=i.useCollectionManager_deprecated(),l=[{collectionName:o.collection,name:"data",type:"hasOne",target:o.collection,uiSchema:{title:D("Trigger data")}}];return Se(T(C({appends:["data",...((u=o.appends)==null?void 0:u.map(d=>`data.${d}`))||[]]},n),{fields:l,compile:s,getCollectionFields:a}))}useInitializers(o){return o.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Me,collection:o.collection,dataPath:"$context.data"}:null}}const ve={STATIC:0,DATE_FIELD:1};function Nn(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function oo({value:e,onChange:t}){const o=e!=null?e:{},{t:n}=Q.useTranslation(),[s,a]=b.useState(o.offset?o.offset/Math.abs(o.offset):0);return r.jsxs("fieldset",{className:i.css`
|
|
459
|
+
`}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},kn={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"}}},Sn={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}}}}}}},Pe={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}=j.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},ke={label:"label",value:"value",children:"children"},Zt={label:`{{t("Node result", { ns: "${p}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=i.usePlugin(ce),o=Ce(),n=Pt(o),s=[];return n.forEach(a=>{var u;const l=t.get(a.type),c=(u=l.useVariables)==null?void 0:u.call(l,a,e);c&&s.push(c)}),s}},Qt={label:`{{t("Trigger variables", { ns: "${p}" })}}`,value:"$context",useOptions(e){var s,a;const{triggers:t}=i.usePlugin(ce),{workflow:o}=Y(),n=t.get(o.type);return(a=(s=n==null?void 0:n.useVariables)==null?void 0:s.call(n,o.config,e))!=null?a:null}},Xt={label:`{{t("Scope variables", { ns: "${p}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=ke,current:o}=e,{instructions:n}=i.usePlugin(ce),s=Ce(),a=o!=null?o:s,l=Bt(a),c=[];return l.forEach(u=>{var h,x;const d=n.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}},Rt={label:`{{t("System variables", { ns: "${p}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=ke}){return[...!e||e.includes("date")?[{key:"now",[t.label]:N("System time"),[t.value]:"now"}]:[]]}},Ye={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 eo(e,t){var o,n,s,a,l,c;return typeof t=="string"?(o=Ye[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?Ct(e)?((n=t.options)==null?void 0:n.entity)&&(e.collectionName===((s=t.options)==null?void 0:s.collection)||((a=t.options)==null?void 0:a.collection)==="*"):e.isForeignKey?e.collectionName===((l=t.options)==null?void 0:l.collection)&&e.name==="id"||e.target===((c=t.options)==null?void 0:c.collection):!1:typeof t=="function"?t(e):!1}function Ct(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function kt(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function St({fields:e,types:t,appends:o,depth:n=1,compile:s,getCollectionFields:a}){return e.filter(l=>{const c=t!=null&&t.length?t.some(u=>eo(l,u)):!0;if(Ct(l)){if(o===null)return n?c||St({fields:At(l.target,{compile:s,getCollectionFields:a}),types:t,depth:n-1,appends:o,compile:s,getCollectionFields:a}):!1;const u=kt(l,o),d=o.includes(l.name);return c?d:((u==null?void 0:u.length)||d)&&St({fields:At(l.target,{compile:s,getCollectionFields:a}),types:t,appends:u,compile:s,getCollectionFields:a}).length}else return c})}function qe(e,t){var a,l;const o=i.useCompile(),n=(l=(a=e.useOptions)==null?void 0:a.call(e,t))==null?void 0:l.filter(Boolean),{fieldNames:s}=t;return{[s.label]:o(e.label),[s.value]:e.value,key:e[s.value],[s.children]:n,disabled:!n||!n.length}}function me(e={}){var s;const t=Object.assign({},ke,(s=e.fieldNames)!=null?s:{}),o=Object.assign(e,{fieldNames:t});return[qe(Xt,o),qe(Zt,o),qe(Qt,o),qe(Rt,o)]}function At(e,{compile:t,getCollectionFields:o}){var u,d,f,h,x,v,m;const[n,s]=i.parseCollectionName(e),a=o(s,n),l=[],c=[];a.forEach(k=>{k.isForeignKey?l.push(k):c.push(k)});for(let k=c.length-1;k>=0;k--){const S=c[k];if(S.type==="belongsTo"){const E=l.find(A=>A.name===S.foreignKey);E?c.splice(k,0,T(C(C({},S),E),{uiSchema:T(C({},S.uiSchema),{title:(u=S.uiSchema)!=null&&u.title?`${t((d=S.uiSchema)==null?void 0:d.title)} ID`:E.name})})):c.splice(k,0,T(C({},S),{name:S.foreignKey,type:"bigInt",isForeignKey:!0,interface:S.interface,uiSchema:T(C({},S.uiSchema),{title:(f=S.uiSchema)!=null&&f.title?`${t((h=S.uiSchema)==null?void 0:h.title)} ID`:S.name})}))}else if(S.type==="context"&&S.collectionName==="users"){const E=(x=c.find(A=>A.type==="belongsTo"&&A.target==="users"&&A.foreignKey===S.name))!=null?x:{};c.splice(k,0,T(C({},S),{type:S.dataType,interface:E.interface,uiSchema:T(C({},E.uiSchema),{title:(v=E.uiSchema)!=null&&v.title?`${t((m=E.uiSchema)==null?void 0:m.title)} ID`:S.name})}))}}return c.filter(k=>k.interface&&!k.hidden)}function An(e){const t=kt(e.field,e.appends),o=Se(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=>eo(e.field,s))||(e.disabled=!0))}function Se(e){const{fields:t,collection:o,types:n,appends:s=[],depth:a=1,compile:l,getCollectionFields:c,fieldNames:u=ke}=e,d=t!=null?t:At(o,{compile:l,getCollectionFields:c}),f=An.bind({compile:l,getCollectionFields:c,fieldNames:u});return St({fields:d,types:n,depth:a,appends:s,compile:l,getCollectionFields:c}).map(x=>{var S;const v=l(((S=x.uiSchema)==null?void 0:S.title)||x.name),m=kt(x,s),k=!Ct(x)||m&&!m.length&&!s.includes(x.name)||!1;return{[u.label]:v,key:x.name,[u.value]:x.name,isLeaf:k,loadChildren:k?null:f,field:x,depth:a,appends:s,types:n}})}function to(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=me(e);return r.jsx(i.Variable.Input,C({scope:s},t))}function Ot(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=me(e);return r.jsx(i.Variable.TextArea,C({scope:s},t))}function On(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=me(e);return r.jsx(i.Variable.RawTextArea,C({scope:s},t))}function Tn(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=me(e);return r.jsx(i.Variable.JSON,C({scope:s},t))}function Fn(){const e=i.useAPIClient(),t=j.useForm(),{field:o,__parent:n}=i.useBlockRequestContext(),{setVisible:s}=i.useActionContext(),a=oe.useNavigate(),l=j.useFieldSchema(),c=j.useField(),u=i.useCompile(),{modal:d}=y.App.useApp(),f=i.useCollectValuesToSubmit(),h=c.componentProps.filterKeys||[];return{onClick(){return _(this,null,function*(){var E,A,P;const{onSuccess:v,skipValidator:m,triggerWorkflows:k}=(E=l==null?void 0:l["x-action-settings"])!=null?E:{};m||(yield t.submit());const S=yield f();c.data=o.data||{},c.data.loading=!0;try{const z=yield e.resource("workflows").trigger({values:S,filterKeys:h,triggerWorkflows:k!=null&&k.length?k.map(U=>[U.workflowKey,U.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.loading=!1,c.data.data=z,(P=(A=n==null?void 0:n.service)==null?void 0:A.refresh)==null||P.call(A),s==null||s(!1),!(v!=null&&v.successMessage))return;v!=null&&v.manualClose?d.success({title:u(v==null?void 0:v.successMessage),onOk:()=>_(this,null,function*(){yield t.reset(),v!=null&&v.redirecting&&(v!=null&&v.redirectTo)&&(H.isURL(v.redirectTo)?window.location.href=v.redirectTo:a(v.redirectTo))})}):y.message.success(u(v==null?void 0:v.successMessage))}catch(z){c.data.loading=!1}})}}}function En(){var v;const e=i.useCompile(),t=i.useAPIClient(),o=i.useRecord(),n=j.useField(),s=j.useFieldSchema(),{field:a,__parent:l}=i.useBlockRequestContext(),{setVisible:c,setSubmitted:u}=i.useActionContext(),{modal:d}=y.App.useApp(),f=oe.useNavigate(),{onSuccess:h,triggerWorkflows:x}=(v=s==null?void 0:s["x-action-settings"])!=null?v:{};return{onClick(k,S){return _(this,null,function*(){n.data=a.data||{},n.data.loading=!0;try{if(yield t.resource("workflows").trigger({values:o,triggerWorkflows:x!=null&&x.length?x.map(E=>[E.workflowKey,E.context].filter(Boolean).join("!")).join(","):void 0}),S&&S(),c==null||c(!1),u==null||u(!0),!(h!=null&&h.successMessage))return;if(h!=null&&h.manualClose){let E;d.success({title:e(h==null?void 0:h.successMessage),onOk(){return _(this,null,function*(){h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(H.isURL(h.redirectTo)?window.location.href=h.redirectTo:f(h.redirectTo))})}})}else y.message.success(e(h==null?void 0:h.successMessage))}catch(E){console.error(E)}finally{n.data.loading=!1}})}}}function Nn(){const{workflow:e}=Y();return!!(e!=null&&e.executed)}function oo(){const{workflow:e}=Y();return!!(e!=null&&e.allExecuted)}const Ae={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},Dn=[{label:`{{t("After record added", { ns: "${p}" })}}`,value:Ae.CREATED},{label:`{{t("After record updated", { ns: "${p}" })}}`,value:Ae.UPDATED},{label:`{{t("After record added or updated", { ns: "${p}" })}}`,value:Ae.SAVED},{label:`{{t("After record deleted", { ns: "${p}" })}}`,value:Ae.DELETED}];class $n extends gt{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:T(C({},le),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(o){return o.options.key==="main"||o.options.isDBInstance}},"x-reactions":[...le["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:Dn,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] & ${Ae.UPDATED})}}`}}}]},condition:T(C({},Ge),{title:`{{t("Only triggers when match conditions", { ns: "${p}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:T(C({},Pe),{"x-reactions":[...Pe["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Ae.DELETED})}}`}}}]})});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource,useWorkflowAnyExecuted:oo});w(this,"components",{FieldsSelect:wt})}useVariables(o,n){var u;const s=i.useCompile(),{getCollectionFields:a}=i.useCollectionManager_deprecated(),l=[{collectionName:o.collection,name:"data",type:"hasOne",target:o.collection,uiSchema:{title:N("Trigger data")}}];return Se(T(C({appends:["data",...((u=o.appends)==null?void 0:u.map(d=>`data.${d}`))||[]]},n),{fields:l,compile:s,getCollectionFields:a}))}useInitializers(o){return o.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Ie,collection:o.collection,dataPath:"$context.data"}:null}}const xe={STATIC:0,DATE_FIELD:1};function Mn(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function no({value:e,onChange:t}){const o=e!=null?e:{},{t:n}=Q.useTranslation(),[s,a]=g.useState(o.offset?o.offset/Math.abs(o.offset):0);return r.jsxs("fieldset",{className:i.css`
|
|
457
460
|
display: flex;
|
|
458
461
|
gap: 0.5em;
|
|
459
|
-
`,children:[r.jsx(
|
|
462
|
+
`,children:[r.jsx(wt,{value:o.field,onChange:l=>t(T(C({},o),{field:l})),filter:Mn,placeholder:n("Select field"),className:"auto-width"}),o.field?r.jsx(y.Select,{value:s,onChange:l=>{a(l),t(T(C({},o),{offset:Math.abs(o.offset)*l}))},options:[{value:0,label:N("Exactly at")},{value:-1,label:n("Before")},{value:1,label:n("After")}],className:"auto-width"}):null,s?r.jsxs(r.Fragment,{children:[r.jsx(y.InputNumber,{value:Math.abs(o.offset),onChange:l=>t(T(C({},o),{offset:(l!=null?l:0)*s}))}),r.jsx(y.Select,{value:o.unit||864e5,onChange:l=>t(T(C({},o),{unit:l})),options:[{value:864e5,label:N("Days")},{value:36e5,label:N("Hours")},{value:6e4,label:N("Minutes")},{value:1e3,label:N("Seconds")}],className:"auto-width"})]}):null]})}function In({value:e,onChange:t}){const{t:o}=pt(),n=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return r.jsxs("fieldset",{className:i.css`
|
|
460
463
|
display: flex;
|
|
461
464
|
gap: 0.5em;
|
|
462
|
-
`,children:[r.jsxs(y.Select,{value:n,onChange:s=>{t(s?s==="field"?{}:new Date:null)},className:"auto-width",children:[r.jsx(y.Select.Option,{value:null,children:o("No end")}),r.jsx(y.Select.Option,{value:"field",children:o("By field")}),r.jsx(y.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(oo,{value:e,onChange:t}):null,n==="date"?r.jsx(y.DatePicker,{showTime:!0,value:Lo(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var re=function(){return re=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;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 no(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(o[n[s]]=e[n[s]])}return o}function Ke(e,t,o){if(o||arguments.length===2)for(var n,s=0,a=t.length;s<a;s++)!n&&s in t||(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}var $n=[{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 * * * *"}],we=[{type:"minutes",min:0,max:59,total:60},{type:"hours",min:0,max:23,total:24},{type:"month-days",min:1,max:31,total:31},{type:"months",min:1,max:12,total:12,alt:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]},{type:"week-days",min:0,max:6,total:7,alt:["SUN","MON","TUE","WED","THU","FRI","SAT"]}],B={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function ro(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function Ze(e){return e.sort(function(t,o){return t-o}),e}function so(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function ae(e){return Object.entries(e).filter(function(t){var o=t[0],n=t[1];return o&&n}).map(function(t){return t[0]}).join(" ")}function io(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||B.errorInvalidCron})}function Qe(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function lo(e,t,o,n,s,a,l,c,u,d,f,h,v,x){o&&o(void 0),t(!1);var m=!1;if(!e){if(n==="always"||a&&n==="for-default-value")return;m=!0}if(!m){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void x("reboot");var k=$n.find(function(A){return A.name===e});k&&(e=k.value)}try{var S=function(A){if(typeof A!="string")throw new Error("Invalid cron string");var P=A.replace(/\s+/g," ").trim().split(" ");if(P.length===5)return P.map(function(z,U){return function(F,M){if(F==="*"||F==="*/1")return[];var O=Ze(so(po(function(L,J,ue){if(ue){L=L.toUpperCase();for(var $=0;$<ue.length;$++)L=L.replace(ue[$],"".concat($+J))}return L}(F,M.min,M.alt).split(",").map(function(L){var J,ue=L.split("/");if(ue.length>2)throw new Error('Invalid value "'.concat(F,' for "').concat(M.type,'"'));var $=ue[0],V=ue[1];J=$==="*"?ro(M.min,M.max):function(G,q,R){var ee=G.split("-");if(ee.length===1){var Ve=Qe(ee[0]);if(isNaN(Ve))throw new Error('Invalid value "'.concat(q,'" for ').concat(R.type));return[Ve]}if(ee.length===2){var me=Qe(ee[0]),Fe=Qe(ee[1]);if(isNaN(me)||isNaN(Fe))throw new Error('Invalid value "'.concat(q,'" for ').concat(R.type));if(Fe<me)throw new Error('Max range is less than min range in "'.concat(G,'" for ').concat(R.type));return ro(me,Fe)}throw new Error('Invalid value "'.concat(G,'" for ').concat(R.type))}($,F,M);var W=function(G,q){if(G!==void 0){var R=Qe(G);if(isNaN(R)||R<1)throw new Error('Invalid interval step value "'.concat(G,'" for ').concat(q.type));return R}}(V,M),se=function(G,q){if(q){var R=G[0];G=G.filter(function(ee){return ee%q==R%q||ee===R})}return G}(J,W);return se}).flat(),M))),I=mo(O,M);if(I!==void 0)throw new Error('Value "'.concat(I,'" out of range for ').concat(M.type));return O.length===M.total?[]:O}(z,we[U])});throw new Error("Invalid cron string format")}(e),N=function(A){return A[3].length>0?"year":A[2].length>0?"month":A[4].length>0?"week":A[1].length>0?"day":A[0].length>0?"hour":"minute"}(S);x(N),u(S[0]),d(S[1]),f(S[2]),h(S[3]),v(S[4])}catch(A){m=!0}}m&&(s.current=e,t(!0),io(o,l))}function ao(e,t,o,n,s,a,l){if(e==="reboot")return"@reboot";var c=function(u,d){return u.map(function(f,h){var v=we[h];return co(uo(f,v),v,d)})}([e!=="minute"&&a?a:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return c.join(" ")}function co(e,t,o,n,s){var a="";if(function(c,u){return c.length===u.max-u.min+1}(e,t)||e.length===0)a="*";else{var l=function(c){if(c.length>2){var u=c[1]-c[0];if(u>1)return u}}(e);a=l&&function(c,u){for(var d=1;d<c.length;d++){var f=c[d-1];if(c[d]-f!==u)return!1}return!0}(e,l)?function(c,u,d){var f=fo(c),h=ho(c),v=c.length===(h-f)/d+1;return!!(f===u.min&&h+d>u.max&&v)}(e,t,l)?"*/".concat(l):"".concat(Oe(fo(e),t,o,n,s),"-").concat(Oe(ho(e),t,o,n,s),"/").concat(l):function(c){var u=[],d=null;return c.forEach(function(f,h,v){f!==v[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],t,o,n,s),"-").concat(Oe(c[1],t,o,n,s)):Oe(c,t,o,n,s)}).join(",")}return a}function Oe(e,t,o,n,s){var a=e.toString(),l=t.type,c=t.alt,u=t.min,d=n&&(n===!0||n.includes(l)),f=s==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?a=c[e-u]:e<10&&(d||f)&&(a=a.padStart(2,"0")),l==="hours"&&s==="12-hour-clock"){var h=e>=12?"PM":"AM",v=e%12||12;v<10&&d&&(v=v.toString().padStart(2,"0")),a="".concat(v).concat(h)}return a}function uo(e,t){var o=Ze(so(po(e,t)));if(o.length===0)return o;var n=mo(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function po(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function mo(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function fo(e){return e[0]}function ho(e){return e[e.length-1]}function Pe(e){var t=e.value,o=e.grid,n=o===void 0||o,s=e.optionsList,a=e.setValue,l=e.locale,c=e.className,u=e.humanizeLabels,d=e.disabled,f=e.readOnly,h=e.leadingZero,v=e.clockFormat,x=e.period,m=e.unit,k=e.periodicityOnDoubleClick,S=e.mode,N=no(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),A=b.useMemo(function(){if(t&&Array.isArray(t))return t.map(function($){return $.toString()})},[t]),P=b.useMemo(function(){return s?s.map(function($,V){return{value:(m.min===0?V:V+1).toString(),label:$}}):Ke([],Array(m.total),!0).map(function($,V){var W=m.min===0?V:V+1;return{value:W.toString(),label:Oe(W,m,u,h,v)}})},[s,h,u,v]),z=JSON.stringify(l),U=b.useCallback(function($){var V=$.value;if(!t||t[0]!==Number(V))return r.jsx(r.Fragment,{});var W=co(uo(t,m),m,u,h,v),se=W.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:se[1]?"".concat(l.everyText||B.everyText," ").concat(se[1]):W})},[t,z,u,h,v]),F=b.useCallback(function($){var V=Array.isArray($)?Ze($):[$],W=V;t&&(W=S==="single"?[]:Ke([],t,!0),V.forEach(function(se){var G=Number(se);W=t.some(function(q){return q===G})?W.filter(function(q){return q!==G}):Ze(Ke(Ke([],W,!0),[G],!1))})),W.length===m.total?a([]):a(W)},[a,t]),M=b.useCallback(function($){if($!==0&&$!==1){for(var V=m.total+m.min,W=[],se=m.min;se<V;se++)se%$==0&&W.push(se);var G=t&&W&&t.length===W.length&&t.every(function(R,ee){return R===W[ee]}),q=W.length===P.length;a(q||G?[]:W)}else a([])},[t,P,a]),O=b.useRef([]),I=b.useCallback(function($){if(!f){var V=O.current;V.push({time:new Date().getTime(),value:Number($)});var W=window.setTimeout(function(){k&&V.length>1&&V[V.length-1].time-V[V.length-2].time<300?V[V.length-1].value===V[V.length-2].value?M(Number($)):F([V[V.length-2].value,V[V.length-1].value]):F(Number($)),O.current=[]},300);return function(){window.clearTimeout(W)}}},[O,F,M,f,k]),L=b.useCallback(function(){f||a([])},[a,f]),J=b.useMemo(function(){var $;return ae((($={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,$))},[c]),ue=b.useMemo(function(){var $;return ae((($={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(m.type)]=!0,$["react-js-cron-custom-select-dropdown"]=!0,$["react-js-cron-custom-select-dropdown-".concat(m.type)]=!0,$["react-js-cron-custom-select-dropdown-minutes-large"]=m.type==="minutes"&&x!=="hour"&&x!=="day",$["react-js-cron-custom-select-dropdown-minutes-medium"]=m.type==="minutes"&&(x==="day"||x==="hour"),$["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=m.type==="hours"&&v==="12-hour-clock",$["react-js-cron-custom-select-dropdown-grid"]=!!n,$["".concat(c,"-select-dropdown")]=!!c,$["".concat(c,"-select-dropdown-").concat(m.type)]=!!c,$))},[c,n,v,x]);return r.jsx(y.Select,re({mode:S!=="single"||k?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:A,onClear:L,tagRender:U,className:J,popupClassName:ue,options:P,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:I,onDeselect:I,disabled:d,dropdownAlign:m.type!=="minutes"&&m.type!=="hours"||x==="day"||x==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(m.type)},N))}function En(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,v=b.useMemo(function(){var x;return ae(((x={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,x["".concat(s,"-hours")]=!!s,x))},[s]);return r.jsxs("div",re({className:v},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||B.prefixHours}),r.jsx(Pe,{placeholder:n.emptyHours||B.emptyHours,value:t,unit:we[1],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:h})]}))}function Mn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,v=b.useMemo(function(){var x;return ae(((x={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,x["".concat(s,"-minutes")]=!!s,x))},[s]);return r.jsxs("div",re({className:v},{children:[d==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||B.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||B.prefixMinutes}),r.jsx(Pe,{placeholder:d==="hour"?n.emptyMinutesForHourPeriod||B.emptyMinutesForHourPeriod:n.emptyMinutes||B.emptyMinutes,value:t,unit:we[0],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:h}),d==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||B.suffixMinutesForHourPeriod})]}))}function In(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.weekDays,l=e.disabled,c=e.readOnly,u=e.leadingZero,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,v=!a||a.length===0,x=b.useMemo(function(){var S;return ae(((S={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!v})["".concat(s,"-field")]=!!s,S["".concat(s,"-month-days")]=!!s,S))},[s,v]),m=JSON.stringify(n),k=b.useMemo(function(){return v?n.emptyMonthDays||B.emptyMonthDays:n.emptyMonthDaysShort||B.emptyMonthDaysShort},[v,m]);return!c||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?r.jsxs("div",re({className:x},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||B.prefixMonthDays}),r.jsx(Pe,{placeholder:k,value:t,setValue:o,unit:we[2],locale:n,className:s,disabled:l,readOnly:c,leadingZero:u,period:d,periodicityOnDoubleClick:f,mode:h})]})):null}function Pn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.disabled,c=e.readOnly,u=e.period,d=e.periodicityOnDoubleClick,f=e.mode,h=n.months||B.months,v=b.useMemo(function(){var x;return ae(((x={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,x["".concat(s,"-months")]=!!s,x))},[s]);return r.jsxs("div",re({className:v},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||B.prefixMonths}),r.jsx(Pe,{placeholder:n.emptyMonths||B.emptyMonths,optionsList:h,grid:!1,value:t,unit:re(re({},we[3]),{alt:n.altMonths||B.altMonths}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:l,readOnly:c,period:u,periodicityOnDoubleClick:d,mode:f})]}))}function Bn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.shortcuts,u=e.allowedPeriods,d=[];u.includes("year")&&d.push({value:"year",label:n.yearOption||B.yearOption}),u.includes("month")&&d.push({value:"month",label:n.monthOption||B.monthOption}),u.includes("week")&&d.push({value:"week",label:n.weekOption||B.weekOption}),u.includes("day")&&d.push({value:"day",label:n.dayOption||B.dayOption}),u.includes("hour")&&d.push({value:"hour",label:n.hourOption||B.hourOption}),u.includes("minute")&&d.push({value:"minute",label:n.minuteOption||B.minuteOption}),u.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&d.push({value:"reboot",label:n.rebootOption||B.rebootOption});var f=b.useCallback(function(m){l||o(m)},[o,l]),h=b.useMemo(function(){var m;return ae(((m={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,m["".concat(s,"-period")]=!!s,m))},[s]),v=b.useMemo(function(){var m;return ae(((m={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(s,"-select")]=!!s,m))},[s,n.prefixPeriod]),x=b.useMemo(function(){var m;return ae(((m={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,m["".concat(s,"-select-dropdown-period")]=!!s,m))},[s]);return r.jsxs("div",re({className:h},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||B.prefixPeriod}),r.jsx(y.Select,{defaultValue:t,value:t,onChange:f,options:d,className:v,popupClassName:x,disabled:a,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function Vn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.monthDays,c=e.disabled,u=e.readOnly,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,v=n.weekDays||B.weekDays,x=d==="week"||!l||l.length===0,m=b.useMemo(function(){var P;return ae(((P={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!x})["".concat(s,"-field")]=!!s,P["".concat(s,"-week-days")]=!!s,P))},[s,x]),k=JSON.stringify(n),S=b.useMemo(function(){return x?n.emptyWeekDays||B.emptyWeekDays:n.emptyWeekDaysShort||B.emptyWeekDaysShort},[x,k]),N=d==="week"||!u||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),A=!u||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return N?r.jsxs("div",re({className:m},{children:[n.prefixWeekDays!==""&&(d==="week"||!A)&&r.jsx("span",{children:n.prefixWeekDays||B.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&d!=="week"&&A&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||B.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(Pe,{placeholder:S,optionsList:v,grid:!1,value:t,unit:re(re({},we[4]),{alt:n.altWeekDays||B.altWeekDays}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:c,readOnly:u,period:d,periodicityOnDoubleClick:f,mode:h})]})):null}function jn(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,s=n===void 0?{}:n,a=e.clearButtonAction,l=a===void 0?"fill-with-every":a,c=e.locale,u=c===void 0?B:c,d=e.value,f=d===void 0?"":d,h=e.setValue,v=e.displayError,x=v===void 0||v,m=e.onError,k=e.className,S=e.defaultPeriod,N=S===void 0?"day":S,A=e.allowEmpty,P=A===void 0?"for-default-value":A,z=e.humanizeLabels,U=z===void 0||z,F=e.humanizeValue,M=F!==void 0&&F,O=e.disabled,I=O!==void 0&&O,L=e.readOnly,J=L!==void 0&&L,ue=e.leadingZero,$=ue!==void 0&&ue,V=e.shortcuts,W=V===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:V,se=e.clockFormat,G=e.periodicityOnDoubleClick,q=G===void 0||G,R=e.mode,ee=R===void 0?"multiple":R,Ve=e.allowedDropdowns,me=Ve===void 0?["period","months","month-days","week-days","hours","minutes"]:Ve,Fe=e.allowedPeriods,mr=Fe===void 0?["year","month","week","day","hour","minute","reboot"]:Fe,Ne=b.useRef(f),Ot=b.useRef(N),ko=b.useState(),be=ko[0],Re=ko[1],So=b.useState(),je=So[0],et=So[1],Ao=b.useState(),tt=Ao[0],ot=Ao[1],Oo=b.useState(),We=Oo[0],nt=Oo[1],To=b.useState(),rt=To[0],st=To[1],Fo=b.useState(),it=Fo[0],lt=Fo[1],No=b.useState(!1),Tt=No[0],Le=No[1],Do=b.useState(!1),at=Do[0],$o=Do[1],fr=function(K){var fe=b.useRef(K);return b.useEffect(function(){fe.current=K},[K]),fe.current}(at),Eo=JSON.stringify(u);b.useEffect(function(){lo(f,Le,m,P,Ne,!0,u,W,lt,st,et,ot,nt,Re)},[]),b.useEffect(function(){f!==Ne.current&&lo(f,Le,m,P,Ne,!1,u,W,lt,st,et,ot,nt,Re)},[f,Ne,Eo,P,W]),b.useEffect(function(){if(!(be||it||tt||je||We||rt)||at||fr)at&&$o(!1);else{var K=be||Ot.current,fe=ao(K,tt,je,We,rt,it,M);h(fe,{selectedPeriod:K}),Ne.current=fe,m&&m(void 0),Le(!1)}},[be,je,tt,We,rt,it,M,at]);var Mo=b.useCallback(function(){et(void 0),ot(void 0),nt(void 0),st(void 0),lt(void 0);var K="",fe=be!=="reboot"&&be?be:Ot.current;fe!==be&&Re(fe),l==="fill-with-every"&&(K=ao(fe,void 0,void 0,void 0,void 0,void 0)),h(K,{selectedPeriod:fe}),Ne.current=K,$o(!0),P==="never"&&l==="empty"?(Le(!0),io(m,u)):(m&&m(void 0),Le(!1))},[be,h,m,l]),hr=b.useMemo(function(){var K;return ae(((K={"react-js-cron":!0,"react-js-cron-error":Tt&&x,"react-js-cron-disabled":I,"react-js-cron-read-only":J})["".concat(k)]=!!k,K["".concat(k,"-error")]=Tt&&x&&!!k,K["".concat(k,"-disabled")]=I&&!!k,K["".concat(k,"-read-only")]=J&&!!k,K))},[k,Tt,x,I,J]),Ft=s.className,Io=no(s,["className"]),Po=b.useMemo(function(){var K;return ae(((K={"react-js-cron-clear-button":!0})["".concat(k,"-clear-button")]=!!k,K["".concat(Ft)]=!!Ft,K))},[k,Ft]),yr=JSON.stringify(Io),Bo=b.useMemo(function(){return o&&!J?r.jsx(y.Button,re({className:Po,danger:!0,type:"primary",disabled:I},Io,{onClick:Mo},{children:u.clearButtonText||B.clearButtonText})):null},[o,J,Eo,Po,I,yr,Mo]),te=be||Ot.current;return r.jsxs("div",re({className:hr},{children:[me.includes("period")&&r.jsx(Bn,{value:te,setValue:Re,locale:u,className:k,disabled:I,readOnly:J,shortcuts:W,allowedPeriods:mr}),te==="reboot"?Bo:r.jsxs(r.Fragment,{children:[te==="year"&&me.includes("months")&&r.jsx(Pn,{value:tt,setValue:ot,locale:u,className:k,humanizeLabels:U,disabled:I,readOnly:J,period:te,periodicityOnDoubleClick:q,mode:ee}),(te==="year"||te==="month")&&me.includes("month-days")&&r.jsx(In,{value:je,setValue:et,locale:u,className:k,weekDays:We,disabled:I,readOnly:J,leadingZero:$,period:te,periodicityOnDoubleClick:q,mode:ee}),(te==="year"||te==="month"||te==="week")&&me.includes("week-days")&&r.jsx(Vn,{value:We,setValue:nt,locale:u,className:k,humanizeLabels:U,monthDays:je,disabled:I,readOnly:J,period:te,periodicityOnDoubleClick:q,mode:ee}),r.jsxs("div",{children:[te!=="minute"&&te!=="hour"&&me.includes("hours")&&r.jsx(En,{value:rt,setValue:st,locale:u,className:k,disabled:I,readOnly:J,leadingZero:$,clockFormat:se,period:te,periodicityOnDoubleClick:q,mode:ee}),te!=="minute"&&me.includes("minutes")&&r.jsx(Mn,{value:it,setValue:lt,locale:u,period:te,className:k,disabled:I,readOnly:J,leadingZero:$,clockFormat:se,periodicityOnDoubleClick:q,mode:ee}),Bo]})]})]}))}const Wn={"zh-CN":{everyText:"每",emptyMonths:"每月",emptyMonthDays:"每日(月)",emptyMonthDaysShort:"每日",emptyWeekDays:"每天(周)",emptyWeekDaysShort:"每天(周)",emptyHours:"每小时",emptyMinutes:"每分钟",emptyMinutesForHourPeriod:"每",yearOption:"年",monthOption:"月",weekOption:"周",dayOption:"天",hourOption:"小时",minuteOption:"分钟",rebootOption:"重启",prefixPeriod:"每",prefixMonths:"的",prefixMonthDays:"的",prefixWeekDays:"的",prefixWeekDaysForMonthAndYearPeriod:"或者",prefixHours:"的",prefixMinutes:":",prefixMinutesForHourPeriod:"的",suffixMinutesForHourPeriod:"分钟",errorInvalidCron:"不符合 cron 规则的表达式",clearButtonText:"清空",weekDays:["周日","周一","周二","周三","周四","周五","周六"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],altWeekDays:["周日","周一","周二","周三","周四","周五","周六"],altMonths:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},yo=[{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 go(e){return yo.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function Ln(e){let t;switch(typeof e){case"number":return t=go(e),t?t.value:"none";case"string":return"cron"}return"none"}function zn({value:e,onChange:t}){const{t:o}=dt(),n=go(e);return r.jsx(y.InputNumber,{value:e/n.value,onChange:s=>t(s*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function Hn({value:e=null,onChange:t}){const{t:o}=dt(),n=Ln(e);function s(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const a=Wn[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:i.css`
|
|
465
|
+
`,children:[r.jsxs(y.Select,{value:n,onChange:s=>{t(s?s==="field"?{}:new Date:null)},className:"auto-width",children:[r.jsx(y.Select.Option,{value:null,children:o("No end")}),r.jsx(y.Select.Option,{value:"field",children:o("By field")}),r.jsx(y.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(no,{value:e,onChange:t}):null,n==="date"?r.jsx(y.DatePicker,{showTime:!0,value:zo(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var re=function(){return re=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;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 ro(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(o[n[s]]=e[n[s]])}return o}function Ke(e,t,o){if(o||arguments.length===2)for(var n,s=0,a=t.length;s<a;s++)!n&&s in t||(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}var Pn=[{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 * * * *"}],we=[{type:"minutes",min:0,max:59,total:60},{type:"hours",min:0,max:23,total:24},{type:"month-days",min:1,max:31,total:31},{type:"months",min:1,max:12,total:12,alt:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]},{type:"week-days",min:0,max:6,total:7,alt:["SUN","MON","TUE","WED","THU","FRI","SAT"]}],B={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function so(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function Ze(e){return e.sort(function(t,o){return t-o}),e}function io(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function ae(e){return Object.entries(e).filter(function(t){var o=t[0],n=t[1];return o&&n}).map(function(t){return t[0]}).join(" ")}function lo(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||B.errorInvalidCron})}function Qe(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function ao(e,t,o,n,s,a,l,c,u,d,f,h,x,v){o&&o(void 0),t(!1);var m=!1;if(!e){if(n==="always"||a&&n==="for-default-value")return;m=!0}if(!m){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void v("reboot");var k=Pn.find(function(A){return A.name===e});k&&(e=k.value)}try{var S=function(A){if(typeof A!="string")throw new Error("Invalid cron string");var P=A.replace(/\s+/g," ").trim().split(" ");if(P.length===5)return P.map(function(z,U){return function(F,M){if(F==="*"||F==="*/1")return[];var O=Ze(io(mo(function(L,J,ue){if(ue){L=L.toUpperCase();for(var D=0;D<ue.length;D++)L=L.replace(ue[D],"".concat(D+J))}return L}(F,M.min,M.alt).split(",").map(function(L){var J,ue=L.split("/");if(ue.length>2)throw new Error('Invalid value "'.concat(F,' for "').concat(M.type,'"'));var D=ue[0],V=ue[1];J=D==="*"?so(M.min,M.max):function(G,q,R){var ee=G.split("-");if(ee.length===1){var Ve=Qe(ee[0]);if(isNaN(Ve))throw new Error('Invalid value "'.concat(q,'" for ').concat(R.type));return[Ve]}if(ee.length===2){var fe=Qe(ee[0]),Ee=Qe(ee[1]);if(isNaN(fe)||isNaN(Ee))throw new Error('Invalid value "'.concat(q,'" for ').concat(R.type));if(Ee<fe)throw new Error('Max range is less than min range in "'.concat(G,'" for ').concat(R.type));return so(fe,Ee)}throw new Error('Invalid value "'.concat(G,'" for ').concat(R.type))}(D,F,M);var W=function(G,q){if(G!==void 0){var R=Qe(G);if(isNaN(R)||R<1)throw new Error('Invalid interval step value "'.concat(G,'" for ').concat(q.type));return R}}(V,M),se=function(G,q){if(q){var R=G[0];G=G.filter(function(ee){return ee%q==R%q||ee===R})}return G}(J,W);return se}).flat(),M))),I=fo(O,M);if(I!==void 0)throw new Error('Value "'.concat(I,'" out of range for ').concat(M.type));return O.length===M.total?[]:O}(z,we[U])});throw new Error("Invalid cron string format")}(e),E=function(A){return A[3].length>0?"year":A[2].length>0?"month":A[4].length>0?"week":A[1].length>0?"day":A[0].length>0?"hour":"minute"}(S);v(E),u(S[0]),d(S[1]),f(S[2]),h(S[3]),x(S[4])}catch(A){m=!0}}m&&(s.current=e,t(!0),lo(o,l))}function co(e,t,o,n,s,a,l){if(e==="reboot")return"@reboot";var c=function(u,d){return u.map(function(f,h){var x=we[h];return uo(po(f,x),x,d)})}([e!=="minute"&&a?a:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return c.join(" ")}function uo(e,t,o,n,s){var a="";if(function(c,u){return c.length===u.max-u.min+1}(e,t)||e.length===0)a="*";else{var l=function(c){if(c.length>2){var u=c[1]-c[0];if(u>1)return u}}(e);a=l&&function(c,u){for(var d=1;d<c.length;d++){var f=c[d-1];if(c[d]-f!==u)return!1}return!0}(e,l)?function(c,u,d){var f=ho(c),h=yo(c),x=c.length===(h-f)/d+1;return!!(f===u.min&&h+d>u.max&&x)}(e,t,l)?"*/".concat(l):"".concat(Oe(ho(e),t,o,n,s),"-").concat(Oe(yo(e),t,o,n,s),"/").concat(l):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],t,o,n,s),"-").concat(Oe(c[1],t,o,n,s)):Oe(c,t,o,n,s)}).join(",")}return a}function Oe(e,t,o,n,s){var a=e.toString(),l=t.type,c=t.alt,u=t.min,d=n&&(n===!0||n.includes(l)),f=s==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?a=c[e-u]:e<10&&(d||f)&&(a=a.padStart(2,"0")),l==="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 po(e,t){var o=Ze(io(mo(e,t)));if(o.length===0)return o;var n=fo(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function mo(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function fo(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function ho(e){return e[0]}function yo(e){return e[e.length-1]}function Be(e){var t=e.value,o=e.grid,n=o===void 0||o,s=e.optionsList,a=e.setValue,l=e.locale,c=e.className,u=e.humanizeLabels,d=e.disabled,f=e.readOnly,h=e.leadingZero,x=e.clockFormat,v=e.period,m=e.unit,k=e.periodicityOnDoubleClick,S=e.mode,E=ro(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),A=g.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(D){return D.toString()})},[t]),P=g.useMemo(function(){return s?s.map(function(D,V){return{value:(m.min===0?V:V+1).toString(),label:D}}):Ke([],Array(m.total),!0).map(function(D,V){var W=m.min===0?V:V+1;return{value:W.toString(),label:Oe(W,m,u,h,x)}})},[s,h,u,x]),z=JSON.stringify(l),U=g.useCallback(function(D){var V=D.value;if(!t||t[0]!==Number(V))return r.jsx(r.Fragment,{});var W=uo(po(t,m),m,u,h,x),se=W.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:se[1]?"".concat(l.everyText||B.everyText," ").concat(se[1]):W})},[t,z,u,h,x]),F=g.useCallback(function(D){var V=Array.isArray(D)?Ze(D):[D],W=V;t&&(W=S==="single"?[]:Ke([],t,!0),V.forEach(function(se){var G=Number(se);W=t.some(function(q){return q===G})?W.filter(function(q){return q!==G}):Ze(Ke(Ke([],W,!0),[G],!1))})),W.length===m.total?a([]):a(W)},[a,t]),M=g.useCallback(function(D){if(D!==0&&D!==1){for(var V=m.total+m.min,W=[],se=m.min;se<V;se++)se%D==0&&W.push(se);var G=t&&W&&t.length===W.length&&t.every(function(R,ee){return R===W[ee]}),q=W.length===P.length;a(q||G?[]:W)}else a([])},[t,P,a]),O=g.useRef([]),I=g.useCallback(function(D){if(!f){var V=O.current;V.push({time:new Date().getTime(),value:Number(D)});var W=window.setTimeout(function(){k&&V.length>1&&V[V.length-1].time-V[V.length-2].time<300?V[V.length-1].value===V[V.length-2].value?M(Number(D)):F([V[V.length-2].value,V[V.length-1].value]):F(Number(D)),O.current=[]},300);return function(){window.clearTimeout(W)}}},[O,F,M,f,k]),L=g.useCallback(function(){f||a([])},[a,f]),J=g.useMemo(function(){var D;return ae(((D={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,D))},[c]),ue=g.useMemo(function(){var D;return ae(((D={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(m.type)]=!0,D["react-js-cron-custom-select-dropdown"]=!0,D["react-js-cron-custom-select-dropdown-".concat(m.type)]=!0,D["react-js-cron-custom-select-dropdown-minutes-large"]=m.type==="minutes"&&v!=="hour"&&v!=="day",D["react-js-cron-custom-select-dropdown-minutes-medium"]=m.type==="minutes"&&(v==="day"||v==="hour"),D["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=m.type==="hours"&&x==="12-hour-clock",D["react-js-cron-custom-select-dropdown-grid"]=!!n,D["".concat(c,"-select-dropdown")]=!!c,D["".concat(c,"-select-dropdown-").concat(m.type)]=!!c,D))},[c,n,x,v]);return r.jsx(y.Select,re({mode:S!=="single"||k?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:A,onClear:L,tagRender:U,className:J,popupClassName:ue,options:P,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:I,onDeselect:I,disabled:d,dropdownAlign:m.type!=="minutes"&&m.type!=="hours"||v==="day"||v==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(m.type)},E))}function Bn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=g.useMemo(function(){var v;return ae(((v={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,v["".concat(s,"-hours")]=!!s,v))},[s]);return r.jsxs("div",re({className:x},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||B.prefixHours}),r.jsx(Be,{placeholder:n.emptyHours||B.emptyHours,value:t,unit:we[1],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:h})]}))}function Vn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=g.useMemo(function(){var v;return ae(((v={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,v["".concat(s,"-minutes")]=!!s,v))},[s]);return r.jsxs("div",re({className:x},{children:[d==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||B.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||B.prefixMinutes}),r.jsx(Be,{placeholder:d==="hour"?n.emptyMinutesForHourPeriod||B.emptyMinutesForHourPeriod:n.emptyMinutes||B.emptyMinutes,value:t,unit:we[0],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:h}),d==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||B.suffixMinutesForHourPeriod})]}))}function jn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.weekDays,l=e.disabled,c=e.readOnly,u=e.leadingZero,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=!a||a.length===0,v=g.useMemo(function(){var S;return ae(((S={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!x})["".concat(s,"-field")]=!!s,S["".concat(s,"-month-days")]=!!s,S))},[s,x]),m=JSON.stringify(n),k=g.useMemo(function(){return x?n.emptyMonthDays||B.emptyMonthDays:n.emptyMonthDaysShort||B.emptyMonthDaysShort},[x,m]);return!c||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?r.jsxs("div",re({className:v},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||B.prefixMonthDays}),r.jsx(Be,{placeholder:k,value:t,setValue:o,unit:we[2],locale:n,className:s,disabled:l,readOnly:c,leadingZero:u,period:d,periodicityOnDoubleClick:f,mode:h})]})):null}function Wn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.disabled,c=e.readOnly,u=e.period,d=e.periodicityOnDoubleClick,f=e.mode,h=n.months||B.months,x=g.useMemo(function(){var v;return ae(((v={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,v["".concat(s,"-months")]=!!s,v))},[s]);return r.jsxs("div",re({className:x},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||B.prefixMonths}),r.jsx(Be,{placeholder:n.emptyMonths||B.emptyMonths,optionsList:h,grid:!1,value:t,unit:re(re({},we[3]),{alt:n.altMonths||B.altMonths}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:l,readOnly:c,period:u,periodicityOnDoubleClick:d,mode:f})]}))}function Ln(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.shortcuts,u=e.allowedPeriods,d=[];u.includes("year")&&d.push({value:"year",label:n.yearOption||B.yearOption}),u.includes("month")&&d.push({value:"month",label:n.monthOption||B.monthOption}),u.includes("week")&&d.push({value:"week",label:n.weekOption||B.weekOption}),u.includes("day")&&d.push({value:"day",label:n.dayOption||B.dayOption}),u.includes("hour")&&d.push({value:"hour",label:n.hourOption||B.hourOption}),u.includes("minute")&&d.push({value:"minute",label:n.minuteOption||B.minuteOption}),u.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&d.push({value:"reboot",label:n.rebootOption||B.rebootOption});var f=g.useCallback(function(m){l||o(m)},[o,l]),h=g.useMemo(function(){var m;return ae(((m={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,m["".concat(s,"-period")]=!!s,m))},[s]),x=g.useMemo(function(){var m;return ae(((m={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(s,"-select")]=!!s,m))},[s,n.prefixPeriod]),v=g.useMemo(function(){var m;return ae(((m={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,m["".concat(s,"-select-dropdown-period")]=!!s,m))},[s]);return r.jsxs("div",re({className:h},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||B.prefixPeriod}),r.jsx(y.Select,{defaultValue:t,value:t,onChange:f,options:d,className:x,popupClassName:v,disabled:a,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function zn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.monthDays,c=e.disabled,u=e.readOnly,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=n.weekDays||B.weekDays,v=d==="week"||!l||l.length===0,m=g.useMemo(function(){var P;return ae(((P={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!v})["".concat(s,"-field")]=!!s,P["".concat(s,"-week-days")]=!!s,P))},[s,v]),k=JSON.stringify(n),S=g.useMemo(function(){return v?n.emptyWeekDays||B.emptyWeekDays:n.emptyWeekDaysShort||B.emptyWeekDaysShort},[v,k]),E=d==="week"||!u||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),A=!u||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return E?r.jsxs("div",re({className:m},{children:[n.prefixWeekDays!==""&&(d==="week"||!A)&&r.jsx("span",{children:n.prefixWeekDays||B.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&d!=="week"&&A&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||B.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(Be,{placeholder:S,optionsList:x,grid:!1,value:t,unit:re(re({},we[4]),{alt:n.altWeekDays||B.altWeekDays}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:c,readOnly:u,period:d,periodicityOnDoubleClick:f,mode:h})]})):null}function Hn(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,s=n===void 0?{}:n,a=e.clearButtonAction,l=a===void 0?"fill-with-every":a,c=e.locale,u=c===void 0?B:c,d=e.value,f=d===void 0?"":d,h=e.setValue,x=e.displayError,v=x===void 0||x,m=e.onError,k=e.className,S=e.defaultPeriod,E=S===void 0?"day":S,A=e.allowEmpty,P=A===void 0?"for-default-value":A,z=e.humanizeLabels,U=z===void 0||z,F=e.humanizeValue,M=F!==void 0&&F,O=e.disabled,I=O!==void 0&&O,L=e.readOnly,J=L!==void 0&&L,ue=e.leadingZero,D=ue!==void 0&&ue,V=e.shortcuts,W=V===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:V,se=e.clockFormat,G=e.periodicityOnDoubleClick,q=G===void 0||G,R=e.mode,ee=R===void 0?"multiple":R,Ve=e.allowedDropdowns,fe=Ve===void 0?["period","months","month-days","week-days","hours","minutes"]:Ve,Ee=e.allowedPeriods,gr=Ee===void 0?["year","month","week","day","hour","minute","reboot"]:Ee,Ne=g.useRef(f),Tt=g.useRef(E),So=g.useState(),be=So[0],Re=So[1],Ao=g.useState(),je=Ao[0],et=Ao[1],Oo=g.useState(),tt=Oo[0],ot=Oo[1],To=g.useState(),We=To[0],nt=To[1],Fo=g.useState(),rt=Fo[0],st=Fo[1],Eo=g.useState(),it=Eo[0],lt=Eo[1],No=g.useState(!1),Ft=No[0],Le=No[1],Do=g.useState(!1),at=Do[0],$o=Do[1],br=function(K){var he=g.useRef(K);return g.useEffect(function(){he.current=K},[K]),he.current}(at),Mo=JSON.stringify(u);g.useEffect(function(){ao(f,Le,m,P,Ne,!0,u,W,lt,st,et,ot,nt,Re)},[]),g.useEffect(function(){f!==Ne.current&&ao(f,Le,m,P,Ne,!1,u,W,lt,st,et,ot,nt,Re)},[f,Ne,Mo,P,W]),g.useEffect(function(){if(!(be||it||tt||je||We||rt)||at||br)at&&$o(!1);else{var K=be||Tt.current,he=co(K,tt,je,We,rt,it,M);h(he,{selectedPeriod:K}),Ne.current=he,m&&m(void 0),Le(!1)}},[be,je,tt,We,rt,it,M,at]);var Io=g.useCallback(function(){et(void 0),ot(void 0),nt(void 0),st(void 0),lt(void 0);var K="",he=be!=="reboot"&&be?be:Tt.current;he!==be&&Re(he),l==="fill-with-every"&&(K=co(he,void 0,void 0,void 0,void 0,void 0)),h(K,{selectedPeriod:he}),Ne.current=K,$o(!0),P==="never"&&l==="empty"?(Le(!0),lo(m,u)):(m&&m(void 0),Le(!1))},[be,h,m,l]),vr=g.useMemo(function(){var K;return ae(((K={"react-js-cron":!0,"react-js-cron-error":Ft&&v,"react-js-cron-disabled":I,"react-js-cron-read-only":J})["".concat(k)]=!!k,K["".concat(k,"-error")]=Ft&&v&&!!k,K["".concat(k,"-disabled")]=I&&!!k,K["".concat(k,"-read-only")]=J&&!!k,K))},[k,Ft,v,I,J]),Et=s.className,Po=ro(s,["className"]),Bo=g.useMemo(function(){var K;return ae(((K={"react-js-cron-clear-button":!0})["".concat(k,"-clear-button")]=!!k,K["".concat(Et)]=!!Et,K))},[k,Et]),xr=JSON.stringify(Po),Vo=g.useMemo(function(){return o&&!J?r.jsx(y.Button,re({className:Bo,danger:!0,type:"primary",disabled:I},Po,{onClick:Io},{children:u.clearButtonText||B.clearButtonText})):null},[o,J,Mo,Bo,I,xr,Io]),te=be||Tt.current;return r.jsxs("div",re({className:vr},{children:[fe.includes("period")&&r.jsx(Ln,{value:te,setValue:Re,locale:u,className:k,disabled:I,readOnly:J,shortcuts:W,allowedPeriods:gr}),te==="reboot"?Vo:r.jsxs(r.Fragment,{children:[te==="year"&&fe.includes("months")&&r.jsx(Wn,{value:tt,setValue:ot,locale:u,className:k,humanizeLabels:U,disabled:I,readOnly:J,period:te,periodicityOnDoubleClick:q,mode:ee}),(te==="year"||te==="month")&&fe.includes("month-days")&&r.jsx(jn,{value:je,setValue:et,locale:u,className:k,weekDays:We,disabled:I,readOnly:J,leadingZero:D,period:te,periodicityOnDoubleClick:q,mode:ee}),(te==="year"||te==="month"||te==="week")&&fe.includes("week-days")&&r.jsx(zn,{value:We,setValue:nt,locale:u,className:k,humanizeLabels:U,monthDays:je,disabled:I,readOnly:J,period:te,periodicityOnDoubleClick:q,mode:ee}),r.jsxs("div",{children:[te!=="minute"&&te!=="hour"&&fe.includes("hours")&&r.jsx(Bn,{value:rt,setValue:st,locale:u,className:k,disabled:I,readOnly:J,leadingZero:D,clockFormat:se,period:te,periodicityOnDoubleClick:q,mode:ee}),te!=="minute"&&fe.includes("minutes")&&r.jsx(Vn,{value:it,setValue:lt,locale:u,period:te,className:k,disabled:I,readOnly:J,leadingZero:D,clockFormat:se,periodicityOnDoubleClick:q,mode:ee}),Vo]})]})]}))}const Jn={"zh-CN":{everyText:"每",emptyMonths:"每月",emptyMonthDays:"每日(月)",emptyMonthDaysShort:"每日",emptyWeekDays:"每天(周)",emptyWeekDaysShort:"每天(周)",emptyHours:"每小时",emptyMinutes:"每分钟",emptyMinutesForHourPeriod:"每",yearOption:"年",monthOption:"月",weekOption:"周",dayOption:"天",hourOption:"小时",minuteOption:"分钟",rebootOption:"重启",prefixPeriod:"每",prefixMonths:"的",prefixMonthDays:"的",prefixWeekDays:"的",prefixWeekDaysForMonthAndYearPeriod:"或者",prefixHours:"的",prefixMinutes:":",prefixMinutesForHourPeriod:"的",suffixMinutesForHourPeriod:"分钟",errorInvalidCron:"不符合 cron 规则的表达式",clearButtonText:"清空",weekDays:["周日","周一","周二","周三","周四","周五","周六"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],altWeekDays:["周日","周一","周二","周三","周四","周五","周六"],altMonths:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},go=[{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 bo(e){return go.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function Un(e){let t;switch(typeof e){case"number":return t=bo(e),t?t.value:"none";case"string":return"cron"}return"none"}function _n({value:e,onChange:t}){const{t:o}=pt(),n=bo(e);return r.jsx(y.InputNumber,{value:e/n.value,onChange:s=>t(s*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function Gn({value:e=null,onChange:t}){const{t:o}=pt(),n=Un(e);function s(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const a=Jn[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:i.css`
|
|
463
466
|
display: flex;
|
|
464
467
|
flex-direction: ${n==="cron"?"column":"row"};
|
|
465
468
|
align-items: flex-start;
|
|
@@ -488,7 +491,7 @@
|
|
|
488
491
|
}
|
|
489
492
|
}
|
|
490
493
|
}
|
|
491
|
-
`,children:[r.jsx(y.Select,{value:n,onChange:s,className:"auto-width",children:
|
|
494
|
+
`,children:[r.jsx(y.Select,{value:n,onChange:s,className:"auto-width",children:go.map(l=>r.jsx(y.Select.Option,{value:l.value,children:o(l.text)},l.value))}),typeof n=="number"?r.jsx(_n,{value:e,onChange:t}):null,n==="cron"?r.jsx(Hn,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:l=>t(`0 ${l}`),clearButton:!1,locale:a}):null]})}const Yn={[xe.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}}},[xe.DATE_FIELD]:{collection:T(C({},le),{"x-component-props":{dataSourceFilter(e){return e.options.key==="main"||e.options.isDBInstance}},"x-reactions":[...le["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:T(C({},Pe),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${xe.DATE_FIELD} && $deps[1]}}`}}}]})}},qn=[{value:xe.STATIC,label:`{{t("Based on certain date", { ns: "${p}" })}}`},{value:xe.DATE_FIELD,label:`{{t("Based on date field of collection", { ns: "${p}" })}}`}],Kn=()=>{const{values:e={},clearFormGraph:t}=j.useForm(),[o,n]=g.useState(e.mode);return j.useFormEffects(()=>{ye.onFieldValueChange("mode",s=>{n(s.value),t("collection"),t("startsOn"),t("repeat"),t("endsOn"),t("limit")})}),r.jsxs(r.Fragment,{children:[r.jsx(i.SchemaComponent,{schema:{type:"number",title:`{{t("Trigger mode", { ns: "${p}" })}}`,name:"mode","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:qn},required:!0,default:xe.STATIC}}),r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`mode-${o}`]:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
|
|
492
495
|
.ant-input-number {
|
|
493
496
|
width: auto;
|
|
494
497
|
min-width: 6em;
|
|
@@ -497,29 +500,29 @@
|
|
|
497
500
|
.ant-picker {
|
|
498
501
|
width: auto;
|
|
499
502
|
}
|
|
500
|
-
`},properties:
|
|
503
|
+
`},properties:Yn[o]}}},components:{OnField:no,RepeatField:Gn,EndsByField:In}})]})};class Zn extends gt{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:i.useCollectionDataSource});w(this,"components",{ScheduleConfig:Kn})}useVariables(o,n){var c;const s=i.useCompile(),{getCollectionFields:a}=i.useCollectionManager_deprecated(),l=[];if((!(n!=null&&n.types)||n.types.includes("date"))&&l.push({key:"date",value:"date",label:N("Trigger time")}),o.mode===xe.DATE_FIELD){const[u]=Se(T(C({appends:["data",...((c=o.appends)==null?void 0:c.map(d=>`data.${d}`))||[]]},n),{fields:[{collectionName:o.collection,name:"data",type:"hasOne",target:o.collection,uiSchema:{title:N("Trigger data")}}],compile:s,getCollectionFields:a}));u&&l.push(u)}return l}useInitializers(o){return o.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Ie,collection:o.collection,dataPath:"$context.data"}:null}}function Te(e){const a=e,{options:t=[],direction:o}=a,n=Z(a,["options","direction"]),s=i.useCompile();return r.jsx(y.Radio.Group,T(C({},n),{children:r.jsx(y.Space,{direction:o,children:t.map(l=>r.jsxs(y.Radio,{value:l.value,children:[r.jsx("span",{className:i.css`
|
|
501
504
|
& + .anticon {
|
|
502
505
|
margin-left: 0.25em;
|
|
503
506
|
}
|
|
504
|
-
`,children:s(l.label)}),l.tooltip&&r.jsx(y.Tooltip,{title:s(l.tooltip),children:r.jsx(
|
|
507
|
+
`,children:s(l.label)}),l.tooltip&&r.jsx(y.Tooltip,{title:s(l.tooltip),children:r.jsx($.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}function vo(){const e=j.useFieldSchema(),t=i.useCompile();return r.jsxs(i.GeneralSchemaDesigner,{title:t(e.title),children:[r.jsx(i.SchemaSettingsBlockTitleItem,{}),r.jsx(i.SchemaSettingsDivider,{}),r.jsx(i.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Fe=()=>null;function Qn(){const a=i.useSchemaInitializerItem(),{node:t,resultTitle:o}=a,n=Z(a,["node","resultTitle"]),{insert:s}=i.useSchemaInitializer();return r.jsx(i.SchemaInitializerItem,T(C({},n),{onClick:()=>{var l;s({type:"void",name:t.id,title:t.title,"x-component":"CardItem","x-component-props":{title:(l=t.title)!=null?l:`#${t.id}`},"x-designer":"ValueBlock.Designer",properties:{result:{type:"void",title:o,"x-component":"ValueBlock.Result","x-component-props":{dataSource:`{{$jobsMapByNodeKey.${t.key}}}`}}}})}}))}function Xn({dataSource:e}){var s;const t=j.useFieldSchema(),{execution:o}=Y();if(!o)return t.title;const n=H.parse(e)({$jobsMapByNodeKey:((s=o.jobs)!=null?s:[]).reduce((a,l)=>Object.assign(a,{[l.nodeKey]:l.result}),{})});return r.jsx("pre",{className:i.css`
|
|
505
508
|
margin: 0;
|
|
506
|
-
`,children:JSON.stringify(n,null,2)})}
|
|
509
|
+
`,children:JSON.stringify(n,null,2)})}Fe.Initializer=Qn,Fe.Result=Xn,Fe.Designer=vo;const xo=e=>{const t=De.evaluators.get(e);return t&&t.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:i.css`
|
|
507
510
|
&:after {
|
|
508
511
|
content: ':';
|
|
509
512
|
}
|
|
510
513
|
& + a {
|
|
511
514
|
margin-left: 0.25em;
|
|
512
515
|
}
|
|
513
|
-
`,children:i.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class
|
|
516
|
+
`,children:i.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class Rn 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:De.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,n,{form:s}){const{values:a}=s,{evaluate:l}=De.evaluators.get(a.engine),c=o.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return l(c),""}catch(u){return N("Expression syntax error")}},"x-reactions":[{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0}});w(this,"scope",{renderEngineReference:xo});w(this,"components",{WorkflowVariableTextArea:Ot,RadioWithTooltip:Te,ValueBlock:Fe})}useVariables({key:o,title:n},{types:s,fieldNames:a=ke}){return s&&!s.some(l=>l in Ye||Object.values(Ye).some(c=>c.has(l)))?null:{value:o,label:n}}useInitializers(o){var n,s;return{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Fe.Initializer,node:o,resultTitle:N("Calculation result")}}}const X=new H.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 er=[{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 wo(e){return Array.from(X.getEntities()).filter(([t,o])=>o.group===e)}function tr({calculator:e,operands:t=[],onChange:o}){const n=i.useCompile(),s=me(),a=me(),l=g.useCallback(d=>o({calculator:e,operands:[d,t[1]]}),[e,o,t]),c=g.useCallback(d=>o({calculator:e,operands:[t[0],d]}),[e,o,t]),u=g.useCallback(d=>o({operands:t,calculator:d}),[o,t]);return r.jsxs("fieldset",{className:i.css`
|
|
514
517
|
display: flex;
|
|
515
518
|
gap: 0.5em;
|
|
516
519
|
align-items: center;
|
|
517
520
|
flex-wrap: wrap;
|
|
518
|
-
`,children:[r.jsx(i.Variable.Input,{value:t[0],onChange:
|
|
521
|
+
`,children:[r.jsx(i.Variable.Input,{changeOnSelect:!0,value:t[0],onChange:l,scope:s,useTypedConstant:!0}),r.jsx(y.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:u,placeholder:N("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:er.filter(d=>!!wo(d.value).length).map(d=>r.jsx(y.Select.OptGroup,{label:n(d.title),children:wo(d.value).map(([f,{name:h}])=>r.jsx(y.Select.Option,{value:f,children:n(h)},f))},d.value))}),r.jsx(i.Variable.Input,{changeOnSelect:!0,value:t[1],onChange:c,scope:a,useTypedConstant:!0})]})}function or({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:n,operands:s=[]}=e;return r.jsxs("div",{className:i.css`
|
|
519
522
|
display: flex;
|
|
520
523
|
position: relative;
|
|
521
524
|
margin: 0.5em 0;
|
|
522
|
-
`,children:[e.group?r.jsx(
|
|
525
|
+
`,children:[e.group?r.jsx(Co,{value:e.group,onChange:a=>t(T(C({},e),{group:a}))}):r.jsx(tr,{operands:s,calculator:n,onChange:t}),r.jsx(y.Button,{"aria-label":"icon-close",onClick:o,type:"link",icon:r.jsx($.CloseCircleOutlined,{})})]})}function Co({value:e,onChange:t}){const{t:o}=Q.useTranslation(),{type:n="and",calculations:s=[]}=e;function a(){t(T(C({},e),{calculations:[...s,{not:!1,calculator:"equal"}]}))}function l(){t(T(C({},e),{calculations:[...s,{not:!1,group:{type:"and",calculations:[]}}]}))}function c(d){s.splice(d,1),t(T(C({},e),{calculations:[...s]}))}function u(d,f){s.splice(d,1,f),t(T(C({},e),{calculations:[...s]}))}return r.jsxs("div",{className:i.cx("node-type-condition-group",i.css`
|
|
523
526
|
position: relative;
|
|
524
527
|
width: 100%;
|
|
525
528
|
.node-type-condition-group {
|
|
@@ -538,14 +541,18 @@
|
|
|
538
541
|
width: auto;
|
|
539
542
|
min-width: 6em;
|
|
540
543
|
}
|
|
541
|
-
`,children:r.jsxs(Q.Trans,{children:["Meet ",r.jsxs(y.Select,{role:"button","data-testid":"filter-select-all-or-any",value:n,onChange:d=>t(T(C({},e),{type:d})),children:[r.jsx(y.Select.Option,{value:"and",children:"All"}),r.jsx(y.Select.Option,{value:"or",children:"Any"})]})," conditions in the group"]})}),r.jsx("div",{className:"calculation-items",children:s.map((d,f)=>r.jsx(
|
|
544
|
+
`,children:r.jsxs(Q.Trans,{children:["Meet ",r.jsxs(y.Select,{role:"button","data-testid":"filter-select-all-or-any",value:n,onChange:d=>t(T(C({},e),{type:d})),children:[r.jsx(y.Select.Option,{value:"and",children:"All"}),r.jsx(y.Select.Option,{value:"or",children:"Any"})]})," conditions in the group"]})}),r.jsx("div",{className:"calculation-items",children:s.map((d,f)=>r.jsx(or,{value:d,onChange:u.bind(this,f),onRemove:()=>c(f)},`${d.calculator}_${f}`))}),r.jsxs("div",{className:i.css`
|
|
542
545
|
button {
|
|
543
546
|
padding: 0;
|
|
544
547
|
&:not(:last-child) {
|
|
545
548
|
margin-right: 1em;
|
|
546
549
|
}
|
|
547
550
|
}
|
|
548
|
-
`,children:[r.jsx(y.Button,{type:"link",onClick:a,children:o("Add condition")}),r.jsx(y.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function
|
|
551
|
+
`,children:[r.jsx(y.Button,{type:"link",onClick:a,children:o("Add condition")}),r.jsx(y.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function nr({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(Co,{value:o.group,onChange:n=>t(T(C({},o),{group:n}))})}class rr 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(De.evaluators.getEntities()).filter(([o])=>["math.js","formula.js"].includes(o))].reduce((o,[n,s])=>o.concat(C({value:n},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,n,{form:s}){const{values:a}=s,{evaluate:l}=De.evaluators.get(a.engine),c=o.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return l(c),""}catch(u){return N("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:xo,useWorkflowVariableOptions:me});w(this,"components",{CalculationConfig:nr,WorkflowVariableTextArea:Ot,RadioWithTooltip:Te})}Component({data:o}){const{t:n}=Q.useTranslation(),{nodes:s}=Y(),{styles:a}=ne(),{id:l,config:{rejectOnFalse:c}}=o,u=s.find(f=>f.upstreamId===l&&f.branchIndex===1),d=s.find(f=>f.upstreamId===l&&f.branchIndex===0);return r.jsx(yt,{data:o,children:c?null:r.jsxs("div",{className:a.nodeSubtreeClass,children:[r.jsxs("div",{className:a.branchBlockClass,children:[r.jsx(Ue,{from:o,entry:d,branchIndex:0}),r.jsx(Ue,{from:o,entry:u,branchIndex:1})]}),r.jsxs("div",{className:a.conditionClass,children:[r.jsx("span",{style:{right:"4em"},children:n("No")}),r.jsx("span",{style:{left:"4em"},children:n("Yes")})]})]})})}}class sr 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:ie.RESOLVED},{label:`{{t("Failed", { ns: "${p}" })}}`,value:ie.FAILED}],required:!0,default:ie.RESOLVED}});w(this,"end",!0)}}function Xe({value:e,onChange:t,renderSchemaComponent:o}){const n=me();return r.jsx(i.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}function ir(e){const{execution:t,nodes:o}=Y(),n=g.useMemo(()=>o.reduce((l,c)=>Object.assign(l,{[c.id]:c.key}),{}),[o]),s=g.useMemo(()=>{var l;return{$context:t==null?void 0:t.context,$jobsMapByNodeKey:((l=t==null?void 0:t.jobs)!=null?l:[]).reduce((c,u)=>Object.assign(c,{[n[u.nodeId]]:u.result}),{})}},[t==null?void 0:t.context,t==null?void 0:t.jobs,n]);return g.useMemo(()=>ut.get(s,e),[s,e])}function lr({collection:e,dataPath:t,children:o}){const n=j.useField(),s=g.useRef(null),{getAssociationAppends:a}=i.useAssociationNames(),{appends:l,updateAssociationValues:c}=a(),u=ir(t);let d,f;if(typeof e=="string"){const E=i.parseCollectionName(e);d=E[0],f=E[1]}else f=e;const h=g.useMemo(()=>ye.createForm({values:u,readPretty:!0}),[u]),x={appends:l},v={loading:!1,data:{data:u}},k=i.useAPIClient().resource(f),S=i.useBlockRequestContext();return r.jsx(i.CollectionProvider_deprecated,{dataSource:d,collection:f,children:r.jsx(i.RecordProvider,{record:u,parent:null,children:r.jsx(i.BlockRequestContext_deprecated.Provider,{value:{block:"form",field:n,service:v,resource:k,__parent:S},children:r.jsx(i.FormBlockContext.Provider,{value:{params:x,form:h,field:n,service:v,updateAssociationValues:c,formBlockRef:s},children:o})})})})}function ar(e){const a=e,{options:t=[],direction:o}=a,n=Z(a,["options","direction"]),s=i.useCompile();return r.jsx(y.Checkbox.Group,T(C({},n),{children:r.jsx(y.Space,{direction:o,children:t.map(l=>r.jsxs(y.Checkbox,{value:l.value,children:[r.jsx("span",{className:i.css`
|
|
552
|
+
& + .anticon {
|
|
553
|
+
margin-left: 0.25em;
|
|
554
|
+
}
|
|
555
|
+
`,children:s(l.label)}),l.tooltip&&r.jsx(y.Tooltip,{title:s(l.tooltip),children:r.jsx($.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}class cr 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:T(C({},le),{"x-reactions":[...le["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:Ge,sort:kn,pagination:Sn,appends:Pe},"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",{useCollectionDataSource:i.useCollectionDataSource,useSortableFields(){const o=i.useCompile(),{getCollectionFields:n,getInterface:s}=i.useCollectionManager_deprecated(),{values:a}=j.useForm();return n(a.collection).filter(c=>{if(!c.interface)return!1;const u=s(c.interface);return!!(u!=null&&u.sortable)}).map(c=>{var u,d;return{value:c.name,label:(u=c==null?void 0:c.uiSchema)!=null&&u.title?o((d=c==null?void 0:c.uiSchema)==null?void 0:d.title):c.name}})}});w(this,"components",{ArrayItems:Ho.ArrayItems,FilterDynamicComponent:Xe,SchemaComponentContext:i.SchemaComponentContext,WorkflowVariableInput:to,RadioWithTooltip:Te})}useVariables({key:o,title:n,config:s},a){var d,f;const l=i.useCompile(),{getCollectionFields:c}=i.useCollectionManager_deprecated(),[u]=Se(T(C({appends:[o,...((f=(d=s.params)==null?void 0:d.appends)==null?void 0:f.map(h=>`${o}.${h}`))||[]]},a),{fields:[{collectionName:s.collection,name:o,type:"hasOne",target:s.collection,uiSchema:{title:n}}],compile:l,getCollectionFields:c}));return u}useInitializers(o){var n,s;return!o.config.collection||o.config.multiple?null:{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Ie,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}}}function ur(e){const{getCollectionFields:t}=i.useCollectionManager_deprecated(),{path:o}=j.useField(),n=o.segments[o.segments.length-1],{values:s}=j.useForm(),[a,l]=i.parseCollectionName(s==null?void 0:s.collection),c=t(l,a),{type:u}=c.find(h=>h.name===n),d=Array.isArray(e.value)?e.value.join(","):e.value,f=g.useCallback(h=>{const x=h.target.value.trim(),v=["belongsTo","hasOne"].includes(u)?x||null:x.split(",").map(m=>m.trim()).filter(m=>m!=="");e.onChange(v)},[e.onChange,u]);return r.jsx(y.Input,T(C({},e),{value:d,onChange:f}))}const ko=j.observer(({value:e,disabled:t,onChange:o,filter:n})=>{const{token:s}=i.useToken(),{t:a}=Q.useTranslation(),l=i.useCompile(),c=j.useForm(),{getCollectionFields:u}=i.useCollectionManager_deprecated(),d=me(),{values:f}=c,[h,x]=i.parseCollectionName(f==null?void 0:f.collection),v=u(x,h).filter(A=>A.uiSchema),m=n?v.filter(n.bind(f)):v,k=g.useMemo(()=>m.filter(A=>!e||!(A.name in e)),[m,e]),S=t||c.disabled,E=g.useMemo(()=>({onClick:({key:A})=>{o(T(C({},e),{[A]:null}))},style:{maxHeight:300,overflowY:"auto"},items:k.map(A=>{var P,z;return{key:A.name,label:l((z=(P=A.uiSchema)==null?void 0:P.title)!=null?z:A.name)}})}),[o,k,e]);return r.jsx("fieldset",{className:i.css`
|
|
549
556
|
margin-top: 0.5em;
|
|
550
557
|
|
|
551
558
|
> .ant-formily-item {
|
|
@@ -555,12 +562,8 @@
|
|
|
555
562
|
line-height: 32px;
|
|
556
563
|
}
|
|
557
564
|
}
|
|
558
|
-
`,children:m.length?r.jsxs(i.CollectionProvider_deprecated,{name:
|
|
565
|
+
`,children:m.length?r.jsxs(i.CollectionProvider_deprecated,{name:x,dataSource:h,children:[m.filter(A=>e&&A.name in e).map(A=>{var z,U;const P=["belongsTo","hasOne","hasMany","belongsToMany"].includes(A.type)?ur:i.CollectionField;return r.jsxs(y.Form.Item,{label:l((U=(z=A.uiSchema)==null?void 0:z.title)!=null?U:A.name),labelAlign:"left",className:i.css`
|
|
559
566
|
.ant-form-item-control-input-content {
|
|
560
567
|
display: flex;
|
|
561
568
|
}
|
|
562
|
-
`,children:[r.jsx(i.Variable.Input,{scope:d,value:e[A.name],changeOnSelect:!0,onChange:F=>{o(T(C({},e),{[A.name]:F}))},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[A.name]:{"x-component":P,"x-validator"(){return""}}}}})}),S?null:r.jsx(y.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx(
|
|
563
|
-
& + .anticon {
|
|
564
|
-
margin-left: 0.25em;
|
|
565
|
-
}
|
|
566
|
-
`,children:s(l.label)}),l.tooltip&&r.jsx(y.Tooltip,{title:s(l.tooltip),children:r.jsx(E.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}function pr({children:e,workflow:t,execution:o,nodes:n}){const s=i.usePlugin(ce),a=s.triggers.get(t.type).components,l=n.reduce((c,{type:u})=>Object.assign(c,s.instructions.get(u).components),{});return r.jsx($e.Provider,{value:{workflow:t,nodes:n,execution:o},children:r.jsx(i.SchemaComponentOptions,{components:C(C({},a),l),children:e})})}class ce extends i.Plugin{constructor(){super(...arguments);w(this,"triggers",new H.Registry);w(this,"instructions",new H.Registry);w(this,"getTriggersOptions",()=>Array.from(this.triggers.getEntities()).map(a=>{var[o,l]=a,c=l,{title:n}=c,s=Z(c,["title"]);return{value:o,label:n,color:"gold",options:s}}))}isWorkflowSync(o){var n;return(n=this.triggers.get(o.type).sync)!=null?n:o.sync}registerTrigger(o,n){if(typeof n=="function")this.triggers.register(o,new n);else if(n)this.triggers.register(o,n);else throw new TypeError("invalid trigger type to register")}registerInstruction(o,n){if(typeof n=="function")this.instructions.register(o,new n);else if(n instanceof ye)this.instructions.register(o,n);else throw new TypeError("invalid instruction type to register")}load(){return _(this,null,function*(){this.app.router.add("admin.workflow.workflows.id",{path:xe(":id"),element:r.jsx(Gt,{})}),this.app.router.add("admin.workflow.executions.id",{path:_e(":id"),element:r.jsx(Lt,{})}),this.app.addComponents({WorkflowPage:Gt,ExecutionPage:Lt}),this.app.pluginSettingsManager.add(p,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${p}" })}}`,Component:yn,aclSnippet:"pm.workflow.workflows"}),this.app.schemaSettingsManager.add(ar),this.registerTrigger("collection",Fn),this.registerTrigger("schedule",Gn),this.registerInstruction("calculation",Kn),this.registerInstruction("condition",er),this.registerInstruction("end",tr),this.registerInstruction("query",or),this.registerInstruction("create",rr),this.registerInstruction("update",ir),this.registerInstruction("destroy",lr)})}}g.BaseTypeSets=Ye,g.Branch=Ue,g.CheckboxGroupWithTooltip=dr,g.CollectionBlockInitializer=Me,g.DetailsBlockProvider=ur,g.EXECUTION_STATUS=de,g.ExecutionContextProvider=pr,g.ExecutionStatusOptions=ze,g.ExecutionStatusOptionsMap=He,g.FieldsSelect=vt,g.FilterDynamicComponent=Xe,g.FlowContext=$e,g.Instruction=ye,g.JOB_STATUS=ie,g.JobButton=jt,g.JobStatusOptions=mt,g.JobStatusOptionsMap=Je,g.Node=Bt,g.NodeContext=ft,g.NodeDefaultView=ht,g.RadioWithTooltip=Be,g.RemoveButton=Vt,g.SimpleDesigner=bo,g.Trigger=yt,g.ValueBlock=Te,g.WorkflowVariableInput=eo,g.WorkflowVariableJSON=kn,g.WorkflowVariableRawTextArea=Cn,g.WorkflowVariableTextArea=At,g.default=ce,g.defaultFieldNames=ke,g.getCollectionFieldOptions=Se,g.getWorkflowDetailPath=xe,g.getWorkflowExecutionsPath=_e,g.linkNodes=bt,g.nodesOptions=Kt,g.scopeOptions=Qt,g.systemOptions=Xt,g.traverseSchema=xt,g.triggerOptions=Zt,g.useAvailableUpstreams=It,g.useFlowContext=Y,g.useGetAriaLabelOfAddButton=pt,g.useNodeContext=Ce,g.useRecordTriggerWorkflowsActionProps=An,g.useStyles=ne,g.useTrigger=gt,g.useTriggerWorkflowsActionProps=Sn,g.useUpstreamScopes=Pt,g.useWorkflowAnyExecuted=to,g.useWorkflowExecuted=On,g.useWorkflowVariableOptions=ge,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
569
|
+
`,children:[r.jsx(i.Variable.Input,{scope:d,value:e[A.name],changeOnSelect:!0,onChange:F=>{o(T(C({},e),{[A.name]:F}))},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[A.name]:{"x-component":P,"x-validator"(){return""}}}}})}),S?null:r.jsx(y.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx($.CloseCircleOutlined,{}),onClick:()=>{var O;const I=e,{[O=A.name]:F}=I,M=Z(I,[Lo(O)]);o(M)}})]},A.name)}),k.length?r.jsx(y.Dropdown,{menu:E,children:r.jsx(y.Button,{icon:r.jsx($.PlusOutlined,{}),children:a("Add field")})}):null]}):r.jsx("p",{style:{color:s.colorText},children:N("Please select collection first")})})},{displayName:"CollectionFieldSet"});class dr 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:T(C({},le),{"x-reactions":[...le["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{values:Kt,appends:Pe}}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource});w(this,"components",{CollectionFieldset:ko})}useVariables({key:o,title:n,config:s},a){var d,f;const l=i.useCompile(),{getCollectionFields:c}=i.useCollectionManager_deprecated(),[u]=Se(T(C({appends:[o,...((f=(d=s.params)==null?void 0:d.appends)==null?void 0:f.map(h=>`${o}.${h}`))||[]]},a),{fields:[{collectionName:s.collection,name:o,type:"hasOne",target:s.collection,uiSchema:{title:n}}],compile:l,getCollectionFields:c}));return u}useInitializers(o){var n,s;return o.config.collection?{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Ie,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}:null}}function pr(o){var n=o,{onChange:e}=n,t=Z(n,["onChange"]);const{getCollectionFields:s}=i.useCollectionManager_deprecated(),a=j.useForm(),{collection:l}=a.values,c=s(l),u=j.useField();function d({target:f}){const h=u.query(".values").take();if(!h)return;const x=c.reduce((v,m)=>(m.name in h.value&&(f.value||!["hasOne","hasMany","belongsToMany"].includes(m.type))&&(v[m.name]=h.value[m.name]),v),{});a.setValuesIn("params.values",x),e(f.value)}return r.jsx(Te,T(C({},t),{onChange:d}))}class mr 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:T(C({},le),{"x-reactions":[...le["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":"IndividualHooksRadioWithTooltip","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:T(C({},Ge),{title:`{{t("Only update records matching conditions", { ns: "${p}" })}}`,"x-validator"(o){return H.isValidFilter(o)?"":N("Please add at least one condition")}}),values:T(C({},Kt),{"x-component-props":{filter(o){var n;return((n=this.params)==null?void 0:n.individualHooks)||!["hasOne","hasMany","belongsToMany"].includes(o.type)}}})}}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource});w(this,"components",{FilterDynamicComponent:Xe,CollectionFieldset:ko,IndividualHooksRadioWithTooltip:pr})}}class fr 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:T(C({},le),{"x-reactions":[...le["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:T(C({},Ge),{"x-validator"(o){return H.isValidFilter(o)?"":N("Please add at least one condition")}})}}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource});w(this,"components",{FilterDynamicComponent:Xe})}}const hr=new i.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:i.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=i.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:i.SecondConFirm},{name:"assignFieldValues",Component:i.AssignedFieldValues},{name:"skipRequiredValidation",Component:i.SkipValidation},{name:"afterSuccessfulSubmission",Component:i.AfterSuccess,useVisible(){var t;const e=j.useFieldSchema();return Dt.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.onSuccess)}},{name:"bindWorkflow",Component:i.WorkflowConfig},{name:"delete",sort:100,Component:i.RemoveButton,useComponentProps(){const{removeButtonProps:e}=i.useSchemaToolbar();return e}}]});function yr({children:e,workflow:t,execution:o,nodes:n}){const s=i.usePlugin(ce),a=s.triggers.get(t.type).components,l=n.reduce((c,{type:u})=>Object.assign(c,s.instructions.get(u).components),{});return r.jsx($e.Provider,{value:{workflow:t,nodes:n,execution:o},children:r.jsx(i.SchemaComponentOptions,{components:C(C({},a),l),children:e})})}class ce extends i.Plugin{constructor(){super(...arguments);w(this,"triggers",new H.Registry);w(this,"instructions",new H.Registry);w(this,"getTriggersOptions",()=>Array.from(this.triggers.getEntities()).map(a=>{var[o,l]=a,c=l,{title:n}=c,s=Z(c,["title"]);return{value:o,label:n,color:"gold",options:s}}))}isWorkflowSync(o){var n;return(n=this.triggers.get(o.type).sync)!=null?n:o.sync}registerTrigger(o,n){if(typeof n=="function")this.triggers.register(o,new n);else if(n)this.triggers.register(o,n);else throw new TypeError("invalid trigger type to register")}registerInstruction(o,n){if(typeof n=="function")this.instructions.register(o,new n);else if(n instanceof ge)this.instructions.register(o,n);else throw new TypeError("invalid instruction type to register")}load(){return _(this,null,function*(){this.app.router.add("admin.workflow.workflows.id",{path:ve(":id"),element:r.jsx(Yt,{})}),this.app.router.add("admin.workflow.executions.id",{path:_e(":id"),element:r.jsx(zt,{})}),this.app.addComponents({WorkflowPage:Yt,ExecutionPage:zt}),this.app.pluginSettingsManager.add(p,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${p}" })}}`,Component:xn,aclSnippet:"pm.workflow.workflows"}),this.app.schemaSettingsManager.add(hr),this.registerTrigger("collection",$n),this.registerTrigger("schedule",Zn),this.registerInstruction("calculation",Rn),this.registerInstruction("condition",rr),this.registerInstruction("end",sr),this.registerInstruction("query",cr),this.registerInstruction("create",dr),this.registerInstruction("update",mr),this.registerInstruction("destroy",fr)})}}b.BaseTypeSets=Ye,b.Branch=Ue,b.CheckboxGroupWithTooltip=ar,b.CollectionBlockInitializer=Ie,b.DetailsBlockProvider=lr,b.EXECUTION_STATUS=de,b.ExecutionContextProvider=yr,b.ExecutionStatusOptions=ze,b.ExecutionStatusOptionsMap=He,b.FieldsSelect=wt,b.FilterDynamicComponent=Xe,b.FlowContext=$e,b.Instruction=ge,b.JOB_STATUS=ie,b.JobButton=Wt,b.JobStatusOptions=ft,b.JobStatusOptionsMap=Je,b.Node=Vt,b.NodeContext=ht,b.NodeDefaultView=yt,b.RadioWithTooltip=Te,b.RemoveButton=jt,b.SimpleDesigner=vo,b.Trigger=gt,b.ValueBlock=Fe,b.WorkflowVariableInput=to,b.WorkflowVariableJSON=Tn,b.WorkflowVariableRawTextArea=On,b.WorkflowVariableTextArea=Ot,b.default=ce,b.defaultFieldNames=ke,b.getCollectionFieldOptions=Se,b.getWorkflowDetailPath=ve,b.getWorkflowExecutionsPath=_e,b.linkNodes=vt,b.nodesOptions=Zt,b.scopeOptions=Xt,b.systemOptions=Rt,b.traverseSchema=xt,b.triggerOptions=Qt,b.useAvailableUpstreams=Pt,b.useFlowContext=Y,b.useGetAriaLabelOfAddButton=mt,b.useNodeContext=Ce,b.useRecordTriggerWorkflowsActionProps=En,b.useStyles=ne,b.useTrigger=bt,b.useTriggerWorkflowsActionProps=Fn,b.useUpstreamScopes=Bt,b.useWorkflowAnyExecuted=oo,b.useWorkflowExecuted=Nn,b.useWorkflowVariableOptions=me,Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -11,6 +11,7 @@ import { SchemaInitializerItemType, useCollectionDataSource } from '@nocobase/cl
|
|
|
11
11
|
import { FilterDynamicComponent } from '../components/FilterDynamicComponent';
|
|
12
12
|
import { WorkflowVariableInput } from '../variable';
|
|
13
13
|
import { Instruction } from '.';
|
|
14
|
+
import { RadioWithTooltip } from '../components';
|
|
14
15
|
export default class extends Instruction {
|
|
15
16
|
title: string;
|
|
16
17
|
type: string;
|
|
@@ -27,10 +28,18 @@ export default class extends Instruction {
|
|
|
27
28
|
};
|
|
28
29
|
multiple: {
|
|
29
30
|
type: string;
|
|
31
|
+
title: string;
|
|
30
32
|
'x-decorator': string;
|
|
31
33
|
'x-component': string;
|
|
32
|
-
'x-
|
|
33
|
-
|
|
34
|
+
'x-component-props': {
|
|
35
|
+
options: {
|
|
36
|
+
label: string;
|
|
37
|
+
value: boolean;
|
|
38
|
+
tooltip: string;
|
|
39
|
+
}[];
|
|
40
|
+
};
|
|
41
|
+
required: boolean;
|
|
42
|
+
default: boolean;
|
|
34
43
|
};
|
|
35
44
|
params: {
|
|
36
45
|
type: string;
|
|
@@ -212,6 +221,7 @@ export default class extends Instruction {
|
|
|
212
221
|
FilterDynamicComponent: typeof FilterDynamicComponent;
|
|
213
222
|
SchemaComponentContext: import("react").Context<import("@nocobase/client").ISchemaComponentContext>;
|
|
214
223
|
WorkflowVariableInput: typeof WorkflowVariableInput;
|
|
224
|
+
RadioWithTooltip: typeof RadioWithTooltip;
|
|
215
225
|
};
|
|
216
226
|
useVariables({ key: name, title, config }: {
|
|
217
227
|
key: any;
|
package/dist/externalVersion.js
CHANGED
|
@@ -11,23 +11,23 @@ module.exports = {
|
|
|
11
11
|
"react": "18.2.0",
|
|
12
12
|
"antd": "5.12.8",
|
|
13
13
|
"@ant-design/icons": "5.2.6",
|
|
14
|
-
"@nocobase/client": "1.0.
|
|
14
|
+
"@nocobase/client": "1.0.1-alpha.1",
|
|
15
15
|
"react-router-dom": "6.21.0",
|
|
16
|
-
"@nocobase/utils": "1.0.
|
|
16
|
+
"@nocobase/utils": "1.0.1-alpha.1",
|
|
17
17
|
"react-i18next": "11.18.6",
|
|
18
18
|
"@formily/core": "2.3.0",
|
|
19
19
|
"@formily/react": "2.3.0",
|
|
20
|
-
"@nocobase/database": "1.0.
|
|
21
|
-
"@nocobase/server": "1.0.
|
|
22
|
-
"@nocobase/logger": "1.0.
|
|
23
|
-
"@nocobase/evaluators": "1.0.
|
|
20
|
+
"@nocobase/database": "1.0.1-alpha.1",
|
|
21
|
+
"@nocobase/server": "1.0.1-alpha.1",
|
|
22
|
+
"@nocobase/logger": "1.0.1-alpha.1",
|
|
23
|
+
"@nocobase/evaluators": "1.0.1-alpha.1",
|
|
24
24
|
"@formily/shared": "2.3.0",
|
|
25
25
|
"lodash": "4.17.21",
|
|
26
26
|
"@formily/antd-v5": "1.1.9",
|
|
27
|
-
"@nocobase/actions": "1.0.
|
|
28
|
-
"@nocobase/data-source-manager": "1.0.
|
|
27
|
+
"@nocobase/actions": "1.0.1-alpha.1",
|
|
28
|
+
"@nocobase/data-source-manager": "1.0.1-alpha.1",
|
|
29
29
|
"sequelize": "6.35.2",
|
|
30
|
-
"@nocobase/plugin-workflow-test": "1.0.
|
|
31
|
-
"@nocobase/test": "1.0.
|
|
30
|
+
"@nocobase/plugin-workflow-test": "1.0.1-alpha.1",
|
|
31
|
+
"@nocobase/test": "1.0.1-alpha.1",
|
|
32
32
|
"dayjs": "1.11.10"
|
|
33
33
|
};
|
package/dist/locale/zh-CN.json
CHANGED
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"适用于需要即时反馈的用户操作。不能在此模式下使用异步节点,并且不建议在同步模式下执行耗时的操作。",
|
|
38
38
|
"Go back": "返回",
|
|
39
39
|
"Bind workflows": "绑定工作流",
|
|
40
|
-
"Workflow will be triggered before or after submitting succeeded based on workflow type.": "
|
|
40
|
+
"Workflow will be triggered before or after submitting succeeded based on workflow type (supports pre/post action event in local mode, and approval event).": "工作流会基于其类型在提交成功之前或之后触发(支持局部模式的操作前、操作后事件,和审批事件)。",
|
|
41
41
|
"Workflow will be triggered directly once the button clicked, without data saving. Only supports to be bound with \"Custom action event\".": "按钮点击后直接触发工作流,但不会保存数据。仅支持绑定“自定义操作事件”。",
|
|
42
42
|
"\"Submit to workflow\" to \"Post-action event\" is deprecated, please use \"Custom action event\" instead.": "“提交至工作流”到“操作后事件”的方式已被弃用,请使用“自定义操作事件”代替。",
|
|
43
|
-
"Workflow will be triggered before deleting succeeded.": "
|
|
43
|
+
"Workflow will be triggered before deleting succeeded (only supports pre-action event in local mode).": "删除成功之前触发工作流(支持操作前事件)。",
|
|
44
44
|
"Submit to workflow": "提交至工作流",
|
|
45
45
|
"Add workflow": "添加工作流",
|
|
46
46
|
"Select workflow": "选择工作流",
|
|
@@ -173,6 +173,11 @@
|
|
|
173
173
|
"Allow multiple records as result": "允许结果是多条数据",
|
|
174
174
|
"If checked, when there are multiple records in the query result, an array will be returned as the result, which can be operated on one by one using a loop node. Otherwise, only one record will be returned.":
|
|
175
175
|
"选中后,当查询结果有多条记录时,会返回数组作为结果,可以使用循环节点对它逐条操作;否则,仅返回一条数据。",
|
|
176
|
+
"Result type": "结果类型",
|
|
177
|
+
"Single record": "单条数据",
|
|
178
|
+
"Multiple records": "多条数据",
|
|
179
|
+
"The result will be an object of the first matching record only, or null if no matched record.": "结果是一个对象,仅为首条匹配的记录,或空值。",
|
|
180
|
+
"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.": "结果会是一个数组,包含匹配条件的记录,没有匹配记录则为空数组。可以通过循环节点逐个处理。",
|
|
176
181
|
"Exit when query result is null": "查询结果为空时,退出流程",
|
|
177
182
|
"Please select collection first": "请先选择数据表",
|
|
178
183
|
"Only update records matching conditions": "只更新满足条件的数据",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"cron-parser","version":"4.4.0","description":"Node.js library for parsing crontab instructions","main":"lib/parser.js","types":"index.d.ts","typesVersions":{"<4.1":{"*":["types/ts3/*"]}},"directories":{"test":"test"},"scripts":{"test:tsd":"tsd","test:unit":"TZ=UTC tap ./test/*.js","test:cover":"TZ=UTC tap --coverage-report=html ./test/*.js","lint":"eslint .","lint:fix":"eslint --fix .","test":"npm run lint && npm run test:unit && npm run test:tsd"},"repository":{"type":"git","url":"https://github.com/harrisiirak/cron-parser.git"},"keywords":["cron","crontab","parser"],"author":"Harri Siirak","contributors":["Nicholas Clawson","Daniel Prentis <daniel@salsitasoft.com>","Renault John Lecoultre","Richard Astbury <richard.astbury@gmail.com>","Meaglin Wasabi <Meaglin.wasabi@gmail.com>","Mike Kusold <hello@mikekusold.com>","Alex Kit <alex.kit@atmajs.com>","Santiago Gimeno <santiago.gimeno@gmail.com>","Daniel <darc.tec@gmail.com>","Christian Steininger <christian.steininger.cs@gmail.com>","Mykola Piskovyi <m.piskovyi@gmail.com>","Brian Vaughn <brian.david.vaughn@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Yasuhiroki <yasuhiroki.duck@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Brendan Warkentin <faazshift@gmail.com>","Charlie Fish <fishcharlie.code@gmail.com>","Ian Graves <ian+diskimage@iangrav.es>","Andy Thompson <me@andytson.com>","Regev Brody <regevbr@gmail.com>"],"license":"MIT","dependencies":{"luxon":"^1.28.0"},"devDependencies":{"eslint":"^8.2.0","sinon":"^10.0.0","tap":"^16.0.1","tsd":"^0.19.0"},"engines":{"node":">=0.8"},"browser":{"fs":false},"tap":{"check-coverage":false},"tsd":{"directory":"test","compilerOptions":{"lib":["es2017","dom"]}},"_lastModified":"2024-
|
|
1
|
+
{"name":"cron-parser","version":"4.4.0","description":"Node.js library for parsing crontab instructions","main":"lib/parser.js","types":"index.d.ts","typesVersions":{"<4.1":{"*":["types/ts3/*"]}},"directories":{"test":"test"},"scripts":{"test:tsd":"tsd","test:unit":"TZ=UTC tap ./test/*.js","test:cover":"TZ=UTC tap --coverage-report=html ./test/*.js","lint":"eslint .","lint:fix":"eslint --fix .","test":"npm run lint && npm run test:unit && npm run test:tsd"},"repository":{"type":"git","url":"https://github.com/harrisiirak/cron-parser.git"},"keywords":["cron","crontab","parser"],"author":"Harri Siirak","contributors":["Nicholas Clawson","Daniel Prentis <daniel@salsitasoft.com>","Renault John Lecoultre","Richard Astbury <richard.astbury@gmail.com>","Meaglin Wasabi <Meaglin.wasabi@gmail.com>","Mike Kusold <hello@mikekusold.com>","Alex Kit <alex.kit@atmajs.com>","Santiago Gimeno <santiago.gimeno@gmail.com>","Daniel <darc.tec@gmail.com>","Christian Steininger <christian.steininger.cs@gmail.com>","Mykola Piskovyi <m.piskovyi@gmail.com>","Brian Vaughn <brian.david.vaughn@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Yasuhiroki <yasuhiroki.duck@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Brendan Warkentin <faazshift@gmail.com>","Charlie Fish <fishcharlie.code@gmail.com>","Ian Graves <ian+diskimage@iangrav.es>","Andy Thompson <me@andytson.com>","Regev Brody <regevbr@gmail.com>"],"license":"MIT","dependencies":{"luxon":"^1.28.0"},"devDependencies":{"eslint":"^8.2.0","sinon":"^10.0.0","tap":"^16.0.1","tsd":"^0.19.0"},"engines":{"node":">=0.8"},"browser":{"fs":false},"tap":{"check-coverage":false},"tsd":{"directory":"test","compilerOptions":{"lib":["es2017","dom"]}},"_lastModified":"2024-06-07T14:04:55.171Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"lru-cache","description":"A cache object that deletes the least-recently-used items.","version":"8.0.5","author":"Isaac Z. Schlueter <i@izs.me>","keywords":["mru","lru","cache"],"sideEffects":false,"scripts":{"build":"npm run prepare","preprepare":"rm -rf dist","prepare":"tsc -p tsconfig.json && tsc -p tsconfig-esm.json","postprepare":"bash fixup.sh","pretest":"npm run prepare","presnap":"npm run prepare","test":"c8 tap","snap":"c8 tap","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","format":"prettier --write .","typedoc":"typedoc --tsconfig tsconfig-esm.json ./src/*.ts","benchmark-results-typedoc":"bash scripts/benchmark-results-typedoc.sh","prebenchmark":"npm run prepare","benchmark":"make -C benchmark","preprofile":"npm run prepare","profile":"make -C benchmark profile"},"main":"./dist/cjs/index-cjs.js","module":"./dist/mjs/index.js","types":"./dist/mjs/index.d.ts","exports":{"./min":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.min.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.min.js"}},".":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index-cjs.js"}}},"repository":"git://github.com/isaacs/node-lru-cache.git","devDependencies":{"@size-limit/preset-small-lib":"^7.0.8","@types/node":"^17.0.31","@types/tap":"^15.0.6","benchmark":"^2.1.4","c8":"^7.11.2","clock-mock":"^1.0.6","esbuild":"^0.17.11","eslint-config-prettier":"^8.5.0","marked":"^4.2.12","mkdirp":"^2.1.5","prettier":"^2.6.2","size-limit":"^7.0.8","tap":"^16.3.4","ts-node":"^10.7.0","tslib":"^2.4.0","typedoc":"^0.23.24","typescript":"^4.6.4"},"license":"ISC","files":["dist"],"engines":{"node":">=16.14"},"prettier":{"semi":false,"printWidth":70,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"tap":{"coverage":false,"node-arg":["--expose-gc","--no-warnings","--loader","ts-node/esm"],"ts":false},"size-limit":[{"path":"./dist/mjs/index.js"}],"_lastModified":"2024-
|
|
1
|
+
{"name":"lru-cache","description":"A cache object that deletes the least-recently-used items.","version":"8.0.5","author":"Isaac Z. Schlueter <i@izs.me>","keywords":["mru","lru","cache"],"sideEffects":false,"scripts":{"build":"npm run prepare","preprepare":"rm -rf dist","prepare":"tsc -p tsconfig.json && tsc -p tsconfig-esm.json","postprepare":"bash fixup.sh","pretest":"npm run prepare","presnap":"npm run prepare","test":"c8 tap","snap":"c8 tap","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","format":"prettier --write .","typedoc":"typedoc --tsconfig tsconfig-esm.json ./src/*.ts","benchmark-results-typedoc":"bash scripts/benchmark-results-typedoc.sh","prebenchmark":"npm run prepare","benchmark":"make -C benchmark","preprofile":"npm run prepare","profile":"make -C benchmark profile"},"main":"./dist/cjs/index-cjs.js","module":"./dist/mjs/index.js","types":"./dist/mjs/index.d.ts","exports":{"./min":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.min.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.min.js"}},".":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index-cjs.js"}}},"repository":"git://github.com/isaacs/node-lru-cache.git","devDependencies":{"@size-limit/preset-small-lib":"^7.0.8","@types/node":"^17.0.31","@types/tap":"^15.0.6","benchmark":"^2.1.4","c8":"^7.11.2","clock-mock":"^1.0.6","esbuild":"^0.17.11","eslint-config-prettier":"^8.5.0","marked":"^4.2.12","mkdirp":"^2.1.5","prettier":"^2.6.2","size-limit":"^7.0.8","tap":"^16.3.4","ts-node":"^10.7.0","tslib":"^2.4.0","typedoc":"^0.23.24","typescript":"^4.6.4"},"license":"ISC","files":["dist"],"engines":{"node":">=16.14"},"prettier":{"semi":false,"printWidth":70,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"tap":{"coverage":false,"node-arg":["--expose-gc","--no-warnings","--loader","ts-node/esm"],"ts":false},"size-limit":[{"path":"./dist/mjs/index.js"}],"_lastModified":"2024-06-07T14:04:54.818Z"}
|
package/dist/server/Plugin.js
CHANGED
|
@@ -211,11 +211,10 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
211
211
|
]
|
|
212
212
|
});
|
|
213
213
|
this.app.acl.registerSnippet({
|
|
214
|
-
name: "ui
|
|
214
|
+
name: "ui.workflows",
|
|
215
215
|
actions: ["workflows:list"]
|
|
216
216
|
});
|
|
217
|
-
this.app.acl.allow("
|
|
218
|
-
await this.importCollections(import_path.default.resolve(__dirname, "collections"));
|
|
217
|
+
this.app.acl.allow("*", ["trigger"], "loggedIn");
|
|
219
218
|
this.db.addMigrations({
|
|
220
219
|
namespace: this.name,
|
|
221
220
|
directory: import_path.default.resolve(__dirname, "migrations"),
|
package/package.json
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
"displayName.zh-CN": "工作流",
|
|
5
5
|
"description": "A powerful BPM tool that provides foundational support for business automation, with the capability to extend unlimited triggers and nodes.",
|
|
6
6
|
"description.zh-CN": "一个强大的 BPM 工具,为业务自动化提供基础支持,并且可任意扩展更多的触发器和节点。",
|
|
7
|
-
"version": "1.0.
|
|
7
|
+
"version": "1.0.1-alpha.1",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"homepage": "https://docs.nocobase.com/handbook/workflow",
|
|
11
11
|
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/workflow",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@nocobase/plugin-workflow-test": "1.0.
|
|
13
|
+
"@nocobase/plugin-workflow-test": "1.0.1-alpha.1"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@ant-design/icons": "5.x",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@nocobase/test": "1.x",
|
|
45
45
|
"@nocobase/utils": "1.x"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "d24aa16987a4068f857ae073fcce18f3cb490660",
|
|
48
48
|
"keywords": [
|
|
49
49
|
"Workflow"
|
|
50
50
|
]
|