@nocobase/plugin-workflow 0.21.0-alpha.9 → 1.0.0-alpha.2

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.
@@ -1,4 +1,4 @@
1
- (function(g,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("react/jsx-runtime"),require("@nocobase/client"),require("@nocobase/utils/client"),require("react-router-dom"),require("react"),require("antd"),require("react-i18next"),require("@ant-design/icons"),require("@formily/core"),require("@formily/react"),require("lodash"),require("@formily/shared"),require("dayjs"),require("@nocobase/evaluators/client"),require("@formily/antd-v5")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","@nocobase/utils/client","react-router-dom","react","antd","react-i18next","@ant-design/icons","@formily/core","@formily/react","lodash","@formily/shared","dayjs","@nocobase/evaluators/client","@formily/antd-v5"],r):(g=typeof globalThis!="undefined"?globalThis:g||self,r(g["@nocobase/plugin-workflow"]={},g.jsxRuntime,g["@nocobase/client"],g["@nocobase/utils"],g["react-router-dom"],g.react,g.antd,g["react-i18next"],g["@ant-design/icons"],g["@formily/core"],g["@formily/react"],g.lodash,g["@formily/shared"],g.dayjs,g["@nocobase/evaluators"],g["@formily/antd-v5"]))})(this,function(g,r,i,H,oe,b,y,Q,$,he,j,ut,Dt,Lo,De,zo){"use strict";var gr=Object.defineProperty,br=Object.defineProperties;var xr=Object.getOwnPropertyDescriptors;var ct=Object.getOwnPropertySymbols;var Vo=Object.prototype.hasOwnProperty,jo=Object.prototype.propertyIsEnumerable;var Nt=(g,r,i)=>r in g?gr(g,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):g[r]=i,C=(g,r)=>{for(var i in r||(r={}))Vo.call(r,i)&&Nt(g,i,r[i]);if(ct)for(var i of ct(r))jo.call(r,i)&&Nt(g,i,r[i]);return g},T=(g,r)=>br(g,xr(r));var Wo=g=>typeof g=="symbol"?g:g+"",Z=(g,r)=>{var i={};for(var H in g)Vo.call(g,H)&&r.indexOf(H)<0&&(i[H]=g[H]);if(g!=null&&ct)for(var H of ct(g))r.indexOf(H)<0&&jo.call(g,H)&&(i[H]=g[H]);return i};var w=(g,r,i)=>(Nt(g,typeof r!="symbol"?r+"":r,i),i);var _=(g,r,i)=>new Promise((H,oe)=>{var b=$=>{try{Q(i.next($))}catch(he){oe(he)}},y=$=>{try{Q(i.throw($))}catch(he){oe(he)}},Q=$=>$.done?H($.value):Promise.resolve($.value).then(b,y);Q((i=i.apply(g,r)).next())});const $e=b.createContext({});function Y(){return b.useContext($e)}const p="workflow";function E(e,t={}){return i.i18n.t(e,T(C({},t),{ns:p}))}function dt(){return Q.useTranslation(p)}const ne=i.createStyles(({css:e,token:t})=>({workflowPageClass:e`
1
+ (function(g,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("react/jsx-runtime"),require("@nocobase/client"),require("@nocobase/utils/client"),require("react-router-dom"),require("react"),require("antd"),require("react-i18next"),require("@ant-design/icons"),require("@formily/core"),require("@formily/react"),require("lodash"),require("@formily/shared"),require("dayjs"),require("@nocobase/evaluators/client"),require("@formily/antd-v5")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","@nocobase/utils/client","react-router-dom","react","antd","react-i18next","@ant-design/icons","@formily/core","@formily/react","lodash","@formily/shared","dayjs","@nocobase/evaluators/client","@formily/antd-v5"],r):(g=typeof globalThis!="undefined"?globalThis:g||self,r(g["@nocobase/plugin-workflow"]={},g.jsxRuntime,g["@nocobase/client"],g["@nocobase/utils"],g["react-router-dom"],g.react,g.antd,g["react-i18next"],g["@ant-design/icons"],g["@formily/core"],g["@formily/react"],g.lodash,g["@formily/shared"],g.dayjs,g["@nocobase/evaluators"],g["@formily/antd-v5"]))})(this,function(g,r,i,H,oe,b,y,Q,E,he,j,ut,Dt,Lo,De,zo){"use strict";var gr=Object.defineProperty,br=Object.defineProperties;var xr=Object.getOwnPropertyDescriptors;var ct=Object.getOwnPropertySymbols;var Vo=Object.prototype.hasOwnProperty,jo=Object.prototype.propertyIsEnumerable;var Nt=(g,r,i)=>r in g?gr(g,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):g[r]=i,C=(g,r)=>{for(var i in r||(r={}))Vo.call(r,i)&&Nt(g,i,r[i]);if(ct)for(var i of ct(r))jo.call(r,i)&&Nt(g,i,r[i]);return g},T=(g,r)=>br(g,xr(r));var Wo=g=>typeof g=="symbol"?g:g+"",Z=(g,r)=>{var i={};for(var H in g)Vo.call(g,H)&&r.indexOf(H)<0&&(i[H]=g[H]);if(g!=null&&ct)for(var H of ct(g))r.indexOf(H)<0&&jo.call(g,H)&&(i[H]=g[H]);return i};var w=(g,r,i)=>(Nt(g,typeof r!="symbol"?r+"":r,i),i);var _=(g,r,i)=>new Promise((H,oe)=>{var b=E=>{try{Q(i.next(E))}catch(he){oe(he)}},y=E=>{try{Q(i.throw(E))}catch(he){oe(he)}},Q=E=>E.done?H(E.value):Promise.resolve(E.value).then(b,y);Q((i=i.apply(g,r)).next())});const $e=b.createContext({});function Y(){return b.useContext($e)}const p="workflow";function D(e,t={}){return i.i18n.t(e,T(C({},t),{ns:p}))}function dt(){return Q.useTranslation(p)}const ne=i.createStyles(({css:e,token:t})=>({workflowPageClass:e`
2
2
  flex-grow: 1;
3
3
  overflow: hidden;
4
4
  display: flex;
@@ -355,7 +355,7 @@
355
355
  max-height: 30em;
356
356
  overflow-y: auto;
357
357
  }
358
- `,children:r.jsx(y.Button,{"aria-label":e["aria-label"]||"add-button",shape:"circle",icon:r.jsx($.PlusOutlined,{})})})}):null}const pt=(e,t)=>({getAriaLabel:b.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])}),Ho=i.createStyles(({css:e,token:t})=>({container:e`
358
+ `,children:r.jsx(y.Button,{"aria-label":e["aria-label"]||"add-button",shape:"circle",icon:r.jsx(E.PlusOutlined,{})})})}):null}const pt=(e,t)=>({getAriaLabel:b.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])}),Ho=i.createStyles(({css:e,token:t})=>({container:e`
359
359
  margin-bottom: 1.5em;
360
360
  padding: 1em;
361
361
  background-color: ${t.colorFillAlter};
@@ -396,7 +396,7 @@
396
396
  }
397
397
  `,noStatusButtonClass:e`
398
398
  border-width: 2px;
399
- `}));function Ee(e){var n;const{styles:t}=Go();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:s,color:a}=e.statusMap[e.status];o=r.jsx(y.Tag,{color:a,children:s})}return r.jsx(y.Button,T(C({},e),{shape:"circle",size:"small",className:_o(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const de={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},ze=[{value:de.QUEUEING,label:`{{t("Queueing", { ns: "${p}" })}}`,color:"blue",icon:r.jsx($.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${p}" })}}`},{value:de.STARTED,label:`{{t("On going", { ns: "${p}" })}}`,color:"gold",icon:r.jsx($.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${p}" })}}`},{value:de.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:r.jsx($.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${p}" })}}`},{value:de.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:r.jsx($.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${p}" })}}`},{value:de.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:r.jsx($.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${p}" })}}`},{value:de.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:r.jsx($.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${p}" })}}`},{value:de.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx($.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${p}" })}}`},{value:de.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx($.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${p}" })}}`},{value:de.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx($.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${p}" })}}`}],He=ze.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),ie={PENDING:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},mt=[{value:ie.PENDING,label:`{{t("Pending", { ns: "${p}" })}}`,color:"gold",icon:r.jsx($.ClockCircleOutlined,{})},{value:ie.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:r.jsx($.CheckOutlined,{})},{value:ie.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:r.jsx($.ExclamationOutlined,{})},{value:ie.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:r.jsx($.CloseOutlined,{})},{value:ie.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:r.jsx($.MinusOutlined,{rotate:90})},{value:ie.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx($.MinusOutlined,{rotate:45})},{value:ie.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx($.MinusOutlined,{})},{value:ie.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx($.RedoOutlined,{})}],Je=mt.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")}}function Yo(){const e=j.useForm(),t=i.useAPIClient(),o=i.useActionContext(),{refresh:n}=i.useResourceActionContext(),s=Ce(),{workflow:a}=Y();return{run(){return _(this,null,function*(){var c,u;if(a.executed){y.message.error(E("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(u=(c=t.resource("flow_nodes")).update)==null?void 0:u.call(c,{filterByTk:s.id,values:{config:e.values}}),o.setFormValueChanged(!1),o.setVisible(!1),n()})}}}const ft=b.createContext({});function Ce(){return b.useContext(ft)}function It(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 Pt(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 Bt({data:e}){const{styles:t}=ne(),{getAriaLabel:o}=pt(e),n=i.usePlugin(ce),{Component:s=ht,end:a}=n.instructions.get(e.type);return r.jsx(ft.Provider,{value:e,children:r.jsxs("div",{className:i.cx(t.nodeBlockClass),children:[r.jsx(s,{data:e}),!a||typeof a=="function"&&!a(e)?r.jsx($t,{"aria-label":o(),upstream:e}):r.jsx("div",{className:"end-sign",children:r.jsx($.CloseOutlined,{})})]})})}function Vt(){var d;const{t:e}=Q.useTranslation(),t=i.useAPIClient(),{workflow:o,nodes:n,refresh:s}=(d=Y())!=null?d:{},a=Ce(),{modal:l}=y.App.useApp();if(!o)return null;const c=t.resource("flow_nodes");function u(){return _(this,null,function*(){function f(){return _(this,null,function*(){var m;yield(m=c.destroy)==null?void 0:m.call(c,{filterByTk:a.id}),s()})}const h=n.filter(m=>m===a?!1:H.parse(m.config).parameters.filter(({key:N})=>N.startsWith(`$jobsMapByNodeKey.${a.key}.`)||N===`$jobsMapByNodeKey.${a.key}`).length);if(h.length){l.error({title:E("Can not delete"),content:E("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 x=!n.find(m=>m.upstream===a&&m.branchIndex!=null)?e("Are you sure you want to delete it?"):E("This node contains branches, deleting will also be preformed to them, are you sure?");l.confirm({title:e("Delete"),content:x,onOk:f})})}return o.executed?null:r.jsx(y.Button,{type:"text",shape:"circle",icon:r.jsx($.DeleteOutlined,{}),onClick:u,className:"workflow-node-remove-button"})}function jt(){var a;const{execution:e,setViewJob:t}=Y(),{jobs:o}=(a=Ce())!=null?a:{},{styles:n}=ne();if(!e)return null;if(!o.length)return r.jsx(Ee,{className:n.nodeJobButtonClass,disabled:!0});function s({key:l}){const c=o.find(u=>u.id==l);t(c)}return o.length>1?r.jsx(y.Dropdown,{menu:{items:o.map(l=>({key:l.id,label:r.jsxs(r.Fragment,{children:[r.jsx(Ee,{statusMap:Je,status:l.status}),r.jsx("time",{children:H.str2moment(l.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),onClick:s,className:n.dropdownClass},children:r.jsx(Ee,{statusMap:Je,status:o[o.length-1].status,className:n.nodeJobButtonClass})}):r.jsx(Ee,{statusMap:Je,status:o[0].status,onClick:()=>t(o[0]),className:n.nodeJobButtonClass})}function qo(){return{form:j.useForm()}}function ht(e){var F,M;const{data:t,children:o}=e,n=i.useCompile(),s=i.useAPIClient(),{workflow:a,refresh:l}=(F=Y())!=null?F:{},{styles:c}=ne(),d=i.usePlugin(ce).instructions.get(t.type),f=a.executed?'{{t("View")}}':'{{t("Configure")}}',h=n(d.title),[v,x]=b.useState((M=t.title)!=null?M:h),[m,k]=b.useState(!1),[S,N]=b.useState(!1),A=b.useMemo(()=>{const O=ut.cloneDeep(t.config);return he.createForm({initialValues:O,disabled:a.executed})},[t,a]),P=b.useCallback(O=>{k(O),O||A.reset()},[A]),z=b.useCallback(function(O){return _(this,null,function*(){var L,J;const I=O||h;x(I),I!==t.title&&(yield(J=(L=s.resource("flow_nodes")).update)==null?void 0:J.call(L,{filterByTk:t.id,values:{title:I}}),l())})},[t]),U=b.useCallback(function(O){if(O.target===O.currentTarget){k(!0);return}const I=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let L=O.target;L&&L!==O.currentTarget&&L!==document.documentElement;L=L.parentNode)if(Array.from(L.classList).some(J=>I.has(J))){k(!0),O.stopPropagation();return}},[]);return r.jsxs("div",{className:i.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:[r.jsxs("div",{role:"button","aria-label":`${h}-${v}`,className:i.cx(c.nodeCardClass,{configuring:m}),onClick:U,children:[r.jsxs("div",{className:i.cx(c.nodeMetaClass,"workflow-node-meta"),children:[r.jsx(y.Tag,{children:h}),r.jsx("span",{className:"workflow-node-id",children:t.id})]}),r.jsx(y.Input.TextArea,{disabled:a.executed,value:v,onChange:O=>x(O.target.value),onBlur:O=>z(O.target.value),autoSize:!0}),r.jsx(Vt,{}),r.jsx(jt,{}),r.jsx(i.ActionContextProvider,{value:{visible:m,setVisible:P,formValueChanged:S,setFormValueChanged:N},children:r.jsx(i.FormProvider,{form:A,children:r.jsx(i.SchemaComponent,{distributed:!1,scope:T(C({},d.scope),{useFormProviderProps:qo}),components:d.components,schema:{type:"void",properties:T(C({},d.view?{view:d.view}:{}),{button:{type:"void","x-content":f,"x-component":y.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},[t.id]:{type:"void",title:r.jsxs("div",{className:i.css`
399
+ `}));function Ee(e){var n;const{styles:t}=Go();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:s,color:a}=e.statusMap[e.status];o=r.jsx(y.Tag,{color:a,children:s})}return r.jsx(y.Button,T(C({},e),{shape:"circle",size:"small",className:_o(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const de={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},ze=[{value:de.QUEUEING,label:`{{t("Queueing", { ns: "${p}" })}}`,color:"blue",icon:r.jsx(E.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${p}" })}}`},{value:de.STARTED,label:`{{t("On going", { ns: "${p}" })}}`,color:"gold",icon:r.jsx(E.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${p}" })}}`},{value:de.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:r.jsx(E.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${p}" })}}`},{value:de.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:r.jsx(E.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${p}" })}}`},{value:de.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:r.jsx(E.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${p}" })}}`},{value:de.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:r.jsx(E.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${p}" })}}`},{value:de.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(E.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${p}" })}}`},{value:de.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(E.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${p}" })}}`},{value:de.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(E.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${p}" })}}`}],He=ze.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),ie={PENDING:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},mt=[{value:ie.PENDING,label:`{{t("Pending", { ns: "${p}" })}}`,color:"gold",icon:r.jsx(E.ClockCircleOutlined,{})},{value:ie.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:r.jsx(E.CheckOutlined,{})},{value:ie.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:r.jsx(E.ExclamationOutlined,{})},{value:ie.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:r.jsx(E.CloseOutlined,{})},{value:ie.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:r.jsx(E.MinusOutlined,{rotate:90})},{value:ie.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(E.MinusOutlined,{rotate:45})},{value:ie.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(E.MinusOutlined,{})},{value:ie.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(E.RedoOutlined,{})}],Je=mt.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")}}function Yo(){const e=j.useForm(),t=i.useAPIClient(),o=i.useActionContext(),{refresh:n}=i.useResourceActionContext(),s=Ce(),{workflow:a}=Y();return{run(){return _(this,null,function*(){var c,u;if(a.executed){y.message.error(D("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(u=(c=t.resource("flow_nodes")).update)==null?void 0:u.call(c,{filterByTk:s.id,values:{config:e.values}}),o.setFormValueChanged(!1),o.setVisible(!1),n()})}}}const ft=b.createContext({});function Ce(){return b.useContext(ft)}function It(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 Pt(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 Bt({data:e}){const{styles:t}=ne(),{getAriaLabel:o}=pt(e),n=i.usePlugin(ce),{Component:s=ht,end:a}=n.instructions.get(e.type);return r.jsx(ft.Provider,{value:e,children:r.jsxs("div",{className:i.cx(t.nodeBlockClass),children:[r.jsx(s,{data:e}),!a||typeof a=="function"&&!a(e)?r.jsx($t,{"aria-label":o(),upstream:e}):r.jsx("div",{className:"end-sign",children:r.jsx(E.CloseOutlined,{})})]})})}function Vt(){var d;const{t:e}=Q.useTranslation(),t=i.useAPIClient(),{workflow:o,nodes:n,refresh:s}=(d=Y())!=null?d:{},a=Ce(),{modal:l}=y.App.useApp();if(!o)return null;const c=t.resource("flow_nodes");function u(){return _(this,null,function*(){function f(){return _(this,null,function*(){var m;yield(m=c.destroy)==null?void 0:m.call(c,{filterByTk:a.id}),s()})}const h=n.filter(m=>m===a?!1:H.parse(m.config).parameters.filter(({key:N})=>N.startsWith(`$jobsMapByNodeKey.${a.key}.`)||N===`$jobsMapByNodeKey.${a.key}`).length);if(h.length){l.error({title:D("Can not delete"),content:D("The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",{nodes:h.map(m=>`#${m.id}`).join(", ")})});return}const x=!n.find(m=>m.upstream===a&&m.branchIndex!=null)?e("Are you sure you want to delete it?"):D("This node contains branches, deleting will also be preformed to them, are you sure?");l.confirm({title:e("Delete"),content:x,onOk:f})})}return o.executed?null:r.jsx(y.Button,{type:"text",shape:"circle",icon:r.jsx(E.DeleteOutlined,{}),onClick:u,className:"workflow-node-remove-button"})}function jt(){var a;const{execution:e,setViewJob:t}=Y(),{jobs:o}=(a=Ce())!=null?a:{},{styles:n}=ne();if(!e)return null;if(!o.length)return r.jsx(Ee,{className:n.nodeJobButtonClass,disabled:!0});function s({key:l}){const c=o.find(u=>u.id==l);t(c)}return o.length>1?r.jsx(y.Dropdown,{menu:{items:o.map(l=>({key:l.id,label:r.jsxs(r.Fragment,{children:[r.jsx(Ee,{statusMap:Je,status:l.status}),r.jsx("time",{children:H.str2moment(l.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),onClick:s,className:n.dropdownClass},children:r.jsx(Ee,{statusMap:Je,status:o[o.length-1].status,className:n.nodeJobButtonClass})}):r.jsx(Ee,{statusMap:Je,status:o[0].status,onClick:()=>t(o[0]),className:n.nodeJobButtonClass})}function qo(){return{form:j.useForm()}}function ht(e){var F,M;const{data:t,children:o}=e,n=i.useCompile(),s=i.useAPIClient(),{workflow:a,refresh:l}=(F=Y())!=null?F:{},{styles:c}=ne(),d=i.usePlugin(ce).instructions.get(t.type),f=a.executed?'{{t("View")}}':'{{t("Configure")}}',h=n(d.title),[v,x]=b.useState((M=t.title)!=null?M:h),[m,k]=b.useState(!1),[S,N]=b.useState(!1),A=b.useMemo(()=>{const O=ut.cloneDeep(t.config);return he.createForm({initialValues:O,disabled:a.executed})},[t,a]),P=b.useCallback(O=>{k(O),O||A.reset()},[A]),z=b.useCallback(function(O){return _(this,null,function*(){var L,J;const I=O||h;x(I),I!==t.title&&(yield(J=(L=s.resource("flow_nodes")).update)==null?void 0:J.call(L,{filterByTk:t.id,values:{title:I}}),l())})},[t]),U=b.useCallback(function(O){if(O.target===O.currentTarget){k(!0);return}const I=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let L=O.target;L&&L!==O.currentTarget&&L!==document.documentElement;L=L.parentNode)if(Array.from(L.classList).some(J=>I.has(J))){k(!0),O.stopPropagation();return}},[]);return r.jsxs("div",{className:i.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:[r.jsxs("div",{role:"button","aria-label":`${h}-${v}`,className:i.cx(c.nodeCardClass,{configuring:m}),onClick:U,children:[r.jsxs("div",{className:i.cx(c.nodeMetaClass,"workflow-node-meta"),children:[r.jsx(y.Tag,{children:h}),r.jsx("span",{className:"workflow-node-id",children:t.id})]}),r.jsx(y.Input.TextArea,{disabled:a.executed,value:v,onChange:O=>x(O.target.value),onBlur:O=>z(O.target.value),autoSize:!0}),r.jsx(Vt,{}),r.jsx(jt,{}),r.jsx(i.ActionContextProvider,{value:{visible:m,setVisible:P,formValueChanged:S,setFormValueChanged:N},children:r.jsx(i.FormProvider,{form:A,children:r.jsx(i.SchemaComponent,{distributed:!1,scope:T(C({},d.scope),{useFormProviderProps:qo}),components:d.components,schema:{type:"void",properties:T(C({},d.view?{view:d.view}:{}),{button:{type:"void","x-content":f,"x-component":y.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},[t.id]:{type:"void",title:r.jsxs("div",{className:i.css`
400
400
  display: flex;
401
401
  justify-content: space-between;
402
402
 
@@ -411,7 +411,7 @@
411
411
  code {
412
412
  font-weight: normal;
413
413
  }
