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