@nocobase/plugin-workflow 0.19.0-alpha.4 → 0.19.0-alpha.5

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("@ant-design/icons"),require("@nocobase/client"),require("react"),require("antd"),require("react-i18next"),require("@formily/core"),require("@formily/react"),require("lodash"),require("@nocobase/utils/client"),require("react-router-dom"),require("dayjs"),require("@nocobase/evaluators/client"),require("@formily/antd-v5")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@ant-design/icons","@nocobase/client","react","antd","react-i18next","@formily/core","@formily/react","lodash","@nocobase/utils/client","react-router-dom","dayjs","@nocobase/evaluators/client","@formily/antd-v5"],r):(g=typeof globalThis!="undefined"?globalThis:g||self,r(g["@nocobase/plugin-workflow"]={},g.jsxRuntime,g["@ant-design/icons"],g["@nocobase/client"],g.react,g.antd,g["react-i18next"],g["@formily/core"],g["@formily/react"],g.lodash,g["@nocobase/utils"],g["react-router-dom"],g.dayjs,g["@nocobase/evaluators"],g["@formily/antd-v5"]))})(this,function(g,r,T,a,b,y,Q,ge,P,we,ue,le,Vo,De,jo){"use strict";var sr=Object.defineProperty,ir=Object.defineProperties;var lr=Object.getOwnPropertyDescriptors;var ut=Object.getOwnPropertySymbols;var Mo=Object.prototype.hasOwnProperty,Po=Object.prototype.propertyIsEnumerable;var Dt=(g,r,T)=>r in g?sr(g,r,{enumerable:!0,configurable:!0,writable:!0,value:T}):g[r]=T,w=(g,r)=>{for(var T in r||(r={}))Mo.call(r,T)&&Dt(g,T,r[T]);if(ut)for(var T of ut(r))Po.call(r,T)&&Dt(g,T,r[T]);return g},A=(g,r)=>ir(g,lr(r));var Bo=g=>typeof g=="symbol"?g:g+"",_=(g,r)=>{var T={};for(var a in g)Mo.call(g,a)&&r.indexOf(a)<0&&(T[a]=g[a]);if(g!=null&&ut)for(var a of ut(g))r.indexOf(a)<0&&Po.call(g,a)&&(T[a]=g[a]);return T};var x=(g,r,T)=>(Dt(g,typeof r!="symbol"?r+"":r,T),T);var K=(g,r,T)=>new Promise((a,b)=>{var y=P=>{try{ge(T.next(P))}catch(we){b(we)}},Q=P=>{try{ge(T.throw(P))}catch(we){b(we)}},ge=P=>P.done?a(P.value):Promise.resolve(P.value).then(y,Q);ge((T=T.apply(g,r)).next())});const Je=b.createContext({});function Z(){return b.useContext(Je)}const m="workflow";function E(e,t={}){return a.i18n.t(e,A(w({},t),{ns:m}))}function dt(){return Q.useTranslation(m)}const te=a.createStyles(({css:e,token:t})=>({workflowPageClass:e`
1
+ (function(g,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("react/jsx-runtime"),require("@ant-design/icons"),require("@nocobase/client"),require("react"),require("antd"),require("react-i18next"),require("@formily/core"),require("@formily/react"),require("lodash"),require("@nocobase/utils/client"),require("react-router-dom"),require("dayjs"),require("@nocobase/evaluators/client"),require("@formily/antd-v5")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@ant-design/icons","@nocobase/client","react","antd","react-i18next","@formily/core","@formily/react","lodash","@nocobase/utils/client","react-router-dom","dayjs","@nocobase/evaluators/client","@formily/antd-v5"],r):(g=typeof globalThis!="undefined"?globalThis:g||self,r(g["@nocobase/plugin-workflow"]={},g.jsxRuntime,g["@ant-design/icons"],g["@nocobase/client"],g.react,g.antd,g["react-i18next"],g["@formily/core"],g["@formily/react"],g.lodash,g["@nocobase/utils"],g["react-router-dom"],g.dayjs,g["@nocobase/evaluators"],g["@formily/antd-v5"]))})(this,function(g,r,T,a,b,y,Q,ge,P,we,ue,le,Vo,Ee,jo){"use strict";var sr=Object.defineProperty,ir=Object.defineProperties;var lr=Object.getOwnPropertyDescriptors;var ut=Object.getOwnPropertySymbols;var Mo=Object.prototype.hasOwnProperty,Po=Object.prototype.propertyIsEnumerable;var Et=(g,r,T)=>r in g?sr(g,r,{enumerable:!0,configurable:!0,writable:!0,value:T}):g[r]=T,w=(g,r)=>{for(var T in r||(r={}))Mo.call(r,T)&&Et(g,T,r[T]);if(ut)for(var T of ut(r))Po.call(r,T)&&Et(g,T,r[T]);return g},A=(g,r)=>ir(g,lr(r));var Bo=g=>typeof g=="symbol"?g:g+"",_=(g,r)=>{var T={};for(var a in g)Mo.call(g,a)&&r.indexOf(a)<0&&(T[a]=g[a]);if(g!=null&&ut)for(var a of ut(g))r.indexOf(a)<0&&Po.call(g,a)&&(T[a]=g[a]);return T};var x=(g,r,T)=>(Et(g,typeof r!="symbol"?r+"":r,T),T);var K=(g,r,T)=>new Promise((a,b)=>{var y=P=>{try{ge(T.next(P))}catch(we){b(we)}},Q=P=>{try{ge(T.throw(P))}catch(we){b(we)}},ge=P=>P.done?a(P.value):Promise.resolve(P.value).then(y,Q);ge((T=T.apply(g,r)).next())});const Je=b.createContext({});function Z(){return b.useContext(Je)}const p="workflow";function D(e,t={}){return a.i18n.t(e,A(w({},t),{ns:p}))}function dt(){return Q.useTranslation(p)}const te=a.createStyles(({css:e,token:t})=>({workflowPageClass:e`
2
2
  flex-grow: 1;
3
3
  overflow: hidden;
4
4
  display: flex;
@@ -186,8 +186,7 @@
186
186
  align-items: center;
187
187
  justify-content: center;
188
188
  width: 0;
189
- height: 4em;
190
- padding: 1em 0;
189
+ height: 6em;
191
190
  border-left: 1px dashed ${t.colorBgLayout};
192
191
 
193
192
  .anticon {
@@ -351,7 +350,7 @@
351
350
  border-radius: 50%;
352
351
  background-color: ${t.colorText};
353
352
  color: ${t.colorBgContainer};
354
- `}));function Et(e){var h;const{upstream:t,branchIndex:o=null}=e,n=a.usePlugin(ce),s=a.useCompile(),i=a.useAPIClient(),{workflow:l,refresh:c}=(h=Z())!=null?h:{},u=Array.from(n.instructions.getValues()),{styles:d}=te(),f=b.useMemo(()=>[{key:"control",label:`{{t("Control", { ns: "${m}" })}}`},{key:"collection",label:`{{t("Collection operations", { ns: "${m}" })}}`},{key:"manual",label:`{{t("Manual", { ns: "${m}" })}}`},{key:"extended",label:`{{t("Extended types", { ns: "${m}" })}}`}].map(p=>{const C=u.filter(F=>F.group===p.key&&(F.isAvailable?F.isAvailable({engine:n,workflow:l,upstream:t,branchIndex:o}):!0));return A(w({},p),{type:"group",children:C.map(F=>({role:"button","aria-label":F.type,key:F.type,label:F.title,type:F.options?"subMenu":null,children:F.options?F.options.map(M=>({role:"button","aria-label":M.key,key:M.key,label:M.label})):null}))})}).filter(p=>p.children.length),[o,n,u,t,l]),v=b.useCallback(C=>K(this,[C],function*({keyPath:p}){var z,H,$;const F=p.pop(),M={},[O]=p,B=n.instructions.get(F);if(O){const{value:N}=(H=(z=B.options)==null?void 0:z.find(S=>S.key===O))!=null?H:{};Object.assign(M,typeof N=="function"?N():N)}l&&(yield i.resource("workflows.nodes",l.id).create({values:{type:F,upstreamId:($=t==null?void 0:t.id)!=null?$:null,branchIndex:o,title:s(B.title),config:M}}),c())}),[i,o,n.instructions,c,t==null?void 0:t.id,l]),k=b.useMemo(()=>({onClick:v,items:s(f)}),[f,v]);return l?r.jsx("div",{className:d.addButtonClass,children:r.jsx(y.Dropdown,{trigger:["click"],menu:k,disabled:l.executed,overlayClassName:a.css`
353
+ `}));function Dt(e){var h;const{upstream:t,branchIndex:o=null}=e,n=a.usePlugin(ce),s=a.useCompile(),i=a.useAPIClient(),{workflow:l,refresh:c}=(h=Z())!=null?h:{},u=Array.from(n.instructions.getValues()),{styles:d}=te(),f=b.useMemo(()=>[{key:"control",label:`{{t("Control", { ns: "${p}" })}}`},{key:"collection",label:`{{t("Collection operations", { ns: "${p}" })}}`},{key:"manual",label:`{{t("Manual", { ns: "${p}" })}}`},{key:"extended",label:`{{t("Extended types", { ns: "${p}" })}}`}].map(m=>{const C=u.filter(F=>F.group===m.key&&(F.isAvailable?F.isAvailable({engine:n,workflow:l,upstream:t,branchIndex:o}):!0));return A(w({},m),{type:"group",children:C.map(F=>({role:"button","aria-label":F.type,key:F.type,label:F.title,type:F.options?"subMenu":null,children:F.options?F.options.map(M=>({role:"button","aria-label":M.key,key:M.key,label:M.label})):null}))})}).filter(m=>m.children.length),[o,n,u,t,l]),v=b.useCallback(C=>K(this,[C],function*({keyPath:m}){var z,H,$;const F=m.pop(),M={},[O]=m,B=n.instructions.get(F);if(O){const{value:N}=(H=(z=B.options)==null?void 0:z.find(S=>S.key===O))!=null?H:{};Object.assign(M,typeof N=="function"?N():N)}l&&(yield i.resource("workflows.nodes",l.id).create({values:{type:F,upstreamId:($=t==null?void 0:t.id)!=null?$:null,branchIndex:o,title:s(B.title),config:M}}),c())}),[i,o,n.instructions,c,t==null?void 0:t.id,l]),k=b.useMemo(()=>({onClick:v,items:s(f)}),[f,v]);return l?r.jsx("div",{className:d.addButtonClass,children:r.jsx(y.Dropdown,{trigger:["click"],menu:k,disabled:l.executed,overlayClassName:a.css`
355
354
  .ant-dropdown-menu-root {
356
355
  max-height: 30em;
357
356
  overflow-y: auto;
@@ -397,7 +396,7 @@
397
396
  }
398
397
  `,noStatusButtonClass:e`
399
398
  border-width: 2px;
400
- `}));function Ee(e){var n;const{styles:t}=Ho();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:s,color:i}=e.statusMap[e.status];o=r.jsx(y.Tag,{color:i,children:s})}return r.jsx(y.Button,A(w({},e),{shape:"circle",size:"small",className:Jo(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const ae={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},He=[{value:ae.QUEUEING,label:`{{t("Queueing", { ns: "${m}" })}}`,color:"blue",icon:r.jsx(T.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${m}" })}}`},{value:ae.STARTED,label:`{{t("On going", { ns: "${m}" })}}`,color:"gold",icon:r.jsx(T.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${m}" })}}`},{value:ae.RESOLVED,label:`{{t("Resolved", { ns: "${m}" })}}`,color:"green",icon:r.jsx(T.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${m}" })}}`},{value:ae.FAILED,label:`{{t("Failed", { ns: "${m}" })}}`,color:"red",icon:r.jsx(T.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${m}" })}}`},{value:ae.ERROR,label:`{{t("Error", { ns: "${m}" })}}`,color:"red",icon:r.jsx(T.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${m}" })}}`},{value:ae.ABORTED,label:`{{t("Aborted", { ns: "${m}" })}}`,color:"red",icon:r.jsx(T.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${m}" })}}`},{value:ae.CANCELED,label:`{{t("Canceled", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(T.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${m}" })}}`},{value:ae.REJECTED,label:`{{t("Rejected", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(T.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${m}" })}}`},{value:ae.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(T.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${m}" })}}`}],Ue=He.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),re={PENDING:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},mt=[{value:re.PENDING,label:`{{t("Pending", { ns: "${m}" })}}`,color:"gold",icon:r.jsx(T.ClockCircleOutlined,{})},{value:re.RESOLVED,label:`{{t("Resolved", { ns: "${m}" })}}`,color:"green",icon:r.jsx(T.CheckOutlined,{})},{value:re.FAILED,label:`{{t("Failed", { ns: "${m}" })}}`,color:"red",icon:r.jsx(T.ExclamationOutlined,{})},{value:re.ERROR,label:`{{t("Error", { ns: "${m}" })}}`,color:"red",icon:r.jsx(T.CloseOutlined,{})},{value:re.ABORTED,label:`{{t("Aborted", { ns: "${m}" })}}`,color:"red",icon:r.jsx(T.MinusOutlined,{rotate:90})},{value:re.CANCELED,label:`{{t("Canceled", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(T.MinusOutlined,{rotate:45})},{value:re.REJECTED,label:`{{t("Rejected", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(T.MinusOutlined,{})},{value:re.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(T.RedoOutlined,{})}],Ye=mt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});class fe{constructor(){x(this,"title");x(this,"type");x(this,"group");x(this,"description");x(this,"options");x(this,"fieldset");x(this,"view");x(this,"scope");x(this,"components");x(this,"end")}}function Uo(){const e=P.useForm(),t=a.useAPIClient(),o=a.useActionContext(),{refresh:n}=a.useResourceActionContext(),s=Ce(),{workflow:i}=Z();return{run(){return K(this,null,function*(){var c,u;if(i.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 Mt(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}=te(),{getAriaLabel:o}=pt(e),n=a.usePlugin(ce),{Component:s=ht,end:i}=n.instructions.get(e.type);return r.jsx(ft.Provider,{value:e,children:r.jsxs("div",{className:a.cx(t.nodeBlockClass),children:[r.jsx(s,{data:e}),!i||typeof i=="function"&&!i(e)?r.jsx(Et,{"aria-label":o(),upstream:e}):r.jsx("div",{className:"end-sign",children:r.jsx(T.CloseOutlined,{})})]})})}function Vt(){var d;const{t:e}=Q.useTranslation(),t=a.useAPIClient(),{workflow:o,nodes:n,refresh:s}=(d=Z())!=null?d:{},i=Ce(),{modal:l}=y.App.useApp();if(!o)return null;const c=t.resource("flow_nodes");function u(){return K(this,null,function*(){function f(){return K(this,null,function*(){var p;yield(p=c.destroy)==null?void 0:p.call(c,{filterByTk:i.id}),s()})}const v=n.filter(p=>p===i?!1:ue.parse(p.config).parameters.filter(({key:M})=>M.startsWith(`$jobsMapByNodeKey.${i.key}.`)||M===`$jobsMapByNodeKey.${i.key}`).length);if(v.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:v.map(p=>`#${p.id}`).join(", ")})});return}const h=!n.find(p=>p.upstream===i&&p.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:h,onOk:f})})}return o.executed?null:r.jsx(y.Button,{type:"text",shape:"circle",icon:r.jsx(T.DeleteOutlined,{}),onClick:u,className:"workflow-node-remove-button"})}function jt(){var i;const{execution:e,setViewJob:t}=Z(),{jobs:o}=(i=Ce())!=null?i:{},{styles:n}=te();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:Ye,status:l.status}),r.jsx("time",{children:ue.str2moment(l.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),onClick:s,className:n.dropdownClass},children:r.jsx(Ee,{statusMap:Ye,status:o[o.length-1].status,className:n.nodeJobButtonClass})}):r.jsx(Ee,{statusMap:Ye,status:o[0].status,onClick:()=>t(o[0]),className:n.nodeJobButtonClass})}function Yo(){return{form:P.useForm()}}function ht(e){var $,N;const{data:t,children:o}=e,n=a.useCompile(),s=a.useAPIClient(),{workflow:i,refresh:l}=($=Z())!=null?$:{},{styles:c}=te(),d=a.usePlugin(ce).instructions.get(t.type),f=i.executed?'{{t("View")}}':'{{t("Configure")}}',v=n(d.title),[k,h]=b.useState((N=t.title)!=null?N:v),[p,C]=b.useState(!1),[F,M]=b.useState(!1),O=b.useMemo(()=>{const S=we.cloneDeep(t.config);return ge.createForm({initialValues:S,disabled:i.executed})},[t,i]),B=b.useCallback(S=>{C(S),S||O.reset()},[O]),z=b.useCallback(function(S){return K(this,null,function*(){var W,J;const I=S||v;h(I),I!==t.title&&(yield(J=(W=s.resource("flow_nodes")).update)==null?void 0:J.call(W,{filterByTk:t.id,values:{title:I}}),l())})},[t]),H=b.useCallback(function(S){if(S.target===S.currentTarget){C(!0);return}const I=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let W=S.target;W&&W!==S.currentTarget&&W!==document.documentElement;W=W.parentNode)if(Array.from(W.classList).some(J=>I.has(J))){C(!0),S.stopPropagation();return}},[]);return r.jsxs("div",{className:a.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:[r.jsxs("div",{role:"button","aria-label":`${v}-${k}`,className:a.cx(c.nodeCardClass,{configuring:p}),onClick:H,children:[r.jsxs("div",{className:a.cx(c.nodeMetaClass,"workflow-node-meta"),children:[r.jsx(y.Tag,{children:v}),r.jsx("span",{className:"workflow-node-id",children:t.id})]}),r.jsx(y.Input.TextArea,{disabled:i.executed,value:k,onChange:S=>h(S.target.value),onBlur:S=>z(S.target.value),autoSize:!0}),r.jsx(Vt,{}),r.jsx(jt,{}),r.jsx(a.ActionContextProvider,{value:{visible:p,setVisible:B,formValueChanged:F,setFormValueChanged:M},children:r.jsx(a.FormProvider,{form:O,children:r.jsx(a.SchemaComponent,{scope:A(w({},d.scope),{useFormProviderProps:Yo}),components:d.components,schema:{type:"void",properties:A(w({},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:a.css`
399
+ `}));function De(e){var n;const{styles:t}=Ho();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:s,color:i}=e.statusMap[e.status];o=r.jsx(y.Tag,{color:i,children:s})}return r.jsx(y.Button,A(w({},e),{shape:"circle",size:"small",className:Jo(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const ae={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},He=[{value:ae.QUEUEING,label:`{{t("Queueing", { ns: "${p}" })}}`,color:"blue",icon:r.jsx(T.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${p}" })}}`},{value:ae.STARTED,label:`{{t("On going", { ns: "${p}" })}}`,color:"gold",icon:r.jsx(T.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${p}" })}}`},{value:ae.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:r.jsx(T.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${p}" })}}`},{value:ae.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:r.jsx(T.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${p}" })}}`},{value:ae.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:r.jsx(T.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${p}" })}}`},{value:ae.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:r.jsx(T.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${p}" })}}`},{value:ae.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(T.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${p}" })}}`},{value:ae.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(T.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${p}" })}}`},{value:ae.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(T.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${p}" })}}`}],Ue=He.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),re={PENDING:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},mt=[{value:re.PENDING,label:`{{t("Pending", { ns: "${p}" })}}`,color:"gold",icon:r.jsx(T.ClockCircleOutlined,{})},{value:re.RESOLVED,label:`{{t("Resolved", { ns: "${p}" })}}`,color:"green",icon:r.jsx(T.CheckOutlined,{})},{value:re.FAILED,label:`{{t("Failed", { ns: "${p}" })}}`,color:"red",icon:r.jsx(T.ExclamationOutlined,{})},{value:re.ERROR,label:`{{t("Error", { ns: "${p}" })}}`,color:"red",icon:r.jsx(T.CloseOutlined,{})},{value:re.ABORTED,label:`{{t("Aborted", { ns: "${p}" })}}`,color:"red",icon:r.jsx(T.MinusOutlined,{rotate:90})},{value:re.CANCELED,label:`{{t("Canceled", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(T.MinusOutlined,{rotate:45})},{value:re.REJECTED,label:`{{t("Rejected", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(T.MinusOutlined,{})},{value:re.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${p}" })}}`,color:"volcano",icon:r.jsx(T.RedoOutlined,{})}],Ye=mt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});class fe{constructor(){x(this,"title");x(this,"type");x(this,"group");x(this,"description");x(this,"options");x(this,"fieldset");x(this,"view");x(this,"scope");x(this,"components");x(this,"end")}}function Uo(){const e=P.useForm(),t=a.useAPIClient(),o=a.useActionContext(),{refresh:n}=a.useResourceActionContext(),s=Ce(),{workflow:i}=Z();return{run(){return K(this,null,function*(){var c,u;if(i.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 Mt(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}=te(),{getAriaLabel:o}=pt(e),n=a.usePlugin(ce),{Component:s=ht,end:i}=n.instructions.get(e.type);return r.jsx(ft.Provider,{value:e,children:r.jsxs("div",{className:a.cx(t.nodeBlockClass),children:[r.jsx(s,{data:e}),!i||typeof i=="function"&&!i(e)?r.jsx(Dt,{"aria-label":o(),upstream:e}):r.jsx("div",{className:"end-sign",children:r.jsx(T.CloseOutlined,{})})]})})}function Vt(){var d;const{t:e}=Q.useTranslation(),t=a.useAPIClient(),{workflow:o,nodes:n,refresh:s}=(d=Z())!=null?d:{},i=Ce(),{modal:l}=y.App.useApp();if(!o)return null;const c=t.resource("flow_nodes");function u(){return K(this,null,function*(){function f(){return K(this,null,function*(){var m;yield(m=c.destroy)==null?void 0:m.call(c,{filterByTk:i.id}),s()})}const v=n.filter(m=>m===i?!1:ue.parse(m.config).parameters.filter(({key:M})=>M.startsWith(`$jobsMapByNodeKey.${i.key}.`)||M===`$jobsMapByNodeKey.${i.key}`).length);if(v.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:v.map(m=>`#${m.id}`).join(", ")})});return}const h=!n.find(m=>m.upstream===i&&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:h,onOk:f})})}return o.executed?null:r.jsx(y.Button,{type:"text",shape:"circle",icon:r.jsx(T.DeleteOutlined,{}),onClick:u,className:"workflow-node-remove-button"})}function jt(){var i;const{execution:e,setViewJob:t}=Z(),{jobs:o}=(i=Ce())!=null?i:{},{styles:n}=te();if(!e)return null;if(!o.length)return r.jsx(De,{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(De,{statusMap:Ye,status:l.status}),r.jsx("time",{children:ue.str2moment(l.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),onClick:s,className:n.dropdownClass},children:r.jsx(De,{statusMap:Ye,status:o[o.length-1].status,className:n.nodeJobButtonClass})}):r.jsx(De,{statusMap:Ye,status:o[0].status,onClick:()=>t(o[0]),className:n.nodeJobButtonClass})}function Yo(){return{form:P.useForm()}}function ht(e){var $,N;const{data:t,children:o}=e,n=a.useCompile(),s=a.useAPIClient(),{workflow:i,refresh:l}=($=Z())!=null?$:{},{styles:c}=te(),d=a.usePlugin(ce).instructions.get(t.type),f=i.executed?'{{t("View")}}':'{{t("Configure")}}',v=n(d.title),[k,h]=b.useState((N=t.title)!=null?N:v),[m,C]=b.useState(!1),[F,M]=b.useState(!1),O=b.useMemo(()=>{const S=we.cloneDeep(t.config);return ge.createForm({initialValues:S,disabled:i.executed})},[t,i]),B=b.useCallback(S=>{C(S),S||O.reset()},[O]),z=b.useCallback(function(S){return K(this,null,function*(){var W,J;const I=S||v;h(I),I!==t.title&&(yield(J=(W=s.resource("flow_nodes")).update)==null?void 0:J.call(W,{filterByTk:t.id,values:{title:I}}),l())})},[t]),H=b.useCallback(function(S){if(S.target===S.currentTarget){C(!0);return}const I=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let W=S.target;W&&W!==S.currentTarget&&W!==document.documentElement;W=W.parentNode)if(Array.from(W.classList).some(J=>I.has(J))){C(!0),S.stopPropagation();return}},[]);return r.jsxs("div",{className:a.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:[r.jsxs("div",{role:"button","aria-label":`${v}-${k}`,className:a.cx(c.nodeCardClass,{configuring:m}),onClick:H,children:[r.jsxs("div",{className:a.cx(c.nodeMetaClass,"workflow-node-meta"),children:[r.jsx(y.Tag,{children:v}),r.jsx("span",{className:"workflow-node-id",children:t.id})]}),r.jsx(y.Input.TextArea,{disabled:i.executed,value:k,onChange:S=>h(S.target.value),onBlur:S=>z(S.target.value),autoSize:!0}),r.jsx(Vt,{}),r.jsx(jt,{}),r.jsx(a.ActionContextProvider,{value:{visible:m,setVisible:B,formValueChanged:F,setFormValueChanged:M},children:r.jsx(a.FormProvider,{form:O,children:r.jsx(a.SchemaComponent,{scope:A(w({},d.scope),{useFormProviderProps:Yo}),components:d.components,schema:{type:"void",properties:A(w({},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:a.css`
401
400
  display: flex;
402
401
  justify-content: space-between;
403
402
 
@@ -412,7 +411,7 @@
412
411
  code {
413
412
  font-weight: normal;
414
413
  }
415
- `,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-decorator-props":{useProps:"{{ useFormProviderProps }}"},"x-component":"Action.Drawer",properties:A(w({},d.description?{description:{type:"void","x-component":Nt,"x-component-props":{label:E("Node type"),title:d.title,description:d.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:a.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-decorator-props":{useProps:"{{ useFormProviderProps }}"},"x-component":"Action.Drawer",properties:A(w({},d.description?{description:{type:"void","x-component":Nt,"x-component-props":{label:D("Node type"),title:d.title,description:d.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:a.css`
416
415
  .ant-input,
417
416
  .ant-select,
418
417
  .ant-cascader-picker,
@@ -424,15 +423,15 @@
424
423
  min-width: 6em;
425
424
  }
426
425
  }
427
- `},properties:d.fieldset},actions:i.executed?null:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:Uo}}}}})}})}})})})]}),o]})}function Ge({from:e=null,entry:t=null,branchIndex:o=null,controller:n=null,className:s,end:i}){const{styles:l}=te(),{getAriaLabel:c}=pt(e,o),u=[];for(let d=t;d;d=d.downstream)u.push(d);return r.jsxs("div",{className:a.cx("workflow-branch",l.branchClass,s),children:[r.jsx("div",{className:"workflow-branch-lines"}),n,r.jsx(Et,{"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))}),i?r.jsx("div",{className:"end-sign",children:r.jsx(T.CloseOutlined,{})}):null]})}function Go(){var i;const e=P.useForm(),t=a.useAPIClient(),{workflow:o}=(i=Z())!=null?i:{},n=a.useActionContext(),{refresh:s}=a.useResourceActionContext();return{run(){return K(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(){x(this,"sync");x(this,"title");x(this,"description");x(this,"fieldset");x(this,"view");x(this,"scope");x(this,"components");x(this,"initializers");x(this,"useActionTriggerable")}}function qo(){const e=a.useCompile(),{workflow:t,execution:o}=Z(),{styles:n}=te(),s=gt();return o?r.jsx(a.SchemaComponent,{schema:{type:"void",name:"execution","x-component":"Action","x-component-props":{title:r.jsx(T.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:a.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: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},context:{type:"object",title:`{{t("Trigger variables", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:a.css`
426
+ `},properties:d.fieldset},actions:i.executed?null:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:Uo}}}}})}})}})})})]}),o]})}function Ge({from:e=null,entry:t=null,branchIndex:o=null,controller:n=null,className:s,end:i}){const{styles:l}=te(),{getAriaLabel:c}=pt(e,o),u=[];for(let d=t;d;d=d.downstream)u.push(d);return r.jsxs("div",{className:a.cx("workflow-branch",l.branchClass,s),children:[r.jsx("div",{className:"workflow-branch-lines"}),n,r.jsx(Dt,{"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))}),i?r.jsx("div",{className:"end-sign",children:r.jsx(T.CloseOutlined,{})}):null]})}function Go(){var i;const e=P.useForm(),t=a.useAPIClient(),{workflow:o}=(i=Z())!=null?i:{},n=a.useActionContext(),{refresh:s}=a.useResourceActionContext();return{run(){return K(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(){x(this,"sync");x(this,"title");x(this,"description");x(this,"fieldset");x(this,"view");x(this,"scope");x(this,"components");x(this,"initializers");x(this,"useActionTriggerable")}}function qo(){const e=a.useCompile(),{workflow:t,execution:o}=Z(),{styles:n}=te(),s=gt();return o?r.jsx(a.SchemaComponent,{schema:{type:"void",name:"execution","x-component":"Action","x-component-props":{title:r.jsx(T.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:a.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:a.css`
428
427
  padding: 1em;
429
428
  background-color: #eee;
430
- `},"x-read-pretty":!0}}}}}}):null}function _o(){return{form:P.useForm()}}const Ko=()=>{const e=a.useAPIClient(),{workflow:t,refresh:o}=Z(),[n,s]=b.useState(""),[i,l]=b.useState(!1),[c,u]=b.useState(!1),{styles:d}=te(),f=a.useCompile(),v=gt(),k=f(v.title),{fieldset:h,scope:p,components:C}=v,F=t.executed?'{{t("View")}}':'{{t("Configure")}}',M=E("Trigger");b.useEffect(()=>{var $,N;t&&s((N=($=t.triggerTitle)!=null?$:t.title)!=null?N:k)},[t]);const O=b.useMemo(()=>{const $=we.cloneDeep(t.config);return ge.createForm({initialValues:$,disabled:t.executed})},[t]),B=b.useCallback($=>{l($),$||O.reset()},[O]),z=b.useCallback(function($){return K(this,null,function*(){const N=$||k;s(N),N!==t.triggerTitle&&(yield e.resource("workflows").update({filterByTk:t.id,values:{triggerTitle:N}}),o())})},[t]),H=b.useCallback(function($){var S;if($.target===$.currentTarget){l(!0);return}const N=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let I=$.target;I&&I!==$.currentTarget;I=I.parentNode)if(Array.from((S=I.classList)!=null?S:[]).some(W=>N.has(W))){l(!0),$.stopPropagation();return}},[]);return r.jsxs("div",{role:"button","aria-label":`${M}-${n}`,className:a.cx(d.nodeCardClass),onClick:H,children:[r.jsx("div",{className:a.cx(d.nodeMetaClass,"workflow-node-meta"),children:r.jsx(y.Tag,{color:"gold",children:M})}),r.jsx("div",{children:r.jsx(y.Input.TextArea,{value:n,onChange:$=>s($.target.value),onBlur:$=>z($.target.value),autoSize:!0})}),r.jsx(qo,{}),r.jsx(a.ActionContextProvider,{value:{visible:i,setVisible:B,formValueChanged:c,setFormValueChanged:u},children:r.jsx(a.FormProvider,{form:O,children:r.jsx(a.SchemaComponent,{scope:A(w({},p),{useFormProviderProps:_o}),components:C,schema:{name:`workflow-trigger-${t.id}`,type:"void",properties:{config:{type:"void","x-content":F,"x-component":y.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},drawer:{type:"void",title:M,"x-component":"Action.Drawer","x-decorator":"FormV2","x-decorator-props":{useProps:"{{ useFormProviderProps }}"},properties:A(w({},v.description?{description:{type:"void","x-component":Nt,"x-component-props":{label:E("Trigger type"),title:v.title,description:v.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:a.css`
429
+ `},"x-read-pretty":!0}}}}}}):null}function _o(){return{form:P.useForm()}}const Ko=()=>{const e=a.useAPIClient(),{workflow:t,refresh:o}=Z(),[n,s]=b.useState(""),[i,l]=b.useState(!1),[c,u]=b.useState(!1),{styles:d}=te(),f=a.useCompile(),v=gt(),k=f(v.title),{fieldset:h,scope:m,components:C}=v,F=t.executed?'{{t("View")}}':'{{t("Configure")}}',M=D("Trigger");b.useEffect(()=>{var $,N;t&&s((N=($=t.triggerTitle)!=null?$:t.title)!=null?N:k)},[t]);const O=b.useMemo(()=>{const $=we.cloneDeep(t.config);return ge.createForm({initialValues:$,disabled:t.executed})},[t]),B=b.useCallback($=>{l($),$||O.reset()},[O]),z=b.useCallback(function($){return K(this,null,function*(){const N=$||k;s(N),N!==t.triggerTitle&&(yield e.resource("workflows").update({filterByTk:t.id,values:{triggerTitle:N}}),o())})},[t]),H=b.useCallback(function($){var S;if($.target===$.currentTarget){l(!0);return}const N=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let I=$.target;I&&I!==$.currentTarget;I=I.parentNode)if(Array.from((S=I.classList)!=null?S:[]).some(W=>N.has(W))){l(!0),$.stopPropagation();return}},[]);return r.jsxs("div",{role:"button","aria-label":`${M}-${n}`,className:a.cx(d.nodeCardClass),onClick:H,children:[r.jsx("div",{className:a.cx(d.nodeMetaClass,"workflow-node-meta"),children:r.jsx(y.Tag,{color:"gold",children:M})}),r.jsx("div",{children:r.jsx(y.Input.TextArea,{value:n,onChange:$=>s($.target.value),onBlur:$=>z($.target.value),autoSize:!0})}),r.jsx(qo,{}),r.jsx(a.ActionContextProvider,{value:{visible:i,setVisible:B,formValueChanged:c,setFormValueChanged:u},children:r.jsx(a.FormProvider,{form:O,children:r.jsx(a.SchemaComponent,{scope:A(w({},m),{useFormProviderProps:_o}),components:C,schema:{name:`workflow-trigger-${t.id}`,type:"void",properties:{config:{type:"void","x-content":F,"x-component":y.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},drawer:{type:"void",title:M,"x-component":"Action.Drawer","x-decorator":"FormV2","x-decorator-props":{useProps:"{{ useFormProviderProps }}"},properties:A(w({},v.description?{description:{type:"void","x-component":Nt,"x-component-props":{label:D("Trigger type"),title:v.title,description:v.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:a.css`
431
430
  .ant-select.auto-width {
432
431
  width: auto;
433
432
  min-width: 6em;
434
433
  }
435
- `},properties:h},actions:w({},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:Go}}}})})}}}})})})]})};function gt(){const e=a.usePlugin(ce),{workflow:t}=Z();return e.triggers.get(t.type)}const ke={label:"label",value:"value",children:"children"},Lt={label:`{{t("Node result", { ns: "${m}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=a.usePlugin(ce),o=Ce(),n=Mt(o),s=[];return n.forEach(i=>{var u;const l=t.get(i.type),c=(u=l.useVariables)==null?void 0:u.call(l,i,e);c&&s.push(c)}),s}},Wt={label:`{{t("Trigger variables", { ns: "${m}" })}}`,value:"$context",useOptions(e){var s,i;const{triggers:t}=a.usePlugin(ce),{workflow:o}=Z(),n=t.get(o.type);return(i=(s=n==null?void 0:n.useVariables)==null?void 0:s.call(n,o.config,e))!=null?i:null}},zt={label:`{{t("Scope variables", { ns: "${m}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=ke,current:o}=e,{instructions:n}=a.usePlugin(ce),s=Ce(),i=o!=null?o:s,l=Pt(i),c=[];return l.forEach(u=>{var v,k;const d=n.get(u.type),f=(v=d.useScopeVariables)==null?void 0:v.call(d,u,e);f&&c.push({key:u.key,[t.value]:u.key,[t.label]:(k=u.title)!=null?k:`#${u.id}`,[t.children]:f})}),c}},Jt={label:`{{t("System variables", { ns: "${m}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=ke}){return[...!e||e.includes("date")?[{key:"now",[t.label]:E("System time"),[t.value]:"now"}]:[]]}},qe={boolean:new Set(["checkbox"]),number:new Set(["integer","number","percent"]),string:new Set(["input","password","email","phone","select","radioGroup","text","markdown","richText","expression","time"]),date:new Set(["date","createdAt","updatedAt"])};function Ht(e,t){var o,n,s,i,l,c;return typeof t=="string"?(o=qe[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?bt(e)?((n=t.options)==null?void 0:n.entity)&&(e.collectionName===((s=t.options)==null?void 0:s.collection)||((i=t.options)==null?void 0:i.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 bt(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function xt(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function vt({fields:e,types:t,appends:o,depth:n=1,compile:s,getCollectionFields:i}){return e.filter(l=>{const c=t!=null&&t.length?t.some(u=>Ht(l,u)):!0;if(bt(l)){if(o===null)return n?c||vt({fields:wt(l.target,{compile:s,getCollectionFields:i}),types:t,depth:n-1,appends:o,compile:s,getCollectionFields:i}):!1;const u=xt(l,o),d=o.includes(l.name);return c?d:((u==null?void 0:u.length)||d)&&vt({fields:wt(l.target,{compile:s,getCollectionFields:i}),types:t,appends:u,compile:s,getCollectionFields:i}).length}else return c})}function _e(e,t){var i,l;const o=a.useCompile(),n=(l=(i=e.useOptions)==null?void 0:i.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 he(e={}){var s;const t=Object.assign({},ke,(s=e.fieldNames)!=null?s:{}),o=Object.assign(e,{fieldNames:t});return[_e(zt,o),_e(Lt,o),_e(Wt,o),_e(Jt,o)]}function wt(e,{compile:t,getCollectionFields:o}){var l,c,u,d,f,v,k;const n=o(e),s=[],i=[];n.forEach(h=>{h.isForeignKey?s.push(h):i.push(h)});for(let h=i.length-1;h>=0;h--){const p=i[h];if(p.type==="belongsTo"){const C=s.find(F=>F.name===p.foreignKey);C?i.splice(h,0,A(w(w({},p),C),{uiSchema:A(w({},p.uiSchema),{title:(l=p.uiSchema)!=null&&l.title?`${t((c=p.uiSchema)==null?void 0:c.title)} ID`:C.name})})):i.splice(h,0,A(w({},p),{name:p.foreignKey,type:"bigInt",isForeignKey:!0,interface:p.interface,uiSchema:A(w({},p.uiSchema),{title:(u=p.uiSchema)!=null&&u.title?`${t((d=p.uiSchema)==null?void 0:d.title)} ID`:p.name})}))}else if(p.type==="context"&&p.collectionName==="users"){const C=(f=i.find(F=>F.type==="belongsTo"&&F.target==="users"&&F.foreignKey===p.name))!=null?f:{};i.splice(h,0,A(w({},p),{type:p.dataType,interface:C.interface,uiSchema:A(w({},C.uiSchema),{title:(v=C.uiSchema)!=null&&v.title?`${t((k=C.uiSchema)==null?void 0:k.title)} ID`:p.name})}))}}return i.filter(h=>h.interface&&!h.hidden)}function Zo(e){const t=xt(e.field,e.appends),o=Se(w({collection: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=>Ht(e.field,s))||(e.disabled=!0))}function Se(e){const{fields:t,collection:o,types:n,appends:s=[],depth:i=1,compile:l,getCollectionFields:c,fieldNames:u=ke}=e,d=wt(o,{compile:l,getCollectionFields:c}),f=t!=null?t:d,v=Zo.bind({compile:l,getCollectionFields:c,fieldNames:u});return vt({fields:f,types:n,depth:i,appends:s,compile:l,getCollectionFields:c}).map(h=>{var M;const p=l(((M=h.uiSchema)==null?void 0:M.title)||h.name),C=xt(h,s),F=!bt(h)||C&&!C.length&&!s.includes(h.name)||!1;return{[u.label]:p,key:h.name,[u.value]:h.name,isLeaf:F,loadChildren:F?null:v,field:h,depth:i,appends:s,types:n}})}function Ut(o){var n=o,{variableOptions:e}=n,t=_(n,["variableOptions"]);const s=he(e);return r.jsx(a.Variable.Input,w({scope:s},t))}function Ct(o){var n=o,{variableOptions:e}=n,t=_(n,["variableOptions"]);const s=he(e);return r.jsx(a.Variable.TextArea,w({scope:s},t))}function Qo(o){var n=o,{variableOptions:e}=n,t=_(n,["variableOptions"]);const s=he(e);return r.jsx(a.Variable.RawTextArea,w({scope:s},t))}function Xo(o){var n=o,{variableOptions:e}=n,t=_(n,["variableOptions"]);const s=he(e);return r.jsx(a.Variable.JSON,w({scope:s},t))}function kt(e){const t=new Map;e.forEach(o=>t.set(o.id,o));for(const o of t.values())o.upstreamId&&(o.upstream=t.get(o.upstreamId)),o.downstreamId&&(o.downstream=t.get(o.downstreamId))}function Ke(e){const t=e.$and||e.$or;return t?t.some(o=>{if(o.$and||o.$or)return Ke(o);const[n]=Object.keys(o);if(!n||!o[n])return!1;const[s]=Object.keys(o[n]);return!(!s||typeof o[n][s]=="undefined")}):!1}function St(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{St(e.properties[o],t)})}function Ro(n){var s=n,{collection:e,dataSource:t}=s,o=_(s,["collection","dataSource"]);const{insert:i}=a.useSchemaInitializer(),{getTemplateSchemaByMode:l}=a.useSchemaTemplateManager(),{getCollection:c}=a.useCollectionManager(),u=a.useRecordCollectionDataSourceItems("FormItem"),d=c(e);function f(k){return K(this,arguments,function*({item:v}){const h=v.template?yield l(v):null,p={type:"void",name:d.name,title:d.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:e,dataSource:t},"x-component":"CardItem","x-component-props":{title:o.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-component-props":{useProps:"{{useDetailsBlockProps}}"},"x-read-pretty":!0,properties:{grid:h||{type:"void","x-component":"Grid","x-initializer":"ReadPrettyFormItemInitializers",properties:{}}}}}};St(p,C=>{C["x-uid"]&&delete C["x-uid"]}),i(p)})}return r.jsx(a.SchemaInitializerItem,A(w({},o),{onClick:f,items:u}))}function Ne(){const e=a.useSchemaInitializerItem();return r.jsx(a.CollectionProvider,{collection:e.collection,children:r.jsx(Ro,w({},e))})}function en(){return!0}const Ot=P.observer(e=>{const c=e,{filter:t=en}=c,o=_(c,["filter"]),n=a.useCompile(),{getCollectionFields:s}=a.useCollectionManager(),{values:i}=P.useForm(),l=s(i==null?void 0:i.collection);return r.jsx(y.Select,A(w({popupMatchSelectWidth:!1},o),{options:l.filter(t).map(u=>{var d;return{label:n((d=u.uiSchema)==null?void 0:d.title),value:u.name}})}))},{displayName:"FieldsSelect"});function Ze({value:e,onChange:t,renderSchemaComponent:o}){const n=he();return r.jsx(a.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}function Ie(e){const i=e,{options:t=[],direction:o}=i,n=_(i,["options","direction"]),s=a.useCompile();return r.jsx(y.Radio.Group,A(w({},n),{children:r.jsx(y.Space,{direction:o,children:t.map(l=>r.jsxs(y.Radio,{value:l.value,children:[r.jsx("span",{className:a.css`
434
+ `},properties:h},actions:w({},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:Go}}}})})}}}})})})]})};function gt(){const e=a.usePlugin(ce),{workflow:t}=Z();return e.triggers.get(t.type)}const ke={label:"label",value:"value",children:"children"},Lt={label:`{{t("Node result", { ns: "${p}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=a.usePlugin(ce),o=Ce(),n=Mt(o),s=[];return n.forEach(i=>{var u;const l=t.get(i.type),c=(u=l.useVariables)==null?void 0:u.call(l,i,e);c&&s.push(c)}),s}},Wt={label:`{{t("Trigger variables", { ns: "${p}" })}}`,value:"$context",useOptions(e){var s,i;const{triggers:t}=a.usePlugin(ce),{workflow:o}=Z(),n=t.get(o.type);return(i=(s=n==null?void 0:n.useVariables)==null?void 0:s.call(n,o.config,e))!=null?i:null}},zt={label:`{{t("Scope variables", { ns: "${p}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=ke,current:o}=e,{instructions:n}=a.usePlugin(ce),s=Ce(),i=o!=null?o:s,l=Pt(i),c=[];return l.forEach(u=>{var v,k;const d=n.get(u.type),f=(v=d.useScopeVariables)==null?void 0:v.call(d,u,e);f&&c.push({key:u.key,[t.value]:u.key,[t.label]:(k=u.title)!=null?k:`#${u.id}`,[t.children]:f})}),c}},Jt={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"}]:[]]}},qe={boolean:new Set(["checkbox"]),number:new Set(["integer","number","percent"]),string:new Set(["input","password","email","phone","select","radioGroup","text","markdown","richText","expression","time"]),date:new Set(["date","createdAt","updatedAt"])};function Ht(e,t){var o,n,s,i,l,c;return typeof t=="string"?(o=qe[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?bt(e)?((n=t.options)==null?void 0:n.entity)&&(e.collectionName===((s=t.options)==null?void 0:s.collection)||((i=t.options)==null?void 0:i.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 bt(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function xt(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function vt({fields:e,types:t,appends:o,depth:n=1,compile:s,getCollectionFields:i}){return e.filter(l=>{const c=t!=null&&t.length?t.some(u=>Ht(l,u)):!0;if(bt(l)){if(o===null)return n?c||vt({fields:wt(l.target,{compile:s,getCollectionFields:i}),types:t,depth:n-1,appends:o,compile:s,getCollectionFields:i}):!1;const u=xt(l,o),d=o.includes(l.name);return c?d:((u==null?void 0:u.length)||d)&&vt({fields:wt(l.target,{compile:s,getCollectionFields:i}),types:t,appends:u,compile:s,getCollectionFields:i}).length}else return c})}function _e(e,t){var i,l;const o=a.useCompile(),n=(l=(i=e.useOptions)==null?void 0:i.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 he(e={}){var s;const t=Object.assign({},ke,(s=e.fieldNames)!=null?s:{}),o=Object.assign(e,{fieldNames:t});return[_e(zt,o),_e(Lt,o),_e(Wt,o),_e(Jt,o)]}function wt(e,{compile:t,getCollectionFields:o}){var l,c,u,d,f,v,k;const n=o(e),s=[],i=[];n.forEach(h=>{h.isForeignKey?s.push(h):i.push(h)});for(let h=i.length-1;h>=0;h--){const m=i[h];if(m.type==="belongsTo"){const C=s.find(F=>F.name===m.foreignKey);C?i.splice(h,0,A(w(w({},m),C),{uiSchema:A(w({},m.uiSchema),{title:(l=m.uiSchema)!=null&&l.title?`${t((c=m.uiSchema)==null?void 0:c.title)} ID`:C.name})})):i.splice(h,0,A(w({},m),{name:m.foreignKey,type:"bigInt",isForeignKey:!0,interface:m.interface,uiSchema:A(w({},m.uiSchema),{title:(u=m.uiSchema)!=null&&u.title?`${t((d=m.uiSchema)==null?void 0:d.title)} ID`:m.name})}))}else if(m.type==="context"&&m.collectionName==="users"){const C=(f=i.find(F=>F.type==="belongsTo"&&F.target==="users"&&F.foreignKey===m.name))!=null?f:{};i.splice(h,0,A(w({},m),{type:m.dataType,interface:C.interface,uiSchema:A(w({},C.uiSchema),{title:(v=C.uiSchema)!=null&&v.title?`${t((k=C.uiSchema)==null?void 0:k.title)} ID`:m.name})}))}}return i.filter(h=>h.interface&&!h.hidden)}function Zo(e){const t=xt(e.field,e.appends),o=Se(w({collection: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=>Ht(e.field,s))||(e.disabled=!0))}function Se(e){const{fields:t,collection:o,types:n,appends:s=[],depth:i=1,compile:l,getCollectionFields:c,fieldNames:u=ke}=e,d=wt(o,{compile:l,getCollectionFields:c}),f=t!=null?t:d,v=Zo.bind({compile:l,getCollectionFields:c,fieldNames:u});return vt({fields:f,types:n,depth:i,appends:s,compile:l,getCollectionFields:c}).map(h=>{var M;const m=l(((M=h.uiSchema)==null?void 0:M.title)||h.name),C=xt(h,s),F=!bt(h)||C&&!C.length&&!s.includes(h.name)||!1;return{[u.label]:m,key:h.name,[u.value]:h.name,isLeaf:F,loadChildren:F?null:v,field:h,depth:i,appends:s,types:n}})}function Ut(o){var n=o,{variableOptions:e}=n,t=_(n,["variableOptions"]);const s=he(e);return r.jsx(a.Variable.Input,w({scope:s},t))}function Ct(o){var n=o,{variableOptions:e}=n,t=_(n,["variableOptions"]);const s=he(e);return r.jsx(a.Variable.TextArea,w({scope:s},t))}function Qo(o){var n=o,{variableOptions:e}=n,t=_(n,["variableOptions"]);const s=he(e);return r.jsx(a.Variable.RawTextArea,w({scope:s},t))}function Xo(o){var n=o,{variableOptions:e}=n,t=_(n,["variableOptions"]);const s=he(e);return r.jsx(a.Variable.JSON,w({scope:s},t))}function kt(e){const t=new Map;e.forEach(o=>t.set(o.id,o));for(const o of t.values())o.upstreamId&&(o.upstream=t.get(o.upstreamId)),o.downstreamId&&(o.downstream=t.get(o.downstreamId))}function Ke(e){const t=e.$and||e.$or;return t?t.some(o=>{if(o.$and||o.$or)return Ke(o);const[n]=Object.keys(o);if(!n||!o[n])return!1;const[s]=Object.keys(o[n]);return!(!s||typeof o[n][s]=="undefined")}):!1}function St(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{St(e.properties[o],t)})}function Ro(n){var s=n,{collection:e,dataSource:t}=s,o=_(s,["collection","dataSource"]);const{insert:i}=a.useSchemaInitializer(),{getTemplateSchemaByMode:l}=a.useSchemaTemplateManager(),{getCollection:c}=a.useCollectionManager(),u=a.useRecordCollectionDataSourceItems("FormItem"),d=c(e);function f(k){return K(this,arguments,function*({item:v}){const h=v.template?yield l(v):null,m={type:"void",name:d.name,title:d.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:e,dataSource:t},"x-component":"CardItem","x-component-props":{title:o.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-component-props":{useProps:"{{useDetailsBlockProps}}"},"x-read-pretty":!0,properties:{grid:h||{type:"void","x-component":"Grid","x-initializer":"ReadPrettyFormItemInitializers",properties:{}}}}}};St(m,C=>{C["x-uid"]&&delete C["x-uid"]}),i(m)})}return r.jsx(a.SchemaInitializerItem,A(w({},o),{onClick:f,items:u}))}function Ne(){const e=a.useSchemaInitializerItem();return r.jsx(a.CollectionProvider,{collection:e.collection,children:r.jsx(Ro,w({},e))})}function en(){return!0}const Ot=P.observer(e=>{const c=e,{filter:t=en}=c,o=_(c,["filter"]),n=a.useCompile(),{getCollectionFields:s}=a.useCollectionManager(),{values:i}=P.useForm(),l=s(i==null?void 0:i.collection);return r.jsx(y.Select,A(w({popupMatchSelectWidth:!1},o),{options:l.filter(t).map(u=>{var d;return{label:n((d=u.uiSchema)==null?void 0:d.title),value:u.name}})}))},{displayName:"FieldsSelect"});function Ze({value:e,onChange:t,renderSchemaComponent:o}){const n=he();return r.jsx(a.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}function Ie(e){const i=e,{options:t=[],direction:o}=i,n=_(i,["options","direction"]),s=a.useCompile();return r.jsx(y.Radio.Group,A(w({},n),{children:r.jsx(y.Space,{direction:o,children:t.map(l=>r.jsxs(y.Radio,{value:l.value,children:[r.jsx("span",{className:a.css`
436
435
  & + .anticon {
437
436
  margin-left: 0.25em;
438
437
  }
@@ -440,24 +439,24 @@
440
439
  margin: 0;
441
440
  `,children:JSON.stringify(n,null,2)})}Me.Initializer=tn,Me.Result=on;function Yt({entry:e}){const{styles:t}=te(),{workflow:o}=Z(),[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:a.cx(t.branchBlockClass,a.css`
442
441
  margin-top: 0 !important;
443
- `),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:a.css`
442
+ `),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"),showIcon:!0,className:a.css`
444
443
  margin-bottom: 1em;
445
444
  `}):null,r.jsx(Ko,{}),r.jsx("div",{className:a.cx(t.branchBlockClass,a.css`
446
445
  margin-top: 0 !important;
447
- `),children:r.jsx(Ge,{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})})]})}const Oe=e=>`/admin/workflow/workflows/${e}`,At=e=>`/admin/workflow/executions/${e}`;function nn(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const s=o.get(n.nodeId);s.jobs.push(n),n.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((s,i)=>s.id-i.id)})}function rn(){const{instructions:e}=a.usePlugin(ce),t=a.useCompile(),{viewJob:o,setViewJob:n}=Z(),{styles:s}=te(),{node:i={}}=o!=null?o:{},l=e.get(i.type);return r.jsx(a.ActionContextProvider,{value:{visible:!!o,setVisible:n},children:r.jsx(a.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:i.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",i.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:mt,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},result:{type:"object",title:`{{t("Node result", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:s.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function sn(e){const{execution:t}=Z(),o=a.useAPIClient(),n=le.useNavigate(),{styles:s}=te(),[i,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(At(f))},[t]);return t?r.jsx(y.Dropdown,{menu:{onClick:d,defaultSelectedKeys:[`${t.id}`],className:a.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...i].map(f=>({key:f.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${f.id}`}),r.jsx("time",{children:ue.str2moment(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(Ee,{statusMap:Ue,status:f.status})})}))},children:r.jsxs(y.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(T.DownOutlined,{})]})}):null}function ln(){var O;const{t:e}=Q.useTranslation(),t=a.useCompile(),{data:o,loading:n,refresh:s}=a.useResourceActionContext(),{setTitle:i}=a.useDocumentTitle(),[l,c]=b.useState(null),u=a.useApp(),d=a.useAPIClient();b.useEffect(()=>{var N;const{workflow:$}=(N=o==null?void 0:o.data)!=null?N:{};i==null||i(`${$!=null&&$.title?`${$.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(T.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($=>{console.error($.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 B=(O=o==null?void 0:o.data)!=null?O:{},{jobs:v=[],workflow:z={}}=B,H=z,{nodes:k=[],revisions:h=[]}=H,p=_(H,["nodes","revisions"]),C=_(B,["jobs","workflow"]);kt(k),nn(k,v);const F=k.find($=>!$.upstream),M=Ue[C.status];return r.jsxs(Je.Provider,{value:{workflow:p.type?p:null,nodes:k,execution:C,viewJob:l,setViewJob:c},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(y.Breadcrumb,{items:[{title:r.jsx(le.Link,{to:u.pluginSettingsManager.getRoutePath("workflow"),children:E("Workflow")})},{title:r.jsx(le.Link,{to:Oe(p.id),children:p.title})},{title:r.jsx(sn,{})}]})}),r.jsxs("aside",{children:[r.jsx(y.Tag,{color:M.color,children:t(M.label)}),C.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(T.StopOutlined,{})})}),r.jsx("time",{children:ue.str2moment(C.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(Yt,{entry:F}),r.jsx(rn,{})]})}const Gt=()=>{const e=le.useParams(),{styles:t}=te();return r.jsx("div",{className:a.cx(t.workflowPageClass),children:r.jsx(a.SchemaComponent,{schema:{type:"void",properties:{[`execution_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:e,appends:["jobs","workflow","workflow.nodes"]}}},"x-component":"ExecutionCanvas"}}},components:{ExecutionCanvas:ln}})})},qt=()=>{const{t:e}=Q.useTranslation(),{id:t}=a.useRecord(),{setVisible:o}=a.useActionContext();return r.jsx(le.Link,{to:At(t),onClick:()=>o(!1),children:e("View")})},an={name:"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: "${m}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${m}" })}}`,"x-component"({value:e}){const{setVisible:t}=a.useActionContext();return r.jsx(le.Link,{to:Oe(e),onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${m}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:He}}]},_t={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${m}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:an,resourceName:"executions",request:{resource:"executions",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"],filter:{}}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=Q.useTranslation(),{refresh:t,defaultRequest:o}=a.useResourceActionContext(),{resource:n}=a.useResourceContext(),{setVisible:s}=a.useActionContext();return{run(){return K(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: "${m}" })}}`,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: "${m}" })}}`}}}}},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: "${m}" })}}`,properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void","x-component":"ExecutionLink"}}}}}}}}}}};function Kt(e){var i;const o=a.useCompile()(e.label),n=b.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:s}=(i=Ue[e.value])!=null?i:{};return r.jsx(y.Tag,{color:s,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function cn(e){const t=a.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Kt,w({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function un(t){var e=_(t,[]);const o=e.multiple?"multiple":null;return r.jsx(y.Select,A(w({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Kt,children:He.filter(n=>!!n.value&&n.value!==ae.ABORTED).map(n=>r.jsx(y.Select.Option,A(w({},n),{children:r.jsx(cn,w({},n))}),n.value))}))}function Zt(e){const{t}=Q.useTranslation(),{refresh:o}=a.useResourceActionContext(),{resource:n}=a.useResourceContext(),s=a.useRecord(),i=b.useCallback(()=>{y.Modal.confirm({title:E("Cancel the execution"),icon:r.jsx(T.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:a.css`
446
+ `),children:r.jsx(Ge,{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})})]})}const Oe=e=>`/admin/workflow/workflows/${e}`,At=e=>`/admin/workflow/executions/${e}`;function nn(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const s=o.get(n.nodeId);s.jobs.push(n),n.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((s,i)=>s.id-i.id)})}function rn(){const{instructions:e}=a.usePlugin(ce),t=a.useCompile(),{viewJob:o,setViewJob:n}=Z(),{styles:s}=te(),{node:i={}}=o!=null?o:{},l=e.get(i.type);return r.jsx(a.ActionContextProvider,{value:{visible:!!o,setVisible:n},children:r.jsx(a.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:i.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",i.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum: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 sn(e){const{execution:t}=Z(),o=a.useAPIClient(),n=le.useNavigate(),{styles:s}=te(),[i,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(At(f))},[t]);return t?r.jsx(y.Dropdown,{menu:{onClick:d,defaultSelectedKeys:[`${t.id}`],className:a.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...i].map(f=>({key:f.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${f.id}`}),r.jsx("time",{children:ue.str2moment(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(De,{statusMap:Ue,status:f.status})})}))},children:r.jsxs(y.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(T.DownOutlined,{})]})}):null}function ln(){var O;const{t:e}=Q.useTranslation(),t=a.useCompile(),{data:o,loading:n,refresh:s}=a.useResourceActionContext(),{setTitle:i}=a.useDocumentTitle(),[l,c]=b.useState(null),u=a.useApp(),d=a.useAPIClient();b.useEffect(()=>{var N;const{workflow:$}=(N=o==null?void 0:o.data)!=null?N:{};i==null||i(`${$!=null&&$.title?`${$.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(T.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($=>{console.error($.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 B=(O=o==null?void 0:o.data)!=null?O:{},{jobs:v=[],workflow:z={}}=B,H=z,{nodes:k=[],revisions:h=[]}=H,m=_(H,["nodes","revisions"]),C=_(B,["jobs","workflow"]);kt(k),nn(k,v);const F=k.find($=>!$.upstream),M=Ue[C.status];return r.jsxs(Je.Provider,{value:{workflow:m.type?m:null,nodes:k,execution:C,viewJob:l,setViewJob:c},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(y.Breadcrumb,{items:[{title:r.jsx(le.Link,{to:u.pluginSettingsManager.getRoutePath("workflow"),children:D("Workflow")})},{title:r.jsx(le.Link,{to:Oe(m.id),children:m.title})},{title:r.jsx(sn,{})}]})}),r.jsxs("aside",{children:[r.jsx(y.Tag,{color:M.color,children:t(M.label)}),C.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(T.StopOutlined,{})})}),r.jsx("time",{children:ue.str2moment(C.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(Yt,{entry:F}),r.jsx(rn,{})]})}const Gt=()=>{const e=le.useParams(),{styles:t}=te();return r.jsx("div",{className:a.cx(t.workflowPageClass),children:r.jsx(a.SchemaComponent,{schema:{type:"void",properties:{[`execution_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:e,appends:["jobs","workflow","workflow.nodes"]}}},"x-component":"ExecutionCanvas"}}},components:{ExecutionCanvas:ln}})})},qt=()=>{const{t:e}=Q.useTranslation(),{id:t}=a.useRecord(),{setVisible:o}=a.useActionContext();return r.jsx(le.Link,{to:At(t),onClick:()=>o(!1),children:e("View")})},an={name:"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}=a.useActionContext();return r.jsx(le.Link,{to:Oe(e),onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${p}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:He}}]},_t={type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${p}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:an,resourceName:"executions",request:{resource:"executions",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"],filter:{}}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=Q.useTranslation(),{refresh:t,defaultRequest:o}=a.useResourceActionContext(),{resource:n}=a.useResourceContext(),{setVisible:s}=a.useActionContext();return{run(){return K(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 Kt(e){var i;const o=a.useCompile()(e.label),n=b.useCallback(l=>{l.preventDefault(),l.stopPropagation()},[]),{color:s}=(i=Ue[e.value])!=null?i:{};return r.jsx(y.Tag,{color:s,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function cn(e){const t=a.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Kt,w({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function un(t){var e=_(t,[]);const o=e.multiple?"multiple":null;return r.jsx(y.Select,A(w({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Kt,children:He.filter(n=>!!n.value&&n.value!==ae.ABORTED).map(n=>r.jsx(y.Select.Option,A(w({},n),{children:r.jsx(cn,w({},n))}),n.value))}))}function Zt(e){const{t}=Q.useTranslation(),{refresh:o}=a.useResourceActionContext(),{resource:n}=a.useResourceContext(),s=a.useRecord(),i=b.useCallback(()=>{y.Modal.confirm({title:D("Cancel the execution"),icon:r.jsx(T.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:a.css`
448
447
  display: flex;
449
- `,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:i,shape:"circle",size:"small",icon:r.jsx(T.StopOutlined,{})})})]})}function dn(n){var s=n,{request:e,filter:t={}}=s,o=_(s,["request","filter"]);var c;const{workflow:i}=Z(),l=A(w({},o),{request:A(w({},e),{params:A(w({},e==null?void 0:e.params),{filter:A(w({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:i.key})})})});return r.jsx(a.ResourceActionProvider,w({},l))}function pn(){var $;const e=le.useNavigate(),{t}=Q.useTranslation(),o=a.useApp(),{data:n,refresh:s,loading:i}=a.useResourceActionContext(),{resource:l}=a.useResourceContext(),{setTitle:c}=a.useDocumentTitle(),[u,d]=b.useState(!1),{styles:f}=te(),{modal:v}=y.App.useApp();if(b.useEffect(()=>{var I;const{title:S}=(I=n==null?void 0:n.data)!=null?I:{};c==null||c(`${E("Workflow")}${S?`: ${S}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return i?r.jsx(y.Spin,{}):r.jsx(y.Result,{status:"404",title:"Not found"});const N=($=n==null?void 0:n.data)!=null?$:{},{nodes:k=[],revisions:h=[]}=N,p=_(N,["nodes","revisions"]);kt(k);const C=k.find(S=>!S.upstream);function F({key:S}){S!=p.id&&e(Oe(S))}function M(S){return K(this,null,function*(){yield l.update({filterByTk:p.id,values:{enabled:S}}),s()})}function O(){return K(this,null,function*(){const{data:{data:S}}=yield l.revision({filterByTk:p.id,filter:{key:p.key}});y.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${S.id}`)})}function B(){return K(this,null,function*(){const S=p.current?E("Delete a main version will cause all other revisions to be deleted too."):"";v.confirm({title:t("Are you sure you want to delete it?"),content:S,onOk(){return K(this,null,function*(){var W;yield l.destroy({filterByTk:p.id}),y.message.success(t("Operation succeeded")),e(p.current?o.pluginSettingsManager.getRoutePath("workflow"):Oe((W=h.find(J=>J.current))==null?void 0:W.id))})}})})}function z(I){return K(this,arguments,function*({key:S}){switch(S){case"history":d(!0);return;case"revision":return O();case"delete":return B()}})}const H=p.executed&&!h.find(S=>!S.executed&&new Date(S.createdAt)>new Date(p.createdAt));return r.jsxs(Je.Provider,{value:{workflow:p,nodes:k,refresh:s},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(y.Breadcrumb,{items:[{title:r.jsx(le.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:E("Workflow")})},{title:r.jsx("strong",{children:p.title})}]})}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(y.Dropdown,{trigger:["click"],menu:{onClick:F,defaultSelectedKeys:[`${p.id}`],className:a.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:h.sort((S,I)=>I.id-S.id).map((S,I)=>({role:"button","aria-label":`version-${I}`,key:`${S.id}`,icon:S.current?r.jsx(T.RightOutlined,{}):null,className:a.cx({executed:S.executed,unexecuted:!S.executed,enabled:S.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${S.id}`}),r.jsx("time",{children:ue.str2moment(S.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:p!=null&&p.id?`#${p.id}`:null}),r.jsx(T.DownOutlined,{})]})})}),r.jsx(y.Switch,{checked:p.enabled,onChange:M,checkedChildren:E("On"),unCheckedChildren:E("Off")}),r.jsx(y.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:E("Execution history"),disabled:!p.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:E("Copy to new version"),disabled:!H},{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(T.EllipsisOutlined,{})})}),r.jsx(a.ActionContextProvider,{value:{visible:u,setVisible:d},children:r.jsx(a.SchemaComponent,{schema:_t,components:{ExecutionResourceProvider:dn,ExecutionLink:qt,ExecutionStatusColumn:Zt}})})]})]}),r.jsx(Yt,{entry:C})]})}const Qt=()=>{const e=le.useParams(),{styles:t}=te();return r.jsx("div",{className:a.cx(t.workflowPageClass),children:r.jsx(a.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:pn}})})},mn=n=>{var s=n,{request:e,filter:t={}}=s,o=_(s,["request","filter"]);var c;const i=a.useRecord(),l=A(w({},o),{request:A(w({},e),{params:A(w({},e==null?void 0:e.params),{filter:A(w({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:i.key})})})});return r.jsx(a.ResourceActionProvider,w({},l))},fn=()=>{const{t:e}=Q.useTranslation(),{id:t}=a.useRecord(),{setVisible:o}=a.useActionContext(),{getAriaLabel:n}=a.useGetAriaLabelOfAction("Configure");return r.jsx(le.Link,{"aria-label":n(),to:Oe(t),onClick:()=>o(!1),children:e("Configure")})};function hn(n){var s=n,{component:e="div",children:t}=s,o=_(s,["component","children"]);const[i,l]=b.useState(!1),c=P.useFieldSchema();return r.jsxs(a.ActionContextProvider,{value:{visible:i,setVisible:l,fieldSchema:c},children:[b.createElement(e,A(w({},o),{onClick(){l(!0)}}),t),r.jsx(a.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}const Xt={name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Trigger type", { ns: "${m}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}"},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: "${m}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${m}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${m}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${m}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},de={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${m}" }) }}`,description:`{{ t("Could not be changed after created.", { ns: "${m}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Asynchronously", { ns: "${m}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${m}" }) }}`},{label:`{{ t("Synchronously", { ns: "${m}" }) }}`,value:!0,tooltip:`{{ t("For user actions that require immediate feedback. Can not use asynchronous nodes in such mode.", { ns: "${m}" }) }}`}]}},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: "${m}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},yn={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Xt,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider","x-component-props":{collection:Xt},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined",useProps:"{{ cm.useFilterActionProps }}"},"x-align":"left"},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{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"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:de.title,type:de.type,sync:de.sync,description:de.description,options:de.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=a.useRecord();return b.createElement("a",w({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:_t}}}},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:de.title,enabled:de.enabled,sync:de.sync,description:de.description,options:de.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: "${m}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${m}" })}}`,"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}=a.useResourceActionContext(),{resource:o,targetKey:n}=a.useResourceContext(),{setVisible:s}=a.useActionContext(),{[n]:i}=a.useRecord(),{values:l}=P.useForm();return{run(){return K(this,null,function*(){yield o.revision({filterByTk:i,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 gn(e){const t=P.useField(),o=a.useRecord(),n=a.usePlugin(ce);return P.useFormEffects(s=>{ge.onFieldChange("type",i=>{let l=o.id||!i.value;if(i.value){const c=n.triggers.get(i.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(Ie,w({},e))}function bn(){const e=b.useContext(a.SchemaComponentContext),{getTriggersOptions:t}=a.usePlugin(ce);return r.jsx(y.Card,{bordered:!1,children:r.jsx(a.SchemaComponentContext.Provider,{value:A(w({},e),{designable:!1}),children:r.jsx(a.SchemaComponent,{schema:yn,components:{WorkflowLink:fn,ExecutionResourceProvider:mn,ExecutionLink:qt,OpenDrawer:hn,ExecutionStatusSelect:un,SyncOptionSelect:gn,ExecutionStatusColumn:Zt},scope:{getTriggersOptions:t}})})})}const be={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"CollectionSelect","x-component-props":{className:"auto-width"}},Rt={type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:a.css`
448
+ `,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:i,shape:"circle",size:"small",icon:r.jsx(T.StopOutlined,{})})})]})}function dn(n){var s=n,{request:e,filter:t={}}=s,o=_(s,["request","filter"]);var c;const{workflow:i}=Z(),l=A(w({},o),{request:A(w({},e),{params:A(w({},e==null?void 0:e.params),{filter:A(w({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:i.key})})})});return r.jsx(a.ResourceActionProvider,w({},l))}function pn(){var $;const e=le.useNavigate(),{t}=Q.useTranslation(),o=a.useApp(),{data:n,refresh:s,loading:i}=a.useResourceActionContext(),{resource:l}=a.useResourceContext(),{setTitle:c}=a.useDocumentTitle(),[u,d]=b.useState(!1),{styles:f}=te(),{modal:v}=y.App.useApp();if(b.useEffect(()=>{var I;const{title:S}=(I=n==null?void 0:n.data)!=null?I:{};c==null||c(`${D("Workflow")}${S?`: ${S}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return i?r.jsx(y.Spin,{}):r.jsx(y.Result,{status:"404",title:"Not found"});const N=($=n==null?void 0:n.data)!=null?$:{},{nodes:k=[],revisions:h=[]}=N,m=_(N,["nodes","revisions"]);kt(k);const C=k.find(S=>!S.upstream);function F({key:S}){S!=m.id&&e(Oe(S))}function M(S){return K(this,null,function*(){yield l.update({filterByTk:m.id,values:{enabled:S}}),s()})}function O(){return K(this,null,function*(){const{data:{data:S}}=yield l.revision({filterByTk:m.id,filter:{key:m.key}});y.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${S.id}`)})}function B(){return K(this,null,function*(){const S=m.current?D("Delete a main version will cause all other revisions to be deleted too."):"";v.confirm({title:t("Are you sure you want to delete it?"),content:S,onOk(){return K(this,null,function*(){var W;yield l.destroy({filterByTk:m.id}),y.message.success(t("Operation succeeded")),e(m.current?o.pluginSettingsManager.getRoutePath("workflow"):Oe((W=h.find(J=>J.current))==null?void 0:W.id))})}})})}function z(I){return K(this,arguments,function*({key:S}){switch(S){case"history":d(!0);return;case"revision":return O();case"delete":return B()}})}const H=m.executed&&!h.find(S=>!S.executed&&new Date(S.createdAt)>new Date(m.createdAt));return r.jsxs(Je.Provider,{value:{workflow:m,nodes:k,refresh:s},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(y.Breadcrumb,{items:[{title:r.jsx(le.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:D("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:F,defaultSelectedKeys:[`${m.id}`],className:a.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:h.sort((S,I)=>I.id-S.id).map((S,I)=>({role:"button","aria-label":`version-${I}`,key:`${S.id}`,icon:S.current?r.jsx(T.RightOutlined,{}):null,className:a.cx({executed:S.executed,unexecuted:!S.executed,enabled:S.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${S.id}`}),r.jsx("time",{children:ue.str2moment(S.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(T.DownOutlined,{})]})})}),r.jsx(y.Switch,{checked:m.enabled,onChange:M,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:!H},{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(T.EllipsisOutlined,{})})}),r.jsx(a.ActionContextProvider,{value:{visible:u,setVisible:d},children:r.jsx(a.SchemaComponent,{schema:_t,components:{ExecutionResourceProvider:dn,ExecutionLink:qt,ExecutionStatusColumn:Zt}})})]})]}),r.jsx(Yt,{entry:C})]})}const Qt=()=>{const e=le.useParams(),{styles:t}=te();return r.jsx("div",{className:a.cx(t.workflowPageClass),children:r.jsx(a.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:pn}})})},mn=n=>{var s=n,{request:e,filter:t={}}=s,o=_(s,["request","filter"]);var c;const i=a.useRecord(),l=A(w({},o),{request:A(w({},e),{params:A(w({},e==null?void 0:e.params),{filter:A(w({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:i.key})})})});return r.jsx(a.ResourceActionProvider,w({},l))},fn=()=>{const{t:e}=Q.useTranslation(),{id:t}=a.useRecord(),{setVisible:o}=a.useActionContext(),{getAriaLabel:n}=a.useGetAriaLabelOfAction("Configure");return r.jsx(le.Link,{"aria-label":n(),to:Oe(t),onClick:()=>o(!1),children:e("Configure")})};function hn(n){var s=n,{component:e="div",children:t}=s,o=_(s,["component","children"]);const[i,l]=b.useState(!1),c=P.useFieldSchema();return r.jsxs(a.ActionContextProvider,{value:{visible:i,setVisible:l,fieldSchema:c},children:[b.createElement(e,A(w({},o),{onClick(){l(!0)}}),t),r.jsx(a.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}const Xt={name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Trigger type", { ns: "${p}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}"},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"}]},de={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}}}}},yn={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Xt,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider","x-component-props":{collection:Xt},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined",useProps:"{{ cm.useFilterActionProps }}"},"x-align":"left"},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{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"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:de.title,type:de.type,sync:de.sync,description:de.description,options:de.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=a.useRecord();return b.createElement("a",w({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:_t}}}},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:de.title,enabled:de.enabled,sync:de.sync,description:de.description,options:de.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}=a.useResourceActionContext(),{resource:o,targetKey:n}=a.useResourceContext(),{setVisible:s}=a.useActionContext(),{[n]:i}=a.useRecord(),{values:l}=P.useForm();return{run(){return K(this,null,function*(){yield o.revision({filterByTk:i,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 gn(e){const t=P.useField(),o=a.useRecord(),n=a.usePlugin(ce);return P.useFormEffects(s=>{ge.onFieldChange("type",i=>{let l=o.id||!i.value;if(i.value){const c=n.triggers.get(i.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(Ie,w({},e))}function bn(){const e=b.useContext(a.SchemaComponentContext),{getTriggersOptions:t}=a.usePlugin(ce);return r.jsx(y.Card,{bordered:!1,children:r.jsx(a.SchemaComponentContext.Provider,{value:A(w({},e),{designable:!1}),children:r.jsx(a.SchemaComponent,{schema:yn,components:{WorkflowLink:fn,ExecutionResourceProvider:mn,ExecutionLink:qt,OpenDrawer:hn,ExecutionStatusSelect:un,SyncOptionSelect:gn,ExecutionStatusColumn:Zt},scope:{getTriggersOptions:t}})})})}const be={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"CollectionSelect","x-component-props":{className:"auto-width"}},Rt={type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:a.css`
450
449
  flex-direction: column;
451
- `},"x-component":"CollectionFieldset",description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${m}" })}}`},Pe={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-component-props":{useProps(){const{values:e}=P.useForm();return{options:a.useCollectionFilterOptions(e==null?void 0:e.collection),className:a.css`
450
+ `},"x-component":"CollectionFieldset",description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${p}" })}}`},Pe={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-component-props":{useProps(){const{values:e}=P.useForm();return{options:a.useCollectionFilterOptions(e==null?void 0:e.collection),className:a.css`
452
451
  position: relative;
453
452
  width: 100%;
454
- `}},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}}}}}}},Be={type:"array",title:`{{t("Preload associations", { ns: "${m}" })}}`,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: "${m}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=P.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},Ae={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},wn=[{label:`{{t("After record added", { ns: "${m}" })}}`,value:Ae.CREATED},{label:`{{t("After record updated", { ns: "${m}" })}}`,value:Ae.UPDATED},{label:`{{t("After record added or updated", { ns: "${m}" })}}`,value:Ae.SAVED},{label:`{{t("After record deleted", { ns: "${m}" })}}`,value:Ae.DELETED}];class Cn extends yt{constructor(){super(...arguments);x(this,"title",`{{t("Collection event", { ns: "${m}" })}}`);x(this,"description",`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${m}" })}}`);x(this,"fieldset",{collection:A(w({},be),{"x-reactions":[...be["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: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${m}" })}}`,className:"auto-width"},enum:wn,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${m}" })}}`,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: "${m}" })}}`,"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:A(w({},Pe),{title:`{{t("Only triggers when match conditions", { ns: "${m}" })}}`,"x-component-props":{useProps:Pe["x-component-props"].useProps},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:A(w({},Be),{"x-reactions":[...Be["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Ae.DELETED})}}`}}}]})});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});x(this,"components",{FieldsSelect:Ot})}useVariables(o,n){var u;const s=a.useCompile(),{getCollectionFields:i}=a.useCollectionManager(),l=[{collectionName:o.collection,name:"data",type:"hasOne",target:o.collection,uiSchema:{title:E("Trigger data")}}];return Se(A(w({appends:["data",...((u=o.appends)==null?void 0:u.map(d=>`data.${d}`))||[]]},n),{fields:l,compile:s,getCollectionFields:i}))}useInitializers(o){return o.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Ne,collection:o.collection,dataSource:"{{$context.data}}"}:null}}const xe={STATIC:0,COLLECTION_FIELD:1};function kn(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function eo({value:e,onChange:t}){const{t:o}=Q.useTranslation(),[n,s]=b.useState(e.offset?e.offset/Math.abs(e.offset):0);return r.jsxs("fieldset",{className:a.css`
453
+ `}},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}}}}}}},Be={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}=P.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},Ae={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},wn=[{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 Cn extends yt{constructor(){super(...arguments);x(this,"title",`{{t("Collection event", { ns: "${p}" })}}`);x(this,"description",`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${p}" })}}`);x(this,"fieldset",{collection:A(w({},be),{"x-reactions":[...be["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:wn,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:A(w({},Pe),{title:`{{t("Only triggers when match conditions", { ns: "${p}" })}}`,"x-component-props":{useProps:Pe["x-component-props"].useProps},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:A(w({},Be),{"x-reactions":[...Be["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Ae.DELETED})}}`}}}]})});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});x(this,"components",{FieldsSelect:Ot})}useVariables(o,n){var u;const s=a.useCompile(),{getCollectionFields:i}=a.useCollectionManager(),l=[{collectionName:o.collection,name:"data",type:"hasOne",target:o.collection,uiSchema:{title:D("Trigger data")}}];return Se(A(w({appends:["data",...((u=o.appends)==null?void 0:u.map(d=>`data.${d}`))||[]]},n),{fields:l,compile:s,getCollectionFields:i}))}useInitializers(o){return o.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Ne,collection:o.collection,dataSource:"{{$context.data}}"}:null}}const xe={STATIC:0,COLLECTION_FIELD:1};function kn(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function eo({value:e,onChange:t}){const{t:o}=Q.useTranslation(),[n,s]=b.useState(e.offset?e.offset/Math.abs(e.offset):0);return r.jsxs("fieldset",{className:a.css`
455
454
  display: flex;
456
455
  gap: 0.5em;
457
- `,children:[r.jsx(Ot,{value:e.field,onChange:i=>t(A(w({},e),{field:i})),filter:kn,placeholder:o("Select field")}),e.field?r.jsx(y.Select,{value:n,onChange:i=>{s(i),t(A(w({},e),{offset:Math.abs(e.offset)*i}))},options:[{value:0,label:E("Exactly at")},{value:-1,label:o("Before")},{value:1,label:o("After")}]}):null,n?r.jsxs(r.Fragment,{children:[r.jsx(y.InputNumber,{value:Math.abs(e.offset),onChange:i=>t(A(w({},e),{offset:(i!=null?i:0)*n}))}),r.jsx(y.Select,{value:e.unit||864e5,onChange:i=>t(A(w({},e),{unit:i})),options:[{value:864e5,label:E("Days")},{value:36e5,label:E("Hours")},{value:6e4,label:E("Minutes")},{value:1e3,label:E("Seconds")}]})]}):null]})}function Sn({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:a.css`
456
+ `,children:[r.jsx(Ot,{value:e.field,onChange:i=>t(A(w({},e),{field:i})),filter:kn,placeholder:o("Select field")}),e.field?r.jsx(y.Select,{value:n,onChange:i=>{s(i),t(A(w({},e),{offset:Math.abs(e.offset)*i}))},options:[{value:0,label:D("Exactly at")},{value:-1,label:o("Before")},{value:1,label:o("After")}]}):null,n?r.jsxs(r.Fragment,{children:[r.jsx(y.InputNumber,{value:Math.abs(e.offset),onChange:i=>t(A(w({},e),{offset:(i!=null?i:0)*n}))}),r.jsx(y.Select,{value:e.unit||864e5,onChange:i=>t(A(w({},e),{unit:i})),options:[{value:864e5,label:D("Days")},{value:36e5,label:D("Hours")},{value:6e4,label:D("Minutes")},{value:1e3,label:D("Seconds")}]})]}):null]})}function Sn({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:a.css`
458
457
  display: flex;
459
458
  gap: 0.5em;
460
- `,children:[r.jsxs(y.Select,{value:n,onChange:s=>{t(s?s==="field"?{}:new Date:null)},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(eo,{value:e,onChange:t}):null,n==="date"?r.jsx(y.DatePicker,{showTime:!0,value:Vo(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var oe=function(){return oe=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},oe.apply(this,arguments)};function to(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 Qe(e,t,o){if(o||arguments.length===2)for(var n,s=0,i=t.length;s<i;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 On=[{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 * * * *"}],ve=[{type:"minutes",min:0,max:59,total:60},{type:"hours",min:0,max:23,total:24},{type:"month-days",min:1,max:31,total:31},{type:"months",min:1,max:12,total:12,alt:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]},{type:"week-days",min:0,max:6,total:7,alt:["SUN","MON","TUE","WED","THU","FRI","SAT"]}],V={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function oo(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function Xe(e){return e.sort(function(t,o){return t-o}),e}function no(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function se(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 ro(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||V.errorInvalidCron})}function Re(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function so(e,t,o,n,s,i,l,c,u,d,f,v,k,h){o&&o(void 0),t(!1);var p=!1;if(!e){if(n==="always"||i&&n==="for-default-value")return;p=!0}if(!p){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void h("reboot");var C=On.find(function(O){return O.name===e});C&&(e=C.value)}try{var F=function(O){if(typeof O!="string")throw new Error("Invalid cron string");var B=O.replace(/\s+/g," ").trim().split(" ");if(B.length===5)return B.map(function(z,H){return function($,N){if($==="*"||$==="*/1")return[];var S=Xe(no(co(function(W,J,ie){if(ie){W=W.toUpperCase();for(var D=0;D<ie.length;D++)W=W.replace(ie[D],"".concat(D+J))}return W}($,N.min,N.alt).split(",").map(function(W){var J,ie=W.split("/");if(ie.length>2)throw new Error('Invalid value "'.concat($,' for "').concat(N.type,'"'));var D=ie[0],j=ie[1];J=D==="*"?oo(N.min,N.max):function(U,Y,X){var R=U.split("-");if(R.length===1){var je=Re(R[0]);if(isNaN(je))throw new Error('Invalid value "'.concat(Y,'" for ').concat(X.type));return[je]}if(R.length===2){var pe=Re(R[0]),Fe=Re(R[1]);if(isNaN(pe)||isNaN(Fe))throw new Error('Invalid value "'.concat(Y,'" for ').concat(X.type));if(Fe<pe)throw new Error('Max range is less than min range in "'.concat(U,'" for ').concat(X.type));return oo(pe,Fe)}throw new Error('Invalid value "'.concat(U,'" for ').concat(X.type))}(D,$,N);var L=function(U,Y){if(U!==void 0){var X=Re(U);if(isNaN(X)||X<1)throw new Error('Invalid interval step value "'.concat(U,'" for ').concat(Y.type));return X}}(j,N),ne=function(U,Y){if(Y){var X=U[0];U=U.filter(function(R){return R%Y==X%Y||R===X})}return U}(J,L);return ne}).flat(),N))),I=uo(S,N);if(I!==void 0)throw new Error('Value "'.concat(I,'" out of range for ').concat(N.type));return S.length===N.total?[]:S}(z,ve[H])});throw new Error("Invalid cron string format")}(e),M=function(O){return O[3].length>0?"year":O[2].length>0?"month":O[4].length>0?"week":O[1].length>0?"day":O[0].length>0?"hour":"minute"}(F);h(M),u(F[0]),d(F[1]),f(F[2]),v(F[3]),k(F[4])}catch(O){p=!0}}p&&(s.current=e,t(!0),ro(o,l))}function io(e,t,o,n,s,i,l){if(e==="reboot")return"@reboot";var c=function(u,d){return u.map(function(f,v){var k=ve[v];return lo(ao(f,k),k,d)})}([e!=="minute"&&i?i:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return c.join(" ")}function lo(e,t,o,n,s){var i="";if(function(c,u){return c.length===u.max-u.min+1}(e,t)||e.length===0)i="*";else{var l=function(c){if(c.length>2){var u=c[1]-c[0];if(u>1)return u}}(e);i=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=po(c),v=mo(c),k=c.length===(v-f)/d+1;return!!(f===u.min&&v+d>u.max&&k)}(e,t,l)?"*/".concat(l):"".concat(Te(po(e),t,o,n,s),"-").concat(Te(mo(e),t,o,n,s),"/").concat(l):function(c){var u=[],d=null;return c.forEach(function(f,v,k){f!==k[v+1]-1?d!==null?(u.push([d,f]),d=null):u.push(f):d===null&&(d=f)}),u}(e).map(function(c){return Array.isArray(c)?"".concat(Te(c[0],t,o,n,s),"-").concat(Te(c[1],t,o,n,s)):Te(c,t,o,n,s)}).join(",")}return i}function Te(e,t,o,n,s){var i=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"?i=c[e-u]:e<10&&(d||f)&&(i=i.padStart(2,"0")),l==="hours"&&s==="12-hour-clock"){var v=e>=12?"PM":"AM",k=e%12||12;k<10&&d&&(k=k.toString().padStart(2,"0")),i="".concat(k).concat(v)}return i}function ao(e,t){var o=Xe(no(co(e,t)));if(o.length===0)return o;var n=uo(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function co(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function uo(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function po(e){return e[0]}function mo(e){return e[e.length-1]}function Ve(e){var t=e.value,o=e.grid,n=o===void 0||o,s=e.optionsList,i=e.setValue,l=e.locale,c=e.className,u=e.humanizeLabels,d=e.disabled,f=e.readOnly,v=e.leadingZero,k=e.clockFormat,h=e.period,p=e.unit,C=e.periodicityOnDoubleClick,F=e.mode,M=to(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),O=b.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(D){return D.toString()})},[t]),B=b.useMemo(function(){return s?s.map(function(D,j){return{value:(p.min===0?j:j+1).toString(),label:D}}):Qe([],Array(p.total),!0).map(function(D,j){var L=p.min===0?j:j+1;return{value:L.toString(),label:Te(L,p,u,v,k)}})},[s,v,u,k]),z=JSON.stringify(l),H=b.useCallback(function(D){var j=D.value;if(!t||t[0]!==Number(j))return r.jsx(r.Fragment,{});var L=lo(ao(t,p),p,u,v,k),ne=L.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:ne[1]?"".concat(l.everyText||V.everyText," ").concat(ne[1]):L})},[t,z,u,v,k]),$=b.useCallback(function(D){var j=Array.isArray(D)?Xe(D):[D],L=j;t&&(L=F==="single"?[]:Qe([],t,!0),j.forEach(function(ne){var U=Number(ne);L=t.some(function(Y){return Y===U})?L.filter(function(Y){return Y!==U}):Xe(Qe(Qe([],L,!0),[U],!1))})),L.length===p.total?i([]):i(L)},[i,t]),N=b.useCallback(function(D){if(D!==0&&D!==1){for(var j=p.total+p.min,L=[],ne=p.min;ne<j;ne++)ne%D==0&&L.push(ne);var U=t&&L&&t.length===L.length&&t.every(function(X,R){return X===L[R]}),Y=L.length===B.length;i(Y||U?[]:L)}else i([])},[t,B,i]),S=b.useRef([]),I=b.useCallback(function(D){if(!f){var j=S.current;j.push({time:new Date().getTime(),value:Number(D)});var L=window.setTimeout(function(){C&&j.length>1&&j[j.length-1].time-j[j.length-2].time<300?j[j.length-1].value===j[j.length-2].value?N(Number(D)):$([j[j.length-2].value,j[j.length-1].value]):$(Number(D)),S.current=[]},300);return function(){window.clearTimeout(L)}}},[S,$,N,f,C]),W=b.useCallback(function(){f||i([])},[i,f]),J=b.useMemo(function(){var D;return se(((D={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,D))},[c]),ie=b.useMemo(function(){var D;return se(((D={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(p.type)]=!0,D["react-js-cron-custom-select-dropdown"]=!0,D["react-js-cron-custom-select-dropdown-".concat(p.type)]=!0,D["react-js-cron-custom-select-dropdown-minutes-large"]=p.type==="minutes"&&h!=="hour"&&h!=="day",D["react-js-cron-custom-select-dropdown-minutes-medium"]=p.type==="minutes"&&(h==="day"||h==="hour"),D["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=p.type==="hours"&&k==="12-hour-clock",D["react-js-cron-custom-select-dropdown-grid"]=!!n,D["".concat(c,"-select-dropdown")]=!!c,D["".concat(c,"-select-dropdown-").concat(p.type)]=!!c,D))},[c,n,k,h]);return r.jsx(y.Select,oe({mode:F!=="single"||C?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:O,onClear:W,tagRender:H,className:J,popupClassName:ie,options:B,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:I,onDeselect:I,disabled:d,dropdownAlign:p.type!=="minutes"&&p.type!=="hours"||h==="day"||h==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(p.type)},M))}function An(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,v=e.mode,k=b.useMemo(function(){var h;return se(((h={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-hours")]=!!s,h))},[s]);return r.jsxs("div",oe({className:k},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||V.prefixHours}),r.jsx(Ve,{placeholder:n.emptyHours||V.emptyHours,value:t,unit:ve[1],setValue:o,locale:n,className:s,disabled:i,readOnly:l,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:v})]}))}function Tn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,v=e.mode,k=b.useMemo(function(){var h;return se(((h={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-minutes")]=!!s,h))},[s]);return r.jsxs("div",oe({className:k},{children:[d==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||V.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||V.prefixMinutes}),r.jsx(Ve,{placeholder:d==="hour"?n.emptyMinutesForHourPeriod||V.emptyMinutesForHourPeriod:n.emptyMinutes||V.emptyMinutes,value:t,unit:ve[0],setValue:o,locale:n,className:s,disabled:i,readOnly:l,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:v}),d==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||V.suffixMinutesForHourPeriod})]}))}function Fn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.weekDays,l=e.disabled,c=e.readOnly,u=e.leadingZero,d=e.period,f=e.periodicityOnDoubleClick,v=e.mode,k=!i||i.length===0,h=b.useMemo(function(){var F;return se(((F={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!k})["".concat(s,"-field")]=!!s,F["".concat(s,"-month-days")]=!!s,F))},[s,k]),p=JSON.stringify(n),C=b.useMemo(function(){return k?n.emptyMonthDays||V.emptyMonthDays:n.emptyMonthDaysShort||V.emptyMonthDaysShort},[k,p]);return!c||t&&t.length>0||(!t||t.length===0)&&(!i||i.length===0)?r.jsxs("div",oe({className:h},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||V.prefixMonthDays}),r.jsx(Ve,{placeholder:C,value:t,setValue:o,unit:ve[2],locale:n,className:s,disabled:l,readOnly:c,leadingZero:u,period:d,periodicityOnDoubleClick:f,mode:v})]})):null}function $n(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.humanizeLabels,l=e.disabled,c=e.readOnly,u=e.period,d=e.periodicityOnDoubleClick,f=e.mode,v=n.months||V.months,k=b.useMemo(function(){var h;return se(((h={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-months")]=!!s,h))},[s]);return r.jsxs("div",oe({className:k},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||V.prefixMonths}),r.jsx(Ve,{placeholder:n.emptyMonths||V.emptyMonths,optionsList:v,grid:!1,value:t,unit:oe(oe({},ve[3]),{alt:n.altMonths||V.altMonths}),setValue:o,locale:n,className:s,humanizeLabels:i,disabled:l,readOnly:c,period:u,periodicityOnDoubleClick:d,mode:f})]}))}function Dn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.disabled,l=e.readOnly,c=e.shortcuts,u=e.allowedPeriods,d=[];u.includes("year")&&d.push({value:"year",label:n.yearOption||V.yearOption}),u.includes("month")&&d.push({value:"month",label:n.monthOption||V.monthOption}),u.includes("week")&&d.push({value:"week",label:n.weekOption||V.weekOption}),u.includes("day")&&d.push({value:"day",label:n.dayOption||V.dayOption}),u.includes("hour")&&d.push({value:"hour",label:n.hourOption||V.hourOption}),u.includes("minute")&&d.push({value:"minute",label:n.minuteOption||V.minuteOption}),u.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&d.push({value:"reboot",label:n.rebootOption||V.rebootOption});var f=b.useCallback(function(p){l||o(p)},[o,l]),v=b.useMemo(function(){var p;return se(((p={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,p["".concat(s,"-period")]=!!s,p))},[s]),k=b.useMemo(function(){var p;return se(((p={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(s,"-select")]=!!s,p))},[s,n.prefixPeriod]),h=b.useMemo(function(){var p;return se(((p={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,p["".concat(s,"-select-dropdown-period")]=!!s,p))},[s]);return r.jsxs("div",oe({className:v},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||V.prefixPeriod}),r.jsx(y.Select,{defaultValue:t,value:t,onChange:f,options:d,className:k,popupClassName:h,disabled:i,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function En(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.humanizeLabels,l=e.monthDays,c=e.disabled,u=e.readOnly,d=e.period,f=e.periodicityOnDoubleClick,v=e.mode,k=n.weekDays||V.weekDays,h=d==="week"||!l||l.length===0,p=b.useMemo(function(){var B;return se(((B={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!h})["".concat(s,"-field")]=!!s,B["".concat(s,"-week-days")]=!!s,B))},[s,h]),C=JSON.stringify(n),F=b.useMemo(function(){return h?n.emptyWeekDays||V.emptyWeekDays:n.emptyWeekDaysShort||V.emptyWeekDaysShort},[h,C]),M=d==="week"||!u||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),O=!u||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return M?r.jsxs("div",oe({className:p},{children:[n.prefixWeekDays!==""&&(d==="week"||!O)&&r.jsx("span",{children:n.prefixWeekDays||V.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&d!=="week"&&O&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||V.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(Ve,{placeholder:F,optionsList:k,grid:!1,value:t,unit:oe(oe({},ve[4]),{alt:n.altWeekDays||V.altWeekDays}),setValue:o,locale:n,className:s,humanizeLabels:i,disabled:c,readOnly:u,period:d,periodicityOnDoubleClick:f,mode:v})]})):null}function Nn(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,s=n===void 0?{}:n,i=e.clearButtonAction,l=i===void 0?"fill-with-every":i,c=e.locale,u=c===void 0?V:c,d=e.value,f=d===void 0?"":d,v=e.setValue,k=e.displayError,h=k===void 0||k,p=e.onError,C=e.className,F=e.defaultPeriod,M=F===void 0?"day":F,O=e.allowEmpty,B=O===void 0?"for-default-value":O,z=e.humanizeLabels,H=z===void 0||z,$=e.humanizeValue,N=$!==void 0&&$,S=e.disabled,I=S!==void 0&&S,W=e.readOnly,J=W!==void 0&&W,ie=e.leadingZero,D=ie!==void 0&&ie,j=e.shortcuts,L=j===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:j,ne=e.clockFormat,U=e.periodicityOnDoubleClick,Y=U===void 0||U,X=e.mode,R=X===void 0?"multiple":X,je=e.allowedDropdowns,pe=je===void 0?["period","months","month-days","week-days","hours","minutes"]:je,Fe=e.allowedPeriods,tr=Fe===void 0?["year","month","week","day","hour","minute","reboot"]:Fe,$e=b.useRef(f),Tt=b.useRef(M),vo=b.useState(),ye=vo[0],et=vo[1],wo=b.useState(),Le=wo[0],tt=wo[1],Co=b.useState(),ot=Co[0],nt=Co[1],ko=b.useState(),We=ko[0],rt=ko[1],So=b.useState(),st=So[0],it=So[1],Oo=b.useState(),lt=Oo[0],at=Oo[1],Ao=b.useState(!1),Ft=Ao[0],ze=Ao[1],To=b.useState(!1),ct=To[0],Fo=To[1],or=function(G){var me=b.useRef(G);return b.useEffect(function(){me.current=G},[G]),me.current}(ct),$o=JSON.stringify(u);b.useEffect(function(){so(f,ze,p,B,$e,!0,u,L,at,it,tt,nt,rt,et)},[]),b.useEffect(function(){f!==$e.current&&so(f,ze,p,B,$e,!1,u,L,at,it,tt,nt,rt,et)},[f,$e,$o,B,L]),b.useEffect(function(){if(!(ye||lt||ot||Le||We||st)||ct||or)ct&&Fo(!1);else{var G=ye||Tt.current,me=io(G,ot,Le,We,st,lt,N);v(me,{selectedPeriod:G}),$e.current=me,p&&p(void 0),ze(!1)}},[ye,Le,ot,We,st,lt,N,ct]);var Do=b.useCallback(function(){tt(void 0),nt(void 0),rt(void 0),it(void 0),at(void 0);var G="",me=ye!=="reboot"&&ye?ye:Tt.current;me!==ye&&et(me),l==="fill-with-every"&&(G=io(me,void 0,void 0,void 0,void 0,void 0)),v(G,{selectedPeriod:me}),$e.current=G,Fo(!0),B==="never"&&l==="empty"?(ze(!0),ro(p,u)):(p&&p(void 0),ze(!1))},[ye,v,p,l]),nr=b.useMemo(function(){var G;return se(((G={"react-js-cron":!0,"react-js-cron-error":Ft&&h,"react-js-cron-disabled":I,"react-js-cron-read-only":J})["".concat(C)]=!!C,G["".concat(C,"-error")]=Ft&&h&&!!C,G["".concat(C,"-disabled")]=I&&!!C,G["".concat(C,"-read-only")]=J&&!!C,G))},[C,Ft,h,I,J]),$t=s.className,Eo=to(s,["className"]),No=b.useMemo(function(){var G;return se(((G={"react-js-cron-clear-button":!0})["".concat(C,"-clear-button")]=!!C,G["".concat($t)]=!!$t,G))},[C,$t]),rr=JSON.stringify(Eo),Io=b.useMemo(function(){return o&&!J?r.jsx(y.Button,oe({className:No,danger:!0,type:"primary",disabled:I},Eo,{onClick:Do},{children:u.clearButtonText||V.clearButtonText})):null},[o,J,$o,No,I,rr,Do]),ee=ye||Tt.current;return r.jsxs("div",oe({className:nr},{children:[pe.includes("period")&&r.jsx(Dn,{value:ee,setValue:et,locale:u,className:C,disabled:I,readOnly:J,shortcuts:L,allowedPeriods:tr}),ee==="reboot"?Io:r.jsxs(r.Fragment,{children:[ee==="year"&&pe.includes("months")&&r.jsx($n,{value:ot,setValue:nt,locale:u,className:C,humanizeLabels:H,disabled:I,readOnly:J,period:ee,periodicityOnDoubleClick:Y,mode:R}),(ee==="year"||ee==="month")&&pe.includes("month-days")&&r.jsx(Fn,{value:Le,setValue:tt,locale:u,className:C,weekDays:We,disabled:I,readOnly:J,leadingZero:D,period:ee,periodicityOnDoubleClick:Y,mode:R}),(ee==="year"||ee==="month"||ee==="week")&&pe.includes("week-days")&&r.jsx(En,{value:We,setValue:rt,locale:u,className:C,humanizeLabels:H,monthDays:Le,disabled:I,readOnly:J,period:ee,periodicityOnDoubleClick:Y,mode:R}),r.jsxs("div",{children:[ee!=="minute"&&ee!=="hour"&&pe.includes("hours")&&r.jsx(An,{value:st,setValue:it,locale:u,className:C,disabled:I,readOnly:J,leadingZero:D,clockFormat:ne,period:ee,periodicityOnDoubleClick:Y,mode:R}),ee!=="minute"&&pe.includes("minutes")&&r.jsx(Tn,{value:lt,setValue:at,locale:u,period:ee,className:C,disabled:I,readOnly:J,leadingZero:D,clockFormat:ne,periodicityOnDoubleClick:Y,mode:R}),Io]})]})]}))}const In={"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:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},fo=[{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 ho(e){return fo.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function Mn(e){let t;switch(typeof e){case"number":return t=ho(e),t?t.value:"none";case"string":return"cron"}return"none"}function Pn({value:e,onChange:t}){const{t:o}=dt(),n=ho(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 Bn({value:e=null,onChange:t}){const{t:o}=dt(),n=Mn(e);function s(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const i=In[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:a.css`
459
+ `,children:[r.jsxs(y.Select,{value:n,onChange:s=>{t(s?s==="field"?{}:new Date:null)},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(eo,{value:e,onChange:t}):null,n==="date"?r.jsx(y.DatePicker,{showTime:!0,value:Vo(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var oe=function(){return oe=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},oe.apply(this,arguments)};function to(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 Qe(e,t,o){if(o||arguments.length===2)for(var n,s=0,i=t.length;s<i;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 On=[{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 * * * *"}],ve=[{type:"minutes",min:0,max:59,total:60},{type:"hours",min:0,max:23,total:24},{type:"month-days",min:1,max:31,total:31},{type:"months",min:1,max:12,total:12,alt:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]},{type:"week-days",min:0,max:6,total:7,alt:["SUN","MON","TUE","WED","THU","FRI","SAT"]}],V={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function oo(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function Xe(e){return e.sort(function(t,o){return t-o}),e}function no(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function se(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 ro(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||V.errorInvalidCron})}function Re(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function so(e,t,o,n,s,i,l,c,u,d,f,v,k,h){o&&o(void 0),t(!1);var m=!1;if(!e){if(n==="always"||i&&n==="for-default-value")return;m=!0}if(!m){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void h("reboot");var C=On.find(function(O){return O.name===e});C&&(e=C.value)}try{var F=function(O){if(typeof O!="string")throw new Error("Invalid cron string");var B=O.replace(/\s+/g," ").trim().split(" ");if(B.length===5)return B.map(function(z,H){return function($,N){if($==="*"||$==="*/1")return[];var S=Xe(no(co(function(W,J,ie){if(ie){W=W.toUpperCase();for(var E=0;E<ie.length;E++)W=W.replace(ie[E],"".concat(E+J))}return W}($,N.min,N.alt).split(",").map(function(W){var J,ie=W.split("/");if(ie.length>2)throw new Error('Invalid value "'.concat($,' for "').concat(N.type,'"'));var E=ie[0],j=ie[1];J=E==="*"?oo(N.min,N.max):function(U,Y,X){var R=U.split("-");if(R.length===1){var je=Re(R[0]);if(isNaN(je))throw new Error('Invalid value "'.concat(Y,'" for ').concat(X.type));return[je]}if(R.length===2){var pe=Re(R[0]),Fe=Re(R[1]);if(isNaN(pe)||isNaN(Fe))throw new Error('Invalid value "'.concat(Y,'" for ').concat(X.type));if(Fe<pe)throw new Error('Max range is less than min range in "'.concat(U,'" for ').concat(X.type));return oo(pe,Fe)}throw new Error('Invalid value "'.concat(U,'" for ').concat(X.type))}(E,$,N);var L=function(U,Y){if(U!==void 0){var X=Re(U);if(isNaN(X)||X<1)throw new Error('Invalid interval step value "'.concat(U,'" for ').concat(Y.type));return X}}(j,N),ne=function(U,Y){if(Y){var X=U[0];U=U.filter(function(R){return R%Y==X%Y||R===X})}return U}(J,L);return ne}).flat(),N))),I=uo(S,N);if(I!==void 0)throw new Error('Value "'.concat(I,'" out of range for ').concat(N.type));return S.length===N.total?[]:S}(z,ve[H])});throw new Error("Invalid cron string format")}(e),M=function(O){return O[3].length>0?"year":O[2].length>0?"month":O[4].length>0?"week":O[1].length>0?"day":O[0].length>0?"hour":"minute"}(F);h(M),u(F[0]),d(F[1]),f(F[2]),v(F[3]),k(F[4])}catch(O){m=!0}}m&&(s.current=e,t(!0),ro(o,l))}function io(e,t,o,n,s,i,l){if(e==="reboot")return"@reboot";var c=function(u,d){return u.map(function(f,v){var k=ve[v];return lo(ao(f,k),k,d)})}([e!=="minute"&&i?i:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],l);return c.join(" ")}function lo(e,t,o,n,s){var i="";if(function(c,u){return c.length===u.max-u.min+1}(e,t)||e.length===0)i="*";else{var l=function(c){if(c.length>2){var u=c[1]-c[0];if(u>1)return u}}(e);i=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=po(c),v=mo(c),k=c.length===(v-f)/d+1;return!!(f===u.min&&v+d>u.max&&k)}(e,t,l)?"*/".concat(l):"".concat(Te(po(e),t,o,n,s),"-").concat(Te(mo(e),t,o,n,s),"/").concat(l):function(c){var u=[],d=null;return c.forEach(function(f,v,k){f!==k[v+1]-1?d!==null?(u.push([d,f]),d=null):u.push(f):d===null&&(d=f)}),u}(e).map(function(c){return Array.isArray(c)?"".concat(Te(c[0],t,o,n,s),"-").concat(Te(c[1],t,o,n,s)):Te(c,t,o,n,s)}).join(",")}return i}function Te(e,t,o,n,s){var i=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"?i=c[e-u]:e<10&&(d||f)&&(i=i.padStart(2,"0")),l==="hours"&&s==="12-hour-clock"){var v=e>=12?"PM":"AM",k=e%12||12;k<10&&d&&(k=k.toString().padStart(2,"0")),i="".concat(k).concat(v)}return i}function ao(e,t){var o=Xe(no(co(e,t)));if(o.length===0)return o;var n=uo(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function co(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function uo(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function po(e){return e[0]}function mo(e){return e[e.length-1]}function Ve(e){var t=e.value,o=e.grid,n=o===void 0||o,s=e.optionsList,i=e.setValue,l=e.locale,c=e.className,u=e.humanizeLabels,d=e.disabled,f=e.readOnly,v=e.leadingZero,k=e.clockFormat,h=e.period,m=e.unit,C=e.periodicityOnDoubleClick,F=e.mode,M=to(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),O=b.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(E){return E.toString()})},[t]),B=b.useMemo(function(){return s?s.map(function(E,j){return{value:(m.min===0?j:j+1).toString(),label:E}}):Qe([],Array(m.total),!0).map(function(E,j){var L=m.min===0?j:j+1;return{value:L.toString(),label:Te(L,m,u,v,k)}})},[s,v,u,k]),z=JSON.stringify(l),H=b.useCallback(function(E){var j=E.value;if(!t||t[0]!==Number(j))return r.jsx(r.Fragment,{});var L=lo(ao(t,m),m,u,v,k),ne=L.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:ne[1]?"".concat(l.everyText||V.everyText," ").concat(ne[1]):L})},[t,z,u,v,k]),$=b.useCallback(function(E){var j=Array.isArray(E)?Xe(E):[E],L=j;t&&(L=F==="single"?[]:Qe([],t,!0),j.forEach(function(ne){var U=Number(ne);L=t.some(function(Y){return Y===U})?L.filter(function(Y){return Y!==U}):Xe(Qe(Qe([],L,!0),[U],!1))})),L.length===m.total?i([]):i(L)},[i,t]),N=b.useCallback(function(E){if(E!==0&&E!==1){for(var j=m.total+m.min,L=[],ne=m.min;ne<j;ne++)ne%E==0&&L.push(ne);var U=t&&L&&t.length===L.length&&t.every(function(X,R){return X===L[R]}),Y=L.length===B.length;i(Y||U?[]:L)}else i([])},[t,B,i]),S=b.useRef([]),I=b.useCallback(function(E){if(!f){var j=S.current;j.push({time:new Date().getTime(),value:Number(E)});var L=window.setTimeout(function(){C&&j.length>1&&j[j.length-1].time-j[j.length-2].time<300?j[j.length-1].value===j[j.length-2].value?N(Number(E)):$([j[j.length-2].value,j[j.length-1].value]):$(Number(E)),S.current=[]},300);return function(){window.clearTimeout(L)}}},[S,$,N,f,C]),W=b.useCallback(function(){f||i([])},[i,f]),J=b.useMemo(function(){var E;return se(((E={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,E))},[c]),ie=b.useMemo(function(){var E;return se(((E={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(m.type)]=!0,E["react-js-cron-custom-select-dropdown"]=!0,E["react-js-cron-custom-select-dropdown-".concat(m.type)]=!0,E["react-js-cron-custom-select-dropdown-minutes-large"]=m.type==="minutes"&&h!=="hour"&&h!=="day",E["react-js-cron-custom-select-dropdown-minutes-medium"]=m.type==="minutes"&&(h==="day"||h==="hour"),E["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=m.type==="hours"&&k==="12-hour-clock",E["react-js-cron-custom-select-dropdown-grid"]=!!n,E["".concat(c,"-select-dropdown")]=!!c,E["".concat(c,"-select-dropdown-").concat(m.type)]=!!c,E))},[c,n,k,h]);return r.jsx(y.Select,oe({mode:F!=="single"||C?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:O,onClear:W,tagRender:H,className:J,popupClassName:ie,options:B,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:I,onDeselect:I,disabled:d,dropdownAlign:m.type!=="minutes"&&m.type!=="hours"||h==="day"||h==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(m.type)},M))}function An(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,v=e.mode,k=b.useMemo(function(){var h;return se(((h={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-hours")]=!!s,h))},[s]);return r.jsxs("div",oe({className:k},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||V.prefixHours}),r.jsx(Ve,{placeholder:n.emptyHours||V.emptyHours,value:t,unit:ve[1],setValue:o,locale:n,className:s,disabled:i,readOnly:l,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:v})]}))}function Tn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.disabled,l=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,v=e.mode,k=b.useMemo(function(){var h;return se(((h={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-minutes")]=!!s,h))},[s]);return r.jsxs("div",oe({className:k},{children:[d==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||V.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||V.prefixMinutes}),r.jsx(Ve,{placeholder:d==="hour"?n.emptyMinutesForHourPeriod||V.emptyMinutesForHourPeriod:n.emptyMinutes||V.emptyMinutes,value:t,unit:ve[0],setValue:o,locale:n,className:s,disabled:i,readOnly:l,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:v}),d==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||V.suffixMinutesForHourPeriod})]}))}function Fn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.weekDays,l=e.disabled,c=e.readOnly,u=e.leadingZero,d=e.period,f=e.periodicityOnDoubleClick,v=e.mode,k=!i||i.length===0,h=b.useMemo(function(){var F;return se(((F={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!k})["".concat(s,"-field")]=!!s,F["".concat(s,"-month-days")]=!!s,F))},[s,k]),m=JSON.stringify(n),C=b.useMemo(function(){return k?n.emptyMonthDays||V.emptyMonthDays:n.emptyMonthDaysShort||V.emptyMonthDaysShort},[k,m]);return!c||t&&t.length>0||(!t||t.length===0)&&(!i||i.length===0)?r.jsxs("div",oe({className:h},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||V.prefixMonthDays}),r.jsx(Ve,{placeholder:C,value:t,setValue:o,unit:ve[2],locale:n,className:s,disabled:l,readOnly:c,leadingZero:u,period:d,periodicityOnDoubleClick:f,mode:v})]})):null}function $n(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.humanizeLabels,l=e.disabled,c=e.readOnly,u=e.period,d=e.periodicityOnDoubleClick,f=e.mode,v=n.months||V.months,k=b.useMemo(function(){var h;return se(((h={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-months")]=!!s,h))},[s]);return r.jsxs("div",oe({className:k},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||V.prefixMonths}),r.jsx(Ve,{placeholder:n.emptyMonths||V.emptyMonths,optionsList:v,grid:!1,value:t,unit:oe(oe({},ve[3]),{alt:n.altMonths||V.altMonths}),setValue:o,locale:n,className:s,humanizeLabels:i,disabled:l,readOnly:c,period:u,periodicityOnDoubleClick:d,mode:f})]}))}function En(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.disabled,l=e.readOnly,c=e.shortcuts,u=e.allowedPeriods,d=[];u.includes("year")&&d.push({value:"year",label:n.yearOption||V.yearOption}),u.includes("month")&&d.push({value:"month",label:n.monthOption||V.monthOption}),u.includes("week")&&d.push({value:"week",label:n.weekOption||V.weekOption}),u.includes("day")&&d.push({value:"day",label:n.dayOption||V.dayOption}),u.includes("hour")&&d.push({value:"hour",label:n.hourOption||V.hourOption}),u.includes("minute")&&d.push({value:"minute",label:n.minuteOption||V.minuteOption}),u.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&d.push({value:"reboot",label:n.rebootOption||V.rebootOption});var f=b.useCallback(function(m){l||o(m)},[o,l]),v=b.useMemo(function(){var m;return se(((m={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,m["".concat(s,"-period")]=!!s,m))},[s]),k=b.useMemo(function(){var m;return se(((m={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(s,"-select")]=!!s,m))},[s,n.prefixPeriod]),h=b.useMemo(function(){var m;return se(((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",oe({className:v},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||V.prefixPeriod}),r.jsx(y.Select,{defaultValue:t,value:t,onChange:f,options:d,className:k,popupClassName:h,disabled:i,showArrow:!l,open:!l&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function Dn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.humanizeLabels,l=e.monthDays,c=e.disabled,u=e.readOnly,d=e.period,f=e.periodicityOnDoubleClick,v=e.mode,k=n.weekDays||V.weekDays,h=d==="week"||!l||l.length===0,m=b.useMemo(function(){var B;return se(((B={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!h})["".concat(s,"-field")]=!!s,B["".concat(s,"-week-days")]=!!s,B))},[s,h]),C=JSON.stringify(n),F=b.useMemo(function(){return h?n.emptyWeekDays||V.emptyWeekDays:n.emptyWeekDaysShort||V.emptyWeekDaysShort},[h,C]),M=d==="week"||!u||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0),O=!u||l&&l.length>0||(!l||l.length===0)&&(!t||t.length===0);return M?r.jsxs("div",oe({className:m},{children:[n.prefixWeekDays!==""&&(d==="week"||!O)&&r.jsx("span",{children:n.prefixWeekDays||V.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&d!=="week"&&O&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||V.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(Ve,{placeholder:F,optionsList:k,grid:!1,value:t,unit:oe(oe({},ve[4]),{alt:n.altWeekDays||V.altWeekDays}),setValue:o,locale:n,className:s,humanizeLabels:i,disabled:c,readOnly:u,period:d,periodicityOnDoubleClick:f,mode:v})]})):null}function Nn(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,s=n===void 0?{}:n,i=e.clearButtonAction,l=i===void 0?"fill-with-every":i,c=e.locale,u=c===void 0?V:c,d=e.value,f=d===void 0?"":d,v=e.setValue,k=e.displayError,h=k===void 0||k,m=e.onError,C=e.className,F=e.defaultPeriod,M=F===void 0?"day":F,O=e.allowEmpty,B=O===void 0?"for-default-value":O,z=e.humanizeLabels,H=z===void 0||z,$=e.humanizeValue,N=$!==void 0&&$,S=e.disabled,I=S!==void 0&&S,W=e.readOnly,J=W!==void 0&&W,ie=e.leadingZero,E=ie!==void 0&&ie,j=e.shortcuts,L=j===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:j,ne=e.clockFormat,U=e.periodicityOnDoubleClick,Y=U===void 0||U,X=e.mode,R=X===void 0?"multiple":X,je=e.allowedDropdowns,pe=je===void 0?["period","months","month-days","week-days","hours","minutes"]:je,Fe=e.allowedPeriods,tr=Fe===void 0?["year","month","week","day","hour","minute","reboot"]:Fe,$e=b.useRef(f),Tt=b.useRef(M),vo=b.useState(),ye=vo[0],et=vo[1],wo=b.useState(),Le=wo[0],tt=wo[1],Co=b.useState(),ot=Co[0],nt=Co[1],ko=b.useState(),We=ko[0],rt=ko[1],So=b.useState(),st=So[0],it=So[1],Oo=b.useState(),lt=Oo[0],at=Oo[1],Ao=b.useState(!1),Ft=Ao[0],ze=Ao[1],To=b.useState(!1),ct=To[0],Fo=To[1],or=function(G){var me=b.useRef(G);return b.useEffect(function(){me.current=G},[G]),me.current}(ct),$o=JSON.stringify(u);b.useEffect(function(){so(f,ze,m,B,$e,!0,u,L,at,it,tt,nt,rt,et)},[]),b.useEffect(function(){f!==$e.current&&so(f,ze,m,B,$e,!1,u,L,at,it,tt,nt,rt,et)},[f,$e,$o,B,L]),b.useEffect(function(){if(!(ye||lt||ot||Le||We||st)||ct||or)ct&&Fo(!1);else{var G=ye||Tt.current,me=io(G,ot,Le,We,st,lt,N);v(me,{selectedPeriod:G}),$e.current=me,m&&m(void 0),ze(!1)}},[ye,Le,ot,We,st,lt,N,ct]);var Eo=b.useCallback(function(){tt(void 0),nt(void 0),rt(void 0),it(void 0),at(void 0);var G="",me=ye!=="reboot"&&ye?ye:Tt.current;me!==ye&&et(me),l==="fill-with-every"&&(G=io(me,void 0,void 0,void 0,void 0,void 0)),v(G,{selectedPeriod:me}),$e.current=G,Fo(!0),B==="never"&&l==="empty"?(ze(!0),ro(m,u)):(m&&m(void 0),ze(!1))},[ye,v,m,l]),nr=b.useMemo(function(){var G;return se(((G={"react-js-cron":!0,"react-js-cron-error":Ft&&h,"react-js-cron-disabled":I,"react-js-cron-read-only":J})["".concat(C)]=!!C,G["".concat(C,"-error")]=Ft&&h&&!!C,G["".concat(C,"-disabled")]=I&&!!C,G["".concat(C,"-read-only")]=J&&!!C,G))},[C,Ft,h,I,J]),$t=s.className,Do=to(s,["className"]),No=b.useMemo(function(){var G;return se(((G={"react-js-cron-clear-button":!0})["".concat(C,"-clear-button")]=!!C,G["".concat($t)]=!!$t,G))},[C,$t]),rr=JSON.stringify(Do),Io=b.useMemo(function(){return o&&!J?r.jsx(y.Button,oe({className:No,danger:!0,type:"primary",disabled:I},Do,{onClick:Eo},{children:u.clearButtonText||V.clearButtonText})):null},[o,J,$o,No,I,rr,Eo]),ee=ye||Tt.current;return r.jsxs("div",oe({className:nr},{children:[pe.includes("period")&&r.jsx(En,{value:ee,setValue:et,locale:u,className:C,disabled:I,readOnly:J,shortcuts:L,allowedPeriods:tr}),ee==="reboot"?Io:r.jsxs(r.Fragment,{children:[ee==="year"&&pe.includes("months")&&r.jsx($n,{value:ot,setValue:nt,locale:u,className:C,humanizeLabels:H,disabled:I,readOnly:J,period:ee,periodicityOnDoubleClick:Y,mode:R}),(ee==="year"||ee==="month")&&pe.includes("month-days")&&r.jsx(Fn,{value:Le,setValue:tt,locale:u,className:C,weekDays:We,disabled:I,readOnly:J,leadingZero:E,period:ee,periodicityOnDoubleClick:Y,mode:R}),(ee==="year"||ee==="month"||ee==="week")&&pe.includes("week-days")&&r.jsx(Dn,{value:We,setValue:rt,locale:u,className:C,humanizeLabels:H,monthDays:Le,disabled:I,readOnly:J,period:ee,periodicityOnDoubleClick:Y,mode:R}),r.jsxs("div",{children:[ee!=="minute"&&ee!=="hour"&&pe.includes("hours")&&r.jsx(An,{value:st,setValue:it,locale:u,className:C,disabled:I,readOnly:J,leadingZero:E,clockFormat:ne,period:ee,periodicityOnDoubleClick:Y,mode:R}),ee!=="minute"&&pe.includes("minutes")&&r.jsx(Tn,{value:lt,setValue:at,locale:u,period:ee,className:C,disabled:I,readOnly:J,leadingZero:E,clockFormat:ne,periodicityOnDoubleClick:Y,mode:R}),Io]})]})]}))}const In={"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:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},fo=[{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 ho(e){return fo.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function Mn(e){let t;switch(typeof e){case"number":return t=ho(e),t?t.value:"none";case"string":return"cron"}return"none"}function Pn({value:e,onChange:t}){const{t:o}=dt(),n=ho(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 Bn({value:e=null,onChange:t}){const{t:o}=dt(),n=Mn(e);function s(l){if(l==="none"){t(null);return}if(l==="cron"){t("0 * * * * *");return}t(l)}const i=In[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:a.css`
461
460
  display: flex;
462
461
  flex-direction: ${n==="cron"?"column":"row"};
463
462
  align-items: flex-start;
@@ -486,7 +485,7 @@
486
485
  }
487
486
  }
488
487
  }
489
- `,children:[r.jsx(y.Select,{value:n,onChange:s,className:"auto-width",children:fo.map(l=>r.jsx(y.Select.Option,{value:l.value,children:o(l.text)},l.value))}),typeof n=="number"?r.jsx(Pn,{value:e,onChange:t}):null,n==="cron"?r.jsx(Nn,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:l=>t(`0 ${l}`),clearButton:!1,locale:i}):null]})}const Vn={[xe.STATIC]:{startsOn:{type:"datetime",title:`{{t("Starts on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"datetime",title:`{{t("Ends on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0}},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${m}" })}}`,min:0}}},[xe.COLLECTION_FIELD]:{collection:A(w({},be),{"x-reactions":[...be["x-reactions"],{target:"startsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}}]}),startsOn:{type:"object",title:`{{t("Starts on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"OnField","x-reactions":[{target:"repeat",fulfill:{state:{visible:"{{!!$self.value}}"}}}],required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"object",title:`{{t("Ends on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"EndsByField"},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${m}" })}}`,min:0}},appends:A(w({},Be),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${xe.COLLECTION_FIELD} && $deps[1]}}`}}}]})}},jn=[{value:xe.STATIC,label:`{{t("Based on certain date", { ns: "${m}" })}}`},{value:xe.COLLECTION_FIELD,label:`{{t("Based on date field of collection", { ns: "${m}" })}}`}],Ln=()=>{const{values:e={},clearFormGraph:t}=P.useForm(),[o,n]=b.useState(e.mode);return P.useFormEffects(()=>{ge.onFieldValueChange("mode",s=>{n(s.value),t("collection"),t("startsOn"),t("repeat"),t("endsOn"),t("limit")})}),r.jsxs(r.Fragment,{children:[r.jsx(a.SchemaComponent,{schema:{type:"number",title:`{{t("Trigger mode", { ns: "${m}" })}}`,name:"mode","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:jn},required:!0,default:xe.STATIC}}),r.jsx(a.SchemaComponent,{schema:{type:"void",properties:{[`mode-${o}`]:{type:"void","x-component":"fieldset","x-component-props":{className:a.css`
488
+ `,children:[r.jsx(y.Select,{value:n,onChange:s,className:"auto-width",children:fo.map(l=>r.jsx(y.Select.Option,{value:l.value,children:o(l.text)},l.value))}),typeof n=="number"?r.jsx(Pn,{value:e,onChange:t}):null,n==="cron"?r.jsx(Nn,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:l=>t(`0 ${l}`),clearButton:!1,locale:i}):null]})}const Vn={[xe.STATIC]:{startsOn:{type:"datetime",title:`{{t("Starts on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"datetime",title:`{{t("Ends on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0}},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${p}" })}}`,min:0}}},[xe.COLLECTION_FIELD]:{collection:A(w({},be),{"x-reactions":[...be["x-reactions"],{target:"startsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}}]}),startsOn:{type:"object",title:`{{t("Starts on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"OnField","x-reactions":[{target:"repeat",fulfill:{state:{visible:"{{!!$self.value}}"}}}],required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"object",title:`{{t("Ends on", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"EndsByField"},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${p}" })}}`,min:0}},appends:A(w({},Be),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${xe.COLLECTION_FIELD} && $deps[1]}}`}}}]})}},jn=[{value:xe.STATIC,label:`{{t("Based on certain date", { ns: "${p}" })}}`},{value:xe.COLLECTION_FIELD,label:`{{t("Based on date field of collection", { ns: "${p}" })}}`}],Ln=()=>{const{values:e={},clearFormGraph:t}=P.useForm(),[o,n]=b.useState(e.mode);return P.useFormEffects(()=>{ge.onFieldValueChange("mode",s=>{n(s.value),t("collection"),t("startsOn"),t("repeat"),t("endsOn"),t("limit")})}),r.jsxs(r.Fragment,{children:[r.jsx(a.SchemaComponent,{schema:{type:"number",title:`{{t("Trigger mode", { ns: "${p}" })}}`,name:"mode","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:jn},required:!0,default:xe.STATIC}}),r.jsx(a.SchemaComponent,{schema:{type:"void",properties:{[`mode-${o}`]:{type:"void","x-component":"fieldset","x-component-props":{className:a.css`
490
489
  .ant-input-number {
491
490
  width: auto;
492
491
  min-width: 6em;
@@ -495,19 +494,19 @@
495
494
  .ant-picker {
496
495
  width: auto;
497
496
  }
498
- `},properties:Vn[o]}}},components:{OnField:eo,RepeatField:Bn,EndsByField:Sn}})]})};class Wn extends yt{constructor(){super(...arguments);x(this,"sync",!1);x(this,"title",`{{t("Schedule event", { ns: "${m}" })}}`);x(this,"description",`{{t("Event will be scheduled and triggered base on time conditions.", { ns: "${m}" })}}`);x(this,"fieldset",{config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});x(this,"components",{ScheduleConfig:Ln})}useVariables(o,n){var c;const s=a.useCompile(),{getCollectionFields:i}=a.useCollectionManager(),l=[];if((!(n!=null&&n.types)||n.types.includes("date"))&&l.push({key:"date",value:"date",label:E("Trigger time")}),o.mode===xe.COLLECTION_FIELD){const[u]=Se(A(w({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:i}));u&&l.push(u)}return l}useInitializers(o){return o.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Ne,collection:o.collection,dataSource:"{{$context.data}}"}:null}}const yo=e=>{const t=De.evaluators.get(e);return t&&t.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:a.css`
497
+ `},properties:Vn[o]}}},components:{OnField:eo,RepeatField:Bn,EndsByField:Sn}})]})};class Wn extends yt{constructor(){super(...arguments);x(this,"sync",!1);x(this,"title",`{{t("Schedule event", { ns: "${p}" })}}`);x(this,"description",`{{t("Event will be scheduled and triggered base on time conditions.", { ns: "${p}" })}}`);x(this,"fieldset",{config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});x(this,"components",{ScheduleConfig:Ln})}useVariables(o,n){var c;const s=a.useCompile(),{getCollectionFields:i}=a.useCollectionManager(),l=[];if((!(n!=null&&n.types)||n.types.includes("date"))&&l.push({key:"date",value:"date",label:D("Trigger time")}),o.mode===xe.COLLECTION_FIELD){const[u]=Se(A(w({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:i}));u&&l.push(u)}return l}useInitializers(o){return o.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${p}" })}}`,Component:Ne,collection:o.collection,dataSource:"{{$context.data}}"}:null}}const yo=e=>{const t=Ee.evaluators.get(e);return t&&t.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:a.css`
499
498
  &:after {
500
499
  content: ':';
501
500
  }
502
501
  & + a {
503
502
  margin-left: 0.25em;
504
503
  }
505
- `,children:a.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class zn extends fe{constructor(){super(...arguments);x(this,"title",`{{t("Calculation", { ns: "${m}" })}}`);x(this,"type","calculation");x(this,"group","control");x(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: "${m}" })}}`);x(this,"fieldset",{engine:{type:"string",title:`{{t("Calculation engine", { ns: "${m}" })}}`,"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: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(o,n,{form:s}){const{values:i}=s,{evaluate:l}=De.evaluators.get(i.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}});x(this,"scope",{renderEngineReference:yo});x(this,"components",{WorkflowVariableTextArea:Ct,RadioWithTooltip:Ie,ValueBlock:Me})}useVariables({key:o,title:n},{types:s,fieldNames:i=ke}){return s&&!s.some(l=>l in qe||Object.values(qe).some(c=>c.has(l)))?null:{[i.value]:o,[i.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:Me.Initializer,node:o,resultTitle:E("Calculation result")}}}const q=new ue.Registry;q.register("equal",{name:"=",type:"boolean",group:"boolean"}),q.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),q.register("gt",{name:">",type:"boolean",group:"boolean"}),q.register("gte",{name:"≥",type:"boolean",group:"boolean"}),q.register("lt",{name:"<",type:"boolean",group:"boolean"}),q.register("lte",{name:"≤",type:"boolean",group:"boolean"}),q.register("add",{name:"+",type:"number",group:"number"}),q.register("minus",{name:"-",type:"number",group:"number"}),q.register("multiple",{name:"*",type:"number",group:"number"}),q.register("divide",{name:"/",type:"number",group:"number"}),q.register("mod",{name:"%",type:"number",group:"number"}),q.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),q.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),q.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),q.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),q.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),q.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),q.register("concat",{name:`{{t("concat", { ns: "${m}" })}}`,type:"string",group:"string"});const Jn=[{value:"boolean",title:'{{t("Comparision")}}'},{value:"number",title:`{{t("Arithmetic calculation", { ns: "${m}" })}}`},{value:"string",title:`{{t("String operation", { ns: "${m}" })}}`},{value:"date",title:`{{t("Date", { ns: "${m}" })}}`}];function go(e){return Array.from(q.getEntities()).filter(([t,o])=>o.group===e)}function Hn({calculator:e,operands:t=[],onChange:o}){const n=a.useCompile(),s=he();return r.jsxs("fieldset",{className:a.css`
504
+ `,children:a.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class zn extends fe{constructor(){super(...arguments);x(this,"title",`{{t("Calculation", { ns: "${p}" })}}`);x(this,"type","calculation");x(this,"group","control");x(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}" })}}`);x(this,"fieldset",{engine:{type:"string",title:`{{t("Calculation engine", { ns: "${p}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:Ee.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:i}=s,{evaluate:l}=Ee.evaluators.get(i.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}});x(this,"scope",{renderEngineReference:yo});x(this,"components",{WorkflowVariableTextArea:Ct,RadioWithTooltip:Ie,ValueBlock:Me})}useVariables({key:o,title:n},{types:s,fieldNames:i=ke}){return s&&!s.some(l=>l in qe||Object.values(qe).some(c=>c.has(l)))?null:{[i.value]:o,[i.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:Me.Initializer,node:o,resultTitle:D("Calculation result")}}}const q=new ue.Registry;q.register("equal",{name:"=",type:"boolean",group:"boolean"}),q.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),q.register("gt",{name:">",type:"boolean",group:"boolean"}),q.register("gte",{name:"≥",type:"boolean",group:"boolean"}),q.register("lt",{name:"<",type:"boolean",group:"boolean"}),q.register("lte",{name:"≤",type:"boolean",group:"boolean"}),q.register("add",{name:"+",type:"number",group:"number"}),q.register("minus",{name:"-",type:"number",group:"number"}),q.register("multiple",{name:"*",type:"number",group:"number"}),q.register("divide",{name:"/",type:"number",group:"number"}),q.register("mod",{name:"%",type:"number",group:"number"}),q.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),q.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),q.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),q.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),q.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),q.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),q.register("concat",{name:`{{t("concat", { ns: "${p}" })}}`,type:"string",group:"string"});const Jn=[{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 go(e){return Array.from(q.getEntities()).filter(([t,o])=>o.group===e)}function Hn({calculator:e,operands:t=[],onChange:o}){const n=a.useCompile(),s=he();return r.jsxs("fieldset",{className:a.css`
506
505
  display: flex;
507
506
  gap: 0.5em;
508
507
  align-items: center;
509
508
  flex-wrap: wrap;
510
- `,children:[r.jsx(a.Variable.Input,{value:t[0],onChange:i=>o({calculator:e,operands:[i,t[1]]}),scope:s,useTypedConstant:!0}),r.jsx(y.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:i=>o({operands:t,calculator:i}),placeholder:E("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:Jn.filter(i=>!!go(i.value).length).map(i=>r.jsx(y.Select.OptGroup,{label:n(i.title),children:go(i.value).map(([l,{name:c}])=>r.jsx(y.Select.Option,{value:l,children:n(c)},l))},i.value))}),r.jsx(a.Variable.Input,{value:t[1],onChange:i=>o({calculator:e,operands:[t[0],i]}),scope:s,useTypedConstant:!0})]})}function Un({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:n,operands:s=[]}=e;return r.jsxs("div",{className:a.css`
509
+ `,children:[r.jsx(a.Variable.Input,{value:t[0],onChange:i=>o({calculator:e,operands:[i,t[1]]}),scope:s,useTypedConstant:!0}),r.jsx(y.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:i=>o({operands:t,calculator:i}),placeholder:D("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:Jn.filter(i=>!!go(i.value).length).map(i=>r.jsx(y.Select.OptGroup,{label:n(i.title),children:go(i.value).map(([l,{name:c}])=>r.jsx(y.Select.Option,{value:l,children:n(c)},l))},i.value))}),r.jsx(a.Variable.Input,{value:t[1],onChange:i=>o({calculator:e,operands:[t[0],i]}),scope:s,useTypedConstant:!0})]})}function Un({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:n,operands:s=[]}=e;return r.jsxs("div",{className:a.css`
511
510
  display: flex;
512
511
  position: relative;
513
512
  margin: 0.5em 0;
@@ -537,7 +536,7 @@
537
536
  margin-right: 1em;
538
537
  }
539
538
  }
540
- `,children:[r.jsx(y.Button,{type:"link",onClick:i,children:o("Add condition")}),r.jsx(y.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function Yn({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(bo,{value:o.group,onChange:n=>t(A(w({},o),{group:n}))})}class Gn extends fe{constructor(){super(...arguments);x(this,"title",`{{t("Condition", { ns: "${m}" })}}`);x(this,"type","condition");x(this,"group","control");x(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: "${m}" })}}`);x(this,"fieldset",{rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{disabled:!0},enum:[{value:!0,label:`{{t('Continue when "Yes"', { ns: "${m}" })}}`},{value:!1,label:`{{t('Branch into "Yes" and "No"', { ns: "${m}" })}}`}]},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[["basic",{label:`{{t("Basic", { ns: "${m}" })}}`}],...Array.from(De.evaluators.getEntities())].reduce((o,[n,s])=>o.concat(w({value:n},s)),[])},required:!0,default:"basic"},calculation:{type:"string",title:`{{t("Condition", { ns: "${m}" })}}`,"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: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-validator"(o,n,{form:s}){const{values:i}=s,{evaluate:l}=De.evaluators.get(i.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}});x(this,"options",[{label:`{{t('Continue when "Yes"', { ns: "${m}" })}}`,key:"rejectOnFalse",value:{rejectOnFalse:!0}},{label:`{{t('Branch into "Yes" and "No"', { ns: "${m}" })}}`,key:"branch",value:{rejectOnFalse:!1}}]);x(this,"scope",{renderEngineReference:yo,useWorkflowVariableOptions:he});x(this,"components",{CalculationConfig:Yn,WorkflowVariableTextArea:Ct,RadioWithTooltip:Ie})}Component({data:o}){const{t:n}=Q.useTranslation(),{nodes:s}=Z(),{styles:i}=te(),{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:i.nodeSubtreeClass,children:[r.jsxs("div",{className:i.branchBlockClass,children:[r.jsx(Ge,{from:o,entry:d,branchIndex:0}),r.jsx(Ge,{from:o,entry:u,branchIndex:1})]}),r.jsxs("div",{className:i.conditionClass,children:[r.jsx("span",{style:{right:"4em"},children:n("No")}),r.jsx("span",{style:{left:"4em"},children:n("Yes")})]})]})})}}class qn extends fe{constructor(){super(...arguments);x(this,"title",'{{t("End process")}}');x(this,"type","end");x(this,"group","control");x(this,"description",`{{t("End the process immediately, with set status.", { ns: "${m}" })}}`);x(this,"fieldset",{endStatus:{type:"number",title:`{{t("End status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeeded", { ns: "${m}" })}}`,value:re.RESOLVED},{label:`{{t("Failed", { ns: "${m}" })}}`,value:re.FAILED}],required:!0,default:re.RESOLVED}});x(this,"end",!0)}}class _n extends fe{constructor(){super(...arguments);x(this,"title",`{{t("Query record", { ns: "${m}" })}}`);x(this,"type","query");x(this,"group","collection");x(this,"description",`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${m}" })}}`);x(this,"fieldset",{collection:be,multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${m}" })}}`,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: "${m}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:Pe,sort:xn,pagination:vn,appends:Be},"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: "${m}" })}}`}});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource,useSortableFields(){const o=a.useCompile(),{getCollectionFields:n,getInterface:s}=a.useCollectionManager(),{values:i}=P.useForm();return n(i.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}})}});x(this,"components",{ArrayItems:jo.ArrayItems,FilterDynamicComponent:Ze,SchemaComponentContext:a.SchemaComponentContext,WorkflowVariableInput:Ut})}useVariables({key:o,title:n,config:s},i){var d,f;const l=a.useCompile(),{getCollectionFields:c}=a.useCollectionManager(),[u]=Se(A(w({appends:[o,...((f=(d=s.params)==null?void 0:d.appends)==null?void 0:f.map(v=>`${o}.${v}`))||[]]},i),{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:Ne,collection:o.config.collection,dataSource:`{{$jobsMapByNodeKey.${o.key}}}`}}}function Kn(e){const{getCollectionFields:t}=a.useCollectionManager(),{path:o}=P.useField(),n=o.segments[o.segments.length-1],{values:s}=P.useForm(),i=t(s==null?void 0:s.collection),{type:l}=i.find(d=>d.name===n),c=Array.isArray(e.value)?e.value.join(","):e.value;function u(d){const f=d.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(l)?f:f.split(/[,\s]+/))}return r.jsx(y.Input,A(w({},e),{value:c,onChange:u}))}const xo=P.observer(({value:e,disabled:t,onChange:o,filter:n})=>{const{token:s}=a.useToken(),{t:i}=Q.useTranslation(),l=a.useCompile(),c=P.useForm(),{getCollection:u,getCollectionFields:d}=a.useCollectionManager(),f=he(),{values:v}=c,k=v==null?void 0:v.collection,h=d(k).filter(O=>O.uiSchema),p=n?h.filter(n.bind(v)):h,C=b.useMemo(()=>p.filter(O=>!e||!(O.name in e)),[p,e]),F=t||c.disabled,M=b.useMemo(()=>({onClick:({key:O})=>{o(A(w({},e),{[O]:null}))},style:{maxHeight:300,overflowY:"auto"},items:C.map(O=>{var B,z;return{key:O.name,label:l((z=(B=O.uiSchema)==null?void 0:B.title)!=null?z:O.name)}})}),[o,C,e]);return r.jsx("fieldset",{className:a.css`
539
+ `,children:[r.jsx(y.Button,{type:"link",onClick:i,children:o("Add condition")}),r.jsx(y.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function Yn({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(bo,{value:o.group,onChange:n=>t(A(w({},o),{group:n}))})}class Gn extends fe{constructor(){super(...arguments);x(this,"title",`{{t("Condition", { ns: "${p}" })}}`);x(this,"type","condition");x(this,"group","control");x(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}" })}}`);x(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(Ee.evaluators.getEntities())].reduce((o,[n,s])=>o.concat(w({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:i}=s,{evaluate:l}=Ee.evaluators.get(i.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}});x(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}}]);x(this,"scope",{renderEngineReference:yo,useWorkflowVariableOptions:he});x(this,"components",{CalculationConfig:Yn,WorkflowVariableTextArea:Ct,RadioWithTooltip:Ie})}Component({data:o}){const{t:n}=Q.useTranslation(),{nodes:s}=Z(),{styles:i}=te(),{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:i.nodeSubtreeClass,children:[r.jsxs("div",{className:i.branchBlockClass,children:[r.jsx(Ge,{from:o,entry:d,branchIndex:0}),r.jsx(Ge,{from:o,entry:u,branchIndex:1})]}),r.jsxs("div",{className:i.conditionClass,children:[r.jsx("span",{style:{right:"4em"},children:n("No")}),r.jsx("span",{style:{left:"4em"},children:n("Yes")})]})]})})}}class qn extends fe{constructor(){super(...arguments);x(this,"title",`{{t("End process", { ns: "${p}" })}}`);x(this,"type","end");x(this,"group","control");x(this,"description",`{{t("End the process immediately, with set status.", { ns: "${p}" })}}`);x(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:re.RESOLVED},{label:`{{t("Failed", { ns: "${p}" })}}`,value:re.FAILED}],required:!0,default:re.RESOLVED}});x(this,"end",!0)}}class _n extends fe{constructor(){super(...arguments);x(this,"title",`{{t("Query record", { ns: "${p}" })}}`);x(this,"type","query");x(this,"group","collection");x(this,"description",`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${p}" })}}`);x(this,"fieldset",{collection:be,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:Pe,sort:xn,pagination:vn,appends:Be},"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}" })}}`}});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource,useSortableFields(){const o=a.useCompile(),{getCollectionFields:n,getInterface:s}=a.useCollectionManager(),{values:i}=P.useForm();return n(i.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}})}});x(this,"components",{ArrayItems:jo.ArrayItems,FilterDynamicComponent:Ze,SchemaComponentContext:a.SchemaComponentContext,WorkflowVariableInput:Ut})}useVariables({key:o,title:n,config:s},i){var d,f;const l=a.useCompile(),{getCollectionFields:c}=a.useCollectionManager(),[u]=Se(A(w({appends:[o,...((f=(d=s.params)==null?void 0:d.appends)==null?void 0:f.map(v=>`${o}.${v}`))||[]]},i),{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:Ne,collection:o.config.collection,dataSource:`{{$jobsMapByNodeKey.${o.key}}}`}}}function Kn(e){const{getCollectionFields:t}=a.useCollectionManager(),{path:o}=P.useField(),n=o.segments[o.segments.length-1],{values:s}=P.useForm(),i=t(s==null?void 0:s.collection),{type:l}=i.find(d=>d.name===n),c=Array.isArray(e.value)?e.value.join(","):e.value;function u(d){const f=d.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(l)?f:f.split(/[,\s]+/))}return r.jsx(y.Input,A(w({},e),{value:c,onChange:u}))}const xo=P.observer(({value:e,disabled:t,onChange:o,filter:n})=>{const{token:s}=a.useToken(),{t:i}=Q.useTranslation(),l=a.useCompile(),c=P.useForm(),{getCollection:u,getCollectionFields:d}=a.useCollectionManager(),f=he(),{values:v}=c,k=v==null?void 0:v.collection,h=d(k).filter(O=>O.uiSchema),m=n?h.filter(n.bind(v)):h,C=b.useMemo(()=>m.filter(O=>!e||!(O.name in e)),[m,e]),F=t||c.disabled,M=b.useMemo(()=>({onClick:({key:O})=>{o(A(w({},e),{[O]:null}))},style:{maxHeight:300,overflowY:"auto"},items:C.map(O=>{var B,z;return{key:O.name,label:l((z=(B=O.uiSchema)==null?void 0:B.title)!=null?z:O.name)}})}),[o,C,e]);return r.jsx("fieldset",{className:a.css`
541
540
  margin-top: 0.5em;