414
- `,children:[r.jsx("strong",{children:t.title}),r.jsx(y.Tooltip,{title:E("Variable key of node"),children:r.jsx(y.Tag,{children:r.jsx("code",{children:t.key})})})]}),"x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps","x-component":"Action.Drawer",properties:T(C({},d.description?{description:{type:"void","x-component":Et,"x-component-props":{label:E("Node type"),title:d.title,description:d.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
414
+ `,children:[r.jsx("strong",{children:t.title}),r.jsx(y.Tooltip,{title:D("Variable key of node"),children:r.jsx(y.Tag,{children:r.jsx("code",{children:t.key})})})]}),"x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps","x-component":"Action.Drawer",properties:T(C({},d.description?{description:{type:"void","x-component":Et,"x-component-props":{label:D("Node type"),title:d.title,description:d.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
415
415
  .ant-input,
416
416
  .ant-select,
417
417
  .ant-cascader-picker,
@@ -423,34 +423,34 @@
423
423
  min-width: 6em;
424
424
  }
425
425
  }
426
- `},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:Yo}}}}})}})}})})})]}),o]})}function Ue({from:e=null,entry:t=null,branchIndex:o=null,controller:n=null,className:s,end:a}){const{styles:l}=ne(),{getAriaLabel:c}=pt(e,o),u=[];for(let d=t;d;d=d.downstream)u.push(d);return r.jsxs("div",{className:i.cx("workflow-branch",l.branchClass,s),children:[r.jsx("div",{className:"workflow-branch-lines"}),n,r.jsx($t,{"aria-label":c(),upstream:e,branchIndex:o}),r.jsx("div",{className:"workflow-node-list",children:u.map(d=>r.jsx(Bt,{data:d},d.id))}),a?r.jsx("div",{className:"end-sign",children:r.jsx($.CloseOutlined,{})}):null]})}function Ko(){var a;const e=j.useForm(),t=i.useAPIClient(),{workflow:o}=(a=Y())!=null?a:{},n=i.useActionContext(),{refresh:s}=i.useResourceActionContext();return{run(){return _(this,null,function*(){if(o.executed){y.message.error(E("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 yt{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 Zo(){const e=i.useCompile(),{workflow:t,execution:o}=Y(),{styles:n}=ne(),s=gt();return o?r.jsx(i.SchemaComponent,{schema:{type:"void",name:"execution","x-component":"Action","x-component-props":{title:r.jsx($.InfoOutlined,{}),shape:"circle",size:"small",className:n.nodeJobButtonClass,type:"primary"},properties:{[o.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:r.jsxs("div",{className:i.cx(n.nodeTitleClass),children:[r.jsx(y.Tag,{children:e(s.title)}),r.jsx("strong",{children:t.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",o.id]})]}),properties:{createdAt:{type:"string",title:`{{t("Triggered at", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},context:{type:"object",title:`{{t("Trigger variables", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:i.css`
426
+ `},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:Yo}}}}})}})}})})})]}),o]})}function Ue({from:e=null,entry:t=null,branchIndex:o=null,controller:n=null,className:s,end:a}){const{styles:l}=ne(),{getAriaLabel:c}=pt(e,o),u=[];for(let d=t;d;d=d.downstream)u.push(d);return r.jsxs("div",{className:i.cx("workflow-branch",l.branchClass,s),children:[r.jsx("div",{className:"workflow-branch-lines"}),n,r.jsx($t,{"aria-label":c(),upstream:e,branchIndex:o}),r.jsx("div",{className:"workflow-node-list",children:u.map(d=>r.jsx(Bt,{data:d},d.id))}),a?r.jsx("div",{className:"end-sign",children:r.jsx(E.CloseOutlined,{})}):null]})}function Ko(){var a;const e=j.useForm(),t=i.useAPIClient(),{workflow:o}=(a=Y())!=null?a:{},n=i.useActionContext(),{refresh:s}=i.useResourceActionContext();return{run(){return _(this,null,function*(){if(o.executed){y.message.error(D("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 yt{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 Zo(){const e=i.useCompile(),{workflow:t,execution:o}=Y(),{styles:n}=ne(),s=gt();return o?r.jsx(i.SchemaComponent,{schema:{type:"void",name:"execution","x-component":"Action","x-component-props":{title:r.jsx(E.InfoOutlined,{}),shape:"circle",size:"small",className:n.nodeJobButtonClass,type:"primary"},properties:{[o.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:r.jsxs("div",{className:i.cx(n.nodeTitleClass),children:[r.jsx(y.Tag,{children:e(s.title)}),r.jsx("strong",{children:t.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",o.id]})]}),properties:{createdAt:{type:"string",title:`{{t("Triggered at", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},context:{type:"object",title:`{{t("Trigger variables", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:i.css`
427
427
  padding: 1em;
428
428
  background-color: #eee;
429
- `},"x-read-pretty":!0}}}}}}):null}function Qo(){return{form:j.useForm()}}const Xo=()=>{const e=i.useAPIClient(),{workflow:t,refresh:o}=Y(),[n,s]=b.useState(""),[a,l]=b.useState(!1),[c,u]=b.useState(!1),{styles:d}=ne(),f=i.useCompile(),h=gt(),v=f(h.title),{fieldset:x,scope:m,components:k}=h,S=t.executed?'{{t("View")}}':'{{t("Configure")}}',N=E("Trigger");b.useEffect(()=>{var F,M;t&&s((M=(F=t.triggerTitle)!=null?F:t.title)!=null?M:v)},[t]);const A=b.useMemo(()=>{const F=ut.cloneDeep(t.config);return he.createForm({initialValues:F,disabled:t.executed})},[t]),P=b.useCallback(F=>{l(F),F||A.reset()},[A]),z=b.useCallback(function(F){return _(this,null,function*(){const M=F||v;s(M),M!==t.triggerTitle&&(yield e.resource("workflows").update({filterByTk:t.id,values:{triggerTitle:M}}),o())})},[t]),U=b.useCallback(function(F){var O;if(F.target===F.currentTarget){l(!0);return}const M=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let I=F.target;I&&I!==F.currentTarget;I=I.parentNode)if(Array.from((O=I.classList)!=null?O:[]).some(L=>M.has(L))){l(!0),F.stopPropagation();return}},[]);return r.jsxs("div",{role:"button","aria-label":`${N}-${n}`,className:i.cx(d.nodeCardClass),onClick:U,children:[r.jsx("div",{className:i.cx(d.nodeMetaClass,"workflow-node-meta"),children:r.jsx(y.Tag,{color:"gold",children:N})}),r.jsx("div",{children:r.jsx(y.Input.TextArea,{value:n,onChange:F=>s(F.target.value),onBlur:F=>z(F.target.value),autoSize:!0})}),r.jsx(Zo,{}),r.jsx(i.ActionContextProvider,{value:{visible:a,setVisible:P,formValueChanged:c,setFormValueChanged:u},children:r.jsx(i.FormProvider,{form:A,children:r.jsx(i.SchemaComponent,{scope:T(C({},m),{useFormProviderProps:Qo}),components:k,schema:{name:`workflow-trigger-${t.id}`,type:"void",properties:{config:{type:"void","x-content":S,"x-component":y.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},drawer:{type:"void",title:N,"x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps",properties:T(C({},h.description?{description:{type:"void","x-component":Et,"x-component-props":{label:E("Trigger type"),title:h.title,description:h.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
429
+ `},"x-read-pretty":!0}}}}}}):null}function Qo(){return{form:j.useForm()}}const Xo=()=>{const e=i.useAPIClient(),{workflow:t,refresh:o}=Y(),[n,s]=b.useState(""),[a,l]=b.useState(!1),[c,u]=b.useState(!1),{styles:d}=ne(),f=i.useCompile(),h=gt(),v=f(h.title),{fieldset:x,scope:m,components:k}=h,S=t.executed?'{{t("View")}}':'{{t("Configure")}}',N=D("Trigger");b.useEffect(()=>{var F,M;t&&s((M=(F=t.triggerTitle)!=null?F:t.title)!=null?M:v)},[t]);const A=b.useMemo(()=>{const F=ut.cloneDeep(t.config);return he.createForm({initialValues:F,disabled:t.executed})},[t]),P=b.useCallback(F=>{l(F),F||A.reset()},[A]),z=b.useCallback(function(F){return _(this,null,function*(){const M=F||v;s(M),M!==t.triggerTitle&&(yield e.resource("workflows").update({filterByTk:t.id,values:{triggerTitle:M}}),o())})},[t]),U=b.useCallback(function(F){var O;if(F.target===F.currentTarget){l(!0);return}const M=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let I=F.target;I&&I!==F.currentTarget;I=I.parentNode)if(Array.from((O=I.classList)!=null?O:[]).some(L=>M.has(L))){l(!0),F.stopPropagation();return}},[]);return r.jsxs("div",{role:"button","aria-label":`${N}-${n}`,className:i.cx(d.nodeCardClass),onClick:U,children:[r.jsx("div",{className:i.cx(d.nodeMetaClass,"workflow-node-meta"),children:r.jsx(y.Tag,{color:"gold",children:N})}),r.jsx("div",{children:r.jsx(y.Input.TextArea,{value:n,onChange:F=>s(F.target.value),onBlur:F=>z(F.target.value),autoSize:!0,disabled:t.executed})}),r.jsx(Zo,{}),r.jsx(i.ActionContextProvider,{value:{visible:a,setVisible:P,formValueChanged:c,setFormValueChanged:u},children:r.jsx(i.FormProvider,{form:A,children:r.jsx(i.SchemaComponent,{scope:T(C({},m),{useFormProviderProps:Qo}),components:k,schema:{name:`workflow-trigger-${t.id}`,type:"void",properties:{config:{type:"void","x-content":S,"x-component":y.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},drawer:{type:"void",title:N,"x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useFormProviderProps",properties:T(C({},h.description?{description:{type:"void","x-component":Et,"x-component-props":{label:D("Trigger type"),title:h.title,description:h.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:i.css`
430
430
  .ant-select.auto-width {
431
431
  width: auto;
432
432
  min-width: 6em;
433
433
  }
434
434
  `},properties:x},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:Ko}}}})})}}}})})})]})};function gt(){const e=i.usePlugin(ce),{workflow:t}=Y();return e.triggers.get(t.type)}function Wt({entry:e}){const{styles:t}=ne(),{workflow:o}=Y(),[n,s]=b.useState(100);return r.jsxs("div",{className:"workflow-canvas-wrapper",children:[r.jsx("div",{className:"workflow-canvas",style:{zoom:n/100},children:r.jsx("div",{className:i.cx(t.branchBlockClass,i.css`
435
435
  margin-top: 0 !important;
436
- `),children:r.jsxs("div",{className:t.branchClass,children:[o!=null&&o.executed?r.jsx(y.Alert,{type:"warning",message:E("Executed workflow cannot be modified"),showIcon:!0,className:i.css`
436
+ `),children:r.jsxs("div",{className:t.branchClass,children:[o!=null&&o.executed?r.jsx(y.Alert,{type:"warning",message:D("Executed workflow cannot be modified. Could be copied to a new version to modify."),showIcon:!0,className:i.css`
437
437
  margin-bottom: 1em;
438
438
  `}):null,r.jsx(Xo,{}),r.jsx("div",{className:i.cx(t.branchBlockClass,i.css`
439
439
  margin-top: 0 !important;
440
- `),children:r.jsx(Ue,{entry:e})}),r.jsx("div",{className:t.terminalClass,children:E("End")})]})})}),r.jsx("div",{className:"workflow-canvas-zoomer",children:r.jsx(y.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:n,onChange:s})})]})}function bt(e){const t=new Map;e.forEach(o=>t.set(o.id,o));for(const o of t.values())o.upstreamId&&(o.upstream=t.get(o.upstreamId)),o.downstreamId&&(o.downstream=t.get(o.downstreamId))}function xt(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{xt(e.properties[o],t)})}function xe(e){return`/admin/workflow/workflows/${e}`}function _e(e){return`/admin/workflow/executions/${e}`}function Ro(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const s=o.get(n.nodeId);s.jobs.push(n),n.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((s,a)=>s.id-a.id)})}function en(){const{instructions:e}=i.usePlugin(ce),t=i.useCompile(),{viewJob:o,setViewJob:n}=Y(),{styles:s}=ne(),{node:a={}}=o!=null?o:{},l=e.get(a.type);return r.jsx(i.ActionContextProvider,{value:{visible:!!o,setVisible:n},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`${o==null?void 0:o.id}-${o==null?void 0:o.updatedAt}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:r.jsxs("div",{className:s.nodeTitleClass,children:[r.jsx(y.Tag,{children:t(l==null?void 0:l.title)}),r.jsx("strong",{children:a.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",a.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:mt,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:s.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function tn(e){const{execution:t}=Y(),o=i.useAPIClient(),n=oe.useNavigate(),{styles:s}=ne(),[a,l]=b.useState([]),[c,u]=b.useState([]);b.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{l(f.data)}).catch(()=>{})},[t]),b.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{u(f.data.reverse())}).catch(()=>{})},[t]);const d=b.useCallback(({key:f})=>{f!=t.id&&n(_e(f))},[t]);return t?r.jsx(y.Dropdown,{menu:{onClick:d,defaultSelectedKeys:[`${t.id}`],className:i.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...a].map(f=>({key:f.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${f.id}`}),r.jsx("time",{children:H.str2moment(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(Ee,{statusMap:He,status:f.status})})}))},children:r.jsxs(y.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx($.DownOutlined,{})]})}):null}function on(){var A;const{t:e}=Q.useTranslation(),t=i.useCompile(),{data:o,loading:n,refresh:s}=i.useResourceActionContext(),{setTitle:a}=i.useDocumentTitle(),[l,c]=b.useState(null),u=i.useApp(),d=i.useAPIClient();b.useEffect(()=>{var M;const{workflow:F}=(M=o==null?void 0:o.data)!=null?M:{};a==null||a(`${F!=null&&F.title?`${F.title} - `:""}${E("Execution history")}`)},[o==null?void 0:o.data]);const f=b.useCallback(()=>{y.Modal.confirm({title:E("Cancel the execution"),icon:r.jsx($.ExclamationCircleFilled,{}),content:E("Are you sure you want to cancel the execution?"),onOk:()=>{d.resource("executions").cancel({filterByTk:o==null?void 0:o.data.id}).then(()=>{y.message.success(e("Operation succeeded")),s()}).catch(F=>{console.error(F.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return n?r.jsx(y.Spin,{}):r.jsx(y.Result,{status:"404",title:"Not found"});const P=(A=o==null?void 0:o.data)!=null?A:{},{jobs:h=[],workflow:z={}}=P,U=z,{nodes:v=[],revisions:x=[]}=U,m=Z(U,["nodes","revisions"]),k=Z(P,["jobs","workflow"]);bt(v),Ro(v,h);const S=v.find(F=>!F.upstream),N=He[k.status];return r.jsxs($e.Provider,{value:{workflow:m.type?m:null,nodes:v,execution:k,viewJob:l,setViewJob:c},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(y.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:u.pluginSettingsManager.getRoutePath("workflow"),children:E("Workflow")})},{title:r.jsx(oe.Link,{to:xe(m.id),children:m.title})},{title:r.jsx(tn,{})}]})}),r.jsxs("aside",{children:[r.jsx(y.Tag,{color:N.color,children:t(N.label)}),k.status?null:r.jsx(y.Tooltip,{title:E("Cancel the execution"),children:r.jsx(y.Button,{type:"link",danger:!0,onClick:f,shape:"circle",size:"small",icon:r.jsx($.StopOutlined,{})})}),r.jsx("time",{children:H.str2moment(k.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(Wt,{entry:S}),r.jsx(en,{})]})}const Lt=()=>{const e=oe.useParams(),{styles:t}=ne();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`execution_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:e,appends:["jobs","workflow","workflow.nodes"]}}},"x-component":"ExecutionCanvas"}}},components:{ExecutionCanvas:on}})})},zt=()=>{const{t:e}=Q.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext();return r.jsx(oe.Link,{to:_e(t),onClick:()=>o(!1),children:e("View")})},nn={name:"execution-executions",fields:[{interface:"id",type:"bigInt",name:"id",uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${p}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${p}" })}}`,"x-component"({value:e}){const{setVisible:t}=i.useActionContext();return r.jsx(oe.Link,{to:xe(e),onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${p}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:ze}}]},Ht={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${p}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:nn,resourceName:"executions",request:{resource:"executions",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"],filter:{}}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=Q.useTranslation(),{refresh:t,defaultRequest:o}=i.useResourceActionContext(),{resource:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext();return{run(){return _(this,null,function*(){var l;yield n.destroy({filter:(l=o.params)==null?void 0:l.filter}),y.message.success(e("Operation succeeded")),t(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${p}" })}}`,content:`{{t("Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?", { ns: "${p}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:`{{t("Status", { ns: "${p}" })}}`,properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void","x-component":"ExecutionLink"}}}}}}}}}}};function Jt(e){var a;const o=i.useCompile()(e.label),n=b.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:s}=(a=He[e.value])!=null?a:{};return r.jsx(y.Tag,{color:s,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function rn(e){const t=i.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Jt,C({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function sn(t){var e=Z(t,[]);const o=e.multiple?"multiple":null;return r.jsx(y.Select,T(C({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Jt,children:ze.filter(n=>!!n.value&&n.value!==de.ABORTED).map(n=>r.jsx(y.Select.Option,T(C({},n),{children:r.jsx(rn,C({},n))}),n.value))}))}function Ut(e){const{t}=Q.useTranslation(),{refresh:o}=i.useResourceActionContext(),{resource:n}=i.useResourceContext(),s=i.useRecord(),a=b.useCallback(()=>{y.Modal.confirm({title:E("Cancel the execution"),icon:r.jsx($.ExclamationCircleFilled,{}),content:E("Are you sure you want to cancel the execution?"),onOk:()=>{n.cancel({filterByTk:s.id}).then(()=>{y.message.success(t("Operation succeeded")),o()}).catch(l=>{console.error(l.data.error)})}})},[s]);return r.jsxs("div",{className:i.css`
440
+ `),children:r.jsx(Ue,{entry:e})}),r.jsx("div",{className:t.terminalClass,children:D("End")})]})})}),r.jsx("div",{className:"workflow-canvas-zoomer",children:r.jsx(y.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:n,onChange:s})})]})}function bt(e){const t=new Map;e.forEach(o=>t.set(o.id,o));for(const o of t.values())o.upstreamId&&(o.upstream=t.get(o.upstreamId)),o.downstreamId&&(o.downstream=t.get(o.downstreamId))}function xt(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{xt(e.properties[o],t)})}function xe(e){return`/admin/workflow/workflows/${e}`}function _e(e){return`/admin/workflow/executions/${e}`}function Ro(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const s=o.get(n.nodeId);s.jobs.push(n),n.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((s,a)=>s.id-a.id)})}function en(){const{instructions:e}=i.usePlugin(ce),t=i.useCompile(),{viewJob:o,setViewJob:n}=Y(),{styles:s}=ne(),{node:a={}}=o!=null?o:{},l=e.get(a.type);return r.jsx(i.ActionContextProvider,{value:{visible:!!o,setVisible:n},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`${o==null?void 0:o.id}-${o==null?void 0:o.updatedAt}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:r.jsxs("div",{className:s.nodeTitleClass,children:[r.jsx(y.Tag,{children:t(l==null?void 0:l.title)}),r.jsx("strong",{children:a.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",a.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:mt,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:s.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function tn(e){const{execution:t}=Y(),o=i.useAPIClient(),n=oe.useNavigate(),{styles:s}=ne(),[a,l]=b.useState([]),[c,u]=b.useState([]);b.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{l(f.data)}).catch(()=>{})},[t]),b.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:f})=>{u(f.data.reverse())}).catch(()=>{})},[t]);const d=b.useCallback(({key:f})=>{f!=t.id&&n(_e(f))},[t]);return t?r.jsx(y.Dropdown,{menu:{onClick:d,defaultSelectedKeys:[`${t.id}`],className:i.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...a].map(f=>({key:f.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${f.id}`}),r.jsx("time",{children:H.str2moment(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(Ee,{statusMap:He,status:f.status})})}))},children:r.jsxs(y.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(E.DownOutlined,{})]})}):null}function on(){var A;const{t:e}=Q.useTranslation(),t=i.useCompile(),{data:o,loading:n,refresh:s}=i.useResourceActionContext(),{setTitle:a}=i.useDocumentTitle(),[l,c]=b.useState(null),u=i.useApp(),d=i.useAPIClient();b.useEffect(()=>{var M;const{workflow:F}=(M=o==null?void 0:o.data)!=null?M:{};a==null||a(`${F!=null&&F.title?`${F.title} - `:""}${D("Execution history")}`)},[o==null?void 0:o.data]);const f=b.useCallback(()=>{y.Modal.confirm({title:D("Cancel the execution"),icon:r.jsx(E.ExclamationCircleFilled,{}),content:D("Are you sure you want to cancel the execution?"),onOk:()=>{d.resource("executions").cancel({filterByTk:o==null?void 0:o.data.id}).then(()=>{y.message.success(e("Operation succeeded")),s()}).catch(F=>{console.error(F.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return n?r.jsx(y.Spin,{}):r.jsx(y.Result,{status:"404",title:"Not found"});const P=(A=o==null?void 0:o.data)!=null?A:{},{jobs:h=[],workflow:z={}}=P,U=z,{nodes:v=[],revisions:x=[]}=U,m=Z(U,["nodes","revisions"]),k=Z(P,["jobs","workflow"]);bt(v),Ro(v,h);const S=v.find(F=>!F.upstream),N=He[k.status];return r.jsxs($e.Provider,{value:{workflow:m.type?m:null,nodes:v,execution:k,viewJob:l,setViewJob:c},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(y.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:u.pluginSettingsManager.getRoutePath("workflow"),children:D("Workflow")})},{title:r.jsx(y.Tooltip,{title:`Key: ${m.key}`,children:r.jsx(oe.Link,{to:xe(m.id),children:m.title})})},{title:r.jsx(tn,{})}]})}),r.jsxs("aside",{children:[r.jsx(y.Tag,{color:N.color,children:t(N.label)}),k.status?null:r.jsx(y.Tooltip,{title:D("Cancel the execution"),children:r.jsx(y.Button,{type:"link",danger:!0,onClick:f,shape:"circle",size:"small",icon:r.jsx(E.StopOutlined,{})})}),r.jsx("time",{children:H.str2moment(k.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(Wt,{entry:S}),r.jsx(en,{})]})}const Lt=()=>{const e=oe.useParams(),{styles:t}=ne();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`execution_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:e,appends:["jobs","workflow","workflow.nodes"]}}},"x-component":"ExecutionCanvas"}}},components:{ExecutionCanvas:on}})})},zt=()=>{const{t:e}=Q.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext();return r.jsx(oe.Link,{to:_e(t),onClick:()=>o(!1),children:e("View")})},nn={name:"execution-executions",fields:[{interface:"id",type:"bigInt",name:"id",uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${p}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${p}" })}}`,"x-component"({value:e}){const{setVisible:t}=i.useActionContext();return r.jsx(oe.Link,{to:xe(e),onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${p}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:ze}}]},Ht={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${p}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:nn,resourceName:"executions",request:{resource:"executions",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"],filter:{}}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=Q.useTranslation(),{refresh:t,defaultRequest:o}=i.useResourceActionContext(),{resource:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext();return{run(){return _(this,null,function*(){var l;yield n.destroy({filter:(l=o.params)==null?void 0:l.filter}),y.message.success(e("Operation succeeded")),t(),s(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${p}" })}}`,content:`{{t("Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?", { ns: "${p}" })}}`}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:`{{t("Status", { ns: "${p}" })}}`,properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void","x-component":"ExecutionLink"}}}}}}}}}}};function Jt(e){var a;const o=i.useCompile()(e.label),n=b.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:s}=(a=He[e.value])!=null?a:{};return r.jsx(y.Tag,{color:s,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function rn(e){const t=i.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Jt,C({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function sn(t){var e=Z(t,[]);const o=e.multiple?"multiple":null;return r.jsx(y.Select,T(C({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Jt,children:ze.filter(n=>!!n.value&&n.value!==de.ABORTED).map(n=>r.jsx(y.Select.Option,T(C({},n),{children:r.jsx(rn,C({},n))}),n.value))}))}function Ut(e){const{t}=Q.useTranslation(),{refresh:o}=i.useResourceActionContext(),{resource:n}=i.useResourceContext(),s=i.useRecord(),a=b.useCallback(()=>{y.Modal.confirm({title:D("Cancel the execution"),icon:r.jsx(E.ExclamationCircleFilled,{}),content:D("Are you sure you want to cancel the execution?"),onOk:()=>{n.cancel({filterByTk:s.id}).then(()=>{y.message.success(t("Operation succeeded")),o()}).catch(l=>{console.error(l.data.error)})}})},[s]);return r.jsxs("div",{className:i.css`
441
441
  display: flex;
442
- `,children:[e.children,s.status?null:r.jsx(y.Tooltip,{title:E("Cancel the execution"),children:r.jsx(y.Button,{type:"link",danger:!0,onClick:a,shape:"circle",size:"small",icon:r.jsx($.StopOutlined,{})})})]})}function _t(){const e=i.useResourceActionContext();return{onClick(){return _(this,null,function*(){var o;(o=e==null?void 0:e.refresh)==null||o.call(e)})}}}function ln(n){var s=n,{request:e,filter:t={}}=s,o=Z(s,["request","filter"]);var c;const{workflow:a}=Y(),l=T(C({},o),{request:T(C({},e),{params:T(C({},e==null?void 0:e.params),{filter:T(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,C({},l))}function an(){var F;const e=oe.useNavigate(),{t}=Q.useTranslation(),o=i.useApp(),{data:n,refresh:s,loading:a}=i.useResourceActionContext(),{resource:l}=i.useResourceContext(),{setTitle:c}=i.useDocumentTitle(),[u,d]=b.useState(!1),{styles:f}=ne(),{modal:h}=y.App.useApp();if(b.useEffect(()=>{var I;const{title:O}=(I=n==null?void 0:n.data)!=null?I:{};c==null||c(`${E("Workflow")}${O?`: ${O}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return a?r.jsx(y.Spin,{}):r.jsx(y.Result,{status:"404",title:"Not found"});const M=(F=n==null?void 0:n.data)!=null?F:{},{nodes:v=[],revisions:x=[]}=M,m=Z(M,["nodes","revisions"]);bt(v);const k=v.find(O=>!O.upstream);function S({key:O}){O!=m.id&&e(xe(O))}function N(O){return _(this,null,function*(){yield l.update({filterByTk:m.id,values:{enabled:O}}),s()})}function A(){return _(this,null,function*(){const{data:{data:O}}=yield l.revision({filterByTk:m.id,filter:{key:m.key}});y.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${O.id}`)})}function P(){return _(this,null,function*(){const O=m.current?E("Delete a main version will cause all other revisions to be deleted too."):"";h.confirm({title:t("Are you sure you want to delete it?"),content:O,onOk(){return _(this,null,function*(){var L;yield l.destroy({filterByTk:m.id}),y.message.success(t("Operation succeeded")),e(m.current?o.pluginSettingsManager.getRoutePath("workflow"):xe((L=x.find(J=>J.current))==null?void 0:L.id))})}})})}function z(I){return _(this,arguments,function*({key:O}){switch(O){case"history":d(!0);return;case"revision":return A();case"delete":return P()}})}const U=m.executed&&!x.find(O=>!O.executed&&new Date(O.createdAt)>new Date(m.createdAt));return r.jsxs($e.Provider,{value:{workflow:m,nodes:v,refresh:s},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(y.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:E("Workflow")})},{title:r.jsx("strong",{children:m.title})}]})}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(y.Dropdown,{trigger:["click"],menu:{onClick:S,defaultSelectedKeys:[`${m.id}`],className:i.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:x.sort((O,I)=>I.id-O.id).map((O,I)=>({role:"button","aria-label":`version-${I}`,key:`${O.id}`,icon:O.current?r.jsx($.RightOutlined,{}):null,className:i.cx({executed:O.executed,unexecuted:!O.executed,enabled:O.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${O.id}`}),r.jsx("time",{children:H.str2moment(O.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(y.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:E("Version")}),r.jsx("span",{children:m!=null&&m.id?`#${m.id}`:null}),r.jsx($.DownOutlined,{})]})})}),r.jsx(y.Switch,{checked:m.enabled,onChange:N,checkedChildren:E("On"),unCheckedChildren:E("Off")}),r.jsx(y.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:E("Execution history"),disabled:!m.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:E("Copy to new version"),disabled:!U},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")}],onClick:z},children:r.jsx(y.Button,{"aria-label":"more",type:"text",icon:r.jsx($.EllipsisOutlined,{})})}),r.jsx(i.ActionContextProvider,{value:{visible:u,setVisible:d},children:r.jsx(i.SchemaComponent,{schema:Ht,components:{ExecutionResourceProvider:ln,ExecutionLink:zt,ExecutionStatusColumn:Ut},scope:{useRefreshActionProps:_t}})})]})]}),r.jsx(Wt,{entry:k})]})}const Gt=()=>{const e=oe.useParams(),{styles:t}=ne();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:an}})})},cn=n=>{var s=n,{request:e,filter:t={}}=s,o=Z(s,["request","filter"]);var c;const a=i.useRecord(),l=T(C({},o),{request:T(C({},e),{params:T(C({},e==null?void 0:e.params),{filter:T(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,C({},l))},un=()=>{const{t:e}=Q.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext(),{getAriaLabel:n}=i.useGetAriaLabelOfAction("Configure");return r.jsx(oe.Link,{"aria-label":n(),to:xe(t),onClick:()=>o(!1),children:e("Configure")})};function dn(n){var s=n,{component:e="div",children:t}=s,o=Z(s,["component","children"]);const[a,l]=b.useState(!1),c=j.useFieldSchema();return r.jsxs(i.ActionContextProvider,{value:{visible:a,setVisible:l,fieldSchema:c},children:[b.createElement(e,T(C({},o),{onClick(){l(!0)}}),t),r.jsx(i.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}function pn({data:e}){const{label:t,color:o,options:n}=e,s=i.useCompile();return r.jsxs(y.Space,{direction:"vertical",children:[r.jsx(y.Tag,{color:o,children:s(t)}),r.jsx(y.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:s(n.description)})]})}const Yt={name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Trigger type", { ns: "${p}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}",optionRender:pn,popupMatchSelectWidth:!0,listHeight:300},required:!0}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${p}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${p}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${p}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${p}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},pe={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${p}" }) }}`,description:`{{ t("Execute workflow asynchronously or synchronously based on trigger type, and could not be changed after created.", { ns: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Asynchronously", { ns: "${p}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${p}" }) }}`},{label:`{{ t("Synchronously", { ns: "${p}" }) }}`,value:!0,tooltip:`{{ t("For user actions that require immediate feedback. Can not use asynchronous nodes in such mode, and it is not recommended to perform time-consuming operations under synchronous mode.", { ns: "${p}" }) }}`}]}},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"fieldset",properties:{deleteExecutionOnStatus:{type:"array",title:`{{ t("Auto delete history when execution is on end status", { ns: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},mn={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Yt,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:Yt},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"cm.useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},sync:{type:"void",title:`{{t("Sync", { ns: "${p}" })}}`,"x-decorator":"Tooltip","x-decorator-props":{title:`{{ t("Sync enabled status of all workflows from database", { ns: "${p}" }) }}`},"x-component":"Action","x-component-props":{icon:"SyncOutlined",useAction(){const{t:e}=Q.useTranslation(),{resource:t}=i.useResourceContext();return{run(){return _(this,null,function*(){yield t.sync(),y.message.success(e("Operation succeeded"))})}}}},"x-reactions":["{{useWorkflowSyncAction}}"]},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:pe.title,type:pe.type,sync:pe.sync,description:pe.description,options:pe.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=i.useRecord();return b.createElement("a",C({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:Ht}}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{ t("Edit") }}',properties:{title:pe.title,enabled:pe.enabled,sync:pe.sync,description:pe.description,options:pe.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},revision:{type:"void",title:`{{t("Duplicate", { ns: "${p}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${p}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=Q.useTranslation(),{refresh:t}=i.useResourceActionContext(),{resource:o,targetKey:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext(),{[n]:a}=i.useRecord(),{values:l}=j.useForm();return{run(){return _(this,null,function*(){yield o.revision({filterByTk:a,values:l}),y.message.success(e("Operation succeeded")),t(),s(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"}}}}}}}}}}}};function fn(e){const t=j.useField(),o=i.useRecord(),n=i.usePlugin(ce);return j.useFormEffects(s=>{he.onFieldChange("type",a=>{let l=o.id||!a.value;if(a.value){const c=n.triggers.get(a.value);c.sync!=null?(l=!0,t.setValue(c.sync)):t.setInitialValue(!1)}t.setPattern(l?"disabled":"editable")})}),b.useEffect(()=>{if(o.id){t.setPattern("disabled");const s=n.triggers.get(o.type);s.sync!=null?t.setValue(s.sync):t.setInitialValue(!1)}},[o.id,t,n.triggers]),r.jsx(Be,C({},e))}function hn(e){const t=i.useApp();e.visible=!!(i.usePlugin("multi-app-share-collection")||t.name!=="main")}function yn(){const e=b.useContext(i.SchemaComponentContext),{getTriggersOptions:t}=i.usePlugin(ce);return r.jsx(y.Card,{bordered:!1,children:r.jsx(i.SchemaComponentContext.Provider,{value:T(C({},e),{designable:!1}),children:r.jsx(i.SchemaComponent,{schema:mn,components:{WorkflowLink:un,ExecutionResourceProvider:cn,ExecutionLink:zt,OpenDrawer:dn,ExecutionStatusSelect:sn,SyncOptionSelect:fn,ExecutionStatusColumn:Ut,Tooltip:y.Tooltip},scope:{getTriggersOptions:t,useWorkflowSyncAction:hn,useRefreshActionProps:_t}})})})}function gn(n){var s=n,{collection:e,dataPath:t}=s,o=Z(s,["collection","dataPath"]);const{insert:a}=i.useSchemaInitializer(),{getTemplateSchemaByMode:l}=i.useSchemaTemplateManager(),{getCollection:c}=i.useCollectionManager_deprecated(),u=i.useRecordCollectionDataSourceItems("FormItem");let d;if(typeof e=="string"){const[h,v]=i.parseCollectionName(e);d=c(v,h)}else d=e;function f(v){return _(this,arguments,function*({item:h}){const x=h.template?yield l(h):null,m={type:"void",name:Dt.uid(),title:d.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:e,dataPath:t},"x-component":"CardItem","x-component-props":{title:o.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-use-component-props":"useDetailsBlockProps","x-read-pretty":!0,properties:{grid:x||{type:"void","x-component":"Grid","x-initializer":"details:configureFields",properties:{}}}}}};xt(m,k=>{k["x-uid"]&&delete k["x-uid"]}),a(m)})}return r.jsx(i.SchemaInitializerItem,T(C({},o),{onClick:f,items:u}))}function Me(e){var a;const t=i.useSchemaInitializerItem(),o=(a=e==null?void 0:e.collection)!=null?a:t.collection;let n,s;if(typeof o=="string"){const l=i.parseCollectionName(o);n=l[0],s=l[1]}else s=o;return r.jsx(i.CollectionProvider_deprecated,{dataSource:n,collection:s,children:r.jsx(gn,C(C({},t),e))})}function bn(){return!0}const vt=j.observer(e=>{const d=e,{filter:t=bn}=d,o=Z(d,["filter"]),n=i.useCompile(),{getCollectionFields:s}=i.useCollectionManager_deprecated(),{values:a}=j.useForm(),[l,c]=i.parseCollectionName(a==null?void 0:a.collection),u=s(c,l);return r.jsx(y.Select,T(C({popupMatchSelectWidth:!1},o),{options:u.filter(t).map(f=>{var h;return{label:n((h=f.uiSchema)==null?void 0:h.title),value:f.name}})}))},{displayName:"FieldsSelect"}),le={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"},qt={type:"object",title:'{{t("Fields values")}}',description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:i.css`
442
+ `,children:[e.children,s.status?null:r.jsx(y.Tooltip,{title:D("Cancel the execution"),children:r.jsx(y.Button,{type:"link",danger:!0,onClick:a,shape:"circle",size:"small",icon:r.jsx(E.StopOutlined,{})})})]})}function _t(){const e=i.useResourceActionContext();return{onClick(){return _(this,null,function*(){var o;(o=e==null?void 0:e.refresh)==null||o.call(e)})}}}function ln(n){var s=n,{request:e,filter:t={}}=s,o=Z(s,["request","filter"]);var c;const{workflow:a}=Y(),l=T(C({},o),{request:T(C({},e),{params:T(C({},e==null?void 0:e.params),{filter:T(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,C({},l))}function an(){var F;const e=oe.useNavigate(),{t}=Q.useTranslation(),o=i.useApp(),{data:n,refresh:s,loading:a}=i.useResourceActionContext(),{resource:l}=i.useResourceContext(),{setTitle:c}=i.useDocumentTitle(),[u,d]=b.useState(!1),{styles:f}=ne(),{modal:h}=y.App.useApp();if(b.useEffect(()=>{var I;const{title:O}=(I=n==null?void 0:n.data)!=null?I:{};c==null||c(`${D("Workflow")}${O?`: ${O}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return a?r.jsx(y.Spin,{}):r.jsx(y.Result,{status:"404",title:"Not found",extra:r.jsx(y.Button,{onClick:()=>e(-1),children:D("Go back")})});const M=(F=n==null?void 0:n.data)!=null?F:{},{nodes:v=[],revisions:x=[]}=M,m=Z(M,["nodes","revisions"]);bt(v);const k=v.find(O=>!O.upstream);function S({key:O}){O!=m.id&&e(xe(O))}function N(O){return _(this,null,function*(){yield l.update({filterByTk:m.id,values:{enabled:O}}),s()})}function A(){return _(this,null,function*(){const{data:{data:O}}=yield l.revision({filterByTk:m.id,filter:{key:m.key}});y.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${O.id}`)})}function P(){return _(this,null,function*(){const O=m.current?D("Delete a main version will cause all other revisions to be deleted too."):"";h.confirm({title:t("Are you sure you want to delete it?"),content:O,onOk(){return _(this,null,function*(){var L;yield l.destroy({filterByTk:m.id}),y.message.success(t("Operation succeeded")),e(m.current?o.pluginSettingsManager.getRoutePath("workflow"):xe((L=x.find(J=>J.current))==null?void 0:L.id))})}})})}function z(I){return _(this,arguments,function*({key:O}){switch(O){case"history":d(!0);return;case"revision":return A();case"delete":return P()}})}const U=m.executed&&!x.find(O=>!O.executed&&new Date(O.createdAt)>new Date(m.createdAt));return r.jsxs($e.Provider,{value:{workflow:m,nodes:v,refresh:s},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(y.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:D("Workflow")})},{title:r.jsx(y.Tooltip,{title:`Key: ${m.key}`,children:r.jsx("strong",{children:m.title})})}]})}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(y.Dropdown,{trigger:["click"],menu:{onClick:S,defaultSelectedKeys:[`${m.id}`],className:i.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:x.sort((O,I)=>I.id-O.id).map((O,I)=>({role:"button","aria-label":`version-${I}`,key:`${O.id}`,icon:O.current?r.jsx(E.RightOutlined,{}):null,className:i.cx({executed:O.executed,unexecuted:!O.executed,enabled:O.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${O.id}`}),r.jsx("time",{children:H.str2moment(O.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(y.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:D("Version")}),r.jsx("span",{children:m!=null&&m.id?`#${m.id}`:null}),r.jsx(E.DownOutlined,{})]})})}),r.jsx(y.Switch,{checked:m.enabled,onChange:N,checkedChildren:D("On"),unCheckedChildren:D("Off")}),r.jsx(y.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:D("Execution history"),disabled:!m.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:D("Copy to new version"),disabled:!U},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")}],onClick:z},children:r.jsx(y.Button,{"aria-label":"more",type:"text",icon:r.jsx(E.EllipsisOutlined,{})})}),r.jsx(i.ActionContextProvider,{value:{visible:u,setVisible:d},children:r.jsx(i.SchemaComponent,{schema:Ht,components:{ExecutionResourceProvider:ln,ExecutionLink:zt,ExecutionStatusColumn:Ut},scope:{useRefreshActionProps:_t}})})]})]}),r.jsx(Wt,{entry:k})]})}const Gt=()=>{const e=oe.useParams(),{styles:t}=ne();return r.jsx("div",{className:i.cx(t.workflowPageClass),children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:an}})})},cn=n=>{var s=n,{request:e,filter:t={}}=s,o=Z(s,["request","filter"]);var c;const a=i.useRecord(),l=T(C({},o),{request:T(C({},e),{params:T(C({},e==null?void 0:e.params),{filter:T(C({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:a.key})})})});return r.jsx(i.ResourceActionProvider,C({},l))},un=()=>{const{t:e}=Q.useTranslation(),{id:t}=i.useRecord(),{setVisible:o}=i.useActionContext(),{getAriaLabel:n}=i.useGetAriaLabelOfAction("Configure");return r.jsx(oe.Link,{"aria-label":n(),to:xe(t),onClick:()=>o(!1),children:e("Configure")})};function dn(n){var s=n,{component:e="div",children:t}=s,o=Z(s,["component","children"]);const[a,l]=b.useState(!1),c=j.useFieldSchema();return r.jsxs(i.ActionContextProvider,{value:{visible:a,setVisible:l,fieldSchema:c},children:[b.createElement(e,T(C({},o),{onClick(){l(!0)}}),t),r.jsx(i.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}function pn({data:e}){const{label:t,color:o,options:n}=e,s=i.useCompile();return r.jsxs(y.Space,{direction:"vertical",children:[r.jsx(y.Tag,{color:o,children:s(t)}),r.jsx(y.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:s(n.description)})]})}const Yt={name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Trigger type", { ns: "${p}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}",optionRender:pn,popupMatchSelectWidth:!0,listHeight:300},required:!0}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${p}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${p}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${p}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${p}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},pe={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${p}" }) }}`,description:`{{ t("Execute workflow asynchronously or synchronously based on trigger type, and could not be changed after created.", { ns: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Asynchronously", { ns: "${p}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${p}" }) }}`},{label:`{{ t("Synchronously", { ns: "${p}" }) }}`,value:!0,tooltip:`{{ t("For user actions that require immediate feedback. Can not use asynchronous nodes in such mode, and it is not recommended to perform time-consuming operations under synchronous mode.", { ns: "${p}" }) }}`}]}},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"fieldset",properties:{deleteExecutionOnStatus:{type:"array",title:`{{ t("Auto delete history when execution is on end status", { ns: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},mn={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Yt,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:Yt},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"cm.useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},sync:{type:"void",title:`{{t("Sync", { ns: "${p}" })}}`,"x-decorator":"Tooltip","x-decorator-props":{title:`{{ t("Sync enabled status of all workflows from database", { ns: "${p}" }) }}`},"x-component":"Action","x-component-props":{icon:"SyncOutlined",useAction(){const{t:e}=Q.useTranslation(),{resource:t}=i.useResourceContext(),o=i.useResourceActionContext();return{run(){return _(this,null,function*(){yield t.sync(),yield o==null?void 0:o.refresh(),y.message.success(e("Operation succeeded"))})}}}},"x-reactions":["{{useWorkflowSyncAction}}"]},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:pe.title,type:pe.type,sync:pe.sync,description:pe.description,options:pe.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=i.useRecord();return b.createElement("a",C({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:Ht}}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{ t("Edit") }}',properties:{title:pe.title,enabled:pe.enabled,sync:pe.sync,description:pe.description,options:pe.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},revision:{type:"void",title:`{{t("Duplicate", { ns: "${p}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${p}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=Q.useTranslation(),{refresh:t}=i.useResourceActionContext(),{resource:o,targetKey:n}=i.useResourceContext(),{setVisible:s}=i.useActionContext(),{[n]:a}=i.useRecord(),{values:l}=j.useForm();return{run(){return _(this,null,function*(){yield o.revision({filterByTk:a,values:l}),y.message.success(e("Operation succeeded")),t(),s(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"}}}}}}}}}}}};function fn(e){const t=j.useField(),o=i.useRecord(),n=i.usePlugin(ce);return j.useFormEffects(s=>{he.onFieldChange("type",a=>{let l=o.id||!a.value;if(a.value){const c=n.triggers.get(a.value);c.sync!=null?(l=!0,t.setValue(c.sync)):t.setInitialValue(!1)}t.setPattern(l?"disabled":"editable")})}),b.useEffect(()=>{if(o.id){t.setPattern("disabled");const s=n.triggers.get(o.type);s.sync!=null?t.setValue(s.sync):t.setInitialValue(!1)}},[o.id,t,n.triggers]),r.jsx(Be,C({},e))}function hn(e){const t=i.useApp();e.visible=!!(i.usePlugin("multi-app-share-collection")||t.name!=="main")}function yn(){const e=b.useContext(i.SchemaComponentContext),{getTriggersOptions:t}=i.usePlugin(ce);return r.jsx(y.Card,{bordered:!1,children:r.jsx(i.SchemaComponentContext.Provider,{value:T(C({},e),{designable:!1}),children:r.jsx(i.SchemaComponent,{schema:mn,components:{WorkflowLink:un,ExecutionResourceProvider:cn,ExecutionLink:zt,OpenDrawer:dn,ExecutionStatusSelect:sn,SyncOptionSelect:fn,ExecutionStatusColumn:Ut,Tooltip:y.Tooltip},scope:{getTriggersOptions:t,useWorkflowSyncAction:hn,useRefreshActionProps:_t}})})})}function gn(n){var s=n,{collection:e,dataPath:t}=s,o=Z(s,["collection","dataPath"]);const{insert:a}=i.useSchemaInitializer(),{getTemplateSchemaByMode:l}=i.useSchemaTemplateManager(),{getCollection:c}=i.useCollectionManager_deprecated(),u=i.useRecordCollectionDataSourceItems("FormItem");let d;if(typeof e=="string"){const[h,v]=i.parseCollectionName(e);d=c(v,h)}else d=e;function f(v){return _(this,arguments,function*({item:h}){const x=h.template?yield l(h):null,m={type:"void",name:Dt.uid(),title:d.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:e,dataPath:t},"x-component":"CardItem","x-component-props":{title:o.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-use-component-props":"useDetailsBlockProps","x-read-pretty":!0,properties:{grid:x||{type:"void","x-component":"Grid","x-initializer":"details:configureFields",properties:{}}}}}};xt(m,k=>{k["x-uid"]&&delete k["x-uid"]}),a(m)})}return r.jsx(i.SchemaInitializerItem,T(C({},o),{onClick:f,items:u}))}function Me(e){var a;const t=i.useSchemaInitializerItem(),o=(a=e==null?void 0:e.collection)!=null?a:t.collection;let n,s;if(typeof o=="string"){const l=i.parseCollectionName(o);n=l[0],s=l[1]}else s=o;return r.jsx(i.CollectionProvider_deprecated,{dataSource:n,collection:s,children:r.jsx(gn,C(C({},t),e))})}function bn(){return!0}const vt=j.observer(e=>{const d=e,{filter:t=bn}=d,o=Z(d,["filter"]),n=i.useCompile(),{getCollectionFields:s}=i.useCollectionManager_deprecated(),{values:a}=j.useForm(),[l,c]=i.parseCollectionName(a==null?void 0:a.collection),u=s(c,l);return r.jsx(y.Select,T(C({popupMatchSelectWidth:!1},o),{options:u.filter(t).map(f=>{var h;return{label:n((h=f.uiSchema)==null?void 0:h.title),value:f.name}})}))},{displayName:"FieldsSelect"}),le={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"},qt={type:"object",title:'{{t("Fields values")}}',description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:i.css`
443
443
  flex-direction: column;
444
444
  `},"x-component":"CollectionFieldset"},Ge={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:e}=j.useForm(),[t,o]=i.parseCollectionName(e==null?void 0:e.collection);return{options:i.useCollectionFilterOptions(o,t),className:i.css`
445
445
  position: relative;
446
446
  width: 100%;
447
- `}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},xn={type:"array",title:'{{t("Sort")}}',"x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:"{{useSortableFields()}}",required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:'{{t("ASC")}}',value:"asc"},{label:'{{t("DESC")}}',value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{t("Add sort field")}}',"x-component":"ArrayItems.Addition"}}},vn={type:"void",title:'{{t("Pagination")}}',"x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{page:{type:"void","x-component":"Grid.Col",properties:{page:{type:"number",title:'{{t("Page number")}}',"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:["number","null"]},default:1}}},pageSize:{type:"void","x-component":"Grid.Col",properties:{pageSize:{type:"number",title:'{{t("Page size")}}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:1,max:100},default:20}}}}}}},Ie={type:"array",title:`{{t("Preload associations", { ns: "${p}" })}}`,description:`{{t("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=j.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},ke={label:"label",value:"value",children:"children"},Kt={label:`{{t("Node result", { ns: "${p}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=i.usePlugin(ce),o=Ce(),n=It(o),s=[];return n.forEach(a=>{var u;const l=t.get(a.type),c=(u=l.useVariables)==null?void 0:u.call(l,a,e);c&&s.push(c)}),s}},Zt={label:`{{t("Trigger variables", { ns: "${p}" })}}`,value:"$context",useOptions(e){var s,a;const{triggers:t}=i.usePlugin(ce),{workflow:o}=Y(),n=t.get(o.type);return(a=(s=n==null?void 0:n.useVariables)==null?void 0:s.call(n,o.config,e))!=null?a:null}},Qt={label:`{{t("Scope variables", { ns: "${p}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=ke,current:o}=e,{instructions:n}=i.usePlugin(ce),s=Ce(),a=o!=null?o:s,l=Pt(a),c=[];return l.forEach(u=>{var h,v;const d=n.get(u.type),f=(h=d.useScopeVariables)==null?void 0:h.call(d,u,e);f&&c.push({key:u.key,[t.value]:u.key,[t.label]:(v=u.title)!=null?v:`#${u.id}`,[t.children]:f})}),c}},Xt={label:`{{t("System variables", { ns: "${p}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=ke}){return[...!e||e.includes("date")?[{key:"now",[t.label]:E("System time"),[t.value]:"now"}]:[]]}},Ye={boolean:new Set(["checkbox"]),number:new Set(["integer","number","percent"]),string:new Set(["input","password","email","phone","select","radioGroup","text","markdown","richText","expression","time"]),date:new Set(["date","createdAt","updatedAt"])};function Rt(e,t){var o,n,s,a,l,c;return typeof t=="string"?(o=Ye[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?wt(e)?((n=t.options)==null?void 0:n.entity)&&(e.collectionName===((s=t.options)==null?void 0:s.collection)||((a=t.options)==null?void 0:a.collection)==="*"):e.isForeignKey?e.collectionName===((l=t.options)==null?void 0:l.collection)&&e.name==="id"||e.target===((c=t.options)==null?void 0:c.collection):!1:typeof t=="function"?t(e):!1}function wt(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function Ct(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function kt({fields:e,types:t,appends:o,depth:n=1,compile:s,getCollectionFields:a}){return e.filter(l=>{const c=t!=null&&t.length?t.some(u=>Rt(l,u)):!0;if(wt(l)){if(o===null)return n?c||kt({fields:St(l.target,{compile:s,getCollectionFields:a}),types:t,depth:n-1,appends:o,compile:s,getCollectionFields:a}):!1;const u=Ct(l,o),d=o.includes(l.name);return c?d:((u==null?void 0:u.length)||d)&&kt({fields:St(l.target,{compile:s,getCollectionFields:a}),types:t,appends:u,compile:s,getCollectionFields:a}).length}else return c})}function qe(e,t){var a,l;const o=i.useCompile(),n=(l=(a=e.useOptions)==null?void 0:a.call(e,t))==null?void 0:l.filter(Boolean),{fieldNames:s}=t;return{[s.label]:o(e.label),[s.value]:e.value,key:e[s.value],[s.children]:n,disabled:!n||!n.length}}function ge(e={}){var s;const t=Object.assign({},ke,(s=e.fieldNames)!=null?s:{}),o=Object.assign(e,{fieldNames:t});return[qe(Qt,o),qe(Kt,o),qe(Zt,o),qe(Xt,o)]}function St(e,{compile:t,getCollectionFields:o}){var u,d,f,h,v,x,m;const[n,s]=i.parseCollectionName(e),a=o(s,n),l=[],c=[];a.forEach(k=>{k.isForeignKey?l.push(k):c.push(k)});for(let k=c.length-1;k>=0;k--){const S=c[k];if(S.type==="belongsTo"){const N=l.find(A=>A.name===S.foreignKey);N?c.splice(k,0,T(C(C({},S),N),{uiSchema:T(C({},S.uiSchema),{title:(u=S.uiSchema)!=null&&u.title?`${t((d=S.uiSchema)==null?void 0:d.title)} ID`:N.name})})):c.splice(k,0,T(C({},S),{name:S.foreignKey,type:"bigInt",isForeignKey:!0,interface:S.interface,uiSchema:T(C({},S.uiSchema),{title:(f=S.uiSchema)!=null&&f.title?`${t((h=S.uiSchema)==null?void 0:h.title)} ID`:S.name})}))}else if(S.type==="context"&&S.collectionName==="users"){const N=(v=c.find(A=>A.type==="belongsTo"&&A.target==="users"&&A.foreignKey===S.name))!=null?v:{};c.splice(k,0,T(C({},S),{type:S.dataType,interface:N.interface,uiSchema:T(C({},N.uiSchema),{title:(x=N.uiSchema)!=null&&x.title?`${t((m=N.uiSchema)==null?void 0:m.title)} ID`:S.name})}))}}return c.filter(k=>k.interface&&!k.hidden)}function wn(e){const t=Ct(e.field,e.appends),o=Se(C({collection:`${e.field.dataSourceKey&&e.field.dataSourceKey!=="main"?`${e.field.dataSourceKey}:`:""}${e.field.target}`,types:e.types,appends:t,depth:e.depth-1},this));e.loadChildren=null,o.length?e.children=o:(e.isLeaf=!0,!e.types||e.types.some(s=>Rt(e.field,s))||(e.disabled=!0))}function Se(e){const{fields:t,collection:o,types:n,appends:s=[],depth:a=1,compile:l,getCollectionFields:c,fieldNames:u=ke}=e,d=t!=null?t:St(o,{compile:l,getCollectionFields:c}),f=wn.bind({compile:l,getCollectionFields:c,fieldNames:u});return kt({fields:d,types:n,depth:a,appends:s,compile:l,getCollectionFields:c}).map(v=>{var S;const x=l(((S=v.uiSchema)==null?void 0:S.title)||v.name),m=Ct(v,s),k=!wt(v)||m&&!m.length&&!s.includes(v.name)||!1;return{[u.label]:x,key:v.name,[u.value]:v.name,isLeaf:k,loadChildren:k?null:f,field:v,depth:a,appends:s,types:n}})}function eo(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=ge(e);return r.jsx(i.Variable.Input,C({scope:s},t))}function At(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=ge(e);return r.jsx(i.Variable.TextArea,C({scope:s},t))}function Cn(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=ge(e);return r.jsx(i.Variable.RawTextArea,C({scope:s},t))}function kn(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=ge(e);return r.jsx(i.Variable.JSON,C({scope:s},t))}function Sn(){const e=i.useAPIClient(),t=j.useForm(),{field:o,__parent:n}=i.useBlockRequestContext(),{setVisible:s}=i.useActionContext(),a=oe.useNavigate(),l=j.useFieldSchema(),c=j.useField(),u=i.useCompile(),{modal:d}=y.App.useApp(),f=i.useCollectValuesToSubmit(),h=c.componentProps.filterKeys||[];return{onClick(){return _(this,null,function*(){var N,A,P;const{onSuccess:x,skipValidator:m,triggerWorkflows:k}=(N=l==null?void 0:l["x-action-settings"])!=null?N:{};m||(yield t.submit());const S=yield f();c.data=o.data||{},c.data.loading=!0;try{const z=yield e.resource("workflows").trigger({values:S,filterKeys:h,triggerWorkflows:k!=null&&k.length?k.map(U=>[U.workflowKey,U.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.loading=!1,c.data.data=z,(P=(A=n==null?void 0:n.service)==null?void 0:A.refresh)==null||P.call(A),s==null||s(!1),!(x!=null&&x.successMessage))return;x!=null&&x.manualClose?d.success({title:u(x==null?void 0:x.successMessage),onOk:()=>_(this,null,function*(){yield t.reset(),x!=null&&x.redirecting&&(x!=null&&x.redirectTo)&&(H.isURL(x.redirectTo)?window.location.href=x.redirectTo:a(x.redirectTo))})}):y.message.success(u(x==null?void 0:x.successMessage))}catch(z){c.data.loading=!1}})}}}function An(){var x;const e=i.useCompile(),t=i.useAPIClient(),o=i.useRecord(),n=j.useField(),s=j.useFieldSchema(),{field:a,__parent:l}=i.useBlockRequestContext(),{setVisible:c,setSubmitted:u}=i.useActionContext(),{modal:d}=y.App.useApp(),f=oe.useNavigate(),{onSuccess:h,triggerWorkflows:v}=(x=s==null?void 0:s["x-action-settings"])!=null?x:{};return{onClick(k,S){return _(this,null,function*(){n.data=a.data||{},n.data.loading=!0;try{if(yield t.resource("workflows").trigger({values:o,triggerWorkflows:v!=null&&v.length?v.map(N=>[N.workflowKey,N.context].filter(Boolean).join("!")).join(","):void 0}),S&&S(),c==null||c(!1),u==null||u(!0),!(h!=null&&h.successMessage))return;if(h!=null&&h.manualClose){let N;d.success({title:e(h==null?void 0:h.successMessage),onOk(){return _(this,null,function*(){h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(H.isURL(h.redirectTo)?window.location.href=h.redirectTo:f(h.redirectTo))})}})}else y.message.success(e(h==null?void 0:h.successMessage))}catch(N){console.error(N)}finally{n.data.loading=!1}})}}}function On(){const{workflow:e}=Y();return!!(e!=null&&e.executed)}function to(){const{workflow:e}=Y();return!!(e!=null&&e.allExecuted)}const Ae={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},Tn=[{label:`{{t("After record added", { ns: "${p}" })}}`,value:Ae.CREATED},{label:`{{t("After record updated", { ns: "${p}" })}}`,value:Ae.UPDATED},{label:`{{t("After record added or updated", { ns: "${p}" })}}`,value:Ae.SAVED},{label:`{{t("After record deleted", { ns: "${p}" })}}`,value:Ae.DELETED}];class Fn extends yt{constructor(){super(...arguments);w(this,"title",`{{t("Collection event", { ns: "${p}" })}}`);w(this,"description",`{{t('Triggered when data changes in the collection, such as after adding, updating, or deleting a record. Unlike "Post-action event", Collection event listens for data changes rather than HTTP requests. Unless you understand the exact meaning, it is recommended to use "Post-action event".', { ns: "${p}" })}}`);w(this,"fieldset",{collection:T(C({},le),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(o){return o.options.key==="main"||o.options.isDBInstance}},"x-reactions":[...le["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${p}" })}}`,className:"auto-width"},enum:Tn,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${p}" })}}`,description:`{{t("Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(o){return!o.hidden&&(o.uiSchema?!o.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(o.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Ae.UPDATED})}}`}}}]},condition:T(C({},Ge),{title:`{{t("Only triggers when match conditions", { ns: "${p}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:T(C({},Ie),{"x-reactions":[...Ie["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Ae.DELETED})}}`}}}]})});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource,useWorkflowAnyExecuted:to});w(this,"components",{FieldsSelect:vt})}useVariables(o,n){var u;const s=i.useCompile(),{getCollectionFields:a}=i.useCollectionManager_deprecated(),l=[{collectionName:o.collection,name:"data",type:"hasOne",target:o.collection,uiSchema:{title:E("Trigger data")}}];return Se(T(C({appends:["data",...((u=o.appends)==null?void 0:u.map(d=>`data.${d}`))||[]]},n),{fields:l,compile:s,getCollectionFields:a}))}useInitializers(o){return o.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Me,collection:o.collection,dataPath:"$context.data"}:null}}const ve={STATIC:0,DATE_FIELD:1};function Nn(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function oo({value:e,onChange:t}){const o=e!=null?e:{},{t:n}=Q.useTranslation(),[s,a]=b.useState(o.offset?o.offset/Math.abs(o.offset):0);return r.jsxs("fieldset",{className:i.css`
447
+ `}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},xn={type:"array",title:'{{t("Sort")}}',"x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:"{{useSortableFields()}}",required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:'{{t("ASC")}}',value:"asc"},{label:'{{t("DESC")}}',value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{t("Add sort field")}}',"x-component":"ArrayItems.Addition"}}},vn={type:"void",title:'{{t("Pagination")}}',"x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{page:{type:"void","x-component":"Grid.Col",properties:{page:{type:"number",title:'{{t("Page number")}}',"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:["number","null"]},default:1}}},pageSize:{type:"void","x-component":"Grid.Col",properties:{pageSize:{type:"number",title:'{{t("Page size")}}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:1,max:100},default:20}}}}}}},Ie={type:"array",title:`{{t("Preload associations", { ns: "${p}" })}}`,description:`{{t("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=j.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},ke={label:"label",value:"value",children:"children"},Kt={label:`{{t("Node result", { ns: "${p}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=i.usePlugin(ce),o=Ce(),n=It(o),s=[];return n.forEach(a=>{var u;const l=t.get(a.type),c=(u=l.useVariables)==null?void 0:u.call(l,a,e);c&&s.push(c)}),s}},Zt={label:`{{t("Trigger variables", { ns: "${p}" })}}`,value:"$context",useOptions(e){var s,a;const{triggers:t}=i.usePlugin(ce),{workflow:o}=Y(),n=t.get(o.type);return(a=(s=n==null?void 0:n.useVariables)==null?void 0:s.call(n,o.config,e))!=null?a:null}},Qt={label:`{{t("Scope variables", { ns: "${p}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=ke,current:o}=e,{instructions:n}=i.usePlugin(ce),s=Ce(),a=o!=null?o:s,l=Pt(a),c=[];return l.forEach(u=>{var h,v;const d=n.get(u.type),f=(h=d.useScopeVariables)==null?void 0:h.call(d,u,e);f&&c.push({key:u.key,[t.value]:u.key,[t.label]:(v=u.title)!=null?v:`#${u.id}`,[t.children]:f})}),c}},Xt={label:`{{t("System variables", { ns: "${p}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=ke}){return[...!e||e.includes("date")?[{key:"now",[t.label]:D("System time"),[t.value]:"now"}]:[]]}},Ye={boolean:new Set(["checkbox"]),number:new Set(["integer","number","percent"]),string:new Set(["input","password","email","phone","select","radioGroup","text","markdown","richText","expression","time"]),date:new Set(["date","createdAt","updatedAt"])};function Rt(e,t){var o,n,s,a,l,c;return typeof t=="string"?(o=Ye[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?wt(e)?((n=t.options)==null?void 0:n.entity)&&(e.collectionName===((s=t.options)==null?void 0:s.collection)||((a=t.options)==null?void 0:a.collection)==="*"):e.isForeignKey?e.collectionName===((l=t.options)==null?void 0:l.collection)&&e.name==="id"||e.target===((c=t.options)==null?void 0:c.collection):!1:typeof t=="function"?t(e):!1}function wt(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function Ct(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function kt({fields:e,types:t,appends:o,depth:n=1,compile:s,getCollectionFields:a}){return e.filter(l=>{const c=t!=null&&t.length?t.some(u=>Rt(l,u)):!0;if(wt(l)){if(o===null)return n?c||kt({fields:St(l.target,{compile:s,getCollectionFields:a}),types:t,depth:n-1,appends:o,compile:s,getCollectionFields:a}):!1;const u=Ct(l,o),d=o.includes(l.name);return c?d:((u==null?void 0:u.length)||d)&&kt({fields:St(l.target,{compile:s,getCollectionFields:a}),types:t,appends:u,compile:s,getCollectionFields:a}).length}else return c})}function qe(e,t){var a,l;const o=i.useCompile(),n=(l=(a=e.useOptions)==null?void 0:a.call(e,t))==null?void 0:l.filter(Boolean),{fieldNames:s}=t;return{[s.label]:o(e.label),[s.value]:e.value,key:e[s.value],[s.children]:n,disabled:!n||!n.length}}function ge(e={}){var s;const t=Object.assign({},ke,(s=e.fieldNames)!=null?s:{}),o=Object.assign(e,{fieldNames:t});return[qe(Qt,o),qe(Kt,o),qe(Zt,o),qe(Xt,o)]}function St(e,{compile:t,getCollectionFields:o}){var u,d,f,h,v,x,m;const[n,s]=i.parseCollectionName(e),a=o(s,n),l=[],c=[];a.forEach(k=>{k.isForeignKey?l.push(k):c.push(k)});for(let k=c.length-1;k>=0;k--){const S=c[k];if(S.type==="belongsTo"){const N=l.find(A=>A.name===S.foreignKey);N?c.splice(k,0,T(C(C({},S),N),{uiSchema:T(C({},S.uiSchema),{title:(u=S.uiSchema)!=null&&u.title?`${t((d=S.uiSchema)==null?void 0:d.title)} ID`:N.name})})):c.splice(k,0,T(C({},S),{name:S.foreignKey,type:"bigInt",isForeignKey:!0,interface:S.interface,uiSchema:T(C({},S.uiSchema),{title:(f=S.uiSchema)!=null&&f.title?`${t((h=S.uiSchema)==null?void 0:h.title)} ID`:S.name})}))}else if(S.type==="context"&&S.collectionName==="users"){const N=(v=c.find(A=>A.type==="belongsTo"&&A.target==="users"&&A.foreignKey===S.name))!=null?v:{};c.splice(k,0,T(C({},S),{type:S.dataType,interface:N.interface,uiSchema:T(C({},N.uiSchema),{title:(x=N.uiSchema)!=null&&x.title?`${t((m=N.uiSchema)==null?void 0:m.title)} ID`:S.name})}))}}return c.filter(k=>k.interface&&!k.hidden)}function wn(e){const t=Ct(e.field,e.appends),o=Se(C({collection:`${e.field.dataSourceKey&&e.field.dataSourceKey!=="main"?`${e.field.dataSourceKey}:`:""}${e.field.target}`,types:e.types,appends:t,depth:e.depth-1},this));e.loadChildren=null,o.length?e.children=o:(e.isLeaf=!0,!e.types||e.types.some(s=>Rt(e.field,s))||(e.disabled=!0))}function Se(e){const{fields:t,collection:o,types:n,appends:s=[],depth:a=1,compile:l,getCollectionFields:c,fieldNames:u=ke}=e,d=t!=null?t:St(o,{compile:l,getCollectionFields:c}),f=wn.bind({compile:l,getCollectionFields:c,fieldNames:u});return kt({fields:d,types:n,depth:a,appends:s,compile:l,getCollectionFields:c}).map(v=>{var S;const x=l(((S=v.uiSchema)==null?void 0:S.title)||v.name),m=Ct(v,s),k=!wt(v)||m&&!m.length&&!s.includes(v.name)||!1;return{[u.label]:x,key:v.name,[u.value]:v.name,isLeaf:k,loadChildren:k?null:f,field:v,depth:a,appends:s,types:n}})}function eo(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=ge(e);return r.jsx(i.Variable.Input,C({scope:s},t))}function At(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=ge(e);return r.jsx(i.Variable.TextArea,C({scope:s},t))}function Cn(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=ge(e);return r.jsx(i.Variable.RawTextArea,C({scope:s},t))}function kn(o){var n=o,{variableOptions:e}=n,t=Z(n,["variableOptions"]);const s=ge(e);return r.jsx(i.Variable.JSON,C({scope:s},t))}function Sn(){const e=i.useAPIClient(),t=j.useForm(),{field:o,__parent:n}=i.useBlockRequestContext(),{setVisible:s}=i.useActionContext(),a=oe.useNavigate(),l=j.useFieldSchema(),c=j.useField(),u=i.useCompile(),{modal:d}=y.App.useApp(),f=i.useCollectValuesToSubmit(),h=c.componentProps.filterKeys||[];return{onClick(){return _(this,null,function*(){var N,A,P;const{onSuccess:x,skipValidator:m,triggerWorkflows:k}=(N=l==null?void 0:l["x-action-settings"])!=null?N:{};m||(yield t.submit());const S=yield f();c.data=o.data||{},c.data.loading=!0;try{const z=yield e.resource("workflows").trigger({values:S,filterKeys:h,triggerWorkflows:k!=null&&k.length?k.map(U=>[U.workflowKey,U.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.loading=!1,c.data.data=z,(P=(A=n==null?void 0:n.service)==null?void 0:A.refresh)==null||P.call(A),s==null||s(!1),!(x!=null&&x.successMessage))return;x!=null&&x.manualClose?d.success({title:u(x==null?void 0:x.successMessage),onOk:()=>_(this,null,function*(){yield t.reset(),x!=null&&x.redirecting&&(x!=null&&x.redirectTo)&&(H.isURL(x.redirectTo)?window.location.href=x.redirectTo:a(x.redirectTo))})}):y.message.success(u(x==null?void 0:x.successMessage))}catch(z){c.data.loading=!1}})}}}function An(){var x;const e=i.useCompile(),t=i.useAPIClient(),o=i.useRecord(),n=j.useField(),s=j.useFieldSchema(),{field:a,__parent:l}=i.useBlockRequestContext(),{setVisible:c,setSubmitted:u}=i.useActionContext(),{modal:d}=y.App.useApp(),f=oe.useNavigate(),{onSuccess:h,triggerWorkflows:v}=(x=s==null?void 0:s["x-action-settings"])!=null?x:{};return{onClick(k,S){return _(this,null,function*(){n.data=a.data||{},n.data.loading=!0;try{if(yield t.resource("workflows").trigger({values:o,triggerWorkflows:v!=null&&v.length?v.map(N=>[N.workflowKey,N.context].filter(Boolean).join("!")).join(","):void 0}),S&&S(),c==null||c(!1),u==null||u(!0),!(h!=null&&h.successMessage))return;if(h!=null&&h.manualClose){let N;d.success({title:e(h==null?void 0:h.successMessage),onOk(){return _(this,null,function*(){h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(H.isURL(h.redirectTo)?window.location.href=h.redirectTo:f(h.redirectTo))})}})}else y.message.success(e(h==null?void 0:h.successMessage))}catch(N){console.error(N)}finally{n.data.loading=!1}})}}}function On(){const{workflow:e}=Y();return!!(e!=null&&e.executed)}function to(){const{workflow:e}=Y();return!!(e!=null&&e.allExecuted)}const Ae={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},Tn=[{label:`{{t("After record added", { ns: "${p}" })}}`,value:Ae.CREATED},{label:`{{t("After record updated", { ns: "${p}" })}}`,value:Ae.UPDATED},{label:`{{t("After record added or updated", { ns: "${p}" })}}`,value:Ae.SAVED},{label:`{{t("After record deleted", { ns: "${p}" })}}`,value:Ae.DELETED}];class Fn extends yt{constructor(){super(...arguments);w(this,"title",`{{t("Collection event", { ns: "${p}" })}}`);w(this,"description",`{{t('Triggered when data changes in the collection, such as after adding, updating, or deleting a record. Unlike "Post-action event", Collection event listens for data changes rather than HTTP requests. Unless you understand the exact meaning, it is recommended to use "Post-action event".', { ns: "${p}" })}}`);w(this,"fieldset",{collection:T(C({},le),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(o){return o.options.key==="main"||o.options.isDBInstance}},"x-reactions":[...le["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${p}" })}}`,className:"auto-width"},enum:Tn,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${p}" })}}`,description:`{{t("Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(o){return!o.hidden&&(o.uiSchema?!o.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(o.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Ae.UPDATED})}}`}}}]},condition:T(C({},Ge),{title:`{{t("Only triggers when match conditions", { ns: "${p}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:T(C({},Ie),{"x-reactions":[...Ie["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Ae.DELETED})}}`}}}]})});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource,useWorkflowAnyExecuted:to});w(this,"components",{FieldsSelect:vt})}useVariables(o,n){var u;const s=i.useCompile(),{getCollectionFields:a}=i.useCollectionManager_deprecated(),l=[{collectionName:o.collection,name:"data",type:"hasOne",target:o.collection,uiSchema:{title:D("Trigger data")}}];return Se(T(C({appends:["data",...((u=o.appends)==null?void 0:u.map(d=>`data.${d}`))||[]]},n),{fields:l,compile:s,getCollectionFields:a}))}useInitializers(o){return o.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Me,collection:o.collection,dataPath:"$context.data"}:null}}const ve={STATIC:0,DATE_FIELD:1};function Nn(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function oo({value:e,onChange:t}){const o=e!=null?e:{},{t:n}=Q.useTranslation(),[s,a]=b.useState(o.offset?o.offset/Math.abs(o.offset):0);return r.jsxs("fieldset",{className:i.css`
448
448
  display: flex;
449
449
  gap: 0.5em;
450
- `,children:[r.jsx(vt,{value:o.field,onChange:l=>t(T(C({},o),{field:l})),filter:Nn,placeholder:n("Select field"),className:"auto-width"}),o.field?r.jsx(y.Select,{value:s,onChange:l=>{a(l),t(T(C({},o),{offset:Math.abs(o.offset)*l}))},options:[{value:0,label:E("Exactly at")},{value:-1,label:n("Before")},{value:1,label:n("After")}],className:"auto-width"}):null,s?r.jsxs(r.Fragment,{children:[r.jsx(y.InputNumber,{value:Math.abs(o.offset),onChange:l=>t(T(C({},o),{offset:(l!=null?l:0)*s}))}),r.jsx(y.Select,{value:o.unit||864e5,onChange:l=>t(T(C({},o),{unit:l})),options:[{value:864e5,label:E("Days")},{value:36e5,label:E("Hours")},{value:6e4,label:E("Minutes")},{value:1e3,label:E("Seconds")}],className:"auto-width"})]}):null]})}function Dn({value:e,onChange:t}){const{t:o}=dt(),n=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return r.jsxs("fieldset",{className:i.css`
450
+ `,children:[r.jsx(vt,{value:o.field,onChange:l=>t(T(C({},o),{field:l})),filter:Nn,placeholder:n("Select field"),className:"auto-width"}),o.field?r.jsx(y.Select,{value:s,onChange:l=>{a(l),t(T(C({},o),{offset:Math.abs(o.offset)*l}))},options:[{value:0,label:D("Exactly at")},{value:-1,label:n("Before")},{value:1,label:n("After")}],className:"auto-width"}):null,s?r.jsxs(r.Fragment,{children:[r.jsx(y.InputNumber,{value:Math.abs(o.offset),onChange:l=>t(T(C({},o),{offset:(l!=null?l:0)*s}))}),r.jsx(y.Select,{value:o.unit||864e5,onChange:l=>t(T(C({},o),{unit:l})),options:[{value:864e5,label:D("Days")},{value:36e5,label:D("Hours")},{value:6e4,label:D("Minutes")},{value:1e3,label:D("Seconds")}],className:"auto-width"})]}):null]})}function Dn({value:e,onChange:t}){const{t:o}=dt(),n=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return r.jsxs("fieldset",{className:i.css`
451
451
  display: flex;
452
452
  gap: 0.5em;
453
- `,children:[r.jsxs(y.Select,{value:n,onChange:s=>{t(s?s==="field"?{}:new Date:null)},className:"auto-width",children:[r.jsx(y.Select.Option,{value:null,children:o("No end")}),r.jsx(y.Select.Option,{value:"field",children:o("By field")}),r.jsx(y.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(oo,{value:e,onChange:t}):null,n==="date"?r.jsx(y.DatePicker,{showTime:!0,value:Lo(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var re=function(){return re=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var s in t=arguments[o])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},re.apply(this,arguments)};function no(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(o[n[s]]=e[n[s]])}return o}function Ke(e,t,o){if(o||arguments.length===2)for(var n,s=0,a=t.length;s<a;s++)!n&&s in t||(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}var $n=[{name:"@yearly",value:"0 0 1 1 *"},{name:"@annually",value:"0 0 1 1 *"},{name:"@monthly",value:"0 0 1 * *"},{name:"@weekly",value:"0 0 * * 0"},{name:"@daily",value:"0 0 * * *"},{name:"@midnight",value:"0 0 * * *"},{name:"@hourly",value:"0 * * * *"}],we=[{type:"minutes",min:0,max:59,total:60},{type:"hours",min:0,max:23,total:24},{type:"month-days",min:1,max:31,total:31},{type:"months",min:1,max:12,total:12,alt:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]},{type:"week-days",min:0,max:6,total:7,alt:["SUN","MON","TUE","WED","THU","FRI","SAT"]}],B={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function ro(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function Ze(e){return e.sort(function(t,o){return t-o}),e}function so(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function ae(e){return Object.entries(e).filter(function(t){var o=t[0],n=t[1];return o&&n}).map(function(t){return t[0]}).join(" ")}function io(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||B.errorInvalidCron})}function Qe(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function lo(e,t,o,n,s,a,l,c,u,d,f,h,v,x){o&&o(void 0),t(!1);var m=!1;if(!e){if(n==="always"||a&&n==="for-default-value")return;m=!0}if(!m){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void x("reboot");var k=$n.find(function(A){return A.name===e});k&&(e=k.value)}try{var S=function(A){if(typeof A!="string")throw new Error("Invalid cron string");var P=A.replace(/\s+/g," ").trim().split(" ");if(P.length===5)return P.map(function(z,U){return function(F,M){if(F==="*"||F==="*/1")return[];var O=Ze(so(po(function(L,J,ue){if(ue){L=L.toUpperCase();for(var D=0;D<ue.length;D++)L=L.replace(ue[D],"".concat(D+J))}return L}(F,M.min,M.alt).split(",").map(function(L){var J,ue=L.split("/");if(ue.length>2)throw new Error('Invalid value "'.concat(F,' for "').concat(M.type,'"'));var D=ue[0],V=ue[1];J=D==="*"?ro(M.min,M.max):function(G,q,R){var ee=G.split("-");if(ee.length===1){var Ve=Qe(ee[0]);if(isNaN(Ve))throw new Error('Invalid value "'.concat(q,'" for ').concat(R.type));return[Ve]}if(ee.length===2){var me=Qe(ee[0]),Fe=Qe(ee[1]);if(isNaN(me)||isNaN(Fe))throw new Error('Invalid value "'.concat(q,'" for ').concat(R.type));if(Fe<me)throw new Error('Max range is less than min range in "'.concat(G,'" for ').concat(R.type));return ro(me,Fe)}throw new Error('Invalid value "'.concat(G,'" for ').concat(R.type))}(D,F,M);var W=function(G,q){if(G!==void 0){var R=Qe(G);if(isNaN(R)||R<1)throw new Error('Invalid interval step value "'.concat(G,'" for ').concat(q.type));return R}}(V,M),se=function(G,q){if(q){var R=G[0];G=G.filter(function(ee){return ee%q==R%q||ee===R})}return G}(J,W);return se}).flat(),M))),I=mo(O,M);if(I!==void 0)throw new Error('Value "'.concat(I,'" out of range for ').concat(M.type));return O.length===M.total?[]:O}(z,we[U])});throw new Error("Invalid cron string format")}(e),N=function(A){return A[3].length>0?"year":A[2].length>0?"month":A[4].length>0?"week":A[1].length>0?"day":A[0].length>0?"hour":"minute"}(S);x(N),u(S[0]),d(S[1]),f(S[2]),h(S[3]),v(S[4])}catch(A){m=!0}}m&&(s.current=e,t(!0),io(o,l))}function ao(e,t,o,n,s,a,l){if(e==="reboot")return"@reboot";var c=function(u,d){return u.map(function(f,h){var v=we[h];return co(uo(f,v),v,d)})}([e!=="minute"&&a?a:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return c.join(" ")}function co(e,t,o,n,s){var a="";if(function(c,u){return c.length===u.max-u.min+1}(e,t)||e.length===0)a="*";else{var l=function(c){if(c.length>2){var u=c[1]-c[0];if(u>1)return u}}(e);a=l&&function(c,u){for(var d=1;d<c.length;d++){var f=c[d-1];if(c[d]-f!==u)return!1}return!0}(e,l)?function(c,u,d){var f=fo(c),h=ho(c),v=c.length===(h-f)/d+1;return!!(f===u.min&&h+d>u.max&&v)}(e,t,l)?"*/".concat(l):"".concat(Oe(fo(e),t,o,n,s),"-").concat(Oe(ho(e),t,o,n,s),"/").concat(l):function(c){var u=[],d=null;return c.forEach(function(f,h,v){f!==v[h+1]-1?d!==null?(u.push([d,f]),d=null):u.push(f):d===null&&(d=f)}),u}(e).map(function(c){return Array.isArray(c)?"".concat(Oe(c[0],t,o,n,s),"-").concat(Oe(c[1],t,o,n,s)):Oe(c,t,o,n,s)}).join(",")}return a}function Oe(e,t,o,n,s){var a=e.toString(),l=t.type,c=t.alt,u=t.min,d=n&&(n===!0||n.includes(l)),f=s==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?a=c[e-u]:e<10&&(d||f)&&(a=a.padStart(2,"0")),l==="hours"&&s==="12-hour-clock"){var h=e>=12?"PM":"AM",v=e%12||12;v<10&&d&&(v=v.toString().padStart(2,"0")),a="".concat(v).concat(h)}return a}function uo(e,t){var o=Ze(so(po(e,t)));if(o.length===0)return o;var n=mo(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function po(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function mo(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function fo(e){return e[0]}function ho(e){return e[e.length-1]}function Pe(e){var t=e.value,o=e.grid,n=o===void 0||o,s=e.optionsList,a=e.setValue,l=e.locale,c=e.className,u=e.humanizeLabels,d=e.disabled,f=e.readOnly,h=e.leadingZero,v=e.clockFormat,x=e.period,m=e.unit,k=e.periodicityOnDoubleClick,S=e.mode,N=no(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),A=b.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(D){return D.toString()})},[t]),P=b.useMemo(function(){return s?s.map(function(D,V){return{value:(m.min===0?V:V+1).toString(),label:D}}):Ke([],Array(m.total),!0).map(function(D,V){var W=m.min===0?V:V+1;return{value:W.toString(),label:Oe(W,m,u,h,v)}})},[s,h,u,v]),z=JSON.stringify(l),U=b.useCallback(function(D){var V=D.value;if(!t||t[0]!==Number(V))return r.jsx(r.Fragment,{});var W=co(uo(t,m),m,u,h,v),se=W.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:se[1]?"".concat(l.everyText||B.everyText," ").concat(se[1]):W})},[t,z,u,h,v]),F=b.useCallback(function(D){var V=Array.isArray(D)?Ze(D):[D],W=V;t&&(W=S==="single"?[]:Ke([],t,!0),V.forEach(function(se){var G=Number(se);W=t.some(function(q){return q===G})?W.filter(function(q){return q!==G}):Ze(Ke(Ke([],W,!0),[G],!1))})),W.length===m.total?a([]):a(W)},[a,t]),M=b.useCallback(function(D){if(D!==0&&D!==1){for(var V=m.total+m.min,W=[],se=m.min;se<V;se++)se%D==0&&W.push(se);var G=t&&W&&t.length===W.length&&t.every(function(R,ee){return R===W[ee]}),q=W.length===P.length;a(q||G?[]:W)}else a([])},[t,P,a]),O=b.useRef([]),I=b.useCallback(function(D){if(!f){var V=O.current;V.push({time:new Date().getTime(),value:Number(D)});var W=window.setTimeout(function(){k&&V.length>1&&V[V.length-1].time-V[V.length-2].time<300?V[V.length-1].value===V[V.length-2].value?M(Number(D)):F([V[V.length-2].value,V[V.length-1].value]):F(Number(D)),O.current=[]},300);return function(){window.clearTimeout(W)}}},[O,F,M,f,k]),L=b.useCallback(function(){f||a([])},[a,f]),J=b.useMemo(function(){var D;return ae(((D={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,D))},[c]),ue=b.useMemo(function(){var D;return ae(((D={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(m.type)]=!0,D["react-js-cron-custom-select-dropdown"]=!0,D["react-js-cron-custom-select-dropdown-".concat(m.type)]=!0,D["react-js-cron-custom-select-dropdown-minutes-large"]=m.type==="minutes"&&x!=="hour"&&x!=="day",D["react-js-cron-custom-select-dropdown-minutes-medium"]=m.type==="minutes"&&(x==="day"||x==="hour"),D["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=m.type==="hours"&&v==="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,v,x]);return r.jsx(y.Select,re({mode:S!=="single"||k?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:A,onClear:L,tagRender:U,className:J,popupClassName:ue,options:P,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:I,onDeselect:I,disabled:d,dropdownAlign:m.type!=="minutes"&&m.type!=="hours"||x==="day"||x==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(m.type)},N))}function En(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,v=b.useMemo(function(){var x;return ae(((x={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,x["".concat(s,"-hours")]=!!s,x))},[s]);return r.jsxs("div",re({className:v},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||B.prefixHours}),r.jsx(Pe,{placeholder:n.emptyHours||B.emptyHours,value:t,unit:we[1],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:h})]}))}function Mn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,v=b.useMemo(function(){var x;return ae(((x={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,x["".concat(s,"-minutes")]=!!s,x))},[s]);return r.jsxs("div",re({className:v},{children:[d==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||B.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||B.prefixMinutes}),r.jsx(Pe,{placeholder:d==="hour"?n.emptyMinutesForHourPeriod||B.emptyMinutesForHourPeriod:n.emptyMinutes||B.emptyMinutes,value:t,unit:we[0],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:h}),d==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||B.suffixMinutesForHourPeriod})]}))}function In(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.weekDays,l=e.disabled,c=e.readOnly,u=e.leadingZero,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,v=!a||a.length===0,x=b.useMemo(function(){var S;return ae(((S={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!v})["".concat(s,"-field")]=!!s,S["".concat(s,"-month-days")]=!!s,S))},[s,v]),m=JSON.stringify(n),k=b.useMemo(function(){return v?n.emptyMonthDays||B.emptyMonthDays:n.emptyMonthDaysShort||B.emptyMonthDaysShort},[v,m]);return!c||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?r.jsxs("div",re({className:x},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||B.prefixMonthDays}),r.jsx(Pe,{placeholder:k,value:t,setValue:o,unit:we[2],locale:n,className:s,disabled:l,readOnly:c,leadingZero:u,period:d,periodicityOnDoubleClick:f,mode:h})]})):null}function Pn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.disabled,c=e.readOnly,u=e.period,d=e.periodicityOnDoubleClick,f=e.mode,h=n.months||B.months,v=b.useMemo(function(){var x;return ae(((x={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,x["".concat(s,"-months")]=!!s,x))},[s]);return r.jsxs("div",re({className:v},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||B.prefixMonths}),r.jsx(Pe,{placeholder:n.emptyMonths||B.emptyMonths,optionsList:h,grid:!1,value:t,unit:re(re({},we[3]),{alt:n.altMonths||B.altMonths}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:l,readOnly:c,period:u,periodicityOnDoubleClick:d,mode:f})]}))}function Bn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.shortcuts,u=e.allowedPeriods,d=[];u.includes("year")&&d.push({value:"year",label:n.yearOption||B.yearOption}),u.includes("month")&&d.push({value:"month",label:n.monthOption||B.monthOption}),u.includes("week")&&d.push({value:"week",label:n.weekOption||B.weekOption}),u.includes("day")&&d.push({value:"day",label:n.dayOption||B.dayOption}),u.includes("hour")&&d.push({value:"hour",label:n.hourOption||B.hourOption}),u.includes("minute")&&d.push({value:"minute",label:n.minuteOption||B.minuteOption}),u.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&d.push({value:"reboot",label:n.rebootOption||B.rebootOption});var f=b.useCallback(function(m){l||o(m)},[o,l]),h=b.useMemo(function(){var m;return ae(((m={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,m["".concat(s,"-period")]=!!s,m))},[s]),v=b.useMemo(function(){var m;return ae(((m={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(s,"-select")]=!!s,m))},[s,n.prefixPeriod]),x=b.useMemo(function(){var m;return ae(((m={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,m["".concat(s,"-select-dropdown-period")]=!!s,m))},[s]);return r.jsxs("div",re({className:h},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||B.prefixPeriod}),r.jsx(y.Select,{defaultValue:t,value:t,onChange:f,options:d,className:v,popupClassName:x,disabled:a,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function Vn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.monthDays,c=e.disabled,u=e.readOnly,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,v=n.weekDays||B.weekDays,x=d==="week"||!l||l.length===0,m=b.useMemo(function(){var P;return ae(((P={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!x})["".concat(s,"-field")]=!!s,P["".concat(s,"-week-days")]=!!s,P))},[s,x]),k=JSON.stringify(n),S=b.useMemo(function(){return x?n.emptyWeekDays||B.emptyWeekDays:n.emptyWeekDaysShort||B.emptyWeekDaysShort},[x,k]),N=d==="week"||!u||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),A=!u||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return N?r.jsxs("div",re({className:m},{children:[n.prefixWeekDays!==""&&(d==="week"||!A)&&r.jsx("span",{children:n.prefixWeekDays||B.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&d!=="week"&&A&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||B.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(Pe,{placeholder:S,optionsList:v,grid:!1,value:t,unit:re(re({},we[4]),{alt:n.altWeekDays||B.altWeekDays}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:c,readOnly:u,period:d,periodicityOnDoubleClick:f,mode:h})]})):null}function jn(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,s=n===void 0?{}:n,a=e.clearButtonAction,l=a===void 0?"fill-with-every":a,c=e.locale,u=c===void 0?B:c,d=e.value,f=d===void 0?"":d,h=e.setValue,v=e.displayError,x=v===void 0||v,m=e.onError,k=e.className,S=e.defaultPeriod,N=S===void 0?"day":S,A=e.allowEmpty,P=A===void 0?"for-default-value":A,z=e.humanizeLabels,U=z===void 0||z,F=e.humanizeValue,M=F!==void 0&&F,O=e.disabled,I=O!==void 0&&O,L=e.readOnly,J=L!==void 0&&L,ue=e.leadingZero,D=ue!==void 0&&ue,V=e.shortcuts,W=V===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:V,se=e.clockFormat,G=e.periodicityOnDoubleClick,q=G===void 0||G,R=e.mode,ee=R===void 0?"multiple":R,Ve=e.allowedDropdowns,me=Ve===void 0?["period","months","month-days","week-days","hours","minutes"]:Ve,Fe=e.allowedPeriods,mr=Fe===void 0?["year","month","week","day","hour","minute","reboot"]:Fe,Ne=b.useRef(f),Ot=b.useRef(N),ko=b.useState(),be=ko[0],Re=ko[1],So=b.useState(),je=So[0],et=So[1],Ao=b.useState(),tt=Ao[0],ot=Ao[1],Oo=b.useState(),We=Oo[0],nt=Oo[1],To=b.useState(),rt=To[0],st=To[1],Fo=b.useState(),it=Fo[0],lt=Fo[1],No=b.useState(!1),Tt=No[0],Le=No[1],Do=b.useState(!1),at=Do[0],$o=Do[1],fr=function(K){var fe=b.useRef(K);return b.useEffect(function(){fe.current=K},[K]),fe.current}(at),Eo=JSON.stringify(u);b.useEffect(function(){lo(f,Le,m,P,Ne,!0,u,W,lt,st,et,ot,nt,Re)},[]),b.useEffect(function(){f!==Ne.current&&lo(f,Le,m,P,Ne,!1,u,W,lt,st,et,ot,nt,Re)},[f,Ne,Eo,P,W]),b.useEffect(function(){if(!(be||it||tt||je||We||rt)||at||fr)at&&$o(!1);else{var K=be||Ot.current,fe=ao(K,tt,je,We,rt,it,M);h(fe,{selectedPeriod:K}),Ne.current=fe,m&&m(void 0),Le(!1)}},[be,je,tt,We,rt,it,M,at]);var Mo=b.useCallback(function(){et(void 0),ot(void 0),nt(void 0),st(void 0),lt(void 0);var K="",fe=be!=="reboot"&&be?be:Ot.current;fe!==be&&Re(fe),l==="fill-with-every"&&(K=ao(fe,void 0,void 0,void 0,void 0,void 0)),h(K,{selectedPeriod:fe}),Ne.current=K,$o(!0),P==="never"&&l==="empty"?(Le(!0),io(m,u)):(m&&m(void 0),Le(!1))},[be,h,m,l]),hr=b.useMemo(function(){var K;return ae(((K={"react-js-cron":!0,"react-js-cron-error":Tt&&x,"react-js-cron-disabled":I,"react-js-cron-read-only":J})["".concat(k)]=!!k,K["".concat(k,"-error")]=Tt&&x&&!!k,K["".concat(k,"-disabled")]=I&&!!k,K["".concat(k,"-read-only")]=J&&!!k,K))},[k,Tt,x,I,J]),Ft=s.className,Io=no(s,["className"]),Po=b.useMemo(function(){var K;return ae(((K={"react-js-cron-clear-button":!0})["".concat(k,"-clear-button")]=!!k,K["".concat(Ft)]=!!Ft,K))},[k,Ft]),yr=JSON.stringify(Io),Bo=b.useMemo(function(){return o&&!J?r.jsx(y.Button,re({className:Po,danger:!0,type:"primary",disabled:I},Io,{onClick:Mo},{children:u.clearButtonText||B.clearButtonText})):null},[o,J,Eo,Po,I,yr,Mo]),te=be||Ot.current;return r.jsxs("div",re({className:hr},{children:[me.includes("period")&&r.jsx(Bn,{value:te,setValue:Re,locale:u,className:k,disabled:I,readOnly:J,shortcuts:W,allowedPeriods:mr}),te==="reboot"?Bo:r.jsxs(r.Fragment,{children:[te==="year"&&me.includes("months")&&r.jsx(Pn,{value:tt,setValue:ot,locale:u,className:k,humanizeLabels:U,disabled:I,readOnly:J,period:te,periodicityOnDoubleClick:q,mode:ee}),(te==="year"||te==="month")&&me.includes("month-days")&&r.jsx(In,{value:je,setValue:et,locale:u,className:k,weekDays:We,disabled:I,readOnly:J,leadingZero:D,period:te,periodicityOnDoubleClick:q,mode:ee}),(te==="year"||te==="month"||te==="week")&&me.includes("week-days")&&r.jsx(Vn,{value:We,setValue:nt,locale:u,className:k,humanizeLabels:U,monthDays:je,disabled:I,readOnly:J,period:te,periodicityOnDoubleClick:q,mode:ee}),r.jsxs("div",{children:[te!=="minute"&&te!=="hour"&&me.includes("hours")&&r.jsx(En,{value:rt,setValue:st,locale:u,className:k,disabled:I,readOnly:J,leadingZero:D,clockFormat:se,period:te,periodicityOnDoubleClick:q,mode:ee}),te!=="minute"&&me.includes("minutes")&&r.jsx(Mn,{value:it,setValue:lt,locale:u,period:te,className:k,disabled:I,readOnly:J,leadingZero:D,clockFormat:se,periodicityOnDoubleClick:q,mode:ee}),Bo]})]})]}))}const Wn={"zh-CN":{everyText:"每",emptyMonths:"每月",emptyMonthDays:"每日(月)",emptyMonthDaysShort:"每日",emptyWeekDays:"每天(周)",emptyWeekDaysShort:"每天(周)",emptyHours:"每小时",emptyMinutes:"每分钟",emptyMinutesForHourPeriod:"每",yearOption:"年",monthOption:"月",weekOption:"周",dayOption:"天",hourOption:"小时",minuteOption:"分钟",rebootOption:"重启",prefixPeriod:"每",prefixMonths:"的",prefixMonthDays:"的",prefixWeekDays:"的",prefixWeekDaysForMonthAndYearPeriod:"或者",prefixHours:"的",prefixMinutes:":",prefixMinutesForHourPeriod:"的",suffixMinutesForHourPeriod:"分钟",errorInvalidCron:"不符合 cron 规则的表达式",clearButtonText:"清空",weekDays:["周日","周一","周二","周三","周四","周五","周六"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],altWeekDays:["周日","周一","周二","周三","周四","周五","周六"],altMonths:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},yo=[{value:"none",text:"No repeat"},{value:6e4,text:"By minute",unitText:"Minutes"},{value:36e5,text:"By hour",unitText:"Hours"},{value:864e5,text:"By day",unitText:"Days"},{value:6048e5,text:"By week",unitText:"Weeks"},{value:"cron",text:"Advanced"}];function go(e){return yo.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function Ln(e){let t;switch(typeof e){case"number":return t=go(e),t?t.value:"none";case"string":return"cron"}return"none"}function zn({value:e,onChange:t}){const{t:o}=dt(),n=go(e);return r.jsx(y.InputNumber,{value:e/n.value,onChange:s=>t(s*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function Hn({value:e=null,onChange:t}){const{t:o}=dt(),n=Ln(e);function s(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const a=Wn[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:i.css`
453
+ `,children:[r.jsxs(y.Select,{value:n,onChange:s=>{t(s?s==="field"?{}:new Date:null)},className:"auto-width",children:[r.jsx(y.Select.Option,{value:null,children:o("No end")}),r.jsx(y.Select.Option,{value:"field",children:o("By field")}),r.jsx(y.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(oo,{value:e,onChange:t}):null,n==="date"?r.jsx(y.DatePicker,{showTime:!0,value:Lo(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var re=function(){return re=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var s in t=arguments[o])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},re.apply(this,arguments)};function no(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(o[n[s]]=e[n[s]])}return o}function Ke(e,t,o){if(o||arguments.length===2)for(var n,s=0,a=t.length;s<a;s++)!n&&s in t||(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}var $n=[{name:"@yearly",value:"0 0 1 1 *"},{name:"@annually",value:"0 0 1 1 *"},{name:"@monthly",value:"0 0 1 * *"},{name:"@weekly",value:"0 0 * * 0"},{name:"@daily",value:"0 0 * * *"},{name:"@midnight",value:"0 0 * * *"},{name:"@hourly",value:"0 * * * *"}],we=[{type:"minutes",min:0,max:59,total:60},{type:"hours",min:0,max:23,total:24},{type:"month-days",min:1,max:31,total:31},{type:"months",min:1,max:12,total:12,alt:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]},{type:"week-days",min:0,max:6,total:7,alt:["SUN","MON","TUE","WED","THU","FRI","SAT"]}],B={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function ro(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function Ze(e){return e.sort(function(t,o){return t-o}),e}function so(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function ae(e){return Object.entries(e).filter(function(t){var o=t[0],n=t[1];return o&&n}).map(function(t){return t[0]}).join(" ")}function io(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||B.errorInvalidCron})}function Qe(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function lo(e,t,o,n,s,a,l,c,u,d,f,h,v,x){o&&o(void 0),t(!1);var m=!1;if(!e){if(n==="always"||a&&n==="for-default-value")return;m=!0}if(!m){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void x("reboot");var k=$n.find(function(A){return A.name===e});k&&(e=k.value)}try{var S=function(A){if(typeof A!="string")throw new Error("Invalid cron string");var P=A.replace(/\s+/g," ").trim().split(" ");if(P.length===5)return P.map(function(z,U){return function(F,M){if(F==="*"||F==="*/1")return[];var O=Ze(so(po(function(L,J,ue){if(ue){L=L.toUpperCase();for(var $=0;$<ue.length;$++)L=L.replace(ue[$],"".concat($+J))}return L}(F,M.min,M.alt).split(",").map(function(L){var J,ue=L.split("/");if(ue.length>2)throw new Error('Invalid value "'.concat(F,' for "').concat(M.type,'"'));var $=ue[0],V=ue[1];J=$==="*"?ro(M.min,M.max):function(G,q,R){var ee=G.split("-");if(ee.length===1){var Ve=Qe(ee[0]);if(isNaN(Ve))throw new Error('Invalid value "'.concat(q,'" for ').concat(R.type));return[Ve]}if(ee.length===2){var me=Qe(ee[0]),Fe=Qe(ee[1]);if(isNaN(me)||isNaN(Fe))throw new Error('Invalid value "'.concat(q,'" for ').concat(R.type));if(Fe<me)throw new Error('Max range is less than min range in "'.concat(G,'" for ').concat(R.type));return ro(me,Fe)}throw new Error('Invalid value "'.concat(G,'" for ').concat(R.type))}($,F,M);var W=function(G,q){if(G!==void 0){var R=Qe(G);if(isNaN(R)||R<1)throw new Error('Invalid interval step value "'.concat(G,'" for ').concat(q.type));return R}}(V,M),se=function(G,q){if(q){var R=G[0];G=G.filter(function(ee){return ee%q==R%q||ee===R})}return G}(J,W);return se}).flat(),M))),I=mo(O,M);if(I!==void 0)throw new Error('Value "'.concat(I,'" out of range for ').concat(M.type));return O.length===M.total?[]:O}(z,we[U])});throw new Error("Invalid cron string format")}(e),N=function(A){return A[3].length>0?"year":A[2].length>0?"month":A[4].length>0?"week":A[1].length>0?"day":A[0].length>0?"hour":"minute"}(S);x(N),u(S[0]),d(S[1]),f(S[2]),h(S[3]),v(S[4])}catch(A){m=!0}}m&&(s.current=e,t(!0),io(o,l))}function ao(e,t,o,n,s,a,l){if(e==="reboot")return"@reboot";var c=function(u,d){return u.map(function(f,h){var v=we[h];return co(uo(f,v),v,d)})}([e!=="minute"&&a?a:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return c.join(" ")}function co(e,t,o,n,s){var a="";if(function(c,u){return c.length===u.max-u.min+1}(e,t)||e.length===0)a="*";else{var l=function(c){if(c.length>2){var u=c[1]-c[0];if(u>1)return u}}(e);a=l&&function(c,u){for(var d=1;d<c.length;d++){var f=c[d-1];if(c[d]-f!==u)return!1}return!0}(e,l)?function(c,u,d){var f=fo(c),h=ho(c),v=c.length===(h-f)/d+1;return!!(f===u.min&&h+d>u.max&&v)}(e,t,l)?"*/".concat(l):"".concat(Oe(fo(e),t,o,n,s),"-").concat(Oe(ho(e),t,o,n,s),"/").concat(l):function(c){var u=[],d=null;return c.forEach(function(f,h,v){f!==v[h+1]-1?d!==null?(u.push([d,f]),d=null):u.push(f):d===null&&(d=f)}),u}(e).map(function(c){return Array.isArray(c)?"".concat(Oe(c[0],t,o,n,s),"-").concat(Oe(c[1],t,o,n,s)):Oe(c,t,o,n,s)}).join(",")}return a}function Oe(e,t,o,n,s){var a=e.toString(),l=t.type,c=t.alt,u=t.min,d=n&&(n===!0||n.includes(l)),f=s==="24-hour-clock"&&(l==="hours"||l==="minutes");if(o&&l==="week-days"||o&&l==="months"?a=c[e-u]:e<10&&(d||f)&&(a=a.padStart(2,"0")),l==="hours"&&s==="12-hour-clock"){var h=e>=12?"PM":"AM",v=e%12||12;v<10&&d&&(v=v.toString().padStart(2,"0")),a="".concat(v).concat(h)}return a}function uo(e,t){var o=Ze(so(po(e,t)));if(o.length===0)return o;var n=mo(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function po(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function mo(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function fo(e){return e[0]}function ho(e){return e[e.length-1]}function Pe(e){var t=e.value,o=e.grid,n=o===void 0||o,s=e.optionsList,a=e.setValue,l=e.locale,c=e.className,u=e.humanizeLabels,d=e.disabled,f=e.readOnly,h=e.leadingZero,v=e.clockFormat,x=e.period,m=e.unit,k=e.periodicityOnDoubleClick,S=e.mode,N=no(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),A=b.useMemo(function(){if(t&&Array.isArray(t))return t.map(function($){return $.toString()})},[t]),P=b.useMemo(function(){return s?s.map(function($,V){return{value:(m.min===0?V:V+1).toString(),label:$}}):Ke([],Array(m.total),!0).map(function($,V){var W=m.min===0?V:V+1;return{value:W.toString(),label:Oe(W,m,u,h,v)}})},[s,h,u,v]),z=JSON.stringify(l),U=b.useCallback(function($){var V=$.value;if(!t||t[0]!==Number(V))return r.jsx(r.Fragment,{});var W=co(uo(t,m),m,u,h,v),se=W.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:se[1]?"".concat(l.everyText||B.everyText," ").concat(se[1]):W})},[t,z,u,h,v]),F=b.useCallback(function($){var V=Array.isArray($)?Ze($):[$],W=V;t&&(W=S==="single"?[]:Ke([],t,!0),V.forEach(function(se){var G=Number(se);W=t.some(function(q){return q===G})?W.filter(function(q){return q!==G}):Ze(Ke(Ke([],W,!0),[G],!1))})),W.length===m.total?a([]):a(W)},[a,t]),M=b.useCallback(function($){if($!==0&&$!==1){for(var V=m.total+m.min,W=[],se=m.min;se<V;se++)se%$==0&&W.push(se);var G=t&&W&&t.length===W.length&&t.every(function(R,ee){return R===W[ee]}),q=W.length===P.length;a(q||G?[]:W)}else a([])},[t,P,a]),O=b.useRef([]),I=b.useCallback(function($){if(!f){var V=O.current;V.push({time:new Date().getTime(),value:Number($)});var W=window.setTimeout(function(){k&&V.length>1&&V[V.length-1].time-V[V.length-2].time<300?V[V.length-1].value===V[V.length-2].value?M(Number($)):F([V[V.length-2].value,V[V.length-1].value]):F(Number($)),O.current=[]},300);return function(){window.clearTimeout(W)}}},[O,F,M,f,k]),L=b.useCallback(function(){f||a([])},[a,f]),J=b.useMemo(function(){var $;return ae((($={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,$))},[c]),ue=b.useMemo(function(){var $;return ae((($={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(m.type)]=!0,$["react-js-cron-custom-select-dropdown"]=!0,$["react-js-cron-custom-select-dropdown-".concat(m.type)]=!0,$["react-js-cron-custom-select-dropdown-minutes-large"]=m.type==="minutes"&&x!=="hour"&&x!=="day",$["react-js-cron-custom-select-dropdown-minutes-medium"]=m.type==="minutes"&&(x==="day"||x==="hour"),$["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=m.type==="hours"&&v==="12-hour-clock",$["react-js-cron-custom-select-dropdown-grid"]=!!n,$["".concat(c,"-select-dropdown")]=!!c,$["".concat(c,"-select-dropdown-").concat(m.type)]=!!c,$))},[c,n,v,x]);return r.jsx(y.Select,re({mode:S!=="single"||k?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:A,onClear:L,tagRender:U,className:J,popupClassName:ue,options:P,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:I,onDeselect:I,disabled:d,dropdownAlign:m.type!=="minutes"&&m.type!=="hours"||x==="day"||x==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(m.type)},N))}function En(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,v=b.useMemo(function(){var x;return ae(((x={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,x["".concat(s,"-hours")]=!!s,x))},[s]);return r.jsxs("div",re({className:v},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||B.prefixHours}),r.jsx(Pe,{placeholder:n.emptyHours||B.emptyHours,value:t,unit:we[1],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:h})]}))}function Mn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,v=b.useMemo(function(){var x;return ae(((x={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,x["".concat(s,"-minutes")]=!!s,x))},[s]);return r.jsxs("div",re({className:v},{children:[d==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||B.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||B.prefixMinutes}),r.jsx(Pe,{placeholder:d==="hour"?n.emptyMinutesForHourPeriod||B.emptyMinutesForHourPeriod:n.emptyMinutes||B.emptyMinutes,value:t,unit:we[0],setValue:o,locale:n,className:s,disabled:a,readOnly:l,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:h}),d==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||B.suffixMinutesForHourPeriod})]}))}function In(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.weekDays,l=e.disabled,c=e.readOnly,u=e.leadingZero,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,v=!a||a.length===0,x=b.useMemo(function(){var S;return ae(((S={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!v})["".concat(s,"-field")]=!!s,S["".concat(s,"-month-days")]=!!s,S))},[s,v]),m=JSON.stringify(n),k=b.useMemo(function(){return v?n.emptyMonthDays||B.emptyMonthDays:n.emptyMonthDaysShort||B.emptyMonthDaysShort},[v,m]);return!c||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0)?r.jsxs("div",re({className:x},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||B.prefixMonthDays}),r.jsx(Pe,{placeholder:k,value:t,setValue:o,unit:we[2],locale:n,className:s,disabled:l,readOnly:c,leadingZero:u,period:d,periodicityOnDoubleClick:f,mode:h})]})):null}function Pn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.disabled,c=e.readOnly,u=e.period,d=e.periodicityOnDoubleClick,f=e.mode,h=n.months||B.months,v=b.useMemo(function(){var x;return ae(((x={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,x["".concat(s,"-months")]=!!s,x))},[s]);return r.jsxs("div",re({className:v},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||B.prefixMonths}),r.jsx(Pe,{placeholder:n.emptyMonths||B.emptyMonths,optionsList:h,grid:!1,value:t,unit:re(re({},we[3]),{alt:n.altMonths||B.altMonths}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:l,readOnly:c,period:u,periodicityOnDoubleClick:d,mode:f})]}))}function Bn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.disabled,l=e.readOnly,c=e.shortcuts,u=e.allowedPeriods,d=[];u.includes("year")&&d.push({value:"year",label:n.yearOption||B.yearOption}),u.includes("month")&&d.push({value:"month",label:n.monthOption||B.monthOption}),u.includes("week")&&d.push({value:"week",label:n.weekOption||B.weekOption}),u.includes("day")&&d.push({value:"day",label:n.dayOption||B.dayOption}),u.includes("hour")&&d.push({value:"hour",label:n.hourOption||B.hourOption}),u.includes("minute")&&d.push({value:"minute",label:n.minuteOption||B.minuteOption}),u.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&d.push({value:"reboot",label:n.rebootOption||B.rebootOption});var f=b.useCallback(function(m){l||o(m)},[o,l]),h=b.useMemo(function(){var m;return ae(((m={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,m["".concat(s,"-period")]=!!s,m))},[s]),v=b.useMemo(function(){var m;return ae(((m={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(s,"-select")]=!!s,m))},[s,n.prefixPeriod]),x=b.useMemo(function(){var m;return ae(((m={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,m["".concat(s,"-select-dropdown-period")]=!!s,m))},[s]);return r.jsxs("div",re({className:h},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||B.prefixPeriod}),r.jsx(y.Select,{defaultValue:t,value:t,onChange:f,options:d,className:v,popupClassName:x,disabled:a,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function Vn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,a=e.humanizeLabels,l=e.monthDays,c=e.disabled,u=e.readOnly,d=e.period,f=e.periodicityOnDoubleClick,h=e.mode,v=n.weekDays||B.weekDays,x=d==="week"||!l||l.length===0,m=b.useMemo(function(){var P;return ae(((P={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!x})["".concat(s,"-field")]=!!s,P["".concat(s,"-week-days")]=!!s,P))},[s,x]),k=JSON.stringify(n),S=b.useMemo(function(){return x?n.emptyWeekDays||B.emptyWeekDays:n.emptyWeekDaysShort||B.emptyWeekDaysShort},[x,k]),N=d==="week"||!u||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),A=!u||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return N?r.jsxs("div",re({className:m},{children:[n.prefixWeekDays!==""&&(d==="week"||!A)&&r.jsx("span",{children:n.prefixWeekDays||B.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&d!=="week"&&A&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||B.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(Pe,{placeholder:S,optionsList:v,grid:!1,value:t,unit:re(re({},we[4]),{alt:n.altWeekDays||B.altWeekDays}),setValue:o,locale:n,className:s,humanizeLabels:a,disabled:c,readOnly:u,period:d,periodicityOnDoubleClick:f,mode:h})]})):null}function jn(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,s=n===void 0?{}:n,a=e.clearButtonAction,l=a===void 0?"fill-with-every":a,c=e.locale,u=c===void 0?B:c,d=e.value,f=d===void 0?"":d,h=e.setValue,v=e.displayError,x=v===void 0||v,m=e.onError,k=e.className,S=e.defaultPeriod,N=S===void 0?"day":S,A=e.allowEmpty,P=A===void 0?"for-default-value":A,z=e.humanizeLabels,U=z===void 0||z,F=e.humanizeValue,M=F!==void 0&&F,O=e.disabled,I=O!==void 0&&O,L=e.readOnly,J=L!==void 0&&L,ue=e.leadingZero,$=ue!==void 0&&ue,V=e.shortcuts,W=V===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:V,se=e.clockFormat,G=e.periodicityOnDoubleClick,q=G===void 0||G,R=e.mode,ee=R===void 0?"multiple":R,Ve=e.allowedDropdowns,me=Ve===void 0?["period","months","month-days","week-days","hours","minutes"]:Ve,Fe=e.allowedPeriods,mr=Fe===void 0?["year","month","week","day","hour","minute","reboot"]:Fe,Ne=b.useRef(f),Ot=b.useRef(N),ko=b.useState(),be=ko[0],Re=ko[1],So=b.useState(),je=So[0],et=So[1],Ao=b.useState(),tt=Ao[0],ot=Ao[1],Oo=b.useState(),We=Oo[0],nt=Oo[1],To=b.useState(),rt=To[0],st=To[1],Fo=b.useState(),it=Fo[0],lt=Fo[1],No=b.useState(!1),Tt=No[0],Le=No[1],Do=b.useState(!1),at=Do[0],$o=Do[1],fr=function(K){var fe=b.useRef(K);return b.useEffect(function(){fe.current=K},[K]),fe.current}(at),Eo=JSON.stringify(u);b.useEffect(function(){lo(f,Le,m,P,Ne,!0,u,W,lt,st,et,ot,nt,Re)},[]),b.useEffect(function(){f!==Ne.current&&lo(f,Le,m,P,Ne,!1,u,W,lt,st,et,ot,nt,Re)},[f,Ne,Eo,P,W]),b.useEffect(function(){if(!(be||it||tt||je||We||rt)||at||fr)at&&$o(!1);else{var K=be||Ot.current,fe=ao(K,tt,je,We,rt,it,M);h(fe,{selectedPeriod:K}),Ne.current=fe,m&&m(void 0),Le(!1)}},[be,je,tt,We,rt,it,M,at]);var Mo=b.useCallback(function(){et(void 0),ot(void 0),nt(void 0),st(void 0),lt(void 0);var K="",fe=be!=="reboot"&&be?be:Ot.current;fe!==be&&Re(fe),l==="fill-with-every"&&(K=ao(fe,void 0,void 0,void 0,void 0,void 0)),h(K,{selectedPeriod:fe}),Ne.current=K,$o(!0),P==="never"&&l==="empty"?(Le(!0),io(m,u)):(m&&m(void 0),Le(!1))},[be,h,m,l]),hr=b.useMemo(function(){var K;return ae(((K={"react-js-cron":!0,"react-js-cron-error":Tt&&x,"react-js-cron-disabled":I,"react-js-cron-read-only":J})["".concat(k)]=!!k,K["".concat(k,"-error")]=Tt&&x&&!!k,K["".concat(k,"-disabled")]=I&&!!k,K["".concat(k,"-read-only")]=J&&!!k,K))},[k,Tt,x,I,J]),Ft=s.className,Io=no(s,["className"]),Po=b.useMemo(function(){var K;return ae(((K={"react-js-cron-clear-button":!0})["".concat(k,"-clear-button")]=!!k,K["".concat(Ft)]=!!Ft,K))},[k,Ft]),yr=JSON.stringify(Io),Bo=b.useMemo(function(){return o&&!J?r.jsx(y.Button,re({className:Po,danger:!0,type:"primary",disabled:I},Io,{onClick:Mo},{children:u.clearButtonText||B.clearButtonText})):null},[o,J,Eo,Po,I,yr,Mo]),te=be||Ot.current;return r.jsxs("div",re({className:hr},{children:[me.includes("period")&&r.jsx(Bn,{value:te,setValue:Re,locale:u,className:k,disabled:I,readOnly:J,shortcuts:W,allowedPeriods:mr}),te==="reboot"?Bo:r.jsxs(r.Fragment,{children:[te==="year"&&me.includes("months")&&r.jsx(Pn,{value:tt,setValue:ot,locale:u,className:k,humanizeLabels:U,disabled:I,readOnly:J,period:te,periodicityOnDoubleClick:q,mode:ee}),(te==="year"||te==="month")&&me.includes("month-days")&&r.jsx(In,{value:je,setValue:et,locale:u,className:k,weekDays:We,disabled:I,readOnly:J,leadingZero:$,period:te,periodicityOnDoubleClick:q,mode:ee}),(te==="year"||te==="month"||te==="week")&&me.includes("week-days")&&r.jsx(Vn,{value:We,setValue:nt,locale:u,className:k,humanizeLabels:U,monthDays:je,disabled:I,readOnly:J,period:te,periodicityOnDoubleClick:q,mode:ee}),r.jsxs("div",{children:[te!=="minute"&&te!=="hour"&&me.includes("hours")&&r.jsx(En,{value:rt,setValue:st,locale:u,className:k,disabled:I,readOnly:J,leadingZero:$,clockFormat:se,period:te,periodicityOnDoubleClick:q,mode:ee}),te!=="minute"&&me.includes("minutes")&&r.jsx(Mn,{value:it,setValue:lt,locale:u,period:te,className:k,disabled:I,readOnly:J,leadingZero:$,clockFormat:se,periodicityOnDoubleClick:q,mode:ee}),Bo]})]})]}))}const Wn={"zh-CN":{everyText:"每",emptyMonths:"每月",emptyMonthDays:"每日(月)",emptyMonthDaysShort:"每日",emptyWeekDays:"每天(周)",emptyWeekDaysShort:"每天(周)",emptyHours:"每小时",emptyMinutes:"每分钟",emptyMinutesForHourPeriod:"每",yearOption:"年",monthOption:"月",weekOption:"周",dayOption:"天",hourOption:"小时",minuteOption:"分钟",rebootOption:"重启",prefixPeriod:"每",prefixMonths:"的",prefixMonthDays:"的",prefixWeekDays:"的",prefixWeekDaysForMonthAndYearPeriod:"或者",prefixHours:"的",prefixMinutes:":",prefixMinutesForHourPeriod:"的",suffixMinutesForHourPeriod:"分钟",errorInvalidCron:"不符合 cron 规则的表达式",clearButtonText:"清空",weekDays:["周日","周一","周二","周三","周四","周五","周六"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],altWeekDays:["周日","周一","周二","周三","周四","周五","周六"],altMonths:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},yo=[{value:"none",text:"No repeat"},{value:6e4,text:"By minute",unitText:"Minutes"},{value:36e5,text:"By hour",unitText:"Hours"},{value:864e5,text:"By day",unitText:"Days"},{value:6048e5,text:"By week",unitText:"Weeks"},{value:"cron",text:"Advanced"}];function go(e){return yo.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function Ln(e){let t;switch(typeof e){case"number":return t=go(e),t?t.value:"none";case"string":return"cron"}return"none"}function zn({value:e,onChange:t}){const{t:o}=dt(),n=go(e);return r.jsx(y.InputNumber,{value:e/n.value,onChange:s=>t(s*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function Hn({value:e=null,onChange:t}){const{t:o}=dt(),n=Ln(e);function s(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const a=Wn[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:i.css`
454
454
  display: flex;
455
455
  flex-direction: ${n==="cron"?"column":"row"};
456
456
  align-items: flex-start;
@@ -488,11 +488,11 @@
488
488
  .ant-picker {
489
489
  width: auto;
490
490
  }
491
- `},properties:Jn[o]}}},components:{OnField:oo,RepeatField:Hn,EndsByField:Dn}})]})};class Gn extends yt{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:_n})}useVariables(o,n){var c;const s=i.useCompile(),{getCollectionFields:a}=i.useCollectionManager_deprecated(),l=[];if((!(n!=null&&n.types)||n.types.includes("date"))&&l.push({key:"date",value:"date",label:E("Trigger time")}),o.mode===ve.DATE_FIELD){const[u]=Se(T(C({appends:["data",...((c=o.appends)==null?void 0:c.map(d=>`data.${d}`))||[]]},n),{fields:[{collectionName:o.collection,name:"data",type:"hasOne",target:o.collection,uiSchema:{title:E("Trigger data")}}],compile:s,getCollectionFields:a}));u&&l.push(u)}return l}useInitializers(o){return o.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Me,collection:o.collection,dataPath:"$context.data"}:null}}function Be(e){const a=e,{options:t=[],direction:o}=a,n=Z(a,["options","direction"]),s=i.useCompile();return r.jsx(y.Radio.Group,T(C({},n),{children:r.jsx(y.Space,{direction:o,children:t.map(l=>r.jsxs(y.Radio,{value:l.value,children:[r.jsx("span",{className:i.css`
491
+ `},properties:Jn[o]}}},components:{OnField:oo,RepeatField:Hn,EndsByField:Dn}})]})};class Gn extends yt{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:_n})}useVariables(o,n){var c;const s=i.useCompile(),{getCollectionFields:a}=i.useCollectionManager_deprecated(),l=[];if((!(n!=null&&n.types)||n.types.includes("date"))&&l.push({key:"date",value:"date",label:D("Trigger time")}),o.mode===ve.DATE_FIELD){const[u]=Se(T(C({appends:["data",...((c=o.appends)==null?void 0:c.map(d=>`data.${d}`))||[]]},n),{fields:[{collectionName:o.collection,name:"data",type:"hasOne",target:o.collection,uiSchema:{title:D("Trigger data")}}],compile:s,getCollectionFields:a}));u&&l.push(u)}return l}useInitializers(o){return o.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Me,collection:o.collection,dataPath:"$context.data"}:null}}function Be(e){const a=e,{options:t=[],direction:o}=a,n=Z(a,["options","direction"]),s=i.useCompile();return r.jsx(y.Radio.Group,T(C({},n),{children:r.jsx(y.Space,{direction:o,children:t.map(l=>r.jsxs(y.Radio,{value:l.value,children:[r.jsx("span",{className:i.css`
492
492
  & + .anticon {
493
493
  margin-left: 0.25em;
494
494
  }
495
- `,children:s(l.label)}),l.tooltip&&r.jsx(y.Tooltip,{title:s(l.tooltip),children:r.jsx($.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}function bo(){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 Te=()=>null;function Yn(){const a=i.useSchemaInitializerItem(),{node:t,resultTitle:o}=a,n=Z(a,["node","resultTitle"]),{insert:s}=i.useSchemaInitializer();return r.jsx(i.SchemaInitializerItem,T(C({},n),{onClick:()=>{var l;s({type:"void",name:t.id,title:t.title,"x-component":"CardItem","x-component-props":{title:(l=t.title)!=null?l:`#${t.id}`},"x-designer":"ValueBlock.Designer",properties:{result:{type:"void",title:o,"x-component":"ValueBlock.Result","x-component-props":{dataSource:`{{$jobsMapByNodeKey.${t.key}}}`}}}})}}))}function qn({dataSource:e}){var s;const t=j.useFieldSchema(),{execution:o}=Y();if(!o)return t.title;const n=H.parse(e)({$jobsMapByNodeKey:((s=o.jobs)!=null?s:[]).reduce((a,l)=>Object.assign(a,{[l.nodeKey]:l.result}),{})});return r.jsx("pre",{className:i.css`
495
+ `,children:s(l.label)}),l.tooltip&&r.jsx(y.Tooltip,{title:s(l.tooltip),children:r.jsx(E.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}function bo(){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 Te=()=>null;function Yn(){const a=i.useSchemaInitializerItem(),{node:t,resultTitle:o}=a,n=Z(a,["node","resultTitle"]),{insert:s}=i.useSchemaInitializer();return r.jsx(i.SchemaInitializerItem,T(C({},n),{onClick:()=>{var l;s({type:"void",name:t.id,title:t.title,"x-component":"CardItem","x-component-props":{title:(l=t.title)!=null?l:`#${t.id}`},"x-designer":"ValueBlock.Designer",properties:{result:{type:"void",title:o,"x-component":"ValueBlock.Result","x-component-props":{dataSource:`{{$jobsMapByNodeKey.${t.key}}}`}}}})}}))}function qn({dataSource:e}){var s;const t=j.useFieldSchema(),{execution:o}=Y();if(!o)return t.title;const n=H.parse(e)({$jobsMapByNodeKey:((s=o.jobs)!=null?s:[]).reduce((a,l)=>Object.assign(a,{[l.nodeKey]:l.result}),{})});return r.jsx("pre",{className:i.css`
496
496
  margin: 0;
497
497
  `,children:JSON.stringify(n,null,2)})}Te.Initializer=Yn,Te.Result=qn,Te.Designer=bo;const xo=e=>{const t=De.evaluators.get(e);return t&&t.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:i.css`
498
498
  &:after {
@@ -501,16 +501,16 @@
501
501
  & + a {
502
502
  margin-left: 0.25em;
503
503
  }
504
- `,children:i.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class Kn 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 E("Expression syntax error")}},"x-reactions":[{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0}});w(this,"scope",{renderEngineReference:xo});w(this,"components",{WorkflowVariableTextArea:At,RadioWithTooltip:Be,ValueBlock:Te})}useVariables({key:o,title:n},{types:s,fieldNames:a=ke}){return s&&!s.some(l=>l in Ye||Object.values(Ye).some(c=>c.has(l)))?null:{[a.value]:o,[a.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:Te.Initializer,node:o,resultTitle:E("Calculation result")}}}const X=new H.Registry;X.register("equal",{name:"=",type:"boolean",group:"boolean"}),X.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),X.register("gt",{name:">",type:"boolean",group:"boolean"}),X.register("gte",{name:"≥",type:"boolean",group:"boolean"}),X.register("lt",{name:"<",type:"boolean",group:"boolean"}),X.register("lte",{name:"≤",type:"boolean",group:"boolean"}),X.register("add",{name:"+",type:"number",group:"number"}),X.register("minus",{name:"-",type:"number",group:"number"}),X.register("multiple",{name:"*",type:"number",group:"number"}),X.register("divide",{name:"/",type:"number",group:"number"}),X.register("mod",{name:"%",type:"number",group:"number"}),X.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),X.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),X.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),X.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),X.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),X.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),X.register("concat",{name:`{{t("concat", { ns: "${p}" })}}`,type:"string",group:"string"});const Zn=[{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 vo(e){return Array.from(X.getEntities()).filter(([t,o])=>o.group===e)}function Qn({calculator:e,operands:t=[],onChange:o}){const n=i.useCompile(),s=ge();return r.jsxs("fieldset",{className:i.css`
504
+ `,children:i.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class Kn 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 D("Expression syntax error")}},"x-reactions":[{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0}});w(this,"scope",{renderEngineReference:xo});w(this,"components",{WorkflowVariableTextArea:At,RadioWithTooltip:Be,ValueBlock:Te})}useVariables({key:o,title:n},{types:s,fieldNames:a=ke}){return s&&!s.some(l=>l in Ye||Object.values(Ye).some(c=>c.has(l)))?null:{[a.value]:o,[a.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:Te.Initializer,node:o,resultTitle:D("Calculation result")}}}const X=new H.Registry;X.register("equal",{name:"=",type:"boolean",group:"boolean"}),X.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),X.register("gt",{name:">",type:"boolean",group:"boolean"}),X.register("gte",{name:"≥",type:"boolean",group:"boolean"}),X.register("lt",{name:"<",type:"boolean",group:"boolean"}),X.register("lte",{name:"≤",type:"boolean",group:"boolean"}),X.register("add",{name:"+",type:"number",group:"number"}),X.register("minus",{name:"-",type:"number",group:"number"}),X.register("multiple",{name:"*",type:"number",group:"number"}),X.register("divide",{name:"/",type:"number",group:"number"}),X.register("mod",{name:"%",type:"number",group:"number"}),X.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),X.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),X.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),X.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),X.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),X.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),X.register("concat",{name:`{{t("concat", { ns: "${p}" })}}`,type:"string",group:"string"});const Zn=[{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 vo(e){return Array.from(X.getEntities()).filter(([t,o])=>o.group===e)}function Qn({calculator:e,operands:t=[],onChange:o}){const n=i.useCompile(),s=ge();return r.jsxs("fieldset",{className:i.css`
505
505
  display: flex;
506
506
  gap: 0.5em;
507
507
  align-items: center;
508
508
  flex-wrap: wrap;
509
- `,children:[r.jsx(i.Variable.Input,{value:t[0],onChange:a=>o({calculator:e,operands:[a,t[1]]}),scope:s,useTypedConstant:!0}),r.jsx(y.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:a=>o({operands:t,calculator:a}),placeholder:E("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:Zn.filter(a=>!!vo(a.value).length).map(a=>r.jsx(y.Select.OptGroup,{label:n(a.title),children:vo(a.value).map(([l,{name:c}])=>r.jsx(y.Select.Option,{value:l,children:n(c)},l))},a.value))}),r.jsx(i.Variable.Input,{value:t[1],onChange:a=>o({calculator:e,operands:[t[0],a]}),scope:s,useTypedConstant:!0})]})}function Xn({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:n,operands:s=[]}=e;return r.jsxs("div",{className:i.css`
509
+ `,children:[r.jsx(i.Variable.Input,{value:t[0],onChange:a=>o({calculator:e,operands:[a,t[1]]}),scope:s,useTypedConstant:!0}),r.jsx(y.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:a=>o({operands:t,calculator:a}),placeholder:D("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:Zn.filter(a=>!!vo(a.value).length).map(a=>r.jsx(y.Select.OptGroup,{label:n(a.title),children:vo(a.value).map(([l,{name:c}])=>r.jsx(y.Select.Option,{value:l,children:n(c)},l))},a.value))}),r.jsx(i.Variable.Input,{value:t[1],onChange:a=>o({calculator:e,operands:[t[0],a]}),scope:s,useTypedConstant:!0})]})}function Xn({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:n,operands:s=[]}=e;return r.jsxs("div",{className:i.css`
510
510
  display: flex;
511
511
  position: relative;
512
512
  margin: 0.5em 0;
513
- `,children:[e.group?r.jsx(wo,{value:e.group,onChange:a=>t(T(C({},e),{group:a}))}):r.jsx(Qn,{operands:s,calculator:n,onChange:t}),r.jsx(y.Button,{"aria-label":"icon-close",onClick:o,type:"link",icon:r.jsx($.CloseCircleOutlined,{})})]})}function wo({value:e,onChange:t}){const{t:o}=Q.useTranslation(),{type:n="and",calculations:s=[]}=e;function a(){t(T(C({},e),{calculations:[...s,{not:!1,calculator:"equal"}]}))}function l(){t(T(C({},e),{calculations:[...s,{not:!1,group:{type:"and",calculations:[]}}]}))}function c(d){s.splice(d,1),t(T(C({},e),{calculations:[...s]}))}function u(d,f){s.splice(d,1,f),t(T(C({},e),{calculations:[...s]}))}return r.jsxs("div",{className:i.cx("node-type-condition-group",i.css`
513
+ `,children:[e.group?r.jsx(wo,{value:e.group,onChange:a=>t(T(C({},e),{group:a}))}):r.jsx(Qn,{operands:s,calculator:n,onChange:t}),r.jsx(y.Button,{"aria-label":"icon-close",onClick:o,type:"link",icon:r.jsx(E.CloseCircleOutlined,{})})]})}function wo({value:e,onChange:t}){const{t:o}=Q.useTranslation(),{type:n="and",calculations:s=[]}=e;function a(){t(T(C({},e),{calculations:[...s,{not:!1,calculator:"equal"}]}))}function l(){t(T(C({},e),{calculations:[...s,{not:!1,group:{type:"and",calculations:[]}}]}))}function c(d){s.splice(d,1),t(T(C({},e),{calculations:[...s]}))}function u(d,f){s.splice(d,1,f),t(T(C({},e),{calculations:[...s]}))}return r.jsxs("div",{className:i.cx("node-type-condition-group",i.css`
514
514
  position: relative;
515
515
  width: 100%;
516
516
  .node-type-condition-group {
@@ -536,7 +536,7 @@
536
536
  margin-right: 1em;
537
537
  }
538
538
  }
539
- `,children:[r.jsx(y.Button,{type:"link",onClick:a,children:o("Add condition")}),r.jsx(y.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function Rn({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(wo,{value:o.group,onChange:n=>t(T(C({},o),{group:n}))})}class er 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-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 E("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0}});w(this,"options",[{label:`{{t('Continue when "Yes"', { ns: "${p}" })}}`,key:"rejectOnFalse",value:{rejectOnFalse:!0}},{label:`{{t('Branch into "Yes" and "No"', { ns: "${p}" })}}`,key:"branch",value:{rejectOnFalse:!1}}]);w(this,"scope",{renderEngineReference:xo,useWorkflowVariableOptions:ge});w(this,"components",{CalculationConfig:Rn,WorkflowVariableTextArea:At,RadioWithTooltip:Be})}Component({data:o}){const{t:n}=Q.useTranslation(),{nodes:s}=Y(),{styles:a}=ne(),{id:l,config:{rejectOnFalse:c}}=o,u=s.find(f=>f.upstreamId===l&&f.branchIndex===1),d=s.find(f=>f.upstreamId===l&&f.branchIndex===0);return r.jsx(ht,{data:o,children:c?null:r.jsxs("div",{className:a.nodeSubtreeClass,children:[r.jsxs("div",{className:a.branchBlockClass,children:[r.jsx(Ue,{from:o,entry:d,branchIndex:0}),r.jsx(Ue,{from:o,entry:u,branchIndex:1})]}),r.jsxs("div",{className:a.conditionClass,children:[r.jsx("span",{style:{right:"4em"},children:n("No")}),r.jsx("span",{style:{left:"4em"},children:n("Yes")})]})]})})}}class tr 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:ie.RESOLVED},{label:`{{t("Failed", { ns: "${p}" })}}`,value:ie.FAILED}],required:!0,default:ie.RESOLVED}});w(this,"end",!0)}}function Xe({value:e,onChange:t,renderSchemaComponent:o}){const n=ge();return r.jsx(i.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}class or 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:T(C({},le),{"x-reactions":[...le["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${p}" })}}`,description:`{{t("If checked, when there are multiple records in the query result, an array will be returned as the result, which can be operated on one by one using a loop node. Otherwise, only one record will be returned.", { ns: "${p}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:Ge,sort:xn,pagination:vn,appends:Ie},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{$deps[0] != null}}"}}}]},failOnEmpty:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Exit when query result is null", { ns: "${p}" })}}`}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource,useSortableFields(){const o=i.useCompile(),{getCollectionFields:n,getInterface:s}=i.useCollectionManager_deprecated(),{values:a}=j.useForm();return n(a.collection).filter(c=>{if(!c.interface)return!1;const u=s(c.interface);return!!(u!=null&&u.sortable)}).map(c=>{var u,d;return{value:c.name,label:(u=c==null?void 0:c.uiSchema)!=null&&u.title?o((d=c==null?void 0:c.uiSchema)==null?void 0:d.title):c.name}})}});w(this,"components",{ArrayItems:zo.ArrayItems,FilterDynamicComponent:Xe,SchemaComponentContext:i.SchemaComponentContext,WorkflowVariableInput:eo})}useVariables({key:o,title:n,config:s},a){var d,f;const l=i.useCompile(),{getCollectionFields:c}=i.useCollectionManager_deprecated(),[u]=Se(T(C({appends:[o,...((f=(d=s.params)==null?void 0:d.appends)==null?void 0:f.map(h=>`${o}.${h}`))||[]]},a),{fields:[{collectionName:s.collection,name:o,type:"hasOne",target:s.collection,uiSchema:{title:n}}],compile:l,getCollectionFields:c}));return u}useInitializers(o){var n,s;return!o.config.collection||o.config.multiple?null:{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Me,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}}}function nr(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;function f(h){const v=h.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(u)?v:v.split(/[,\s]+/))}return r.jsx(y.Input,T(C({},e),{value:d,onChange:f}))}const Co=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=ge(),{values:f}=c,[h,v]=i.parseCollectionName(f==null?void 0:f.collection),x=u(v,h).filter(A=>A.uiSchema),m=n?x.filter(n.bind(f)):x,k=b.useMemo(()=>m.filter(A=>!e||!(A.name in e)),[m,e]),S=t||c.disabled,N=b.useMemo(()=>({onClick:({key:A})=>{o(T(C({},e),{[A]:null}))},style:{maxHeight:300,overflowY:"auto"},items:k.map(A=>{var P,z;return{key:A.name,label:l((z=(P=A.uiSchema)==null?void 0:P.title)!=null?z:A.name)}})}),[o,k,e]);return r.jsx("fieldset",{className:i.css`
539
+ `,children:[r.jsx(y.Button,{type:"link",onClick:a,children:o("Add condition")}),r.jsx(y.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function Rn({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(wo,{value:o.group,onChange:n=>t(T(C({},o),{group:n}))})}class er 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-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 D("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0}});w(this,"options",[{label:`{{t('Continue when "Yes"', { ns: "${p}" })}}`,key:"rejectOnFalse",value:{rejectOnFalse:!0}},{label:`{{t('Branch into "Yes" and "No"', { ns: "${p}" })}}`,key:"branch",value:{rejectOnFalse:!1}}]);w(this,"scope",{renderEngineReference:xo,useWorkflowVariableOptions:ge});w(this,"components",{CalculationConfig:Rn,WorkflowVariableTextArea:At,RadioWithTooltip:Be})}Component({data:o}){const{t:n}=Q.useTranslation(),{nodes:s}=Y(),{styles:a}=ne(),{id:l,config:{rejectOnFalse:c}}=o,u=s.find(f=>f.upstreamId===l&&f.branchIndex===1),d=s.find(f=>f.upstreamId===l&&f.branchIndex===0);return r.jsx(ht,{data:o,children:c?null:r.jsxs("div",{className:a.nodeSubtreeClass,children:[r.jsxs("div",{className:a.branchBlockClass,children:[r.jsx(Ue,{from:o,entry:d,branchIndex:0}),r.jsx(Ue,{from:o,entry:u,branchIndex:1})]}),r.jsxs("div",{className:a.conditionClass,children:[r.jsx("span",{style:{right:"4em"},children:n("No")}),r.jsx("span",{style:{left:"4em"},children:n("Yes")})]})]})})}}class tr 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:ie.RESOLVED},{label:`{{t("Failed", { ns: "${p}" })}}`,value:ie.FAILED}],required:!0,default:ie.RESOLVED}});w(this,"end",!0)}}function Xe({value:e,onChange:t,renderSchemaComponent:o}){const n=ge();return r.jsx(i.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}class or 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:T(C({},le),{"x-reactions":[...le["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${p}" })}}`,description:`{{t("If checked, when there are multiple records in the query result, an array will be returned as the result, which can be operated on one by one using a loop node. Otherwise, only one record will be returned.", { ns: "${p}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:Ge,sort:xn,pagination:vn,appends:Ie},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{$deps[0] != null}}"}}}]},failOnEmpty:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Exit when query result is null", { ns: "${p}" })}}`}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource,useSortableFields(){const o=i.useCompile(),{getCollectionFields:n,getInterface:s}=i.useCollectionManager_deprecated(),{values:a}=j.useForm();return n(a.collection).filter(c=>{if(!c.interface)return!1;const u=s(c.interface);return!!(u!=null&&u.sortable)}).map(c=>{var u,d;return{value:c.name,label:(u=c==null?void 0:c.uiSchema)!=null&&u.title?o((d=c==null?void 0:c.uiSchema)==null?void 0:d.title):c.name}})}});w(this,"components",{ArrayItems:zo.ArrayItems,FilterDynamicComponent:Xe,SchemaComponentContext:i.SchemaComponentContext,WorkflowVariableInput:eo})}useVariables({key:o,title:n,config:s},a){var d,f;const l=i.useCompile(),{getCollectionFields:c}=i.useCollectionManager_deprecated(),[u]=Se(T(C({appends:[o,...((f=(d=s.params)==null?void 0:d.appends)==null?void 0:f.map(h=>`${o}.${h}`))||[]]},a),{fields:[{collectionName:s.collection,name:o,type:"hasOne",target:s.collection,uiSchema:{title:n}}],compile:l,getCollectionFields:c}));return u}useInitializers(o){var n,s;return!o.config.collection||o.config.multiple?null:{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Me,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}}}function nr(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;function f(h){const v=h.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(u)?v:v.split(/[,\s]+/))}return r.jsx(y.Input,T(C({},e),{value:d,onChange:f}))}const Co=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=ge(),{values:f}=c,[h,v]=i.parseCollectionName(f==null?void 0:f.collection),x=u(v,h).filter(A=>A.uiSchema),m=n?x.filter(n.bind(f)):x,k=b.useMemo(()=>m.filter(A=>!e||!(A.name in e)),[m,e]),S=t||c.disabled,N=b.useMemo(()=>({onClick:({key:A})=>{o(T(C({},e),{[A]:null}))},style:{maxHeight:300,overflowY:"auto"},items:k.map(A=>{var P,z;return{key:A.name,label:l((z=(P=A.uiSchema)==null?void 0:P.title)!=null?z:A.name)}})}),[o,k,e]);return r.jsx("fieldset",{className:i.css`
540
540
  margin-top: 0.5em;
541
541
 
542
542
  > .ant-formily-item {
@@ -550,8 +550,8 @@
550
550
  .ant-form-item-control-input-content {
551
551
  display: flex;
552
552
  }
553
- `,children:[r.jsx(i.Variable.Input,{scope:d,value:e[A.name],changeOnSelect:!0,onChange:F=>{o(T(C({},e),{[A.name]:F}))},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[A.name]:{"x-component":P,"x-validator"(){return""}}}}})}),S?null:r.jsx(y.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx($.CloseCircleOutlined,{}),onClick:()=>{var O;const I=e,{[O=A.name]:F}=I,M=Z(I,[Wo(O)]);o(M)}})]},A.name)}),k.length?r.jsx(y.Dropdown,{menu:N,children:r.jsx(y.Button,{icon:r.jsx($.PlusOutlined,{}),children:a("Add field")})}):null]}):r.jsx("p",{style:{color:s.colorText},children:E("Please select collection first")})})},{displayName:"CollectionFieldSet"});class rr 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:T(C({},le),{"x-reactions":[...le["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{values:qt,appends:Ie}}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource});w(this,"components",{CollectionFieldset:Co})}useVariables({key:o,title:n,config:s},a){var d,f;const l=i.useCompile(),{getCollectionFields:c}=i.useCollectionManager_deprecated(),[u]=Se(T(C({appends:[o,...((f=(d=s.params)==null?void 0:d.appends)==null?void 0:f.map(h=>`${o}.${h}`))||[]]},a),{fields:[{collectionName:s.collection,name:o,type:"hasOne",target:s.collection,uiSchema:{title:n}}],compile:l,getCollectionFields:c}));return u}useInitializers(o){var n,s;return o.config.collection?{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Me,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}:null}}function sr(o){var n=o,{onChange:e}=n,t=Z(n,["onChange"]);const{getCollectionFields:s}=i.useCollectionManager_deprecated(),a=j.useForm(),{collection:l}=a.values,c=s(l),u=j.useField();function d({target:f}){const h=u.query(".values").take();if(!h)return;const v=c.reduce((x,m)=>(m.name in h.value&&(f.value||!["hasOne","hasMany","belongsToMany"].includes(m.type))&&(x[m.name]=h.value[m.name]),x),{});a.setValuesIn("params.values",v),e(f.value)}return r.jsx(Be,T(C({},t),{onChange:d}))}class ir 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:T(C({},le),{"x-reactions":[...le["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}},{target:"params.values",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${p}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.", { ns: "${p}" })}}`},{label:`{{t("Update one by one", { ns: "${p}" })}}`,value:!0,tooltip:`{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${p}" })}}`}]},default:!1},filter:T(C({},Ge),{title:`{{t("Only update records matching conditions", { ns: "${p}" })}}`,"x-validator"(o){return H.isValidFilter(o)?"":E("Please add at least one condition")}}),values:T(C({},qt),{"x-component-props":{filter(o){var n;return((n=this.params)==null?void 0:n.individualHooks)||!["hasOne","hasMany","belongsToMany"].includes(o.type)}}})}}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource});w(this,"components",{FilterDynamicComponent:Xe,CollectionFieldset:Co,IndividualHooksRadioWithTooltip:sr})}}class lr 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:T(C({},le),{"x-reactions":[...le["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:T(C({},Ge),{"x-validator"(o){return H.isValidFilter(o)?"":E("Please add at least one condition")}})}}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource});w(this,"components",{FilterDynamicComponent:Xe})}}const ar=new i.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:i.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=i.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:i.SecondConFirm},{name:"assignFieldValues",Component:i.AssignedFieldValues},{name:"skipRequiredValidation",Component:i.SkipValidation},{name:"afterSuccessfulSubmission",Component:i.AfterSuccess,useVisible(){var t;const e=j.useFieldSchema();return Dt.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.onSuccess)}},{name:"bindWorkflow",Component:i.WorkflowConfig},{name:"delete",sort:100,Component:i.RemoveButton,useComponentProps(){const{removeButtonProps:e}=i.useSchemaToolbar();return e}}]});function cr(e){const{execution:t,nodes:o}=Y(),n=b.useMemo(()=>o.reduce((l,c)=>Object.assign(l,{[c.id]:c.key}),{}),[o]),s=b.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 b.useMemo(()=>ut.get(s,e),[s,e])}function ur({collection:e,dataPath:t,children:o}){const n=j.useField(),s=b.useRef(null),{getAssociationAppends:a}=i.useAssociationNames(),{appends:l,updateAssociationValues:c}=a(),u=cr(t);let d,f;if(typeof e=="string"){const N=i.parseCollectionName(e);d=N[0],f=N[1]}else f=e;const h=b.useMemo(()=>he.createForm({values:u,readPretty:!0}),[u]),v={appends:l},x={loading:!1,data:{data:u}},k=i.useAPIClient().resource(f),S=i.useBlockRequestContext();return r.jsx(i.CollectionProvider_deprecated,{dataSource:d,collection:f,children:r.jsx(i.RecordProvider,{record:u,parent:null,children:r.jsx(i.BlockRequestContext_deprecated.Provider,{value:{block:"form",field:n,service:x,resource:k,__parent:S},children:r.jsx(i.FormBlockContext.Provider,{value:{params:v,form:h,field:n,service:x,updateAssociationValues:c,formBlockRef:s},children:o})})})})}function dr(e){const a=e,{options:t=[],direction:o}=a,n=Z(a,["options","direction"]),s=i.useCompile();return r.jsx(y.Checkbox.Group,T(C({},n),{children:r.jsx(y.Space,{direction:o,children:t.map(l=>r.jsxs(y.Checkbox,{value:l.value,children:[r.jsx("span",{className:i.css`
553
+ `,children:[r.jsx(i.Variable.Input,{scope:d,value:e[A.name],changeOnSelect:!0,onChange:F=>{o(T(C({},e),{[A.name]:F}))},children:r.jsx(i.SchemaComponent,{schema:{type:"void",properties:{[A.name]:{"x-component":P,"x-validator"(){return""}}}}})}),S?null:r.jsx(y.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx(E.CloseCircleOutlined,{}),onClick:()=>{var O;const I=e,{[O=A.name]:F}=I,M=Z(I,[Wo(O)]);o(M)}})]},A.name)}),k.length?r.jsx(y.Dropdown,{menu:N,children:r.jsx(y.Button,{icon:r.jsx(E.PlusOutlined,{}),children:a("Add field")})}):null]}):r.jsx("p",{style:{color:s.colorText},children:D("Please select collection first")})})},{displayName:"CollectionFieldSet"});class rr 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:T(C({},le),{"x-reactions":[...le["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{values:qt,appends:Ie}}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource});w(this,"components",{CollectionFieldset:Co})}useVariables({key:o,title:n,config:s},a){var d,f;const l=i.useCompile(),{getCollectionFields:c}=i.useCollectionManager_deprecated(),[u]=Se(T(C({appends:[o,...((f=(d=s.params)==null?void 0:d.appends)==null?void 0:f.map(h=>`${o}.${h}`))||[]]},a),{fields:[{collectionName:s.collection,name:o,type:"hasOne",target:s.collection,uiSchema:{title:n}}],compile:l,getCollectionFields:c}));return u}useInitializers(o){var n,s;return o.config.collection?{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Me,collection:o.config.collection,dataPath:`$jobsMapByNodeKey.${o.key}`}:null}}function sr(o){var n=o,{onChange:e}=n,t=Z(n,["onChange"]);const{getCollectionFields:s}=i.useCollectionManager_deprecated(),a=j.useForm(),{collection:l}=a.values,c=s(l),u=j.useField();function d({target:f}){const h=u.query(".values").take();if(!h)return;const v=c.reduce((x,m)=>(m.name in h.value&&(f.value||!["hasOne","hasMany","belongsToMany"].includes(m.type))&&(x[m.name]=h.value[m.name]),x),{});a.setValuesIn("params.values",v),e(f.value)}return r.jsx(Be,T(C({},t),{onChange:d}))}class ir 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:T(C({},le),{"x-reactions":[...le["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}},{target:"params.values",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${p}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.", { ns: "${p}" })}}`},{label:`{{t("Update one by one", { ns: "${p}" })}}`,value:!0,tooltip:`{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${p}" })}}`}]},default:!1},filter:T(C({},Ge),{title:`{{t("Only update records matching conditions", { ns: "${p}" })}}`,"x-validator"(o){return H.isValidFilter(o)?"":D("Please add at least one condition")}}),values:T(C({},qt),{"x-component-props":{filter(o){var n;return((n=this.params)==null?void 0:n.individualHooks)||!["hasOne","hasMany","belongsToMany"].includes(o.type)}}})}}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource});w(this,"components",{FilterDynamicComponent:Xe,CollectionFieldset:Co,IndividualHooksRadioWithTooltip:sr})}}class lr 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:T(C({},le),{"x-reactions":[...le["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:T(C({},Ge),{"x-validator"(o){return H.isValidFilter(o)?"":D("Please add at least one condition")}})}}});w(this,"scope",{useCollectionDataSource:i.useCollectionDataSource});w(this,"components",{FilterDynamicComponent:Xe})}}const ar=new i.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:i.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=i.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:i.SecondConFirm},{name:"assignFieldValues",Component:i.AssignedFieldValues},{name:"skipRequiredValidation",Component:i.SkipValidation},{name:"afterSuccessfulSubmission",Component:i.AfterSuccess,useVisible(){var t;const e=j.useFieldSchema();return Dt.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.onSuccess)}},{name:"bindWorkflow",Component:i.WorkflowConfig},{name:"delete",sort:100,Component:i.RemoveButton,useComponentProps(){const{removeButtonProps:e}=i.useSchemaToolbar();return e}}]});function cr(e){const{execution:t,nodes:o}=Y(),n=b.useMemo(()=>o.reduce((l,c)=>Object.assign(l,{[c.id]:c.key}),{}),[o]),s=b.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 b.useMemo(()=>ut.get(s,e),[s,e])}function ur({collection:e,dataPath:t,children:o}){const n=j.useField(),s=b.useRef(null),{getAssociationAppends:a}=i.useAssociationNames(),{appends:l,updateAssociationValues:c}=a(),u=cr(t);let d,f;if(typeof e=="string"){const N=i.parseCollectionName(e);d=N[0],f=N[1]}else f=e;const h=b.useMemo(()=>he.createForm({values:u,readPretty:!0}),[u]),v={appends:l},x={loading:!1,data:{data:u}},k=i.useAPIClient().resource(f),S=i.useBlockRequestContext();return r.jsx(i.CollectionProvider_deprecated,{dataSource:d,collection:f,children:r.jsx(i.RecordProvider,{record:u,parent:null,children:r.jsx(i.BlockRequestContext_deprecated.Provider,{value:{block:"form",field:n,service:x,resource:k,__parent:S},children:r.jsx(i.FormBlockContext.Provider,{value:{params:v,form:h,field:n,service:x,updateAssociationValues:c,formBlockRef:s},children:o})})})})}function dr(e){const a=e,{options:t=[],direction:o}=a,n=Z(a,["options","direction"]),s=i.useCompile();return r.jsx(y.Checkbox.Group,T(C({},n),{children:r.jsx(y.Space,{direction:o,children:t.map(l=>r.jsxs(y.Checkbox,{value:l.value,children:[r.jsx("span",{className:i.css`
554
554
  & + .anticon {
555
555
  margin-left: 0.25em;
556
556
  }
557
- `,children:s(l.label)}),l.tooltip&&r.jsx(y.Tooltip,{title:s(l.tooltip),children:r.jsx($.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}function pr({children:e,workflow:t,execution:o,nodes:n}){const s=i.usePlugin(ce),a=s.triggers.get(t.type).components,l=n.reduce((c,{type:u})=>Object.assign(c,s.instructions.get(u).components),{});return r.jsx($e.Provider,{value:{workflow:t,nodes:n,execution:o},children:r.jsx(i.SchemaComponentOptions,{components:C(C({},a),l),children:e})})}class ce extends i.Plugin{constructor(){super(...arguments);w(this,"triggers",new H.Registry);w(this,"instructions",new H.Registry);w(this,"getTriggersOptions",()=>Array.from(this.triggers.getEntities()).map(a=>{var[o,l]=a,c=l,{title:n}=c,s=Z(c,["title"]);return{value:o,label:n,color:"gold",options:s}}))}isWorkflowSync(o){var n;return(n=this.triggers.get(o.type).sync)!=null?n:o.sync}registerTrigger(o,n){if(typeof n=="function")this.triggers.register(o,new n);else if(n)this.triggers.register(o,n);else throw new TypeError("invalid trigger type to register")}registerInstruction(o,n){if(typeof n=="function")this.instructions.register(o,new n);else if(n instanceof ye)this.instructions.register(o,n);else throw new TypeError("invalid instruction type to register")}load(){return _(this,null,function*(){this.app.router.add("admin.workflow.workflows.id",{path:xe(":id"),element:r.jsx(Gt,{})}),this.app.router.add("admin.workflow.executions.id",{path:_e(":id"),element:r.jsx(Lt,{})}),this.app.addComponents({WorkflowPage:Gt,ExecutionPage:Lt}),this.app.pluginSettingsManager.add(p,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${p}" })}}`,Component:yn,aclSnippet:"pm.workflow.workflows"}),this.app.schemaSettingsManager.add(ar),this.registerTrigger("collection",Fn),this.registerTrigger("schedule",Gn),this.registerInstruction("calculation",Kn),this.registerInstruction("condition",er),this.registerInstruction("end",tr),this.registerInstruction("query",or),this.registerInstruction("create",rr),this.registerInstruction("update",ir),this.registerInstruction("destroy",lr)})}}g.BaseTypeSets=Ye,g.Branch=Ue,g.CheckboxGroupWithTooltip=dr,g.CollectionBlockInitializer=Me,g.DetailsBlockProvider=ur,g.EXECUTION_STATUS=de,g.ExecutionContextProvider=pr,g.ExecutionStatusOptions=ze,g.ExecutionStatusOptionsMap=He,g.FieldsSelect=vt,g.FilterDynamicComponent=Xe,g.FlowContext=$e,g.Instruction=ye,g.JOB_STATUS=ie,g.JobButton=jt,g.JobStatusOptions=mt,g.JobStatusOptionsMap=Je,g.Node=Bt,g.NodeContext=ft,g.NodeDefaultView=ht,g.RadioWithTooltip=Be,g.RemoveButton=Vt,g.SimpleDesigner=bo,g.Trigger=yt,g.ValueBlock=Te,g.WorkflowVariableInput=eo,g.WorkflowVariableJSON=kn,g.WorkflowVariableRawTextArea=Cn,g.WorkflowVariableTextArea=At,g.default=ce,g.defaultFieldNames=ke,g.getCollectionFieldOptions=Se,g.getWorkflowDetailPath=xe,g.getWorkflowExecutionsPath=_e,g.linkNodes=bt,g.nodesOptions=Kt,g.scopeOptions=Qt,g.systemOptions=Xt,g.traverseSchema=xt,g.triggerOptions=Zt,g.useAvailableUpstreams=It,g.useFlowContext=Y,g.useGetAriaLabelOfAddButton=pt,g.useNodeContext=Ce,g.useRecordTriggerWorkflowsActionProps=An,g.useStyles=ne,g.useTrigger=gt,g.useTriggerWorkflowsActionProps=Sn,g.useUpstreamScopes=Pt,g.useWorkflowAnyExecuted=to,g.useWorkflowExecuted=On,g.useWorkflowVariableOptions=ge,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
557
+ `,children:s(l.label)}),l.tooltip&&r.jsx(y.Tooltip,{title:s(l.tooltip),children:r.jsx(E.QuestionCircleOutlined,{style:{color:"#666"}})})]},l.value))})}))}function pr({children:e,workflow:t,execution:o,nodes:n}){const s=i.usePlugin(ce),a=s.triggers.get(t.type).components,l=n.reduce((c,{type:u})=>Object.assign(c,s.instructions.get(u).components),{});return r.jsx($e.Provider,{value:{workflow:t,nodes:n,execution:o},children:r.jsx(i.SchemaComponentOptions,{components:C(C({},a),l),children:e})})}class ce extends i.Plugin{constructor(){super(...arguments);w(this,"triggers",new H.Registry);w(this,"instructions",new H.Registry);w(this,"getTriggersOptions",()=>Array.from(this.triggers.getEntities()).map(a=>{var[o,l]=a,c=l,{title:n}=c,s=Z(c,["title"]);return{value:o,label:n,color:"gold",options:s}}))}isWorkflowSync(o){var n;return(n=this.triggers.get(o.type).sync)!=null?n:o.sync}registerTrigger(o,n){if(typeof n=="function")this.triggers.register(o,new n);else if(n)this.triggers.register(o,n);else throw new TypeError("invalid trigger type to register")}registerInstruction(o,n){if(typeof n=="function")this.instructions.register(o,new n);else if(n instanceof ye)this.instructions.register(o,n);else throw new TypeError("invalid instruction type to register")}load(){return _(this,null,function*(){this.app.router.add("admin.workflow.workflows.id",{path:xe(":id"),element:r.jsx(Gt,{})}),this.app.router.add("admin.workflow.executions.id",{path:_e(":id"),element:r.jsx(Lt,{})}),this.app.addComponents({WorkflowPage:Gt,ExecutionPage:Lt}),this.app.pluginSettingsManager.add(p,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${p}" })}}`,Component:yn,aclSnippet:"pm.workflow.workflows"}),this.app.schemaSettingsManager.add(ar),this.registerTrigger("collection",Fn),this.registerTrigger("schedule",Gn),this.registerInstruction("calculation",Kn),this.registerInstruction("condition",er),this.registerInstruction("end",tr),this.registerInstruction("query",or),this.registerInstruction("create",rr),this.registerInstruction("update",ir),this.registerInstruction("destroy",lr)})}}g.BaseTypeSets=Ye,g.Branch=Ue,g.CheckboxGroupWithTooltip=dr,g.CollectionBlockInitializer=Me,g.DetailsBlockProvider=ur,g.EXECUTION_STATUS=de,g.ExecutionContextProvider=pr,g.ExecutionStatusOptions=ze,g.ExecutionStatusOptionsMap=He,g.FieldsSelect=vt,g.FilterDynamicComponent=Xe,g.FlowContext=$e,g.Instruction=ye,g.JOB_STATUS=ie,g.JobButton=jt,g.JobStatusOptions=mt,g.JobStatusOptionsMap=Je,g.Node=Bt,g.NodeContext=ft,g.NodeDefaultView=ht,g.RadioWithTooltip=Be,g.RemoveButton=Vt,g.SimpleDesigner=bo,g.Trigger=yt,g.ValueBlock=Te,g.WorkflowVariableInput=eo,g.WorkflowVariableJSON=kn,g.WorkflowVariableRawTextArea=Cn,g.WorkflowVariableTextArea=At,g.default=ce,g.defaultFieldNames=ke,g.getCollectionFieldOptions=Se,g.getWorkflowDetailPath=xe,g.getWorkflowExecutionsPath=_e,g.linkNodes=bt,g.nodesOptions=Kt,g.scopeOptions=Qt,g.systemOptions=Xt,g.traverseSchema=xt,g.triggerOptions=Zt,g.useAvailableUpstreams=It,g.useFlowContext=Y,g.useGetAriaLabelOfAddButton=pt,g.useNodeContext=Ce,g.useRecordTriggerWorkflowsActionProps=An,g.useStyles=ne,g.useTrigger=gt,g.useTriggerWorkflowsActionProps=Sn,g.useUpstreamScopes=Pt,g.useWorkflowAnyExecuted=to,g.useWorkflowExecuted=On,g.useWorkflowVariableOptions=ge,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -2,23 +2,23 @@ module.exports = {
2
2
  "react": "18.2.0",
3
3
  "antd": "5.12.8",
4
4
  "@ant-design/icons": "5.2.6",
5
- "@nocobase/client": "0.21.0-alpha.9",
5
+ "@nocobase/client": "1.0.0-alpha.2",
6
6
  "react-router-dom": "6.21.0",
7
- "@nocobase/utils": "0.21.0-alpha.9",
7
+ "@nocobase/utils": "1.0.0-alpha.2",
8
8
  "react-i18next": "11.18.6",
9
9
  "@formily/core": "2.3.0",
10
10
  "@formily/react": "2.3.0",
11
- "@nocobase/database": "0.21.0-alpha.9",
12
- "@nocobase/server": "0.21.0-alpha.9",
13
- "@nocobase/logger": "0.21.0-alpha.9",
14
- "@nocobase/evaluators": "0.21.0-alpha.9",
11
+ "@nocobase/database": "1.0.0-alpha.2",
12
+ "@nocobase/server": "1.0.0-alpha.2",
13
+ "@nocobase/logger": "1.0.0-alpha.2",
14
+ "@nocobase/evaluators": "1.0.0-alpha.2",
15
15
  "@formily/shared": "2.3.0",
16
16
  "lodash": "4.17.21",
17
17
  "@formily/antd-v5": "1.1.9",
18
- "@nocobase/actions": "0.21.0-alpha.9",
19
- "@nocobase/data-source-manager": "0.21.0-alpha.9",
18
+ "@nocobase/actions": "1.0.0-alpha.2",
19
+ "@nocobase/data-source-manager": "1.0.0-alpha.2",
20
20
  "sequelize": "6.35.2",
21
- "@nocobase/plugin-workflow-test": "0.21.0-alpha.9",
22
- "@nocobase/test": "0.21.0-alpha.9",
21
+ "@nocobase/plugin-workflow-test": "1.0.0-alpha.2",
22
+ "@nocobase/test": "1.0.0-alpha.2",
23
23
  "dayjs": "1.11.10"
24
24
  };
