@nocobase/plugin-workflow 1.4.13 → 1.4.15
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 +20 -20
- package/dist/externalVersion.js +10 -10
- 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 +6 -4
- package/dist/server/triggers/ScheduleTrigger/DateFieldScheduleTrigger.js +1 -1
- 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(x,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("react/jsx-runtime"),require("@formily/react"),require("@formily/shared"),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("lodash"),require("@formily/reactive"),require("@nocobase/evaluators/client"),require("@formily/antd-v5"),require("dayjs")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@formily/react","@formily/shared","@nocobase/client","@nocobase/utils/client","react-router-dom","react","antd","react-i18next","@ant-design/icons","@formily/core","lodash","@formily/reactive","@nocobase/evaluators/client","@formily/antd-v5","dayjs"],n):(x=typeof globalThis!="undefined"?globalThis:x||self,n(x["@nocobase/plugin-workflow"]={},x.jsxRuntime,x["@formily/react"],x["@formily/shared"],x["@nocobase/client"],x["@nocobase/utils"],x["react-router-dom"],x.react,x.antd,x["react-i18next"],x["@ant-design/icons"],x["@formily/core"],x.lodash,x["@formily/reactive"],x["@nocobase/evaluators"],x["@formily/antd-v5"],x.dayjs))})(this,function(x,n,T,oe,l,Q,se,y,g,X,V,fe,we,
|
|
10
|
+
(function(x,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("react/jsx-runtime"),require("@formily/react"),require("@formily/shared"),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("lodash"),require("@formily/reactive"),require("@nocobase/evaluators/client"),require("@formily/antd-v5"),require("dayjs")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@formily/react","@formily/shared","@nocobase/client","@nocobase/utils/client","react-router-dom","react","antd","react-i18next","@ant-design/icons","@formily/core","lodash","@formily/reactive","@nocobase/evaluators/client","@formily/antd-v5","dayjs"],n):(x=typeof globalThis!="undefined"?globalThis:x||self,n(x["@nocobase/plugin-workflow"]={},x.jsxRuntime,x["@formily/react"],x["@formily/shared"],x["@nocobase/client"],x["@nocobase/utils"],x["react-router-dom"],x.react,x.antd,x["react-i18next"],x["@ant-design/icons"],x["@formily/core"],x.lodash,x["@formily/reactive"],x["@nocobase/evaluators"],x["@formily/antd-v5"],x.dayjs))})(this,function(x,n,T,oe,l,Q,se,y,g,X,V,fe,we,$e,Ie,gt,en){"use strict";var Hr=Object.defineProperty,Gr=Object.defineProperties;var qr=Object.getOwnPropertyDescriptors;var yt=Object.getOwnPropertySymbols;var Qo=Object.prototype.hasOwnProperty,Xo=Object.prototype.propertyIsEnumerable;var Lt=(x,n,T)=>n in x?Hr(x,n,{enumerable:!0,configurable:!0,writable:!0,value:T}):x[n]=T,C=(x,n)=>{for(var T in n||(n={}))Qo.call(n,T)&&Lt(x,T,n[T]);if(yt)for(var T of yt(n))Xo.call(n,T)&&Lt(x,T,n[T]);return x},A=(x,n)=>Gr(x,qr(n));var Ro=x=>typeof x=="symbol"?x:x+"",Z=(x,n)=>{var T={};for(var oe in x)Qo.call(x,oe)&&n.indexOf(oe)<0&&(T[oe]=x[oe]);if(x!=null&&yt)for(var oe of yt(x))n.indexOf(oe)<0&&Xo.call(x,oe)&&(T[oe]=x[oe]);return T};var w=(x,n,T)=>(Lt(x,typeof n!="symbol"?n+"":n,T),T);var J=(x,n,T)=>new Promise((oe,l)=>{var Q=g=>{try{y(T.next(g))}catch(X){l(X)}},se=g=>{try{y(T.throw(g))}catch(X){l(X)}},y=g=>g.done?oe(g.value):Promise.resolve(g.value).then(Q,se);y((T=T.apply(x,n)).next())});const tn=y.createContext(null),bt={didCatch:!1,error:null};class on extends y.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=bt}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var o,r,s=arguments.length,a=new Array(s),i=0;i<s;i++)a[i]=arguments[i];(o=(r=this.props).onReset)===null||o===void 0||o.call(r,{args:a,reason:"imperative-api"}),this.setState(bt)}}componentDidCatch(t,o){var r,s;(r=(s=this.props).onError)===null||r===void 0||r.call(s,t,o)}componentDidUpdate(t,o){const{didCatch:r}=this.state,{resetKeys:s}=this.props;if(r&&o.error!==null&&nn(t.resetKeys,s)){var a,i;(a=(i=this.props).onReset)===null||a===void 0||a.call(i,{next:s,prev:t.resetKeys,reason:"keys"}),this.setState(bt)}}render(){const{children:t,fallbackRender:o,FallbackComponent:r,fallback:s}=this.props,{didCatch:a,error:i}=this.state;let c=t;if(a){const u={error:i,resetErrorBoundary:this.resetErrorBoundary};if(y.isValidElement(s))c=s;else if(typeof o=="function")c=o(u);else if(r)c=y.createElement(r,u);else throw i}return y.createElement(tn.Provider,{value:{didCatch:a,error:i,resetErrorBoundary:this.resetErrorBoundary}},c)}}function nn(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((o,r)=>!Object.is(o,t[r]))}const Pe=y.createContext({});function H(){return y.useContext(Pe)}const p="workflow";function O(e,t={}){return l.i18n.t(e,A(C({},t),{ns:p}))}function xt(){return X.useTranslation(p)}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 wt(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{wt(e.properties[o],t)})}function Ce(e){return`/admin/workflow/workflows/${e}`}function qe(e){return`/admin/workflow/executions/${e}`}function rn(r){var s=r,{collection:e,dataPath:t}=s,o=Z(s,["collection","dataPath"]);const{insert:a}=l.useSchemaInitializer(),{getTemplateSchemaByMode:i}=l.useSchemaTemplateManager(),{getCollection:c}=l.useCollectionManager_deprecated(),u=l.useRecordCollectionDataSourceItems("FormItem");let d;if(typeof e=="string"){const[h,v]=l.parseCollectionName(e);d=c(v,h)}else d=e;function m(v){return J(this,arguments,function*({item:h}){const b=h.template?yield i(h):null,f={type:"void",name:oe.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:b||{type:"void","x-component":"Grid","x-initializer":"details:configureFields",properties:{}}}}}};wt(f,k=>{k["x-uid"]&&delete k["x-uid"]}),a(f)})}return n.jsx(l.SchemaInitializerItem,A(C({},o),{onClick:m,items:u}))}function Me(e){var a;const t=l.useSchemaInitializerItem(),o=(a=e==null?void 0:e.collection)!=null?a:t.collection;let r,s;if(typeof o=="string"){const i=l.parseCollectionName(o);r=i[0],s=i[1]}else s=o;return n.jsx(l.CollectionProvider_deprecated,{dataSource:r,collection:s,children:n.jsx(rn,C(C({},t),e))})}function sn(e){const{execution:t,nodes:o}=H(),r=y.useMemo(()=>o.reduce((i,c)=>Object.assign(i,{[c.id]:c.key}),{}),[o]),s=y.useMemo(()=>{var i;return{$context:t==null?void 0:t.context,$jobsMapByNodeKey:((i=t==null?void 0:t.jobs)!=null?i:[]).reduce((c,u)=>Object.assign(c,{[r[u.nodeId]]:u.result}),{})}},[t==null?void 0:t.context,t==null?void 0:t.jobs,r]);return y.useMemo(()=>we.get(s,e),[s,e])}function ln({collection:e,dataPath:t,children:o}){const r=T.useField(),s=y.useRef(null),{getAssociationAppends:a}=l.useAssociationNames(),{appends:i,updateAssociationValues:c}=a(),u=sn(t);let d,m;if(typeof e=="string"){const M=l.parseCollectionName(e);d=M[0],m=M[1]}else m=e;const h=y.useMemo(()=>fe.createForm({values:u,readPretty:!0}),[u]),v={appends:i},b={loading:!1,data:{data:u}},k=l.useAPIClient().resource(m),F=l.useBlockRequestContext();return n.jsx(l.CollectionProvider_deprecated,{dataSource:d,collection:m,children:n.jsx(l.RecordProvider,{record:u,parent:null,children:n.jsx(l.BlockRequestContext_deprecated.Provider,{value:{block:"form",field:r,service:b,resource:k,__parent:F},children:n.jsx(l.FormBlockContext.Provider,{value:{params:v,form:h,field:r,service:b,updateAssociationValues:c,formBlockRef:s},children:o})})})})}function an(){return!0}const Ct=T.observer(e=>{const d=e,{filter:t=an}=d,o=Z(d,["filter"]),r=l.useCompile(),{getCollectionFields:s}=l.useCollectionManager_deprecated(),{values:a}=T.useForm(),[i,c]=l.parseCollectionName(a==null?void 0:a.collection),u=s(c,i);return n.jsx(g.Select,A(C({popupMatchSelectWidth:!1},o),{options:u.filter(t).map(m=>{var h;return{label:r((h=m.uiSchema)==null?void 0:h.title),value:m.name}})}))},{displayName:"FieldsSelect"}),cn=l.createStyles(({css:e,token:t})=>({container:e`
|
|
11
11
|
margin-bottom: 1.5em;
|
|
12
12
|
padding: 1em;
|
|
13
13
|
background-color: ${t.colorFillAlter};
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
}
|
|
49
49
|
`,noStatusButtonClass:e`
|
|
50
50
|
border-width: 2px;
|
|
51
|
-
`}));function Be(e){const i=e,{status:t,statusMap:o}=i,r=Z(i,["status","statusMap"]),{styles:s}=mn();let a=null;if(typeof t!="undefined"&&(o!=null&&o[t])){const{icon:c,color:
|
|
51
|
+
`}));function Be(e){const i=e,{status:t,statusMap:o}=i,r=Z(i,["status","statusMap"]),{styles:s}=mn();let a=null;if(typeof t!="undefined"&&(o!=null&&o[t])){const{icon:c,color:u}=o[t];a=n.jsx(g.Tag,{color:u,children:c})}return n.jsx(g.Button,A(C({},r),{shape:"circle",size:"small",className:pn(a?s.statusButtonClass:s.noStatusButtonClass,e.className),children:a}))}const ie={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},Ye=[{value:ie.QUEUEING,label:`{{t("Queueing", { ns: "${p}" })}}`,color:"blue",icon:n.jsx(V.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${p}" })}}`},{value:ie.STARTED,label:`{{t("On going", { ns: "${p}" })}}`,color:"gold",icon:n.jsx(V.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${p}" })}}`},{value:ie.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:n.jsx(V.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${p}" })}}`},{value:ie.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:n.jsx(V.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${p}" })}}`},{value:ie.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:n.jsx(V.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${p}" })}}`},{value:ie.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:n.jsx(V.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${p}" })}}`},{value:ie.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(V.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${p}" })}}`},{value:ie.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(V.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${p}" })}}`},{value:ie.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(V.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${p}" })}}`}],_e=Ye.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),ce={PENDING:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},kt=[{value:ce.PENDING,label:`{{t("Pending", { ns: "${p}" })}}`,color:"gold",icon:n.jsx(V.ClockCircleOutlined,{})},{value:ce.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:n.jsx(V.CheckOutlined,{})},{value:ce.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:n.jsx(V.ExclamationOutlined,{})},{value:ce.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:n.jsx(V.CloseOutlined,{})},{value:ce.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:n.jsx(V.MinusOutlined,{rotate:90})},{value:ce.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(V.MinusOutlined,{rotate:45})},{value:ce.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(V.MinusOutlined,{})},{value:ce.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:n.jsx(V.RedoOutlined,{})}],Ke=kt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),St=(e,t)=>({getAriaLabel:y.useCallback(r=>["add-button",e==null?void 0:e.type,e==null?void 0:e.title,t!=null?String(t):"",r].filter(Boolean).join("-"),[t,e==null?void 0:e.title,e==null?void 0:e.type])}),ne=l.createStyles(({css:e,token:t})=>({workflowPageClass:e`
|
|
52
52
|
flex-grow: 1;
|
|
53
53
|
overflow: hidden;
|
|
54
54
|
display: flex;
|
|
@@ -407,9 +407,9 @@
|
|
|
407
407
|
border-radius: 50%;
|
|
408
408
|
background-color: ${t.colorText};
|
|
409
409
|
color: ${t.colorBgContainer};
|
|
410
|
-
`}));class be{constructor(){w(this,"title");w(this,"type");w(this,"group");w(this,"description");w(this,"options");w(this,"fieldset");w(this,"presetFieldset");w(this,"branching");w(this,"view");w(this,"scope");w(this,"components");w(this,"end");w(this,"testable")}createDefaultConfig(){return{}}}function fn(){const e=T.useForm(),t=l.useAPIClient(),o=l.useActionContext(),{refresh:r}=l.useResourceActionContext(),s=xe(),{workflow:a}=H();return{run(){return J(this,null,function*(){var c,
|
|
410
|
+
`}));class be{constructor(){w(this,"title");w(this,"type");w(this,"group");w(this,"description");w(this,"options");w(this,"fieldset");w(this,"presetFieldset");w(this,"branching");w(this,"view");w(this,"scope");w(this,"components");w(this,"end");w(this,"testable")}createDefaultConfig(){return{}}}function fn(){const e=T.useForm(),t=l.useAPIClient(),o=l.useActionContext(),{refresh:r}=l.useResourceActionContext(),s=xe(),{workflow:a}=H();return{run(){return J(this,null,function*(){var c,u;if(a.executed){g.message.error(O("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(u=(c=t.resource("flow_nodes")).update)==null?void 0:u.call(c,{filterByTk:s.id,values:{config:e.values}}),e.setInitialValues($e.toJS(e.values)),o.setFormValueChanged(!1),o.setVisible(!1),r()})}}}const Ze=y.createContext({});function xe(){return y.useContext(Ze)}function Ve(e=[]){const t=xe();return e.some(o=>we.get(t.config,o)!=null)}function Ut(e,t){const o=[];if(!e)return[];for(let r=e.upstream;r;r=r.upstream)(typeof t!="function"||t(r))&&o.push(r);return o}function Ht(e){const t=[];for(let o=e;o;o=o.upstream)o.upstream&&o.branchIndex!=null&&t.push(o.upstream);return t}function Gt({data:e}){var i;const{styles:t}=ne(),{getAriaLabel:o}=St(e),r=l.usePlugin(le),{Component:s=Tt,end:a}=(i=r.instructions.get(e.type))!=null?i:{};return n.jsx(Ze.Provider,{value:e,children:n.jsxs("div",{className:l.cx(t.nodeBlockClass),children:[n.jsx(s,{data:e}),!a||typeof a=="function"&&!a(e)?n.jsx(no,{"aria-label":o(),upstream:e}):n.jsx("div",{className:"end-sign",children:n.jsx(V.CloseOutlined,{})})]})})}function At(){var m;const{t:e}=X.useTranslation(),t=l.useAPIClient(),{workflow:o,nodes:r,refresh:s}=(m=H())!=null?m:{},a=xe(),{modal:i}=g.App.useApp(),c=t.resource("flow_nodes"),u=y.useCallback(()=>J(this,null,function*(){var h;yield(h=c.destroy)==null?void 0:h.call(c,{filterByTk:a.id}),s()}),[a.id,s,c]),d=y.useCallback(()=>J(this,null,function*(){const h=r.filter(f=>f===a?!1:Q.parse(f.config).parameters.filter(({key:M})=>M.startsWith(`$jobsMapByNodeKey.${a.key}.`)||M===`$jobsMapByNodeKey.${a.key}`).length);if(h.length){i.error({title:O("Can not delete"),content:O("The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",{nodes:h.map(f=>`#${f.id}`).join(", ")})});return}const b=!r.find(f=>f.upstream===a&&f.branchIndex!=null)?e("Are you sure you want to delete it?"):O("This node contains branches, deleting will also be preformed to them, are you sure?");i.confirm({title:e("Delete"),content:b,onOk:u})}),[a,i,r,u,e]);return o?o.executed?null:n.jsx(g.Button,{type:"text",shape:"circle",icon:n.jsx(V.DeleteOutlined,{}),onClick:d,className:"workflow-node-remove-button",size:"small"}):null}function Ft(){var a;const{execution:e,setViewJob:t}=H(),{jobs:o}=(a=xe())!=null?a:{},{styles:r}=ne();if(!e)return null;if(!o.length)return n.jsx(Be,{className:r.nodeJobButtonClass,disabled:!0});function s({key:i}){const c=o.find(u=>u.id==i);t(c)}return n.jsx(g.Tooltip,{title:O("View result"),children:o.length>1?n.jsx(g.Dropdown,{menu:{items:o.map(i=>({key:i.id,label:n.jsxs(n.Fragment,{children:[n.jsx(Be,{statusMap:Ke,status:i.status}),n.jsx("time",{children:Q.str2moment(i.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),onClick:s,className:r.dropdownClass},children:n.jsx(Be,{statusMap:Ke,status:o[o.length-1].status,className:r.nodeJobButtonClass})}):n.jsx(Be,{statusMap:Ke,status:o[0].status,onClick:()=>t(o[0]),className:r.nodeJobButtonClass})})}function hn(){return{form:T.useForm()}}const yn=()=>{const{values:e,query:t}=T.useForm(),o=xe(),r=l.useAPIClient(),s=l.useActionContext(),a=T.useField();return{run(){return J(this,null,function*(){const u=Q.parse(o.config)($e.toJS(e.config)),d=t("result").take();d.setValue(null),d.setFeedback({}),a.data=a.data||{},a.data.loading=!0;try{const{data:{data:m}}=yield r.resource("flow_nodes").test({values:{config:u,type:o.type}});d.setFeedback({type:m.status>0?"success":"error",messages:m.status>0?[O("Resolved")]:[O("Failed")]}),d.setValue(m.result)}catch(m){d.setFeedback({type:"error",messages:m.message})}a.data.loading=!1,s.setFormValueChanged(!1)})}}},qt=y.createContext([]);function gn({name:e,value:t,onChange:o}){return n.jsxs(g.Space,{children:[n.jsx($t,{variableOptions:{},value:`{{${e}}}`,disabled:!0}),n.jsx(l.Variable.Input,{useTypedConstant:["string","number","boolean","date"],value:t,onChange:o})]})}function bn({value:e,onChange:t}){const o=y.useContext(qt);return o.length?n.jsx(n.Fragment,{children:o.map(r=>n.jsx(gn,{name:r,value:we.get(e,r),onChange:s=>{we.set(e,r,s),t($e.toJS(e))}},r))}):n.jsx(g.Empty,{image:g.Empty.PRESENTED_IMAGE_SIMPLE,description:O("No variable"),style:{margin:"1em"}})}function xn(){const e=xe(),{values:t}=T.useForm(),r=Q.parse(t).parameters.map(a=>a.key),s=y.useMemo(()=>fe.createForm(),[]);return n.jsx(Ze.Provider,{value:A(C({},e),{config:t}),children:n.jsx(qt.Provider,{value:r,children:n.jsx(l.SchemaComponent,{components:{Alert:g.Alert,TestFormFieldset:bn},scope:{useCancelAction:l.useCancelAction,useRunAction:yn},schema:{type:"void",name:"testButton",title:'{{t("Test run")}}',"x-component":"Action","x-component-props":{icon:"CaretRightOutlined"},properties:{modal:{type:"void","x-decorator":"FormV2","x-decorator-props":{form:s},"x-component":"Action.Modal",title:'{{t("Test run", { ns: "workflow" })}}',properties:{alert:{type:"void","x-component":"Alert","x-component-props":{message:'{{t("Test run will do the actual data manipulating or API calling, please use with caution.", { ns: "workflow" })}}',type:"warning",showIcon:!0,className:l.css`
|
|
411
411
|
margin-bottom: 1em;
|
|
412
|
-
`}},config:{type:"object",title:'{{t("Replace variables", { ns: "workflow" })}}',"x-decorator":"FormItem","x-component":"TestFormFieldset"},actions:{type:"void","x-component":"ActionBar",properties:{submit:{type:"void",title:'{{t("Run")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useRunAction }}"}}}},result:{type:"string",title:'{{t("Result", { ns: "workflow" })}}',"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{autoSize:{minRows:5,maxRows:20},style:{whiteSpace:"pre",cursor:"text"}},"x-pattern":"disabled"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{cancel:{type:"void",title:'{{t("Close")}}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}}}}}}}}})})})}function Tt(e){var I;const{data:t,children:o}=e,r=l.useCompile(),s=l.useAPIClient(),{workflow:a,refresh:i}=(I=H())!=null?I:{},{styles:c}=ne(),d=l.usePlugin(le).instructions.get(t.type),m=a.executed?'{{t("View")}}':'{{t("Configure")}}',[h,v]=y.useState(t.title),[b,f]=y.useState(!1),[k,F]=y.useState(!1),M=y.useMemo(()=>{const
|
|
412
|
+
`}},config:{type:"object",title:'{{t("Replace variables", { ns: "workflow" })}}',"x-decorator":"FormItem","x-component":"TestFormFieldset"},actions:{type:"void","x-component":"ActionBar",properties:{submit:{type:"void",title:'{{t("Run")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useRunAction }}"}}}},result:{type:"string",title:'{{t("Result", { ns: "workflow" })}}',"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{autoSize:{minRows:5,maxRows:20},style:{whiteSpace:"pre",cursor:"text"}},"x-pattern":"disabled"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{cancel:{type:"void",title:'{{t("Close")}}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}}}}}}}}})})})}function Tt(e){var I;const{data:t,children:o}=e,r=l.useCompile(),s=l.useAPIClient(),{workflow:a,refresh:i}=(I=H())!=null?I:{},{styles:c}=ne(),d=l.usePlugin(le).instructions.get(t.type),m=a.executed?'{{t("View")}}':'{{t("Configure")}}',[h,v]=y.useState(t.title),[b,f]=y.useState(!1),[k,F]=y.useState(!1),M=y.useMemo(()=>{const $=we.cloneDeep(t.config);return fe.createForm({initialValues:$,disabled:a.executed})},[t,a]),S=y.useCallback($=>{f($),$||M.reset()},[M]),D=y.useCallback(function($){return J(this,null,function*(){var B,G;const N=$||r(d==null?void 0:d.title);v(N),N!==t.title&&(yield(G=(B=s.resource("flow_nodes")).update)==null?void 0:G.call(B,{filterByTk:t.id,values:{title:N}}),i())})},[t,d]),L=y.useCallback(function($){if($.target===$.currentTarget){f(!0);return}const N=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let B=$.target;B&&B!==$.currentTarget&&B!==document.documentElement;B=B.parentNode)if(Array.from(B.classList).some(G=>N.has(G))){f(!0),$.stopPropagation();return}},[]);if(!d)return n.jsx("div",{className:l.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:n.jsx(g.Tooltip,{title:O("Node with unknown type will cause error. Please delete it or check plugin which provide this type."),children:n.jsxs("div",{role:"button","aria-label":`_untyped-${h}`,className:l.cx(c.nodeCardClass,"invalid"),children:[n.jsxs("div",{className:c.nodeHeaderClass,children:[n.jsxs("div",{className:l.cx(c.nodeMetaClass,"workflow-node-meta"),children:[n.jsx(g.Tag,{color:"error",children:O("Unknown node")}),n.jsx("span",{className:"workflow-node-id",children:t.id})]}),n.jsxs("div",{className:"workflow-node-actions",children:[n.jsx(At,{}),n.jsx(Ft,{})]})]}),n.jsx(g.Input.TextArea,{value:h,disabled:!0,autoSize:!0})]})})});const E=r(d.title);return n.jsxs("div",{className:l.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:[n.jsxs("div",{role:"button","aria-label":`${E}-${h}`,className:l.cx(c.nodeCardClass,{configuring:b}),onClick:L,children:[n.jsxs("div",{className:c.nodeHeaderClass,children:[n.jsxs("div",{className:l.cx(c.nodeMetaClass,"workflow-node-meta"),children:[n.jsx(g.Tag,{children:E}),n.jsx("span",{className:"workflow-node-id",children:t.id})]}),n.jsxs("div",{className:"workflow-node-actions",children:[n.jsx(At,{}),n.jsx(Ft,{})]})]}),n.jsx(g.Input.TextArea,{disabled:a.executed,value:h,onChange:$=>v($.target.value),onBlur:$=>D($.target.value),autoSize:!0}),n.jsx(l.ActionContextProvider,{value:{visible:b,setVisible:S,formValueChanged:k,setFormValueChanged:F},children:n.jsx(l.FormProvider,{form:M,children:n.jsx(l.SchemaComponent,{distributed:!1,scope:A(C({},d.scope),{useFormProviderProps:hn,useUpdateAction:fn}),components:d.components,schema:{type:"void",properties:A(C({},d.view?{view:d.view}:{}),{button:{type:"void","x-content":m,"x-component":g.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},[t.id]:{type:"void",title:n.jsxs("div",{className:l.css`
|
|
413
413
|
display: flex;
|
|
414
414
|
justify-content: space-between;
|
|
415
415
|
|
|
@@ -436,7 +436,7 @@
|
|
|
436
436
|
min-width: 6em;
|
|
437
437
|
}
|
|
438
438
|
}
|
|
439
|
-
`},properties:d.fieldset},footer:a.executed?null:{type:"void","x-component":"Action.Drawer.Footer",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{flexGrow:1}},properties:A(C({},d.testable?{test:{type:"void","x-component":T.observer(xn),"x-align":"left"}}:{}),{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useUpdateAction }}"}}})}}}})}})}})})})]}),o]})}const je={label:"label",value:"value",children:"children"},Yt={label:`{{t("Node result", { ns: "${
|
|
439
|
+
`},properties:d.fieldset},footer:a.executed?null:{type:"void","x-component":"Action.Drawer.Footer",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{flexGrow:1}},properties:A(C({},d.testable?{test:{type:"void","x-component":T.observer(xn),"x-align":"left"}}:{}),{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useUpdateAction }}"}}})}}}})}})}})})})]}),o]})}const je={label:"label",value:"value",children:"children"},Yt={label:`{{t("Node result", { ns: "${p}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=l.usePlugin(le),o=xe(),r=Ut(o),s=[];return r.forEach(a=>{var u;const i=t.get(a.type),c=(u=i.useVariables)==null?void 0:u.call(i,a,e);c&&s.push(c)}),s}},_t={label:`{{t("Trigger variables", { ns: "${p}" })}}`,value:"$context",useOptions(e){var s,a;const{triggers:t}=l.usePlugin(le),{workflow:o}=H(),r=t.get(o.type);return(a=(s=r==null?void 0:r.useVariables)==null?void 0:s.call(r,o.config,e))!=null?a:null}},Kt={label:`{{t("Scope variables", { ns: "${p}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=je,current:o}=e,{instructions:r}=l.usePlugin(le),s=xe(),a=o!=null?o:s,i=Ht(a),c=[];return i.forEach(u=>{var h,v;const d=r.get(u.type),m=(h=d.useScopeVariables)==null?void 0:h.call(d,u,e);m&&c.push({key:u.key,[t.value]:u.key,[t.label]:(v=u.title)!=null?v:`#${u.id}`,[t.children]:m})}),c}},Zt={label:`{{t("System variables", { ns: "${p}" })}}`,value:"$system",useOptions(e){const{systemVariables:t}=l.usePlugin(le);return l.useCompile()(Array.from(t.getValues()))}},Qe={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 Qt(e,t){var o,r,s,a,i,c;return typeof t=="string"?(o=Qe[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?Nt(e)?((r=t.options)==null?void 0:r.entity)&&(e.collectionName===((s=t.options)==null?void 0:s.collection)||((a=t.options)==null?void 0:a.collection)==="*"):e.isForeignKey?e.collectionName===((i=t.options)==null?void 0:i.collection)&&e.name==="id"||e.target===((c=t.options)==null?void 0:c.collection):!1:typeof t=="function"?t(e):!1}function Nt(e){return["belongsTo","hasOne","hasMany","belongsToMany","belongsToArray"].includes(e.type)}function Ot(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(r=>r.startsWith(o)).map(r=>r.replace(o,""))}function Et({fields:e,types:t,appends:o,depth:r=1,compile:s,getCollectionFields:a}){return e.filter(i=>{const c=t!=null&&t.length?t.some(u=>Qt(i,u)):!0;if(Nt(i)){if(o===null)return r?c||Et({fields:Dt(i.target,{compile:s,getCollectionFields:a}),types:t,depth:r-1,appends:o,compile:s,getCollectionFields:a}):!1;const u=Ot(i,o),d=o.includes(i.name);return c?d:((u==null?void 0:u.length)||d)&&Et({fields:Dt(i.target,{compile:s,getCollectionFields:a}),types:t,appends:u,compile:s,getCollectionFields:a}).length}else return c})}function Xe(e,t){var a,i;const o=l.useCompile(),r=(i=(a=e.useOptions)==null?void 0:a.call(e,t))==null?void 0:i.filter(Boolean),{fieldNames:s}=t;return{[s.label]:o(e.label),[s.value]:e.value,key:e[s.value],[s.children]:r,disabled:!r||!r.length}}function me(e={}){var s;const t=Object.assign({},je,(s=e.fieldNames)!=null?s:{}),o=Object.assign(e,{fieldNames:t});return[Xe(Kt,o),Xe(Yt,o),Xe(_t,o),Xe(Zt,o)]}function Dt(e,{compile:t,getCollectionFields:o}){var d,m,h,v;const[r,s]=l.parseCollectionName(e),a=o(s,r),i=[],c=[];a.forEach(b=>{if(b.isForeignKey&&!b.primaryKey)i.push(b);else{const f=a.find(k=>k.name===b.foreignKey);f&&i.push(f),c.push(b)}});const u=we.uniqBy(i,"name");for(let b=c.length-1;b>=0;b--){const f=c[b];if(f.type==="belongsTo"){const k=u.findIndex(F=>F.name===f.foreignKey);if(k>-1){const F=u[k];c.splice(b,0,A(C(C({},f),F),{uiSchema:A(C({},f.uiSchema),{title:(d=F.uiSchema)!=null&&d.title?t((m=F.uiSchema)==null?void 0:m.title):F.name})})),u.splice(k,1)}else c.splice(b,0,A(C({},f),{name:f.foreignKey,type:"bigInt",isForeignKey:!0,interface:f.interface,uiSchema:A(C({},f.uiSchema),{title:(h=f.uiSchema)!=null&&h.title?`${t((v=f.uiSchema)==null?void 0:v.title)} ID`:f.name})}))}else f.type==="context"&&f.collectionName==="users"&&c.splice(b,1)}return c.push(...u),we.uniqBy(c,"name").filter(b=>b.interface&&!b.hidden)}function vn(e){const t=Ot(e.field,e.appends),o=Te(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=>Qt(e.field,s))||(e.disabled=!0))}function Te(e){const{fields:t,collection:o,types:r,appends:s=[],depth:a=1,compile:i,getCollectionFields:c,fieldNames:u=je}=e,d=t!=null?t:Dt(o,{compile:i,getCollectionFields:c}),m=vn.bind({compile:i,getCollectionFields:c,fieldNames:u});return Et({fields:d,types:r,depth:a,appends:s,compile:i,getCollectionFields:c}).map(v=>{var F;const b=i(((F=v.uiSchema)==null?void 0:F.title)||v.name),f=Ot(v,s),k=!Nt(v)||f&&!f.length&&!s.includes(v.name)||!1;return{[u.label]:b,key:v.name,[u.value]:v.name,isLeaf:k,loadChildren:k?null:m,field:v,depth:a,appends:s,types:r}})}function We(e){const t=l.useApp(),{collectionManager:o}=t.dataSourceManager.getDataSource(e);return y.useCallback(r=>o.getCollectionAllFields(r),[o])}function $t(o){var r=o,{variableOptions:e}=r,t=Z(r,["variableOptions"]);const s=me(e);return n.jsx(l.Variable.Input,C({scope:s},t))}function It(o){var r=o,{variableOptions:e}=r,t=Z(r,["variableOptions"]);const s=me(e);return n.jsx(l.Variable.TextArea,C({scope:s},t))}function wn(o){var r=o,{variableOptions:e}=r,t=Z(r,["variableOptions"]);const s=me(e);return n.jsx(l.Variable.RawTextArea,C({scope:s},t))}function Cn(o){var r=o,{variableOptions:e}=r,t=Z(r,["variableOptions"]);const s=me(e);return n.jsx(l.Variable.JSON,C({scope:s},t))}function Re({value:e,onChange:t,renderSchemaComponent:o}){const r=me();return n.jsx(l.Variable.Input,{value:e,onChange:t,scope:r,children:o()})}function ke(e){const a=e,{options:t=[],direction:o}=a,r=Z(a,["options","direction"]),s=l.useCompile();return n.jsx(g.Radio.Group,A(C({},r),{children:n.jsx(g.Space,{direction:o,children:t.map(i=>n.jsxs(g.Radio,{value:i.value,children:[n.jsx("span",{className:l.css`
|
|
440
440
|
& + .anticon {
|
|
441
441
|
margin-left: 0.25em;
|
|
442
442
|
}
|
|
@@ -453,16 +453,16 @@
|
|
|
453
453
|
& + a {
|
|
454
454
|
margin-left: 0.25em;
|
|
455
455
|
}
|
|
456
|
-
`,children:l.i18n.t("Syntax references")}),n.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null},Y=new Q.Registry;Y.register("equal",{name:"=",type:"boolean",group:"boolean"}),Y.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),Y.register("gt",{name:">",type:"boolean",group:"boolean"}),Y.register("gte",{name:"≥",type:"boolean",group:"boolean"}),Y.register("lt",{name:"<",type:"boolean",group:"boolean"}),Y.register("lte",{name:"≤",type:"boolean",group:"boolean"}),Y.register("add",{name:"+",type:"number",group:"number"}),Y.register("minus",{name:"-",type:"number",group:"number"}),Y.register("multiple",{name:"*",type:"number",group:"number"}),Y.register("divide",{name:"/",type:"number",group:"number"}),Y.register("mod",{name:"%",type:"number",group:"number"}),Y.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),Y.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),Y.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),Y.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),Y.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),Y.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),Y.register("concat",{name:`{{t("concat", { ns: "${
|
|
456
|
+
`,children:l.i18n.t("Syntax references")}),n.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null},Y=new Q.Registry;Y.register("equal",{name:"=",type:"boolean",group:"boolean"}),Y.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),Y.register("gt",{name:">",type:"boolean",group:"boolean"}),Y.register("gte",{name:"≥",type:"boolean",group:"boolean"}),Y.register("lt",{name:"<",type:"boolean",group:"boolean"}),Y.register("lte",{name:"≤",type:"boolean",group:"boolean"}),Y.register("add",{name:"+",type:"number",group:"number"}),Y.register("minus",{name:"-",type:"number",group:"number"}),Y.register("multiple",{name:"*",type:"number",group:"number"}),Y.register("divide",{name:"/",type:"number",group:"number"}),Y.register("mod",{name:"%",type:"number",group:"number"}),Y.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),Y.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),Y.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),Y.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),Y.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),Y.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),Y.register("concat",{name:`{{t("concat", { ns: "${p}" })}}`,type:"string",group:"string"});const Fn=[{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 Rt(e){return Array.from(Y.getEntities()).filter(([t,o])=>o.group===e)}function Tn({calculator:e,operands:t=[],onChange:o}){const r=l.useCompile(),s=y.useContext(to),a=s(),i=s(),c=y.useCallback(m=>o({calculator:e,operands:[m,t[1]]}),[e,o,t]),u=y.useCallback(m=>o({calculator:e,operands:[t[0],m]}),[e,o,t]),d=y.useCallback(m=>o({operands:t,calculator:m}),[o,t]);return n.jsxs("fieldset",{className:l.css`
|
|
457
457
|
display: flex;
|
|
458
458
|
gap: 0.5em;
|
|
459
459
|
align-items: center;
|
|
460
460
|
flex-wrap: wrap;
|
|
461
|
-
`,children:[n.jsx(l.Variable.Input,{changeOnSelect:!0,value:t[0],onChange:c,scope:a,useTypedConstant:!0}),n.jsx(g.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:d,placeholder:O("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:Fn.filter(m=>!!Rt(m.value).length).map(m=>n.jsx(g.Select.OptGroup,{label:r(m.title),children:Rt(m.value).map(([h,{name:v}])=>n.jsx(g.Select.Option,{value:h,children:r(v)},h))},m.value))}),n.jsx(l.Variable.Input,{changeOnSelect:!0,value:t[1],onChange:
|
|
461
|
+
`,children:[n.jsx(l.Variable.Input,{changeOnSelect:!0,value:t[0],onChange:c,scope:a,useTypedConstant:!0}),n.jsx(g.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:d,placeholder:O("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:Fn.filter(m=>!!Rt(m.value).length).map(m=>n.jsx(g.Select.OptGroup,{label:r(m.title),children:Rt(m.value).map(([h,{name:v}])=>n.jsx(g.Select.Option,{value:h,children:r(v)},h))},m.value))}),n.jsx(l.Variable.Input,{changeOnSelect:!0,value:t[1],onChange:u,scope:i,useTypedConstant:!0})]})}function Nn({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:r,operands:s=[]}=e;return n.jsxs("div",{className:l.css`
|
|
462
462
|
display: flex;
|
|
463
463
|
position: relative;
|
|
464
464
|
margin: 0.5em 0;
|
|
465
|
-
`,children:[e.group?n.jsx(eo,{value:e.group,onChange:a=>t(A(C({},e),{group:a}))}):n.jsx(Tn,{operands:s,calculator:r,onChange:t}),n.jsx(g.Button,{"aria-label":"icon-close",onClick:o,type:"link",icon:n.jsx(V.CloseCircleOutlined,{})})]})}function eo({value:e,onChange:t}){const{t:o}=X.useTranslation(),{type:r="and",calculations:s=[]}=e,a=y.useCallback(()=>{t(A(C({},e),{calculations:[...s,{not:!1,calculator:"equal"}]}))},[e,s,t]),i=y.useCallback(()=>{t(A(C({},e),{calculations:[...s,{not:!1,group:{type:"and",calculations:[]}}]}))},[e,s,t]),c=y.useCallback(d=>{s.splice(d,1),t(A(C({},e),{calculations:[...s]}))},[e,s,t]),
|
|
465
|
+
`,children:[e.group?n.jsx(eo,{value:e.group,onChange:a=>t(A(C({},e),{group:a}))}):n.jsx(Tn,{operands:s,calculator:r,onChange:t}),n.jsx(g.Button,{"aria-label":"icon-close",onClick:o,type:"link",icon:n.jsx(V.CloseCircleOutlined,{})})]})}function eo({value:e,onChange:t}){const{t:o}=X.useTranslation(),{type:r="and",calculations:s=[]}=e,a=y.useCallback(()=>{t(A(C({},e),{calculations:[...s,{not:!1,calculator:"equal"}]}))},[e,s,t]),i=y.useCallback(()=>{t(A(C({},e),{calculations:[...s,{not:!1,group:{type:"and",calculations:[]}}]}))},[e,s,t]),c=y.useCallback(d=>{s.splice(d,1),t(A(C({},e),{calculations:[...s]}))},[e,s,t]),u=y.useCallback((d,m)=>{s.splice(d,1,m),t(A(C({},e),{calculations:[...s]}))},[e,s,t]);return n.jsxs("div",{className:l.cx("node-type-condition-group",l.css`
|
|
466
466
|
position: relative;
|
|
467
467
|
width: 100%;
|
|
468
468
|
.node-type-condition-group {
|
|
@@ -481,22 +481,22 @@
|
|
|
481
481
|
width: auto;
|
|
482
482
|
min-width: 6em;
|
|
483
483
|
}
|
|
484
|
-
`,children:n.jsxs(X.Trans,{children:["Meet ",n.jsxs(g.Select,{role:"button","data-testid":"filter-select-all-or-any",value:r,onChange:d=>t(A(C({},e),{type:d})),children:[n.jsx(g.Select.Option,{value:"and",children:"All"}),n.jsx(g.Select.Option,{value:"or",children:"Any"})]})," conditions in the group"]})}),n.jsx("div",{className:"calculation-items",children:s.map((d,m)=>n.jsx(Nn,{value:d,onChange:
|
|
484
|
+
`,children:n.jsxs(X.Trans,{children:["Meet ",n.jsxs(g.Select,{role:"button","data-testid":"filter-select-all-or-any",value:r,onChange:d=>t(A(C({},e),{type:d})),children:[n.jsx(g.Select.Option,{value:"and",children:"All"}),n.jsx(g.Select.Option,{value:"or",children:"Any"})]})," conditions in the group"]})}),n.jsx("div",{className:"calculation-items",children:s.map((d,m)=>n.jsx(Nn,{value:d,onChange:u.bind(this,m),onRemove:()=>c(m)},`${d.calculator}_${m}`))}),n.jsxs("div",{className:l.css`
|
|
485
485
|
button {
|
|
486
486
|
padding: 0;
|
|
487
487
|
&:not(:last-child) {
|
|
488
488
|
margin-right: 1em;
|
|
489
489
|
}
|
|
490
490
|
}
|
|
491
|
-
`,children:[n.jsx(g.Button,{type:"link",onClick:a,children:o("Add condition")}),n.jsx(g.Button,{type:"link",onClick:i,children:o("Add condition group")})]})]})}const to=y.createContext(me);function oo({value:e,onChange:t,useVariableHook:o=me}){const r=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return n.jsx(to.Provider,{value:o,children:n.jsx(eo,{value:r.group,onChange:s=>t(A(C({},r),{group:s}))})})}function On(e){return n.jsx(g.Card,{children:n.jsx(gt.FormLayout,{layout:e.layout||"vertical",children:e.children})})}function no(e){var v;const{upstream:t,branchIndex:o=null}=e,r=l.usePlugin(le),s=l.useCompile(),{workflow:a}=(v=H())!=null?v:{},i=Array.from(r.instructions.getValues()),{styles:c}=ne(),{onCreate:
|
|
491
|
+
`,children:[n.jsx(g.Button,{type:"link",onClick:a,children:o("Add condition")}),n.jsx(g.Button,{type:"link",onClick:i,children:o("Add condition group")})]})]})}const to=y.createContext(me);function oo({value:e,onChange:t,useVariableHook:o=me}){const r=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return n.jsx(to.Provider,{value:o,children:n.jsx(eo,{value:r.group,onChange:s=>t(A(C({},r),{group:s}))})})}function On(e){return n.jsx(g.Card,{children:n.jsx(gt.FormLayout,{layout:e.layout||"vertical",children:e.children})})}function no(e){var v;const{upstream:t,branchIndex:o=null}=e,r=l.usePlugin(le),s=l.useCompile(),{workflow:a}=(v=H())!=null?v:{},i=Array.from(r.instructions.getValues()),{styles:c}=ne(),{onCreate:u,creating:d}=et(),m=y.useMemo(()=>{const b=[{key:"control",label:`{{t("Control", { ns: "${p}" })}}`},{key:"calculation",label:`{{t("Calculation", { 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(f=>{const k=i.filter(F=>F.group===f.key&&(F.isAvailable?F.isAvailable({engine:r,workflow:a,upstream:t,branchIndex:o}):!0));return A(C({},f),{type:"group",children:k.map(F=>({role:"button","aria-label":F.type,key:F.type,label:F.title}))})}).filter(f=>f.children.length);return s(b)},[o,s,r,i,t,a]),h=y.useCallback(f=>J(this,[f],function*({keyPath:b}){const[k]=b;u({type:k,upstream:t,branchIndex:o})}),[o,u,t]);return a?n.jsx("div",{className:c.addButtonClass,children:n.jsx(g.Dropdown,{menu:{items:m,onClick:h},disabled:a.executed,overlayClassName:l.css`
|
|
492
492
|
.ant-dropdown-menu-root {
|
|
493
493
|
max-height: 30em;
|
|
494
494
|
overflow-y: auto;
|
|
495
495
|
}
|
|
496
|
-
`,children:n.jsx(g.Button,{"aria-label":e["aria-label"]||"add-button",shape:"circle",icon:n.jsx(V.PlusOutlined,{}),loading:(d==null?void 0:d.upstreamId)==(t==null?void 0:t.id)&&(d==null?void 0:d.branchIndex)===o,size:"small"})})}):null}function
|
|
496
|
+
`,children:n.jsx(g.Button,{"aria-label":e["aria-label"]||"add-button",shape:"circle",icon:n.jsx(V.PlusOutlined,{}),loading:(d==null?void 0:d.upstreamId)==(t==null?void 0:t.id)&&(d==null?void 0:d.branchIndex)===o,size:"small"})})}):null}function En(){const e=T.useForm(),t=l.useAPIClient(),{workflow:o,refresh:r}=H(),{presetting:s,setPresetting:a,setCreating:i}=et(),c=l.useActionContext();return{run(){return J(this,null,function*(){if(s){yield e.submit(),i(s.data);try{const{data:{data:d}}=yield t.resource("workflows.nodes",o.id).create({values:A(C({},s.data),{config:C(C({},s.data.config),e.values.config)})});typeof e.values.downstreamBranchIndex=="number"&&d.downstreamId&&(yield t.resource("flow_nodes").update({filterByTk:d.downstreamId,values:{branchIndex:e.values.downstreamBranchIndex,upstream:{id:d.id,downstreamId:null}},updateAssociationValues:["upstream"]})),c.setVisible(!1),a(null),r()}catch(d){console.error(d)}finally{i(null)}}})}}}const ro=y.createContext(null);function et(){return y.useContext(ro)}const Dn=[{label:`{{t('After end of branches', { ns: "${p}" })}}`,value:!1},{label:`{{t('Inside of branch', { ns: "${p}" })}}`,value:0}],$n=T.observer(e=>{var i,c;const{presetting:t}=et(),{nodes:o}=H(),{values:r}=T.useForm(),s=y.useMemo(()=>{var v;if(!(t!=null&&t.instruction))return[];const{instruction:u,data:d}=t;if(!(d.upstreamId?o.find(b=>b.upstreamId===d.upstreamId&&b.branchIndex===d.branchIndex):o.find(b=>b.upstreamId===null)))return[];const h=typeof u.branching=="function"?u.branching((v=r.config)!=null?v:{}):u.branching;return h?h===!0?Dn:h:[]},[t,o,r.config]);if(!s.length)return null;const{data:a}=t;return n.jsx(l.SchemaComponent,{components:{RadioWithTooltip:ke},schema:{name:`${(i=a.type)!=null?i:"unknown"}-${(c=a.upstreamId)!=null?c:"root"}-${a.branchIndex}`,type:"void",properties:{downstreamBranchIndex:{type:"number",title:O("Move all downstream nodes to",{ns:p}),"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:s,direction:"vertical"},default:!1,required:!0}}}})});function In(){const{presetting:e}=et();return e!=null&&e.instruction.presetFieldset?n.jsx(l.SchemaComponent,{schema:{type:"void",properties:{config:{type:"object",properties:e.instruction.presetFieldset}}}}):null}function Pn(e){var M;const t=l.useAPIClient(),o=l.useCompile(),r=l.usePlugin(le),[s,a]=y.useState(null),[i,c]=y.useState(null),[u,d]=y.useState(!1),{workflow:m,nodes:h,refresh:v}=(M=H())!=null?M:{},b=y.useMemo(()=>fe.createForm(),[]),f=y.useCallback(S=>{S||(b.reset(),b.clearFormGraph("*"),c(null))},[b]),k=y.useCallback(S=>J(this,null,function*(){a(S);try{yield t.resource("workflows.nodes",m.id).create({values:S}),v()}catch(D){console.error(D)}finally{a(null)}}),[t,v,m.id]),F=y.useCallback(({type:S,upstream:D,branchIndex:L})=>{var N,B,G;const E=r.instructions.get(S);if(!E){console.error(`Instruction "${S}" not found`);return}const I={key:Q.uid(),type:S,upstreamId:(N=D==null?void 0:D.id)!=null?N:null,branchIndex:L,title:o(E.title),config:(G=(B=E.createDefaultConfig)==null?void 0:B.call(E))!=null?G:{}},$=D!=null&&D.id?h.find(U=>U.upstreamId===I.upstreamId&&U.branchIndex===I.branchIndex):h.find(U=>U.upstreamId===null);if(E.presetFieldset||(typeof E.branching=="function"?E.branching(I.config):E.branching)&&$){c({data:I,instruction:E});return}k(I)},[o,k,r.instructions]);return n.jsxs(ro.Provider,{value:{presetting:i,setPresetting:c,onCreate:F,creating:s,setCreating:a},children:[e.children,n.jsx(l.ActionContextProvider,{value:{visible:!!i,setVisible:f,formValueChanged:u,setFormValueChanged:d,openSize:"small"},children:n.jsx(l.SchemaComponent,{components:{DownstreamBranchIndex:$n,PresetFieldset:In},scope:{useCancelAction:l.useCancelAction,useAddNodeSubmitAction:En},schema:{name:"modal",type:"void","x-decorator":"FormV2","x-decorator-props":{form:b},"x-component":"Action.Modal",title:`{{ t("Add node", { ns: "${p}" }) }}`,properties:{config:{type:"void","x-component":"PresetFieldset"},downstreamBranchIndex:{type:"void","x-component":"DownstreamBranchIndex"},footer:{"x-component":"Action.Modal.Footer",properties:{actions:{type:"void","x-component":"ActionBar",properties:{cancel:{type:"void",title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},submit:{type:"void",title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",htmlType:"submit",useAction:"{{ useAddNodeSubmitAction }}"}}}}}}}}})})]})}function tt({from:e=null,entry:t=null,branchIndex:o=null,controller:r=null,className:s,end:a}){const{styles:i}=ne(),{getAriaLabel:c}=St(e,o),u=[];for(let d=t;d;d=d.downstream)u.push(d);return n.jsxs("div",{className:l.cx("workflow-branch",i.branchClass,s),children:[n.jsx("div",{className:"workflow-branch-lines"}),r,n.jsx(no,{"aria-label":c(),upstream:e,branchIndex:o}),n.jsx("div",{className:"workflow-node-list",children:u.map(d=>n.jsx(Gt,{data:d},d.id))}),a?n.jsx("div",{className:"end-sign",children:n.jsx(V.CloseOutlined,{})}):null]})}function Mn(){var a;const e=T.useForm(),t=l.useAPIClient(),{workflow:o}=(a=H())!=null?a:{},r=l.useActionContext(),{refresh:s}=l.useResourceActionContext();return{run(){return J(this,null,function*(){if(o.executed){g.message.error(O("Trigger in executed workflow cannot be modified"));return}yield e.submit(),yield t.resource("workflows").update({filterByTk:o.id,values:{config:e.values}}),r.setFormValueChanged(!1),r.setVisible(!1),s()})}}}class Mt{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 Bn(){const e=l.useCompile(),{workflow:t,execution:o}=H(),{styles:r}=ne(),s=Bt();return o?n.jsx(l.SchemaComponent,{components:{Tooltip:g.Tooltip},schema:{type:"void",name:"execution","x-decorator":"Tooltip","x-decorator-props":{title:O("View result")},"x-component":"Action","x-component-props":{title:n.jsx(V.InfoOutlined,{}),shape:"circle",size:"small",className:r.nodeJobButtonClass,type:"primary"},properties:{[o.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:n.jsxs("div",{className:l.cx(r.nodeTitleClass),children:[n.jsx(g.Tag,{children:e(s.title)}),n.jsx("strong",{children:t.title}),n.jsxs("span",{className:"workflow-node-id",children:["#",o.id]})]}),properties:{createdAt:{type:"string",title:`{{t("Triggered at", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},context:{type:"object",title:`{{t("Trigger variables", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:l.css`
|
|
497
497
|
padding: 1em;
|
|
498
498
|
background-color: #f3f3f3;
|
|
499
|
-
`},"x-read-pretty":!0}}}}}}):null}function Vn(){return{form:T.useForm()}}const jn=()=>{const e=l.useAPIClient(),{workflow:t,refresh:o}=H(),[r,s]=y.useState(""),[a,i]=y.useState(!1),[c,
|
|
499
|
+
`},"x-read-pretty":!0}}}}}}):null}function Vn(){return{form:T.useForm()}}const jn=()=>{const e=l.useAPIClient(),{workflow:t,refresh:o}=H(),[r,s]=y.useState(""),[a,i]=y.useState(!1),[c,u]=y.useState(!1),{styles:d}=ne(),m=l.useCompile(),h=Bt();y.useEffect(()=>{var E,I;t&&s((I=(E=t.triggerTitle)!=null?E:t.title)!=null?I:m(h==null?void 0:h.title))},[t,h]);const v=y.useMemo(()=>{const E=we.cloneDeep(t.config);return fe.createForm({initialValues:E,disabled:t.executed})},[t]),b=y.useCallback(E=>{i(E),E||v.reset()},[v]),f=y.useCallback(function(E){return J(this,null,function*(){const I=E||m(h==null?void 0:h.title);s(I),I!==t.triggerTitle&&(yield e.resource("workflows").update({filterByTk:t.id,values:{triggerTitle:I}}),o())})},[t,h]),k=y.useCallback(function(E){var $;if(E.target===E.currentTarget){i(!0);return}const I=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let N=E.target;N&&N!==E.currentTarget;N=N.parentNode)if(Array.from(($=N.classList)!=null?$:[]).some(B=>I.has(B))){i(!0),E.stopPropagation();return}},[]),F=t.executed?'{{t("View")}}':'{{t("Configure")}}',M=O("Trigger");if(!h)return n.jsx(g.Tooltip,{title:O("Workflow with unknown type will cause error. Please delete it or check plugin which provide this type."),children:n.jsxs("div",{role:"button","aria-label":`${M}-${r}`,className:l.cx(d.nodeCardClass,"invalid"),onClick:k,children:[n.jsx("div",{className:d.nodeHeaderClass,children:n.jsx("div",{className:l.cx(d.nodeMetaClass,"workflow-node-meta"),children:n.jsx(g.Tag,{color:"error",children:O("Unknown trigger")})})}),n.jsx("div",{className:"workflow-node-title",children:n.jsx(g.Input.TextArea,{value:r,disabled:!0,autoSize:!0})})]})});const{fieldset:S,scope:D,components:L}=h;return n.jsxs("div",{role:"button","aria-label":`${M}-${r}`,className:l.cx(d.nodeCardClass),onClick:k,children:[n.jsxs("div",{className:d.nodeHeaderClass,children:[n.jsx("div",{className:l.cx(d.nodeMetaClass,"workflow-node-meta"),children:n.jsxs(g.Tag,{color:"gold",children:[n.jsx(V.ThunderboltOutlined,{}),n.jsx("span",{className:"type",children:m(h.title)})]})}),n.jsx("div",{className:"workflow-node-actions",children:n.jsx(Bn,{})})]}),n.jsx("div",{className:"workflow-node-title",children:n.jsx(g.Input.TextArea,{value:r,onChange:E=>s(E.target.value),onBlur:E=>f(E.target.value),autoSize:!0,disabled:t.executed})}),n.jsx(l.ActionContextProvider,{value:{visible:a,setVisible:b,formValueChanged:c,setFormValueChanged:u},children:n.jsx(l.FormProvider,{form:v,children:n.jsx(l.SchemaComponent,{scope:A(C({},D),{useFormProviderProps:Vn}),components:L,schema:{name:`workflow-trigger-${t.id}`,type:"void",properties:{config:{type:"void","x-content":F,"x-component":g.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},drawer:{type:"void",title:M,"x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps",properties:A(C({},h.description?{description:{type:"void","x-component":zt,"x-component-props":{label:O("Trigger type"),title:h.title,description:h.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:l.css`
|
|
500
500
|
.ant-select.auto-width {
|
|
501
501
|
width: auto;
|
|
502
502
|
min-width: 6em;
|
|
@@ -507,20 +507,20 @@
|
|
|
507
507
|
margin-bottom: 1em;
|
|
508
508
|
`}):null,n.jsx(jn,{}),n.jsx("div",{className:l.cx(t.branchBlockClass,l.css`
|
|
509
509
|
margin-top: 0 !important;
|
|
510
|
-
`),children:n.jsx(tt,{entry:e})}),n.jsx("div",{className:t.terminalClass,children:O("End")})]})})})})}),n.jsx("div",{className:"workflow-canvas-zoomer",children:n.jsx(g.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:r,onChange:s})})]})}function Wn(e,t=[]){const o=new Map;e.forEach(r=>{r.jobs=[],o.set(r.id,r)}),t.forEach(r=>{const s=o.get(r.nodeId);s.jobs.push(r),r.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(r=>{r.jobs=r.jobs.sort((s,a)=>s.id-a.id)})}function Ln(){const{instructions:e}=l.usePlugin(le),t=l.useCompile(),{viewJob:o,setViewJob:r}=H(),{styles:s}=ne(),{node:a={}}=o!=null?o:{},i=e.get(a.type);return n.jsx(l.ActionContextProvider,{value:{visible:!!o,setVisible:r},children:n.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`${o==null?void 0:o.id}-${o==null?void 0:o.updatedAt}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:n.jsxs("div",{className:s.nodeTitleClass,children:[n.jsx(g.Tag,{children:t(i==null?void 0:i.title)}),n.jsx("strong",{children:a.title}),n.jsxs("span",{className:"workflow-node-id",children:["#",a.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:kt,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:s.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function zn(e){const{execution:t}=H(),o=l.useAPIClient(),r=se.useNavigate(),{styles:s}=ne(),[a,i]=y.useState([]),[c,p]=y.useState([]);y.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:m})=>{i(m.data)}).catch(()=>{})},[t]),y.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:m})=>{p(m.data.reverse())}).catch(()=>{})},[t]);const d=y.useCallback(({key:m})=>{m!=t.id&&r(qe(m))},[t]);return t?n.jsx(g.Dropdown,{menu:{onClick:d,defaultSelectedKeys:[`${t.id}`],className:l.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...a].map(m=>({key:m.id,label:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"id",children:`#${m.id}`}),n.jsx("time",{children:Q.str2moment(m.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:n.jsx("span",{children:n.jsx(Be,{statusMap:_e,status:m.status})})}))},children:n.jsxs(g.Space,{children:[n.jsx("strong",{children:`#${t.id}`}),n.jsx(V.DownOutlined,{})]})}):null}function Jn(){var S;const{t:e}=X.useTranslation(),t=l.useCompile(),{data:o,loading:r,refresh:s}=l.useResourceActionContext(),{setTitle:a}=l.useDocumentTitle(),[i,c]=y.useState(null),p=l.useApp(),d=l.useAPIClient();y.useEffect(()=>{var D;const{workflow:I}=(D=o==null?void 0:o.data)!=null?D:{};a==null||a(`${I!=null&&I.title?`${I.title} - `:""}${O("Execution history")}`)},[o==null?void 0:o.data]);const m=y.useCallback(()=>{g.Modal.confirm({title:O("Cancel the execution"),icon:n.jsx(V.ExclamationCircleFilled,{}),content:O("Are you sure you want to cancel the execution?"),onOk:()=>{d.resource("executions").cancel({filterByTk:o==null?void 0:o.data.id}).then(()=>{g.message.success(e("Operation succeeded")),s()}).catch(I=>{console.error(I.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return r?n.jsx(g.Spin,{}):n.jsx(g.Result,{status:"404",title:"Not found"});const E=(S=o==null?void 0:o.data)!=null?S:{},{jobs:h=[],workflow:L={}}=E,$=L,{nodes:v=[],revisions:b=[]}=$,f=Z($,["nodes","revisions"]),k=Z(E,["jobs","workflow"]);vt(v),Wn(v,h);const F=v.find(I=>!I.upstream),M=_e[k.status];return n.jsxs(Pe.Provider,{value:{workflow:f.type?f:null,nodes:v,execution:k,viewJob:i,setViewJob:c},children:[n.jsxs("div",{className:"workflow-toolbar",children:[n.jsx("header",{children:n.jsx(g.Breadcrumb,{items:[{title:n.jsx(se.Link,{to:p.pluginSettingsManager.getRoutePath("workflow"),children:O("Workflow")})},{title:n.jsx(g.Tooltip,{title:`Key: ${f.key}`,children:n.jsx(se.Link,{to:Ce(f.id),children:f.title})})},{title:n.jsx(zn,{})}]})}),n.jsxs("aside",{children:[n.jsx(g.Tag,{color:M.color,children:t(M.label)}),k.status?null:n.jsx(g.Tooltip,{title:O("Cancel the execution"),children:n.jsx(g.Button,{type:"link",danger:!0,onClick:m,shape:"circle",size:"small",icon:n.jsx(V.StopOutlined,{})})}),n.jsx("time",{children:Q.str2moment(k.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),n.jsx(so,{entry:F}),n.jsx(Ln,{})]})}const lo=()=>{const e=se.useParams(),{styles:t}=ne();return n.jsx("div",{className:l.cx(t.workflowPageClass),children:n.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`execution_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:e,appends:["jobs","workflow","workflow.nodes"]}}},"x-component":"ExecutionCanvas"}}},components:{ExecutionCanvas:Jn}})})},ao=()=>{const{t:e}=X.useTranslation(),{id:t}=l.useRecord(),{setVisible:o}=l.useActionContext();return n.jsx(se.Link,{to:qe(t),onClick:()=>o(!1),children:e("View")})},Un={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: "${u}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${u}" })}}`,"x-component"({value:e}){const{setVisible:t}=l.useActionContext();return n.jsx(se.Link,{to:Ce(e),onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${u}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:Ye}}]},io={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${u}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:Un,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"}},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?')}}"}}},clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=X.useTranslation(),{refresh:t,defaultRequest:o}=l.useResourceActionContext(),{resource:r}=l.useResourceContext(),{setVisible:s}=l.useActionContext();return{run(){return J(this,null,function*(){var i;yield r.destroy({filter:(i=o.params)==null?void 0:i.filter}),g.message.success(e("Operation succeeded")),t(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${u}" })}}`,content:`{{t("Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?", { ns: "${u}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},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: "${u}" })}}`,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"},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 }}"},"x-reactions":[{dependencies:["..status"],fulfill:{state:{visible:`{{ $deps[0] !== ${ie.STARTED} }}`}}}]}}}}}}}}}}};function co(e){var a;const o=l.useCompile()(e.label),r=y.useCallback(i=>{i.preventDefault(),i.stopPropagation()},[]),{color:s}=(a=_e[e.value])!=null?a:{};return n.jsx(g.Tag,{color:s,onMouseDown:r,closable:e.closable,onClose:e.onClose,children:o})}function Hn(e){const t=l.useCompile();return n.jsxs(n.Fragment,{children:[n.jsx(co,C({},e)),e.description?n.jsx("span",{children:t(e.description)}):null]})}function Gn(t){var e=Z(t,[]);const o=e.multiple?"multiple":null;return n.jsx(g.Select,A(C({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:co,children:Ye.filter(r=>!!r.value&&r.value!==ie.ABORTED).map(r=>n.jsx(g.Select.Option,A(C({},r),{children:n.jsx(Hn,C({},r))}),r.value))}))}function uo(e){const{t}=X.useTranslation(),{refresh:o}=l.useResourceActionContext(),{resource:r}=l.useResourceContext(),s=l.useRecord(),a=y.useCallback(()=>{g.Modal.confirm({title:O("Cancel the execution"),icon:n.jsx(V.ExclamationCircleFilled,{}),content:O("Are you sure you want to cancel the execution?"),onOk:()=>{r.cancel({filterByTk:s.id}).then(()=>{g.message.success(t("Operation succeeded")),o()}).catch(i=>{console.error(i.data.error)})}})},[s]);return n.jsxs("div",{className:l.css`
|
|
510
|
+
`),children:n.jsx(tt,{entry:e})}),n.jsx("div",{className:t.terminalClass,children:O("End")})]})})})})}),n.jsx("div",{className:"workflow-canvas-zoomer",children:n.jsx(g.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:r,onChange:s})})]})}function Wn(e,t=[]){const o=new Map;e.forEach(r=>{r.jobs=[],o.set(r.id,r)}),t.forEach(r=>{const s=o.get(r.nodeId);s.jobs.push(r),r.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(r=>{r.jobs=r.jobs.sort((s,a)=>s.id-a.id)})}function Ln(){const{instructions:e}=l.usePlugin(le),t=l.useCompile(),{viewJob:o,setViewJob:r}=H(),{styles:s}=ne(),{node:a={}}=o!=null?o:{},i=e.get(a.type);return n.jsx(l.ActionContextProvider,{value:{visible:!!o,setVisible:r},children:n.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`${o==null?void 0:o.id}-${o==null?void 0:o.updatedAt}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:n.jsxs("div",{className:s.nodeTitleClass,children:[n.jsx(g.Tag,{children:t(i==null?void 0:i.title)}),n.jsx("strong",{children:a.title}),n.jsxs("span",{className:"workflow-node-id",children:["#",a.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:kt,"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 zn(e){const{execution:t}=H(),o=l.useAPIClient(),r=se.useNavigate(),{styles:s}=ne(),[a,i]=y.useState([]),[c,u]=y.useState([]);y.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:m})=>{i(m.data)}).catch(()=>{})},[t]),y.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:m})=>{u(m.data.reverse())}).catch(()=>{})},[t]);const d=y.useCallback(({key:m})=>{m!=t.id&&r(qe(m))},[t]);return t?n.jsx(g.Dropdown,{menu:{onClick:d,defaultSelectedKeys:[`${t.id}`],className:l.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...a].map(m=>({key:m.id,label:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"id",children:`#${m.id}`}),n.jsx("time",{children:Q.str2moment(m.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:n.jsx("span",{children:n.jsx(Be,{statusMap:_e,status:m.status})})}))},children:n.jsxs(g.Space,{children:[n.jsx("strong",{children:`#${t.id}`}),n.jsx(V.DownOutlined,{})]})}):null}function Jn(){var S;const{t:e}=X.useTranslation(),t=l.useCompile(),{data:o,loading:r,refresh:s}=l.useResourceActionContext(),{setTitle:a}=l.useDocumentTitle(),[i,c]=y.useState(null),u=l.useApp(),d=l.useAPIClient();y.useEffect(()=>{var $;const{workflow:I}=($=o==null?void 0:o.data)!=null?$:{};a==null||a(`${I!=null&&I.title?`${I.title} - `:""}${O("Execution history")}`)},[o==null?void 0:o.data]);const m=y.useCallback(()=>{g.Modal.confirm({title:O("Cancel the execution"),icon:n.jsx(V.ExclamationCircleFilled,{}),content:O("Are you sure you want to cancel the execution?"),onOk:()=>{d.resource("executions").cancel({filterByTk:o==null?void 0:o.data.id}).then(()=>{g.message.success(e("Operation succeeded")),s()}).catch(I=>{console.error(I.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return r?n.jsx(g.Spin,{}):n.jsx(g.Result,{status:"404",title:"Not found"});const D=(S=o==null?void 0:o.data)!=null?S:{},{jobs:h=[],workflow:L={}}=D,E=L,{nodes:v=[],revisions:b=[]}=E,f=Z(E,["nodes","revisions"]),k=Z(D,["jobs","workflow"]);vt(v),Wn(v,h);const F=v.find(I=>!I.upstream),M=_e[k.status];return n.jsxs(Pe.Provider,{value:{workflow:f.type?f:null,nodes:v,execution:k,viewJob:i,setViewJob:c},children:[n.jsxs("div",{className:"workflow-toolbar",children:[n.jsx("header",{children:n.jsx(g.Breadcrumb,{items:[{title:n.jsx(se.Link,{to:u.pluginSettingsManager.getRoutePath("workflow"),children:O("Workflow")})},{title:n.jsx(g.Tooltip,{title:`Key: ${f.key}`,children:n.jsx(se.Link,{to:Ce(f.id),children:f.title})})},{title:n.jsx(zn,{})}]})}),n.jsxs("aside",{children:[n.jsx(g.Tag,{color:M.color,children:t(M.label)}),k.status?null:n.jsx(g.Tooltip,{title:O("Cancel the execution"),children:n.jsx(g.Button,{type:"link",danger:!0,onClick:m,shape:"circle",size:"small",icon:n.jsx(V.StopOutlined,{})})}),n.jsx("time",{children:Q.str2moment(k.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),n.jsx(so,{entry:F}),n.jsx(Ln,{})]})}const lo=()=>{const e=se.useParams(),{styles:t}=ne();return n.jsx("div",{className:l.cx(t.workflowPageClass),children:n.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`execution_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:e,appends:["jobs","workflow","workflow.nodes"]}}},"x-component":"ExecutionCanvas"}}},components:{ExecutionCanvas:Jn}})})},ao=()=>{const{t:e}=X.useTranslation(),{id:t}=l.useRecord(),{setVisible:o}=l.useActionContext();return n.jsx(se.Link,{to:qe(t),onClick:()=>o(!1),children:e("View")})},Un={name:"execution-executions",fields:[{interface:"id",type:"bigInt",name:"id",uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${p}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${p}" })}}`,"x-component"({value:e}){const{setVisible:t}=l.useActionContext();return n.jsx(se.Link,{to:Ce(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:Ye}}]},io={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:Un,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"}},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?')}}"}}},clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=X.useTranslation(),{refresh:t,defaultRequest:o}=l.useResourceActionContext(),{resource:r}=l.useResourceContext(),{setVisible:s}=l.useActionContext();return{run(){return J(this,null,function*(){var i;yield r.destroy({filter:(i=o.params)==null?void 0:i.filter}),g.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",rowSelection:{type:"checkbox"},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"},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 }}"},"x-reactions":[{dependencies:["..status"],fulfill:{state:{visible:`{{ $deps[0] !== ${ie.STARTED} }}`}}}]}}}}}}}}}}};function co(e){var a;const o=l.useCompile()(e.label),r=y.useCallback(i=>{i.preventDefault(),i.stopPropagation()},[]),{color:s}=(a=_e[e.value])!=null?a:{};return n.jsx(g.Tag,{color:s,onMouseDown:r,closable:e.closable,onClose:e.onClose,children:o})}function Hn(e){const t=l.useCompile();return n.jsxs(n.Fragment,{children:[n.jsx(co,C({},e)),e.description?n.jsx("span",{children:t(e.description)}):null]})}function Gn(t){var e=Z(t,[]);const o=e.multiple?"multiple":null;return n.jsx(g.Select,A(C({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:co,children:Ye.filter(r=>!!r.value&&r.value!==ie.ABORTED).map(r=>n.jsx(g.Select.Option,A(C({},r),{children:n.jsx(Hn,C({},r))}),r.value))}))}function uo(e){const{t}=X.useTranslation(),{refresh:o}=l.useResourceActionContext(),{resource:r}=l.useResourceContext(),s=l.useRecord(),a=y.useCallback(()=>{g.Modal.confirm({title:O("Cancel the execution"),icon:n.jsx(V.ExclamationCircleFilled,{}),content:O("Are you sure you want to cancel the execution?"),onOk:()=>{r.cancel({filterByTk:s.id}).then(()=>{g.message.success(t("Operation succeeded")),o()}).catch(i=>{console.error(i.data.error)})}})},[s]);return n.jsxs("div",{className:l.css`
|
|
511
511
|
display: flex;
|
|
512
|
-
`,children:[e.children,s.status?null:n.jsx(g.Tooltip,{title:O("Cancel the execution"),children:n.jsx(g.Button,{type:"link",danger:!0,onClick:a,shape:"circle",size:"small",icon:n.jsx(V.StopOutlined,{})})})]})}function po(){const e=l.useResourceActionContext();return{onClick(){return J(this,null,function*(){var o;(o=e==null?void 0:e.refresh)==null||o.call(e)})}}}function qn(r){var s=r,{request:e,filter:t={}}=s,o=Z(s,["request","filter"]);var c;const{workflow:a}=H(),i=A(C({},o),{request:A(C({},e),{params:A(C({},e==null?void 0:e.params),{filter:A(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return n.jsx(l.ResourceActionProvider,C({},i))}function Yn(){var I;const e=se.useNavigate(),{t}=X.useTranslation(),o=l.useApp(),{data:r,refresh:s,loading:a}=l.useResourceActionContext(),{resource:i}=l.useResourceContext(),{setTitle:c}=l.useDocumentTitle(),[p,d]=y.useState(!1),{styles:m}=ne(),{modal:h}=g.App.useApp();if(y.useEffect(()=>{var B;const{title:N}=(B=r==null?void 0:r.data)!=null?B:{};c==null||c(`${O("Workflow")}${N?`: ${N}`:""}`)},[r==null?void 0:r.data]),!(r!=null&&r.data))return a?n.jsx(g.Spin,{}):n.jsx(g.Result,{status:"404",title:"Not found",extra:n.jsx(g.Button,{onClick:()=>e(-1),children:O("Go back")})});const D=(I=r==null?void 0:r.data)!=null?I:{},{nodes:v=[],revisions:b=[]}=D,f=Z(D,["nodes","revisions"]);vt(v);const k=v.find(N=>!N.upstream);function F({key:N}){N!=f.id&&e(Ce(N))}function M(N){return J(this,null,function*(){yield i.update({filterByTk:f.id,values:{enabled:N}}),s()})}function S(){return J(this,null,function*(){const{data:{data:N}}=yield i.revision({filterByTk:f.id,filter:{key:f.key}});g.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${N.id}`)})}function E(){return J(this,null,function*(){const N=f.current?O("Delete a main version will cause all other revisions to be deleted too."):"";h.confirm({title:t("Are you sure you want to delete it?"),content:N,onOk(){return J(this,null,function*(){var G;yield i.destroy({filterByTk:f.id}),g.message.success(t("Operation succeeded")),e(f.current?o.pluginSettingsManager.getRoutePath("workflow"):Ce((G=b.find(U=>U.current))==null?void 0:G.id))})}})})}function L(B){return J(this,arguments,function*({key:N}){switch(N){case"history":d(!0);return;case"revision":return S();case"delete":return E()}})}const $=f.executed&&!b.find(N=>!N.executed&&new Date(N.createdAt)>new Date(f.createdAt));return n.jsxs(Pe.Provider,{value:{workflow:f,nodes:v,refresh:s},children:[n.jsxs("div",{className:"workflow-toolbar",children:[n.jsx("header",{children:n.jsx(g.Breadcrumb,{items:[{title:n.jsx(se.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:O("Workflow")})},{title:n.jsx(g.Tooltip,{title:`Key: ${f.key}`,children:n.jsx("strong",{children:f.title})})}]})}),n.jsxs("aside",{children:[f.sync?n.jsx(g.Tag,{color:"orange",children:O("Synchronously")}):n.jsx(g.Tag,{color:"cyan",children:O("Asynchronously")}),n.jsx(g.Dropdown,{className:"workflow-versions",trigger:["click"],menu:{onClick:F,defaultSelectedKeys:[`${f.id}`],className:l.cx(m.dropdownClass,m.workflowVersionDropdownClass),items:b.sort((N,B)=>B.id-N.id).map((N,B)=>({role:"button","aria-label":`version-${B}`,key:`${N.id}`,icon:N.current?n.jsx(V.RightOutlined,{}):null,className:l.cx({executed:N.executed,unexecuted:!N.executed,enabled:N.enabled}),label:n.jsxs(n.Fragment,{children:[n.jsx("strong",{children:`#${N.id}`}),n.jsx("time",{children:Q.str2moment(N.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:n.jsxs(g.Button,{type:"text","aria-label":"version",children:[n.jsx("label",{children:O("Version")}),n.jsx("span",{children:f!=null&&f.id?`#${f.id}`:null}),n.jsx(V.DownOutlined,{})]})}),n.jsx(g.Switch,{checked:f.enabled,onChange:M,checkedChildren:O("On"),unCheckedChildren:O("Off")}),n.jsx(g.Dropdown,{menu:{items:[{key:"key",label:`Key: ${f.key}`,disabled:!0},{type:"divider"},{role:"button","aria-label":"history",key:"history",label:O("Execution history"),disabled:!f.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:O("Copy to new version"),disabled:!$},{type:"divider"},{role:"button","aria-label":"delete",danger:!0,key:"delete",label:t("Delete")}],onClick:L},children:n.jsx(g.Button,{"aria-label":"more",type:"text",icon:n.jsx(V.EllipsisOutlined,{})})}),n.jsx(l.ActionContextProvider,{value:{visible:p,setVisible:d},children:n.jsx(l.SchemaComponent,{schema:io,components:{ExecutionResourceProvider:qn,ExecutionLink:ao,ExecutionStatusColumn:uo},scope:{useRefreshActionProps:po}})})]})]}),n.jsx(so,{entry:k})]})}const mo=()=>{const e=se.useParams(),{styles:t}=ne();return n.jsx("div",{className:l.cx(t.workflowPageClass),children:n.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:Yn}})})},_n=r=>{var s=r,{request:e,filter:t={}}=s,o=Z(s,["request","filter"]);var c;const a=l.useRecord(),i=A(C({},o),{request:A(C({},e),{params:A(C({},e==null?void 0:e.params),{filter:A(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return n.jsx(l.ResourceActionProvider,C({},i))},Kn=()=>{const{t:e}=X.useTranslation(),{id:t}=l.useRecord(),{setVisible:o}=l.useActionContext(),{getAriaLabel:r}=l.useGetAriaLabelOfAction("Configure");return n.jsx(se.Link,{"aria-label":r(),to:Ce(t),onClick:()=>o(!1),children:e("Configure")})};function Zn(r){var s=r,{component:e="div",children:t}=s,o=Z(s,["component","children"]);const[a,i]=y.useState(!1),c=T.useFieldSchema();return n.jsxs(l.ActionContextProvider,{value:{visible:a,setVisible:i,fieldSchema:c},children:[y.createElement(e,A(C({},o),{onClick(){i(!0)}}),t),n.jsx(l.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}function Qn({data:e}){const{label:t,color:o,options:r}=e,s=l.useCompile();return n.jsxs(g.Space,{direction:"vertical",children:[n.jsx(g.Tag,{color:o,children:s(t)}),n.jsx(g.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:s(r.description)})]})}const fo={name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Trigger type", { ns: "${u}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select",enum:"{{useTriggersOptions()}}","x-component-props":{optionRender:Qn,popupMatchSelectWidth:!0,listHeight:300},required:!0}},{type:"boolean",name:"sync",interface:"radioGroup",uiSchema:{title:`{{t("Mode", { ns: "${u}" })}}`,type:"boolean","x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{ t("Asynchronously", { ns: "${u}" }) }}`,value:!1,color:"cyan"},{label:`{{ t("Synchronously", { ns: "${u}" }) }}`,value:!0,color:"orange"}],required:!0}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${u}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${u}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${u}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${u}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},he={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${u}" }) }}`,description:`{{ t("Execute workflow asynchronously or synchronously based on trigger type, and could not be changed after created.", { ns: "${u}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Asynchronously", { ns: "${u}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${u}" }) }}`},{label:`{{ t("Synchronously", { ns: "${u}" }) }}`,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: "${u}" }) }}`}]}},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"fieldset",properties:{deleteExecutionOnStatus:{type:"array",title:`{{ t("Auto delete history when execution is on end status", { ns: "${u}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},Xn={name:"workflow",type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:fo,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:fo},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: "${u}" })}}`,"x-decorator":"Tooltip","x-decorator-props":{title:`{{ t("Sync enabled status of all workflows from database", { ns: "${u}" }) }}`},"x-component":"Action","x-component-props":{icon:"SyncOutlined",useAction(){const{t:e}=X.useTranslation(),{resource:t}=l.useResourceContext(),o=l.useResourceActionContext();return{run(){return J(this,null,function*(){yield t.sync(),yield o==null?void 0:o.refresh(),g.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:he.title,type:he.type,sync:he.sync,description:he.description,options:he.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},sync:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{sync:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=l.useRecord();return y.createElement("a",C({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:io}}}},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:he.title,enabled:he.enabled,sync:he.sync,description:he.description,options:he.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},revision:{type:"void",title:`{{t("Duplicate", { ns: "${u}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${u}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=X.useTranslation(),{refresh:t}=l.useResourceActionContext(),{resource:o,targetKey:r}=l.useResourceContext(),{setVisible:s}=l.useActionContext(),{[r]:a}=l.useRecord(),{values:i}=T.useForm();return{run(){return J(this,null,function*(){yield o.revision({filterByTk:a,values:i}),g.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 Rn(e){const t=T.useField(),o=l.useRecord(),r=l.usePlugin(le);return T.useFormEffects(s=>{fe.onFieldChange("type",a=>{let i=o.id||!a.value;if(a.value){const c=r.triggers.get(a.value);c.sync!=null?(i=!0,t.setValue(c.sync)):t.setInitialValue(!1)}t.setPattern(i?"disabled":"editable")})}),y.useEffect(()=>{if(o.id){t.setPattern("disabled");const s=r.triggers.get(o.type);s.sync!=null?t.setValue(s.sync):t.setInitialValue(!1)}},[o.id,t,r.triggers]),n.jsx(ke,C({},e))}function er(e){const t=l.useApp();e.visible=!!(l.usePlugin("multi-app-share-collection")||t.name!=="main")}function tr(){const e=y.useContext(l.SchemaComponentContext),{useTriggersOptions:t}=l.usePlugin(le);return n.jsx(g.Card,{bordered:!1,children:n.jsx(l.SchemaComponentContext.Provider,{value:A(C({},e),{designable:!1}),children:n.jsx(l.SchemaComponent,{schema:Xn,components:{WorkflowLink:Kn,ExecutionResourceProvider:_n,ExecutionLink:ao,OpenDrawer:Zn,ExecutionStatusSelect:Gn,SyncOptionSelect:Rn,ExecutionStatusColumn:uo,Tooltip:g.Tooltip},scope:{useTriggersOptions:t,useWorkflowSyncAction:er,useRefreshActionProps:po}})})})}const de={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"},ho={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: "${u}" })}}`,"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:l.css`
|
|
512
|
+
`,children:[e.children,s.status?null:n.jsx(g.Tooltip,{title:O("Cancel the execution"),children:n.jsx(g.Button,{type:"link",danger:!0,onClick:a,shape:"circle",size:"small",icon:n.jsx(V.StopOutlined,{})})})]})}function po(){const e=l.useResourceActionContext();return{onClick(){return J(this,null,function*(){var o;(o=e==null?void 0:e.refresh)==null||o.call(e)})}}}function qn(r){var s=r,{request:e,filter:t={}}=s,o=Z(s,["request","filter"]);var c;const{workflow:a}=H(),i=A(C({},o),{request:A(C({},e),{params:A(C({},e==null?void 0:e.params),{filter:A(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return n.jsx(l.ResourceActionProvider,C({},i))}function Yn(){var I;const e=se.useNavigate(),{t}=X.useTranslation(),o=l.useApp(),{data:r,refresh:s,loading:a}=l.useResourceActionContext(),{resource:i}=l.useResourceContext(),{setTitle:c}=l.useDocumentTitle(),[u,d]=y.useState(!1),{styles:m}=ne(),{modal:h}=g.App.useApp();if(y.useEffect(()=>{var B;const{title:N}=(B=r==null?void 0:r.data)!=null?B:{};c==null||c(`${O("Workflow")}${N?`: ${N}`:""}`)},[r==null?void 0:r.data]),!(r!=null&&r.data))return a?n.jsx(g.Spin,{}):n.jsx(g.Result,{status:"404",title:"Not found",extra:n.jsx(g.Button,{onClick:()=>e(-1),children:O("Go back")})});const $=(I=r==null?void 0:r.data)!=null?I:{},{nodes:v=[],revisions:b=[]}=$,f=Z($,["nodes","revisions"]);vt(v);const k=v.find(N=>!N.upstream);function F({key:N}){N!=f.id&&e(Ce(N))}function M(N){return J(this,null,function*(){yield i.update({filterByTk:f.id,values:{enabled:N}}),s()})}function S(){return J(this,null,function*(){const{data:{data:N}}=yield i.revision({filterByTk:f.id,filter:{key:f.key}});g.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${N.id}`)})}function D(){return J(this,null,function*(){const N=f.current?O("Delete a main version will cause all other revisions to be deleted too."):"";h.confirm({title:t("Are you sure you want to delete it?"),content:N,onOk(){return J(this,null,function*(){var G;yield i.destroy({filterByTk:f.id}),g.message.success(t("Operation succeeded")),e(f.current?o.pluginSettingsManager.getRoutePath("workflow"):Ce((G=b.find(U=>U.current))==null?void 0:G.id))})}})})}function L(B){return J(this,arguments,function*({key:N}){switch(N){case"history":d(!0);return;case"revision":return S();case"delete":return D()}})}const E=f.executed&&!b.find(N=>!N.executed&&new Date(N.createdAt)>new Date(f.createdAt));return n.jsxs(Pe.Provider,{value:{workflow:f,nodes:v,refresh:s},children:[n.jsxs("div",{className:"workflow-toolbar",children:[n.jsx("header",{children:n.jsx(g.Breadcrumb,{items:[{title:n.jsx(se.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:O("Workflow")})},{title:n.jsx(g.Tooltip,{title:`Key: ${f.key}`,children:n.jsx("strong",{children:f.title})})}]})}),n.jsxs("aside",{children:[f.sync?n.jsx(g.Tag,{color:"orange",children:O("Synchronously")}):n.jsx(g.Tag,{color:"cyan",children:O("Asynchronously")}),n.jsx(g.Dropdown,{className:"workflow-versions",trigger:["click"],menu:{onClick:F,defaultSelectedKeys:[`${f.id}`],className:l.cx(m.dropdownClass,m.workflowVersionDropdownClass),items:b.sort((N,B)=>B.id-N.id).map((N,B)=>({role:"button","aria-label":`version-${B}`,key:`${N.id}`,icon:N.current?n.jsx(V.RightOutlined,{}):null,className:l.cx({executed:N.executed,unexecuted:!N.executed,enabled:N.enabled}),label:n.jsxs(n.Fragment,{children:[n.jsx("strong",{children:`#${N.id}`}),n.jsx("time",{children:Q.str2moment(N.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:n.jsxs(g.Button,{type:"text","aria-label":"version",children:[n.jsx("label",{children:O("Version")}),n.jsx("span",{children:f!=null&&f.id?`#${f.id}`:null}),n.jsx(V.DownOutlined,{})]})}),n.jsx(g.Switch,{checked:f.enabled,onChange:M,checkedChildren:O("On"),unCheckedChildren:O("Off")}),n.jsx(g.Dropdown,{menu:{items:[{key:"key",label:`Key: ${f.key}`,disabled:!0},{type:"divider"},{role:"button","aria-label":"history",key:"history",label:O("Execution history"),disabled:!f.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:O("Copy to new version"),disabled:!E},{type:"divider"},{role:"button","aria-label":"delete",danger:!0,key:"delete",label:t("Delete")}],onClick:L},children:n.jsx(g.Button,{"aria-label":"more",type:"text",icon:n.jsx(V.EllipsisOutlined,{})})}),n.jsx(l.ActionContextProvider,{value:{visible:u,setVisible:d},children:n.jsx(l.SchemaComponent,{schema:io,components:{ExecutionResourceProvider:qn,ExecutionLink:ao,ExecutionStatusColumn:uo},scope:{useRefreshActionProps:po}})})]})]}),n.jsx(so,{entry:k})]})}const mo=()=>{const e=se.useParams(),{styles:t}=ne();return n.jsx("div",{className:l.cx(t.workflowPageClass),children:n.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:Yn}})})},_n=r=>{var s=r,{request:e,filter:t={}}=s,o=Z(s,["request","filter"]);var c;const a=l.useRecord(),i=A(C({},o),{request:A(C({},e),{params:A(C({},e==null?void 0:e.params),{filter:A(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return n.jsx(l.ResourceActionProvider,C({},i))},Kn=()=>{const{t:e}=X.useTranslation(),{id:t}=l.useRecord(),{setVisible:o}=l.useActionContext(),{getAriaLabel:r}=l.useGetAriaLabelOfAction("Configure");return n.jsx(se.Link,{"aria-label":r(),to:Ce(t),onClick:()=>o(!1),children:e("Configure")})};function Zn(r){var s=r,{component:e="div",children:t}=s,o=Z(s,["component","children"]);const[a,i]=y.useState(!1),c=T.useFieldSchema();return n.jsxs(l.ActionContextProvider,{value:{visible:a,setVisible:i,fieldSchema:c},children:[y.createElement(e,A(C({},o),{onClick(){i(!0)}}),t),n.jsx(l.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}function Qn({data:e}){const{label:t,color:o,options:r}=e,s=l.useCompile();return n.jsxs(g.Space,{direction:"vertical",children:[n.jsx(g.Tag,{color:o,children:s(t)}),n.jsx(g.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:s(r.description)})]})}const fo={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",enum:"{{useTriggersOptions()}}","x-component-props":{optionRender:Qn,popupMatchSelectWidth:!0,listHeight:300},required:!0}},{type:"boolean",name:"sync",interface:"radioGroup",uiSchema:{title:`{{t("Mode", { ns: "${p}" })}}`,type:"boolean","x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{ t("Asynchronously", { ns: "${p}" }) }}`,value:!1,color:"cyan"},{label:`{{ t("Synchronously", { ns: "${p}" }) }}`,value:!0,color:"orange"}],required:!0}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${p}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${p}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${p}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${p}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},he={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}}}}},Xn={name:"workflow",type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:fo,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:fo},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}=X.useTranslation(),{resource:t}=l.useResourceContext(),o=l.useResourceActionContext();return{run(){return J(this,null,function*(){yield t.sync(),yield o==null?void 0:o.refresh(),g.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:he.title,type:he.type,sync:he.sync,description:he.description,options:he.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},sync:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{sync:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=l.useRecord();return y.createElement("a",C({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:io}}}},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:he.title,enabled:he.enabled,sync:he.sync,description:he.description,options:he.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}=X.useTranslation(),{refresh:t}=l.useResourceActionContext(),{resource:o,targetKey:r}=l.useResourceContext(),{setVisible:s}=l.useActionContext(),{[r]:a}=l.useRecord(),{values:i}=T.useForm();return{run(){return J(this,null,function*(){yield o.revision({filterByTk:a,values:i}),g.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 Rn(e){const t=T.useField(),o=l.useRecord(),r=l.usePlugin(le);return T.useFormEffects(s=>{fe.onFieldChange("type",a=>{let i=o.id||!a.value;if(a.value){const c=r.triggers.get(a.value);c.sync!=null?(i=!0,t.setValue(c.sync)):t.setInitialValue(!1)}t.setPattern(i?"disabled":"editable")})}),y.useEffect(()=>{if(o.id){t.setPattern("disabled");const s=r.triggers.get(o.type);s.sync!=null?t.setValue(s.sync):t.setInitialValue(!1)}},[o.id,t,r.triggers]),n.jsx(ke,C({},e))}function er(e){const t=l.useApp();e.visible=!!(l.usePlugin("multi-app-share-collection")||t.name!=="main")}function tr(){const e=y.useContext(l.SchemaComponentContext),{useTriggersOptions:t}=l.usePlugin(le);return n.jsx(g.Card,{bordered:!1,children:n.jsx(l.SchemaComponentContext.Provider,{value:A(C({},e),{designable:!1}),children:n.jsx(l.SchemaComponent,{schema:Xn,components:{WorkflowLink:Kn,ExecutionResourceProvider:_n,ExecutionLink:ao,OpenDrawer:Zn,ExecutionStatusSelect:Gn,SyncOptionSelect:Rn,ExecutionStatusColumn:uo,Tooltip:g.Tooltip},scope:{useTriggersOptions:t,useWorkflowSyncAction:er,useRefreshActionProps:po}})})})}const de={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"},ho={type:"object",title:'{{t("Fields values")}}',description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:l.css`
|
|
513
513
|
flex-direction: column;
|
|
514
514
|
`},"x-component":"CollectionFieldset"},ot={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:e}=T.useForm(),[t,o]=l.parseCollectionName(e==null?void 0:e.collection);return{options:l.useCollectionFilterOptions(o,t),className:l.css`
|
|
515
515
|
position: relative;
|
|
516
516
|
width: 100%;
|
|
517
|
-
`}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},or={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"}}},nr={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},default:20}}}}}}},Le={type:"array",title:`{{t("Preload associations", { ns: "${
|
|
517
|
+
`}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},or={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"}}},nr={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},default:20}}}}}}},Le={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}=T.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]};function rr(){const e=l.useAPIClient(),t=T.useForm(),{field:o,__parent:r}=l.useBlockRequestContext(),{setVisible:s}=l.useActionContext(),a=se.useNavigate(),i=T.useFieldSchema(),c=T.useField(),u=l.useCompile(),{modal:d}=g.App.useApp(),m=l.useCollectValuesToSubmit(),h=c.componentProps.filterKeys||[];return{onClick(){return J(this,null,function*(){var M,S,D;const{onSuccess:b,skipValidator:f,triggerWorkflows:k}=(M=i==null?void 0:i["x-action-settings"])!=null?M:{};f||(yield t.submit());const F=yield m();c.data=o.data||{},c.data.loading=!0;try{const L=yield e.resource("workflows").trigger({values:F,filterKeys:h,triggerWorkflows:k!=null&&k.length?k.map(E=>[E.workflowKey,E.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.loading=!1,c.data.data=L,(D=(S=r==null?void 0:r.service)==null?void 0:S.refresh)==null||D.call(S),s==null||s(!1),!(b!=null&&b.successMessage))return;b!=null&&b.manualClose?d.success({title:u(b==null?void 0:b.successMessage),onOk:()=>J(this,null,function*(){yield t.reset(),b!=null&&b.redirecting&&(b!=null&&b.redirectTo)&&(Q.isURL(b.redirectTo)?window.location.href=b.redirectTo:a(b.redirectTo))})}):g.message.success(u(b==null?void 0:b.successMessage))}catch(L){c.data.loading=!1}})}}}function sr(){var b;const e=l.useCompile(),t=l.useAPIClient(),o=l.useRecord(),r=T.useField(),s=T.useFieldSchema(),{field:a,__parent:i}=l.useBlockRequestContext(),{setVisible:c,setSubmitted:u}=l.useActionContext(),{modal:d}=g.App.useApp(),m=se.useNavigate(),{onSuccess:h,triggerWorkflows:v}=(b=s==null?void 0:s["x-action-settings"])!=null?b:{};return{onClick(k,F){return J(this,null,function*(){r.data=a.data||{},r.data.loading=!0;try{if(yield t.resource("workflows").trigger({values:o,triggerWorkflows:v!=null&&v.length?v.map(M=>[M.workflowKey,M.context].filter(Boolean).join("!")).join(","):void 0}),F&&F(),c==null||c(!1),u==null||u(!0),!(h!=null&&h.successMessage))return;if(h!=null&&h.manualClose){let M;d.success({title:e(h==null?void 0:h.successMessage),onOk(){return J(this,null,function*(){h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(Q.isURL(h.redirectTo)?window.location.href=h.redirectTo:m(h.redirectTo))})}})}else g.message.success(e(h==null?void 0:h.successMessage))}catch(M){console.error(M)}finally{r.data.loading=!1}})}}}function lr(){const{workflow:e}=H();return!!(e!=null&&e.executed)}function yo(){const{workflow:e}=H();return!!(e!=null&&e.allExecuted)}const Se={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},ar=[{label:`{{t("After record added", { ns: "${p}" })}}`,value:Se.CREATED},{label:`{{t("After record updated", { ns: "${p}" })}}`,value:Se.UPDATED},{label:`{{t("After record added or updated", { ns: "${p}" })}}`,value:Se.SAVED},{label:`{{t("After record deleted", { ns: "${p}" })}}`,value:Se.DELETED}];function ir(e,t){var u;const[o,r]=l.parseCollectionName(e.collection),s=l.useCompile(),a=We(o),i=[{collectionName:r,name:"data",type:"hasOne",target:r,uiSchema:{title:O("Trigger data")}}];return Te(A(C({appends:["data",...((u=e.appends)==null?void 0:u.map(d=>`data.${d}`))||[]]},t),{fields:i,compile:s,getCollectionFields:a}))}class cr extends Mt{constructor(){super(...arguments);w(this,"title",`{{t("Collection event", { ns: "${p}" })}}`);w(this,"description",`{{t('Triggered when data changes in the collection, such as after adding, updating, or deleting a record. Unlike "Post-action event", Collection event listens for data changes rather than HTTP requests. Unless you understand the exact meaning, it is recommended to use "Post-action event".', { ns: "${p}" })}}`);w(this,"fieldset",{collection:A(C({},de),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(o){return o.options.key==="main"||o.options.isDBInstance}},"x-reactions":[...de["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${p}" })}}`,className:"auto-width"},enum:ar,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] & ${Se.UPDATED})}}`}}}]},condition:A(C({},ot),{title:`{{t("Only triggers when match conditions", { ns: "${p}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && !($deps[1] & ${Se.DELETED})}}`}}}]}),appends:A(C({},Le),{"x-reactions":[...Le["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Se.DELETED})}}`}}}]})});w(this,"scope",{useCollectionDataSource:l.useCollectionDataSource,useWorkflowAnyExecuted:yo});w(this,"components",{FieldsSelect:Ct});w(this,"useVariables",ir)}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 Ae={STATIC:0,DATE_FIELD:1};function dr(e){return!e.hidden&&(e.uiSchema?["date","datetimeTz","datetimeNoTz"].includes(e.type):!1)}function go({value:e,onChange:t}){const o=e!=null?e:{},{t:r}=X.useTranslation(),[s,a]=y.useState(o.offset?o.offset/Math.abs(o.offset):0);return n.jsxs("fieldset",{className:l.css`
|
|
518
518
|
display: flex;
|
|
519
519
|
gap: 0.5em;
|
|
520
520
|
`,children:[n.jsx(Ct,{value:o.field,onChange:i=>t(A(C({},o),{field:i})),filter:dr,placeholder:r("Select field"),className:"auto-width"}),o.field?n.jsx(g.Select,{value:s,onChange:i=>{a(i),t(A(C({},o),{offset:Math.abs(o.offset)*i}))},options:[{value:0,label:O("Exactly at")},{value:-1,label:r("Before")},{value:1,label:r("After")}],className:"auto-width"}):null,s?n.jsxs(n.Fragment,{children:[n.jsx(g.InputNumber,{value:Math.abs(o.offset),onChange:i=>t(A(C({},o),{offset:(i!=null?i:0)*s}))}),n.jsx(g.Select,{value:o.unit||864e5,onChange:i=>t(A(C({},o),{unit:i})),options:[{value:864e5,label:O("Days")},{value:36e5,label:O("Hours")},{value:6e4,label:O("Minutes")},{value:1e3,label:O("Seconds")}],className:"auto-width"})]}):null]})}function ur({value:e,onChange:t}){const{t:o}=xt(),r=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return n.jsxs("fieldset",{className:l.css`
|
|
521
521
|
display: flex;
|
|
522
522
|
gap: 0.5em;
|
|
523
|
-
`,children:[n.jsxs(g.Select,{value:r,onChange:s=>{t(s?s==="field"?{}:new Date:null)},className:"auto-width",children:[n.jsx(g.Select.Option,{value:null,children:o("No end")}),n.jsx(g.Select.Option,{value:"field",children:o("By field")}),n.jsx(g.Select.Option,{value:"date",children:o("By custom date")})]}),r==="field"?n.jsx(go,{value:e,onChange:t}):null,r==="date"?n.jsx(g.DatePicker,{showTime:!0,value:en(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var re=function(){return re=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var s in t=arguments[o])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},re.apply(this,arguments)};function bo(e,t){var o={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(o[r[s]]=e[r[s]])}return o}function nt(e,t,o){if(o||arguments.length===2)for(var r,s=0,a=t.length;s<a;s++)!r&&s in t||(r||(r=Array.prototype.slice.call(t,0,s)),r[s]=t[s]);return e.concat(r||Array.prototype.slice.call(t))}var pr=[{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 * * * *"}],Fe=[{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"]}],j={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 xo(e,t){for(var o=[],r=e;r<=t;r++)o.push(r);return o}function rt(e){return e.sort(function(t,o){return t-o}),e}function vo(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function ue(e){return Object.entries(e).filter(function(t){var o=t[0],r=t[1];return o&&r}).map(function(t){return t[0]}).join(" ")}function wo(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||j.errorInvalidCron})}function st(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function Co(e,t,o,r,s,a,i,c,p,d,m,h,v,b){o&&o(void 0),t(!1);var f=!1;if(!e){if(r==="always"||a&&r==="for-default-value")return;f=!0}if(!f){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void b("reboot");var k=pr.find(function(S){return S.name===e});k&&(e=k.value)}try{var F=function(S){if(typeof S!="string")throw new Error("Invalid cron string");var E=S.replace(/\s+/g," ").trim().split(" ");if(E.length===5)return E.map(function(L,$){return function(I,D){if(I==="*"||I==="*/1")return[];var N=rt(vo(Fo(function(G,U,pe){if(pe){G=G.toUpperCase();for(var P=0;P<pe.length;P++)G=G.replace(pe[P],"".concat(P+U))}return G}(I,D.min,D.alt).split(",").map(function(G){var U,pe=G.split("/");if(pe.length>2)throw new Error('Invalid value "'.concat(I,' for "').concat(D.type,'"'));var P=pe[0],W=pe[1];U=P==="*"?xo(D.min,D.max):function(q,_,R){var ee=q.split("-");if(ee.length===1){var Je=st(ee[0]);if(isNaN(Je))throw new Error('Invalid value "'.concat(_,'" for ').concat(R.type));return[Je]}if(ee.length===2){var ye=st(ee[0]),$e=st(ee[1]);if(isNaN(ye)||isNaN($e))throw new Error('Invalid value "'.concat(_,'" for ').concat(R.type));if($e<ye)throw new Error('Max range is less than min range in "'.concat(q,'" for ').concat(R.type));return xo(ye,$e)}throw new Error('Invalid value "'.concat(q,'" for ').concat(R.type))}(P,I,D);var z=function(q,_){if(q!==void 0){var R=st(q);if(isNaN(R)||R<1)throw new Error('Invalid interval step value "'.concat(q,'" for ').concat(_.type));return R}}(W,D),ae=function(q,_){if(_){var R=q[0];q=q.filter(function(ee){return ee%_==R%_||ee===R})}return q}(U,z);return ae}).flat(),D))),B=To(N,D);if(B!==void 0)throw new Error('Value "'.concat(B,'" out of range for ').concat(D.type));return N.length===D.total?[]:N}(L,Fe[$])});throw new Error("Invalid cron string format")}(e),M=function(S){return S[3].length>0?"year":S[2].length>0?"month":S[4].length>0?"week":S[1].length>0?"day":S[0].length>0?"hour":"minute"}(F);b(M),p(F[0]),d(F[1]),m(F[2]),h(F[3]),v(F[4])}catch(S){f=!0}}f&&(s.current=e,t(!0),wo(o,i))}function ko(e,t,o,r,s,a,i){if(e==="reboot")return"@reboot";var c=function(p,d){return p.map(function(m,h){var v=Fe[h];return So(Ao(m,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"||!r?[]:r],i);return c.join(" ")}function So(e,t,o,r,s){var a="";if(function(c,p){return c.length===p.max-p.min+1}(e,t)||e.length===0)a="*";else{var i=function(c){if(c.length>2){var p=c[1]-c[0];if(p>1)return p}}(e);a=i&&function(c,p){for(var d=1;d<c.length;d++){var m=c[d-1];if(c[d]-m!==p)return!1}return!0}(e,i)?function(c,p,d){var m=No(c),h=Oo(c),v=c.length===(h-m)/d+1;return!!(m===p.min&&h+d>p.max&&v)}(e,t,i)?"*/".concat(i):"".concat(Oe(No(e),t,o,r,s),"-").concat(Oe(Oo(e),t,o,r,s),"/").concat(i):function(c){var p=[],d=null;return c.forEach(function(m,h,v){m!==v[h+1]-1?d!==null?(p.push([d,m]),d=null):p.push(m):d===null&&(d=m)}),p}(e).map(function(c){return Array.isArray(c)?"".concat(Oe(c[0],t,o,r,s),"-").concat(Oe(c[1],t,o,r,s)):Oe(c,t,o,r,s)}).join(",")}return a}function Oe(e,t,o,r,s){var a=e.toString(),i=t.type,c=t.alt,p=t.min,d=r&&(r===!0||r.includes(i)),m=s==="24-hour-clock"&&(i==="hours"||i==="minutes");if(o&&i==="week-days"||o&&i==="months"?a=c[e-p]:e<10&&(d||m)&&(a=a.padStart(2,"0")),i==="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 Ao(e,t){var o=rt(vo(Fo(e,t)));if(o.length===0)return o;var r=To(o,t);if(r!==void 0)throw new Error('Value "'.concat(r,'" out of range for ').concat(t.type));return o}function Fo(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function To(e,t){var o=e[0],r=e[e.length-1];return o<t.min?o:r>t.max?r:void 0}function No(e){return e[0]}function Oo(e){return e[e.length-1]}function ze(e){var t=e.value,o=e.grid,r=o===void 0||o,s=e.optionsList,a=e.setValue,i=e.locale,c=e.className,p=e.humanizeLabels,d=e.disabled,m=e.readOnly,h=e.leadingZero,v=e.clockFormat,b=e.period,f=e.unit,k=e.periodicityOnDoubleClick,F=e.mode,M=bo(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),S=y.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(P){return P.toString()})},[t]),E=y.useMemo(function(){return s?s.map(function(P,W){return{value:(f.min===0?W:W+1).toString(),label:P}}):nt([],Array(f.total),!0).map(function(P,W){var z=f.min===0?W:W+1;return{value:z.toString(),label:Oe(z,f,p,h,v)}})},[s,h,p,v]),L=JSON.stringify(i),$=y.useCallback(function(P){var W=P.value;if(!t||t[0]!==Number(W))return n.jsx(n.Fragment,{});var z=So(Ao(t,f),f,p,h,v),ae=z.match(/^\*\/([0-9]+),?/)||[];return n.jsx("div",{children:ae[1]?"".concat(i.everyText||j.everyText," ").concat(ae[1]):z})},[t,L,p,h,v]),I=y.useCallback(function(P){var W=Array.isArray(P)?rt(P):[P],z=W;t&&(z=F==="single"?[]:nt([],t,!0),W.forEach(function(ae){var q=Number(ae);z=t.some(function(_){return _===q})?z.filter(function(_){return _!==q}):rt(nt(nt([],z,!0),[q],!1))})),z.length===f.total?a([]):a(z)},[a,t]),D=y.useCallback(function(P){if(P!==0&&P!==1){for(var W=f.total+f.min,z=[],ae=f.min;ae<W;ae++)ae%P==0&&z.push(ae);var q=t&&z&&t.length===z.length&&t.every(function(R,ee){return R===z[ee]}),_=z.length===E.length;a(_||q?[]:z)}else a([])},[t,E,a]),N=y.useRef([]),B=y.useCallback(function(P){if(!m){var W=N.current;W.push({time:new Date().getTime(),value:Number(P)});var z=window.setTimeout(function(){k&&W.length>1&&W[W.length-1].time-W[W.length-2].time<300?W[W.length-1].value===W[W.length-2].value?D(Number(P)):I([W[W.length-2].value,W[W.length-1].value]):I(Number(P)),N.current=[]},300);return function(){window.clearTimeout(z)}}},[N,I,D,m,k]),G=y.useCallback(function(){m||a([])},[a,m]),U=y.useMemo(function(){var P;return ue(((P={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,P))},[c]),pe=y.useMemo(function(){var P;return ue(((P={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(f.type)]=!0,P["react-js-cron-custom-select-dropdown"]=!0,P["react-js-cron-custom-select-dropdown-".concat(f.type)]=!0,P["react-js-cron-custom-select-dropdown-minutes-large"]=f.type==="minutes"&&b!=="hour"&&b!=="day",P["react-js-cron-custom-select-dropdown-minutes-medium"]=f.type==="minutes"&&(b==="day"||b==="hour"),P["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=f.type==="hours"&&v==="12-hour-clock",P["react-js-cron-custom-select-dropdown-grid"]=!!r,P["".concat(c,"-select-dropdown")]=!!c,P["".concat(c,"-select-dropdown-").concat(f.type)]=!!c,P))},[c,r,v,b]);return n.jsx(g.Select,re({mode:F!=="single"||k?"multiple":void 0,allowClear:!m,virtual:!1,open:!m&&void 0,value:S,onClear:G,tagRender:$,className:U,popupClassName:pe,options:E,showSearch:!1,showArrow:!m,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:B,onDeselect:B,disabled:d,dropdownAlign:f.type!=="minutes"&&f.type!=="hours"||b==="day"||b==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(f.type)},M))}function mr(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.disabled,i=e.readOnly,c=e.leadingZero,p=e.clockFormat,d=e.period,m=e.periodicityOnDoubleClick,h=e.mode,v=y.useMemo(function(){var b;return ue(((b={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,b["".concat(s,"-hours")]=!!s,b))},[s]);return n.jsxs("div",re({className:v},{children:[r.prefixHours!==""&&n.jsx("span",{children:r.prefixHours||j.prefixHours}),n.jsx(ze,{placeholder:r.emptyHours||j.emptyHours,value:t,unit:Fe[1],setValue:o,locale:r,className:s,disabled:a,readOnly:i,leadingZero:c,clockFormat:p,period:d,periodicityOnDoubleClick:m,mode:h})]}))}function fr(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.disabled,i=e.readOnly,c=e.leadingZero,p=e.clockFormat,d=e.period,m=e.periodicityOnDoubleClick,h=e.mode,v=y.useMemo(function(){var b;return ue(((b={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,b["".concat(s,"-minutes")]=!!s,b))},[s]);return n.jsxs("div",re({className:v},{children:[d==="hour"?r.prefixMinutesForHourPeriod!==""&&n.jsx("span",{children:r.prefixMinutesForHourPeriod||j.prefixMinutesForHourPeriod}):r.prefixMinutes!==""&&n.jsx("span",{children:r.prefixMinutes||j.prefixMinutes}),n.jsx(ze,{placeholder:d==="hour"?r.emptyMinutesForHourPeriod||j.emptyMinutesForHourPeriod:r.emptyMinutes||j.emptyMinutes,value:t,unit:Fe[0],setValue:o,locale:r,className:s,disabled:a,readOnly:i,leadingZero:c,clockFormat:p,period:d,periodicityOnDoubleClick:m,mode:h}),d==="hour"&&r.suffixMinutesForHourPeriod!==""&&n.jsx("span",{children:r.suffixMinutesForHourPeriod||j.suffixMinutesForHourPeriod})]}))}function hr(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.weekDays,i=e.disabled,c=e.readOnly,p=e.leadingZero,d=e.period,m=e.periodicityOnDoubleClick,h=e.mode,v=!a||a.length===0,b=y.useMemo(function(){var F;return ue(((F={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!v})["".concat(s,"-field")]=!!s,F["".concat(s,"-month-days")]=!!s,F))},[s,v]),f=JSON.stringify(r),k=y.useMemo(function(){return v?r.emptyMonthDays||j.emptyMonthDays:r.emptyMonthDaysShort||j.emptyMonthDaysShort},[v,f]);return!c||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?n.jsxs("div",re({className:b},{children:[r.prefixMonthDays!==""&&n.jsx("span",{children:r.prefixMonthDays||j.prefixMonthDays}),n.jsx(ze,{placeholder:k,value:t,setValue:o,unit:Fe[2],locale:r,className:s,disabled:i,readOnly:c,leadingZero:p,period:d,periodicityOnDoubleClick:m,mode:h})]})):null}function yr(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.humanizeLabels,i=e.disabled,c=e.readOnly,p=e.period,d=e.periodicityOnDoubleClick,m=e.mode,h=r.months||j.months,v=y.useMemo(function(){var b;return ue(((b={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,b["".concat(s,"-months")]=!!s,b))},[s]);return n.jsxs("div",re({className:v},{children:[r.prefixMonths!==""&&n.jsx("span",{children:r.prefixMonths||j.prefixMonths}),n.jsx(ze,{placeholder:r.emptyMonths||j.emptyMonths,optionsList:h,grid:!1,value:t,unit:re(re({},Fe[3]),{alt:r.altMonths||j.altMonths}),setValue:o,locale:r,className:s,humanizeLabels:a,disabled:i,readOnly:c,period:p,periodicityOnDoubleClick:d,mode:m})]}))}function gr(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.disabled,i=e.readOnly,c=e.shortcuts,p=e.allowedPeriods,d=[];p.includes("year")&&d.push({value:"year",label:r.yearOption||j.yearOption}),p.includes("month")&&d.push({value:"month",label:r.monthOption||j.monthOption}),p.includes("week")&&d.push({value:"week",label:r.weekOption||j.weekOption}),p.includes("day")&&d.push({value:"day",label:r.dayOption||j.dayOption}),p.includes("hour")&&d.push({value:"hour",label:r.hourOption||j.hourOption}),p.includes("minute")&&d.push({value:"minute",label:r.minuteOption||j.minuteOption}),p.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&d.push({value:"reboot",label:r.rebootOption||j.rebootOption});var m=y.useCallback(function(f){i||o(f)},[o,i]),h=y.useMemo(function(){var f;return ue(((f={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,f["".concat(s,"-period")]=!!s,f))},[s]),v=y.useMemo(function(){var f;return ue(((f={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":r.prefixPeriod===""})["".concat(s,"-select")]=!!s,f))},[s,r.prefixPeriod]),b=y.useMemo(function(){var f;return ue(((f={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,f["".concat(s,"-select-dropdown-period")]=!!s,f))},[s]);return n.jsxs("div",re({className:h},{children:[r.prefixPeriod!==""&&n.jsx("span",{children:r.prefixPeriod||j.prefixPeriod}),n.jsx(g.Select,{defaultValue:t,value:t,onChange:m,options:d,className:v,popupClassName:b,disabled:a,showArrow:!i,open:!i&&void 0,"data-testid":"select-period"},JSON.stringify(r))]}))}function br(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.humanizeLabels,i=e.monthDays,c=e.disabled,p=e.readOnly,d=e.period,m=e.periodicityOnDoubleClick,h=e.mode,v=r.weekDays||j.weekDays,b=d==="week"||!i||i.length===0,f=y.useMemo(function(){var E;return ue(((E={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!b})["".concat(s,"-field")]=!!s,E["".concat(s,"-week-days")]=!!s,E))},[s,b]),k=JSON.stringify(r),F=y.useMemo(function(){return b?r.emptyWeekDays||j.emptyWeekDays:r.emptyWeekDaysShort||j.emptyWeekDaysShort},[b,k]),M=d==="week"||!p||t&&t.length>0||(!t||t.length===0)&&(!i||i.length===0),S=!p||i&&i.length>0||(!i||i.length===0)&&(!t||t.length===0);return M?n.jsxs("div",re({className:f},{children:[r.prefixWeekDays!==""&&(d==="week"||!S)&&n.jsx("span",{children:r.prefixWeekDays||j.prefixWeekDays}),r.prefixWeekDaysForMonthAndYearPeriod!==""&&d!=="week"&&S&&n.jsx("span",{children:r.prefixWeekDaysForMonthAndYearPeriod||j.prefixWeekDaysForMonthAndYearPeriod}),n.jsx(ze,{placeholder:F,optionsList:v,grid:!1,value:t,unit:re(re({},Fe[4]),{alt:r.altWeekDays||j.altWeekDays}),setValue:o,locale:r,className:s,humanizeLabels:a,disabled:c,readOnly:p,period:d,periodicityOnDoubleClick:m,mode:h})]})):null}function xr(e){var t=e.clearButton,o=t===void 0||t,r=e.clearButtonProps,s=r===void 0?{}:r,a=e.clearButtonAction,i=a===void 0?"fill-with-every":a,c=e.locale,p=c===void 0?j:c,d=e.value,m=d===void 0?"":d,h=e.setValue,v=e.displayError,b=v===void 0||v,f=e.onError,k=e.className,F=e.defaultPeriod,M=F===void 0?"day":F,S=e.allowEmpty,E=S===void 0?"for-default-value":S,L=e.humanizeLabels,$=L===void 0||L,I=e.humanizeValue,D=I!==void 0&&I,N=e.disabled,B=N!==void 0&&N,G=e.readOnly,U=G!==void 0&&G,pe=e.leadingZero,P=pe!==void 0&&pe,W=e.shortcuts,z=W===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:W,ae=e.clockFormat,q=e.periodicityOnDoubleClick,_=q===void 0||q,R=e.mode,ee=R===void 0?"multiple":R,Je=e.allowedDropdowns,ye=Je===void 0?["period","months","month-days","week-days","hours","minutes"]:Je,$e=e.allowedPeriods,Lr=$e===void 0?["year","month","week","day","hour","minute","reboot"]:$e,Ee=y.useRef(m),Vt=y.useRef(M),Vo=y.useState(),ve=Vo[0],lt=Vo[1],jo=y.useState(),Ue=jo[0],at=jo[1],Wo=y.useState(),it=Wo[0],ct=Wo[1],Lo=y.useState(),He=Lo[0],dt=Lo[1],zo=y.useState(),ut=zo[0],pt=zo[1],Jo=y.useState(),mt=Jo[0],ft=Jo[1],Uo=y.useState(!1),jt=Uo[0],Ge=Uo[1],Ho=y.useState(!1),ht=Ho[0],Go=Ho[1],zr=function(K){var ge=y.useRef(K);return y.useEffect(function(){ge.current=K},[K]),ge.current}(ht),qo=JSON.stringify(p);y.useEffect(function(){Co(m,Ge,f,E,Ee,!0,p,z,ft,pt,at,ct,dt,lt)},[]),y.useEffect(function(){m!==Ee.current&&Co(m,Ge,f,E,Ee,!1,p,z,ft,pt,at,ct,dt,lt)},[m,Ee,qo,E,z]),y.useEffect(function(){if(!(ve||mt||it||Ue||He||ut)||ht||zr)ht&&Go(!1);else{var K=ve||Vt.current,ge=ko(K,it,Ue,He,ut,mt,D);h(ge,{selectedPeriod:K}),Ee.current=ge,f&&f(void 0),Ge(!1)}},[ve,Ue,it,He,ut,mt,D,ht]);var Yo=y.useCallback(function(){at(void 0),ct(void 0),dt(void 0),pt(void 0),ft(void 0);var K="",ge=ve!=="reboot"&&ve?ve:Vt.current;ge!==ve&<(ge),i==="fill-with-every"&&(K=ko(ge,void 0,void 0,void 0,void 0,void 0)),h(K,{selectedPeriod:ge}),Ee.current=K,Go(!0),E==="never"&&i==="empty"?(Ge(!0),wo(f,p)):(f&&f(void 0),Ge(!1))},[ve,h,f,i]),Jr=y.useMemo(function(){var K;return ue(((K={"react-js-cron":!0,"react-js-cron-error":jt&&b,"react-js-cron-disabled":B,"react-js-cron-read-only":U})["".concat(k)]=!!k,K["".concat(k,"-error")]=jt&&b&&!!k,K["".concat(k,"-disabled")]=B&&!!k,K["".concat(k,"-read-only")]=U&&!!k,K))},[k,jt,b,B,U]),Wt=s.className,_o=bo(s,["className"]),Ko=y.useMemo(function(){var K;return ue(((K={"react-js-cron-clear-button":!0})["".concat(k,"-clear-button")]=!!k,K["".concat(Wt)]=!!Wt,K))},[k,Wt]),Ur=JSON.stringify(_o),Zo=y.useMemo(function(){return o&&!U?n.jsx(g.Button,re({className:Ko,danger:!0,type:"primary",disabled:B},_o,{onClick:Yo},{children:p.clearButtonText||j.clearButtonText})):null},[o,U,qo,Ko,B,Ur,Yo]),te=ve||Vt.current;return n.jsxs("div",re({className:Jr},{children:[ye.includes("period")&&n.jsx(gr,{value:te,setValue:lt,locale:p,className:k,disabled:B,readOnly:U,shortcuts:z,allowedPeriods:Lr}),te==="reboot"?Zo:n.jsxs(n.Fragment,{children:[te==="year"&&ye.includes("months")&&n.jsx(yr,{value:it,setValue:ct,locale:p,className:k,humanizeLabels:$,disabled:B,readOnly:U,period:te,periodicityOnDoubleClick:_,mode:ee}),(te==="year"||te==="month")&&ye.includes("month-days")&&n.jsx(hr,{value:Ue,setValue:at,locale:p,className:k,weekDays:He,disabled:B,readOnly:U,leadingZero:P,period:te,periodicityOnDoubleClick:_,mode:ee}),(te==="year"||te==="month"||te==="week")&&ye.includes("week-days")&&n.jsx(br,{value:He,setValue:dt,locale:p,className:k,humanizeLabels:$,monthDays:Ue,disabled:B,readOnly:U,period:te,periodicityOnDoubleClick:_,mode:ee}),n.jsxs("div",{children:[te!=="minute"&&te!=="hour"&&ye.includes("hours")&&n.jsx(mr,{value:ut,setValue:pt,locale:p,className:k,disabled:B,readOnly:U,leadingZero:P,clockFormat:ae,period:te,periodicityOnDoubleClick:_,mode:ee}),te!=="minute"&&ye.includes("minutes")&&n.jsx(fr,{value:mt,setValue:ft,locale:p,period:te,className:k,disabled:B,readOnly:U,leadingZero:P,clockFormat:ae,periodicityOnDoubleClick:_,mode:ee}),Zo]})]})]}))}const $o=[{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 Eo(e){return $o.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function vr(e){let t;switch(typeof e){case"number":return t=Eo(e),t?t.value:"none";case"string":return"cron"}return"none"}function wr({value:e,onChange:t}){const{t:o}=xt(),r=Eo(e);return n.jsx(g.InputNumber,{value:e/r.value,onChange:s=>t(s*r.value),min:1,addonBefore:o("Every"),addonAfter:o(r.unitText),className:"auto-width"})}function Cr({value:e=null,onChange:t}){const{t:o}=xt(),r=vr(e),s=y.useCallback(a=>{if(a==="none"){t(null);return}if(a==="cron"){t("0 * * * * *");return}t(a)},[t]);return n.jsxs("fieldset",{className:l.css`
|
|
523
|
+
`,children:[n.jsxs(g.Select,{value:r,onChange:s=>{t(s?s==="field"?{}:new Date:null)},className:"auto-width",children:[n.jsx(g.Select.Option,{value:null,children:o("No end")}),n.jsx(g.Select.Option,{value:"field",children:o("By field")}),n.jsx(g.Select.Option,{value:"date",children:o("By custom date")})]}),r==="field"?n.jsx(go,{value:e,onChange:t}):null,r==="date"?n.jsx(g.DatePicker,{showTime:!0,value:en(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var re=function(){return re=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var s in t=arguments[o])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},re.apply(this,arguments)};function bo(e,t){var o={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(o[r[s]]=e[r[s]])}return o}function nt(e,t,o){if(o||arguments.length===2)for(var r,s=0,a=t.length;s<a;s++)!r&&s in t||(r||(r=Array.prototype.slice.call(t,0,s)),r[s]=t[s]);return e.concat(r||Array.prototype.slice.call(t))}var pr=[{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 * * * *"}],Fe=[{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"]}],j={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 xo(e,t){for(var o=[],r=e;r<=t;r++)o.push(r);return o}function rt(e){return e.sort(function(t,o){return t-o}),e}function vo(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function ue(e){return Object.entries(e).filter(function(t){var o=t[0],r=t[1];return o&&r}).map(function(t){return t[0]}).join(" ")}function wo(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||j.errorInvalidCron})}function st(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function Co(e,t,o,r,s,a,i,c,u,d,m,h,v,b){o&&o(void 0),t(!1);var f=!1;if(!e){if(r==="always"||a&&r==="for-default-value")return;f=!0}if(!f){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void b("reboot");var k=pr.find(function(S){return S.name===e});k&&(e=k.value)}try{var F=function(S){if(typeof S!="string")throw new Error("Invalid cron string");var D=S.replace(/\s+/g," ").trim().split(" ");if(D.length===5)return D.map(function(L,E){return function(I,$){if(I==="*"||I==="*/1")return[];var N=rt(vo(Fo(function(G,U,pe){if(pe){G=G.toUpperCase();for(var P=0;P<pe.length;P++)G=G.replace(pe[P],"".concat(P+U))}return G}(I,$.min,$.alt).split(",").map(function(G){var U,pe=G.split("/");if(pe.length>2)throw new Error('Invalid value "'.concat(I,' for "').concat($.type,'"'));var P=pe[0],W=pe[1];U=P==="*"?xo($.min,$.max):function(q,_,R){var ee=q.split("-");if(ee.length===1){var Je=st(ee[0]);if(isNaN(Je))throw new Error('Invalid value "'.concat(_,'" for ').concat(R.type));return[Je]}if(ee.length===2){var ye=st(ee[0]),Ee=st(ee[1]);if(isNaN(ye)||isNaN(Ee))throw new Error('Invalid value "'.concat(_,'" for ').concat(R.type));if(Ee<ye)throw new Error('Max range is less than min range in "'.concat(q,'" for ').concat(R.type));return xo(ye,Ee)}throw new Error('Invalid value "'.concat(q,'" for ').concat(R.type))}(P,I,$);var z=function(q,_){if(q!==void 0){var R=st(q);if(isNaN(R)||R<1)throw new Error('Invalid interval step value "'.concat(q,'" for ').concat(_.type));return R}}(W,$),ae=function(q,_){if(_){var R=q[0];q=q.filter(function(ee){return ee%_==R%_||ee===R})}return q}(U,z);return ae}).flat(),$))),B=To(N,$);if(B!==void 0)throw new Error('Value "'.concat(B,'" out of range for ').concat($.type));return N.length===$.total?[]:N}(L,Fe[E])});throw new Error("Invalid cron string format")}(e),M=function(S){return S[3].length>0?"year":S[2].length>0?"month":S[4].length>0?"week":S[1].length>0?"day":S[0].length>0?"hour":"minute"}(F);b(M),u(F[0]),d(F[1]),m(F[2]),h(F[3]),v(F[4])}catch(S){f=!0}}f&&(s.current=e,t(!0),wo(o,i))}function ko(e,t,o,r,s,a,i){if(e==="reboot")return"@reboot";var c=function(u,d){return u.map(function(m,h){var v=Fe[h];return So(Ao(m,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"||!r?[]:r],i);return c.join(" ")}function So(e,t,o,r,s){var a="";if(function(c,u){return c.length===u.max-u.min+1}(e,t)||e.length===0)a="*";else{var i=function(c){if(c.length>2){var u=c[1]-c[0];if(u>1)return u}}(e);a=i&&function(c,u){for(var d=1;d<c.length;d++){var m=c[d-1];if(c[d]-m!==u)return!1}return!0}(e,i)?function(c,u,d){var m=No(c),h=Oo(c),v=c.length===(h-m)/d+1;return!!(m===u.min&&h+d>u.max&&v)}(e,t,i)?"*/".concat(i):"".concat(Oe(No(e),t,o,r,s),"-").concat(Oe(Oo(e),t,o,r,s),"/").concat(i):function(c){var u=[],d=null;return c.forEach(function(m,h,v){m!==v[h+1]-1?d!==null?(u.push([d,m]),d=null):u.push(m):d===null&&(d=m)}),u}(e).map(function(c){return Array.isArray(c)?"".concat(Oe(c[0],t,o,r,s),"-").concat(Oe(c[1],t,o,r,s)):Oe(c,t,o,r,s)}).join(",")}return a}function Oe(e,t,o,r,s){var a=e.toString(),i=t.type,c=t.alt,u=t.min,d=r&&(r===!0||r.includes(i)),m=s==="24-hour-clock"&&(i==="hours"||i==="minutes");if(o&&i==="week-days"||o&&i==="months"?a=c[e-u]:e<10&&(d||m)&&(a=a.padStart(2,"0")),i==="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 Ao(e,t){var o=rt(vo(Fo(e,t)));if(o.length===0)return o;var r=To(o,t);if(r!==void 0)throw new Error('Value "'.concat(r,'" out of range for ').concat(t.type));return o}function Fo(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function To(e,t){var o=e[0],r=e[e.length-1];return o<t.min?o:r>t.max?r:void 0}function No(e){return e[0]}function Oo(e){return e[e.length-1]}function ze(e){var t=e.value,o=e.grid,r=o===void 0||o,s=e.optionsList,a=e.setValue,i=e.locale,c=e.className,u=e.humanizeLabels,d=e.disabled,m=e.readOnly,h=e.leadingZero,v=e.clockFormat,b=e.period,f=e.unit,k=e.periodicityOnDoubleClick,F=e.mode,M=bo(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),S=y.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(P){return P.toString()})},[t]),D=y.useMemo(function(){return s?s.map(function(P,W){return{value:(f.min===0?W:W+1).toString(),label:P}}):nt([],Array(f.total),!0).map(function(P,W){var z=f.min===0?W:W+1;return{value:z.toString(),label:Oe(z,f,u,h,v)}})},[s,h,u,v]),L=JSON.stringify(i),E=y.useCallback(function(P){var W=P.value;if(!t||t[0]!==Number(W))return n.jsx(n.Fragment,{});var z=So(Ao(t,f),f,u,h,v),ae=z.match(/^\*\/([0-9]+),?/)||[];return n.jsx("div",{children:ae[1]?"".concat(i.everyText||j.everyText," ").concat(ae[1]):z})},[t,L,u,h,v]),I=y.useCallback(function(P){var W=Array.isArray(P)?rt(P):[P],z=W;t&&(z=F==="single"?[]:nt([],t,!0),W.forEach(function(ae){var q=Number(ae);z=t.some(function(_){return _===q})?z.filter(function(_){return _!==q}):rt(nt(nt([],z,!0),[q],!1))})),z.length===f.total?a([]):a(z)},[a,t]),$=y.useCallback(function(P){if(P!==0&&P!==1){for(var W=f.total+f.min,z=[],ae=f.min;ae<W;ae++)ae%P==0&&z.push(ae);var q=t&&z&&t.length===z.length&&t.every(function(R,ee){return R===z[ee]}),_=z.length===D.length;a(_||q?[]:z)}else a([])},[t,D,a]),N=y.useRef([]),B=y.useCallback(function(P){if(!m){var W=N.current;W.push({time:new Date().getTime(),value:Number(P)});var z=window.setTimeout(function(){k&&W.length>1&&W[W.length-1].time-W[W.length-2].time<300?W[W.length-1].value===W[W.length-2].value?$(Number(P)):I([W[W.length-2].value,W[W.length-1].value]):I(Number(P)),N.current=[]},300);return function(){window.clearTimeout(z)}}},[N,I,$,m,k]),G=y.useCallback(function(){m||a([])},[a,m]),U=y.useMemo(function(){var P;return ue(((P={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,P))},[c]),pe=y.useMemo(function(){var P;return ue(((P={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(f.type)]=!0,P["react-js-cron-custom-select-dropdown"]=!0,P["react-js-cron-custom-select-dropdown-".concat(f.type)]=!0,P["react-js-cron-custom-select-dropdown-minutes-large"]=f.type==="minutes"&&b!=="hour"&&b!=="day",P["react-js-cron-custom-select-dropdown-minutes-medium"]=f.type==="minutes"&&(b==="day"||b==="hour"),P["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=f.type==="hours"&&v==="12-hour-clock",P["react-js-cron-custom-select-dropdown-grid"]=!!r,P["".concat(c,"-select-dropdown")]=!!c,P["".concat(c,"-select-dropdown-").concat(f.type)]=!!c,P))},[c,r,v,b]);return n.jsx(g.Select,re({mode:F!=="single"||k?"multiple":void 0,allowClear:!m,virtual:!1,open:!m&&void 0,value:S,onClear:G,tagRender:E,className:U,popupClassName:pe,options:D,showSearch:!1,showArrow:!m,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:B,onDeselect:B,disabled:d,dropdownAlign:f.type!=="minutes"&&f.type!=="hours"||b==="day"||b==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(f.type)},M))}function mr(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.disabled,i=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,m=e.periodicityOnDoubleClick,h=e.mode,v=y.useMemo(function(){var b;return ue(((b={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,b["".concat(s,"-hours")]=!!s,b))},[s]);return n.jsxs("div",re({className:v},{children:[r.prefixHours!==""&&n.jsx("span",{children:r.prefixHours||j.prefixHours}),n.jsx(ze,{placeholder:r.emptyHours||j.emptyHours,value:t,unit:Fe[1],setValue:o,locale:r,className:s,disabled:a,readOnly:i,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:m,mode:h})]}))}function fr(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.disabled,i=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,m=e.periodicityOnDoubleClick,h=e.mode,v=y.useMemo(function(){var b;return ue(((b={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,b["".concat(s,"-minutes")]=!!s,b))},[s]);return n.jsxs("div",re({className:v},{children:[d==="hour"?r.prefixMinutesForHourPeriod!==""&&n.jsx("span",{children:r.prefixMinutesForHourPeriod||j.prefixMinutesForHourPeriod}):r.prefixMinutes!==""&&n.jsx("span",{children:r.prefixMinutes||j.prefixMinutes}),n.jsx(ze,{placeholder:d==="hour"?r.emptyMinutesForHourPeriod||j.emptyMinutesForHourPeriod:r.emptyMinutes||j.emptyMinutes,value:t,unit:Fe[0],setValue:o,locale:r,className:s,disabled:a,readOnly:i,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:m,mode:h}),d==="hour"&&r.suffixMinutesForHourPeriod!==""&&n.jsx("span",{children:r.suffixMinutesForHourPeriod||j.suffixMinutesForHourPeriod})]}))}function hr(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.weekDays,i=e.disabled,c=e.readOnly,u=e.leadingZero,d=e.period,m=e.periodicityOnDoubleClick,h=e.mode,v=!a||a.length===0,b=y.useMemo(function(){var F;return ue(((F={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!v})["".concat(s,"-field")]=!!s,F["".concat(s,"-month-days")]=!!s,F))},[s,v]),f=JSON.stringify(r),k=y.useMemo(function(){return v?r.emptyMonthDays||j.emptyMonthDays:r.emptyMonthDaysShort||j.emptyMonthDaysShort},[v,f]);return!c||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?n.jsxs("div",re({className:b},{children:[r.prefixMonthDays!==""&&n.jsx("span",{children:r.prefixMonthDays||j.prefixMonthDays}),n.jsx(ze,{placeholder:k,value:t,setValue:o,unit:Fe[2],locale:r,className:s,disabled:i,readOnly:c,leadingZero:u,period:d,periodicityOnDoubleClick:m,mode:h})]})):null}function yr(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.humanizeLabels,i=e.disabled,c=e.readOnly,u=e.period,d=e.periodicityOnDoubleClick,m=e.mode,h=r.months||j.months,v=y.useMemo(function(){var b;return ue(((b={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,b["".concat(s,"-months")]=!!s,b))},[s]);return n.jsxs("div",re({className:v},{children:[r.prefixMonths!==""&&n.jsx("span",{children:r.prefixMonths||j.prefixMonths}),n.jsx(ze,{placeholder:r.emptyMonths||j.emptyMonths,optionsList:h,grid:!1,value:t,unit:re(re({},Fe[3]),{alt:r.altMonths||j.altMonths}),setValue:o,locale:r,className:s,humanizeLabels:a,disabled:i,readOnly:c,period:u,periodicityOnDoubleClick:d,mode:m})]}))}function gr(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.disabled,i=e.readOnly,c=e.shortcuts,u=e.allowedPeriods,d=[];u.includes("year")&&d.push({value:"year",label:r.yearOption||j.yearOption}),u.includes("month")&&d.push({value:"month",label:r.monthOption||j.monthOption}),u.includes("week")&&d.push({value:"week",label:r.weekOption||j.weekOption}),u.includes("day")&&d.push({value:"day",label:r.dayOption||j.dayOption}),u.includes("hour")&&d.push({value:"hour",label:r.hourOption||j.hourOption}),u.includes("minute")&&d.push({value:"minute",label:r.minuteOption||j.minuteOption}),u.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&d.push({value:"reboot",label:r.rebootOption||j.rebootOption});var m=y.useCallback(function(f){i||o(f)},[o,i]),h=y.useMemo(function(){var f;return ue(((f={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,f["".concat(s,"-period")]=!!s,f))},[s]),v=y.useMemo(function(){var f;return ue(((f={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":r.prefixPeriod===""})["".concat(s,"-select")]=!!s,f))},[s,r.prefixPeriod]),b=y.useMemo(function(){var f;return ue(((f={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,f["".concat(s,"-select-dropdown-period")]=!!s,f))},[s]);return n.jsxs("div",re({className:h},{children:[r.prefixPeriod!==""&&n.jsx("span",{children:r.prefixPeriod||j.prefixPeriod}),n.jsx(g.Select,{defaultValue:t,value:t,onChange:m,options:d,className:v,popupClassName:b,disabled:a,showArrow:!i,open:!i&&void 0,"data-testid":"select-period"},JSON.stringify(r))]}))}function br(e){var t=e.value,o=e.setValue,r=e.locale,s=e.className,a=e.humanizeLabels,i=e.monthDays,c=e.disabled,u=e.readOnly,d=e.period,m=e.periodicityOnDoubleClick,h=e.mode,v=r.weekDays||j.weekDays,b=d==="week"||!i||i.length===0,f=y.useMemo(function(){var D;return ue(((D={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!b})["".concat(s,"-field")]=!!s,D["".concat(s,"-week-days")]=!!s,D))},[s,b]),k=JSON.stringify(r),F=y.useMemo(function(){return b?r.emptyWeekDays||j.emptyWeekDays:r.emptyWeekDaysShort||j.emptyWeekDaysShort},[b,k]),M=d==="week"||!u||t&&t.length>0||(!t||t.length===0)&&(!i||i.length===0),S=!u||i&&i.length>0||(!i||i.length===0)&&(!t||t.length===0);return M?n.jsxs("div",re({className:f},{children:[r.prefixWeekDays!==""&&(d==="week"||!S)&&n.jsx("span",{children:r.prefixWeekDays||j.prefixWeekDays}),r.prefixWeekDaysForMonthAndYearPeriod!==""&&d!=="week"&&S&&n.jsx("span",{children:r.prefixWeekDaysForMonthAndYearPeriod||j.prefixWeekDaysForMonthAndYearPeriod}),n.jsx(ze,{placeholder:F,optionsList:v,grid:!1,value:t,unit:re(re({},Fe[4]),{alt:r.altWeekDays||j.altWeekDays}),setValue:o,locale:r,className:s,humanizeLabels:a,disabled:c,readOnly:u,period:d,periodicityOnDoubleClick:m,mode:h})]})):null}function xr(e){var t=e.clearButton,o=t===void 0||t,r=e.clearButtonProps,s=r===void 0?{}:r,a=e.clearButtonAction,i=a===void 0?"fill-with-every":a,c=e.locale,u=c===void 0?j:c,d=e.value,m=d===void 0?"":d,h=e.setValue,v=e.displayError,b=v===void 0||v,f=e.onError,k=e.className,F=e.defaultPeriod,M=F===void 0?"day":F,S=e.allowEmpty,D=S===void 0?"for-default-value":S,L=e.humanizeLabels,E=L===void 0||L,I=e.humanizeValue,$=I!==void 0&&I,N=e.disabled,B=N!==void 0&&N,G=e.readOnly,U=G!==void 0&&G,pe=e.leadingZero,P=pe!==void 0&&pe,W=e.shortcuts,z=W===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:W,ae=e.clockFormat,q=e.periodicityOnDoubleClick,_=q===void 0||q,R=e.mode,ee=R===void 0?"multiple":R,Je=e.allowedDropdowns,ye=Je===void 0?["period","months","month-days","week-days","hours","minutes"]:Je,Ee=e.allowedPeriods,Lr=Ee===void 0?["year","month","week","day","hour","minute","reboot"]:Ee,De=y.useRef(m),Vt=y.useRef(M),Vo=y.useState(),ve=Vo[0],lt=Vo[1],jo=y.useState(),Ue=jo[0],at=jo[1],Wo=y.useState(),it=Wo[0],ct=Wo[1],Lo=y.useState(),He=Lo[0],dt=Lo[1],zo=y.useState(),ut=zo[0],pt=zo[1],Jo=y.useState(),mt=Jo[0],ft=Jo[1],Uo=y.useState(!1),jt=Uo[0],Ge=Uo[1],Ho=y.useState(!1),ht=Ho[0],Go=Ho[1],zr=function(K){var ge=y.useRef(K);return y.useEffect(function(){ge.current=K},[K]),ge.current}(ht),qo=JSON.stringify(u);y.useEffect(function(){Co(m,Ge,f,D,De,!0,u,z,ft,pt,at,ct,dt,lt)},[]),y.useEffect(function(){m!==De.current&&Co(m,Ge,f,D,De,!1,u,z,ft,pt,at,ct,dt,lt)},[m,De,qo,D,z]),y.useEffect(function(){if(!(ve||mt||it||Ue||He||ut)||ht||zr)ht&&Go(!1);else{var K=ve||Vt.current,ge=ko(K,it,Ue,He,ut,mt,$);h(ge,{selectedPeriod:K}),De.current=ge,f&&f(void 0),Ge(!1)}},[ve,Ue,it,He,ut,mt,$,ht]);var Yo=y.useCallback(function(){at(void 0),ct(void 0),dt(void 0),pt(void 0),ft(void 0);var K="",ge=ve!=="reboot"&&ve?ve:Vt.current;ge!==ve&<(ge),i==="fill-with-every"&&(K=ko(ge,void 0,void 0,void 0,void 0,void 0)),h(K,{selectedPeriod:ge}),De.current=K,Go(!0),D==="never"&&i==="empty"?(Ge(!0),wo(f,u)):(f&&f(void 0),Ge(!1))},[ve,h,f,i]),Jr=y.useMemo(function(){var K;return ue(((K={"react-js-cron":!0,"react-js-cron-error":jt&&b,"react-js-cron-disabled":B,"react-js-cron-read-only":U})["".concat(k)]=!!k,K["".concat(k,"-error")]=jt&&b&&!!k,K["".concat(k,"-disabled")]=B&&!!k,K["".concat(k,"-read-only")]=U&&!!k,K))},[k,jt,b,B,U]),Wt=s.className,_o=bo(s,["className"]),Ko=y.useMemo(function(){var K;return ue(((K={"react-js-cron-clear-button":!0})["".concat(k,"-clear-button")]=!!k,K["".concat(Wt)]=!!Wt,K))},[k,Wt]),Ur=JSON.stringify(_o),Zo=y.useMemo(function(){return o&&!U?n.jsx(g.Button,re({className:Ko,danger:!0,type:"primary",disabled:B},_o,{onClick:Yo},{children:u.clearButtonText||j.clearButtonText})):null},[o,U,qo,Ko,B,Ur,Yo]),te=ve||Vt.current;return n.jsxs("div",re({className:Jr},{children:[ye.includes("period")&&n.jsx(gr,{value:te,setValue:lt,locale:u,className:k,disabled:B,readOnly:U,shortcuts:z,allowedPeriods:Lr}),te==="reboot"?Zo:n.jsxs(n.Fragment,{children:[te==="year"&&ye.includes("months")&&n.jsx(yr,{value:it,setValue:ct,locale:u,className:k,humanizeLabels:E,disabled:B,readOnly:U,period:te,periodicityOnDoubleClick:_,mode:ee}),(te==="year"||te==="month")&&ye.includes("month-days")&&n.jsx(hr,{value:Ue,setValue:at,locale:u,className:k,weekDays:He,disabled:B,readOnly:U,leadingZero:P,period:te,periodicityOnDoubleClick:_,mode:ee}),(te==="year"||te==="month"||te==="week")&&ye.includes("week-days")&&n.jsx(br,{value:He,setValue:dt,locale:u,className:k,humanizeLabels:E,monthDays:Ue,disabled:B,readOnly:U,period:te,periodicityOnDoubleClick:_,mode:ee}),n.jsxs("div",{children:[te!=="minute"&&te!=="hour"&&ye.includes("hours")&&n.jsx(mr,{value:ut,setValue:pt,locale:u,className:k,disabled:B,readOnly:U,leadingZero:P,clockFormat:ae,period:te,periodicityOnDoubleClick:_,mode:ee}),te!=="minute"&&ye.includes("minutes")&&n.jsx(fr,{value:mt,setValue:ft,locale:u,period:te,className:k,disabled:B,readOnly:U,leadingZero:P,clockFormat:ae,periodicityOnDoubleClick:_,mode:ee}),Zo]})]})]}))}const Eo=[{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 Do(e){return Eo.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function vr(e){let t;switch(typeof e){case"number":return t=Do(e),t?t.value:"none";case"string":return"cron"}return"none"}function wr({value:e,onChange:t}){const{t:o}=xt(),r=Do(e);return n.jsx(g.InputNumber,{value:e/r.value,onChange:s=>t(s*r.value),min:1,addonBefore:o("Every"),addonAfter:o(r.unitText),className:"auto-width"})}function Cr({value:e=null,onChange:t}){const{t:o}=xt(),r=vr(e),s=y.useCallback(a=>{if(a==="none"){t(null);return}if(a==="cron"){t("0 * * * * *");return}t(a)},[t]);return n.jsxs("fieldset",{className:l.css`
|
|
524
524
|
display: flex;
|
|
525
525
|
flex-direction: ${r==="cron"?"column":"row"};
|
|
526
526
|
align-items: flex-start;
|
|
@@ -549,7 +549,7 @@
|
|
|
549
549
|
}
|
|
550
550
|
}
|
|
551
551
|
}
|
|
552
|
-
`,children:[n.jsx(g.Select,{value:r,onChange:s,className:"auto-width",children
|
|
552
|
+
`,children:[n.jsx(g.Select,{value:r,onChange:s,className:"auto-width",children:Eo.map(a=>n.jsx(g.Select.Option,{value:a.value,children:o(a.text)},a.value))}),typeof r=="number"?n.jsx(wr,{value:e,onChange:t}):null,r==="cron"?n.jsx(xr,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:a=>t(`0 ${a}`),clearButton:!1,locale:window.cronLocale}):null]})}const kr={[Ae.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}}},[Ae.DATE_FIELD]:{collection:A(C({},de),{"x-component-props":{dataSourceFilter(e){return e.options.key==="main"||e.options.isDBInstance}},"x-reactions":[...de["x-reactions"],{target:"startsOn",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),startsOn:{type:"object",title:`{{t("Starts on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"OnField","x-reactions":[{target:"repeat",fulfill:{state:{visible:"{{!!$self.value}}"}}}],required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"object",title:`{{t("Ends on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"EndsByField"},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${p}" })}}`,min:0}},appends:A(C({},Le),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${Ae.DATE_FIELD} && $deps[1]}}`}}}]})}},Sr=[{value:Ae.STATIC,label:`{{t("Based on certain date", { ns: "${p}" })}}`},{value:Ae.DATE_FIELD,label:`{{t("Based on date field of collection", { ns: "${p}" })}}`}],Ar=()=>{const{values:e={},clearFormGraph:t}=T.useForm(),[o,r]=y.useState(e.mode);return T.useFormEffects(()=>{fe.onFieldValueChange("mode",s=>{r(s.value),t("collection"),t("startsOn"),t("repeat"),t("endsOn"),t("limit")})}),n.jsxs(n.Fragment,{children:[n.jsx(l.SchemaComponent,{schema:{type:"number",title:`{{t("Trigger mode", { ns: "${p}" })}}`,name:"mode","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:Sr},required:!0,default:Ae.STATIC}}),n.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`mode-${o}`]:{type:"void","x-component":"fieldset","x-component-props":{className:l.css`
|
|
553
553
|
.ant-input-number {
|
|
554
554
|
width: auto;
|
|
555
555
|
min-width: 6em;
|
|
@@ -558,7 +558,7 @@
|
|
|
558
558
|
.ant-picker {
|
|
559
559
|
width: auto;
|
|
560
560
|
}
|
|
561
|
-
`},properties:kr[o]}}},components:{OnField:go,RepeatField:Cr,EndsByField:ur}})]})};function Fr(e,t){var c;const[o,r]=l.parseCollectionName(e.collection),s=l.useCompile(),a=We(o),i=[];if((!(t!=null&&t.types)||t.types.includes("date"))&&i.push({key:"date",value:"date",label:O("Trigger time")}),e.mode===Ae.DATE_FIELD){const[p]=Te(A(C({appends:["data",...((c=e.appends)==null?void 0:c.map(d=>`data.${d}`))||[]]},t),{fields:[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:O("Trigger data")}}],compile:s,getCollectionFields:a}));p&&i.push(p)}return i}class Tr extends Mt{constructor(){super(...arguments);w(this,"sync",!1);w(this,"title",`{{t("Schedule event", { ns: "${u}" })}}`);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: "${u}" })}}`);w(this,"fieldset",{config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}});w(this,"scope",{useCollectionDataSource:l.useCollectionDataSource});w(this,"components",{ScheduleConfig:Ar});w(this,"useVariables",Fr)}useInitializers(o){return o.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${u}" })}}`,Component:Me,collection:o.collection,dataPath:"$context.data"}:null}}class Nr extends be{constructor(){super(...arguments);w(this,"title",`{{t("Calculation", { ns: "${u}" })}}`);w(this,"type","calculation");w(this,"group","calculation");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: "${u}" })}}`);w(this,"fieldset",{engine:{type:"string",title:`{{t("Calculation engine", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:Ie.getOptions()},required:!0,default:"formula.js"},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(o,r,{form:s}){const{values:a}=s,{evaluate:i}=Ie.evaluators.get(a.engine),c=o.trim().replace(/{{([^{}]+)}}/g,' "1" ');try{return i(c),""}catch(p){return O("Expression syntax error")}},"x-reactions":[{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0}});w(this,"scope",{renderEngineReference:Pt});w(this,"components",{WorkflowVariableTextArea:It,RadioWithTooltip:ke,ValueBlock:Ne})}useVariables({key:o,title:r},{types:s,fieldNames:a=je}){return s&&!s.some(i=>i in Qe||Object.values(Qe).some(c=>c.has(i)))?null:{value:o,label:r}}useInitializers(o){var r,s;return{name:(r=o.title)!=null?r:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Ne.Initializer,node:o,resultTitle:O("Calculation result")}}}const Do={DEFAULT:null,ON_TRUE:1,ON_FALSE:0};class Or extends be{constructor(){super(...arguments);w(this,"title",`{{t("Condition", { ns: "${u}" })}}`);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: "${u}" })}}`);w(this,"fieldset",{rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{disabled:!0},enum:[{value:!0,label:`{{t('Continue when "Yes"', { ns: "${u}" })}}`},{value:!1,label:`{{t('Branch into "Yes" and "No"', { ns: "${u}" })}}`}]},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[["basic",{label:`{{t("Basic", { ns: "${u}" })}}`}],...Array.from(Ie.evaluators.getEntities()).filter(([o])=>["math.js","formula.js"].includes(o))].reduce((o,[r,s])=>o.concat(C({value:r},s)),[])},required:!0,default:"basic"},calculation:{type:"object",title:`{{t("Condition", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"CalculationConfig","x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] === "basic"}}'}}},required:!0},expression:{type:"string",title:`{{t("Condition expression", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(o,r,{form:s}){const{values:a}=s,{evaluate:i}=Ie.evaluators.get(a.engine),c=o.trim().replace(/{{([^{}]+)}}/g,' "1" ');try{return i(c),""}catch(p){return O("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0}});w(this,"presetFieldset",{rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t('Continue when "Yes"', { ns: "${u}" })}}`,value:!0},{label:`{{t('Branch into "Yes" and "No"', { ns: "${u}" })}}`,value:!1}],default:!0}});w(this,"branching",({rejectOnFalse:o=!0}={})=>o?!1:[{label:`{{t('After end of branches', { ns: "${u}" })}}`,value:!1},{label:`{{t('Inside of "Yes" branch', { ns: "${u}" })}}`,value:Do.ON_TRUE},{label:`{{t('Inside of "No" branch', { ns: "${u}" })}}`,value:Do.ON_FALSE}]);w(this,"scope",{renderEngineReference:Pt,useWorkflowVariableOptions:me});w(this,"components",{CalculationConfig:oo,WorkflowVariableTextArea:It,RadioWithTooltip:ke})}Component({data:o}){const{t:r}=X.useTranslation(),{nodes:s}=H(),{styles:a}=ne(),{id:i,config:{rejectOnFalse:c}}=o,p=s.find(m=>m.upstreamId===i&&m.branchIndex===1),d=s.find(m=>m.upstreamId===i&&m.branchIndex===0);return n.jsx(Tt,{data:o,children:c?null:n.jsxs("div",{className:a.nodeSubtreeClass,children:[n.jsxs("div",{className:a.branchBlockClass,children:[n.jsx(tt,{from:o,entry:d,branchIndex:0}),n.jsx(tt,{from:o,entry:p,branchIndex:1})]}),n.jsxs("div",{className:a.conditionClass,children:[n.jsx("span",{style:{right:"4em"},children:r("No")}),n.jsx("span",{style:{left:"4em"},children:r("Yes")})]})]})})}}class $r extends be{constructor(){super(...arguments);w(this,"title",`{{t("End process", { ns: "${u}" })}}`);w(this,"type","end");w(this,"group","control");w(this,"description",`{{t("End the process immediately, with set status.", { ns: "${u}" })}}`);w(this,"fieldset",{endStatus:{type:"number",title:`{{t("End status", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeeded", { ns: "${u}" })}}`,value:ce.RESOLVED},{label:`{{t("Failed", { ns: "${u}" })}}`,value:ce.FAILED}],required:!0,default:ce.RESOLVED}});w(this,"end",!0)}}function Er({key:e,title:t,config:o},r){var d,m;const[s,a]=l.parseCollectionName(o.collection),i=l.useCompile(),c=We(s),[p]=Te(A(C({appends:[e,...((m=(d=o.params)==null?void 0:d.appends)==null?void 0:m.map(h=>`${e}.${h}`))||[]]},r),{fields:[{collectionName:a,name:e,type:"hasOne",target:a,uiSchema:{title:t}}],compile:i,getCollectionFields:c}));return p}class Dr extends be{constructor(){super(...arguments);w(this,"title",`{{t("Query record", { ns: "${u}" })}}`);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: "${u}" })}}`);w(this,"fieldset",{collection:A(C({},de),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...de["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),multiple:{type:"boolean",title:`{{t("Result type", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{label:`{{t("Single record", { ns: "${u}" })}}`,value:!1,tooltip:`{{t("The result will be an object of the first matching record only, or null if no matched record.", { ns: "${u}" })}}`},{label:`{{t("Multiple records", { ns: "${u}" })}}`,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: "${u}" })}}`}]},required:!0,default:!1},params:{type:"object","x-component":"fieldset",properties:{filter:ot,sort:or,pagination:nr,appends:Le},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{$deps[0] != null}}"}}}]},failOnEmpty:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Exit when query result is null", { ns: "${u}" })}}`}});w(this,"scope",{useNodeSavedConfig:Ve,useCollectionDataSource:l.useCollectionDataSource,useSortableFields(){const o=l.useCompile(),{values:r}=T.useForm(),[s,a]=l.parseCollectionName(r.collection),i=l.useApp(),{collectionManager:c}=i.dataSourceManager.getDataSource(s);return c.getCollectionFields(a).filter(d=>{if(!d.interface)return!1;const m=i.dataSourceManager.collectionFieldInterfaceManager.getFieldInterface(d.interface);return!!(m!=null&&m.sortable)}).map(d=>{var m,h;return{value:d.name,label:(m=d==null?void 0:d.uiSchema)!=null&&m.title?o((h=d==null?void 0:d.uiSchema)==null?void 0:h.title):d.name}})}});w(this,"components",{ArrayItems:gt.ArrayItems,FilterDynamicComponent:Re,SchemaComponentContext:l.SchemaComponentContext,WorkflowVariableInput:Dt,RadioWithTooltip:ke});w(this,"useVariables",Er)}useInitializers(o){var r,s;return!o.config.collection||o.config.multiple?null:{name:(r=o.title)!=null?r:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Me,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}}}function Ir(e){const{getCollectionFields:t}=l.useCollectionManager_deprecated(),{path:o}=T.useField(),r=o.segments[o.segments.length-1],{values:s}=T.useForm(),[a,i]=l.parseCollectionName(s==null?void 0:s.collection),c=t(i,a),{type:p}=c.find(h=>h.name===r),d=Array.isArray(e.value)?e.value.join(","):e.value,m=y.useCallback(h=>{const v=h.target.value.trim(),b=["belongsTo","hasOne"].includes(p)?v||null:v.split(",").map(f=>f.trim()).filter(f=>f!=="");e.onChange(b)},[e.onChange,p]);return n.jsx(g.Input,A(C({},e),{value:d,onChange:m}))}const Io=T.observer(({value:e,disabled:t,onChange:o,filter:r})=>{const{token:s}=l.useToken(),{t:a}=X.useTranslation(),i=l.useCompile(),c=T.useForm(),{getCollectionFields:p}=l.useCollectionManager_deprecated(),d=me(),{values:m}=c,[h,v]=l.parseCollectionName(m==null?void 0:m.collection),b=p(v,h).filter(S=>S.uiSchema),f=r?b.filter(r.bind(m)):b,k=y.useMemo(()=>f.filter(S=>!e||!(S.name in e)),[f,e]),F=t||c.disabled,M=y.useMemo(()=>({onClick:({key:S})=>{o(A(C({},e),{[S]:null}))},style:{maxHeight:300,overflowY:"auto"},items:k.map(S=>{var E,L;return{key:S.name,label:i((L=(E=S.uiSchema)==null?void 0:E.title)!=null?L:S.name)}})}),[o,k,e]);return n.jsx("fieldset",{className:l.css`
|
|
561
|
+
`},properties:kr[o]}}},components:{OnField:go,RepeatField:Cr,EndsByField:ur}})]})};function Fr(e,t){var c;const[o,r]=l.parseCollectionName(e.collection),s=l.useCompile(),a=We(o),i=[];if((!(t!=null&&t.types)||t.types.includes("date"))&&i.push({key:"date",value:"date",label:O("Trigger time")}),e.mode===Ae.DATE_FIELD){const[u]=Te(A(C({appends:["data",...((c=e.appends)==null?void 0:c.map(d=>`data.${d}`))||[]]},t),{fields:[{collectionName:e.collection,name:"data",type:"hasOne",target:e.collection,uiSchema:{title:O("Trigger data")}}],compile:s,getCollectionFields:a}));u&&i.push(u)}return i}class Tr extends Mt{constructor(){super(...arguments);w(this,"sync",!1);w(this,"title",`{{t("Schedule event", { ns: "${p}" })}}`);w(this,"description",`{{t("Triggered according to preset time conditions. Suitable for one-time or periodic tasks, such as sending notifications and cleaning data on a schedule.", { ns: "${p}" })}}`);w(this,"fieldset",{config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}});w(this,"scope",{useCollectionDataSource:l.useCollectionDataSource});w(this,"components",{ScheduleConfig:Ar});w(this,"useVariables",Fr)}useInitializers(o){return o.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Me,collection:o.collection,dataPath:"$context.data"}:null}}class Nr extends be{constructor(){super(...arguments);w(this,"title",`{{t("Calculation", { ns: "${p}" })}}`);w(this,"type","calculation");w(this,"group","calculation");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:Ie.getOptions()},required:!0,default:"formula.js"},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(o,r,{form:s}){const{values:a}=s,{evaluate:i}=Ie.evaluators.get(a.engine),c=o.trim().replace(/{{([^{}]+)}}/g,' "1" ');try{return i(c),""}catch(u){return O("Expression syntax error")}},"x-reactions":[{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0}});w(this,"scope",{renderEngineReference:Pt});w(this,"components",{WorkflowVariableTextArea:It,RadioWithTooltip:ke,ValueBlock:Ne})}useVariables({key:o,title:r},{types:s,fieldNames:a=je}){return s&&!s.some(i=>i in Qe||Object.values(Qe).some(c=>c.has(i)))?null:{value:o,label:r}}useInitializers(o){var r,s;return{name:(r=o.title)!=null?r:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Ne.Initializer,node:o,resultTitle:O("Calculation result")}}}const $o={DEFAULT:null,ON_TRUE:1,ON_FALSE:0};class Or extends be{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(Ie.evaluators.getEntities()).filter(([o])=>["math.js","formula.js"].includes(o))].reduce((o,[r,s])=>o.concat(C({value:r},s)),[])},required:!0,default:"basic"},calculation:{type:"object",title:`{{t("Condition", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"CalculationConfig","x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] === "basic"}}'}}},required:!0},expression:{type:"string",title:`{{t("Condition expression", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(o,r,{form:s}){const{values:a}=s,{evaluate:i}=Ie.evaluators.get(a.engine),c=o.trim().replace(/{{([^{}]+)}}/g,' "1" ');try{return i(c),""}catch(u){return O("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0}});w(this,"presetFieldset",{rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t('Continue when "Yes"', { ns: "${p}" })}}`,value:!0},{label:`{{t('Branch into "Yes" and "No"', { ns: "${p}" })}}`,value:!1}],default:!0}});w(this,"branching",({rejectOnFalse:o=!0}={})=>o?!1:[{label:`{{t('After end of branches', { ns: "${p}" })}}`,value:!1},{label:`{{t('Inside of "Yes" branch', { ns: "${p}" })}}`,value:$o.ON_TRUE},{label:`{{t('Inside of "No" branch', { ns: "${p}" })}}`,value:$o.ON_FALSE}]);w(this,"scope",{renderEngineReference:Pt,useWorkflowVariableOptions:me});w(this,"components",{CalculationConfig:oo,WorkflowVariableTextArea:It,RadioWithTooltip:ke})}Component({data:o}){const{t:r}=X.useTranslation(),{nodes:s}=H(),{styles:a}=ne(),{id:i,config:{rejectOnFalse:c}}=o,u=s.find(m=>m.upstreamId===i&&m.branchIndex===1),d=s.find(m=>m.upstreamId===i&&m.branchIndex===0);return n.jsx(Tt,{data:o,children:c?null:n.jsxs("div",{className:a.nodeSubtreeClass,children:[n.jsxs("div",{className:a.branchBlockClass,children:[n.jsx(tt,{from:o,entry:d,branchIndex:0}),n.jsx(tt,{from:o,entry:u,branchIndex:1})]}),n.jsxs("div",{className:a.conditionClass,children:[n.jsx("span",{style:{right:"4em"},children:r("No")}),n.jsx("span",{style:{left:"4em"},children:r("Yes")})]})]})})}}class Er extends be{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:ce.RESOLVED},{label:`{{t("Failed", { ns: "${p}" })}}`,value:ce.FAILED}],required:!0,default:ce.RESOLVED}});w(this,"end",!0)}}function Dr({key:e,title:t,config:o},r){var d,m;const[s,a]=l.parseCollectionName(o.collection),i=l.useCompile(),c=We(s),[u]=Te(A(C({appends:[e,...((m=(d=o.params)==null?void 0:d.appends)==null?void 0:m.map(h=>`${e}.${h}`))||[]]},r),{fields:[{collectionName:a,name:e,type:"hasOne",target:a,uiSchema:{title:t}}],compile:i,getCollectionFields:c}));return u}class $r extends be{constructor(){super(...arguments);w(this,"title",`{{t("Query record", { ns: "${p}" })}}`);w(this,"type","query");w(this,"group","collection");w(this,"description",`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:A(C({},de),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...de["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:ot,sort:or,pagination:nr,appends:Le},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{$deps[0] != null}}"}}}]},failOnEmpty:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Exit when query result is null", { ns: "${p}" })}}`}});w(this,"scope",{useNodeSavedConfig:Ve,useCollectionDataSource:l.useCollectionDataSource,useSortableFields(){const o=l.useCompile(),{values:r}=T.useForm(),[s,a]=l.parseCollectionName(r.collection),i=l.useApp(),{collectionManager:c}=i.dataSourceManager.getDataSource(s);return c.getCollectionFields(a).filter(d=>{if(!d.interface)return!1;const m=i.dataSourceManager.collectionFieldInterfaceManager.getFieldInterface(d.interface);return!!(m!=null&&m.sortable)}).map(d=>{var m,h;return{value:d.name,label:(m=d==null?void 0:d.uiSchema)!=null&&m.title?o((h=d==null?void 0:d.uiSchema)==null?void 0:h.title):d.name}})}});w(this,"components",{ArrayItems:gt.ArrayItems,FilterDynamicComponent:Re,SchemaComponentContext:l.SchemaComponentContext,WorkflowVariableInput:$t,RadioWithTooltip:ke});w(this,"useVariables",Dr)}useInitializers(o){var r,s;return!o.config.collection||o.config.multiple?null:{name:(r=o.title)!=null?r:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Me,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}}}function Ir(e){const{getCollectionFields:t}=l.useCollectionManager_deprecated(),{path:o}=T.useField(),r=o.segments[o.segments.length-1],{values:s}=T.useForm(),[a,i]=l.parseCollectionName(s==null?void 0:s.collection),c=t(i,a),{type:u}=c.find(h=>h.name===r),d=Array.isArray(e.value)?e.value.join(","):e.value,m=y.useCallback(h=>{const v=h.target.value.trim(),b=["belongsTo","hasOne"].includes(u)?v||null:v.split(",").map(f=>f.trim()).filter(f=>f!=="");e.onChange(b)},[e.onChange,u]);return n.jsx(g.Input,A(C({},e),{value:d,onChange:m}))}const Io=T.observer(({value:e,disabled:t,onChange:o,filter:r})=>{const{token:s}=l.useToken(),{t:a}=X.useTranslation(),i=l.useCompile(),c=T.useForm(),{getCollectionFields:u}=l.useCollectionManager_deprecated(),d=me(),{values:m}=c,[h,v]=l.parseCollectionName(m==null?void 0:m.collection),b=u(v,h).filter(S=>S.uiSchema),f=r?b.filter(r.bind(m)):b,k=y.useMemo(()=>f.filter(S=>!e||!(S.name in e)),[f,e]),F=t||c.disabled,M=y.useMemo(()=>({onClick:({key:S})=>{o(A(C({},e),{[S]:null}))},style:{maxHeight:300,overflowY:"auto"},items:k.map(S=>{var D,L;return{key:S.name,label:i((L=(D=S.uiSchema)==null?void 0:D.title)!=null?L:S.name)}})}),[o,k,e]);return n.jsx("fieldset",{className:l.css`
|
|
562
562
|
margin-top: 0.5em;
|
|
563
563
|
|
|
564
564
|
> .ant-formily-item {
|
|
@@ -568,8 +568,8 @@
|
|
|
568
568
|
line-height: 32px;
|
|
569
569
|
}
|
|
570
570
|
}
|
|
571
|
-
`,children:f.length?n.jsxs(l.CollectionProvider_deprecated,{name:v,dataSource:h,children:[f.filter(S=>e&&S.name in e).map(S=>{var L
|
|
571
|
+
`,children:f.length?n.jsxs(l.CollectionProvider_deprecated,{name:v,dataSource:h,children:[f.filter(S=>e&&S.name in e).map(S=>{var L,E;const D=["belongsTo","hasOne","hasMany","belongsToMany"].includes(S.type)?Ir:l.CollectionField;return n.jsxs(g.Form.Item,{label:i((E=(L=S.uiSchema)==null?void 0:L.title)!=null?E:S.name),labelAlign:"left",className:l.css`
|
|
572
572
|
.ant-form-item-control-input-content {
|
|
573
573
|
display: flex;
|
|
574
574
|
}
|
|
575
|
-
`,children:[n.jsx(l.Variable.Input,{scope:d,value:e[S.name],changeOnSelect:!0,onChange:I=>{o(A(C({},e),{[S.name]:I}))},children:n.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[S.name]:{"x-component":E,"x-validator"(){return""}}}}})}),F?null:n.jsx(g.Button,{"aria-label":"icon-close",type:"link",icon:n.jsx(V.CloseCircleOutlined,{}),onClick:()=>{var N;const B=e,{[N=S.name]:I}=B,D=Z(B,[Ro(N)]);o(D)}})]},S.name)}),k.length?n.jsx(g.Dropdown,{menu:M,children:n.jsx(g.Button,{icon:n.jsx(V.PlusOutlined,{}),children:a("Add field")})}):null]}):n.jsx("p",{style:{color:s.colorText},children:O("Please select collection first")})})},{displayName:"CollectionFieldSet"});function Po(e,t){t(e),e!=null&&e.properties&&Object.values(e.properties).forEach(o=>{Po(o,t)})}function Mo(){return{name:oe.uid(),type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields"}}function Bo(e){const{workflow:t}=H(),{setFormValueChanged:o}=l.useActionContext();l.useAPIClient();const r=me(),{values:s,setValuesIn:a,disabled:i}=T.useForm(),c=De.toJS(s.params),[p,d]=l.parseCollectionName(s.collection),m=l.useSchemaOptionsContext(),[h,v]=y.useState(e.value&&Object.keys(e.value).length?e.value:Mo()),b=y.useMemo(()=>fe.createForm({initialValues:c.values,disabled:t.executed,effects(){fe.onFormValuesChange(k=>{a("params.values",De.toJS(k.values)),o(!0)})}}),[t.executed]);T.useFormEffects(()=>{fe.onFieldValueChange("collection",k=>J(this,null,function*(){b.clearFormGraph("*");const F=Mo();a("params.values",{}),v(F)}))});const f=y.useCallback(k=>{const[F]=Object.values(k.toJSON().properties);e.onChange(F);const M=new Set;Po(F,E=>{var L;if(E["x-component"]==="AssignedField"&&(L=E["x-collection-field"])!=null&&L.startsWith(`${d}.`)){const[,$]=E["x-collection-field"].split(".");M.add($)}});const S={};Array.from(M).forEach(E=>{E in b.values&&(S[E]=b.values[E])}),a("params.values",S)},[d,e.onChange]);return n.jsx(g.Card,{children:n.jsx(l.CollectionManagerProvider,{dataSource:p,children:n.jsx(l.CollectionProvider,{name:d,children:n.jsx(l.RerenderDataBlockProvider,{children:n.jsx(l.FormProvider,{form:b,children:n.jsx(gt.FormLayout,{layout:"vertical",children:n.jsx(l.VariableScopeProvider,{scope:r,children:n.jsx(l.SchemaComponentProvider,{form:b,designable:!i,children:n.jsx(l.SchemaComponentOptions,A(C({},m),{children:n.jsx(l.SchemaComponent,{schema:h,onChange:f})}))})})})})})})})})}function Pr({key:e,title:t,config:o},r){var d,m;const[s,a]=l.parseCollectionName(o.collection),i=l.useCompile(),c=We(s),[p]=Te(A(C({appends:[e,...((m=(d=o.params)==null?void 0:d.appends)==null?void 0:m.map(h=>`${e}.${h}`))||[]]},r),{fields:[{collectionName:a,name:e,type:"hasOne",target:a,uiSchema:{title:t}}],compile:i,getCollectionFields:c}));return p}class Mr extends be{constructor(){super(...arguments);w(this,"title",`{{t("Create record", { ns: "${u}" })}}`);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: "${u}" })}}`);w(this,"fieldset",{collection:A(C({},de),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...de["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),usingAssignFormSchema:{type:"boolean"},assignFormSchema:{type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-component":"AssignedFieldsFormSchemaConfig","x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && $deps[1]) ? "visible" : "hidden"}}'}}}]},params:{type:"object",properties:{values:A(C({},ho),{"x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && !$deps[1]) ? "visible" : "hidden"}}'}}}]}),appends:Le}}});w(this,"scope",{useCollectionDataSource:l.useCollectionDataSource,useNodeSavedConfig:Ve});w(this,"components",{CollectionFieldset:Io,AssignedFieldsFormSchemaConfig:Bo});w(this,"useVariables",Pr)}createDefaultConfig(){return{usingAssignFormSchema:!0,assignFormSchema:{}}}useInitializers(o){var r,s;return o.config.collection?{name:(r=o.title)!=null?r:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Me,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}:null}}class Br extends be{constructor(){super(...arguments);w(this,"title",`{{t("Update record", { ns: "${u}" })}}`);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: "${u}" })}}`);w(this,"fieldset",{collection:A(C({},de),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...de["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: "${u}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${u}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But association fields are not supported (unless foreign key in current collection), and the updated data will not trigger other workflows.", { ns: "${u}" })}}`},{label:`{{t("Update one by one", { ns: "${u}" })}}`,value:!0,tooltip:`{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${u}" })}}`}]},default:!1},filter:A(C({},ot),{title:`{{t("Only update records matching conditions", { ns: "${u}" })}}`,"x-validator"(o){return Q.isValidFilter(o)?"":O("Please add at least one condition")}}),values:A(C({},ho),{"x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && !$deps[1]) ? "visible" : "hidden"}}'}}}]})}},usingAssignFormSchema:{type:"boolean"},assignFormSchema:{type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-component":"AssignedFieldsFormSchemaConfig","x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && $deps[1]) ? "visible" : "hidden"}}'}}}]}});w(this,"scope",{useCollectionDataSource:l.useCollectionDataSource,useNodeSavedConfig:Ve});w(this,"components",{FilterDynamicComponent:Re,CollectionFieldset:Io,AssignedFieldsFormSchemaConfig:Bo,RadioWithTooltip:ke})}createDefaultConfig(){return{usingAssignFormSchema:!0,assignFormSchema:{}}}}class Vr extends be{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: "${u}" })}}`);w(this,"fieldset",{collection:A(C({},de),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...de["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:A(C({},ot),{"x-validator"(o){return Q.isValidFilter(o)?"":O("Please add at least one condition")}})}}});w(this,"scope",{useNodeSavedConfig:Ve,useCollectionDataSource:l.useCollectionDataSource});w(this,"components",{FilterDynamicComponent:Re})}}const jr=new l.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:l.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=l.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:l.SecondConFirm},{name:"assignFieldValues",Component:l.AssignedFieldValues},{name:"skipRequiredValidation",Component:l.SkipValidation},{name:"afterSuccessfulSubmission",Component:l.AfterSuccess},{name:"bindWorkflow",Component:l.WorkflowConfig},{name:"delete",sort:100,Component:l.RemoveButton,useComponentProps(){const{removeButtonProps:e}=l.useSchemaToolbar();return e}}]});function Wr({children:e,workflow:t,execution:o,nodes:r}){const s=l.usePlugin(le),a=s.triggers.get(t.type).components,i=r.reduce((c,{type:p})=>Object.assign(c,s.instructions.get(p).components),{});return n.jsx(Pe.Provider,{value:{workflow:t,nodes:r,execution:o},children:n.jsx(l.SchemaComponentOptions,{components:C(C({},a),i),children:e})})}class le extends l.Plugin{constructor(){super(...arguments);w(this,"triggers",new Q.Registry);w(this,"instructions",new Q.Registry);w(this,"systemVariables",new Q.Registry);w(this,"useTriggersOptions",()=>{const o=l.useCompile();return Array.from(this.triggers.getEntities()).map(i=>{var[r,c]=i,p=c,{title:s}=p,a=Z(p,["title"]);return{value:r,label:o(s),color:"gold",options:a}})})}isWorkflowSync(o){var r,s;return(s=(r=this.triggers.get(o.type))==null?void 0:r.sync)!=null?s:o.sync}registerTrigger(o,r){if(typeof r=="function")this.triggers.register(o,new r);else if(r)this.triggers.register(o,r);else throw new TypeError("invalid trigger type to register")}registerInstruction(o,r){if(typeof r=="function")this.instructions.register(o,new r);else if(r instanceof be)this.instructions.register(o,r);else throw new TypeError("invalid instruction type to register")}registerSystemVariable(o){this.systemVariables.register(o.key,o)}load(){return J(this,null,function*(){this.app.router.add("admin.workflow.workflows.id",{path:Ce(":id"),element:n.jsx(mo,{})}),this.app.router.add("admin.workflow.executions.id",{path:qe(":id"),element:n.jsx(lo,{})}),this.app.addComponents({WorkflowPage:mo,ExecutionPage:lo}),this.app.pluginSettingsManager.add(u,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${u}" })}}`,Component:tr,aclSnippet:"pm.workflow.workflows"}),this.app.schemaSettingsManager.add(jr),this.app.schemaSettingsManager.addItem("actionSettings:delete","workflowConfig",{Component:l.WorkflowConfig,useVisible(){var r;const o=T.useFieldSchema();return oe.isValid((r=o==null?void 0:o["x-action-settings"])==null?void 0:r.triggerWorkflows)}}),this.registerTrigger("collection",cr),this.registerTrigger("schedule",Tr),this.registerInstruction("calculation",Nr),this.registerInstruction("condition",Or),this.registerInstruction("end",$r),this.registerInstruction("query",Dr),this.registerInstruction("create",Mr),this.registerInstruction("update",Br),this.registerInstruction("destroy",Vr),this.registerSystemVariable({key:"now",label:`{{t("System time", { ns: "${u}" })}}`,value:"now"}),this.registerSystemVariable({key:"dateRange",label:`{{t("Date range", { ns: "${u}" })}}`,value:"dateRange",children:[{key:"yesterday",value:"yesterday",label:`{{t("Yesterday", { ns: "${u}" })}}`},{key:"today",value:"today",label:`{{t("Today", { ns: "${u}" })}}`},{key:"tomorrow",value:"tomorrow",label:`{{t("Tomorrow", { ns: "${u}" })}}`},{key:"lastWeek",value:"lastWeek",label:`{{t("Last week", { ns: "${u}" })}}`},{key:"thisWeek",value:"thisWeek",label:`{{t("This week", { ns: "${u}" })}}`},{key:"nextWeek",value:"nextWeek",label:`{{t("Next week", { ns: "${u}" })}}`},{key:"lastMonth",value:"lastMonth",label:`{{t("Last month", { ns: "${u}" })}}`},{key:"thisMonth",value:"thisMonth",label:`{{t("This month", { ns: "${u}" })}}`},{key:"nextMonth",value:"nextMonth",label:`{{t("Next month", { ns: "${u}" })}}`},{key:"lastQuarter",value:"lastQuarter",label:`{{t("Last quarter", { ns: "${u}" })}}`},{key:"thisQuarter",value:"thisQuarter",label:`{{t("This quarter", { ns: "${u}" })}}`},{key:"nextQuarter",value:"nextQuarter",label:`{{t("Next quarter", { ns: "${u}" })}}`},{key:"lastYear",value:"lastYear",label:`{{t("Last year", { ns: "${u}" })}}`},{key:"thisYear",value:"thisYear",label:`{{t("This year", { ns: "${u}" })}}`},{key:"nextYear",value:"nextYear",label:`{{t("Next year", { ns: "${u}" })}}`},{key:"last7Days",value:"last7Days",label:`{{t("Last 7 days", { ns: "${u}" })}}`},{key:"next7Days",value:"next7Days",label:`{{t("Next 7 days", { ns: "${u}" })}}`},{key:"last30Days",value:"last30Days",label:`{{t("Last 30 days", { ns: "${u}" })}}`},{key:"next30Days",value:"next30Days",label:`{{t("Next 30 days", { ns: "${u}" })}}`},{key:"last90Days",value:"last90Days",label:`{{t("Last 90 days", { ns: "${u}" })}}`},{key:"next90Days",value:"next90Days",label:`{{t("Next 90 days", { ns: "${u}" })}}`}]})})}}x.BaseTypeSets=Qe,x.Branch=tt,x.CalculationConfig=oo,x.CheckboxGroupWithTooltip=kn,x.CollectionBlockInitializer=Me,x.DetailsBlockProvider=ln,x.EXECUTION_STATUS=ie,x.ExecutionContextProvider=Wr,x.ExecutionStatusOptions=Ye,x.ExecutionStatusOptionsMap=_e,x.FieldsSelect=Ct,x.Fieldset=On,x.FilterDynamicComponent=Re,x.FlowContext=Pe,x.Instruction=be,x.JOB_STATUS=ce,x.JobButton=Ft,x.JobStatusOptions=kt,x.JobStatusOptionsMap=Ke,x.Node=Gt,x.NodeContext=Ze,x.NodeDefaultView=Tt,x.RadioWithTooltip=ke,x.RemoveButton=At,x.SimpleDesigner=Xt,x.Trigger=Mt,x.ValueBlock=Ne,x.WorkflowVariableInput=Dt,x.WorkflowVariableJSON=Cn,x.WorkflowVariableRawTextArea=wn,x.WorkflowVariableTextArea=It,x.calculators=Y,x.default=le,x.defaultFieldNames=je,x.getCollectionFieldOptions=Te,x.getWorkflowDetailPath=Ce,x.getWorkflowExecutionsPath=qe,x.linkNodes=vt,x.nodesOptions=Yt,x.renderEngineReference=Pt,x.scopeOptions=Kt,x.systemOptions=Zt,x.traverseSchema=wt,x.triggerOptions=_t,x.useAvailableUpstreams=Ut,x.useFlowContext=H,x.useGetAriaLabelOfAddButton=St,x.useGetCollectionFields=We,x.useNodeContext=xe,x.useNodeSavedConfig=Ve,x.useRecordTriggerWorkflowsActionProps=sr,x.useStyles=ne,x.useTrigger=Bt,x.useTriggerWorkflowsActionProps=rr,x.useUpstreamScopes=Ht,x.useWorkflowAnyExecuted=yo,x.useWorkflowExecuted=lr,x.useWorkflowVariableOptions=me,Object.defineProperties(x,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
575
|
+
`,children:[n.jsx(l.Variable.Input,{scope:d,value:e[S.name],changeOnSelect:!0,onChange:I=>{o(A(C({},e),{[S.name]:I}))},children:n.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[S.name]:{"x-component":D,"x-validator"(){return""}}}}})}),F?null:n.jsx(g.Button,{"aria-label":"icon-close",type:"link",icon:n.jsx(V.CloseCircleOutlined,{}),onClick:()=>{var N;const B=e,{[N=S.name]:I}=B,$=Z(B,[Ro(N)]);o($)}})]},S.name)}),k.length?n.jsx(g.Dropdown,{menu:M,children:n.jsx(g.Button,{icon:n.jsx(V.PlusOutlined,{}),children:a("Add field")})}):null]}):n.jsx("p",{style:{color:s.colorText},children:O("Please select collection first")})})},{displayName:"CollectionFieldSet"});function Po(e,t){t(e),e!=null&&e.properties&&Object.values(e.properties).forEach(o=>{Po(o,t)})}function Mo(){return{name:oe.uid(),type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields"}}function Bo(e){const{workflow:t}=H(),{setFormValueChanged:o}=l.useActionContext();l.useAPIClient();const r=me(),{values:s,setValuesIn:a,disabled:i}=T.useForm(),c=$e.toJS(s.params),[u,d]=l.parseCollectionName(s.collection),m=l.useSchemaOptionsContext(),[h,v]=y.useState(e.value&&Object.keys(e.value).length?e.value:Mo()),b=y.useMemo(()=>fe.createForm({initialValues:c.values,disabled:t.executed,effects(){fe.onFormValuesChange(k=>{a("params.values",$e.toJS(k.values)),o(!0)})}}),[t.executed]);T.useFormEffects(()=>{fe.onFieldValueChange("collection",k=>J(this,null,function*(){b.clearFormGraph("*");const F=Mo();a("params.values",{}),v(F)}))});const f=y.useCallback(k=>{const[F]=Object.values(k.toJSON().properties);e.onChange(F);const M=new Set;Po(F,D=>{var L;if(D["x-component"]==="AssignedField"&&(L=D["x-collection-field"])!=null&&L.startsWith(`${d}.`)){const[,E]=D["x-collection-field"].split(".");M.add(E)}});const S={};Array.from(M).forEach(D=>{D in b.values&&(S[D]=b.values[D])}),a("params.values",S)},[d,e.onChange]);return n.jsx(g.Card,{children:n.jsx(l.CollectionManagerProvider,{dataSource:u,children:n.jsx(l.CollectionProvider,{name:d,children:n.jsx(l.RerenderDataBlockProvider,{children:n.jsx(l.FormProvider,{form:b,children:n.jsx(gt.FormLayout,{layout:"vertical",children:n.jsx(l.VariableScopeProvider,{scope:r,children:n.jsx(l.SchemaComponentProvider,{form:b,designable:!i,children:n.jsx(l.SchemaComponentOptions,A(C({},m),{children:n.jsx(l.SchemaComponent,{schema:h,onChange:f})}))})})})})})})})})}function Pr({key:e,title:t,config:o},r){var d,m;const[s,a]=l.parseCollectionName(o.collection),i=l.useCompile(),c=We(s),[u]=Te(A(C({appends:[e,...((m=(d=o.params)==null?void 0:d.appends)==null?void 0:m.map(h=>`${e}.${h}`))||[]]},r),{fields:[{collectionName:a,name:e,type:"hasOne",target:a,uiSchema:{title:t}}],compile:i,getCollectionFields:c}));return u}class Mr extends be{constructor(){super(...arguments);w(this,"title",`{{t("Create record", { ns: "${p}" })}}`);w(this,"type","create");w(this,"group","collection");w(this,"description",`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:A(C({},de),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...de["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),usingAssignFormSchema:{type:"boolean"},assignFormSchema:{type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-component":"AssignedFieldsFormSchemaConfig","x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && $deps[1]) ? "visible" : "hidden"}}'}}}]},params:{type:"object",properties:{values:A(C({},ho),{"x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && !$deps[1]) ? "visible" : "hidden"}}'}}}]}),appends:Le}}});w(this,"scope",{useCollectionDataSource:l.useCollectionDataSource,useNodeSavedConfig:Ve});w(this,"components",{CollectionFieldset:Io,AssignedFieldsFormSchemaConfig:Bo});w(this,"useVariables",Pr)}createDefaultConfig(){return{usingAssignFormSchema:!0,assignFormSchema:{}}}useInitializers(o){var r,s;return o.config.collection?{name:(r=o.title)!=null?r:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Me,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}:null}}class Br extends be{constructor(){super(...arguments);w(this,"title",`{{t("Update record", { ns: "${p}" })}}`);w(this,"type","update");w(this,"group","collection");w(this,"description",`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:A(C({},de),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...de["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}},{target:"params.values",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${p}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But association fields are not supported (unless foreign key in current collection), and the updated data will not trigger other workflows.", { ns: "${p}" })}}`},{label:`{{t("Update one by one", { ns: "${p}" })}}`,value:!0,tooltip:`{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${p}" })}}`}]},default:!1},filter:A(C({},ot),{title:`{{t("Only update records matching conditions", { ns: "${p}" })}}`,"x-validator"(o){return Q.isValidFilter(o)?"":O("Please add at least one condition")}}),values:A(C({},ho),{"x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && !$deps[1]) ? "visible" : "hidden"}}'}}}]})}},usingAssignFormSchema:{type:"boolean"},assignFormSchema:{type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-component":"AssignedFieldsFormSchemaConfig","x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && $deps[1]) ? "visible" : "hidden"}}'}}}]}});w(this,"scope",{useCollectionDataSource:l.useCollectionDataSource,useNodeSavedConfig:Ve});w(this,"components",{FilterDynamicComponent:Re,CollectionFieldset:Io,AssignedFieldsFormSchemaConfig:Bo,RadioWithTooltip:ke})}createDefaultConfig(){return{usingAssignFormSchema:!0,assignFormSchema:{}}}}class Vr extends be{constructor(){super(...arguments);w(this,"title",'{{t("Delete record")}}');w(this,"type","destroy");w(this,"group","collection");w(this,"description",`{{t("Delete records of a collection. Could use variables in workflow context as filter. All records match the filter will be deleted.", { ns: "${p}" })}}`);w(this,"fieldset",{collection:A(C({},de),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...de["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:A(C({},ot),{"x-validator"(o){return Q.isValidFilter(o)?"":O("Please add at least one condition")}})}}});w(this,"scope",{useNodeSavedConfig:Ve,useCollectionDataSource:l.useCollectionDataSource});w(this,"components",{FilterDynamicComponent:Re})}}const jr=new l.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:l.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=l.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:l.SecondConFirm},{name:"assignFieldValues",Component:l.AssignedFieldValues},{name:"skipRequiredValidation",Component:l.SkipValidation},{name:"afterSuccessfulSubmission",Component:l.AfterSuccess},{name:"bindWorkflow",Component:l.WorkflowConfig},{name:"delete",sort:100,Component:l.RemoveButton,useComponentProps(){const{removeButtonProps:e}=l.useSchemaToolbar();return e}}]});function Wr({children:e,workflow:t,execution:o,nodes:r}){const s=l.usePlugin(le),a=s.triggers.get(t.type).components,i=r.reduce((c,{type:u})=>Object.assign(c,s.instructions.get(u).components),{});return n.jsx(Pe.Provider,{value:{workflow:t,nodes:r,execution:o},children:n.jsx(l.SchemaComponentOptions,{components:C(C({},a),i),children:e})})}class le extends l.Plugin{constructor(){super(...arguments);w(this,"triggers",new Q.Registry);w(this,"instructions",new Q.Registry);w(this,"systemVariables",new Q.Registry);w(this,"useTriggersOptions",()=>{const o=l.useCompile();return Array.from(this.triggers.getEntities()).map(i=>{var[r,c]=i,u=c,{title:s}=u,a=Z(u,["title"]);return{value:r,label:o(s),color:"gold",options:a}})})}isWorkflowSync(o){var r,s;return(s=(r=this.triggers.get(o.type))==null?void 0:r.sync)!=null?s:o.sync}registerTrigger(o,r){if(typeof r=="function")this.triggers.register(o,new r);else if(r)this.triggers.register(o,r);else throw new TypeError("invalid trigger type to register")}registerInstruction(o,r){if(typeof r=="function")this.instructions.register(o,new r);else if(r instanceof be)this.instructions.register(o,r);else throw new TypeError("invalid instruction type to register")}registerSystemVariable(o){this.systemVariables.register(o.key,o)}load(){return J(this,null,function*(){this.app.router.add("admin.workflow.workflows.id",{path:Ce(":id"),element:n.jsx(mo,{})}),this.app.router.add("admin.workflow.executions.id",{path:qe(":id"),element:n.jsx(lo,{})}),this.app.addComponents({WorkflowPage:mo,ExecutionPage:lo}),this.app.pluginSettingsManager.add(p,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${p}" })}}`,Component:tr,aclSnippet:"pm.workflow.workflows"}),this.app.schemaSettingsManager.add(jr),this.app.schemaSettingsManager.addItem("actionSettings:delete","workflowConfig",{Component:l.WorkflowConfig,useVisible(){var r;const o=T.useFieldSchema();return oe.isValid((r=o==null?void 0:o["x-action-settings"])==null?void 0:r.triggerWorkflows)}}),this.registerTrigger("collection",cr),this.registerTrigger("schedule",Tr),this.registerInstruction("calculation",Nr),this.registerInstruction("condition",Or),this.registerInstruction("end",Er),this.registerInstruction("query",$r),this.registerInstruction("create",Mr),this.registerInstruction("update",Br),this.registerInstruction("destroy",Vr),this.registerSystemVariable({key:"now",label:`{{t("System time", { ns: "${p}" })}}`,value:"now"}),this.registerSystemVariable({key:"dateRange",label:`{{t("Date range", { ns: "${p}" })}}`,value:"dateRange",children:[{key:"yesterday",value:"yesterday",label:'{{t("Yesterday")}}'},{key:"today",value:"today",label:'{{t("Today")}}'},{key:"tomorrow",value:"tomorrow",label:'{{t("Tomorrow")}}'},{key:"lastWeek",value:"lastWeek",label:'{{t("Last week")}}'},{key:"thisWeek",value:"thisWeek",label:'{{t("This week")}}'},{key:"nextWeek",value:"nextWeek",label:'{{t("Next week")}}'},{key:"lastMonth",value:"lastMonth",label:'{{t("Last month")}}'},{key:"thisMonth",value:"thisMonth",label:'{{t("This month")}}'},{key:"nextMonth",value:"nextMonth",label:'{{t("Next month")}}'},{key:"lastQuarter",value:"lastQuarter",label:'{{t("Last quarter")}}'},{key:"thisQuarter",value:"thisQuarter",label:'{{t("This quarter")}}'},{key:"nextQuarter",value:"nextQuarter",label:'{{t("Next quarter")}}'},{key:"lastYear",value:"lastYear",label:'{{t("Last year")}}'},{key:"thisYear",value:"thisYear",label:'{{t("This year")}}'},{key:"nextYear",value:"nextYear",label:'{{t("Next year")}}'},{key:"last7Days",value:"last7Days",label:'{{t("Last 7 days")}}'},{key:"next7Days",value:"next7Days",label:'{{t("Next 7 days")}}'},{key:"last30Days",value:"last30Days",label:'{{t("Last 30 days")}}'},{key:"next30Days",value:"next30Days",label:'{{t("Next 30 days")}}'},{key:"last90Days",value:"last90Days",label:'{{t("Last 90 days")}}'},{key:"next90Days",value:"next90Days",label:'{{t("Next 90 days")}}'}]})})}}x.BaseTypeSets=Qe,x.Branch=tt,x.CalculationConfig=oo,x.CheckboxGroupWithTooltip=kn,x.CollectionBlockInitializer=Me,x.DetailsBlockProvider=ln,x.EXECUTION_STATUS=ie,x.ExecutionContextProvider=Wr,x.ExecutionStatusOptions=Ye,x.ExecutionStatusOptionsMap=_e,x.FieldsSelect=Ct,x.Fieldset=On,x.FilterDynamicComponent=Re,x.FlowContext=Pe,x.Instruction=be,x.JOB_STATUS=ce,x.JobButton=Ft,x.JobStatusOptions=kt,x.JobStatusOptionsMap=Ke,x.Node=Gt,x.NodeContext=Ze,x.NodeDefaultView=Tt,x.RadioWithTooltip=ke,x.RemoveButton=At,x.SimpleDesigner=Xt,x.Trigger=Mt,x.ValueBlock=Ne,x.WorkflowVariableInput=$t,x.WorkflowVariableJSON=Cn,x.WorkflowVariableRawTextArea=wn,x.WorkflowVariableTextArea=It,x.calculators=Y,x.default=le,x.defaultFieldNames=je,x.getCollectionFieldOptions=Te,x.getWorkflowDetailPath=Ce,x.getWorkflowExecutionsPath=qe,x.linkNodes=vt,x.nodesOptions=Yt,x.renderEngineReference=Pt,x.scopeOptions=Kt,x.systemOptions=Zt,x.traverseSchema=wt,x.triggerOptions=_t,x.useAvailableUpstreams=Ut,x.useFlowContext=H,x.useGetAriaLabelOfAddButton=St,x.useGetCollectionFields=We,x.useNodeContext=xe,x.useNodeSavedConfig=Ve,x.useRecordTriggerWorkflowsActionProps=sr,x.useStyles=ne,x.useTrigger=Bt,x.useTriggerWorkflowsActionProps=rr,x.useUpstreamScopes=Ht,x.useWorkflowAnyExecuted=yo,x.useWorkflowExecuted=lr,x.useWorkflowVariableOptions=me,Object.defineProperties(x,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -11,24 +11,24 @@ module.exports = {
|
|
|
11
11
|
"react": "18.2.0",
|
|
12
12
|
"@formily/core": "2.3.0",
|
|
13
13
|
"@formily/react": "2.3.0",
|
|
14
|
-
"@nocobase/client": "1.4.
|
|
15
|
-
"@nocobase/utils": "1.4.
|
|
14
|
+
"@nocobase/client": "1.4.15",
|
|
15
|
+
"@nocobase/utils": "1.4.15",
|
|
16
16
|
"antd": "5.12.8",
|
|
17
17
|
"@ant-design/icons": "5.2.6",
|
|
18
18
|
"react-router-dom": "6.21.0",
|
|
19
19
|
"react-i18next": "11.18.6",
|
|
20
20
|
"@formily/shared": "2.3.2",
|
|
21
21
|
"lodash": "4.17.21",
|
|
22
|
-
"@nocobase/database": "1.4.
|
|
23
|
-
"@nocobase/server": "1.4.
|
|
24
|
-
"@nocobase/logger": "1.4.
|
|
25
|
-
"@nocobase/evaluators": "1.4.
|
|
22
|
+
"@nocobase/database": "1.4.15",
|
|
23
|
+
"@nocobase/server": "1.4.15",
|
|
24
|
+
"@nocobase/logger": "1.4.15",
|
|
25
|
+
"@nocobase/evaluators": "1.4.15",
|
|
26
26
|
"@formily/antd-v5": "1.1.9",
|
|
27
27
|
"@formily/reactive": "2.3.0",
|
|
28
|
-
"@nocobase/actions": "1.4.
|
|
28
|
+
"@nocobase/actions": "1.4.15",
|
|
29
29
|
"dayjs": "1.11.10",
|
|
30
|
-
"@nocobase/data-source-manager": "1.4.
|
|
30
|
+
"@nocobase/data-source-manager": "1.4.15",
|
|
31
31
|
"sequelize": "6.35.2",
|
|
32
|
-
"@nocobase/plugin-workflow-test": "1.4.
|
|
33
|
-
"@nocobase/test": "1.4.
|
|
32
|
+
"@nocobase/plugin-workflow-test": "1.4.15",
|
|
33
|
+
"@nocobase/test": "1.4.15"
|
|
34
34
|
};
|
|
@@ -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-12-
|
|
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-12-24T18:29:04.324Z"}
|
|
@@ -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-12-
|
|
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-12-24T18:29:03.995Z"}
|
package/dist/server/Plugin.js
CHANGED
|
@@ -377,11 +377,13 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
377
377
|
return new import_Processor.default(execution, { ...options, plugin: this });
|
|
378
378
|
}
|
|
379
379
|
async createExecution(workflow, context, options) {
|
|
380
|
-
const {
|
|
380
|
+
const { deferred } = options;
|
|
381
|
+
const transaction = await this.useDataSourceTransaction("main", options.transaction, true);
|
|
382
|
+
const sameTransaction = options.transaction === transaction;
|
|
381
383
|
const trigger = this.triggers.get(workflow.type);
|
|
382
384
|
const valid = await trigger.validateEvent(workflow, context, { ...options, transaction });
|
|
383
385
|
if (!valid) {
|
|
384
|
-
if (!
|
|
386
|
+
if (!sameTransaction) {
|
|
385
387
|
await transaction.commit();
|
|
386
388
|
}
|
|
387
389
|
return null;
|
|
@@ -398,7 +400,7 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
398
400
|
{ transaction }
|
|
399
401
|
);
|
|
400
402
|
} catch (err) {
|
|
401
|
-
if (!
|
|
403
|
+
if (!sameTransaction) {
|
|
402
404
|
await transaction.rollback();
|
|
403
405
|
}
|
|
404
406
|
throw err;
|
|
@@ -419,7 +421,7 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
419
421
|
transaction
|
|
420
422
|
}
|
|
421
423
|
);
|
|
422
|
-
if (!
|
|
424
|
+
if (!sameTransaction) {
|
|
423
425
|
await transaction.commit();
|
|
424
426
|
}
|
|
425
427
|
execution.workflow = workflow;
|
|
@@ -64,7 +64,7 @@ function getDataOptionTime(record, on, dir = 1) {
|
|
|
64
64
|
if (!field || !record.get(field)) {
|
|
65
65
|
return null;
|
|
66
66
|
}
|
|
67
|
-
const second = new Date(record.get(field)
|
|
67
|
+
const second = new Date(record.get(field));
|
|
68
68
|
second.setMilliseconds(0);
|
|
69
69
|
return second.getTime() + offset * unit * dir;
|
|
70
70
|
}
|
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.4.
|
|
7
|
+
"version": "1.4.15",
|
|
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.4.
|
|
13
|
+
"@nocobase/plugin-workflow-test": "1.4.15"
|
|
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": "4ac9c35e410e0e0903e1b13179cac411902fa86c",
|
|
48
48
|
"keywords": [
|
|
49
49
|
"Workflow"
|
|
50
50
|
]
|