542
541
 
543
542
  > .ant-formily-item {
@@ -547,8 +546,8 @@
547
546
  line-height: 32px;
548
547
  }
549
548
  }
550
- `,children:p.length?r.jsxs(a.CollectionProvider,{collection:u(k),children:[p.filter(O=>e&&O.name in e).map(O=>{var z,H;const B=["belongsTo","hasOne","hasMany","belongsToMany"].includes(O.type)?Kn:a.CollectionField;return r.jsxs(y.Form.Item,{label:l((H=(z=O.uiSchema)==null?void 0:z.title)!=null?H:O.name),labelAlign:"left",className:a.css`
549
+ `,children:m.length?r.jsxs(a.CollectionProvider,{collection:u(k),children:[m.filter(O=>e&&O.name in e).map(O=>{var z,H;const B=["belongsTo","hasOne","hasMany","belongsToMany"].includes(O.type)?Kn:a.CollectionField;return r.jsxs(y.Form.Item,{label:l((H=(z=O.uiSchema)==null?void 0:z.title)!=null?H:O.name),labelAlign:"left",className:a.css`
551
550
  .ant-form-item-control-input-content {
552
551
  display: flex;
553
552
  }
554
- `,children:[r.jsx(a.Variable.Input,{scope:f,value:e[O.name],changeOnSelect:!0,onChange:$=>{o(A(w({},e),{[O.name]:$}))},children:r.jsx(a.SchemaComponent,{schema:{type:"void",properties:{[O.name]:{"x-component":B,"x-validator"(){return""}}}}})}),F?null:r.jsx(y.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx(T.CloseCircleOutlined,{}),onClick:()=>{var S;const I=e,{[S=O.name]:$}=I,N=_(I,[Bo(S)]);o(N)}})]},O.name)}),C.length?r.jsx(y.Dropdown,{menu:M,children:r.jsx(y.Button,{icon:r.jsx(T.PlusOutlined,{}),children:i("Add field")})}):null]}):r.jsx("p",{style:{color:s.colorText},children:E("Please select collection first")})})},{displayName:"CollectionFieldSet"});class Zn extends fe{constructor(){super(...arguments);x(this,"title",`{{t("Create record", { ns: "${m}" })}}`);x(this,"type","create");x(this,"group","collection");x(this,"description",`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${m}" })}}`);x(this,"fieldset",{collection:be,params:{type:"object",properties:{values:Rt,appends:Be}}});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});x(this,"components",{CollectionFieldset:xo})}useVariables({key:o,title:n,config:s},i){var d,f;const l=a.useCompile(),{getCollectionFields:c}=a.useCollectionManager(),[u]=Se(A(w({appends:[o,...((f=(d=s.params)==null?void 0:d.appends)==null?void 0:f.map(v=>`${o}.${v}`))||[]]},i),{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:Ne,collection:o.config.collection,dataSource:`{{$jobsMapByNodeKey.${o.key}}}`}:null}}function Qn(o){var n=o,{onChange:e}=n,t=_(n,["onChange"]);const{getCollectionFields:s}=a.useCollectionManager(),i=P.useForm(),{collection:l}=i.values,c=s(l),u=P.useField();function d({target:f}){const v=u.query(".values").take();if(!v)return;const k=c.reduce((h,p)=>(p.name in v.value&&(f.value||!["hasOne","hasMany","belongsToMany"].includes(p.type))&&(h[p.name]=v.value[p.name]),h),{});i.setValuesIn("params.values",k),e(f.value)}return r.jsx(Ie,A(w({},t),{onChange:d}))}class Xn extends fe{constructor(){super(...arguments);x(this,"title",`{{t("Update record", { ns: "${m}" })}}`);x(this,"type","update");x(this,"group","collection");x(this,"description",`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${m}" })}}`);x(this,"fieldset",{collection:be,params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${m}" })}}`,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: "${m}" })}}`},{label:`{{t("Update one by one", { ns: "${m}" })}}`,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: "${m}" })}}`}]},default:!1},filter:A(w({},Pe),{title:`{{t("Only update records matching conditions", { ns: "${m}" })}}`,"x-validator"(o){return Ke(o)?"":E("Please add at least one condition")}}),values:A(w({},Rt),{"x-component-props":{filter(o){var n;return((n=this.params)==null?void 0:n.individualHooks)||!["hasOne","hasMany","belongsToMany"].includes(o.type)}}})}}});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});x(this,"components",{FilterDynamicComponent:Ze,CollectionFieldset:xo,IndividualHooksRadioWithTooltip:Qn})}}class Rn extends fe{constructor(){super(...arguments);x(this,"title",'{{t("Delete record")}}');x(this,"type","destroy");x(this,"group","collection");x(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: "${m}" })}}`);x(this,"fieldset",{collection:be,params:{type:"object",properties:{filter:A(w({},Pe),{"x-validator"(o){return Ke(o)?"":E("Please add at least one condition")}})}}});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});x(this,"components",{FilterDynamicComponent:Ze})}}function er(){const e=a.useAPIClient(),t=P.useForm(),{field:o,__parent:n}=a.useBlockRequestContext(),{setVisible:s}=a.useActionContext(),i=le.useNavigate(),l=P.useFieldSchema(),c=P.useField(),u=a.useCompile(),{modal:d}=y.App.useApp(),f=a.useCollectValuesToSubmit(),v=c.componentProps.filterKeys||[];return{onClick(){return K(this,null,function*(){var M,O,B;const{onSuccess:h,skipValidator:p,triggerWorkflows:C}=(M=l==null?void 0:l["x-action-settings"])!=null?M:{};p||(yield t.submit());const F=yield f();c.data=o.data||{},c.data.loading=!0;try{const z=yield e.resource("workflows").trigger({values:F,filterKeys:v,triggerWorkflows:C!=null&&C.length?C.map(H=>[H.workflowKey,H.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.loading=!1,c.data.data=z,(B=(O=n==null?void 0:n.service)==null?void 0:O.refresh)==null||B.call(O),s==null||s(!1),!(h!=null&&h.successMessage))return;h!=null&&h.manualClose?d.success({title:u(h==null?void 0:h.successMessage),onOk:()=>K(this,null,function*(){yield t.reset(),h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(ue.isURL(h.redirectTo)?window.location.href=h.redirectTo:i(h.redirectTo))})}):y.message.success(u(h==null?void 0:h.successMessage))}catch(z){c.data.loading=!1}})}}}class ce extends a.Plugin{constructor(){super(...arguments);x(this,"triggers",new ue.Registry);x(this,"instructions",new ue.Registry);x(this,"getTriggersOptions",()=>Array.from(this.triggers.getEntities()).map(i=>{var[o,l]=i,c=l,{title:n}=c,s=_(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 fe)this.instructions.register(o,n);else throw new TypeError("invalid instruction type to register")}load(){return K(this,null,function*(){this.addRoutes(),this.addScopes(),this.addComponents(),this.app.pluginSettingsManager.add(m,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:bn,aclSnippet:"pm.workflow.workflows"}),this.registerTrigger("collection",Cn),this.registerTrigger("schedule",Wn),this.registerInstruction("calculation",zn),this.registerInstruction("condition",Gn),this.registerInstruction("end",qn),this.registerInstruction("query",_n),this.registerInstruction("create",Zn),this.registerInstruction("update",Xn),this.registerInstruction("destroy",Rn)})}addScopes(){this.app.addScopes({useTriggerWorkflowsActionProps:er})}addComponents(){this.app.addComponents({WorkflowPage:Qt,ExecutionPage:Gt})}addRoutes(){this.app.router.add("admin.workflow.workflows.id",{path:Oe(":id"),element:r.jsx(Qt,{})}),this.app.router.add("admin.workflow.executions.id",{path:At(":id"),element:r.jsx(Gt,{})})}}g.BaseTypeSets=qe,g.Branch=Ge,g.CollectionBlockInitializer=Ne,g.EXECUTION_STATUS=ae,g.ExecutionStatusOptions=He,g.ExecutionStatusOptionsMap=Ue,g.FieldsSelect=Ot,g.FilterDynamicComponent=Ze,g.FlowContext=Je,g.Instruction=fe,g.JOB_STATUS=re,g.JobButton=jt,g.JobStatusOptions=mt,g.JobStatusOptionsMap=Ye,g.Node=Bt,g.NodeContext=ft,g.NodeDefaultView=ht,g.RadioWithTooltip=Ie,g.RemoveButton=Vt,g.Trigger=yt,g.ValueBlock=Me,g.WorkflowVariableInput=Ut,g.WorkflowVariableJSON=Xo,g.WorkflowVariableRawTextArea=Qo,g.WorkflowVariableTextArea=Ct,g.default=ce,g.defaultFieldNames=ke,g.getCollectionFieldOptions=Se,g.isValidFilter=Ke,g.linkNodes=kt,g.nodesOptions=Lt,g.scopeOptions=zt,g.systemOptions=Jt,g.traverseSchema=St,g.triggerOptions=Wt,g.useAvailableUpstreams=Mt,g.useFlowContext=Z,g.useGetAriaLabelOfAddButton=pt,g.useNodeContext=Ce,g.useStyles=te,g.useTrigger=gt,g.useUpstreamScopes=Pt,g.useWorkflowVariableOptions=he,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
553
+ `,children:[r.jsx(a.Variable.Input,{scope:f,value:e[O.name],changeOnSelect:!0,onChange:$=>{o(A(w({},e),{[O.name]:$}))},children:r.jsx(a.SchemaComponent,{schema:{type:"void",properties:{[O.name]:{"x-component":B,"x-validator"(){return""}}}}})}),F?null:r.jsx(y.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx(T.CloseCircleOutlined,{}),onClick:()=>{var S;const I=e,{[S=O.name]:$}=I,N=_(I,[Bo(S)]);o(N)}})]},O.name)}),C.length?r.jsx(y.Dropdown,{menu:M,children:r.jsx(y.Button,{icon:r.jsx(T.PlusOutlined,{}),children:i("Add field")})}):null]}):r.jsx("p",{style:{color:s.colorText},children:D("Please select collection first")})})},{displayName:"CollectionFieldSet"});class Zn extends fe{constructor(){super(...arguments);x(this,"title",`{{t("Create record", { ns: "${p}" })}}`);x(this,"type","create");x(this,"group","collection");x(this,"description",`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${p}" })}}`);x(this,"fieldset",{collection:be,params:{type:"object",properties:{values:Rt,appends:Be}}});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});x(this,"components",{CollectionFieldset:xo})}useVariables({key:o,title:n,config:s},i){var d,f;const l=a.useCompile(),{getCollectionFields:c}=a.useCollectionManager(),[u]=Se(A(w({appends:[o,...((f=(d=s.params)==null?void 0:d.appends)==null?void 0:f.map(v=>`${o}.${v}`))||[]]},i),{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:Ne,collection:o.config.collection,dataSource:`{{$jobsMapByNodeKey.${o.key}}}`}:null}}function Qn(o){var n=o,{onChange:e}=n,t=_(n,["onChange"]);const{getCollectionFields:s}=a.useCollectionManager(),i=P.useForm(),{collection:l}=i.values,c=s(l),u=P.useField();function d({target:f}){const v=u.query(".values").take();if(!v)return;const k=c.reduce((h,m)=>(m.name in v.value&&(f.value||!["hasOne","hasMany","belongsToMany"].includes(m.type))&&(h[m.name]=v.value[m.name]),h),{});i.setValuesIn("params.values",k),e(f.value)}return r.jsx(Ie,A(w({},t),{onChange:d}))}class Xn extends fe{constructor(){super(...arguments);x(this,"title",`{{t("Update record", { ns: "${p}" })}}`);x(this,"type","update");x(this,"group","collection");x(this,"description",`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${p}" })}}`);x(this,"fieldset",{collection:be,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:A(w({},Pe),{title:`{{t("Only update records matching conditions", { ns: "${p}" })}}`,"x-validator"(o){return Ke(o)?"":D("Please add at least one condition")}}),values:A(w({},Rt),{"x-component-props":{filter(o){var n;return((n=this.params)==null?void 0:n.individualHooks)||!["hasOne","hasMany","belongsToMany"].includes(o.type)}}})}}});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});x(this,"components",{FilterDynamicComponent:Ze,CollectionFieldset:xo,IndividualHooksRadioWithTooltip:Qn})}}class Rn extends fe{constructor(){super(...arguments);x(this,"title",'{{t("Delete record")}}');x(this,"type","destroy");x(this,"group","collection");x(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}" })}}`);x(this,"fieldset",{collection:be,params:{type:"object",properties:{filter:A(w({},Pe),{"x-validator"(o){return Ke(o)?"":D("Please add at least one condition")}})}}});x(this,"scope",{useCollectionDataSource:a.useCollectionDataSource});x(this,"components",{FilterDynamicComponent:Ze})}}function er(){const e=a.useAPIClient(),t=P.useForm(),{field:o,__parent:n}=a.useBlockRequestContext(),{setVisible:s}=a.useActionContext(),i=le.useNavigate(),l=P.useFieldSchema(),c=P.useField(),u=a.useCompile(),{modal:d}=y.App.useApp(),f=a.useCollectValuesToSubmit(),v=c.componentProps.filterKeys||[];return{onClick(){return K(this,null,function*(){var M,O,B;const{onSuccess:h,skipValidator:m,triggerWorkflows:C}=(M=l==null?void 0:l["x-action-settings"])!=null?M:{};m||(yield t.submit());const F=yield f();c.data=o.data||{},c.data.loading=!0;try{const z=yield e.resource("workflows").trigger({values:F,filterKeys:v,triggerWorkflows:C!=null&&C.length?C.map(H=>[H.workflowKey,H.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.loading=!1,c.data.data=z,(B=(O=n==null?void 0:n.service)==null?void 0:O.refresh)==null||B.call(O),s==null||s(!1),!(h!=null&&h.successMessage))return;h!=null&&h.manualClose?d.success({title:u(h==null?void 0:h.successMessage),onOk:()=>K(this,null,function*(){yield t.reset(),h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(ue.isURL(h.redirectTo)?window.location.href=h.redirectTo:i(h.redirectTo))})}):y.message.success(u(h==null?void 0:h.successMessage))}catch(z){c.data.loading=!1}})}}}class ce extends a.Plugin{constructor(){super(...arguments);x(this,"triggers",new ue.Registry);x(this,"instructions",new ue.Registry);x(this,"getTriggersOptions",()=>Array.from(this.triggers.getEntities()).map(i=>{var[o,l]=i,c=l,{title:n}=c,s=_(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 fe)this.instructions.register(o,n);else throw new TypeError("invalid instruction type to register")}load(){return K(this,null,function*(){this.addRoutes(),this.addScopes(),this.addComponents(),this.app.pluginSettingsManager.add(p,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${p}" })}}`,Component:bn,aclSnippet:"pm.workflow.workflows"}),this.registerTrigger("collection",Cn),this.registerTrigger("schedule",Wn),this.registerInstruction("calculation",zn),this.registerInstruction("condition",Gn),this.registerInstruction("end",qn),this.registerInstruction("query",_n),this.registerInstruction("create",Zn),this.registerInstruction("update",Xn),this.registerInstruction("destroy",Rn)})}addScopes(){this.app.addScopes({useTriggerWorkflowsActionProps:er})}addComponents(){this.app.addComponents({WorkflowPage:Qt,ExecutionPage:Gt})}addRoutes(){this.app.router.add("admin.workflow.workflows.id",{path:Oe(":id"),element:r.jsx(Qt,{})}),this.app.router.add("admin.workflow.executions.id",{path:At(":id"),element:r.jsx(Gt,{})})}}g.BaseTypeSets=qe,g.Branch=Ge,g.CollectionBlockInitializer=Ne,g.EXECUTION_STATUS=ae,g.ExecutionStatusOptions=He,g.ExecutionStatusOptionsMap=Ue,g.FieldsSelect=Ot,g.FilterDynamicComponent=Ze,g.FlowContext=Je,g.Instruction=fe,g.JOB_STATUS=re,g.JobButton=jt,g.JobStatusOptions=mt,g.JobStatusOptionsMap=Ye,g.Node=Bt,g.NodeContext=ft,g.NodeDefaultView=ht,g.RadioWithTooltip=Ie,g.RemoveButton=Vt,g.Trigger=yt,g.ValueBlock=Me,g.WorkflowVariableInput=Ut,g.WorkflowVariableJSON=Xo,g.WorkflowVariableRawTextArea=Qo,g.WorkflowVariableTextArea=Ct,g.default=ce,g.defaultFieldNames=ke,g.getCollectionFieldOptions=Se,g.isValidFilter=Ke,g.linkNodes=kt,g.nodesOptions=Lt,g.scopeOptions=zt,g.systemOptions=Jt,g.traverseSchema=St,g.triggerOptions=Wt,g.useAvailableUpstreams=Mt,g.useFlowContext=Z,g.useGetAriaLabelOfAddButton=pt,g.useNodeContext=Ce,g.useStyles=te,g.useTrigger=gt,g.useUpstreamScopes=Pt,g.useWorkflowVariableOptions=he,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -2,21 +2,21 @@ 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.19.0-alpha.4",
5
+ "@nocobase/client": "0.19.0-alpha.5",
6
6
  "react-router-dom": "6.21.0",
7
- "@nocobase/utils": "0.19.0-alpha.4",
7
+ "@nocobase/utils": "0.19.0-alpha.5",
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.19.0-alpha.4",
12
- "@nocobase/server": "0.19.0-alpha.4",
13
- "@nocobase/logger": "0.19.0-alpha.4",
14
- "@nocobase/evaluators": "0.19.0-alpha.4",
11
+ "@nocobase/database": "0.19.0-alpha.5",
12
+ "@nocobase/server": "0.19.0-alpha.5",
13
+ "@nocobase/logger": "0.19.0-alpha.5",
14
+ "@nocobase/evaluators": "0.19.0-alpha.5",
15
15
  "lodash": "4.17.21",
16
16
  "@formily/antd-v5": "1.1.9",
17
- "@nocobase/actions": "0.19.0-alpha.4",
17
+ "@nocobase/actions": "0.19.0-alpha.5",
18
18
  "sequelize": "6.35.2",
19
- "@nocobase/plugin-workflow-test": "0.19.0-alpha.4",
20
- "@nocobase/test": "0.19.0-alpha.4",
19
+ "@nocobase/plugin-workflow-test": "0.19.0-alpha.5",
20
+ "@nocobase/test": "0.19.0-alpha.5",
21
21
  "dayjs": "1.11.10"
22
22
  };
@@ -27,6 +27,14 @@
27
27
  "Trigger time": "触发时间",
28
28
  "Triggered at": "触发时间",
29
29
 
30
+ "Execute mode": "执行模式",
31
+ "Execute workflow asynchronously or synchronously based on trigger type, and could not be changed after created.": "基于触发类型异步或同步执行工作流,创建后不可更改。",
32
+ "Asynchronously": "异步",
33
+ "Synchronously": "同步",
34
+ "Will be executed in the background as a queued task.": "将作为队列任务在后台执行。",
35
+ "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.":
36
+ "适用于需要即时反馈的用户操作。不能在此模式下使用异步节点,并且不建议在同步模式下执行耗时的操作。",
37
+
30
38
  "Bind workflows": "绑定工作流",
31
39
  "Workflow will be triggered after submitting succeeded.": "提交成功后触发工作流。",
32
40
  "Workflow will be triggered after saving succeeded.": "保存成功后触发工作流。",
@@ -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-01-26T14:15:53.300Z"}
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-01-30T09:21:20.958Z"}
@@ -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-01-26T14:15:52.969Z"}
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-01-30T09:21:20.626Z"}
@@ -240,7 +240,7 @@ class PluginWorkflowServer extends import_server.Plugin {
240
240
  this.getLogger(workflow.id).error(`trigger type ${workflow.type} of workflow ${workflow.id} is not implemented`);
241
241
  return;
242
242
  }
243
- if (typeof enable !== "undefined" ? enable : workflow.get("enabled")) {
243
+ if (enable ?? workflow.get("enabled")) {
244
244
  const prev = workflow.previous();
245
245
  if (prev.config) {
246
246
  trigger.off({ ...workflow.get(), ...prev });
@@ -304,22 +304,15 @@ class PluginWorkflowServer extends import_server.Plugin {
304
304
  return new import_Processor.default(execution, { ...options, plugin: this });
305
305
  }
306
306
  async createExecution(workflow, context, options) {
307
- var _a;
308
- if ((_a = options.context) == null ? void 0 : _a.executionId) {
309
- const existed = await workflow.countExecutions({
310
- where: {
311
- id: options.context.executionId
312
- },
313
- transaction: options.transaction
314
- });
315
- if (existed) {
316
- this.getLogger(workflow.id).warn(
317
- `workflow ${workflow.id} has already been triggered in same execution (${options.context.executionId}), and newly triggering will be skipped.`
318
- );
319
- return null;
307
+ const { transaction = await this.db.sequelize.transaction() } = options;
308
+ const trigger = this.triggers.get(workflow.type);
309
+ const valid = await trigger.validateEvent(workflow, context, { ...options, transaction });
310
+ if (!valid) {
311
+ if (!options.transaction) {
312
+ await transaction.commit();
320
313
  }
314
+ return null;
321
315
  }
322
- const { transaction = await this.db.sequelize.transaction() } = options;
323
316
  const execution = await workflow.createExecution(
324
317
  {
325
318
  context,
@@ -351,6 +344,9 @@ class PluginWorkflowServer extends import_server.Plugin {
351
344
  return execution;
352
345
  }
353
346
  prepare = async () => {
347
+ if (this.executing && this.db.options.dialect === "sqlite") {
348
+ await this.executing;
349
+ }
354
350
  const event = this.events.shift();
355
351
  this.eventsCount = this.events.length;
356
352
  if (!event) {
@@ -361,7 +357,7 @@ class PluginWorkflowServer extends import_server.Plugin {
361
357
  logger.info(`preparing execution for event`);
362
358
  try {
363
359
  const execution = await this.createExecution(...event);
364
- if (!this.executing && !this.pending.length) {
360
+ if (execution && !this.executing && !this.pending.length) {
365
361
  this.pending.push([execution]);
366
362
  }
367
363
  } catch (err) {
@@ -382,6 +378,9 @@ class PluginWorkflowServer extends import_server.Plugin {
382
378
  this.getLogger("dispatcher").warn(`workflow executing is not finished, new dispatching will be ignored`);
383
379
  return;
384
380
  }
381
+ if (this.events.length) {
382
+ return this.prepare();
383
+ }
385
384
  this.executing = (async () => {
386
385
  let next = null;
387
386
  if (this.pending.length) {
@@ -32,7 +32,7 @@ class CreateInstruction extends import__.Instruction {
32
32
  const created = await repository.create({
33
33
  ...options,
34
34
  context: {
35
- executionId: processor.execution.id
35
+ stack: Array.from(new Set((processor.execution.context.stack ?? []).concat(processor.execution.id)))
36
36
  },
37
37
  transaction: processor.transaction
38
38
  });
@@ -31,7 +31,7 @@ class DestroyInstruction extends import__.Instruction {
31
31
  const result = await repo.destroy({
32
32
  ...options,
33
33
  context: {
34
- executionId: processor.execution.id
34
+ stack: Array.from(new Set((processor.execution.context.stack ?? []).concat(processor.execution.id)))
35
35
  },
36
36
  transaction: processor.transaction
37
37
  });
@@ -2,7 +2,5 @@ import Instruction from '.';
2
2
  import Processor from '../Processor';
3
3
  import { FlowNodeModel } from '../types';
4
4
  export default class extends Instruction {
5
- run(node: FlowNodeModel, prevJob: any, processor: Processor): Promise<{
6
- status: number;
7
- }>;
5
+ run(node: FlowNodeModel, prevJob: any, processor: Processor): Promise<any>;
8
6
  }
@@ -34,9 +34,13 @@ var import__ = __toESM(require("."));
34
34
  var import_constants = require("../constants");
35
35
  class EndInstruction_default extends import__.default {
36
36
  async run(node, prevJob, processor) {
37
- const { endStatus } = node.config;
38
- return {
39
- status: endStatus ?? import_constants.JOB_STATUS.RESOLVED
40
- };
37
+ const { endStatus = import_constants.JOB_STATUS.RESOLVED } = node.config;
38
+ await processor.saveJob({
39
+ status: endStatus,
40
+ nodeId: node.id,
41
+ nodeKey: node.key,
42
+ upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
43
+ });
44
+ return processor.exit(endStatus);
41
45
  }
42
46
  }
@@ -31,7 +31,7 @@ class UpdateInstruction extends import__.Instruction {
31
31
  const result = await repo.update({
32
32
  ...options,
33
33
  context: {
34
- executionId: processor.execution.id
34
+ stack: Array.from(new Set((processor.execution.context.stack ?? []).concat(processor.execution.id)))
35
35
  },
36
36
  transaction: processor.transaction
37
37
  });
@@ -26,7 +26,6 @@ class add_node_key_to_job_default extends import_server.Migration {
26
26
  on = "afterSync";
27
27
  async up() {
28
28
  const { db } = this.context;
29
- const PluginModel = db.getModel("applicationPlugins");
30
29
  const JobRepo = db.getRepository("jobs");
31
30
  await db.sequelize.transaction(async (transaction) => {
32
31
  const jobs = await JobRepo.find({
@@ -1,3 +1,4 @@
1
+ import { Transactionable } from '@nocobase/database';
1
2
  import Trigger from '.';
2
3
  import type { WorkflowModel } from '../types';
3
4
  export interface CollectionChangeTriggerConfig {
@@ -9,4 +10,9 @@ export default class CollectionTrigger extends Trigger {
9
10
  events: Map<any, any>;
10
11
  on(workflow: WorkflowModel): void;
11
12
  off(workflow: WorkflowModel): void;
13
+ validateEvent(workflow: WorkflowModel, context: any, options: {
14
+ context?: {
15
+ stack?: number[];
16
+ };
17
+ } & Transactionable): Promise<boolean>;
12
18
  }
@@ -151,4 +151,23 @@ class CollectionTrigger extends import__.default {
151
151
  }
152
152
  }
153
153
  }
154
+ async validateEvent(workflow, context, options) {
155
+ var _a;
156
+ if ((_a = options.context) == null ? void 0 : _a.stack) {
157
+ const existed = await workflow.countExecutions({
158
+ where: {
159
+ id: options.context.stack
160
+ },
161
+ transaction: options.transaction
162
+ });
163
+ if (existed) {
164
+ this.workflow.getLogger(workflow.id).warn(
165
+ `workflow ${workflow.id} has already been triggered in stack executions (${options.context.stack}), and newly triggering will be skipped.`
166
+ );
167
+ return false;
168
+ }
169
+ context.stack = options.context.stack;
170
+ }
171
+ return true;
172
+ }
154
173
  }
@@ -6,6 +6,7 @@ export declare abstract class Trigger {
6
6
  constructor(workflow: Plugin);
7
7
  abstract on(workflow: WorkflowModel): void;
8
8
  abstract off(workflow: WorkflowModel): void;
9
+ validateEvent(workflow: WorkflowModel, context: any, options: Transactionable): boolean | Promise<boolean>;
9
10
  duplicateConfig?(workflow: WorkflowModel, options: Transactionable): object | Promise<object>;
10
11
  sync?: boolean;
11
12
  }
@@ -25,6 +25,9 @@ class Trigger {
25
25
  constructor(workflow) {
26
26
  this.workflow = workflow;
27
27
  }
28
+ validateEvent(workflow, context, options) {
29
+ return true;
30
+ }
28
31
  sync;
29
32
  }
30
33
  var triggers_default = Trigger;
package/package.json CHANGED
@@ -4,11 +4,11 @@
4
4
  "displayName.zh-CN": "工作流",
5
5
  "description": "A powerful workflow plugin designed to support business process management and automation.",
6
6
  "description.zh-CN": "工作流插件,为业务流程管理和自动化提供支持。",
7
- "version": "0.19.0-alpha.4",
7
+ "version": "0.19.0-alpha.5",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "dependencies": {
11
- "@nocobase/plugin-workflow-test": "0.19.0-alpha.4"
11
+ "@nocobase/plugin-workflow-test": "0.19.0-alpha.5"
12
12
  },
13
13
  "devDependencies": {
14
14
  "@ant-design/icons": "5.x",
@@ -43,5 +43,5 @@
43
43
  "@nocobase/test": "0.x",
44
44
  "@nocobase/utils": "0.x"
45
45
  },
46
- "gitHead": "9583023f7bea828da5192384a5c002782c341b65"
46
+ "gitHead": "580eca25451ec731d17ddef285d0b8c52c48d501"
47
47
  }