@nocobase/plugin-workflow 1.2.6-alpha → 1.2.8-alpha
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
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
(function(v,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("react/jsx-runtime"),require("@nocobase/client"),require("@nocobase/utils/client"),require("react-router-dom"),require("react"),require("antd"),require("react-i18next"),require("@ant-design/icons"),require("@formily/core"),require("@formily/reactive"),require("@formily/react"),require("lodash"),require("@formily/shared"),require("dayjs"),require("@nocobase/evaluators/client"),require("@formily/antd-v5")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","@nocobase/utils/client","react-router-dom","react","antd","react-i18next","@ant-design/icons","@formily/core","@formily/reactive","@formily/react","lodash","@formily/shared","dayjs","@nocobase/evaluators/client","@formily/antd-v5"],r):(v=typeof globalThis!="undefined"?globalThis:v||self,r(v["@nocobase/plugin-workflow"]={},v.jsxRuntime,v["@nocobase/client"],v["@nocobase/utils"],v["react-router-dom"],v.react,v.antd,v["react-i18next"],v["@ant-design/icons"],v["@formily/core"],v["@formily/reactive"],v["@formily/react"],v.lodash,v["@formily/shared"],v.dayjs,v["@nocobase/evaluators"],v["@formily/antd-v5"]))})(this,function(v,r,i,U,oe,y,b,Q,
|
|
10
|
+
(function(v,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("react/jsx-runtime"),require("@nocobase/client"),require("@nocobase/utils/client"),require("react-router-dom"),require("react"),require("antd"),require("react-i18next"),require("@ant-design/icons"),require("@formily/core"),require("@formily/reactive"),require("@formily/react"),require("lodash"),require("@formily/shared"),require("dayjs"),require("@nocobase/evaluators/client"),require("@formily/antd-v5")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","@nocobase/utils/client","react-router-dom","react","antd","react-i18next","@ant-design/icons","@formily/core","@formily/reactive","@formily/react","lodash","@formily/shared","dayjs","@nocobase/evaluators/client","@formily/antd-v5"],r):(v=typeof globalThis!="undefined"?globalThis:v||self,r(v["@nocobase/plugin-workflow"]={},v.jsxRuntime,v["@nocobase/client"],v["@nocobase/utils"],v["react-router-dom"],v.react,v.antd,v["react-i18next"],v["@ant-design/icons"],v["@formily/core"],v["@formily/reactive"],v["@formily/react"],v.lodash,v["@formily/shared"],v.dayjs,v["@nocobase/evaluators"],v["@formily/antd-v5"]))})(this,function(v,r,i,U,oe,y,b,Q,I,ie,mt,j,ke,ft,Yo,De,Mt){"use strict";var Nr=Object.defineProperty,Er=Object.defineProperties;var $r=Object.getOwnPropertyDescriptors;var pt=Object.getOwnPropertySymbols;var Go=Object.prototype.hasOwnProperty,qo=Object.prototype.propertyIsEnumerable;var Pt=(v,r,i)=>r in v?Nr(v,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):v[r]=i,C=(v,r)=>{for(var i in r||(r={}))Go.call(r,i)&&Pt(v,i,r[i]);if(pt)for(var i of pt(r))qo.call(r,i)&&Pt(v,i,r[i]);return v},F=(v,r)=>Er(v,$r(r));var Ko=v=>typeof v=="symbol"?v:v+"",Z=(v,r)=>{var i={};for(var U in v)Go.call(v,U)&&r.indexOf(U)<0&&(i[U]=v[U]);if(v!=null&&pt)for(var U of pt(v))r.indexOf(U)<0&&qo.call(v,U)&&(i[U]=v[U]);return i};var w=(v,r,i)=>(Pt(v,typeof r!="symbol"?r+"":r,i),i);var G=(v,r,i)=>new Promise((U,oe)=>{var y=I=>{try{Q(i.next(I))}catch(ie){oe(ie)}},b=I=>{try{Q(i.throw(I))}catch(ie){oe(ie)}},Q=I=>I.done?U(I.value):Promise.resolve(I.value).then(y,b);Q((i=i.apply(v,r)).next())});const _o=y.createContext(null),ht={didCatch:!1,error:null};class Zo extends y.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=ht}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var o,n,s=arguments.length,a=new Array(s),l=0;l<s;l++)a[l]=arguments[l];(o=(n=this.props).onReset)===null||o===void 0||o.call(n,{args:a,reason:"imperative-api"}),this.setState(ht)}}componentDidCatch(t,o){var n,s;(n=(s=this.props).onError)===null||n===void 0||n.call(s,t,o)}componentDidUpdate(t,o){const{didCatch:n}=this.state,{resetKeys:s}=this.props;if(n&&o.error!==null&&Qo(t.resetKeys,s)){var a,l;(a=(l=this.props).onReset)===null||a===void 0||a.call(l,{next:s,prev:t.resetKeys,reason:"keys"}),this.setState(ht)}}render(){const{children:t,fallbackRender:o,FallbackComponent:n,fallback:s}=this.props,{didCatch:a,error:l}=this.state;let c=t;if(a){const u={error:l,resetErrorBoundary:this.resetErrorBoundary};if(y.isValidElement(s))c=s;else if(typeof o=="function")c=o(u);else if(n)c=y.createElement(n,u);else throw l}return y.createElement(_o.Provider,{value:{didCatch:a,error:l,resetErrorBoundary:this.resetErrorBoundary}},c)}}function Qo(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((o,n)=>!Object.is(o,t[n]))}const Ie=y.createContext({});function q(){return y.useContext(Ie)}const p="workflow";function $(e,t={}){return i.i18n.t(e,F(C({},t),{ns:p}))}function gt(){return Q.useTranslation(p)}const ne=i.createStyles(({css:e,token:t})=>({workflowPageClass:e`
|
|
11
11
|
flex-grow: 1;
|
|
12
12
|
overflow: hidden;
|
|
13
13
|
display: flex;
|
|
@@ -362,12 +362,12 @@
|
|
|
362
362
|
border-radius: 50%;
|
|
363
363
|
background-color: ${t.colorText};
|
|
364
364
|
color: ${t.colorBgContainer};
|
|
365
|
-
`}));function Bt(e){var
|
|
365
|
+
`}));function Bt(e){var k;const{upstream:t,branchIndex:o=null}=e,n=i.usePlugin(de),s=i.useCompile(),a=i.useAPIClient(),{workflow:l,refresh:c}=(k=q())!=null?k:{},u=Array.from(n.instructions.getValues()),{styles:d}=ne(),[f,h]=y.useState(!1),x=y.useMemo(()=>[{key:"control",label:`{{t("Control", { ns: "${p}" })}}`},{key:"collection",label:`{{t("Collection operations", { ns: "${p}" })}}`},{key:"manual",label:`{{t("Manual", { ns: "${p}" })}}`},{key:"extended",label:`{{t("Extended types", { ns: "${p}" })}}`}].map(O=>{const M=u.filter(S=>S.group===O.key&&(S.isAvailable?S.isAvailable({engine:n,workflow:l,upstream:t,branchIndex:o}):!0));return F(C({},O),{type:"group",children:M.map(S=>({role:"button","aria-label":S.type,key:S.type,label:S.title,type:S.options?"subMenu":null,children:S.options?S.options.map(N=>({role:"button","aria-label":N.key,key:N.key,label:N.label})):null}))})}).filter(O=>O.children.length),[o,n,u,t,l]),g=y.useCallback(M=>G(this,[M],function*({keyPath:O}){var T,P,A;const S=O.pop(),[N]=O,W=n.instructions.get(S),J=W.createDefaultConfig();if(N){const{value:E}=(P=(T=W.options)==null?void 0:T.find(L=>L.key===N))!=null?P:{};Object.assign(J,typeof E=="function"?E():E)}if(l){h(!0);try{yield a.resource("workflows.nodes",l.id).create({values:{type:S,upstreamId:(A=t==null?void 0:t.id)!=null?A:null,branchIndex:o,title:s(W.title),config:J}}),c()}catch(E){console.error(E)}finally{h(!1)}}}),[a,o,n.instructions,c,t==null?void 0:t.id,l]),m=y.useMemo(()=>({onClick:g,items:s(x)}),[x,g]);return l?r.jsx("div",{className:d.addButtonClass,children:r.jsx(b.Dropdown,{trigger:["click"],menu:m,disabled:l.executed,overlayClassName:i.css`
|
|
366
366
|
.ant-dropdown-menu-root {
|
|
367
367
|
max-height: 30em;
|
|
368
368
|
overflow-y: auto;
|
|
369
369
|
}
|
|
370
|
-
`,children:r.jsx(b.Button,{"aria-label":e["aria-label"]||"add-button",shape:"circle",icon:r.jsx(
|
|
370
|
+
`,children:r.jsx(b.Button,{"aria-label":e["aria-label"]||"add-button",shape:"circle",icon:r.jsx(I.PlusOutlined,{}),loading:f})})}):null}const yt=(e,t)=>({getAriaLabel:y.useCallback(n=>["add-button",e==null?void 0:e.type,e==null?void 0:e.title,t!=null?String(t):"",n].filter(Boolean).join("-"),[t,e==null?void 0:e.title,e==null?void 0:e.type])}),Xo=i.createStyles(({css:e,token:t})=>({container:e`
|
|
371
371
|
margin-bottom: 1.5em;
|
|
372
372
|
padding: 1em;
|
|
373
373
|
background-color: ${t.colorFillAlter};
|
|
@@ -408,7 +408,7 @@
|
|
|
408
408
|
}
|
|
409
409
|
`,noStatusButtonClass:e`
|
|
410
410
|
border-width: 2px;
|
|
411
|
-
`}));function Pe(e){const l=e,{status:t,statusMap:o}=l,n=Z(l,["status","statusMap"]),{styles:s}=on();let a=null;if(typeof t!="undefined"&&(o!=null&&o[t])){const{icon:c,color:
|
|
411
|
+
`}));function Pe(e){const l=e,{status:t,statusMap:o}=l,n=Z(l,["status","statusMap"]),{styles:s}=on();let a=null;if(typeof t!="undefined"&&(o!=null&&o[t])){const{icon:c,color:u}=o[t];a=r.jsx(b.Tag,{color:u,children:c})}return r.jsx(b.Button,F(C({},n),{shape:"circle",size:"small",className:tn(a?s.statusButtonClass:s.noStatusButtonClass,e.className),children:a}))}const pe={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},He=[{value:pe.QUEUEING,label:`{{t("Queueing", { ns: "${p}" })}}`,color:"blue",icon:r.jsx(I.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${p}" })}}`},{value:pe.STARTED,label:`{{t("On going", { ns: "${p}" })}}`,color:"gold",icon:r.jsx(I.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${p}" })}}`},{value:pe.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:r.jsx(I.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${p}" })}}`},{value:pe.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:r.jsx(I.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${p}" })}}`},{value:pe.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:r.jsx(I.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${p}" })}}`},{value:pe.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:r.jsx(I.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${p}" })}}`},{value:pe.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(I.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${p}" })}}`},{value:pe.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(I.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${p}" })}}`},{value:pe.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(I.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${p}" })}}`}],Ge=He.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),le={PENDING:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},bt=[{value:le.PENDING,label:`{{t("Pending", { ns: "${p}" })}}`,color:"gold",icon:r.jsx(I.ClockCircleOutlined,{})},{value:le.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:r.jsx(I.CheckOutlined,{})},{value:le.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:r.jsx(I.ExclamationOutlined,{})},{value:le.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:r.jsx(I.CloseOutlined,{})},{value:le.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:r.jsx(I.MinusOutlined,{rotate:90})},{value:le.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(I.MinusOutlined,{rotate:45})},{value:le.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(I.MinusOutlined,{})},{value:le.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(I.RedoOutlined,{})}],qe=bt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});class ye{constructor(){w(this,"title");w(this,"type");w(this,"group");w(this,"description");w(this,"options");w(this,"fieldset");w(this,"view");w(this,"scope");w(this,"components");w(this,"end")}createDefaultConfig(){return{}}}function nn(){const e=j.useForm(),t=i.useAPIClient(),o=i.useActionContext(),{refresh:n}=i.useResourceActionContext(),s=ve(),{workflow:a}=q();return{run(){return G(this,null,function*(){var c,u;if(a.executed){b.message.error($("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(u=(c=t.resource("flow_nodes")).update)==null?void 0:u.call(c,{filterByTk:s.id,values:{config:e.values}}),e.setInitialValues(mt.toJS(e.values)),o.setFormValueChanged(!1),o.setVisible(!1),n()})}}}const vt=y.createContext({});function ve(){return y.useContext(vt)}function Me(e=[]){const t=ve();return e.some(o=>ke.get(t.config,o)!=null)}function Wt(e,t){const o=[];if(!e)return[];for(let n=e.upstream;n;n=n.upstream)(typeof t!="function"||t(n))&&o.push(n);return o}function Lt(e){const t=[];if(!e)return[];for(let o=e;o;o=o.upstream)o.upstream&&o.branchIndex!=null&&t.push(o.upstream);return t}function zt({data:e}){const{styles:t}=ne(),{getAriaLabel:o}=yt(e),n=i.usePlugin(de),{Component:s=xt,end:a}=n.instructions.get(e.type);return r.jsx(vt.Provider,{value:e,children:r.jsxs("div",{className:i.cx(t.nodeBlockClass),children:[r.jsx(s,{data:e}),!a||typeof a=="function"&&!a(e)?r.jsx(Bt,{"aria-label":o(),upstream:e}):r.jsx("div",{className:"end-sign",children:r.jsx(I.CloseOutlined,{})})]})})}function Jt(){var d;const{t:e}=Q.useTranslation(),t=i.useAPIClient(),{workflow:o,nodes:n,refresh:s}=(d=q())!=null?d:{},a=ve(),{modal:l}=b.App.useApp();if(!o)return null;const c=t.resource("flow_nodes");function u(){return G(this,null,function*(){function f(){return G(this,null,function*(){var m;yield(m=c.destroy)==null?void 0:m.call(c,{filterByTk:a.id}),s()})}const h=n.filter(m=>m===a?!1:U.parse(m.config).parameters.filter(({key:M})=>M.startsWith(`$jobsMapByNodeKey.${a.key}.`)||M===`$jobsMapByNodeKey.${a.key}`).length);if(h.length){l.error({title:$("Can not delete"),content:$("The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",{nodes:h.map(m=>`#${m.id}`).join(", ")})});return}const g=!n.find(m=>m.upstream===a&&m.branchIndex!=null)?e("Are you sure you want to delete it?"):$("This node contains branches, deleting will also be preformed to them, are you sure?");l.confirm({title:e("Delete"),content:g,onOk:f})})}return o.executed?null:r.jsx(b.Button,{type:"text",shape:"circle",icon:r.jsx(I.DeleteOutlined,{}),onClick:u,className:"workflow-node-remove-button"})}function Ut(){var a;const{execution:e,setViewJob:t}=q(),{jobs:o}=(a=ve())!=null?a:{},{styles:n}=ne();if(!e)return null;if(!o.length)return r.jsx(Pe,{className:n.nodeJobButtonClass,disabled:!0});function s({key:l}){const c=o.find(u=>u.id==l);t(c)}return o.length>1?r.jsx(b.Dropdown,{menu:{items:o.map(l=>({key:l.id,label:r.jsxs(r.Fragment,{children:[r.jsx(Pe,{statusMap:qe,status:l.status}),r.jsx("time",{children:U.str2moment(l.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),onClick:s,className:n.dropdownClass},children:r.jsx(Pe,{statusMap:qe,status:o[o.length-1].status,className:n.nodeJobButtonClass})}):r.jsx(Pe,{statusMap:qe,status:o[0].status,onClick:()=>t(o[0]),className:n.nodeJobButtonClass})}function rn(){return{form:j.useForm()}}function xt(e){var T,P;const{data:t,children:o}=e,n=i.useCompile(),s=i.useAPIClient(),{workflow:a,refresh:l}=(T=q())!=null?T:{},{styles:c}=ne(),d=i.usePlugin(de).instructions.get(t.type),f=a.executed?'{{t("View")}}':'{{t("Configure")}}',h=n(d.title),[x,g]=y.useState((P=t.title)!=null?P:h),[m,k]=y.useState(!1),[O,M]=y.useState(!1),S=y.useMemo(()=>{const A=ke.cloneDeep(t.config);return ie.createForm({initialValues:A,disabled:a.executed})},[t,a]),N=y.useCallback(A=>{k(A),A||S.reset()},[S]),W=y.useCallback(function(A){return G(this,null,function*(){var L,H;const E=A||h;g(E),E!==t.title&&(yield(H=(L=s.resource("flow_nodes")).update)==null?void 0:H.call(L,{filterByTk:t.id,values:{title:E}}),l())})},[t]),J=y.useCallback(function(A){if(A.target===A.currentTarget){k(!0);return}const E=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let L=A.target;L&&L!==A.currentTarget&&L!==document.documentElement;L=L.parentNode)if(Array.from(L.classList).some(H=>E.has(H))){k(!0),A.stopPropagation();return}},[]);return r.jsxs("div",{className:i.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:[r.jsxs("div",{role:"button","aria-label":`${h}-${x}`,className:i.cx(c.nodeCardClass,{configuring:m}),onClick:J,children:[r.jsxs("div",{className:i.cx(c.nodeMetaClass,"workflow-node-meta"),children:[r.jsx(b.Tag,{children:h}),r.jsx("span",{className:"workflow-node-id",children:t.id})]}),r.jsx(b.Input.TextArea,{disabled:a.executed,value:x,onChange:A=>g(A.target.value),onBlur:A=>W(A.target.value),autoSize:!0}),r.jsx(Jt,{}),r.jsx(Ut,{}),r.jsx(i.ActionContextProvider,{value:{visible:m,setVisible:N,formValueChanged:O,setFormValueChanged:M},children:r.jsx(i.FormProvider,{form:S,children:r.jsx(i.SchemaComponent,{distributed:!1,scope:F(C({},d.scope),{useFormProviderProps:rn,useUpdateAction:nn}),components:d.components,schema:{type:"void",properties:F(C({},d.view?{view:d.view}:{}),{button:{type:"void","x-content":f,"x-component":b.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},[t.id]:{type:"void",title:r.jsxs("div",{className:i.css`
|
|
412
412
|
display: flex;
|
|
413
413
|
justify-content: space-between;
|
|
414
414
|
|
|
@@ -423,7 +423,7 @@
|
|
|
423
423
|
code {
|
|
424
424
|
font-weight: normal;
|
|
425
425
|
}
|
|
426
|
-
`,children:[r.jsx("strong",{children:t.title}),r.jsx(b.Tooltip,{title
|
|
426
|
+
`,children:[r.jsx("strong",{children:t.title}),r.jsx(b.Tooltip,{title:$("Variable key of node"),children:r.jsx(b.Tag,{children:r.jsx("code",{children:t.key})})})]}),"x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps","x-component":"Action.Drawer",properties:F(C({},d.description?{description:{type:"void","x-component":Vt,"x-component-props":{label:$("Node type"),title:d.title,description:d.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
|
|
427
427
|
.ant-input,
|
|
428
428
|
.ant-select,
|
|
429
429
|
.ant-cascader-picker,
|
|
@@ -435,34 +435,34 @@
|
|
|
435
435
|
min-width: 6em;
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
|
-
`},properties:
|
|
438
|
+
`},properties:d.fieldset},actions:a.executed?null:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useUpdateAction }}"}}}}})}})}})})})]}),o]})}function Ke({from:e=null,entry:t=null,branchIndex:o=null,controller:n=null,className:s,end:a}){const{styles:l}=ne(),{getAriaLabel:c}=yt(e,o),u=[];for(let d=t;d;d=d.downstream)u.push(d);return r.jsxs("div",{className:i.cx("workflow-branch",l.branchClass,s),children:[r.jsx("div",{className:"workflow-branch-lines"}),n,r.jsx(Bt,{"aria-label":c(),upstream:e,branchIndex:o}),r.jsx("div",{className:"workflow-node-list",children:u.map(d=>r.jsx(zt,{data:d},d.id))}),a?r.jsx("div",{className:"end-sign",children:r.jsx(I.CloseOutlined,{})}):null]})}function sn(){var a;const e=j.useForm(),t=i.useAPIClient(),{workflow:o}=(a=q())!=null?a:{},n=i.useActionContext(),{refresh:s}=i.useResourceActionContext();return{run(){return G(this,null,function*(){if(o.executed){b.message.error($("Trigger in executed workflow cannot be modified"));return}yield e.submit(),yield t.resource("workflows").update({filterByTk:o.id,values:{config:e.values}}),n.setFormValueChanged(!1),n.setVisible(!1),s()})}}}class wt{constructor(){w(this,"sync");w(this,"title");w(this,"description");w(this,"fieldset");w(this,"view");w(this,"scope");w(this,"components");w(this,"initializers");w(this,"isActionTriggerable")}}function ln(){const e=i.useCompile(),{workflow:t,execution:o}=q(),{styles:n}=ne(),s=Ct();return o?r.jsx(i.SchemaComponent,{schema:{type:"void",name:"execution","x-component":"Action","x-component-props":{title:r.jsx(I.InfoOutlined,{}),shape:"circle",size:"small",className:n.nodeJobButtonClass,type:"primary"},properties:{[o.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:r.jsxs("div",{className:i.cx(n.nodeTitleClass),children:[r.jsx(b.Tag,{children:e(s.title)}),r.jsx("strong",{children:t.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",o.id]})]}),properties:{createdAt:{type:"string",title:`{{t("Triggered at", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},context:{type:"object",title:`{{t("Trigger variables", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:i.css`
|
|
439
439
|
padding: 1em;
|
|
440
440
|
background-color: #eee;
|
|
441
|
-
`},"x-read-pretty":!0}}}}}}):null}function an(){return{form:j.useForm()}}const cn=()=>{const e=i.useAPIClient(),{workflow:t,refresh:o}=q(),[n,s]=y.useState(""),[a,l]=y.useState(!1),[c,
|
|
441
|
+
`},"x-read-pretty":!0}}}}}}):null}function an(){return{form:j.useForm()}}const cn=()=>{const e=i.useAPIClient(),{workflow:t,refresh:o}=q(),[n,s]=y.useState(""),[a,l]=y.useState(!1),[c,u]=y.useState(!1),{styles:d}=ne(),f=i.useCompile(),h=Ct(),x=f(h.title),{fieldset:g,scope:m,components:k}=h,O=t.executed?'{{t("View")}}':'{{t("Configure")}}',M=$("Trigger");y.useEffect(()=>{var T,P;t&&s((P=(T=t.triggerTitle)!=null?T:t.title)!=null?P:x)},[t]);const S=y.useMemo(()=>{const T=ke.cloneDeep(t.config);return ie.createForm({initialValues:T,disabled:t.executed})},[t]),N=y.useCallback(T=>{l(T),T||S.reset()},[S]),W=y.useCallback(function(T){return G(this,null,function*(){const P=T||x;s(P),P!==t.triggerTitle&&(yield e.resource("workflows").update({filterByTk:t.id,values:{triggerTitle:P}}),o())})},[t]),J=y.useCallback(function(T){var A;if(T.target===T.currentTarget){l(!0);return}const P=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let E=T.target;E&&E!==T.currentTarget;E=E.parentNode)if(Array.from((A=E.classList)!=null?A:[]).some(L=>P.has(L))){l(!0),T.stopPropagation();return}},[]);return r.jsxs("div",{role:"button","aria-label":`${M}-${n}`,className:i.cx(d.nodeCardClass),onClick:J,children:[r.jsx("div",{className:i.cx(d.nodeMetaClass,"workflow-node-meta"),children:r.jsx(b.Tag,{color:"gold",children:M})}),r.jsx("div",{children:r.jsx(b.Input.TextArea,{value:n,onChange:T=>s(T.target.value),onBlur:T=>W(T.target.value),autoSize:!0,disabled:t.executed})}),r.jsx(ln,{}),r.jsx(i.ActionContextProvider,{value:{visible:a,setVisible:N,formValueChanged:c,setFormValueChanged:u},children:r.jsx(i.FormProvider,{form:S,children:r.jsx(i.SchemaComponent,{scope:F(C({},m),{useFormProviderProps:an}),components:k,schema:{name:`workflow-trigger-${t.id}`,type:"void",properties:{config:{type:"void","x-content":O,"x-component":b.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:F(C({},h.description?{description:{type:"void","x-component":Vt,"x-component-props":{label:$("Trigger type"),title:h.title,description:h.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
|
|
442
442
|
.ant-select.auto-width {
|
|
443
443
|
width: auto;
|
|
444
444
|
min-width: 6em;
|
|
445
445
|
}
|
|
446
|
-
`},properties:g},actions:C({},t.executed?{}:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:sn}}}})})}}}})})})]})};function Ct(){const e=i.usePlugin(
|
|
446
|
+
`},properties:g},actions:C({},t.executed?{}:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:sn}}}})})}}}})})})]})};function Ct(){const e=i.usePlugin(de),{workflow:t}=q();return e.triggers.get(t.type)}function Ht({entry:e}){const{styles:t}=ne(),{workflow:o}=q(),[n,s]=y.useState(100);return r.jsxs("div",{className:"workflow-canvas-wrapper",children:[r.jsx(Zo,{FallbackComponent:i.ErrorFallback,onError:console.error,children:r.jsx("div",{className:"workflow-canvas",style:{zoom:n/100},children:r.jsx("div",{className:i.cx(t.branchBlockClass,i.css`
|
|
447
447
|
margin-top: 0 !important;
|
|
448
|
-
`),children:r.jsxs("div",{className:t.branchClass,children:[o!=null&&o.executed?r.jsx(b.Alert,{type:"warning",message
|
|
448
|
+
`),children:r.jsxs("div",{className:t.branchClass,children:[o!=null&&o.executed?r.jsx(b.Alert,{type:"warning",message:$("Executed workflow cannot be modified. Could be copied to a new version to modify."),showIcon:!0,className:i.css`
|
|
449
449
|
margin-bottom: 1em;
|
|
450
450
|
`}):null,r.jsx(cn,{}),r.jsx("div",{className:i.cx(t.branchBlockClass,i.css`
|
|
451
451
|
margin-top: 0 !important;
|
|
452
|
-
`),children:r.jsx(Ke,{entry:e})}),r.jsx("div",{className:t.terminalClass,children:N("End")})]})})})}),r.jsx("div",{className:"workflow-canvas-zoomer",children:r.jsx(b.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:n,onChange:s})})]})}function kt(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 St(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{St(e.properties[o],t)})}function xe(e){return`/admin/workflow/workflows/${e}`}function Ye(e){return`/admin/workflow/executions/${e}`}function un(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const s=o.get(n.nodeId);s.jobs.push(n),n.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((s,a)=>s.id-a.id)})}function dn(){const{instructions:e}=i.usePlugin(ue),t=i.useCompile(),{viewJob:o,setViewJob:n}=q(),{styles:s}=ne(),{node:a={}}=o!=null?o:{},l=e.get(a.type);return r.jsx(i.ActionContextProvider,{value:{visible:!!o,setVisible:n},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`${o==null?void 0:o.id}-${o==null?void 0:o.updatedAt}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:r.jsxs("div",{className:s.nodeTitleClass,children:[r.jsx(b.Tag,{children:t(l==null?void 0:l.title)}),r.jsx("strong",{children:a.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",a.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:bt,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:s.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function pn(e){const{execution:t}=q(),o=i.useAPIClient(),n=oe.useNavigate(),{styles:s}=ne(),[a,l]=y.useState([]),[c,d]=y.useState([]);y.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{l(f.data)}).catch(()=>{})},[t]),y.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{d(f.data.reverse())}).catch(()=>{})},[t]);const u=y.useCallback(({key:f})=>{f!=t.id&&n(Ye(f))},[t]);return t?r.jsx(b.Dropdown,{menu:{onClick:u,defaultSelectedKeys:[`${t.id}`],className:i.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...a].map(f=>({key:f.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${f.id}`}),r.jsx("time",{children:U.str2moment(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(Pe,{statusMap:Ge,status:f.status})})}))},children:r.jsxs(b.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(D.DownOutlined,{})]})}):null}function mn(){var S;const{t:e}=Q.useTranslation(),t=i.useCompile(),{data:o,loading:n,refresh:s}=i.useResourceActionContext(),{setTitle:a}=i.useDocumentTitle(),[l,c]=y.useState(null),d=i.useApp(),u=i.useAPIClient();y.useEffect(()=>{var P;const{workflow:T}=(P=o==null?void 0:o.data)!=null?P:{};a==null||a(`${T!=null&&T.title?`${T.title} - `:""}${N("Execution history")}`)},[o==null?void 0:o.data]);const f=y.useCallback(()=>{b.Modal.confirm({title:N("Cancel the execution"),icon:r.jsx(D.ExclamationCircleFilled,{}),content:N("Are you sure you want to cancel the execution?"),onOk:()=>{u.resource("executions").cancel({filterByTk:o==null?void 0:o.data.id}).then(()=>{b.message.success(e("Operation succeeded")),s()}).catch(T=>{console.error(T.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return n?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const I=(S=o==null?void 0:o.data)!=null?S:{},{jobs:h=[],workflow:W={}}=I,J=W,{nodes:x=[],revisions:g=[]}=J,m=Z(J,["nodes","revisions"]),k=Z(I,["jobs","workflow"]);kt(x),un(x,h);const O=x.find(T=>!T.upstream),E=Ge[k.status];return r.jsxs(Ie.Provider,{value:{workflow:m.type?m:null,nodes:x,execution:k,viewJob:l,setViewJob:c},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(b.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:d.pluginSettingsManager.getRoutePath("workflow"),children:N("Workflow")})},{title:r.jsx(b.Tooltip,{title:`Key: ${m.key}`,children:r.jsx(oe.Link,{to:xe(m.id),children:m.title})})},{title:r.jsx(pn,{})}]})}),r.jsxs("aside",{children:[r.jsx(b.Tag,{color:E.color,children:t(E.label)}),k.status?null:r.jsx(b.Tooltip,{title:N("Cancel the execution"),children:r.jsx(b.Button,{type:"link",danger:!0,onClick:f,shape:"circle",size:"small",icon:r.jsx(D.StopOutlined,{})})}),r.jsx("time",{children:U.str2moment(k.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(Ht,{entry:O}),r.jsx(dn,{})]})}const Gt=()=>{const e=oe.useParams(),{styles:t}=ne();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`execution_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:e,appends:["jobs","workflow","workflow.nodes"]}}},"x-component":"ExecutionCanvas"}}},components:{ExecutionCanvas:mn}})})},qt=()=>{const{t:e}=Q.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext();return r.jsx(oe.Link,{to:Ye(t),onClick:()=>o(!1),children:e("View")})},fn={name:"execution-executions",fields:[{interface:"id",type:"bigInt",name:"id",uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${p}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${p}" })}}`,"x-component"({value:e}){const{setVisible:t}=i.useActionContext();return r.jsx(oe.Link,{to:xe(e),onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${p}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:He}}]},Kt={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${p}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:fn,resourceName:"executions",request:{resource:"executions",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"],filter:{}}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=Q.useTranslation(),{refresh:t,defaultRequest:o}=i.useResourceActionContext(),{resource:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext();return{run(){return G(this,null,function*(){var l;yield n.destroy({filter:(l=o.params)==null?void 0:l.filter}),b.message.success(e("Operation succeeded")),t(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${p}" })}}`,content:`{{t("Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?", { ns: "${p}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:`{{t("Status", { ns: "${p}" })}}`,properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void","x-component":"ExecutionLink"}}}}}}}}}}};function Yt(e){var a;const o=i.useCompile()(e.label),n=y.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:s}=(a=Ge[e.value])!=null?a:{};return r.jsx(b.Tag,{color:s,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function hn(e){const t=i.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Yt,C({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function gn(t){var e=Z(t,[]);const o=e.multiple?"multiple":null;return r.jsx(b.Select,F(C({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Yt,children:He.filter(n=>!!n.value&&n.value!==pe.ABORTED).map(n=>r.jsx(b.Select.Option,F(C({},n),{children:r.jsx(hn,C({},n))}),n.value))}))}function _t(e){const{t}=Q.useTranslation(),{refresh:o}=i.useResourceActionContext(),{resource:n}=i.useResourceContext(),s=i.useRecord(),a=y.useCallback(()=>{b.Modal.confirm({title:N("Cancel the execution"),icon:r.jsx(D.ExclamationCircleFilled,{}),content:N("Are you sure you want to cancel the execution?"),onOk:()=>{n.cancel({filterByTk:s.id}).then(()=>{b.message.success(t("Operation succeeded")),o()}).catch(l=>{console.error(l.data.error)})}})},[s]);return r.jsxs("div",{className:i.css`
|
|
452
|
+
`),children:r.jsx(Ke,{entry:e})}),r.jsx("div",{className:t.terminalClass,children:$("End")})]})})})}),r.jsx("div",{className:"workflow-canvas-zoomer",children:r.jsx(b.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:n,onChange:s})})]})}function kt(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 St(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{St(e.properties[o],t)})}function xe(e){return`/admin/workflow/workflows/${e}`}function Ye(e){return`/admin/workflow/executions/${e}`}function dn(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const s=o.get(n.nodeId);s.jobs.push(n),n.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((s,a)=>s.id-a.id)})}function un(){const{instructions:e}=i.usePlugin(de),t=i.useCompile(),{viewJob:o,setViewJob:n}=q(),{styles:s}=ne(),{node:a={}}=o!=null?o:{},l=e.get(a.type);return r.jsx(i.ActionContextProvider,{value:{visible:!!o,setVisible:n},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`${o==null?void 0:o.id}-${o==null?void 0:o.updatedAt}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:r.jsxs("div",{className:s.nodeTitleClass,children:[r.jsx(b.Tag,{children:t(l==null?void 0:l.title)}),r.jsx("strong",{children:a.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",a.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:bt,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:s.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function pn(e){const{execution:t}=q(),o=i.useAPIClient(),n=oe.useNavigate(),{styles:s}=ne(),[a,l]=y.useState([]),[c,u]=y.useState([]);y.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{l(f.data)}).catch(()=>{})},[t]),y.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{u(f.data.reverse())}).catch(()=>{})},[t]);const d=y.useCallback(({key:f})=>{f!=t.id&&n(Ye(f))},[t]);return t?r.jsx(b.Dropdown,{menu:{onClick:d,defaultSelectedKeys:[`${t.id}`],className:i.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...a].map(f=>({key:f.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${f.id}`}),r.jsx("time",{children:U.str2moment(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(Pe,{statusMap:Ge,status:f.status})})}))},children:r.jsxs(b.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(I.DownOutlined,{})]})}):null}function mn(){var S;const{t:e}=Q.useTranslation(),t=i.useCompile(),{data:o,loading:n,refresh:s}=i.useResourceActionContext(),{setTitle:a}=i.useDocumentTitle(),[l,c]=y.useState(null),u=i.useApp(),d=i.useAPIClient();y.useEffect(()=>{var P;const{workflow:T}=(P=o==null?void 0:o.data)!=null?P:{};a==null||a(`${T!=null&&T.title?`${T.title} - `:""}${$("Execution history")}`)},[o==null?void 0:o.data]);const f=y.useCallback(()=>{b.Modal.confirm({title:$("Cancel the execution"),icon:r.jsx(I.ExclamationCircleFilled,{}),content:$("Are you sure you want to cancel the execution?"),onOk:()=>{d.resource("executions").cancel({filterByTk:o==null?void 0:o.data.id}).then(()=>{b.message.success(e("Operation succeeded")),s()}).catch(T=>{console.error(T.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return n?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found"});const N=(S=o==null?void 0:o.data)!=null?S:{},{jobs:h=[],workflow:W={}}=N,J=W,{nodes:x=[],revisions:g=[]}=J,m=Z(J,["nodes","revisions"]),k=Z(N,["jobs","workflow"]);kt(x),dn(x,h);const O=x.find(T=>!T.upstream),M=Ge[k.status];return r.jsxs(Ie.Provider,{value:{workflow:m.type?m:null,nodes:x,execution:k,viewJob:l,setViewJob:c},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(b.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:u.pluginSettingsManager.getRoutePath("workflow"),children:$("Workflow")})},{title:r.jsx(b.Tooltip,{title:`Key: ${m.key}`,children:r.jsx(oe.Link,{to:xe(m.id),children:m.title})})},{title:r.jsx(pn,{})}]})}),r.jsxs("aside",{children:[r.jsx(b.Tag,{color:M.color,children:t(M.label)}),k.status?null:r.jsx(b.Tooltip,{title:$("Cancel the execution"),children:r.jsx(b.Button,{type:"link",danger:!0,onClick:f,shape:"circle",size:"small",icon:r.jsx(I.StopOutlined,{})})}),r.jsx("time",{children:U.str2moment(k.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(Ht,{entry:O}),r.jsx(un,{})]})}const Gt=()=>{const e=oe.useParams(),{styles:t}=ne();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`execution_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:e,appends:["jobs","workflow","workflow.nodes"]}}},"x-component":"ExecutionCanvas"}}},components:{ExecutionCanvas:mn}})})},qt=()=>{const{t:e}=Q.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext();return r.jsx(oe.Link,{to:Ye(t),onClick:()=>o(!1),children:e("View")})},fn={name:"execution-executions",fields:[{interface:"id",type:"bigInt",name:"id",uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${p}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${p}" })}}`,"x-component"({value:e}){const{setVisible:t}=i.useActionContext();return r.jsx(oe.Link,{to:xe(e),onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${p}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:He}}]},Kt={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${p}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:fn,resourceName:"executions",request:{resource:"executions",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"],filter:{}}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=Q.useTranslation(),{refresh:t,defaultRequest:o}=i.useResourceActionContext(),{resource:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext();return{run(){return G(this,null,function*(){var l;yield n.destroy({filter:(l=o.params)==null?void 0:l.filter}),b.message.success(e("Operation succeeded")),t(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${p}" })}}`,content:`{{t("Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?", { ns: "${p}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:`{{t("Status", { ns: "${p}" })}}`,properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void","x-component":"ExecutionLink"}}}}}}}}}}};function Yt(e){var a;const o=i.useCompile()(e.label),n=y.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:s}=(a=Ge[e.value])!=null?a:{};return r.jsx(b.Tag,{color:s,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function hn(e){const t=i.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Yt,C({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function gn(t){var e=Z(t,[]);const o=e.multiple?"multiple":null;return r.jsx(b.Select,F(C({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Yt,children:He.filter(n=>!!n.value&&n.value!==pe.ABORTED).map(n=>r.jsx(b.Select.Option,F(C({},n),{children:r.jsx(hn,C({},n))}),n.value))}))}function _t(e){const{t}=Q.useTranslation(),{refresh:o}=i.useResourceActionContext(),{resource:n}=i.useResourceContext(),s=i.useRecord(),a=y.useCallback(()=>{b.Modal.confirm({title:$("Cancel the execution"),icon:r.jsx(I.ExclamationCircleFilled,{}),content:$("Are you sure you want to cancel the execution?"),onOk:()=>{n.cancel({filterByTk:s.id}).then(()=>{b.message.success(t("Operation succeeded")),o()}).catch(l=>{console.error(l.data.error)})}})},[s]);return r.jsxs("div",{className:i.css`
|
|
453
453
|
display: flex;
|
|
454
|
-
`,children:[e.children,s.status?null:r.jsx(b.Tooltip,{title:N("Cancel the execution"),children:r.jsx(b.Button,{type:"link",danger:!0,onClick:a,shape:"circle",size:"small",icon:r.jsx(D.StopOutlined,{})})})]})}function Zt(){const e=i.useResourceActionContext();return{onClick(){return G(this,null,function*(){var o;(o=e==null?void 0:e.refresh)==null||o.call(e)})}}}function yn(n){var s=n,{request:e,filter:t={}}=s,o=Z(s,["request","filter"]);var c;const{workflow:a}=q(),l=F(C({},o),{request:F(C({},e),{params:F(C({},e==null?void 0:e.params),{filter:F(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,C({},l))}function bn(){var T;const e=oe.useNavigate(),{t}=Q.useTranslation(),o=i.useApp(),{data:n,refresh:s,loading:a}=i.useResourceActionContext(),{resource:l}=i.useResourceContext(),{setTitle:c}=i.useDocumentTitle(),[d,u]=y.useState(!1),{styles:f}=ne(),{modal:h}=b.App.useApp();if(y.useEffect(()=>{var M;const{title:A}=(M=n==null?void 0:n.data)!=null?M:{};c==null||c(`${N("Workflow")}${A?`: ${A}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return a?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found",extra:r.jsx(b.Button,{onClick:()=>e(-1),children:N("Go back")})});const P=(T=n==null?void 0:n.data)!=null?T:{},{nodes:x=[],revisions:g=[]}=P,m=Z(P,["nodes","revisions"]);kt(x);const k=x.find(A=>!A.upstream);function O({key:A}){A!=m.id&&e(xe(A))}function E(A){return G(this,null,function*(){yield l.update({filterByTk:m.id,values:{enabled:A}}),s()})}function S(){return G(this,null,function*(){const{data:{data:A}}=yield l.revision({filterByTk:m.id,filter:{key:m.key}});b.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${A.id}`)})}function I(){return G(this,null,function*(){const A=m.current?N("Delete a main version will cause all other revisions to be deleted too."):"";h.confirm({title:t("Are you sure you want to delete it?"),content:A,onOk(){return G(this,null,function*(){var z;yield l.destroy({filterByTk:m.id}),b.message.success(t("Operation succeeded")),e(m.current?o.pluginSettingsManager.getRoutePath("workflow"):xe((z=g.find(H=>H.current))==null?void 0:z.id))})}})})}function W(M){return G(this,arguments,function*({key:A}){switch(A){case"history":u(!0);return;case"revision":return S();case"delete":return I()}})}const J=m.executed&&!g.find(A=>!A.executed&&new Date(A.createdAt)>new Date(m.createdAt));return r.jsxs(Ie.Provider,{value:{workflow:m,nodes:x,refresh:s},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(b.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:N("Workflow")})},{title:r.jsx(b.Tooltip,{title:`Key: ${m.key}`,children:r.jsx("strong",{children:m.title})})}]})}),r.jsxs("aside",{children:[r.jsx(b.Dropdown,{className:"workflow-versions",trigger:["click"],menu:{onClick:O,defaultSelectedKeys:[`${m.id}`],className:i.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:g.sort((A,M)=>M.id-A.id).map((A,M)=>({role:"button","aria-label":`version-${M}`,key:`${A.id}`,icon:A.current?r.jsx(D.RightOutlined,{}):null,className:i.cx({executed:A.executed,unexecuted:!A.executed,enabled:A.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${A.id}`}),r.jsx("time",{children:U.str2moment(A.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(b.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:N("Version")}),r.jsx("span",{children:m!=null&&m.id?`#${m.id}`:null}),r.jsx(D.DownOutlined,{})]})}),r.jsx(b.Switch,{checked:m.enabled,onChange:E,checkedChildren:N("On"),unCheckedChildren:N("Off")}),r.jsx(b.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:N("Execution history"),disabled:!m.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:N("Copy to new version"),disabled:!J},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")}],onClick:W},children:r.jsx(b.Button,{"aria-label":"more",type:"text",icon:r.jsx(D.EllipsisOutlined,{})})}),r.jsx(i.ActionContextProvider,{value:{visible:d,setVisible:u},children:r.jsx(i.SchemaComponent,{schema:Kt,components:{ExecutionResourceProvider:yn,ExecutionLink:qt,ExecutionStatusColumn:_t},scope:{useRefreshActionProps:Zt}})})]})]}),r.jsx(Ht,{entry:k})]})}const Qt=()=>{const e=oe.useParams(),{styles:t}=ne();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:bn}})})},vn=n=>{var s=n,{request:e,filter:t={}}=s,o=Z(s,["request","filter"]);var c;const a=i.useRecord(),l=F(C({},o),{request:F(C({},e),{params:F(C({},e==null?void 0:e.params),{filter:F(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,C({},l))},xn=()=>{const{t:e}=Q.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext(),{getAriaLabel:n}=i.useGetAriaLabelOfAction("Configure");return r.jsx(oe.Link,{"aria-label":n(),to:xe(t),onClick:()=>o(!1),children:e("Configure")})};function wn(n){var s=n,{component:e="div",children:t}=s,o=Z(s,["component","children"]);const[a,l]=y.useState(!1),c=j.useFieldSchema();return r.jsxs(i.ActionContextProvider,{value:{visible:a,setVisible:l,fieldSchema:c},children:[y.createElement(e,F(C({},o),{onClick(){l(!0)}}),t),r.jsx(i.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}function Cn({data:e}){const{label:t,color:o,options:n}=e,s=i.useCompile();return r.jsxs(b.Space,{direction:"vertical",children:[r.jsx(b.Tag,{color:o,children:s(t)}),r.jsx(b.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:s(n.description)})]})}const Xt={name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Trigger type", { ns: "${p}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}",optionRender:Cn,popupMatchSelectWidth:!0,listHeight:300},required:!0}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${p}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${p}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${p}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${p}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},fe={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${p}" }) }}`,description:`{{ t("Execute workflow asynchronously or synchronously based on trigger type, and could not be changed after created.", { ns: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Asynchronously", { ns: "${p}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${p}" }) }}`},{label:`{{ t("Synchronously", { ns: "${p}" }) }}`,value:!0,tooltip:`{{ t("For user actions that require immediate feedback. Can not use asynchronous nodes in such mode, and it is not recommended to perform time-consuming operations under synchronous mode.", { ns: "${p}" }) }}`}]}},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"fieldset",properties:{deleteExecutionOnStatus:{type:"array",title:`{{ t("Auto delete history when execution is on end status", { ns: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},kn={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Xt,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:Xt},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"cm.useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},sync:{type:"void",title:`{{t("Sync", { ns: "${p}" })}}`,"x-decorator":"Tooltip","x-decorator-props":{title:`{{ t("Sync enabled status of all workflows from database", { ns: "${p}" }) }}`},"x-component":"Action","x-component-props":{icon:"SyncOutlined",useAction(){const{t:e}=Q.useTranslation(),{resource:t}=i.useResourceContext(),o=i.useResourceActionContext();return{run(){return G(this,null,function*(){yield t.sync(),yield o==null?void 0:o.refresh(),b.message.success(e("Operation succeeded"))})}}}},"x-reactions":["{{useWorkflowSyncAction}}"]},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:fe.title,type:fe.type,sync:fe.sync,description:fe.description,options:fe.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=i.useRecord();return y.createElement("a",C({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:Kt}}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{ t("Edit") }}',properties:{title:fe.title,enabled:fe.enabled,sync:fe.sync,description:fe.description,options:fe.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},revision:{type:"void",title:`{{t("Duplicate", { ns: "${p}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${p}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=Q.useTranslation(),{refresh:t}=i.useResourceActionContext(),{resource:o,targetKey:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext(),{[n]:a}=i.useRecord(),{values:l}=j.useForm();return{run(){return G(this,null,function*(){yield o.revision({filterByTk:a,values:l}),b.message.success(e("Operation succeeded")),t(),s(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"}}}}}}}}}}}};function Sn(e){const t=j.useField(),o=i.useRecord(),n=i.usePlugin(ue);return j.useFormEffects(s=>{ie.onFieldChange("type",a=>{let l=o.id||!a.value;if(a.value){const c=n.triggers.get(a.value);c.sync!=null?(l=!0,t.setValue(c.sync)):t.setInitialValue(!1)}t.setPattern(l?"disabled":"editable")})}),y.useEffect(()=>{if(o.id){t.setPattern("disabled");const s=n.triggers.get(o.type);s.sync!=null?t.setValue(s.sync):t.setInitialValue(!1)}},[o.id,t,n.triggers]),r.jsx(Te,C({},e))}function An(e){const t=i.useApp();e.visible=!!(i.usePlugin("multi-app-share-collection")||t.name!=="main")}function Fn(){const e=y.useContext(i.SchemaComponentContext),{getTriggersOptions:t}=i.usePlugin(ue);return r.jsx(b.Card,{bordered:!1,children:r.jsx(i.SchemaComponentContext.Provider,{value:F(C({},e),{designable:!1}),children:r.jsx(i.SchemaComponent,{schema:kn,components:{WorkflowLink:xn,ExecutionResourceProvider:vn,ExecutionLink:qt,OpenDrawer:wn,ExecutionStatusSelect:gn,SyncOptionSelect:Sn,ExecutionStatusColumn:_t,Tooltip:b.Tooltip},scope:{getTriggersOptions:t,useWorkflowSyncAction:An,useRefreshActionProps:Zt}})})})}function On(n){var s=n,{collection:e,dataPath:t}=s,o=Z(s,["collection","dataPath"]);const{insert:a}=i.useSchemaInitializer(),{getTemplateSchemaByMode:l}=i.useSchemaTemplateManager(),{getCollection:c}=i.useCollectionManager_deprecated(),d=i.useRecordCollectionDataSourceItems("FormItem");let u;if(typeof e=="string"){const[h,x]=i.parseCollectionName(e);u=c(x,h)}else u=e;function f(x){return G(this,arguments,function*({item:h}){const g=h.template?yield l(h):null,m={type:"void",name:ft.uid(),title:u.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:e,dataPath:t},"x-component":"CardItem","x-component-props":{title:o.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-use-component-props":"useDetailsBlockProps","x-read-pretty":!0,properties:{grid:g||{type:"void","x-component":"Grid","x-initializer":"details:configureFields",properties:{}}}}}};St(m,k=>{k["x-uid"]&&delete k["x-uid"]}),a(m)})}return r.jsx(i.SchemaInitializerItem,F(C({},o),{onClick:f,items:d}))}function Be(e){var a;const t=i.useSchemaInitializerItem(),o=(a=e==null?void 0:e.collection)!=null?a:t.collection;let n,s;if(typeof o=="string"){const l=i.parseCollectionName(o);n=l[0],s=l[1]}else s=o;return r.jsx(i.CollectionProvider_deprecated,{dataSource:n,collection:s,children:r.jsx(On,C(C({},t),e))})}function Tn(){return!0}const At=j.observer(e=>{const u=e,{filter:t=Tn}=u,o=Z(u,["filter"]),n=i.useCompile(),{getCollectionFields:s}=i.useCollectionManager_deprecated(),{values:a}=j.useForm(),[l,c]=i.parseCollectionName(a==null?void 0:a.collection),d=s(c,l);return r.jsx(b.Select,F(C({popupMatchSelectWidth:!1},o),{options:d.filter(t).map(f=>{var h;return{label:n((h=f.uiSchema)==null?void 0:h.title),value:f.name}})}))},{displayName:"FieldsSelect"}),ae={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"},Rt={type:"object",title:'{{t("Fields values")}}',description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:i.css`
|
|
454
|
+
`,children:[e.children,s.status?null:r.jsx(b.Tooltip,{title:$("Cancel the execution"),children:r.jsx(b.Button,{type:"link",danger:!0,onClick:a,shape:"circle",size:"small",icon:r.jsx(I.StopOutlined,{})})})]})}function Zt(){const e=i.useResourceActionContext();return{onClick(){return G(this,null,function*(){var o;(o=e==null?void 0:e.refresh)==null||o.call(e)})}}}function yn(n){var s=n,{request:e,filter:t={}}=s,o=Z(s,["request","filter"]);var c;const{workflow:a}=q(),l=F(C({},o),{request:F(C({},e),{params:F(C({},e==null?void 0:e.params),{filter:F(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,C({},l))}function bn(){var T;const e=oe.useNavigate(),{t}=Q.useTranslation(),o=i.useApp(),{data:n,refresh:s,loading:a}=i.useResourceActionContext(),{resource:l}=i.useResourceContext(),{setTitle:c}=i.useDocumentTitle(),[u,d]=y.useState(!1),{styles:f}=ne(),{modal:h}=b.App.useApp();if(y.useEffect(()=>{var E;const{title:A}=(E=n==null?void 0:n.data)!=null?E:{};c==null||c(`${$("Workflow")}${A?`: ${A}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return a?r.jsx(b.Spin,{}):r.jsx(b.Result,{status:"404",title:"Not found",extra:r.jsx(b.Button,{onClick:()=>e(-1),children:$("Go back")})});const P=(T=n==null?void 0:n.data)!=null?T:{},{nodes:x=[],revisions:g=[]}=P,m=Z(P,["nodes","revisions"]);kt(x);const k=x.find(A=>!A.upstream);function O({key:A}){A!=m.id&&e(xe(A))}function M(A){return G(this,null,function*(){yield l.update({filterByTk:m.id,values:{enabled:A}}),s()})}function S(){return G(this,null,function*(){const{data:{data:A}}=yield l.revision({filterByTk:m.id,filter:{key:m.key}});b.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${A.id}`)})}function N(){return G(this,null,function*(){const A=m.current?$("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:A,onOk(){return G(this,null,function*(){var L;yield l.destroy({filterByTk:m.id}),b.message.success(t("Operation succeeded")),e(m.current?o.pluginSettingsManager.getRoutePath("workflow"):xe((L=g.find(H=>H.current))==null?void 0:L.id))})}})})}function W(E){return G(this,arguments,function*({key:A}){switch(A){case"history":d(!0);return;case"revision":return S();case"delete":return N()}})}const J=m.executed&&!g.find(A=>!A.executed&&new Date(A.createdAt)>new Date(m.createdAt));return r.jsxs(Ie.Provider,{value:{workflow:m,nodes:x,refresh:s},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(b.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:$("Workflow")})},{title:r.jsx(b.Tooltip,{title:`Key: ${m.key}`,children:r.jsx("strong",{children:m.title})})}]})}),r.jsxs("aside",{children:[r.jsx(b.Dropdown,{className:"workflow-versions",trigger:["click"],menu:{onClick:O,defaultSelectedKeys:[`${m.id}`],className:i.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:g.sort((A,E)=>E.id-A.id).map((A,E)=>({role:"button","aria-label":`version-${E}`,key:`${A.id}`,icon:A.current?r.jsx(I.RightOutlined,{}):null,className:i.cx({executed:A.executed,unexecuted:!A.executed,enabled:A.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${A.id}`}),r.jsx("time",{children:U.str2moment(A.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(b.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:$("Version")}),r.jsx("span",{children:m!=null&&m.id?`#${m.id}`:null}),r.jsx(I.DownOutlined,{})]})}),r.jsx(b.Switch,{checked:m.enabled,onChange:M,checkedChildren:$("On"),unCheckedChildren:$("Off")}),r.jsx(b.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:$("Execution history"),disabled:!m.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:$("Copy to new version"),disabled:!J},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")}],onClick:W},children:r.jsx(b.Button,{"aria-label":"more",type:"text",icon:r.jsx(I.EllipsisOutlined,{})})}),r.jsx(i.ActionContextProvider,{value:{visible:u,setVisible:d},children:r.jsx(i.SchemaComponent,{schema:Kt,components:{ExecutionResourceProvider:yn,ExecutionLink:qt,ExecutionStatusColumn:_t},scope:{useRefreshActionProps:Zt}})})]})]}),r.jsx(Ht,{entry:k})]})}const Qt=()=>{const e=oe.useParams(),{styles:t}=ne();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:bn}})})},vn=n=>{var s=n,{request:e,filter:t={}}=s,o=Z(s,["request","filter"]);var c;const a=i.useRecord(),l=F(C({},o),{request:F(C({},e),{params:F(C({},e==null?void 0:e.params),{filter:F(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,C({},l))},xn=()=>{const{t:e}=Q.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext(),{getAriaLabel:n}=i.useGetAriaLabelOfAction("Configure");return r.jsx(oe.Link,{"aria-label":n(),to:xe(t),onClick:()=>o(!1),children:e("Configure")})};function wn(n){var s=n,{component:e="div",children:t}=s,o=Z(s,["component","children"]);const[a,l]=y.useState(!1),c=j.useFieldSchema();return r.jsxs(i.ActionContextProvider,{value:{visible:a,setVisible:l,fieldSchema:c},children:[y.createElement(e,F(C({},o),{onClick(){l(!0)}}),t),r.jsx(i.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}function Cn({data:e}){const{label:t,color:o,options:n}=e,s=i.useCompile();return r.jsxs(b.Space,{direction:"vertical",children:[r.jsx(b.Tag,{color:o,children:s(t)}),r.jsx(b.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:s(n.description)})]})}const Xt={name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Trigger type", { ns: "${p}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}",optionRender:Cn,popupMatchSelectWidth:!0,listHeight:300},required:!0}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${p}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${p}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${p}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${p}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},fe={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${p}" }) }}`,description:`{{ t("Execute workflow asynchronously or synchronously based on trigger type, and could not be changed after created.", { ns: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Asynchronously", { ns: "${p}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${p}" }) }}`},{label:`{{ t("Synchronously", { ns: "${p}" }) }}`,value:!0,tooltip:`{{ t("For user actions that require immediate feedback. Can not use asynchronous nodes in such mode, and it is not recommended to perform time-consuming operations under synchronous mode.", { ns: "${p}" }) }}`}]}},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"fieldset",properties:{deleteExecutionOnStatus:{type:"array",title:`{{ t("Auto delete history when execution is on end status", { ns: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},kn={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Xt,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:Xt},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"cm.useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},sync:{type:"void",title:`{{t("Sync", { ns: "${p}" })}}`,"x-decorator":"Tooltip","x-decorator-props":{title:`{{ t("Sync enabled status of all workflows from database", { ns: "${p}" }) }}`},"x-component":"Action","x-component-props":{icon:"SyncOutlined",useAction(){const{t:e}=Q.useTranslation(),{resource:t}=i.useResourceContext(),o=i.useResourceActionContext();return{run(){return G(this,null,function*(){yield t.sync(),yield o==null?void 0:o.refresh(),b.message.success(e("Operation succeeded"))})}}}},"x-reactions":["{{useWorkflowSyncAction}}"]},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:fe.title,type:fe.type,sync:fe.sync,description:fe.description,options:fe.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=i.useRecord();return y.createElement("a",C({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:Kt}}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{ t("Edit") }}',properties:{title:fe.title,enabled:fe.enabled,sync:fe.sync,description:fe.description,options:fe.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},revision:{type:"void",title:`{{t("Duplicate", { ns: "${p}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${p}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=Q.useTranslation(),{refresh:t}=i.useResourceActionContext(),{resource:o,targetKey:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext(),{[n]:a}=i.useRecord(),{values:l}=j.useForm();return{run(){return G(this,null,function*(){yield o.revision({filterByTk:a,values:l}),b.message.success(e("Operation succeeded")),t(),s(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"}}}}}}}}}}}};function Sn(e){const t=j.useField(),o=i.useRecord(),n=i.usePlugin(de);return j.useFormEffects(s=>{ie.onFieldChange("type",a=>{let l=o.id||!a.value;if(a.value){const c=n.triggers.get(a.value);c.sync!=null?(l=!0,t.setValue(c.sync)):t.setInitialValue(!1)}t.setPattern(l?"disabled":"editable")})}),y.useEffect(()=>{if(o.id){t.setPattern("disabled");const s=n.triggers.get(o.type);s.sync!=null?t.setValue(s.sync):t.setInitialValue(!1)}},[o.id,t,n.triggers]),r.jsx(Te,C({},e))}function An(e){const t=i.useApp();e.visible=!!(i.usePlugin("multi-app-share-collection")||t.name!=="main")}function Fn(){const e=y.useContext(i.SchemaComponentContext),{getTriggersOptions:t}=i.usePlugin(de);return r.jsx(b.Card,{bordered:!1,children:r.jsx(i.SchemaComponentContext.Provider,{value:F(C({},e),{designable:!1}),children:r.jsx(i.SchemaComponent,{schema:kn,components:{WorkflowLink:xn,ExecutionResourceProvider:vn,ExecutionLink:qt,OpenDrawer:wn,ExecutionStatusSelect:gn,SyncOptionSelect:Sn,ExecutionStatusColumn:_t,Tooltip:b.Tooltip},scope:{getTriggersOptions:t,useWorkflowSyncAction:An,useRefreshActionProps:Zt}})})})}function On(n){var s=n,{collection:e,dataPath:t}=s,o=Z(s,["collection","dataPath"]);const{insert:a}=i.useSchemaInitializer(),{getTemplateSchemaByMode:l}=i.useSchemaTemplateManager(),{getCollection:c}=i.useCollectionManager_deprecated(),u=i.useRecordCollectionDataSourceItems("FormItem");let d;if(typeof e=="string"){const[h,x]=i.parseCollectionName(e);d=c(x,h)}else d=e;function f(x){return G(this,arguments,function*({item:h}){const g=h.template?yield l(h):null,m={type:"void",name:ft.uid(),title:d.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:e,dataPath:t},"x-component":"CardItem","x-component-props":{title:o.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-use-component-props":"useDetailsBlockProps","x-read-pretty":!0,properties:{grid:g||{type:"void","x-component":"Grid","x-initializer":"details:configureFields",properties:{}}}}}};St(m,k=>{k["x-uid"]&&delete k["x-uid"]}),a(m)})}return r.jsx(i.SchemaInitializerItem,F(C({},o),{onClick:f,items:u}))}function Be(e){var a;const t=i.useSchemaInitializerItem(),o=(a=e==null?void 0:e.collection)!=null?a:t.collection;let n,s;if(typeof o=="string"){const l=i.parseCollectionName(o);n=l[0],s=l[1]}else s=o;return r.jsx(i.CollectionProvider_deprecated,{dataSource:n,collection:s,children:r.jsx(On,C(C({},t),e))})}function Tn(){return!0}const At=j.observer(e=>{const d=e,{filter:t=Tn}=d,o=Z(d,["filter"]),n=i.useCompile(),{getCollectionFields:s}=i.useCollectionManager_deprecated(),{values:a}=j.useForm(),[l,c]=i.parseCollectionName(a==null?void 0:a.collection),u=s(c,l);return r.jsx(b.Select,F(C({popupMatchSelectWidth:!1},o),{options:u.filter(t).map(f=>{var h;return{label:n((h=f.uiSchema)==null?void 0:h.title),value:f.name}})}))},{displayName:"FieldsSelect"}),ae={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"},Rt={type:"object",title:'{{t("Fields values")}}',description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:i.css`
|
|
455
455
|
flex-direction: column;
|
|
456
456
|
`},"x-component":"CollectionFieldset"},_e={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:e}=j.useForm(),[t,o]=i.parseCollectionName(e==null?void 0:e.collection);return{options:i.useCollectionFilterOptions(o,t),className:i.css`
|
|
457
457
|
position: relative;
|
|
458
458
|
width: 100%;
|
|
459
|
-
`}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},Nn={type:"array",title:'{{t("Sort")}}',"x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:"{{useSortableFields()}}",required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:'{{t("ASC")}}',value:"asc"},{label:'{{t("DESC")}}',value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{t("Add sort field")}}',"x-component":"ArrayItems.Addition"}}},En={type:"void",title:'{{t("Pagination")}}',"x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{page:{type:"void","x-component":"Grid.Col",properties:{page:{type:"number",title:'{{t("Page number")}}',"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:["number","null"]},default:1}}},pageSize:{type:"void","x-component":"Grid.Col",properties:{pageSize:{type:"number",title:'{{t("Page size")}}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:1,max:100},default:20}}}}}}},Ve={type:"array",title:`{{t("Preload associations", { ns: "${p}" })}}`,description:`{{t("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=j.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},Se={label:"label",value:"value",children:"children"},eo={label:`{{t("Node result", { ns: "${p}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=i.usePlugin(ue),o=ve(),n=Wt(o),s=[];return n.forEach(a=>{var d;const l=t.get(a.type),c=(d=l.useVariables)==null?void 0:d.call(l,a,e);c&&s.push(c)}),s}},to={label:`{{t("Trigger variables", { ns: "${p}" })}}`,value:"$context",useOptions(e){var s,a;const{triggers:t}=i.usePlugin(ue),{workflow:o}=q(),n=t.get(o.type);return(a=(s=n==null?void 0:n.useVariables)==null?void 0:s.call(n,o.config,e))!=null?a:null}},oo={label:`{{t("Scope variables", { ns: "${p}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=Se,current:o}=e,{instructions:n}=i.usePlugin(ue),s=ve(),a=o!=null?o:s,l=Lt(a),c=[];return l.forEach(d=>{var h,x;const u=n.get(d.type),f=(h=u.useScopeVariables)==null?void 0:h.call(u,d,e);f&&c.push({key:d.key,[t.value]:d.key,[t.label]:(x=d.title)!=null?x:`#${d.id}`,[t.children]:f})}),c}},no={label:`{{t("System variables", { ns: "${p}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=Se}){return[...!e||e.includes("date")?[{key:"now",[t.label]:N("System time"),[t.value]:"now"}]:[]]}},Ze={boolean:new Set(["checkbox"]),number:new Set(["integer","number","percent"]),string:new Set(["input","password","email","phone","select","radioGroup","text","markdown","richText","expression","time"]),date:new Set(["date","createdAt","updatedAt"])};function ro(e,t){var o,n,s,a,l,c;return typeof t=="string"?(o=Ze[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?Ft(e)?((n=t.options)==null?void 0:n.entity)&&(e.collectionName===((s=t.options)==null?void 0:s.collection)||((a=t.options)==null?void 0:a.collection)==="*"):e.isForeignKey?e.collectionName===((l=t.options)==null?void 0:l.collection)&&e.name==="id"||e.target===((c=t.options)==null?void 0:c.collection):!1:typeof t=="function"?t(e):!1}function Ft(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function Ot(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function Tt({fields:e,types:t,appends:o,depth:n=1,compile:s,getCollectionFields:a}){return e.filter(l=>{const c=t!=null&&t.length?t.some(d=>ro(l,d)):!0;if(Ft(l)){if(o===null)return n?c||Tt({fields:Nt(l.target,{compile:s,getCollectionFields:a}),types:t,depth:n-1,appends:o,compile:s,getCollectionFields:a}):!1;const d=Ot(l,o),u=o.includes(l.name);return c?u:((d==null?void 0:d.length)||u)&&Tt({fields:Nt(l.target,{compile:s,getCollectionFields:a}),types:t,appends:d,compile:s,getCollectionFields:a}).length}else return c})}function Qe(e,t){var a,l;const o=i.useCompile(),n=(l=(a=e.useOptions)==null?void 0:a.call(e,t))==null?void 0:l.filter(Boolean),{fieldNames:s}=t;return{[s.label]:o(e.label),[s.value]:e.value,key:e[s.value],[s.children]:n,disabled:!n||!n.length}}function me(e={}){var s;const t=Object.assign({},Se,(s=e.fieldNames)!=null?s:{}),o=Object.assign(e,{fieldNames:t});return[Qe(oo,o),Qe(eo,o),Qe(to,o),Qe(no,o)]}function Nt(e,{compile:t,getCollectionFields:o}){var u,f,h,x;const[n,s]=i.parseCollectionName(e),a=o(s,n),l=[],c=[];a.forEach(g=>{if(g.isForeignKey)l.push(g);else{const m=a.find(k=>k.name===g.foreignKey);m&&l.push(m),c.push(g)}});const d=ke.uniqBy(l,"name");for(let g=c.length-1;g>=0;g--){const m=c[g];if(m.type==="belongsTo"){const k=d.find(O=>O.name===m.foreignKey);k?c.splice(g,0,F(C(C({},m),k),{uiSchema:F(C({},m.uiSchema),{title:(u=k.uiSchema)!=null&&u.title?t((f=k.uiSchema)==null?void 0:f.title):k.name})})):c.splice(g,0,F(C({},m),{name:m.foreignKey,type:"bigInt",isForeignKey:!0,interface:m.interface,uiSchema:F(C({},m.uiSchema),{title:(h=m.uiSchema)!=null&&h.title?`${t((x=m.uiSchema)==null?void 0:x.title)} ID`:m.name})}))}else m.type==="context"&&m.collectionName==="users"&&c.splice(g,1)}return ke.uniqBy(c,"name").filter(g=>g.interface&&!g.hidden)}function $n(e){const t=Ot(e.field,e.appends),o=Ae(C({collection:`${e.field.dataSourceKey&&e.field.dataSourceKey!=="main"?`${e.field.dataSourceKey}:`:""}${e.field.target}`,types:e.types,appends:t,depth:e.depth-1},this));e.loadChildren=null,o.length?e.children=o:(e.isLeaf=!0,!e.types||e.types.some(s=>ro(e.field,s))||(e.disabled=!0))}function Ae(e){const{fields:t,collection:o,types:n,appends:s=[],depth:a=1,compile:l,getCollectionFields:c,fieldNames:d=Se}=e,u=t!=null?t:Nt(o,{compile:l,getCollectionFields:c}),f=$n.bind({compile:l,getCollectionFields:c,fieldNames:d});return Tt({fields:u,types:n,depth:a,appends:s,compile:l,getCollectionFields:c}).map(x=>{var O;const g=l(((O=x.uiSchema)==null?void 0:O.title)||x.name),m=Ot(x,s),k=!Ft(x)||m&&!m.length&&!s.includes(x.name)||!1;return{[d.label]:g,key:x.name,[d.value]:x.name,isLeaf:k,loadChildren:k?null:f,field:x,depth:a,appends:s,types:n}})}function je(e){const t=i.useApp(),{collectionManager:o}=t.dataSourceManager.getDataSource(e);return y.useCallback(n=>o.getCollectionFields(n),[o])}function so(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=me(e);return r.jsx(i.Variable.Input,C({scope:s},t))}function Et(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=me(e);return r.jsx(i.Variable.TextArea,C({scope:s},t))}function Dn(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=me(e);return r.jsx(i.Variable.RawTextArea,C({scope:s},t))}function In(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=me(e);return r.jsx(i.Variable.JSON,C({scope:s},t))}function Pn(){const e=i.useAPIClient(),t=j.useForm(),{field:o,__parent:n}=i.useBlockRequestContext(),{setVisible:s}=i.useActionContext(),a=oe.useNavigate(),l=j.useFieldSchema(),c=j.useField(),d=i.useCompile(),{modal:u}=b.App.useApp(),f=i.useCollectValuesToSubmit(),h=c.componentProps.filterKeys||[];return{onClick(){return G(this,null,function*(){var E,S,I;const{onSuccess:g,skipValidator:m,triggerWorkflows:k}=(E=l==null?void 0:l["x-action-settings"])!=null?E:{};m||(yield t.submit());const O=yield f();c.data=o.data||{},c.data.loading=!0;try{const W=yield e.resource("workflows").trigger({values:O,filterKeys:h,triggerWorkflows:k!=null&&k.length?k.map(J=>[J.workflowKey,J.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.loading=!1,c.data.data=W,(I=(S=n==null?void 0:n.service)==null?void 0:S.refresh)==null||I.call(S),s==null||s(!1),!(g!=null&&g.successMessage))return;g!=null&&g.manualClose?u.success({title:d(g==null?void 0:g.successMessage),onOk:()=>G(this,null,function*(){yield t.reset(),g!=null&&g.redirecting&&(g!=null&&g.redirectTo)&&(U.isURL(g.redirectTo)?window.location.href=g.redirectTo:a(g.redirectTo))})}):b.message.success(d(g==null?void 0:g.successMessage))}catch(W){c.data.loading=!1}})}}}function Mn(){var g;const e=i.useCompile(),t=i.useAPIClient(),o=i.useRecord(),n=j.useField(),s=j.useFieldSchema(),{field:a,__parent:l}=i.useBlockRequestContext(),{setVisible:c,setSubmitted:d}=i.useActionContext(),{modal:u}=b.App.useApp(),f=oe.useNavigate(),{onSuccess:h,triggerWorkflows:x}=(g=s==null?void 0:s["x-action-settings"])!=null?g:{};return{onClick(k,O){return G(this,null,function*(){n.data=a.data||{},n.data.loading=!0;try{if(yield t.resource("workflows").trigger({values:o,triggerWorkflows:x!=null&&x.length?x.map(E=>[E.workflowKey,E.context].filter(Boolean).join("!")).join(","):void 0}),O&&O(),c==null||c(!1),d==null||d(!0),!(h!=null&&h.successMessage))return;if(h!=null&&h.manualClose){let E;u.success({title:e(h==null?void 0:h.successMessage),onOk(){return G(this,null,function*(){h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(U.isURL(h.redirectTo)?window.location.href=h.redirectTo:f(h.redirectTo))})}})}else b.message.success(e(h==null?void 0:h.successMessage))}catch(E){console.error(E)}finally{n.data.loading=!1}})}}}function Bn(){const{workflow:e}=q();return!!(e!=null&&e.executed)}function io(){const{workflow:e}=q();return!!(e!=null&&e.allExecuted)}const Fe={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},Vn=[{label:`{{t("After record added", { ns: "${p}" })}}`,value:Fe.CREATED},{label:`{{t("After record updated", { ns: "${p}" })}}`,value:Fe.UPDATED},{label:`{{t("After record added or updated", { ns: "${p}" })}}`,value:Fe.SAVED},{label:`{{t("After record deleted", { ns: "${p}" })}}`,value:Fe.DELETED}];function jn(e,t){var d;const[o,n]=i.parseCollectionName(e.collection),s=i.useCompile(),a=je(o),l=[{collectionName:n,name:"data",type:"hasOne",target:n,uiSchema:{title:N("Trigger data")}}];return Ae(F(C({appends:["data",...((d=e.appends)==null?void 0:d.map(u=>`data.${u}`))||[]]},t),{fields:l,compile:s,getCollectionFields:a}))}class Wn extends wt{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:F(C({},ae),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(o){return o.options.key==="main"||o.options.isDBInstance}},"x-reactions":[...ae["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${p}" })}}`,className:"auto-width"},enum:Vn,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${p}" })}}`,description:`{{t("Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(o){return!o.hidden&&(o.uiSchema?!o.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(o.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Fe.UPDATED})}}`}}}]},condition:F(C({},_e),{title:`{{t("Only triggers when match conditions", { ns: "${p}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:F(C({},Ve),{"x-reactions":[...Ve["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Fe.DELETED})}}`}}}]})});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource,useWorkflowAnyExecuted:io});w(this,"components",{FieldsSelect:At});w(this,"useVariables",jn)}useInitializers(o){return o.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Be,collection:o.collection,dataPath:"$context.data"}:null}}const we={STATIC:0,DATE_FIELD:1};function Ln(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function lo({value:e,onChange:t}){const o=e!=null?e:{},{t:n}=Q.useTranslation(),[s,a]=y.useState(o.offset?o.offset/Math.abs(o.offset):0);return r.jsxs("fieldset",{className:i.css`
|
|
459
|
+
`}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},Nn={type:"array",title:'{{t("Sort")}}',"x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:"{{useSortableFields()}}",required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:'{{t("ASC")}}',value:"asc"},{label:'{{t("DESC")}}',value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{t("Add sort field")}}',"x-component":"ArrayItems.Addition"}}},En={type:"void",title:'{{t("Pagination")}}',"x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{page:{type:"void","x-component":"Grid.Col",properties:{page:{type:"number",title:'{{t("Page number")}}',"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:["number","null"]},default:1}}},pageSize:{type:"void","x-component":"Grid.Col",properties:{pageSize:{type:"number",title:'{{t("Page size")}}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:1,max:100},default:20}}}}}}},Ve={type:"array",title:`{{t("Preload associations", { ns: "${p}" })}}`,description:`{{t("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=j.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},Se={label:"label",value:"value",children:"children"},eo={label:`{{t("Node result", { ns: "${p}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=i.usePlugin(de),o=ve(),n=Wt(o),s=[];return n.forEach(a=>{var u;const l=t.get(a.type),c=(u=l.useVariables)==null?void 0:u.call(l,a,e);c&&s.push(c)}),s}},to={label:`{{t("Trigger variables", { ns: "${p}" })}}`,value:"$context",useOptions(e){var s,a;const{triggers:t}=i.usePlugin(de),{workflow:o}=q(),n=t.get(o.type);return(a=(s=n==null?void 0:n.useVariables)==null?void 0:s.call(n,o.config,e))!=null?a:null}},oo={label:`{{t("Scope variables", { ns: "${p}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=Se,current:o}=e,{instructions:n}=i.usePlugin(de),s=ve(),a=o!=null?o:s,l=Lt(a),c=[];return l.forEach(u=>{var h,x;const d=n.get(u.type),f=(h=d.useScopeVariables)==null?void 0:h.call(d,u,e);f&&c.push({key:u.key,[t.value]:u.key,[t.label]:(x=u.title)!=null?x:`#${u.id}`,[t.children]:f})}),c}},no={label:`{{t("System variables", { ns: "${p}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=Se}){return[...!e||e.includes("date")?[{key:"now",[t.label]:$("System time"),[t.value]:"now"}]:[]]}},Ze={boolean:new Set(["checkbox"]),number:new Set(["integer","number","percent"]),string:new Set(["input","password","email","phone","select","radioGroup","text","markdown","richText","expression","time"]),date:new Set(["date","createdAt","updatedAt"])};function ro(e,t){var o,n,s,a,l,c;return typeof t=="string"?(o=Ze[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?Ft(e)?((n=t.options)==null?void 0:n.entity)&&(e.collectionName===((s=t.options)==null?void 0:s.collection)||((a=t.options)==null?void 0:a.collection)==="*"):e.isForeignKey?e.collectionName===((l=t.options)==null?void 0:l.collection)&&e.name==="id"||e.target===((c=t.options)==null?void 0:c.collection):!1:typeof t=="function"?t(e):!1}function Ft(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function Ot(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function Tt({fields:e,types:t,appends:o,depth:n=1,compile:s,getCollectionFields:a}){return e.filter(l=>{const c=t!=null&&t.length?t.some(u=>ro(l,u)):!0;if(Ft(l)){if(o===null)return n?c||Tt({fields:Nt(l.target,{compile:s,getCollectionFields:a}),types:t,depth:n-1,appends:o,compile:s,getCollectionFields:a}):!1;const u=Ot(l,o),d=o.includes(l.name);return c?d:((u==null?void 0:u.length)||d)&&Tt({fields:Nt(l.target,{compile:s,getCollectionFields:a}),types:t,appends:u,compile:s,getCollectionFields:a}).length}else return c})}function Qe(e,t){var a,l;const o=i.useCompile(),n=(l=(a=e.useOptions)==null?void 0:a.call(e,t))==null?void 0:l.filter(Boolean),{fieldNames:s}=t;return{[s.label]:o(e.label),[s.value]:e.value,key:e[s.value],[s.children]:n,disabled:!n||!n.length}}function me(e={}){var s;const t=Object.assign({},Se,(s=e.fieldNames)!=null?s:{}),o=Object.assign(e,{fieldNames:t});return[Qe(oo,o),Qe(eo,o),Qe(to,o),Qe(no,o)]}function Nt(e,{compile:t,getCollectionFields:o}){var d,f,h,x;const[n,s]=i.parseCollectionName(e),a=o(s,n),l=[],c=[];a.forEach(g=>{if(g.isForeignKey)l.push(g);else{const m=a.find(k=>k.name===g.foreignKey);m&&l.push(m),c.push(g)}});const u=ke.uniqBy(l,"name");for(let g=c.length-1;g>=0;g--){const m=c[g];if(m.type==="belongsTo"){const k=u.find(O=>O.name===m.foreignKey);k?c.splice(g,0,F(C(C({},m),k),{uiSchema:F(C({},m.uiSchema),{title:(d=k.uiSchema)!=null&&d.title?t((f=k.uiSchema)==null?void 0:f.title):k.name})})):c.splice(g,0,F(C({},m),{name:m.foreignKey,type:"bigInt",isForeignKey:!0,interface:m.interface,uiSchema:F(C({},m.uiSchema),{title:(h=m.uiSchema)!=null&&h.title?`${t((x=m.uiSchema)==null?void 0:x.title)} ID`:m.name})}))}else m.type==="context"&&m.collectionName==="users"&&c.splice(g,1)}return ke.uniqBy(c,"name").filter(g=>g.interface&&!g.hidden)}function $n(e){const t=Ot(e.field,e.appends),o=Ae(C({collection:`${e.field.dataSourceKey&&e.field.dataSourceKey!=="main"?`${e.field.dataSourceKey}:`:""}${e.field.target}`,types:e.types,appends:t,depth:e.depth-1},this));e.loadChildren=null,o.length?e.children=o:(e.isLeaf=!0,!e.types||e.types.some(s=>ro(e.field,s))||(e.disabled=!0))}function Ae(e){const{fields:t,collection:o,types:n,appends:s=[],depth:a=1,compile:l,getCollectionFields:c,fieldNames:u=Se}=e,d=t!=null?t:Nt(o,{compile:l,getCollectionFields:c}),f=$n.bind({compile:l,getCollectionFields:c,fieldNames:u});return Tt({fields:d,types:n,depth:a,appends:s,compile:l,getCollectionFields:c}).map(x=>{var O;const g=l(((O=x.uiSchema)==null?void 0:O.title)||x.name),m=Ot(x,s),k=!Ft(x)||m&&!m.length&&!s.includes(x.name)||!1;return{[u.label]:g,key:x.name,[u.value]:x.name,isLeaf:k,loadChildren:k?null:f,field:x,depth:a,appends:s,types:n}})}function je(e){const t=i.useApp(),{collectionManager:o}=t.dataSourceManager.getDataSource(e);return y.useCallback(n=>o.getCollectionFields(n),[o])}function so(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=me(e);return r.jsx(i.Variable.Input,C({scope:s},t))}function Et(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=me(e);return r.jsx(i.Variable.TextArea,C({scope:s},t))}function Dn(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=me(e);return r.jsx(i.Variable.RawTextArea,C({scope:s},t))}function In(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=me(e);return r.jsx(i.Variable.JSON,C({scope:s},t))}function Pn(){const e=i.useAPIClient(),t=j.useForm(),{field:o,__parent:n}=i.useBlockRequestContext(),{setVisible:s}=i.useActionContext(),a=oe.useNavigate(),l=j.useFieldSchema(),c=j.useField(),u=i.useCompile(),{modal:d}=b.App.useApp(),f=i.useCollectValuesToSubmit(),h=c.componentProps.filterKeys||[];return{onClick(){return G(this,null,function*(){var M,S,N;const{onSuccess:g,skipValidator:m,triggerWorkflows:k}=(M=l==null?void 0:l["x-action-settings"])!=null?M:{};m||(yield t.submit());const O=yield f();c.data=o.data||{},c.data.loading=!0;try{const W=yield e.resource("workflows").trigger({values:O,filterKeys:h,triggerWorkflows:k!=null&&k.length?k.map(J=>[J.workflowKey,J.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.loading=!1,c.data.data=W,(N=(S=n==null?void 0:n.service)==null?void 0:S.refresh)==null||N.call(S),s==null||s(!1),!(g!=null&&g.successMessage))return;g!=null&&g.manualClose?d.success({title:u(g==null?void 0:g.successMessage),onOk:()=>G(this,null,function*(){yield t.reset(),g!=null&&g.redirecting&&(g!=null&&g.redirectTo)&&(U.isURL(g.redirectTo)?window.location.href=g.redirectTo:a(g.redirectTo))})}):b.message.success(u(g==null?void 0:g.successMessage))}catch(W){c.data.loading=!1}})}}}function Mn(){var g;const e=i.useCompile(),t=i.useAPIClient(),o=i.useRecord(),n=j.useField(),s=j.useFieldSchema(),{field:a,__parent:l}=i.useBlockRequestContext(),{setVisible:c,setSubmitted:u}=i.useActionContext(),{modal:d}=b.App.useApp(),f=oe.useNavigate(),{onSuccess:h,triggerWorkflows:x}=(g=s==null?void 0:s["x-action-settings"])!=null?g:{};return{onClick(k,O){return G(this,null,function*(){n.data=a.data||{},n.data.loading=!0;try{if(yield t.resource("workflows").trigger({values:o,triggerWorkflows:x!=null&&x.length?x.map(M=>[M.workflowKey,M.context].filter(Boolean).join("!")).join(","):void 0}),O&&O(),c==null||c(!1),u==null||u(!0),!(h!=null&&h.successMessage))return;if(h!=null&&h.manualClose){let M;d.success({title:e(h==null?void 0:h.successMessage),onOk(){return G(this,null,function*(){h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(U.isURL(h.redirectTo)?window.location.href=h.redirectTo:f(h.redirectTo))})}})}else b.message.success(e(h==null?void 0:h.successMessage))}catch(M){console.error(M)}finally{n.data.loading=!1}})}}}function Bn(){const{workflow:e}=q();return!!(e!=null&&e.executed)}function io(){const{workflow:e}=q();return!!(e!=null&&e.allExecuted)}const Fe={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},Vn=[{label:`{{t("After record added", { ns: "${p}" })}}`,value:Fe.CREATED},{label:`{{t("After record updated", { ns: "${p}" })}}`,value:Fe.UPDATED},{label:`{{t("After record added or updated", { ns: "${p}" })}}`,value:Fe.SAVED},{label:`{{t("After record deleted", { ns: "${p}" })}}`,value:Fe.DELETED}];function jn(e,t){var u;const[o,n]=i.parseCollectionName(e.collection),s=i.useCompile(),a=je(o),l=[{collectionName:n,name:"data",type:"hasOne",target:n,uiSchema:{title:$("Trigger data")}}];return Ae(F(C({appends:["data",...((u=e.appends)==null?void 0:u.map(d=>`data.${d}`))||[]]},t),{fields:l,compile:s,getCollectionFields:a}))}class Wn extends wt{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:F(C({},ae),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(o){return o.options.key==="main"||o.options.isDBInstance}},"x-reactions":[...ae["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${p}" })}}`,className:"auto-width"},enum:Vn,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${p}" })}}`,description:`{{t("Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(o){return!o.hidden&&(o.uiSchema?!o.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(o.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Fe.UPDATED})}}`}}}]},condition:F(C({},_e),{title:`{{t("Only triggers when match conditions", { ns: "${p}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:F(C({},Ve),{"x-reactions":[...Ve["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Fe.DELETED})}}`}}}]})});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource,useWorkflowAnyExecuted:io});w(this,"components",{FieldsSelect:At});w(this,"useVariables",jn)}useInitializers(o){return o.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Be,collection:o.collection,dataPath:"$context.data"}:null}}const we={STATIC:0,DATE_FIELD:1};function Ln(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function lo({value:e,onChange:t}){const o=e!=null?e:{},{t:n}=Q.useTranslation(),[s,a]=y.useState(o.offset?o.offset/Math.abs(o.offset):0);return r.jsxs("fieldset",{className:i.css`
|
|
460
460
|
display: flex;
|
|
461
461
|
gap: 0.5em;
|
|
462
|
-
`,children:[r.jsx(At,{value:o.field,onChange:l=>t(F(C({},o),{field:l})),filter:Ln,placeholder:n("Select field"),className:"auto-width"}),o.field?r.jsx(b.Select,{value:s,onChange:l=>{a(l),t(F(C({},o),{offset:Math.abs(o.offset)*l}))},options:[{value:0,label
|
|
462
|
+
`,children:[r.jsx(At,{value:o.field,onChange:l=>t(F(C({},o),{field:l})),filter:Ln,placeholder:n("Select field"),className:"auto-width"}),o.field?r.jsx(b.Select,{value:s,onChange:l=>{a(l),t(F(C({},o),{offset:Math.abs(o.offset)*l}))},options:[{value:0,label:$("Exactly at")},{value:-1,label:n("Before")},{value:1,label:n("After")}],className:"auto-width"}):null,s?r.jsxs(r.Fragment,{children:[r.jsx(b.InputNumber,{value:Math.abs(o.offset),onChange:l=>t(F(C({},o),{offset:(l!=null?l:0)*s}))}),r.jsx(b.Select,{value:o.unit||864e5,onChange:l=>t(F(C({},o),{unit:l})),options:[{value:864e5,label:$("Days")},{value:36e5,label:$("Hours")},{value:6e4,label:$("Minutes")},{value:1e3,label:$("Seconds")}],className:"auto-width"})]}):null]})}function zn({value:e,onChange:t}){const{t:o}=gt(),n=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return r.jsxs("fieldset",{className:i.css`
|
|
463
463
|
display: flex;
|
|
464
464
|
gap: 0.5em;
|
|
465
|
-
`,children:[r.jsxs(b.Select,{value:n,onChange:s=>{t(s?s==="field"?{}:new Date:null)},className:"auto-width",children:[r.jsx(b.Select.Option,{value:null,children:o("No end")}),r.jsx(b.Select.Option,{value:"field",children:o("By field")}),r.jsx(b.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(lo,{value:e,onChange:t}):null,n==="date"?r.jsx(b.DatePicker,{showTime:!0,value:Yo(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var re=function(){return re=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var s in t=arguments[o])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},re.apply(this,arguments)};function ao(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(o[n[s]]=e[n[s]])}return o}function Xe(e,t,o){if(o||arguments.length===2)for(var n,s=0,a=t.length;s<a;s++)!n&&s in t||(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}var Jn=[{name:"@yearly",value:"0 0 1 1 *"},{name:"@annually",value:"0 0 1 1 *"},{name:"@monthly",value:"0 0 1 * *"},{name:"@weekly",value:"0 0 * * 0"},{name:"@daily",value:"0 0 * * *"},{name:"@midnight",value:"0 0 * * *"},{name:"@hourly",value:"0 * * * *"}],Ce=[{type:"minutes",min:0,max:59,total:60},{type:"hours",min:0,max:23,total:24},{type:"month-days",min:1,max:31,total:31},{type:"months",min:1,max:12,total:12,alt:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]},{type:"week-days",min:0,max:6,total:7,alt:["SUN","MON","TUE","WED","THU","FRI","SAT"]}],B={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function co(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function Re(e){return e.sort(function(t,o){return t-o}),e}function uo(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function ce(e){return Object.entries(e).filter(function(t){var o=t[0],n=t[1];return o&&n}).map(function(t){return t[0]}).join(" ")}function po(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||B.errorInvalidCron})}function et(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function mo(e,t,o,n,s,a,l,c,d,u,f,h,x,g){o&&o(void 0),t(!1);var m=!1;if(!e){if(n==="always"||a&&n==="for-default-value")return;m=!0}if(!m){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void g("reboot");var k=Jn.find(function(S){return S.name===e});k&&(e=k.value)}try{var O=function(S){if(typeof S!="string")throw new Error("Invalid cron string");var I=S.replace(/\s+/g," ").trim().split(" ");if(I.length===5)return I.map(function(W,J){return function(T,P){if(T==="*"||T==="*/1")return[];var A=Re(uo(yo(function(z,H,de){if(de){z=z.toUpperCase();for(var $=0;$<de.length;$++)z=z.replace(de[$],"".concat($+H))}return z}(T,P.min,P.alt).split(",").map(function(z){var H,de=z.split("/");if(de.length>2)throw new Error('Invalid value "'.concat(T,' for "').concat(P.type,'"'));var $=de[0],V=de[1];H=$==="*"?co(P.min,P.max):function(K,Y,R){var ee=K.split("-");if(ee.length===1){var Le=et(ee[0]);if(isNaN(Le))throw new Error('Invalid value "'.concat(Y,'" for ').concat(R.type));return[Le]}if(ee.length===2){var he=et(ee[0]),Ee=et(ee[1]);if(isNaN(he)||isNaN(Ee))throw new Error('Invalid value "'.concat(Y,'" for ').concat(R.type));if(Ee<he)throw new Error('Max range is less than min range in "'.concat(K,'" for ').concat(R.type));return co(he,Ee)}throw new Error('Invalid value "'.concat(K,'" for ').concat(R.type))}($,T,P);var L=function(K,Y){if(K!==void 0){var R=et(K);if(isNaN(R)||R<1)throw new Error('Invalid interval step value "'.concat(K,'" for ').concat(Y.type));return R}}(V,P),se=function(K,Y){if(Y){var R=K[0];K=K.filter(function(ee){return ee%Y==R%Y||ee===R})}return K}(H,L);return se}).flat(),P))),M=bo(A,P);if(M!==void 0)throw new Error('Value "'.concat(M,'" out of range for ').concat(P.type));return A.length===P.total?[]:A}(W,Ce[J])});throw new Error("Invalid cron string format")}(e),E=function(S){return S[3].length>0?"year":S[2].length>0?"month":S[4].length>0?"week":S[1].length>0?"day":S[0].length>0?"hour":"minute"}(O);g(E),d(O[0]),u(O[1]),f(O[2]),h(O[3]),x(O[4])}catch(S){m=!0}}m&&(s.current=e,t(!0),po(o,l))}function fo(e,t,o,n,s,a,l){if(e==="reboot")return"@reboot";var c=function(d,u){return d.map(function(f,h){var x=Ce[h];return ho(go(f,x),x,u)})}([e!=="minute"&&a?a:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return c.join(" ")}function ho(e,t,o,n,s){var a="";if(function(c,d){return c.length===d.max-d.min+1}(e,t)||e.length===0)a="*";else{var l=function(c){if(c.length>2){var d=c[1]-c[0];if(d>1)return d}}(e);a=l&&function(c,d){for(var u=1;u<c.length;u++){var f=c[u-1];if(c[u]-f!==d)return!1}return!0}(e,l)?function(c,d,u){var f=vo(c),h=xo(c),x=c.length===(h-f)/u+1;return!!(f===d.min&&h+u>d.max&&x)}(e,t,l)?"*/".concat(l):"".concat(Oe(vo(e),t,o,n,s),"-").concat(Oe(xo(e),t,o,n,s),"/").concat(l):function(c){var d=[],u=null;return c.forEach(function(f,h,x){f!==x[h+1]-1?u!==null?(d.push([u,f]),u=null):d.push(f):u===null&&(u=f)}),d}(e).map(function(c){return Array.isArray(c)?"".concat(Oe(c[0],t,o,n,s),"-").concat(Oe(c[1],t,o,n,s)):Oe(c,t,o,n,s)}).join(",")}return a}function Oe(e,t,o,n,s){var a=e.toString(),l=t.type,c=t.alt,d=t.min,u=n&&(n===!0||n.includes(l)),f=s==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?a=c[e-d]:e<10&&(u||f)&&(a=a.padStart(2,"0")),l==="hours"&&s==="12-hour-clock"){var h=e>=12?"PM":"AM",x=e%12||12;x<10&&u&&(x=x.toString().padStart(2,"0")),a="".concat(x).concat(h)}return a}function go(e,t){var o=Re(uo(yo(e,t)));if(o.length===0)return o;var n=bo(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function yo(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function bo(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function vo(e){return e[0]}function xo(e){return e[e.length-1]}function We(e){var t=e.value,o=e.grid,n=o===void 0||o,s=e.optionsList,a=e.setValue,l=e.locale,c=e.className,d=e.humanizeLabels,u=e.disabled,f=e.readOnly,h=e.leadingZero,x=e.clockFormat,g=e.period,m=e.unit,k=e.periodicityOnDoubleClick,O=e.mode,E=ao(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($){return $.toString()})},[t]),I=y.useMemo(function(){return s?s.map(function($,V){return{value:(m.min===0?V:V+1).toString(),label:$}}):Xe([],Array(m.total),!0).map(function($,V){var L=m.min===0?V:V+1;return{value:L.toString(),label:Oe(L,m,d,h,x)}})},[s,h,d,x]),W=JSON.stringify(l),J=y.useCallback(function($){var V=$.value;if(!t||t[0]!==Number(V))return r.jsx(r.Fragment,{});var L=ho(go(t,m),m,d,h,x),se=L.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:se[1]?"".concat(l.everyText||B.everyText," ").concat(se[1]):L})},[t,W,d,h,x]),T=y.useCallback(function($){var V=Array.isArray($)?Re($):[$],L=V;t&&(L=O==="single"?[]:Xe([],t,!0),V.forEach(function(se){var K=Number(se);L=t.some(function(Y){return Y===K})?L.filter(function(Y){return Y!==K}):Re(Xe(Xe([],L,!0),[K],!1))})),L.length===m.total?a([]):a(L)},[a,t]),P=y.useCallback(function($){if($!==0&&$!==1){for(var V=m.total+m.min,L=[],se=m.min;se<V;se++)se%$==0&&L.push(se);var K=t&&L&&t.length===L.length&&t.every(function(R,ee){return R===L[ee]}),Y=L.length===I.length;a(Y||K?[]:L)}else a([])},[t,I,a]),A=y.useRef([]),M=y.useCallback(function($){if(!f){var V=A.current;V.push({time:new Date().getTime(),value:Number($)});var L=window.setTimeout(function(){k&&V.length>1&&V[V.length-1].time-V[V.length-2].time<300?V[V.length-1].value===V[V.length-2].value?P(Number($)):T([V[V.length-2].value,V[V.length-1].value]):T(Number($)),A.current=[]},300);return function(){window.clearTimeout(L)}}},[A,T,P,f,k]),z=y.useCallback(function(){f||a([])},[a,f]),H=y.useMemo(function(){var $;return ce((($={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,$))},[c]),de=y.useMemo(function(){var $;return ce((($={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(m.type)]=!0,$["react-js-cron-custom-select-dropdown"]=!0,$["react-js-cron-custom-select-dropdown-".concat(m.type)]=!0,$["react-js-cron-custom-select-dropdown-minutes-large"]=m.type==="minutes"&&g!=="hour"&&g!=="day",$["react-js-cron-custom-select-dropdown-minutes-medium"]=m.type==="minutes"&&(g==="day"||g==="hour"),$["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=m.type==="hours"&&x==="12-hour-clock",$["react-js-cron-custom-select-dropdown-grid"]=!!n,$["".concat(c,"-select-dropdown")]=!!c,$["".concat(c,"-select-dropdown-").concat(m.type)]=!!c,$))},[c,n,x,g]);return r.jsx(b.Select,re({mode:O!=="single"||k?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:S,onClear:z,tagRender:J,className:H,popupClassName:de,options:I,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:M,onDeselect:M,disabled:u,dropdownAlign:m.type!=="minutes"&&m.type!=="hours"||g==="day"||g==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(m.type)},E))}function Un(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,d=e.clockFormat,u=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=y.useMemo(function(){var g;return ce(((g={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,g["".concat(s,"-hours")]=!!s,g))},[s]);return r.jsxs("div",re({className:x},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||B.prefixHours}),r.jsx(We,{placeholder:n.emptyHours||B.emptyHours,value:t,unit:Ce[1],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:d,period:u,periodicityOnDoubleClick:f,mode:h})]}))}function Hn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,d=e.clockFormat,u=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=y.useMemo(function(){var g;return ce(((g={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,g["".concat(s,"-minutes")]=!!s,g))},[s]);return r.jsxs("div",re({className:x},{children:[u==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||B.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||B.prefixMinutes}),r.jsx(We,{placeholder:u==="hour"?n.emptyMinutesForHourPeriod||B.emptyMinutesForHourPeriod:n.emptyMinutes||B.emptyMinutes,value:t,unit:Ce[0],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:d,period:u,periodicityOnDoubleClick:f,mode:h}),u==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||B.suffixMinutesForHourPeriod})]}))}function Gn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.weekDays,l=e.disabled,c=e.readOnly,d=e.leadingZero,u=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=!a||a.length===0,g=y.useMemo(function(){var O;return ce(((O={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!x})["".concat(s,"-field")]=!!s,O["".concat(s,"-month-days")]=!!s,O))},[s,x]),m=JSON.stringify(n),k=y.useMemo(function(){return x?n.emptyMonthDays||B.emptyMonthDays:n.emptyMonthDaysShort||B.emptyMonthDaysShort},[x,m]);return!c||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?r.jsxs("div",re({className:g},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||B.prefixMonthDays}),r.jsx(We,{placeholder:k,value:t,setValue:o,unit:Ce[2],locale:n,className:s,disabled:l,readOnly:c,leadingZero:d,period:u,periodicityOnDoubleClick:f,mode:h})]})):null}function qn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.disabled,c=e.readOnly,d=e.period,u=e.periodicityOnDoubleClick,f=e.mode,h=n.months||B.months,x=y.useMemo(function(){var g;return ce(((g={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,g["".concat(s,"-months")]=!!s,g))},[s]);return r.jsxs("div",re({className:x},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||B.prefixMonths}),r.jsx(We,{placeholder:n.emptyMonths||B.emptyMonths,optionsList:h,grid:!1,value:t,unit:re(re({},Ce[3]),{alt:n.altMonths||B.altMonths}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:l,readOnly:c,period:d,periodicityOnDoubleClick:u,mode:f})]}))}function Kn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.shortcuts,d=e.allowedPeriods,u=[];d.includes("year")&&u.push({value:"year",label:n.yearOption||B.yearOption}),d.includes("month")&&u.push({value:"month",label:n.monthOption||B.monthOption}),d.includes("week")&&u.push({value:"week",label:n.weekOption||B.weekOption}),d.includes("day")&&u.push({value:"day",label:n.dayOption||B.dayOption}),d.includes("hour")&&u.push({value:"hour",label:n.hourOption||B.hourOption}),d.includes("minute")&&u.push({value:"minute",label:n.minuteOption||B.minuteOption}),d.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&u.push({value:"reboot",label:n.rebootOption||B.rebootOption});var f=y.useCallback(function(m){l||o(m)},[o,l]),h=y.useMemo(function(){var m;return ce(((m={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,m["".concat(s,"-period")]=!!s,m))},[s]),x=y.useMemo(function(){var m;return ce(((m={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(s,"-select")]=!!s,m))},[s,n.prefixPeriod]),g=y.useMemo(function(){var m;return ce(((m={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,m["".concat(s,"-select-dropdown-period")]=!!s,m))},[s]);return r.jsxs("div",re({className:h},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||B.prefixPeriod}),r.jsx(b.Select,{defaultValue:t,value:t,onChange:f,options:u,className:x,popupClassName:g,disabled:a,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function Yn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.monthDays,c=e.disabled,d=e.readOnly,u=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=n.weekDays||B.weekDays,g=u==="week"||!l||l.length===0,m=y.useMemo(function(){var I;return ce(((I={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!g})["".concat(s,"-field")]=!!s,I["".concat(s,"-week-days")]=!!s,I))},[s,g]),k=JSON.stringify(n),O=y.useMemo(function(){return g?n.emptyWeekDays||B.emptyWeekDays:n.emptyWeekDaysShort||B.emptyWeekDaysShort},[g,k]),E=u==="week"||!d||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),S=!d||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return E?r.jsxs("div",re({className:m},{children:[n.prefixWeekDays!==""&&(u==="week"||!S)&&r.jsx("span",{children:n.prefixWeekDays||B.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&u!=="week"&&S&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||B.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(We,{placeholder:O,optionsList:x,grid:!1,value:t,unit:re(re({},Ce[4]),{alt:n.altWeekDays||B.altWeekDays}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:c,readOnly:d,period:u,periodicityOnDoubleClick:f,mode:h})]})):null}function _n(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,s=n===void 0?{}:n,a=e.clearButtonAction,l=a===void 0?"fill-with-every":a,c=e.locale,d=c===void 0?B:c,u=e.value,f=u===void 0?"":u,h=e.setValue,x=e.displayError,g=x===void 0||x,m=e.onError,k=e.className,O=e.defaultPeriod,E=O===void 0?"day":O,S=e.allowEmpty,I=S===void 0?"for-default-value":S,W=e.humanizeLabels,J=W===void 0||W,T=e.humanizeValue,P=T!==void 0&&T,A=e.disabled,M=A!==void 0&&A,z=e.readOnly,H=z!==void 0&&z,de=e.leadingZero,$=de!==void 0&&de,V=e.shortcuts,L=V===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:V,se=e.clockFormat,K=e.periodicityOnDoubleClick,Y=K===void 0||K,R=e.mode,ee=R===void 0?"multiple":R,Le=e.allowedDropdowns,he=Le===void 0?["period","months","month-days","week-days","hours","minutes"]:Le,Ee=e.allowedPeriods,Ar=Ee===void 0?["year","month","week","day","hour","minute","reboot"]:Ee,$e=y.useRef(f),$t=y.useRef(E),$o=y.useState(),be=$o[0],ot=$o[1],Do=y.useState(),ze=Do[0],nt=Do[1],Io=y.useState(),rt=Io[0],st=Io[1],Po=y.useState(),Je=Po[0],it=Po[1],Mo=y.useState(),lt=Mo[0],at=Mo[1],Bo=y.useState(),ct=Bo[0],ut=Bo[1],Vo=y.useState(!1),Dt=Vo[0],Ue=Vo[1],jo=y.useState(!1),dt=jo[0],Wo=jo[1],Fr=function(_){var ge=y.useRef(_);return y.useEffect(function(){ge.current=_},[_]),ge.current}(dt),Lo=JSON.stringify(d);y.useEffect(function(){mo(f,Ue,m,I,$e,!0,d,L,ut,at,nt,st,it,ot)},[]),y.useEffect(function(){f!==$e.current&&mo(f,Ue,m,I,$e,!1,d,L,ut,at,nt,st,it,ot)},[f,$e,Lo,I,L]),y.useEffect(function(){if(!(be||ct||rt||ze||Je||lt)||dt||Fr)dt&&Wo(!1);else{var _=be||$t.current,ge=fo(_,rt,ze,Je,lt,ct,P);h(ge,{selectedPeriod:_}),$e.current=ge,m&&m(void 0),Ue(!1)}},[be,ze,rt,Je,lt,ct,P,dt]);var zo=y.useCallback(function(){nt(void 0),st(void 0),it(void 0),at(void 0),ut(void 0);var _="",ge=be!=="reboot"&&be?be:$t.current;ge!==be&&ot(ge),l==="fill-with-every"&&(_=fo(ge,void 0,void 0,void 0,void 0,void 0)),h(_,{selectedPeriod:ge}),$e.current=_,Wo(!0),I==="never"&&l==="empty"?(Ue(!0),po(m,d)):(m&&m(void 0),Ue(!1))},[be,h,m,l]),Or=y.useMemo(function(){var _;return ce(((_={"react-js-cron":!0,"react-js-cron-error":Dt&&g,"react-js-cron-disabled":M,"react-js-cron-read-only":H})["".concat(k)]=!!k,_["".concat(k,"-error")]=Dt&&g&&!!k,_["".concat(k,"-disabled")]=M&&!!k,_["".concat(k,"-read-only")]=H&&!!k,_))},[k,Dt,g,M,H]),It=s.className,Jo=ao(s,["className"]),Uo=y.useMemo(function(){var _;return ce(((_={"react-js-cron-clear-button":!0})["".concat(k,"-clear-button")]=!!k,_["".concat(It)]=!!It,_))},[k,It]),Tr=JSON.stringify(Jo),Ho=y.useMemo(function(){return o&&!H?r.jsx(b.Button,re({className:Uo,danger:!0,type:"primary",disabled:M},Jo,{onClick:zo},{children:d.clearButtonText||B.clearButtonText})):null},[o,H,Lo,Uo,M,Tr,zo]),te=be||$t.current;return r.jsxs("div",re({className:Or},{children:[he.includes("period")&&r.jsx(Kn,{value:te,setValue:ot,locale:d,className:k,disabled:M,readOnly:H,shortcuts:L,allowedPeriods:Ar}),te==="reboot"?Ho:r.jsxs(r.Fragment,{children:[te==="year"&&he.includes("months")&&r.jsx(qn,{value:rt,setValue:st,locale:d,className:k,humanizeLabels:J,disabled:M,readOnly:H,period:te,periodicityOnDoubleClick:Y,mode:ee}),(te==="year"||te==="month")&&he.includes("month-days")&&r.jsx(Gn,{value:ze,setValue:nt,locale:d,className:k,weekDays:Je,disabled:M,readOnly:H,leadingZero:$,period:te,periodicityOnDoubleClick:Y,mode:ee}),(te==="year"||te==="month"||te==="week")&&he.includes("week-days")&&r.jsx(Yn,{value:Je,setValue:it,locale:d,className:k,humanizeLabels:J,monthDays:ze,disabled:M,readOnly:H,period:te,periodicityOnDoubleClick:Y,mode:ee}),r.jsxs("div",{children:[te!=="minute"&&te!=="hour"&&he.includes("hours")&&r.jsx(Un,{value:lt,setValue:at,locale:d,className:k,disabled:M,readOnly:H,leadingZero:$,clockFormat:se,period:te,periodicityOnDoubleClick:Y,mode:ee}),te!=="minute"&&he.includes("minutes")&&r.jsx(Hn,{value:ct,setValue:ut,locale:d,period:te,className:k,disabled:M,readOnly:H,leadingZero:$,clockFormat:se,periodicityOnDoubleClick:Y,mode:ee}),Ho]})]})]}))}const wo=[{value:"none",text:"No repeat"},{value:6e4,text:"By minute",unitText:"Minutes"},{value:36e5,text:"By hour",unitText:"Hours"},{value:864e5,text:"By day",unitText:"Days"},{value:6048e5,text:"By week",unitText:"Weeks"},{value:"cron",text:"Advanced"}];function Co(e){return wo.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function Zn(e){let t;switch(typeof e){case"number":return t=Co(e),t?t.value:"none";case"string":return"cron"}return"none"}function Qn({value:e,onChange:t}){const{t:o}=gt(),n=Co(e);return r.jsx(b.InputNumber,{value:e/n.value,onChange:s=>t(s*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function Xn({value:e=null,onChange:t}){const{t:o}=gt(),n=Zn(e),s=y.useCallback(a=>{if(a==="none"){t(null);return}if(a==="cron"){t("0 * * * * *");return}t(a)},[t]);return r.jsxs("fieldset",{className:i.css`
|
|
465
|
+
`,children:[r.jsxs(b.Select,{value:n,onChange:s=>{t(s?s==="field"?{}:new Date:null)},className:"auto-width",children:[r.jsx(b.Select.Option,{value:null,children:o("No end")}),r.jsx(b.Select.Option,{value:"field",children:o("By field")}),r.jsx(b.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(lo,{value:e,onChange:t}):null,n==="date"?r.jsx(b.DatePicker,{showTime:!0,value:Yo(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var re=function(){return re=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var s in t=arguments[o])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},re.apply(this,arguments)};function ao(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(o[n[s]]=e[n[s]])}return o}function Xe(e,t,o){if(o||arguments.length===2)for(var n,s=0,a=t.length;s<a;s++)!n&&s in t||(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}var Jn=[{name:"@yearly",value:"0 0 1 1 *"},{name:"@annually",value:"0 0 1 1 *"},{name:"@monthly",value:"0 0 1 * *"},{name:"@weekly",value:"0 0 * * 0"},{name:"@daily",value:"0 0 * * *"},{name:"@midnight",value:"0 0 * * *"},{name:"@hourly",value:"0 * * * *"}],Ce=[{type:"minutes",min:0,max:59,total:60},{type:"hours",min:0,max:23,total:24},{type:"month-days",min:1,max:31,total:31},{type:"months",min:1,max:12,total:12,alt:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]},{type:"week-days",min:0,max:6,total:7,alt:["SUN","MON","TUE","WED","THU","FRI","SAT"]}],B={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function co(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function Re(e){return e.sort(function(t,o){return t-o}),e}function uo(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function ce(e){return Object.entries(e).filter(function(t){var o=t[0],n=t[1];return o&&n}).map(function(t){return t[0]}).join(" ")}function po(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||B.errorInvalidCron})}function et(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function mo(e,t,o,n,s,a,l,c,u,d,f,h,x,g){o&&o(void 0),t(!1);var m=!1;if(!e){if(n==="always"||a&&n==="for-default-value")return;m=!0}if(!m){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void g("reboot");var k=Jn.find(function(S){return S.name===e});k&&(e=k.value)}try{var O=function(S){if(typeof S!="string")throw new Error("Invalid cron string");var N=S.replace(/\s+/g," ").trim().split(" ");if(N.length===5)return N.map(function(W,J){return function(T,P){if(T==="*"||T==="*/1")return[];var A=Re(uo(yo(function(L,H,ue){if(ue){L=L.toUpperCase();for(var D=0;D<ue.length;D++)L=L.replace(ue[D],"".concat(D+H))}return L}(T,P.min,P.alt).split(",").map(function(L){var H,ue=L.split("/");if(ue.length>2)throw new Error('Invalid value "'.concat(T,' for "').concat(P.type,'"'));var D=ue[0],V=ue[1];H=D==="*"?co(P.min,P.max):function(K,Y,R){var ee=K.split("-");if(ee.length===1){var Le=et(ee[0]);if(isNaN(Le))throw new Error('Invalid value "'.concat(Y,'" for ').concat(R.type));return[Le]}if(ee.length===2){var he=et(ee[0]),Ee=et(ee[1]);if(isNaN(he)||isNaN(Ee))throw new Error('Invalid value "'.concat(Y,'" for ').concat(R.type));if(Ee<he)throw new Error('Max range is less than min range in "'.concat(K,'" for ').concat(R.type));return co(he,Ee)}throw new Error('Invalid value "'.concat(K,'" for ').concat(R.type))}(D,T,P);var z=function(K,Y){if(K!==void 0){var R=et(K);if(isNaN(R)||R<1)throw new Error('Invalid interval step value "'.concat(K,'" for ').concat(Y.type));return R}}(V,P),se=function(K,Y){if(Y){var R=K[0];K=K.filter(function(ee){return ee%Y==R%Y||ee===R})}return K}(H,z);return se}).flat(),P))),E=bo(A,P);if(E!==void 0)throw new Error('Value "'.concat(E,'" out of range for ').concat(P.type));return A.length===P.total?[]:A}(W,Ce[J])});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"}(O);g(M),u(O[0]),d(O[1]),f(O[2]),h(O[3]),x(O[4])}catch(S){m=!0}}m&&(s.current=e,t(!0),po(o,l))}function fo(e,t,o,n,s,a,l){if(e==="reboot")return"@reboot";var c=function(u,d){return u.map(function(f,h){var x=Ce[h];return ho(go(f,x),x,d)})}([e!=="minute"&&a?a:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return c.join(" ")}function ho(e,t,o,n,s){var a="";if(function(c,u){return c.length===u.max-u.min+1}(e,t)||e.length===0)a="*";else{var l=function(c){if(c.length>2){var u=c[1]-c[0];if(u>1)return u}}(e);a=l&&function(c,u){for(var d=1;d<c.length;d++){var f=c[d-1];if(c[d]-f!==u)return!1}return!0}(e,l)?function(c,u,d){var f=vo(c),h=xo(c),x=c.length===(h-f)/d+1;return!!(f===u.min&&h+d>u.max&&x)}(e,t,l)?"*/".concat(l):"".concat(Oe(vo(e),t,o,n,s),"-").concat(Oe(xo(e),t,o,n,s),"/").concat(l):function(c){var u=[],d=null;return c.forEach(function(f,h,x){f!==x[h+1]-1?d!==null?(u.push([d,f]),d=null):u.push(f):d===null&&(d=f)}),u}(e).map(function(c){return Array.isArray(c)?"".concat(Oe(c[0],t,o,n,s),"-").concat(Oe(c[1],t,o,n,s)):Oe(c,t,o,n,s)}).join(",")}return a}function Oe(e,t,o,n,s){var a=e.toString(),l=t.type,c=t.alt,u=t.min,d=n&&(n===!0||n.includes(l)),f=s==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?a=c[e-u]:e<10&&(d||f)&&(a=a.padStart(2,"0")),l==="hours"&&s==="12-hour-clock"){var h=e>=12?"PM":"AM",x=e%12||12;x<10&&d&&(x=x.toString().padStart(2,"0")),a="".concat(x).concat(h)}return a}function go(e,t){var o=Re(uo(yo(e,t)));if(o.length===0)return o;var n=bo(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function yo(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function bo(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function vo(e){return e[0]}function xo(e){return e[e.length-1]}function We(e){var t=e.value,o=e.grid,n=o===void 0||o,s=e.optionsList,a=e.setValue,l=e.locale,c=e.className,u=e.humanizeLabels,d=e.disabled,f=e.readOnly,h=e.leadingZero,x=e.clockFormat,g=e.period,m=e.unit,k=e.periodicityOnDoubleClick,O=e.mode,M=ao(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(D){return D.toString()})},[t]),N=y.useMemo(function(){return s?s.map(function(D,V){return{value:(m.min===0?V:V+1).toString(),label:D}}):Xe([],Array(m.total),!0).map(function(D,V){var z=m.min===0?V:V+1;return{value:z.toString(),label:Oe(z,m,u,h,x)}})},[s,h,u,x]),W=JSON.stringify(l),J=y.useCallback(function(D){var V=D.value;if(!t||t[0]!==Number(V))return r.jsx(r.Fragment,{});var z=ho(go(t,m),m,u,h,x),se=z.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:se[1]?"".concat(l.everyText||B.everyText," ").concat(se[1]):z})},[t,W,u,h,x]),T=y.useCallback(function(D){var V=Array.isArray(D)?Re(D):[D],z=V;t&&(z=O==="single"?[]:Xe([],t,!0),V.forEach(function(se){var K=Number(se);z=t.some(function(Y){return Y===K})?z.filter(function(Y){return Y!==K}):Re(Xe(Xe([],z,!0),[K],!1))})),z.length===m.total?a([]):a(z)},[a,t]),P=y.useCallback(function(D){if(D!==0&&D!==1){for(var V=m.total+m.min,z=[],se=m.min;se<V;se++)se%D==0&&z.push(se);var K=t&&z&&t.length===z.length&&t.every(function(R,ee){return R===z[ee]}),Y=z.length===N.length;a(Y||K?[]:z)}else a([])},[t,N,a]),A=y.useRef([]),E=y.useCallback(function(D){if(!f){var V=A.current;V.push({time:new Date().getTime(),value:Number(D)});var z=window.setTimeout(function(){k&&V.length>1&&V[V.length-1].time-V[V.length-2].time<300?V[V.length-1].value===V[V.length-2].value?P(Number(D)):T([V[V.length-2].value,V[V.length-1].value]):T(Number(D)),A.current=[]},300);return function(){window.clearTimeout(z)}}},[A,T,P,f,k]),L=y.useCallback(function(){f||a([])},[a,f]),H=y.useMemo(function(){var D;return ce(((D={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,D))},[c]),ue=y.useMemo(function(){var D;return ce(((D={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(m.type)]=!0,D["react-js-cron-custom-select-dropdown"]=!0,D["react-js-cron-custom-select-dropdown-".concat(m.type)]=!0,D["react-js-cron-custom-select-dropdown-minutes-large"]=m.type==="minutes"&&g!=="hour"&&g!=="day",D["react-js-cron-custom-select-dropdown-minutes-medium"]=m.type==="minutes"&&(g==="day"||g==="hour"),D["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=m.type==="hours"&&x==="12-hour-clock",D["react-js-cron-custom-select-dropdown-grid"]=!!n,D["".concat(c,"-select-dropdown")]=!!c,D["".concat(c,"-select-dropdown-").concat(m.type)]=!!c,D))},[c,n,x,g]);return r.jsx(b.Select,re({mode:O!=="single"||k?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:S,onClear:L,tagRender:J,className:H,popupClassName:ue,options:N,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:E,onDeselect:E,disabled:d,dropdownAlign:m.type!=="minutes"&&m.type!=="hours"||g==="day"||g==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(m.type)},M))}function Un(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=y.useMemo(function(){var g;return ce(((g={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,g["".concat(s,"-hours")]=!!s,g))},[s]);return r.jsxs("div",re({className:x},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||B.prefixHours}),r.jsx(We,{placeholder:n.emptyHours||B.emptyHours,value:t,unit:Ce[1],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:h})]}))}function Hn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=y.useMemo(function(){var g;return ce(((g={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,g["".concat(s,"-minutes")]=!!s,g))},[s]);return r.jsxs("div",re({className:x},{children:[d==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||B.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||B.prefixMinutes}),r.jsx(We,{placeholder:d==="hour"?n.emptyMinutesForHourPeriod||B.emptyMinutesForHourPeriod:n.emptyMinutes||B.emptyMinutes,value:t,unit:Ce[0],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:h}),d==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||B.suffixMinutesForHourPeriod})]}))}function Gn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.weekDays,l=e.disabled,c=e.readOnly,u=e.leadingZero,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=!a||a.length===0,g=y.useMemo(function(){var O;return ce(((O={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!x})["".concat(s,"-field")]=!!s,O["".concat(s,"-month-days")]=!!s,O))},[s,x]),m=JSON.stringify(n),k=y.useMemo(function(){return x?n.emptyMonthDays||B.emptyMonthDays:n.emptyMonthDaysShort||B.emptyMonthDaysShort},[x,m]);return!c||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?r.jsxs("div",re({className:g},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||B.prefixMonthDays}),r.jsx(We,{placeholder:k,value:t,setValue:o,unit:Ce[2],locale:n,className:s,disabled:l,readOnly:c,leadingZero:u,period:d,periodicityOnDoubleClick:f,mode:h})]})):null}function qn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.disabled,c=e.readOnly,u=e.period,d=e.periodicityOnDoubleClick,f=e.mode,h=n.months||B.months,x=y.useMemo(function(){var g;return ce(((g={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,g["".concat(s,"-months")]=!!s,g))},[s]);return r.jsxs("div",re({className:x},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||B.prefixMonths}),r.jsx(We,{placeholder:n.emptyMonths||B.emptyMonths,optionsList:h,grid:!1,value:t,unit:re(re({},Ce[3]),{alt:n.altMonths||B.altMonths}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:l,readOnly:c,period:u,periodicityOnDoubleClick:d,mode:f})]}))}function Kn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.shortcuts,u=e.allowedPeriods,d=[];u.includes("year")&&d.push({value:"year",label:n.yearOption||B.yearOption}),u.includes("month")&&d.push({value:"month",label:n.monthOption||B.monthOption}),u.includes("week")&&d.push({value:"week",label:n.weekOption||B.weekOption}),u.includes("day")&&d.push({value:"day",label:n.dayOption||B.dayOption}),u.includes("hour")&&d.push({value:"hour",label:n.hourOption||B.hourOption}),u.includes("minute")&&d.push({value:"minute",label:n.minuteOption||B.minuteOption}),u.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&d.push({value:"reboot",label:n.rebootOption||B.rebootOption});var f=y.useCallback(function(m){l||o(m)},[o,l]),h=y.useMemo(function(){var m;return ce(((m={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,m["".concat(s,"-period")]=!!s,m))},[s]),x=y.useMemo(function(){var m;return ce(((m={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(s,"-select")]=!!s,m))},[s,n.prefixPeriod]),g=y.useMemo(function(){var m;return ce(((m={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,m["".concat(s,"-select-dropdown-period")]=!!s,m))},[s]);return r.jsxs("div",re({className:h},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||B.prefixPeriod}),r.jsx(b.Select,{defaultValue:t,value:t,onChange:f,options:d,className:x,popupClassName:g,disabled:a,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function Yn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.monthDays,c=e.disabled,u=e.readOnly,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,x=n.weekDays||B.weekDays,g=d==="week"||!l||l.length===0,m=y.useMemo(function(){var N;return ce(((N={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!g})["".concat(s,"-field")]=!!s,N["".concat(s,"-week-days")]=!!s,N))},[s,g]),k=JSON.stringify(n),O=y.useMemo(function(){return g?n.emptyWeekDays||B.emptyWeekDays:n.emptyWeekDaysShort||B.emptyWeekDaysShort},[g,k]),M=d==="week"||!u||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),S=!u||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return M?r.jsxs("div",re({className:m},{children:[n.prefixWeekDays!==""&&(d==="week"||!S)&&r.jsx("span",{children:n.prefixWeekDays||B.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&d!=="week"&&S&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||B.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(We,{placeholder:O,optionsList:x,grid:!1,value:t,unit:re(re({},Ce[4]),{alt:n.altWeekDays||B.altWeekDays}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:c,readOnly:u,period:d,periodicityOnDoubleClick:f,mode:h})]})):null}function _n(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,s=n===void 0?{}:n,a=e.clearButtonAction,l=a===void 0?"fill-with-every":a,c=e.locale,u=c===void 0?B:c,d=e.value,f=d===void 0?"":d,h=e.setValue,x=e.displayError,g=x===void 0||x,m=e.onError,k=e.className,O=e.defaultPeriod,M=O===void 0?"day":O,S=e.allowEmpty,N=S===void 0?"for-default-value":S,W=e.humanizeLabels,J=W===void 0||W,T=e.humanizeValue,P=T!==void 0&&T,A=e.disabled,E=A!==void 0&&A,L=e.readOnly,H=L!==void 0&&L,ue=e.leadingZero,D=ue!==void 0&&ue,V=e.shortcuts,z=V===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:V,se=e.clockFormat,K=e.periodicityOnDoubleClick,Y=K===void 0||K,R=e.mode,ee=R===void 0?"multiple":R,Le=e.allowedDropdowns,he=Le===void 0?["period","months","month-days","week-days","hours","minutes"]:Le,Ee=e.allowedPeriods,Ar=Ee===void 0?["year","month","week","day","hour","minute","reboot"]:Ee,$e=y.useRef(f),$t=y.useRef(M),$o=y.useState(),be=$o[0],ot=$o[1],Do=y.useState(),ze=Do[0],nt=Do[1],Io=y.useState(),rt=Io[0],st=Io[1],Po=y.useState(),Je=Po[0],it=Po[1],Mo=y.useState(),lt=Mo[0],at=Mo[1],Bo=y.useState(),ct=Bo[0],dt=Bo[1],Vo=y.useState(!1),Dt=Vo[0],Ue=Vo[1],jo=y.useState(!1),ut=jo[0],Wo=jo[1],Fr=function(_){var ge=y.useRef(_);return y.useEffect(function(){ge.current=_},[_]),ge.current}(ut),Lo=JSON.stringify(u);y.useEffect(function(){mo(f,Ue,m,N,$e,!0,u,z,dt,at,nt,st,it,ot)},[]),y.useEffect(function(){f!==$e.current&&mo(f,Ue,m,N,$e,!1,u,z,dt,at,nt,st,it,ot)},[f,$e,Lo,N,z]),y.useEffect(function(){if(!(be||ct||rt||ze||Je||lt)||ut||Fr)ut&&Wo(!1);else{var _=be||$t.current,ge=fo(_,rt,ze,Je,lt,ct,P);h(ge,{selectedPeriod:_}),$e.current=ge,m&&m(void 0),Ue(!1)}},[be,ze,rt,Je,lt,ct,P,ut]);var zo=y.useCallback(function(){nt(void 0),st(void 0),it(void 0),at(void 0),dt(void 0);var _="",ge=be!=="reboot"&&be?be:$t.current;ge!==be&&ot(ge),l==="fill-with-every"&&(_=fo(ge,void 0,void 0,void 0,void 0,void 0)),h(_,{selectedPeriod:ge}),$e.current=_,Wo(!0),N==="never"&&l==="empty"?(Ue(!0),po(m,u)):(m&&m(void 0),Ue(!1))},[be,h,m,l]),Or=y.useMemo(function(){var _;return ce(((_={"react-js-cron":!0,"react-js-cron-error":Dt&&g,"react-js-cron-disabled":E,"react-js-cron-read-only":H})["".concat(k)]=!!k,_["".concat(k,"-error")]=Dt&&g&&!!k,_["".concat(k,"-disabled")]=E&&!!k,_["".concat(k,"-read-only")]=H&&!!k,_))},[k,Dt,g,E,H]),It=s.className,Jo=ao(s,["className"]),Uo=y.useMemo(function(){var _;return ce(((_={"react-js-cron-clear-button":!0})["".concat(k,"-clear-button")]=!!k,_["".concat(It)]=!!It,_))},[k,It]),Tr=JSON.stringify(Jo),Ho=y.useMemo(function(){return o&&!H?r.jsx(b.Button,re({className:Uo,danger:!0,type:"primary",disabled:E},Jo,{onClick:zo},{children:u.clearButtonText||B.clearButtonText})):null},[o,H,Lo,Uo,E,Tr,zo]),te=be||$t.current;return r.jsxs("div",re({className:Or},{children:[he.includes("period")&&r.jsx(Kn,{value:te,setValue:ot,locale:u,className:k,disabled:E,readOnly:H,shortcuts:z,allowedPeriods:Ar}),te==="reboot"?Ho:r.jsxs(r.Fragment,{children:[te==="year"&&he.includes("months")&&r.jsx(qn,{value:rt,setValue:st,locale:u,className:k,humanizeLabels:J,disabled:E,readOnly:H,period:te,periodicityOnDoubleClick:Y,mode:ee}),(te==="year"||te==="month")&&he.includes("month-days")&&r.jsx(Gn,{value:ze,setValue:nt,locale:u,className:k,weekDays:Je,disabled:E,readOnly:H,leadingZero:D,period:te,periodicityOnDoubleClick:Y,mode:ee}),(te==="year"||te==="month"||te==="week")&&he.includes("week-days")&&r.jsx(Yn,{value:Je,setValue:it,locale:u,className:k,humanizeLabels:J,monthDays:ze,disabled:E,readOnly:H,period:te,periodicityOnDoubleClick:Y,mode:ee}),r.jsxs("div",{children:[te!=="minute"&&te!=="hour"&&he.includes("hours")&&r.jsx(Un,{value:lt,setValue:at,locale:u,className:k,disabled:E,readOnly:H,leadingZero:D,clockFormat:se,period:te,periodicityOnDoubleClick:Y,mode:ee}),te!=="minute"&&he.includes("minutes")&&r.jsx(Hn,{value:ct,setValue:dt,locale:u,period:te,className:k,disabled:E,readOnly:H,leadingZero:D,clockFormat:se,periodicityOnDoubleClick:Y,mode:ee}),Ho]})]})]}))}const wo=[{value:"none",text:"No repeat"},{value:6e4,text:"By minute",unitText:"Minutes"},{value:36e5,text:"By hour",unitText:"Hours"},{value:864e5,text:"By day",unitText:"Days"},{value:6048e5,text:"By week",unitText:"Weeks"},{value:"cron",text:"Advanced"}];function Co(e){return wo.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function Zn(e){let t;switch(typeof e){case"number":return t=Co(e),t?t.value:"none";case"string":return"cron"}return"none"}function Qn({value:e,onChange:t}){const{t:o}=gt(),n=Co(e);return r.jsx(b.InputNumber,{value:e/n.value,onChange:s=>t(s*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function Xn({value:e=null,onChange:t}){const{t:o}=gt(),n=Zn(e),s=y.useCallback(a=>{if(a==="none"){t(null);return}if(a==="cron"){t("0 * * * * *");return}t(a)},[t]);return r.jsxs("fieldset",{className:i.css`
|
|
466
466
|
display: flex;
|
|
467
467
|
flex-direction: ${n==="cron"?"column":"row"};
|
|
468
468
|
align-items: flex-start;
|
|
@@ -500,11 +500,11 @@
|
|
|
500
500
|
.ant-picker {
|
|
501
501
|
width: auto;
|
|
502
502
|
}
|
|
503
|
-
`},properties:Rn[o]}}},components:{OnField:lo,RepeatField:Xn,EndsByField:zn}})]})};function or(e,t){var c;const[o,n]=i.parseCollectionName(e.collection),s=i.useCompile(),a=je(o),l=[];if((!(t!=null&&t.types)||t.types.includes("date"))&&l.push({key:"date",value:"date",label
|
|
503
|
+
`},properties:Rn[o]}}},components:{OnField:lo,RepeatField:Xn,EndsByField:zn}})]})};function or(e,t){var c;const[o,n]=i.parseCollectionName(e.collection),s=i.useCompile(),a=je(o),l=[];if((!(t!=null&&t.types)||t.types.includes("date"))&&l.push({key:"date",value:"date",label:$("Trigger time")}),e.mode===we.DATE_FIELD){const[u]=Ae(F(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:$("Trigger data")}}],compile:s,getCollectionFields:a}));u&&l.push(u)}return l}class nr extends wt{constructor(){super(...arguments);w(this,"sync",!1);w(this,"title",`{{t("Schedule event", { ns: "${p}" })}}`);w(this,"description",`{{t("Triggered according to preset time conditions. Suitable for one-time or periodic tasks, such as sending notifications and cleaning data on a schedule.", { ns: "${p}" })}}`);w(this,"fieldset",{config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource});w(this,"components",{ScheduleConfig:tr});w(this,"useVariables",or)}useInitializers(o){return o.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Be,collection:o.collection,dataPath:"$context.data"}:null}}function Te(e){const a=e,{options:t=[],direction:o}=a,n=Z(a,["options","direction"]),s=i.useCompile();return r.jsx(b.Radio.Group,F(C({},n),{children:r.jsx(b.Space,{direction:o,children:t.map(l=>r.jsxs(b.Radio,{value:l.value,children:[r.jsx("span",{className:i.css`
|
|
504
504
|
& + .anticon {
|
|
505
505
|
margin-left: 0.25em;
|
|
506
506
|
}
|
|
507
|
-
`,children:s(l.label)}),l.tooltip&&r.jsx(b.Tooltip,{title:s(l.tooltip),children:r.jsx(
|
|
507
|
+
`,children:s(l.label)}),l.tooltip&&r.jsx(b.Tooltip,{title:s(l.tooltip),children:r.jsx(I.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}function ko(){const e=j.useFieldSchema(),t=i.useCompile();return r.jsxs(i.GeneralSchemaDesigner,{title:t(e.title),children:[r.jsx(i.SchemaSettingsBlockTitleItem,{}),r.jsx(i.SchemaSettingsDivider,{}),r.jsx(i.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})}const Ne=()=>null;function rr(){const a=i.useSchemaInitializerItem(),{node:t,resultTitle:o}=a,n=Z(a,["node","resultTitle"]),{insert:s}=i.useSchemaInitializer();return r.jsx(i.SchemaInitializerItem,F(C({},n),{onClick:()=>{var l;s({type:"void",name:t.id,title:t.title,"x-component":"CardItem","x-component-props":{title:(l=t.title)!=null?l:`#${t.id}`},"x-designer":"ValueBlock.Designer",properties:{result:{type:"void",title:o,"x-component":"ValueBlock.Result","x-component-props":{dataSource:`{{$jobsMapByNodeKey.${t.key}}}`}}}})}}))}function sr({dataSource:e}){var s;const t=j.useFieldSchema(),{execution:o}=q();if(!o)return t.title;const n=U.parse(e)({$jobsMapByNodeKey:((s=o.jobs)!=null?s:[]).reduce((a,l)=>Object.assign(a,{[l.nodeKey]:l.result}),{})});return r.jsx("pre",{className:i.css`
|
|
508
508
|
margin: 0;
|
|
509
509
|
`,children:JSON.stringify(n,null,2)})}Ne.Initializer=rr,Ne.Result=sr,Ne.Designer=ko;const So=e=>{const t=De.evaluators.get(e);return t&&t.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:i.css`
|
|
510
510
|
&:after {
|
|
@@ -513,16 +513,16 @@
|
|
|
513
513
|
& + a {
|
|
514
514
|
margin-left: 0.25em;
|
|
515
515
|
}
|
|
516
|
-
`,children:i.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class ir extends ye{constructor(){super(...arguments);w(this,"title",`{{t("Calculation", { ns: "${p}" })}}`);w(this,"type","calculation");w(this,"group","control");w(this,"description",`{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression.", { ns: "${p}" })}}`);w(this,"fieldset",{engine:{type:"string",title:`{{t("Calculation engine", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:De.getOptions()},required:!0,default:"math.js"},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(o,n,{form:s}){const{values:a}=s,{evaluate:l}=De.evaluators.get(a.engine),c=o.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return l(c),""}catch(
|
|
516
|
+
`,children:i.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class ir extends ye{constructor(){super(...arguments);w(this,"title",`{{t("Calculation", { ns: "${p}" })}}`);w(this,"type","calculation");w(this,"group","control");w(this,"description",`{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression.", { ns: "${p}" })}}`);w(this,"fieldset",{engine:{type:"string",title:`{{t("Calculation engine", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:De.getOptions()},required:!0,default:"math.js"},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(o,n,{form:s}){const{values:a}=s,{evaluate:l}=De.evaluators.get(a.engine),c=o.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return l(c),""}catch(u){return $("Expression syntax error")}},"x-reactions":[{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0}});w(this,"scope",{renderEngineReference:So});w(this,"components",{WorkflowVariableTextArea:Et,RadioWithTooltip:Te,ValueBlock:Ne})}useVariables({key:o,title:n},{types:s,fieldNames:a=Se}){return s&&!s.some(l=>l in Ze||Object.values(Ze).some(c=>c.has(l)))?null:{value:o,label:n}}useInitializers(o){var n,s;return{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Ne.Initializer,node:o,resultTitle:$("Calculation result")}}}const X=new U.Registry;X.register("equal",{name:"=",type:"boolean",group:"boolean"}),X.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),X.register("gt",{name:">",type:"boolean",group:"boolean"}),X.register("gte",{name:"≥",type:"boolean",group:"boolean"}),X.register("lt",{name:"<",type:"boolean",group:"boolean"}),X.register("lte",{name:"≤",type:"boolean",group:"boolean"}),X.register("add",{name:"+",type:"number",group:"number"}),X.register("minus",{name:"-",type:"number",group:"number"}),X.register("multiple",{name:"*",type:"number",group:"number"}),X.register("divide",{name:"/",type:"number",group:"number"}),X.register("mod",{name:"%",type:"number",group:"number"}),X.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),X.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),X.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),X.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),X.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),X.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),X.register("concat",{name:`{{t("concat", { ns: "${p}" })}}`,type:"string",group:"string"});const lr=[{value:"boolean",title:'{{t("Comparision")}}'},{value:"number",title:`{{t("Arithmetic calculation", { ns: "${p}" })}}`},{value:"string",title:`{{t("String operation", { ns: "${p}" })}}`},{value:"date",title:`{{t("Date", { ns: "${p}" })}}`}];function Ao(e){return Array.from(X.getEntities()).filter(([t,o])=>o.group===e)}function ar({calculator:e,operands:t=[],onChange:o}){const n=i.useCompile(),s=me(),a=me(),l=y.useCallback(d=>o({calculator:e,operands:[d,t[1]]}),[e,o,t]),c=y.useCallback(d=>o({calculator:e,operands:[t[0],d]}),[e,o,t]),u=y.useCallback(d=>o({operands:t,calculator:d}),[o,t]);return r.jsxs("fieldset",{className:i.css`
|
|
517
517
|
display: flex;
|
|
518
518
|
gap: 0.5em;
|
|
519
519
|
align-items: center;
|
|
520
520
|
flex-wrap: wrap;
|
|
521
|
-
`,children:[r.jsx(i.Variable.Input,{changeOnSelect:!0,value:t[0],onChange:l,scope:s,useTypedConstant:!0}),r.jsx(b.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:
|
|
521
|
+
`,children:[r.jsx(i.Variable.Input,{changeOnSelect:!0,value:t[0],onChange:l,scope:s,useTypedConstant:!0}),r.jsx(b.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:u,placeholder:$("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:lr.filter(d=>!!Ao(d.value).length).map(d=>r.jsx(b.Select.OptGroup,{label:n(d.title),children:Ao(d.value).map(([f,{name:h}])=>r.jsx(b.Select.Option,{value:f,children:n(h)},f))},d.value))}),r.jsx(i.Variable.Input,{changeOnSelect:!0,value:t[1],onChange:c,scope:a,useTypedConstant:!0})]})}function cr({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:n,operands:s=[]}=e;return r.jsxs("div",{className:i.css`
|
|
522
522
|
display: flex;
|
|
523
523
|
position: relative;
|
|
524
524
|
margin: 0.5em 0;
|
|
525
|
-
`,children:[e.group?r.jsx(Fo,{value:e.group,onChange:a=>t(F(C({},e),{group:a}))}):r.jsx(ar,{operands:s,calculator:n,onChange:t}),r.jsx(b.Button,{"aria-label":"icon-close",onClick:o,type:"link",icon:r.jsx(
|
|
525
|
+
`,children:[e.group?r.jsx(Fo,{value:e.group,onChange:a=>t(F(C({},e),{group:a}))}):r.jsx(ar,{operands:s,calculator:n,onChange:t}),r.jsx(b.Button,{"aria-label":"icon-close",onClick:o,type:"link",icon:r.jsx(I.CloseCircleOutlined,{})})]})}function Fo({value:e,onChange:t}){const{t:o}=Q.useTranslation(),{type:n="and",calculations:s=[]}=e;function a(){t(F(C({},e),{calculations:[...s,{not:!1,calculator:"equal"}]}))}function l(){t(F(C({},e),{calculations:[...s,{not:!1,group:{type:"and",calculations:[]}}]}))}function c(d){s.splice(d,1),t(F(C({},e),{calculations:[...s]}))}function u(d,f){s.splice(d,1,f),t(F(C({},e),{calculations:[...s]}))}return r.jsxs("div",{className:i.cx("node-type-condition-group",i.css`
|
|
526
526
|
position: relative;
|
|
527
527
|
width: 100%;
|
|
528
528
|
.node-type-condition-group {
|
|
@@ -541,18 +541,18 @@
|
|
|
541
541
|
width: auto;
|
|
542
542
|
min-width: 6em;
|
|
543
543
|
}
|
|
544
|
-
`,children:r.jsxs(Q.Trans,{children:["Meet ",r.jsxs(b.Select,{role:"button","data-testid":"filter-select-all-or-any",value:n,onChange:
|
|
544
|
+
`,children:r.jsxs(Q.Trans,{children:["Meet ",r.jsxs(b.Select,{role:"button","data-testid":"filter-select-all-or-any",value:n,onChange:d=>t(F(C({},e),{type:d})),children:[r.jsx(b.Select.Option,{value:"and",children:"All"}),r.jsx(b.Select.Option,{value:"or",children:"Any"})]})," conditions in the group"]})}),r.jsx("div",{className:"calculation-items",children:s.map((d,f)=>r.jsx(cr,{value:d,onChange:u.bind(this,f),onRemove:()=>c(f)},`${d.calculator}_${f}`))}),r.jsxs("div",{className:i.css`
|
|
545
545
|
button {
|
|
546
546
|
padding: 0;
|
|
547
547
|
&:not(:last-child) {
|
|
548
548
|
margin-right: 1em;
|
|
549
549
|
}
|
|
550
550
|
}
|
|
551
|
-
`,children:[r.jsx(b.Button,{type:"link",onClick:a,children:o("Add condition")}),r.jsx(b.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function
|
|
551
|
+
`,children:[r.jsx(b.Button,{type:"link",onClick:a,children:o("Add condition")}),r.jsx(b.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function dr({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(Fo,{value:o.group,onChange:n=>t(F(C({},o),{group:n}))})}class ur extends ye{constructor(){super(...arguments);w(this,"title",`{{t("Condition", { ns: "${p}" })}}`);w(this,"type","condition");w(this,"group","control");w(this,"description",`{{t('Based on boolean result of the calculation to determine whether to "continue" or "exit" the process, or continue on different branches of "yes" and "no".', { ns: "${p}" })}}`);w(this,"fieldset",{rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{disabled:!0},enum:[{value:!0,label:`{{t('Continue when "Yes"', { ns: "${p}" })}}`},{value:!1,label:`{{t('Branch into "Yes" and "No"', { ns: "${p}" })}}`}]},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[["basic",{label:`{{t("Basic", { ns: "${p}" })}}`}],...Array.from(De.evaluators.getEntities()).filter(([o])=>["math.js","formula.js"].includes(o))].reduce((o,[n,s])=>o.concat(C({value:n},s)),[])},required:!0,default:"basic"},calculation:{type:"string",title:`{{t("Condition", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"CalculationConfig","x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] === "basic"}}'}}},required:!0},expression:{type:"string",title:`{{t("Condition expression", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(o,n,{form:s}){const{values:a}=s,{evaluate:l}=De.evaluators.get(a.engine),c=o.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return l(c),""}catch(u){return $("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0}});w(this,"options",[{label:`{{t('Continue when "Yes"', { ns: "${p}" })}}`,key:"rejectOnFalse",value:{rejectOnFalse:!0}},{label:`{{t('Branch into "Yes" and "No"', { ns: "${p}" })}}`,key:"branch",value:{rejectOnFalse:!1}}]);w(this,"scope",{renderEngineReference:So,useWorkflowVariableOptions:me});w(this,"components",{CalculationConfig:dr,WorkflowVariableTextArea:Et,RadioWithTooltip:Te})}Component({data:o}){const{t:n}=Q.useTranslation(),{nodes:s}=q(),{styles:a}=ne(),{id:l,config:{rejectOnFalse:c}}=o,u=s.find(f=>f.upstreamId===l&&f.branchIndex===1),d=s.find(f=>f.upstreamId===l&&f.branchIndex===0);return r.jsx(xt,{data:o,children:c?null:r.jsxs("div",{className:a.nodeSubtreeClass,children:[r.jsxs("div",{className:a.branchBlockClass,children:[r.jsx(Ke,{from:o,entry:d,branchIndex:0}),r.jsx(Ke,{from:o,entry:u,branchIndex:1})]}),r.jsxs("div",{className:a.conditionClass,children:[r.jsx("span",{style:{right:"4em"},children:n("No")}),r.jsx("span",{style:{left:"4em"},children:n("Yes")})]})]})})}}class pr extends ye{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:le.RESOLVED},{label:`{{t("Failed", { ns: "${p}" })}}`,value:le.FAILED}],required:!0,default:le.RESOLVED}});w(this,"end",!0)}}function tt({value:e,onChange:t,renderSchemaComponent:o}){const n=me();return r.jsx(i.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}function mr(e){const{execution:t,nodes:o}=q(),n=y.useMemo(()=>o.reduce((l,c)=>Object.assign(l,{[c.id]:c.key}),{}),[o]),s=y.useMemo(()=>{var l;return{$context:t==null?void 0:t.context,$jobsMapByNodeKey:((l=t==null?void 0:t.jobs)!=null?l:[]).reduce((c,u)=>Object.assign(c,{[n[u.nodeId]]:u.result}),{})}},[t==null?void 0:t.context,t==null?void 0:t.jobs,n]);return y.useMemo(()=>ke.get(s,e),[s,e])}function fr({collection:e,dataPath:t,children:o}){const n=j.useField(),s=y.useRef(null),{getAssociationAppends:a}=i.useAssociationNames(),{appends:l,updateAssociationValues:c}=a(),u=mr(t);let d,f;if(typeof e=="string"){const M=i.parseCollectionName(e);d=M[0],f=M[1]}else f=e;const h=y.useMemo(()=>ie.createForm({values:u,readPretty:!0}),[u]),x={appends:l},g={loading:!1,data:{data:u}},k=i.useAPIClient().resource(f),O=i.useBlockRequestContext();return r.jsx(i.CollectionProvider_deprecated,{dataSource:d,collection:f,children:r.jsx(i.RecordProvider,{record:u,parent:null,children:r.jsx(i.BlockRequestContext_deprecated.Provider,{value:{block:"form",field:n,service:g,resource:k,__parent:O},children:r.jsx(i.FormBlockContext.Provider,{value:{params:x,form:h,field:n,service:g,updateAssociationValues:c,formBlockRef:s},children:o})})})})}function hr(e){const a=e,{options:t=[],direction:o}=a,n=Z(a,["options","direction"]),s=i.useCompile();return r.jsx(b.Checkbox.Group,F(C({},n),{children:r.jsx(b.Space,{direction:o,children:t.map(l=>r.jsxs(b.Checkbox,{value:l.value,children:[r.jsx("span",{className:i.css`
|
|
552
552
|
& + .anticon {
|
|
553
553
|
margin-left: 0.25em;
|
|
554
554
|
}
|
|
555
|
-
`,children:s(l.label)}),l.tooltip&&r.jsx(b.Tooltip,{title:s(l.tooltip),children:r.jsx(
|
|
555
|
+
`,children:s(l.label)}),l.tooltip&&r.jsx(b.Tooltip,{title:s(l.tooltip),children:r.jsx(I.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}function gr({key:e,title:t,config:o},n){var d,f;const[s,a]=i.parseCollectionName(o.collection),l=i.useCompile(),c=je(s),[u]=Ae(F(C({appends:[e,...((f=(d=o.params)==null?void 0:d.appends)==null?void 0:f.map(h=>`${e}.${h}`))||[]]},n),{fields:[{collectionName:a,name:e,type:"hasOne",target:a,uiSchema:{title:t}}],compile:l,getCollectionFields:c}));return u}class yr extends ye{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:F(C({},ae),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...ae["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),multiple:{type:"boolean",title:`{{t("Result type", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{label:`{{t("Single record", { ns: "${p}" })}}`,value:!1,tooltip:`{{t("The result will be an object of the first matching record only, or null if no matched record.", { ns: "${p}" })}}`},{label:`{{t("Multiple records", { ns: "${p}" })}}`,value:!0,tooltip:`{{t("The result will be an array containing matched records, or an empty one if no matching records. This can be used to be processed in a loop node.", { ns: "${p}" })}}`}]},required:!0,default:!1},params:{type:"object","x-component":"fieldset",properties:{filter:_e,sort:Nn,pagination:En,appends:Ve},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{$deps[0] != null}}"}}}]},failOnEmpty:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Exit when query result is null", { ns: "${p}" })}}`}});w(this,"scope",{useNodeSavedConfig:Me,useCollectionDataSource:i.useCollectionDataSource,useSortableFields(){const o=i.useCompile(),{values:n}=j.useForm(),[s,a]=i.parseCollectionName(n.collection),l=i.useApp(),{collectionManager:c}=l.dataSourceManager.getDataSource(s);return c.getCollectionFields(a).filter(d=>{if(!d.interface)return!1;const f=l.dataSourceManager.collectionFieldInterfaceManager.getFieldInterface(d.interface);return!!(f!=null&&f.sortable)}).map(d=>{var f,h;return{value:d.name,label:(f=d==null?void 0:d.uiSchema)!=null&&f.title?o((h=d==null?void 0:d.uiSchema)==null?void 0:h.title):d.name}})}});w(this,"components",{ArrayItems:Mt.ArrayItems,FilterDynamicComponent:tt,SchemaComponentContext:i.SchemaComponentContext,WorkflowVariableInput:so,RadioWithTooltip:Te});w(this,"useVariables",gr)}useInitializers(o){var n,s;return!o.config.collection||o.config.multiple?null:{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Be,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}}}function br(e){const{getCollectionFields:t}=i.useCollectionManager_deprecated(),{path:o}=j.useField(),n=o.segments[o.segments.length-1],{values:s}=j.useForm(),[a,l]=i.parseCollectionName(s==null?void 0:s.collection),c=t(l,a),{type:u}=c.find(h=>h.name===n),d=Array.isArray(e.value)?e.value.join(","):e.value,f=y.useCallback(h=>{const x=h.target.value.trim(),g=["belongsTo","hasOne"].includes(u)?x||null:x.split(",").map(m=>m.trim()).filter(m=>m!=="");e.onChange(g)},[e.onChange,u]);return r.jsx(b.Input,F(C({},e),{value:d,onChange:f}))}const Oo=j.observer(({value:e,disabled:t,onChange:o,filter:n})=>{const{token:s}=i.useToken(),{t:a}=Q.useTranslation(),l=i.useCompile(),c=j.useForm(),{getCollectionFields:u}=i.useCollectionManager_deprecated(),d=me(),{values:f}=c,[h,x]=i.parseCollectionName(f==null?void 0:f.collection),g=u(x,h).filter(S=>S.uiSchema),m=n?g.filter(n.bind(f)):g,k=y.useMemo(()=>m.filter(S=>!e||!(S.name in e)),[m,e]),O=t||c.disabled,M=y.useMemo(()=>({onClick:({key:S})=>{o(F(C({},e),{[S]:null}))},style:{maxHeight:300,overflowY:"auto"},items:k.map(S=>{var N,W;return{key:S.name,label:l((W=(N=S.uiSchema)==null?void 0:N.title)!=null?W:S.name)}})}),[o,k,e]);return r.jsx("fieldset",{className:i.css`
|
|
556
556
|
margin-top: 0.5em;
|
|
557
557
|
|
|
558
558
|
> .ant-formily-item {
|
|
@@ -562,8 +562,8 @@
|
|
|
562
562
|
line-height: 32px;
|
|
563
563
|
}
|
|
564
564
|
}
|
|
565
|
-
`,children:m.length?r.jsxs(i.CollectionProvider_deprecated,{name:x,dataSource:h,children:[m.filter(S=>e&&S.name in e).map(S=>{var W,J;const
|
|
565
|
+
`,children:m.length?r.jsxs(i.CollectionProvider_deprecated,{name:x,dataSource:h,children:[m.filter(S=>e&&S.name in e).map(S=>{var W,J;const N=["belongsTo","hasOne","hasMany","belongsToMany"].includes(S.type)?br:i.CollectionField;return r.jsxs(b.Form.Item,{label:l((J=(W=S.uiSchema)==null?void 0:W.title)!=null?J:S.name),labelAlign:"left",className:i.css`
|
|
566
566
|
.ant-form-item-control-input-content {
|
|
567
567
|
display: flex;
|
|
568
568
|
}
|
|
569
|
-
`,children:[r.jsx(i.Variable.Input,{scope:u,value:e[S.name],changeOnSelect:!0,onChange:T=>{o(F(C({},e),{[S.name]:T}))},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[S.name]:{"x-component":I,"x-validator"(){return""}}}}})}),O?null:r.jsx(b.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx(D.CloseCircleOutlined,{}),onClick:()=>{var A;const M=e,{[A=S.name]:T}=M,P=Z(M,[Ko(A)]);o(P)}})]},S.name)}),k.length?r.jsx(b.Dropdown,{menu:E,children:r.jsx(b.Button,{icon:r.jsx(D.PlusOutlined,{}),children:a("Add field")})}):null]}):r.jsx("p",{style:{color:s.colorText},children:N("Please select collection first")})})},{displayName:"CollectionFieldSet"});function To(e,t){t(e),e!=null&&e.properties&&Object.values(e.properties).forEach(o=>{To(o,t)})}function No(){return{name:ft.uid(),type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields"}}function Eo(e){const{workflow:t}=q(),{setFormValueChanged:o}=i.useActionContext();i.useAPIClient();const n=me(),s=j.useForm(),{values:a,setValuesIn:l}=s,c=mt.toJS(a.params),[d,u]=i.parseCollectionName(a.collection),f=i.useSchemaOptionsContext(),[h,x]=y.useState(e.value&&Object.keys(e.value).length?e.value:No()),g=y.useMemo(()=>ie.createForm({initialValues:c.values,disabled:t.executed,effects(){ie.onFormValuesChange(k=>{l("params.values",mt.toJS(k.values)),o(!0)})}}),[t.executed]);j.useFormEffects(()=>{ie.onFieldValueChange("collection",k=>G(this,null,function*(){g.clearFormGraph("*");const O=No();l("params.values",{}),x(O)}))});const m=y.useCallback(k=>{const[O]=Object.values(k.toJSON().properties);e.onChange(O);const E=new Set;To(O,I=>{var W;if(I["x-component"]==="AssignedField"&&(W=I["x-collection-field"])!=null&&W.startsWith(`${u}.`)){const[,J]=I["x-collection-field"].split(".");E.add(J)}});const S={};Array.from(E).forEach(I=>{I in g.values&&(S[I]=g.values[I])}),l("params.values",S)},[u,e.onChange]);return r.jsx(b.Card,{children:r.jsx(i.CollectionManagerProvider,{dataSource:d,children:r.jsx(i.CollectionProvider,{name:u,children:r.jsx(i.FormProvider,{form:g,children:r.jsx(Mt.FormLayout,{layout:"vertical",children:r.jsx(i.VariableScopeProvider,{scope:n,children:r.jsx(i.SchemaComponentProvider,{form:g,designable:!0,children:r.jsx(i.SchemaComponentOptions,F(C({},f),{children:r.jsx(i.SchemaComponent,{schema:h,onChange:m})}))})})})})})})})}function vr({key:e,title:t,config:o},n){var u,f;const[s,a]=i.parseCollectionName(o.collection),l=i.useCompile(),c=je(s),[d]=Ae(F(C({appends:[e,...((f=(u=o.params)==null?void 0:u.appends)==null?void 0:f.map(h=>`${e}.${h}`))||[]]},n),{fields:[{collectionName:a,name:e,type:"hasOne",target:a,uiSchema:{title:t}}],compile:l,getCollectionFields:c}));return d}class xr extends ye{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:F(C({},ae),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...ae["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),usingAssignFormSchema:{type:"boolean"},assignFormSchema:{type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-component":"AssignedFieldsFormSchemaConfig","x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && $deps[1]) ? "visible" : "hidden"}}'}}}]},params:{type:"object",properties:{values:F(C({},Rt),{"x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && !$deps[1]) ? "visible" : "hidden"}}'}}}]}),appends:Ve}}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource,useNodeSavedConfig:Me});w(this,"components",{CollectionFieldset:Oo,AssignedFieldsFormSchemaConfig:Eo});w(this,"useVariables",vr)}createDefaultConfig(){return{usingAssignFormSchema:!0,assignFormSchema:{}}}useInitializers(o){var n,s;return o.config.collection?{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Be,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}:null}}class wr extends ye{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:F(C({},ae),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...ae["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}},{target:"params.values",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${p}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.", { ns: "${p}" })}}`},{label:`{{t("Update one by one", { ns: "${p}" })}}`,value:!0,tooltip:`{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${p}" })}}`}]},default:!1},filter:F(C({},_e),{title:`{{t("Only update records matching conditions", { ns: "${p}" })}}`,"x-validator"(o){return U.isValidFilter(o)?"":N("Please add at least one condition")}}),values:F(C({},Rt),{"x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && !$deps[1]) ? "visible" : "hidden"}}'}}}]})}},usingAssignFormSchema:{type:"boolean"},assignFormSchema:{type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-component":"AssignedFieldsFormSchemaConfig","x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && $deps[1]) ? "visible" : "hidden"}}'}}}]}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource,useNodeSavedConfig:Me});w(this,"components",{FilterDynamicComponent:tt,CollectionFieldset:Oo,AssignedFieldsFormSchemaConfig:Eo,RadioWithTooltip:Te})}createDefaultConfig(){return{usingAssignFormSchema:!0,assignFormSchema:{}}}}class Cr extends ye{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:F(C({},ae),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...ae["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:F(C({},_e),{"x-validator"(o){return U.isValidFilter(o)?"":N("Please add at least one condition")}})}}});w(this,"scope",{useNodeSavedConfig:Me,useCollectionDataSource:i.useCollectionDataSource});w(this,"components",{FilterDynamicComponent:tt})}}const kr=new i.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:i.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=i.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:i.SecondConFirm},{name:"assignFieldValues",Component:i.AssignedFieldValues},{name:"skipRequiredValidation",Component:i.SkipValidation},{name:"afterSuccessfulSubmission",Component:i.AfterSuccess,useVisible(){var t;const e=j.useFieldSchema();return ft.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.onSuccess)}},{name:"bindWorkflow",Component:i.WorkflowConfig},{name:"delete",sort:100,Component:i.RemoveButton,useComponentProps(){const{removeButtonProps:e}=i.useSchemaToolbar();return e}}]});function Sr({children:e,workflow:t,execution:o,nodes:n}){const s=i.usePlugin(ue),a=s.triggers.get(t.type).components,l=n.reduce((c,{type:d})=>Object.assign(c,s.instructions.get(d).components),{});return r.jsx(Ie.Provider,{value:{workflow:t,nodes:n,execution:o},children:r.jsx(i.SchemaComponentOptions,{components:C(C({},a),l),children:e})})}class ue extends i.Plugin{constructor(){super(...arguments);w(this,"triggers",new U.Registry);w(this,"instructions",new U.Registry);w(this,"getTriggersOptions",()=>Array.from(this.triggers.getEntities()).map(a=>{var[o,l]=a,c=l,{title:n}=c,s=Z(c,["title"]);return{value:o,label:n,color:"gold",options:s}}))}isWorkflowSync(o){var n;return(n=this.triggers.get(o.type).sync)!=null?n:o.sync}registerTrigger(o,n){if(typeof n=="function")this.triggers.register(o,new n);else if(n)this.triggers.register(o,n);else throw new TypeError("invalid trigger type to register")}registerInstruction(o,n){if(typeof n=="function")this.instructions.register(o,new n);else if(n instanceof ye)this.instructions.register(o,n);else throw new TypeError("invalid instruction type to register")}load(){return G(this,null,function*(){this.app.router.add("admin.workflow.workflows.id",{path:xe(":id"),element:r.jsx(Qt,{})}),this.app.router.add("admin.workflow.executions.id",{path:Ye(":id"),element:r.jsx(Gt,{})}),this.app.addComponents({WorkflowPage:Qt,ExecutionPage:Gt}),this.app.pluginSettingsManager.add(p,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${p}" })}}`,Component:Fn,aclSnippet:"pm.workflow.workflows"}),this.app.schemaSettingsManager.add(kr),this.registerTrigger("collection",Wn),this.registerTrigger("schedule",nr),this.registerInstruction("calculation",ir),this.registerInstruction("condition",dr),this.registerInstruction("end",pr),this.registerInstruction("query",yr),this.registerInstruction("create",xr),this.registerInstruction("update",wr),this.registerInstruction("destroy",Cr)})}}v.BaseTypeSets=Ze,v.Branch=Ke,v.CheckboxGroupWithTooltip=hr,v.CollectionBlockInitializer=Be,v.DetailsBlockProvider=fr,v.EXECUTION_STATUS=pe,v.ExecutionContextProvider=Sr,v.ExecutionStatusOptions=He,v.ExecutionStatusOptionsMap=Ge,v.FieldsSelect=At,v.FilterDynamicComponent=tt,v.FlowContext=Ie,v.Instruction=ye,v.JOB_STATUS=le,v.JobButton=Ut,v.JobStatusOptions=bt,v.JobStatusOptionsMap=qe,v.Node=zt,v.NodeContext=vt,v.NodeDefaultView=xt,v.RadioWithTooltip=Te,v.RemoveButton=Jt,v.SimpleDesigner=ko,v.Trigger=wt,v.ValueBlock=Ne,v.WorkflowVariableInput=so,v.WorkflowVariableJSON=In,v.WorkflowVariableRawTextArea=Dn,v.WorkflowVariableTextArea=Et,v.default=ue,v.defaultFieldNames=Se,v.getCollectionFieldOptions=Ae,v.getWorkflowDetailPath=xe,v.getWorkflowExecutionsPath=Ye,v.linkNodes=kt,v.nodesOptions=eo,v.scopeOptions=oo,v.systemOptions=no,v.traverseSchema=St,v.triggerOptions=to,v.useAvailableUpstreams=Wt,v.useFlowContext=q,v.useGetAriaLabelOfAddButton=yt,v.useGetCollectionFields=je,v.useNodeContext=ve,v.useNodeSavedConfig=Me,v.useRecordTriggerWorkflowsActionProps=Mn,v.useStyles=ne,v.useTrigger=Ct,v.useTriggerWorkflowsActionProps=Pn,v.useUpstreamScopes=Lt,v.useWorkflowAnyExecuted=io,v.useWorkflowExecuted=Bn,v.useWorkflowVariableOptions=me,Object.defineProperties(v,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
569
|
+
`,children:[r.jsx(i.Variable.Input,{scope:d,value:e[S.name],changeOnSelect:!0,onChange:T=>{o(F(C({},e),{[S.name]:T}))},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[S.name]:{"x-component":N,"x-validator"(){return""}}}}})}),O?null:r.jsx(b.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx(I.CloseCircleOutlined,{}),onClick:()=>{var A;const E=e,{[A=S.name]:T}=E,P=Z(E,[Ko(A)]);o(P)}})]},S.name)}),k.length?r.jsx(b.Dropdown,{menu:M,children:r.jsx(b.Button,{icon:r.jsx(I.PlusOutlined,{}),children:a("Add field")})}):null]}):r.jsx("p",{style:{color:s.colorText},children:$("Please select collection first")})})},{displayName:"CollectionFieldSet"});function To(e,t){t(e),e!=null&&e.properties&&Object.values(e.properties).forEach(o=>{To(o,t)})}function No(){return{name:ft.uid(),type:"void","x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields"}}function Eo(e){const{workflow:t}=q(),{setFormValueChanged:o}=i.useActionContext();i.useAPIClient();const n=me(),s=j.useForm(),{values:a,setValuesIn:l}=s,c=mt.toJS(a.params),[u,d]=i.parseCollectionName(a.collection),f=i.useSchemaOptionsContext(),[h,x]=y.useState(e.value&&Object.keys(e.value).length?e.value:No()),g=y.useMemo(()=>ie.createForm({initialValues:c.values,disabled:t.executed,effects(){ie.onFormValuesChange(k=>{l("params.values",mt.toJS(k.values)),o(!0)})}}),[t.executed]);j.useFormEffects(()=>{ie.onFieldValueChange("collection",k=>G(this,null,function*(){g.clearFormGraph("*");const O=No();l("params.values",{}),x(O)}))});const m=y.useCallback(k=>{const[O]=Object.values(k.toJSON().properties);e.onChange(O);const M=new Set;To(O,N=>{var W;if(N["x-component"]==="AssignedField"&&(W=N["x-collection-field"])!=null&&W.startsWith(`${d}.`)){const[,J]=N["x-collection-field"].split(".");M.add(J)}});const S={};Array.from(M).forEach(N=>{N in g.values&&(S[N]=g.values[N])}),l("params.values",S)},[d,e.onChange]);return r.jsx(b.Card,{children:r.jsx(i.CollectionManagerProvider,{dataSource:u,children:r.jsx(i.CollectionProvider,{name:d,children:r.jsx(i.FormProvider,{form:g,children:r.jsx(Mt.FormLayout,{layout:"vertical",children:r.jsx(i.VariableScopeProvider,{scope:n,children:r.jsx(i.SchemaComponentProvider,{form:g,designable:!s.disabled,children:r.jsx(i.SchemaComponentOptions,F(C({},f),{children:r.jsx(i.SchemaComponent,{schema:h,onChange:m})}))})})})})})})})}function vr({key:e,title:t,config:o},n){var d,f;const[s,a]=i.parseCollectionName(o.collection),l=i.useCompile(),c=je(s),[u]=Ae(F(C({appends:[e,...((f=(d=o.params)==null?void 0:d.appends)==null?void 0:f.map(h=>`${e}.${h}`))||[]]},n),{fields:[{collectionName:a,name:e,type:"hasOne",target:a,uiSchema:{title:t}}],compile:l,getCollectionFields:c}));return u}class xr extends ye{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:F(C({},ae),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...ae["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),usingAssignFormSchema:{type:"boolean"},assignFormSchema:{type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-component":"AssignedFieldsFormSchemaConfig","x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && $deps[1]) ? "visible" : "hidden"}}'}}}]},params:{type:"object",properties:{values:F(C({},Rt),{"x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && !$deps[1]) ? "visible" : "hidden"}}'}}}]}),appends:Ve}}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource,useNodeSavedConfig:Me});w(this,"components",{CollectionFieldset:Oo,AssignedFieldsFormSchemaConfig:Eo});w(this,"useVariables",vr)}createDefaultConfig(){return{usingAssignFormSchema:!0,assignFormSchema:{}}}useInitializers(o){var n,s;return o.config.collection?{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Be,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}:null}}class wr extends ye{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:F(C({},ae),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...ae["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}},{target:"params.values",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${p}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.", { ns: "${p}" })}}`},{label:`{{t("Update one by one", { ns: "${p}" })}}`,value:!0,tooltip:`{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${p}" })}}`}]},default:!1},filter:F(C({},_e),{title:`{{t("Only update records matching conditions", { ns: "${p}" })}}`,"x-validator"(o){return U.isValidFilter(o)?"":$("Please add at least one condition")}}),values:F(C({},Rt),{"x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && !$deps[1]) ? "visible" : "hidden"}}'}}}]})}},usingAssignFormSchema:{type:"boolean"},assignFormSchema:{type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-component":"AssignedFieldsFormSchemaConfig","x-reactions":[{dependencies:["collection","usingAssignFormSchema"],fulfill:{state:{display:'{{($deps[0] && $deps[1]) ? "visible" : "hidden"}}'}}}]}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource,useNodeSavedConfig:Me});w(this,"components",{FilterDynamicComponent:tt,CollectionFieldset:Oo,AssignedFieldsFormSchemaConfig:Eo,RadioWithTooltip:Te})}createDefaultConfig(){return{usingAssignFormSchema:!0,assignFormSchema:{}}}}class Cr extends ye{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:F(C({},ae),{"x-disabled":'{{ useNodeSavedConfig(["collection"]) }}',"x-reactions":[...ae["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:F(C({},_e),{"x-validator"(o){return U.isValidFilter(o)?"":$("Please add at least one condition")}})}}});w(this,"scope",{useNodeSavedConfig:Me,useCollectionDataSource:i.useCollectionDataSource});w(this,"components",{FilterDynamicComponent:tt})}}const kr=new i.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:i.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=i.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:i.SecondConFirm},{name:"assignFieldValues",Component:i.AssignedFieldValues},{name:"skipRequiredValidation",Component:i.SkipValidation},{name:"afterSuccessfulSubmission",Component:i.AfterSuccess,useVisible(){var t;const e=j.useFieldSchema();return ft.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.onSuccess)}},{name:"bindWorkflow",Component:i.WorkflowConfig},{name:"delete",sort:100,Component:i.RemoveButton,useComponentProps(){const{removeButtonProps:e}=i.useSchemaToolbar();return e}}]});function Sr({children:e,workflow:t,execution:o,nodes:n}){const s=i.usePlugin(de),a=s.triggers.get(t.type).components,l=n.reduce((c,{type:u})=>Object.assign(c,s.instructions.get(u).components),{});return r.jsx(Ie.Provider,{value:{workflow:t,nodes:n,execution:o},children:r.jsx(i.SchemaComponentOptions,{components:C(C({},a),l),children:e})})}class de extends i.Plugin{constructor(){super(...arguments);w(this,"triggers",new U.Registry);w(this,"instructions",new U.Registry);w(this,"getTriggersOptions",()=>Array.from(this.triggers.getEntities()).map(a=>{var[o,l]=a,c=l,{title:n}=c,s=Z(c,["title"]);return{value:o,label:n,color:"gold",options:s}}))}isWorkflowSync(o){var n;return(n=this.triggers.get(o.type).sync)!=null?n:o.sync}registerTrigger(o,n){if(typeof n=="function")this.triggers.register(o,new n);else if(n)this.triggers.register(o,n);else throw new TypeError("invalid trigger type to register")}registerInstruction(o,n){if(typeof n=="function")this.instructions.register(o,new n);else if(n instanceof ye)this.instructions.register(o,n);else throw new TypeError("invalid instruction type to register")}load(){return G(this,null,function*(){this.app.router.add("admin.workflow.workflows.id",{path:xe(":id"),element:r.jsx(Qt,{})}),this.app.router.add("admin.workflow.executions.id",{path:Ye(":id"),element:r.jsx(Gt,{})}),this.app.addComponents({WorkflowPage:Qt,ExecutionPage:Gt}),this.app.pluginSettingsManager.add(p,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${p}" })}}`,Component:Fn,aclSnippet:"pm.workflow.workflows"}),this.app.schemaSettingsManager.add(kr),this.registerTrigger("collection",Wn),this.registerTrigger("schedule",nr),this.registerInstruction("calculation",ir),this.registerInstruction("condition",ur),this.registerInstruction("end",pr),this.registerInstruction("query",yr),this.registerInstruction("create",xr),this.registerInstruction("update",wr),this.registerInstruction("destroy",Cr)})}}v.BaseTypeSets=Ze,v.Branch=Ke,v.CheckboxGroupWithTooltip=hr,v.CollectionBlockInitializer=Be,v.DetailsBlockProvider=fr,v.EXECUTION_STATUS=pe,v.ExecutionContextProvider=Sr,v.ExecutionStatusOptions=He,v.ExecutionStatusOptionsMap=Ge,v.FieldsSelect=At,v.FilterDynamicComponent=tt,v.FlowContext=Ie,v.Instruction=ye,v.JOB_STATUS=le,v.JobButton=Ut,v.JobStatusOptions=bt,v.JobStatusOptionsMap=qe,v.Node=zt,v.NodeContext=vt,v.NodeDefaultView=xt,v.RadioWithTooltip=Te,v.RemoveButton=Jt,v.SimpleDesigner=ko,v.Trigger=wt,v.ValueBlock=Ne,v.WorkflowVariableInput=so,v.WorkflowVariableJSON=In,v.WorkflowVariableRawTextArea=Dn,v.WorkflowVariableTextArea=Et,v.default=de,v.defaultFieldNames=Se,v.getCollectionFieldOptions=Ae,v.getWorkflowDetailPath=xe,v.getWorkflowExecutionsPath=Ye,v.linkNodes=kt,v.nodesOptions=eo,v.scopeOptions=oo,v.systemOptions=no,v.traverseSchema=St,v.triggerOptions=to,v.useAvailableUpstreams=Wt,v.useFlowContext=q,v.useGetAriaLabelOfAddButton=yt,v.useGetCollectionFields=je,v.useNodeContext=ve,v.useNodeSavedConfig=Me,v.useRecordTriggerWorkflowsActionProps=Mn,v.useStyles=ne,v.useTrigger=Ct,v.useTriggerWorkflowsActionProps=Pn,v.useUpstreamScopes=Lt,v.useWorkflowAnyExecuted=io,v.useWorkflowExecuted=Bn,v.useWorkflowVariableOptions=me,Object.defineProperties(v,{__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
|
"antd": "5.12.8",
|
|
13
13
|
"@ant-design/icons": "5.2.6",
|
|
14
|
-
"@nocobase/client": "1.2.
|
|
14
|
+
"@nocobase/client": "1.2.8-alpha",
|
|
15
15
|
"react-router-dom": "6.21.0",
|
|
16
|
-
"@nocobase/utils": "1.2.
|
|
16
|
+
"@nocobase/utils": "1.2.8-alpha",
|
|
17
17
|
"react-i18next": "11.18.6",
|
|
18
18
|
"@formily/core": "2.3.0",
|
|
19
19
|
"@formily/react": "2.3.0",
|
|
20
20
|
"lodash": "4.17.21",
|
|
21
|
-
"@nocobase/database": "1.2.
|
|
22
|
-
"@nocobase/server": "1.2.
|
|
23
|
-
"@nocobase/logger": "1.2.
|
|
24
|
-
"@nocobase/evaluators": "1.2.
|
|
21
|
+
"@nocobase/database": "1.2.8-alpha",
|
|
22
|
+
"@nocobase/server": "1.2.8-alpha",
|
|
23
|
+
"@nocobase/logger": "1.2.8-alpha",
|
|
24
|
+
"@nocobase/evaluators": "1.2.8-alpha",
|
|
25
25
|
"@formily/antd-v5": "1.1.9",
|
|
26
26
|
"@formily/reactive": "2.3.0",
|
|
27
27
|
"@formily/shared": "2.3.0",
|
|
28
|
-
"@nocobase/actions": "1.2.
|
|
29
|
-
"@nocobase/data-source-manager": "1.2.
|
|
28
|
+
"@nocobase/actions": "1.2.8-alpha",
|
|
29
|
+
"@nocobase/data-source-manager": "1.2.8-alpha",
|
|
30
30
|
"sequelize": "6.35.2",
|
|
31
|
-
"@nocobase/plugin-workflow-test": "1.2.
|
|
32
|
-
"@nocobase/test": "1.2.
|
|
31
|
+
"@nocobase/plugin-workflow-test": "1.2.8-alpha",
|
|
32
|
+
"@nocobase/test": "1.2.8-alpha",
|
|
33
33
|
"dayjs": "1.11.10"
|
|
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-06-
|
|
1
|
+
{"name":"cron-parser","version":"4.4.0","description":"Node.js library for parsing crontab instructions","main":"lib/parser.js","types":"index.d.ts","typesVersions":{"<4.1":{"*":["types/ts3/*"]}},"directories":{"test":"test"},"scripts":{"test:tsd":"tsd","test:unit":"TZ=UTC tap ./test/*.js","test:cover":"TZ=UTC tap --coverage-report=html ./test/*.js","lint":"eslint .","lint:fix":"eslint --fix .","test":"npm run lint && npm run test:unit && npm run test:tsd"},"repository":{"type":"git","url":"https://github.com/harrisiirak/cron-parser.git"},"keywords":["cron","crontab","parser"],"author":"Harri Siirak","contributors":["Nicholas Clawson","Daniel Prentis <daniel@salsitasoft.com>","Renault John Lecoultre","Richard Astbury <richard.astbury@gmail.com>","Meaglin Wasabi <Meaglin.wasabi@gmail.com>","Mike Kusold <hello@mikekusold.com>","Alex Kit <alex.kit@atmajs.com>","Santiago Gimeno <santiago.gimeno@gmail.com>","Daniel <darc.tec@gmail.com>","Christian Steininger <christian.steininger.cs@gmail.com>","Mykola Piskovyi <m.piskovyi@gmail.com>","Brian Vaughn <brian.david.vaughn@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Yasuhiroki <yasuhiroki.duck@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Brendan Warkentin <faazshift@gmail.com>","Charlie Fish <fishcharlie.code@gmail.com>","Ian Graves <ian+diskimage@iangrav.es>","Andy Thompson <me@andytson.com>","Regev Brody <regevbr@gmail.com>"],"license":"MIT","dependencies":{"luxon":"^1.28.0"},"devDependencies":{"eslint":"^8.2.0","sinon":"^10.0.0","tap":"^16.0.1","tsd":"^0.19.0"},"engines":{"node":">=0.8"},"browser":{"fs":false},"tap":{"check-coverage":false},"tsd":{"directory":"test","compilerOptions":{"lib":["es2017","dom"]}},"_lastModified":"2024-06-25T07:52:45.236Z"}
|
|
@@ -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-06-
|
|
1
|
+
{"name":"lru-cache","description":"A cache object that deletes the least-recently-used items.","version":"8.0.5","author":"Isaac Z. Schlueter <i@izs.me>","keywords":["mru","lru","cache"],"sideEffects":false,"scripts":{"build":"npm run prepare","preprepare":"rm -rf dist","prepare":"tsc -p tsconfig.json && tsc -p tsconfig-esm.json","postprepare":"bash fixup.sh","pretest":"npm run prepare","presnap":"npm run prepare","test":"c8 tap","snap":"c8 tap","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","format":"prettier --write .","typedoc":"typedoc --tsconfig tsconfig-esm.json ./src/*.ts","benchmark-results-typedoc":"bash scripts/benchmark-results-typedoc.sh","prebenchmark":"npm run prepare","benchmark":"make -C benchmark","preprofile":"npm run prepare","profile":"make -C benchmark profile"},"main":"./dist/cjs/index-cjs.js","module":"./dist/mjs/index.js","types":"./dist/mjs/index.d.ts","exports":{"./min":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.min.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.min.js"}},".":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index-cjs.js"}}},"repository":"git://github.com/isaacs/node-lru-cache.git","devDependencies":{"@size-limit/preset-small-lib":"^7.0.8","@types/node":"^17.0.31","@types/tap":"^15.0.6","benchmark":"^2.1.4","c8":"^7.11.2","clock-mock":"^1.0.6","esbuild":"^0.17.11","eslint-config-prettier":"^8.5.0","marked":"^4.2.12","mkdirp":"^2.1.5","prettier":"^2.6.2","size-limit":"^7.0.8","tap":"^16.3.4","ts-node":"^10.7.0","tslib":"^2.4.0","typedoc":"^0.23.24","typescript":"^4.6.4"},"license":"ISC","files":["dist"],"engines":{"node":">=16.14"},"prettier":{"semi":false,"printWidth":70,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"tap":{"coverage":false,"node-arg":["--expose-gc","--no-warnings","--loader","ts-node/esm"],"ts":false},"size-limit":[{"path":"./dist/mjs/index.js"}],"_lastModified":"2024-06-25T07:52:44.892Z"}
|
|
@@ -106,14 +106,14 @@ async function revision(context, next) {
|
|
|
106
106
|
key: filter.key,
|
|
107
107
|
title: origin.title,
|
|
108
108
|
triggerTitle: origin.triggerTitle,
|
|
109
|
-
allExecuted: origin.allExecuted
|
|
110
|
-
sync: origin.sync
|
|
109
|
+
allExecuted: origin.allExecuted
|
|
111
110
|
} : values;
|
|
112
111
|
const instance = await repository.create({
|
|
113
112
|
values: {
|
|
114
113
|
title: `${origin.title} copy`,
|
|
115
114
|
description: origin.description,
|
|
116
115
|
...revisionData,
|
|
116
|
+
sync: origin.sync,
|
|
117
117
|
type: origin.type,
|
|
118
118
|
config: typeof trigger2.duplicateConfig === "function" ? await trigger2.duplicateConfig(origin, { transaction }) : origin.config
|
|
119
119
|
},
|
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.2.
|
|
7
|
+
"version": "1.2.8-alpha",
|
|
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.2.
|
|
13
|
+
"@nocobase/plugin-workflow-test": "1.2.8-alpha"
|
|
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": "23132ae9e60c152ea61b77a6371a41c684d4041a",
|
|
48
48
|
"keywords": [
|
|
49
49
|
"Workflow"
|
|
50
50
|
]
|