@@ -35,7 +35,7 @@
35
35
  "Will be executed in the background as a queued task.": "将作为队列任务在后台执行。",
36
36
  "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.":
37
37
  "适用于需要即时反馈的用户操作。不能在此模式下使用异步节点,并且不建议在同步模式下执行耗时的操作。",
38
-
38
+ "Go back": "返回",
39
39
  "Bind workflows": "绑定工作流",
40
40
  "Workflow will be triggered before or after submitting succeeded based on workflow type.": "工作流会基于其类型在提交成功之前或之后触发。",
41
41
  "Workflow will be triggered directly once the button clicked, without data saving. Only supports \"Post-action event\" for now.": "按钮点击后直接触发工作流,但不会保存数据。目前仅支持“操作后事件”。",
@@ -183,7 +183,7 @@
183
183
  "Delete records of a collection. Could use variables in workflow context as filter. All records match the filter will be deleted.":
184
184
  "删除一个数据表中的数据。可以使用上游节点里的变量作为过滤条件。所有满足条件的数据都将被删除。",
185
185
 
186
- "Executed workflow cannot be modified": "已经执行过的工作流不能被修改",
186
+ "Executed workflow cannot be modified. Could be copied to a new version to modify.": "已经执行过的工作流不能被修改,可通过复制到新版本后再修改。",
187
187
  "Can not delete": "无法删除",
188
188
  "The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.":
189
189
  "该节点的执行结果已被其他节点({{nodes}})引用,删除前请先移除引用。",
@@ -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-04-16T15:08:03.502Z"}
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-04-29T05:10:52.523Z"}
@@ -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-04-16T15:08:03.189Z"}
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-04-29T05:10:52.189Z"}
@@ -20,6 +20,7 @@ export default class PluginWorkflowServer extends Plugin {
20
20
  private eventsCount;
21
21
  private loggerCache;
22
22
  private meter;
23
+ private checker;
23
24
  private onBeforeSave;
24
25
  /**
25
26
  * @experimental
@@ -60,6 +60,7 @@ class PluginWorkflowServer extends import_server.Plugin {
60
60
  eventsCount = 0;
61
61
  loggerCache;
62
62
  meter = null;
63
+ checker = null;
63
64
  onBeforeSave = async (instance, options) => {
64
65
  const Model = instance.constructor;
65
66
  if (instance.enabled) {
@@ -223,6 +224,9 @@ class PluginWorkflowServer extends import_server.Plugin {
223
224
  workflows.forEach((workflow) => {
224
225
  this.toggle(workflow);
225
226
  });
227
+ this.checker = setInterval(() => {
228
+ this.dispatch();
229
+ }, 3e5);
226
230
  });
227
231
  this.app.on("afterStart", () => {
228
232
  this.app.setMaintainingMessage("check for not started executions");
@@ -244,6 +248,9 @@ class PluginWorkflowServer extends import_server.Plugin {
244
248
  if (this.executing) {
245
249
  await this.executing;
246
250
  }
251
+ if (this.checker) {
252
+ clearInterval(this.checker);
253
+ }
247
254
  });
248
255
  }
249
256
  toggle(workflow, enable) {
@@ -397,32 +404,35 @@ class PluginWorkflowServer extends import_server.Plugin {
397
404
  }
398
405
  this.executing = (async () => {
399
406
  let next = null;
400
- if (this.pending.length) {
401
- next = this.pending.shift();
402
- this.getLogger(next[0].workflowId).info(`pending execution (${next[0].id}) ready to process`);
403
- } else {
404
- const execution = await this.db.getRepository("executions").findOne({
405
- filter: {
406
- status: import_constants.EXECUTION_STATUS.QUEUEING,
407
- "workflow.enabled": true,
408
- "workflow.id": {
409
- [import_database.Op.not]: null
410
- }
411
- },
412
- appends: ["workflow"],
413
- sort: "createdAt"
414
- });
415
- if (execution) {
416
- this.getLogger(execution.workflowId).info(`execution (${execution.id}) fetched from db`);
417
- next = [execution];
407
+ try {
408
+ if (this.pending.length) {
409
+ next = this.pending.shift();
410
+ this.getLogger(next[0].workflowId).info(`pending execution (${next[0].id}) ready to process`);
411
+ } else {
412
+ const execution = await this.db.getRepository("executions").findOne({
413
+ filter: {
414
+ status: import_constants.EXECUTION_STATUS.QUEUEING,
415
+ "workflow.enabled": true,
416
+ "workflow.id": {
417
+ [import_database.Op.not]: null
418
+ }
419
+ },
420
+ appends: ["workflow"],
421
+ sort: "id"
422
+ });
423
+ if (execution) {
424
+ this.getLogger(execution.workflowId).info(`execution (${execution.id}) fetched from db`);
425
+ next = [execution];
426
+ }
427
+ }
428
+ if (next) {
429
+ await this.process(...next);
430
+ }
431
+ } finally {
432
+ this.executing = null;
433
+ if (next) {
434
+ this.dispatch();
418
435
  }
419
- }
420
- if (next) {
421
- await this.process(...next);
422
- }
423
- this.executing = null;
424
- if (next) {
425
- this.dispatch();
426
436
  }
427
437
  })();
428
438
  }
@@ -65,7 +65,7 @@ class ScheduleTrigger extends import__.default {
65
65
  }
66
66
  const existed = await workflow.countExecutions({
67
67
  where: {
68
- "context.date": context.date
68
+ "context.date": context.date instanceof Date ? context.date.toISOString() : context.date
69
69
  },
70
70
  transaction: options.transaction
71
71
  });
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": "0.21.0-alpha.9",
7
+ "version": "1.0.0-alpha.2",
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": "0.21.0-alpha.9"
13
+ "@nocobase/plugin-workflow-test": "1.0.0-alpha.2"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@ant-design/icons": "5.x",
@@ -31,20 +31,20 @@
31
31
  "sequelize": "^6.26.0"
32
32
  },
33
33
  "peerDependencies": {
34
- "@nocobase/actions": "0.x",
35
- "@nocobase/client": "0.x",
36
- "@nocobase/database": "0.x",
37
- "@nocobase/evaluators": "0.x",
38
- "@nocobase/logger": "0.x",
39
- "@nocobase/plugin-collection-manager": "0.x",
40
- "@nocobase/plugin-error-handler": "0.x",
41
- "@nocobase/plugin-users": "0.x",
42
- "@nocobase/resourcer": "0.x",
43
- "@nocobase/server": "0.x",
44
- "@nocobase/test": "0.x",
45
- "@nocobase/utils": "0.x"
34
+ "@nocobase/actions": "1.x",
35
+ "@nocobase/client": "1.x",
36
+ "@nocobase/database": "1.x",
37
+ "@nocobase/evaluators": "1.x",
38
+ "@nocobase/logger": "1.x",
39
+ "@nocobase/plugin-data-source-main": "1.x",
40
+ "@nocobase/plugin-error-handler": "1.x",
41
+ "@nocobase/plugin-users": "1.x",
42
+ "@nocobase/resourcer": "1.x",
43
+ "@nocobase/server": "1.x",
44
+ "@nocobase/test": "1.x",
45
+ "@nocobase/utils": "1.x"
46
46
  },
47
- "gitHead": "a6fe6c4ee532c04e5a50ec777bf76436ca624cbd",
47
+ "gitHead": "f89dbc9e67d58404a2e484a5e124f739f340dcf8",
48
48
  "keywords": [
49
49
  "Workflow"
50
50
  ]